diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 561eec73d2296..ab0fd399e6453 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -78,36 +78,97 @@ 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 + * + * For COLOR_TARGET usage, the following formats are universally supported: + * - R8G8B8A8_UNORM + * - B8G8R8A8_UNORM + * - R8_UNORM + * - R16_FLOAT + * - R16G16_FLOAT + * - R16G16B16A16_FLOAT + * - R32_FLOAT + * - R32G32_FLOAT + * - R32G32B32A32_FLOAT + * - R8_UINT + * - R8G8_UINT + * - R8G8B8A8_UINT + * - R16_UINT + * - R16G16_UINT + * - R16G16B16A16_UINT + * - R8G8B8A8_UNORM_SRGB + * - B8G8R8A8_UNORM_SRGB + * + * For STORAGE usages, the following formats are universally supported: + * - R8G8B8A8_UNORM + * - R8G8B8A8_SNORM + * - R16G16B16A16_FLOAT + * - R32_FLOAT + * - R32G32_FLOAT + * - R32G32B32A32_FLOAT + * - R8_UINT + * - R8G8_UINT + * - R8G8B8A8_UINT + * - R16_UINT + * - R16G16_UINT + * - R16G16B16A16_UINT + * + * For DEPTH_STENCIL_TARGET usage, the following formats are universally supported: + * - D16_UNORM + * - Either (but not necessarily both!) D24_UNORM or D32_SFLOAT + * - Either (but not necessarily both!) 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! + */ 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 +176,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 +1140,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 5dcaeccbc41e6..6747f8e66cae7 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -513,43 +513,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 f995ef8235821..d372fc6ccef65 100644 --- a/src/gpu/SDL_sysgpu.h +++ b/src/gpu/SDL_sysgpu.h @@ -69,7 +69,7 @@ typedef struct BlitPipelineCacheEntry /* Internal Helper Utilities */ -#define SDL_GPU_TEXTUREFORMAT_MAX (SDL_GPU_TEXTUREFORMAT_D32_SFLOAT_S8_UINT + 1) +#define SDL_GPU_TEXTUREFORMAT_MAX (SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT + 1) #define SDL_GPU_SWAPCHAINCOMPOSITION_MAX (SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048 + 1) #define SDL_GPU_PRESENTMODE_MAX (SDL_GPU_PRESENTMODE_MAILBOX + 1) @@ -77,39 +77,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!"); @@ -123,9 +123,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: @@ -138,7 +138,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: @@ -174,10 +174,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; } @@ -192,10 +192,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 e6ea2414eba5d..e8ef6f3ee02b0 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 */ }; SDL_COMPILE_TIME_ASSERT(SDLToD3D11_TextureFormat, SDL_arraysize(SDLToD3D11_TextureFormat) == SDL_GPU_TEXTUREFORMAT_MAX); @@ -5748,7 +5748,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 944bb85aa8a89..2de28932192d6 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 */ }; SDL_COMPILE_TIME_ASSERT(SDLToD3D12_TextureFormat, SDL_arraysize(SDLToD3D12_TextureFormat) == SDL_GPU_TEXTUREFORMAT_MAX); diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index aa58692c84576..22b5da651682e 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 */ }; SDL_COMPILE_TIME_ASSERT(SDLToMetal_SurfaceFormat, SDL_arraysize(SDLToMetal_SurfaceFormat) == SDL_GPU_TEXTUREFORMAT_MAX); @@ -285,10 +278,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 */ @@ -1297,7 +1290,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, @@ -3354,7 +3347,7 @@ static Uint8 METAL_INTERNAL_CreateSwapchain( SDL_Gpu_FetchBlitPipeline( renderer->sdlGpuDevice, (SDL_GpuTextureType)i, - SwapchainCompositionToSDLTextureFormat[swapchainComposition], + SwapchainCompositionToFormat[swapchainComposition], renderer->blitVertexShader, renderer->blitFrom2DShader, renderer->blitFrom2DArrayShader, @@ -3689,18 +3682,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 9615522e6adc0..c975fce97d642 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 */ }; SDL_COMPILE_TIME_ASSERT(SDLToVK_SurfaceFormat, SDL_arraysize(SDLToVK_SurfaceFormat) == SDL_GPU_TEXTUREFORMAT_MAX); @@ -260,13 +260,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; } @@ -1236,8 +1236,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(