Skip to content

Commit

Permalink
implement support checks
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcosmonaut committed Apr 11, 2024
1 parent ae97c2f commit 537549d
Showing 1 changed file with 64 additions and 13 deletions.
77 changes: 64 additions & 13 deletions src/FNA3D_Driver_SDL.c
Original file line number Diff line number Diff line change
Expand Up @@ -3630,48 +3630,74 @@ static int32_t SDLGPU_QueryPixelCount(
return (int32_t) pixelCount;
}

/* Support Checks */

static uint8_t SDLGPU_SupportsDXT1(FNA3D_Renderer *driverData)
{
/* TODO */
return 1;
SDLGPU_Renderer *renderer = (SDLGPU_Renderer*) driverData;
return SDL_GpuIsTextureFormatSupported(
renderer->device,
SDL_GPU_TEXTUREFORMAT_BC1,
SDL_GPU_TEXTURETYPE_2D,
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT | SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT
);
}

static uint8_t SDLGPU_SupportsS3TC(FNA3D_Renderer *driverData)
{
/* TODO */
return 1;
SDLGPU_Renderer *renderer = (SDLGPU_Renderer*) driverData;
return
SDL_GpuIsTextureFormatSupported(
renderer->device,
SDL_GPU_TEXTUREFORMAT_BC2,
SDL_GPU_TEXTURETYPE_2D,
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT | SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT
) ||
SDL_GpuIsTextureFormatSupported(
renderer->device,
SDL_GPU_TEXTUREFORMAT_BC3,
SDL_GPU_TEXTURETYPE_2D,
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT | SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT
);
}

static uint8_t SDLGPU_SupportsBC7(FNA3D_Renderer *driverData)
{
/* TODO */
return 1;
SDLGPU_Renderer *renderer = (SDLGPU_Renderer*) driverData;
return SDL_GpuIsTextureFormatSupported(
renderer->device,
SDL_GPU_TEXTUREFORMAT_BC7,
SDL_GPU_TEXTURETYPE_2D,
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT | SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT
);
}

static uint8_t SDLGPU_SupportsHardwareInstancing(FNA3D_Renderer *driverData)
{
/* TODO */
return 1;
}

static uint8_t SDLGPU_SupportsNoOverwrite(FNA3D_Renderer *driverData)
{
/* TODO */
return 1;
}

static uint8_t SDLGPU_SupportsSRGBRenderTargets(FNA3D_Renderer *driverData)
{
/* TODO */
return 1;
SDLGPU_Renderer *renderer = (SDLGPU_Renderer*) driverData;
return SDL_GpuIsTextureFormatSupported(
renderer->device,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SRGB,
SDL_GPU_TEXTURETYPE_2D,
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT | SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT
);
}

static void SDLGPU_GetMaxTextureSlots(
FNA3D_Renderer *driverData,
int32_t *textures,
int32_t *vertexTextures
) {
/* TODO */
*textures = MAX_TEXTURE_SAMPLERS;
*vertexTextures = MAX_VERTEXTEXTURE_SAMPLERS;
}
Expand All @@ -3681,8 +3707,33 @@ static int32_t SDLGPU_GetMaxMultiSampleCount(
FNA3D_SurfaceFormat format,
int32_t multiSampleCount
) {
/* TODO */
return 8;
SDLGPU_Renderer *renderer = (SDLGPU_Renderer*) driverData;

SDL_GpuSampleCount sampleCount =
SDL_GpuGetBestSampleCount(
renderer->device,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8,
SDL_GPU_SAMPLECOUNT_8
);

switch (sampleCount)
{
case SDL_GPU_SAMPLECOUNT_1:
return 1;

case SDL_GPU_SAMPLECOUNT_2:
return 2;

case SDL_GPU_SAMPLECOUNT_4:
return 4;

case SDL_GPU_SAMPLECOUNT_8:
return 8;

default:
FNA3D_LogError("Unrecognized sample count value!");
return 1;
}
}

/* Debugging */
Expand Down

0 comments on commit 537549d

Please sign in to comment.