From 4bd75140169f38bb027a0851e18dff290da525cb Mon Sep 17 00:00:00 2001 From: Caleb Cornett Date: Tue, 20 Aug 2024 20:39:13 -0500 Subject: [PATCH] Clean up texture format naming + document sampler/color/depth support --- include/SDL3/SDL_gpu.h | 98 +++++++++++++++--------- src/gpu/SDL_gpu.c | 46 ++++++------ src/gpu/SDL_sysgpu.h | 70 ++++++++--------- src/gpu/d3d11/SDL_gpu_d3d11.c | 62 +++++++-------- src/gpu/d3d12/SDL_gpu_d3d12.c | 60 +++++++-------- src/gpu/metal/SDL_gpu_metal.m | 129 +++++++++++++++----------------- src/gpu/vulkan/SDL_gpu_vulkan.c | 64 ++++++++-------- 7 files changed, 274 insertions(+), 255 deletions(-) diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 7c80eb032c9c21..cc50b834c012cf 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -78,36 +78,70 @@ typedef enum SDL_GpuIndexElementSize SDL_GPU_INDEXELEMENTSIZE_32BIT } SDL_GpuIndexElementSize; +/* Texture format support varies depending on driver, hardware, and usage flags. + * In general, you should use SDL_GpuSupportsTextureFormat to query if a format + * is supported before using it. However, there are a few guaranteed formats. + * + * For SAMPLER usage, the following formats are universally supported: + * - R8G8B8A8_UNORM + * - B8G8R8A8_UNORM + * - R8_UNORM + * - R8G8_SNORM + * - R8G8B8A8_SNORM + * - R16_FLOAT + * - R16G16_FLOAT + * - R16G16B16A16_FLOAT + * - R32_FLOAT + * - R32G32_FLOAT + * - R32G32B32A32_FLOAT + * - R8G8B8A8_UNORM_SRGB + * - B8G8R8A8_UNORM_SRGB + * - D16_UNORM + * + * No formats are universally supported for COLOR_TARGET usage. + * When in doubt, you can always use the swapchain format via SDL_GpuGetSwapchainTextureFormat. + * + * For DEPTH_STENCIL_TARGET usage, the following formats are universally supported: + * - D16_UNORM + * - Either D24_UNORM or D32_SFLOAT + * - Either D24_UNORM_S8_UINT or D32_SFLOAT_S8_UINT + * + * Unless D16_UNORM is sufficient for your purposes, always check which + * of D24/D32 is supported before creating a depth-stencil texture! + * + * FIXME: Which formats are supported for storage usage? + * + */ typedef enum SDL_GpuTextureFormat { SDL_GPU_TEXTUREFORMAT_INVALID = -1, /* Unsigned Normalized Float Color Formats */ - SDL_GPU_TEXTUREFORMAT_R8G8B8A8, - SDL_GPU_TEXTUREFORMAT_B8G8R8A8, - SDL_GPU_TEXTUREFORMAT_B5G6R5, - SDL_GPU_TEXTUREFORMAT_B5G5R5A1, - SDL_GPU_TEXTUREFORMAT_B4G4R4A4, - SDL_GPU_TEXTUREFORMAT_R10G10B10A2, - SDL_GPU_TEXTUREFORMAT_R16G16, - SDL_GPU_TEXTUREFORMAT_R16G16B16A16, - SDL_GPU_TEXTUREFORMAT_R8, - SDL_GPU_TEXTUREFORMAT_A8, + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM, + SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM, + SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM, + SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM, + SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM, + SDL_GPU_TEXTUREFORMAT_R16G16_UNORM, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM, + SDL_GPU_TEXTUREFORMAT_R8_UNORM, + SDL_GPU_TEXTUREFORMAT_A8_UNORM, /* Compressed Unsigned Normalized Float Color Formats */ - SDL_GPU_TEXTUREFORMAT_BC1, - SDL_GPU_TEXTUREFORMAT_BC2, - SDL_GPU_TEXTUREFORMAT_BC3, - SDL_GPU_TEXTUREFORMAT_BC7, + SDL_GPU_TEXTUREFORMAT_BC1_UNORM, + SDL_GPU_TEXTUREFORMAT_BC2_UNORM, + SDL_GPU_TEXTUREFORMAT_BC3_UNORM, + SDL_GPU_TEXTUREFORMAT_BC7_UNORM, /* Signed Normalized Float Color Formats */ SDL_GPU_TEXTUREFORMAT_R8G8_SNORM, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM, /* Signed Float Color Formats */ - SDL_GPU_TEXTUREFORMAT_R16_SFLOAT, - SDL_GPU_TEXTUREFORMAT_R16G16_SFLOAT, - SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT, - SDL_GPU_TEXTUREFORMAT_R32_SFLOAT, - SDL_GPU_TEXTUREFORMAT_R32G32_SFLOAT, - SDL_GPU_TEXTUREFORMAT_R32G32B32A32_SFLOAT, + SDL_GPU_TEXTUREFORMAT_R16_FLOAT, + SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT, + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT, + SDL_GPU_TEXTUREFORMAT_R32_FLOAT, + SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT, + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT, /* Unsigned Integer Color Formats */ SDL_GPU_TEXTUREFORMAT_R8_UINT, SDL_GPU_TEXTUREFORMAT_R8G8_UINT, @@ -115,18 +149,18 @@ typedef enum SDL_GpuTextureFormat SDL_GPU_TEXTUREFORMAT_R16_UINT, SDL_GPU_TEXTUREFORMAT_R16G16_UINT, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT, - /* SRGB Color Formats */ - SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SRGB, - SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB, - /* Compressed SRGB Color Formats */ - SDL_GPU_TEXTUREFORMAT_BC3_SRGB, - SDL_GPU_TEXTUREFORMAT_BC7_SRGB, + /* SRGB Unsigned Normalized Color Formats */ + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, + /* Compressed SRGB Unsigned Normalized Color Formats */ + SDL_GPU_TEXTUREFORMAT_BC3_UNORM_SRGB, + SDL_GPU_TEXTUREFORMAT_BC7_UNORM_SRGB, /* Depth Formats */ SDL_GPU_TEXTUREFORMAT_D16_UNORM, SDL_GPU_TEXTUREFORMAT_D24_UNORM, - SDL_GPU_TEXTUREFORMAT_D32_SFLOAT, + SDL_GPU_TEXTUREFORMAT_D32_FLOAT, SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT, - SDL_GPU_TEXTUREFORMAT_D32_SFLOAT_S8_UINT + SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT } SDL_GpuTextureFormat; typedef enum SDL_GpuTextureUsageFlagBits @@ -1079,14 +1113,6 @@ extern SDL_DECLSPEC SDL_GpuShader *SDLCALL SDL_GpuCreateShader( * If you request a sample count higher than the hardware supports, * the implementation will automatically fall back to the highest available sample count. * - * For depth textures, the hardware support matrix looks as follows: - * - D16_UNORM is guaranteed to always be supported. - * - It's guaranteed that either D24_UNORM or D32_SFLOAT will be supported. - * - It's guaranteed that either D24_UNORM_S8_UINT or D32_SFLOAT_S8_UINT will be supported. - * Therefore, unless D16 is sufficient for your purposes, you should always call - * SDL_GpuSupportsTextureFormat to determine which of D24/D32 are supported by the GPU - * before creating a depth texture. - * * \param device a GPU Context * \param textureCreateInfo a struct describing the state of the texture to create * \returns a texture object on success, or NULL on failure diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 408ec25449873e..8f490a19d3b488 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -495,43 +495,43 @@ Uint32 SDL_GpuTextureFormatTexelBlockSize( SDL_GpuTextureFormat textureFormat) { switch (textureFormat) { - case SDL_GPU_TEXTUREFORMAT_BC1: + case SDL_GPU_TEXTUREFORMAT_BC1_UNORM: return 8; - case SDL_GPU_TEXTUREFORMAT_BC2: - case SDL_GPU_TEXTUREFORMAT_BC3: - case SDL_GPU_TEXTUREFORMAT_BC7: - case SDL_GPU_TEXTUREFORMAT_BC3_SRGB: - case SDL_GPU_TEXTUREFORMAT_BC7_SRGB: + case SDL_GPU_TEXTUREFORMAT_BC2_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC3_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC7_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC3_UNORM_SRGB: + case SDL_GPU_TEXTUREFORMAT_BC7_UNORM_SRGB: return 16; - case SDL_GPU_TEXTUREFORMAT_R8: - case SDL_GPU_TEXTUREFORMAT_A8: + case SDL_GPU_TEXTUREFORMAT_R8_UNORM: + case SDL_GPU_TEXTUREFORMAT_A8_UNORM: case SDL_GPU_TEXTUREFORMAT_R8_UINT: return 1; - case SDL_GPU_TEXTUREFORMAT_B5G6R5: - case SDL_GPU_TEXTUREFORMAT_B4G4R4A4: - case SDL_GPU_TEXTUREFORMAT_B5G5R5A1: - case SDL_GPU_TEXTUREFORMAT_R16_SFLOAT: + case SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM: + case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM: + case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM: + case SDL_GPU_TEXTUREFORMAT_R16_FLOAT: case SDL_GPU_TEXTUREFORMAT_R8G8_SNORM: case SDL_GPU_TEXTUREFORMAT_R8G8_UINT: case SDL_GPU_TEXTUREFORMAT_R16_UINT: return 2; - case SDL_GPU_TEXTUREFORMAT_R8G8B8A8: - case SDL_GPU_TEXTUREFORMAT_B8G8R8A8: - case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SRGB: - case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB: - case SDL_GPU_TEXTUREFORMAT_R32_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R16G16_SFLOAT: + case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM: + case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM: + case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB: + case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB: + case SDL_GPU_TEXTUREFORMAT_R32_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT: case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM: - case SDL_GPU_TEXTUREFORMAT_R10G10B10A2: + case SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM: case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT: case SDL_GPU_TEXTUREFORMAT_R16G16_UINT: return 4; - case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R16G16B16A16: - case SDL_GPU_TEXTUREFORMAT_R32G32_SFLOAT: + case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM: + case SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT: case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT: return 8; - case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_SFLOAT: + case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT: return 16; default: SDL_assert_release(!"Unrecognized TextureFormat!"); diff --git a/src/gpu/SDL_sysgpu.h b/src/gpu/SDL_sysgpu.h index 0de75c09e99351..254a468b1f56c6 100644 --- a/src/gpu/SDL_sysgpu.h +++ b/src/gpu/SDL_sysgpu.h @@ -73,39 +73,39 @@ static inline Sint32 Texture_GetBlockSize( SDL_GpuTextureFormat format) { switch (format) { - case SDL_GPU_TEXTUREFORMAT_BC1: - case SDL_GPU_TEXTUREFORMAT_BC2: - case SDL_GPU_TEXTUREFORMAT_BC3: - case SDL_GPU_TEXTUREFORMAT_BC7: - case SDL_GPU_TEXTUREFORMAT_BC3_SRGB: - case SDL_GPU_TEXTUREFORMAT_BC7_SRGB: + case SDL_GPU_TEXTUREFORMAT_BC1_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC2_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC3_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC7_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC3_UNORM_SRGB: + case SDL_GPU_TEXTUREFORMAT_BC7_UNORM_SRGB: return 4; - case SDL_GPU_TEXTUREFORMAT_R8G8B8A8: - case SDL_GPU_TEXTUREFORMAT_B8G8R8A8: - case SDL_GPU_TEXTUREFORMAT_B5G6R5: - case SDL_GPU_TEXTUREFORMAT_B5G5R5A1: - case SDL_GPU_TEXTUREFORMAT_B4G4R4A4: - case SDL_GPU_TEXTUREFORMAT_R10G10B10A2: - case SDL_GPU_TEXTUREFORMAT_R16G16: - case SDL_GPU_TEXTUREFORMAT_R16G16B16A16: - case SDL_GPU_TEXTUREFORMAT_R8: - case SDL_GPU_TEXTUREFORMAT_A8: + case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM: + case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM: + case SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM: + case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM: + case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM: + case SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM: + case SDL_GPU_TEXTUREFORMAT_R16G16_UNORM: + case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM: + case SDL_GPU_TEXTUREFORMAT_R8_UNORM: + case SDL_GPU_TEXTUREFORMAT_A8_UNORM: case SDL_GPU_TEXTUREFORMAT_R8G8_SNORM: case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM: - case SDL_GPU_TEXTUREFORMAT_R16_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R16G16_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R32_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R32G32_SFLOAT: - case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_SFLOAT: + case SDL_GPU_TEXTUREFORMAT_R16_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R32_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT: + case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT: case SDL_GPU_TEXTUREFORMAT_R8_UINT: case SDL_GPU_TEXTUREFORMAT_R8G8_UINT: case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT: case SDL_GPU_TEXTUREFORMAT_R16_UINT: case SDL_GPU_TEXTUREFORMAT_R16G16_UINT: case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT: - case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SRGB: - case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB: + case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB: + case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB: return 1; default: SDL_assert_release(!"Unrecognized TextureFormat!"); @@ -119,9 +119,9 @@ static inline SDL_bool IsDepthFormat( switch (format) { case SDL_GPU_TEXTUREFORMAT_D16_UNORM: case SDL_GPU_TEXTUREFORMAT_D24_UNORM: - case SDL_GPU_TEXTUREFORMAT_D32_SFLOAT: + case SDL_GPU_TEXTUREFORMAT_D32_FLOAT: case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT: - case SDL_GPU_TEXTUREFORMAT_D32_SFLOAT_S8_UINT: + case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT: return SDL_TRUE; default: @@ -134,7 +134,7 @@ static inline SDL_bool IsStencilFormat( { switch (format) { case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT: - case SDL_GPU_TEXTUREFORMAT_D32_SFLOAT_S8_UINT: + case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT: return SDL_TRUE; default: @@ -170,10 +170,10 @@ static inline Uint32 BytesPerRow( { Uint32 blocksPerRow = width; - if (format == SDL_GPU_TEXTUREFORMAT_BC1 || - format == SDL_GPU_TEXTUREFORMAT_BC2 || - format == SDL_GPU_TEXTUREFORMAT_BC3 || - format == SDL_GPU_TEXTUREFORMAT_BC7) { + if (format == SDL_GPU_TEXTUREFORMAT_BC1_UNORM || + format == SDL_GPU_TEXTUREFORMAT_BC2_UNORM || + format == SDL_GPU_TEXTUREFORMAT_BC3_UNORM || + format == SDL_GPU_TEXTUREFORMAT_BC7_UNORM) { blocksPerRow = (width + 3) / 4; } @@ -188,10 +188,10 @@ static inline Sint32 BytesPerImage( Uint32 blocksPerRow = width; Uint32 blocksPerColumn = height; - if (format == SDL_GPU_TEXTUREFORMAT_BC1 || - format == SDL_GPU_TEXTUREFORMAT_BC2 || - format == SDL_GPU_TEXTUREFORMAT_BC3 || - format == SDL_GPU_TEXTUREFORMAT_BC7) { + if (format == SDL_GPU_TEXTUREFORMAT_BC1_UNORM || + format == SDL_GPU_TEXTUREFORMAT_BC2_UNORM || + format == SDL_GPU_TEXTUREFORMAT_BC3_UNORM || + format == SDL_GPU_TEXTUREFORMAT_BC7_UNORM) { blocksPerRow = (width + 3) / 4; blocksPerColumn = (height + 3) / 4; } diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c index 49de7b9c6c925d..886435ed23b8d0 100644 --- a/src/gpu/d3d11/SDL_gpu_d3d11.c +++ b/src/gpu/d3d11/SDL_gpu_d3d11.c @@ -148,10 +148,10 @@ static void D3D11_INTERNAL_DestroyBlitPipelines(SDL_GpuRenderer *driverData); /* Conversions */ static SDL_GpuTextureFormat SwapchainCompositionToSDLTextureFormat[] = { - SDL_GPU_TEXTUREFORMAT_B8G8R8A8, /* SDR */ - SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB, /* SDR_SRGB */ - SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT, /* HDR */ - SDL_GPU_TEXTUREFORMAT_R10G10B10A2, /* HDR_ADVANCED */ + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM, /* SDR */ + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, /* SDR_SRGB */ + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT, /* HDR */ + SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM, /* HDR_ADVANCED */ }; static DXGI_FORMAT SwapchainCompositionToTextureFormat[] = { @@ -169,43 +169,43 @@ static DXGI_COLOR_SPACE_TYPE SwapchainCompositionToColorSpace[] = { }; static DXGI_FORMAT SDLToD3D11_TextureFormat[] = { - DXGI_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8 */ - DXGI_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8 */ - DXGI_FORMAT_B5G6R5_UNORM, /* B5G6R5 */ - DXGI_FORMAT_B5G5R5A1_UNORM, /* B5G5R5A1 */ - DXGI_FORMAT_B4G4R4A4_UNORM, /* B4G4R4A4 */ - DXGI_FORMAT_R10G10B10A2_UNORM, /* R10G10B10A2 */ - DXGI_FORMAT_R16G16_UNORM, /* R16G16 */ - DXGI_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16 */ - DXGI_FORMAT_R8_UNORM, /* R8 */ - DXGI_FORMAT_A8_UNORM, /* A8 */ - DXGI_FORMAT_BC1_UNORM, /* BC1 */ - DXGI_FORMAT_BC2_UNORM, /* BC2 */ - DXGI_FORMAT_BC3_UNORM, /* BC3 */ - DXGI_FORMAT_BC7_UNORM, /* BC7 */ + DXGI_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8_UNORM */ + DXGI_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8_UNORM */ + DXGI_FORMAT_B5G6R5_UNORM, /* B5G6R5_UNORM */ + DXGI_FORMAT_B5G5R5A1_UNORM, /* B5G5R5A1_UNORM */ + DXGI_FORMAT_B4G4R4A4_UNORM, /* B4G4R4A4_UNORM */ + DXGI_FORMAT_R10G10B10A2_UNORM, /* R10G10B10A2_UNORM */ + DXGI_FORMAT_R16G16_UNORM, /* R16G16_UNORM */ + DXGI_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16_UNORM */ + DXGI_FORMAT_R8_UNORM, /* R8_UNORM */ + DXGI_FORMAT_A8_UNORM, /* A8_UNORM */ + DXGI_FORMAT_BC1_UNORM, /* BC1_UNORM */ + DXGI_FORMAT_BC2_UNORM, /* BC2_UNORM */ + DXGI_FORMAT_BC3_UNORM, /* BC3_UNORM */ + DXGI_FORMAT_BC7_UNORM, /* BC7_UNORM */ DXGI_FORMAT_R8G8_SNORM, /* R8G8_SNORM */ DXGI_FORMAT_R8G8B8A8_SNORM, /* R8G8B8A8_SNORM */ - DXGI_FORMAT_R16_FLOAT, /* R16_SFLOAT */ - DXGI_FORMAT_R16G16_FLOAT, /* R16G16_SFLOAT */ - DXGI_FORMAT_R16G16B16A16_FLOAT, /* R16G16B16A16_SFLOAT */ - DXGI_FORMAT_R32_FLOAT, /* R32_SFLOAT */ - DXGI_FORMAT_R32G32_FLOAT, /* R32G32_SFLOAT */ - DXGI_FORMAT_R32G32B32A32_FLOAT, /* R32G32B32A32_SFLOAT */ + DXGI_FORMAT_R16_FLOAT, /* R16_FLOAT */ + DXGI_FORMAT_R16G16_FLOAT, /* R16G16_FLOAT */ + DXGI_FORMAT_R16G16B16A16_FLOAT, /* R16G16B16A16_FLOAT */ + DXGI_FORMAT_R32_FLOAT, /* R32_FLOAT */ + DXGI_FORMAT_R32G32_FLOAT, /* R32G32_FLOAT */ + DXGI_FORMAT_R32G32B32A32_FLOAT, /* R32G32B32A32_FLOAT */ DXGI_FORMAT_R8_UINT, /* R8_UINT */ DXGI_FORMAT_R8G8_UINT, /* R8G8_UINT */ DXGI_FORMAT_R8G8B8A8_UINT, /* R8G8B8A8_UINT */ DXGI_FORMAT_R16_UINT, /* R16_UINT */ DXGI_FORMAT_R16G16_UINT, /* R16G16_UINT */ DXGI_FORMAT_R16G16B16A16_UINT, /* R16G16B16A16_UINT */ - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, /* R8G8B8A8_SRGB */ - DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, /* B8G8R8A8_SRGB */ - DXGI_FORMAT_BC3_UNORM_SRGB, /* BC3_SRGB */ - DXGI_FORMAT_BC7_UNORM_SRGB, /* BC7_SRGB */ + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, /* R8G8B8A8_UNORM_SRGB */ + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, /* B8G8R8A8_UNORM_SRGB */ + DXGI_FORMAT_BC3_UNORM_SRGB, /* BC3_UNORM_SRGB */ + DXGI_FORMAT_BC7_UNORM_SRGB, /* BC7_UNORM_SRGB */ DXGI_FORMAT_D16_UNORM, /* D16_UNORM */ DXGI_FORMAT_D24_UNORM_S8_UINT, /* D24_UNORM */ - DXGI_FORMAT_D32_FLOAT, /* D32_SFLOAT */ + DXGI_FORMAT_D32_FLOAT, /* D32_FLOAT */ DXGI_FORMAT_D24_UNORM_S8_UINT, /* D24_UNORM_S8_UINT */ - DXGI_FORMAT_D32_FLOAT_S8X24_UINT, /* D32_SFLOAT_S8_UINT */ + DXGI_FORMAT_D32_FLOAT_S8X24_UINT, /* D32_FLOAT_S8_UINT */ }; static DXGI_FORMAT SDLToD3D11_VertexFormat[] = { @@ -5735,7 +5735,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( SDL_zero(colorAttachmentDesc); colorAttachmentDesc.blendState.colorWriteMask = 0xF; - colorAttachmentDesc.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8; /* format doesn't matter in d3d11 */ + colorAttachmentDesc.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; /* format doesn't matter in d3d11 */ blitPipelineCreateInfo.attachmentInfo.colorAttachmentDescriptions = &colorAttachmentDesc; blitPipelineCreateInfo.attachmentInfo.colorAttachmentCount = 1; diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index c42d97ac0cc921..a81f20d77cfd56 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -157,10 +157,10 @@ typedef enum D3D12BufferType /* Conversions */ static SDL_GpuTextureFormat SwapchainCompositionToSDLTextureFormat[] = { - SDL_GPU_TEXTUREFORMAT_B8G8R8A8, /* SDR */ - SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB, /* SDR_SRGB */ - SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT, /* HDR */ - SDL_GPU_TEXTUREFORMAT_R10G10B10A2, /* HDR_ADVANCED */ + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM, /* SDR */ + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, /* SDR_SRGB */ + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT, /* HDR */ + SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM, /* HDR_ADVANCED */ }; static DXGI_FORMAT SwapchainCompositionToTextureFormat[] = { @@ -218,43 +218,43 @@ static D3D12_BLEND_OP SDLToD3D12_BlendOp[] = { }; static DXGI_FORMAT SDLToD3D12_TextureFormat[] = { - DXGI_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8 */ - DXGI_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8 */ - DXGI_FORMAT_B5G6R5_UNORM, /* B5G6R5 */ - DXGI_FORMAT_B5G5R5A1_UNORM, /* B5G5R5A1 */ - DXGI_FORMAT_B4G4R4A4_UNORM, /* B4G4R4A4 */ - DXGI_FORMAT_R10G10B10A2_UNORM, /* R10G10B10A2 */ - DXGI_FORMAT_R16G16_UNORM, /* R16G16 */ - DXGI_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16 */ - DXGI_FORMAT_R8_UNORM, /* R8 */ - DXGI_FORMAT_A8_UNORM, /* A8 */ - DXGI_FORMAT_BC1_UNORM, /* BC1 */ - DXGI_FORMAT_BC2_UNORM, /* BC2 */ - DXGI_FORMAT_BC3_UNORM, /* BC3 */ - DXGI_FORMAT_BC7_UNORM, /* BC7 */ + DXGI_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8_UNORM */ + DXGI_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8_UNORM */ + DXGI_FORMAT_B5G6R5_UNORM, /* B5G6R5_UNORM */ + DXGI_FORMAT_B5G5R5A1_UNORM, /* B5G5R5A1_UNORM */ + DXGI_FORMAT_B4G4R4A4_UNORM, /* B4G4R4A4_UNORM */ + DXGI_FORMAT_R10G10B10A2_UNORM, /* R10G10B10A2_UNORM */ + DXGI_FORMAT_R16G16_UNORM, /* R16G16_UNORM */ + DXGI_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16_UNORM */ + DXGI_FORMAT_R8_UNORM, /* R8_UNORM */ + DXGI_FORMAT_A8_UNORM, /* A8_UNORM */ + DXGI_FORMAT_BC1_UNORM, /* BC1_UNORM */ + DXGI_FORMAT_BC2_UNORM, /* BC2_UNORM */ + DXGI_FORMAT_BC3_UNORM, /* BC3_UNORM */ + DXGI_FORMAT_BC7_UNORM, /* BC7_UNORM */ DXGI_FORMAT_R8G8_SNORM, /* R8G8_SNORM */ DXGI_FORMAT_R8G8B8A8_SNORM, /* R8G8B8A8_SNORM */ - DXGI_FORMAT_R16_FLOAT, /* R16_SFLOAT */ - DXGI_FORMAT_R16G16_FLOAT, /* R16G16_SFLOAT */ - DXGI_FORMAT_R16G16B16A16_FLOAT, /* R16G16B16A16_SFLOAT */ - DXGI_FORMAT_R32_FLOAT, /* R32_SFLOAT */ - DXGI_FORMAT_R32G32_FLOAT, /* R32G32_SFLOAT */ - DXGI_FORMAT_R32G32B32A32_FLOAT, /* R32G32B32A32_SFLOAT */ + DXGI_FORMAT_R16_FLOAT, /* R16_FLOAT */ + DXGI_FORMAT_R16G16_FLOAT, /* R16G16_FLOAT */ + DXGI_FORMAT_R16G16B16A16_FLOAT, /* R16G16B16A16_FLOAT */ + DXGI_FORMAT_R32_FLOAT, /* R32_FLOAT */ + DXGI_FORMAT_R32G32_FLOAT, /* R32G32_FLOAT */ + DXGI_FORMAT_R32G32B32A32_FLOAT, /* R32G32B32A32_FLOAT */ DXGI_FORMAT_R8_UINT, /* R8_UINT */ DXGI_FORMAT_R8G8_UINT, /* R8G8_UINT */ DXGI_FORMAT_R8G8B8A8_UINT, /* R8G8B8A8_UINT */ DXGI_FORMAT_R16_UINT, /* R16_UINT */ DXGI_FORMAT_R16G16_UINT, /* R16G16_UINT */ DXGI_FORMAT_R16G16B16A16_UINT, /* R16G16B16A16_UINT */ - DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, /* R8G8B8A8_SRGB */ - DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, /* B8G8R8A8_SRGB */ - DXGI_FORMAT_BC3_UNORM_SRGB, /* BC3_SRGB */ - DXGI_FORMAT_BC7_UNORM_SRGB, /* BC7_SRGB */ + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, /* R8G8B8A8_UNORM_SRGB */ + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, /* B8G8R8A8_UNORM_SRGB */ + DXGI_FORMAT_BC3_UNORM_SRGB, /* BC3_UNORM_SRGB */ + DXGI_FORMAT_BC7_UNORM_SRGB, /* BC7_UNORM_SRGB */ DXGI_FORMAT_D16_UNORM, /* D16_UNORM */ DXGI_FORMAT_D24_UNORM_S8_UINT, /* D24_UNORM */ - DXGI_FORMAT_D32_FLOAT, /* D32_SFLOAT */ + DXGI_FORMAT_D32_FLOAT, /* D32_FLOAT */ DXGI_FORMAT_D24_UNORM_S8_UINT, /* D24_UNORM_S8_UINT */ - DXGI_FORMAT_D32_FLOAT_S8X24_UINT, /* D32_SFLOAT_S8_UINT */ + DXGI_FORMAT_D32_FLOAT_S8X24_UINT, /* D32_FLOAT_S8_UINT */ }; static D3D12_COMPARISON_FUNC SDLToD3D12_CompareOp[] = { diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index 82b44ddc5ccd36..5046440e1836ff 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/src/gpu/metal/SDL_gpu_metal.m @@ -67,71 +67,64 @@ static void METAL_UnclaimWindow( /* Conversions */ -static SDL_GpuTextureFormat SwapchainCompositionToSDLTextureFormat[] = { - SDL_GPU_TEXTUREFORMAT_B8G8R8A8, /* SDR */ - SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB, /* SDR_SRGB */ - SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT, /* HDR */ - SDL_GPU_TEXTUREFORMAT_R10G10B10A2, /* HDR_ADVANCED */ -}; - static MTLPixelFormat SDLToMetal_SurfaceFormat[] = { - MTLPixelFormatRGBA8Unorm, /* R8G8B8A8 */ - MTLPixelFormatBGRA8Unorm, /* B8G8R8A8 */ - MTLPixelFormatB5G6R5Unorm, /* B5G6R5 */ - MTLPixelFormatBGR5A1Unorm, /* B5G5R5A1 */ - MTLPixelFormatABGR4Unorm, /* B4G4R4A4 */ - MTLPixelFormatRGB10A2Unorm, /* A2R10G10B10 */ - MTLPixelFormatRG16Unorm, /* R16G16 */ - MTLPixelFormatRGBA16Unorm, /* R16G16B16A16 */ - MTLPixelFormatR8Unorm, /* R8 */ - MTLPixelFormatA8Unorm, /* A8 */ + MTLPixelFormatRGBA8Unorm, /* R8G8B8A8_UNORM */ + MTLPixelFormatBGRA8Unorm, /* B8G8R8A8_UNORM */ + MTLPixelFormatB5G6R5Unorm, /* B5G6R5_UNORM */ + MTLPixelFormatBGR5A1Unorm, /* B5G5R5A1_UNORM */ + MTLPixelFormatABGR4Unorm, /* B4G4R4A4_UNORM */ + MTLPixelFormatRGB10A2Unorm, /* A2R10G10B10_UNORM */ + MTLPixelFormatRG16Unorm, /* R16G16_UNORM */ + MTLPixelFormatRGBA16Unorm, /* R16G16B16A16_UNORM */ + MTLPixelFormatR8Unorm, /* R8_UNORM */ + MTLPixelFormatA8Unorm, /* A8_UNORM */ #ifdef SDL_PLATFORM_MACOS - MTLPixelFormatBC1_RGBA, /* BC1 */ - MTLPixelFormatBC2_RGBA, /* BC2 */ - MTLPixelFormatBC3_RGBA, /* BC3 */ - MTLPixelFormatBC7_RGBAUnorm, /* BC7 */ + MTLPixelFormatBC1_RGBA, /* BC1_UNORM */ + MTLPixelFormatBC2_RGBA, /* BC2_UNORM */ + MTLPixelFormatBC3_RGBA, /* BC3_UNORM */ + MTLPixelFormatBC7_RGBAUnorm, /* BC7_UNORM */ #else - MTLPixelFormatInvalid, /* BC1 */ - MTLPixelFormatInvalid, /* BC2 */ - MTLPixelFormatInvalid, /* BC3 */ - MTLPixelFormatInvalid, /* BC7 */ + MTLPixelFormatInvalid, /* BC1_UNORM */ + MTLPixelFormatInvalid, /* BC2_UNORM */ + MTLPixelFormatInvalid, /* BC3_UNORM */ + MTLPixelFormatInvalid, /* BC7_UNORM */ #endif - MTLPixelFormatRG8Snorm, /* R8G8_SNORM */ - MTLPixelFormatRGBA8Snorm, /* R8G8B8A8_SNORM */ - MTLPixelFormatR16Float, /* R16_SFLOAT */ - MTLPixelFormatRG16Float, /* R16G16_SFLOAT */ - MTLPixelFormatRGBA16Float, /* R16G16B16A16_SFLOAT */ - MTLPixelFormatR32Float, /* R32_SFLOAT */ - MTLPixelFormatRG32Float, /* R32G32_SFLOAT */ - MTLPixelFormatRGBA32Float, /* R32G32B32A32_SFLOAT */ - MTLPixelFormatR8Uint, /* R8_UINT */ - MTLPixelFormatRG8Uint, /* R8G8_UINT */ - MTLPixelFormatRGBA8Uint, /* R8G8B8A8_UINT */ - MTLPixelFormatR16Uint, /* R16_UINT */ - MTLPixelFormatRG16Uint, /* R16G16_UINT */ - MTLPixelFormatRGBA16Uint, /* R16G16B16A16_UINT */ - MTLPixelFormatRGBA8Unorm_sRGB, /* R8G8B8A8_SRGB*/ - MTLPixelFormatBGRA8Unorm_sRGB, /* B8G8R8A8_SRGB */ + MTLPixelFormatRG8Snorm, /* R8G8_SNORM */ + MTLPixelFormatRGBA8Snorm, /* R8G8B8A8_SNORM */ + MTLPixelFormatR16Float, /* R16_FLOAT */ + MTLPixelFormatRG16Float, /* R16G16_FLOAT */ + MTLPixelFormatRGBA16Float, /* R16G16B16A16_FLOAT */ + MTLPixelFormatR32Float, /* R32_FLOAT */ + MTLPixelFormatRG32Float, /* R32G32_FLOAT */ + MTLPixelFormatRGBA32Float, /* R32G32B32A32_FLOAT */ + MTLPixelFormatR8Uint, /* R8_UINT */ + MTLPixelFormatRG8Uint, /* R8G8_UINT */ + MTLPixelFormatRGBA8Uint, /* R8G8B8A8_UINT */ + MTLPixelFormatR16Uint, /* R16_UINT */ + MTLPixelFormatRG16Uint, /* R16G16_UINT */ + MTLPixelFormatRGBA16Uint, /* R16G16B16A16_UINT */ + MTLPixelFormatRGBA8Unorm_sRGB, /* R8G8B8A8_UNORM_SRGB*/ + MTLPixelFormatBGRA8Unorm_sRGB, /* B8G8R8A8_UNORM_SRGB */ #ifdef SDL_PLATFORM_MACOS - MTLPixelFormatBC3_RGBA_sRGB, /* BC3_SRGB */ - MTLPixelFormatBC7_RGBAUnorm_sRGB, /* BC7_SRGB */ + MTLPixelFormatBC3_RGBA_sRGB, /* BC3_UNORM_SRGB */ + MTLPixelFormatBC7_RGBAUnorm_sRGB, /* BC7_UNORM_SRGB */ #else - MTLPixelFormatInvalid, /* BC3_SRGB */ - MTLPixelFormatInvalid, /* BC7_SRGB */ + MTLPixelFormatInvalid, /* BC3_UNORM_SRGB */ + MTLPixelFormatInvalid, /* BC7_UNORM_SRGB */ #endif - MTLPixelFormatDepth16Unorm, /* D16_UNORM */ + MTLPixelFormatDepth16Unorm, /* D16_UNORM */ #ifdef SDL_PLATFORM_MACOS MTLPixelFormatDepth24Unorm_Stencil8, /* D24_UNORM */ #else - MTLPixelFormatInvalid, /* D24_UNORM */ + MTLPixelFormatInvalid, /* D24_UNORM */ #endif - MTLPixelFormatDepth32Float, /* D32_SFLOAT */ + MTLPixelFormatDepth32Float, /* D32_FLOAT */ #ifdef SDL_PLATFORM_MACOS MTLPixelFormatDepth24Unorm_Stencil8, /* D24_UNORM_S8_UINT */ #else - MTLPixelFormatInvalid, /* D24_UNORM_S8_UINT */ + MTLPixelFormatInvalid, /* D24_UNORM_S8_UINT */ #endif - MTLPixelFormatDepth32Float_Stencil8, /* D32_SFLOAT_S8_UINT */ + MTLPixelFormatDepth32Float_Stencil8, /* D32_FLOAT_S8_UINT */ }; static MTLVertexFormat SDLToMetal_VertexFormat[] = { @@ -284,10 +277,10 @@ static void METAL_UnclaimWindow( }; static SDL_GpuTextureFormat SwapchainCompositionToFormat[] = { - SDL_GPU_TEXTUREFORMAT_B8G8R8A8, /* SDR */ - SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB, /* SDR_LINEAR */ - SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT, /* HDR_EXTENDED_LINEAR */ - SDL_GPU_TEXTUREFORMAT_R10G10B10A2, /* HDR10_ST2048 */ + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM, /* SDR */ + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, /* SDR_LINEAR */ + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT, /* HDR_EXTENDED_LINEAR */ + SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM, /* HDR10_ST2048 */ }; static CFStringRef SwapchainCompositionToColorSpace[4]; /* initialized on device creation */ @@ -1295,7 +1288,7 @@ static void METAL_PopDebugGroup( textureDescriptor.textureType = SDLToMetal_TextureType[textureCreateInfo->type]; textureDescriptor.pixelFormat = SDLToMetal_SurfaceFormat[textureCreateInfo->format]; /* This format isn't natively supported so let's swizzle! */ - if (textureCreateInfo->format == SDL_GPU_TEXTUREFORMAT_B4G4R4A4) { + if (textureCreateInfo->format == SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM) { textureDescriptor.swizzle = MTLTextureSwizzleChannelsMake( MTLTextureSwizzleBlue, MTLTextureSwizzleGreen, @@ -1360,9 +1353,9 @@ static SDL_GpuSampleCount METAL_GetBestSampleCount( MetalRenderer *renderer = (MetalRenderer *)driverData; SDL_GpuSampleCount highestSupported = desiredSampleCount; - if ((format == SDL_GPU_TEXTUREFORMAT_R32_SFLOAT || - format == SDL_GPU_TEXTUREFORMAT_R32G32_SFLOAT || - format == SDL_GPU_TEXTUREFORMAT_R32G32B32A32_SFLOAT)) { + if ((format == SDL_GPU_TEXTUREFORMAT_R32_FLOAT || + format == SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT || + format == SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT)) { if (@available(macOS 11.0, *)) { if (![renderer->device supports32BitMSAA]) { return SDL_GPU_SAMPLECOUNT_1; @@ -3378,7 +3371,7 @@ static Uint8 METAL_INTERNAL_CreateSwapchain( SDL_Gpu_FetchBlitPipeline( renderer->sdlGpuDevice, (SDL_GpuTextureType)i, - SwapchainCompositionToSDLTextureFormat[swapchainComposition], + SwapchainCompositionToFormat[swapchainComposition], renderer->blitVertexShader, renderer->blitFrom2DShader, renderer->blitFrom2DArrayShader, @@ -3715,18 +3708,18 @@ static SDL_bool METAL_SupportsTextureFormat( switch (format) { /* Apple GPU exclusive */ - case SDL_GPU_TEXTUREFORMAT_B5G6R5: - case SDL_GPU_TEXTUREFORMAT_B5G5R5A1: - case SDL_GPU_TEXTUREFORMAT_B4G4R4A4: + case SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM: + case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM: + case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM: return [renderer->device supportsFamily:MTLGPUFamilyApple1]; /* Requires BC compression support */ - case SDL_GPU_TEXTUREFORMAT_BC1: - case SDL_GPU_TEXTUREFORMAT_BC2: - case SDL_GPU_TEXTUREFORMAT_BC3: - case SDL_GPU_TEXTUREFORMAT_BC7: - case SDL_GPU_TEXTUREFORMAT_BC3_SRGB: - case SDL_GPU_TEXTUREFORMAT_BC7_SRGB: + case SDL_GPU_TEXTUREFORMAT_BC1_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC2_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC3_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC7_UNORM: + case SDL_GPU_TEXTUREFORMAT_BC3_UNORM_SRGB: + case SDL_GPU_TEXTUREFORMAT_BC7_UNORM_SRGB: #ifdef SDL_PLATFORM_MACOS if (@available(macOS 11.0, *)) { return ( diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index c4a98fb7fe9200..350d165c7f909a 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -136,43 +136,43 @@ static VkPresentModeKHR SDLToVK_PresentMode[] = { }; static VkFormat SDLToVK_SurfaceFormat[] = { - VK_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8 */ - VK_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8 */ - VK_FORMAT_R5G6B5_UNORM_PACK16, /* B5G6R5 */ - VK_FORMAT_A1R5G5B5_UNORM_PACK16, /* B5G5R5A1 */ - VK_FORMAT_B4G4R4A4_UNORM_PACK16, /* B4G4R4A4 */ - VK_FORMAT_A2B10G10R10_UNORM_PACK32, /* R10G10B10A2 */ - VK_FORMAT_R16G16_UNORM, /* R16G16 */ - VK_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16 */ - VK_FORMAT_R8_UNORM, /* R8 */ - VK_FORMAT_R8_UNORM, /* A8 */ - VK_FORMAT_BC1_RGBA_UNORM_BLOCK, /* BC1 */ - VK_FORMAT_BC2_UNORM_BLOCK, /* BC2 */ - VK_FORMAT_BC3_UNORM_BLOCK, /* BC3 */ - VK_FORMAT_BC7_UNORM_BLOCK, /* BC7 */ + VK_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8_UNORM */ + VK_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8_UNORM */ + VK_FORMAT_R5G6B5_UNORM_PACK16, /* B5G6R5_UNORM */ + VK_FORMAT_A1R5G5B5_UNORM_PACK16, /* B5G5R5A1_UNORM */ + VK_FORMAT_B4G4R4A4_UNORM_PACK16, /* B4G4R4A4_UNORM */ + VK_FORMAT_A2B10G10R10_UNORM_PACK32, /* R10G10B10A2_UNORM */ + VK_FORMAT_R16G16_UNORM, /* R16G16_UNORM */ + VK_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16_UNORM */ + VK_FORMAT_R8_UNORM, /* R8_UNORM */ + VK_FORMAT_R8_UNORM, /* A8_UNORM */ + VK_FORMAT_BC1_RGBA_UNORM_BLOCK, /* BC1_UNORM */ + VK_FORMAT_BC2_UNORM_BLOCK, /* BC2_UNORM */ + VK_FORMAT_BC3_UNORM_BLOCK, /* BC3_UNORM */ + VK_FORMAT_BC7_UNORM_BLOCK, /* BC7_UNORM */ VK_FORMAT_R8G8_SNORM, /* R8G8_SNORM */ VK_FORMAT_R8G8B8A8_SNORM, /* R8G8B8A8_SNORM */ - VK_FORMAT_R16_SFLOAT, /* R16_SFLOAT */ - VK_FORMAT_R16G16_SFLOAT, /* R16G16_SFLOAT */ - VK_FORMAT_R16G16B16A16_SFLOAT, /* R16G16B16A16_SFLOAT */ - VK_FORMAT_R32_SFLOAT, /* R32_SFLOAT */ - VK_FORMAT_R32G32_SFLOAT, /* R32G32_SFLOAT */ - VK_FORMAT_R32G32B32A32_SFLOAT, /* R32G32B32A32_SFLOAT */ + VK_FORMAT_R16_SFLOAT, /* R16_FLOAT */ + VK_FORMAT_R16G16_SFLOAT, /* R16G16_FLOAT */ + VK_FORMAT_R16G16B16A16_SFLOAT, /* R16G16B16A16_FLOAT */ + VK_FORMAT_R32_SFLOAT, /* R32_FLOAT */ + VK_FORMAT_R32G32_SFLOAT, /* R32G32_FLOAT */ + VK_FORMAT_R32G32B32A32_SFLOAT, /* R32G32B32A32_FLOAT */ VK_FORMAT_R8_UINT, /* R8_UINT */ VK_FORMAT_R8G8_UINT, /* R8G8_UINT */ VK_FORMAT_R8G8B8A8_UINT, /* R8G8B8A8_UINT */ VK_FORMAT_R16_UINT, /* R16_UINT */ VK_FORMAT_R16G16_UINT, /* R16G16_UINT */ VK_FORMAT_R16G16B16A16_UINT, /* R16G16B16A16_UINT */ - VK_FORMAT_R8G8B8A8_SRGB, /* R8G8B8A8_SRGB */ - VK_FORMAT_B8G8R8A8_SRGB, /* B8G8R8A8_SRGB */ - VK_FORMAT_BC3_SRGB_BLOCK, /* BC3_SRGB */ - VK_FORMAT_BC7_SRGB_BLOCK, /* BC7_SRGB */ + VK_FORMAT_R8G8B8A8_SRGB, /* R8G8B8A8_UNORM_SRGB */ + VK_FORMAT_B8G8R8A8_SRGB, /* B8G8R8A8_UNORM_SRGB */ + VK_FORMAT_BC3_SRGB_BLOCK, /* BC3_UNORM_SRGB */ + VK_FORMAT_BC7_SRGB_BLOCK, /* BC7_UNORM_SRGB */ VK_FORMAT_D16_UNORM, /* D16_UNORM */ VK_FORMAT_X8_D24_UNORM_PACK32, /* D24_UNORM */ - VK_FORMAT_D32_SFLOAT, /* D32_SFLOAT */ + VK_FORMAT_D32_SFLOAT, /* D32_FLOAT */ VK_FORMAT_D24_UNORM_S8_UINT, /* D24_UNORM_S8_UINT */ - VK_FORMAT_D32_SFLOAT_S8_UINT, /* D32_SFLOAT_S8_UINT */ + VK_FORMAT_D32_SFLOAT_S8_UINT, /* D32_FLOAT_S8_UINT */ }; static VkComponentMapping SDLToVK_SurfaceSwizzle[] = { @@ -259,13 +259,13 @@ static SDL_GpuTextureFormat SwapchainCompositionToSDLFormat( { switch (composition) { case SDL_GPU_SWAPCHAINCOMPOSITION_SDR: - return usingFallback ? SDL_GPU_TEXTUREFORMAT_R8G8B8A8 : SDL_GPU_TEXTUREFORMAT_B8G8R8A8; + return usingFallback ? SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM : SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM; case SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR: - return usingFallback ? SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SRGB : SDL_GPU_TEXTUREFORMAT_B8G8R8A8_SRGB; + return usingFallback ? SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB : SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB; case SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR: - return SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SFLOAT; + return SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT; case SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048: - return SDL_GPU_TEXTUREFORMAT_R10G10B10A2; + return SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM; default: return SDL_GPU_TEXTUREFORMAT_INVALID; } @@ -1492,8 +1492,8 @@ static inline SDL_bool VULKAN_INTERNAL_IsVulkanDepthFormat(VkFormat format) format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D16_UNORM] || format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D24_UNORM] || format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT] || - format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D32_SFLOAT] || - format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D32_SFLOAT_S8_UINT]); + format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D32_FLOAT] || + format == SDLToVK_SurfaceFormat[SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT]); } static inline VkSampleCountFlagBits VULKAN_INTERNAL_GetMaxMultiSampleCount(