From fb7245fb93fa8fd332771e020cd11fdde6556cc6 Mon Sep 17 00:00:00 2001
From: Andrei Alexeyev <[EMAIL REDACTED]>
Date: Tue, 3 Sep 2024 03:14:48 +0300
Subject: [PATCH] GPU: Add support for more texture formats (#10641)
---
include/SDL3/SDL_gpu.h | 62 ++++++++++++++++------
src/gpu/SDL_gpu.c | 25 ++++++---
src/gpu/SDL_sysgpu.h | 36 ++++++++++---
src/gpu/d3d11/SDL_gpu_d3d11.c | 31 ++++++++---
src/gpu/d3d12/SDL_gpu_d3d12.c | 31 ++++++++---
src/gpu/metal/SDL_gpu_metal.m | 55 +++++++++++++++-----
src/gpu/vulkan/SDL_gpu_vulkan.c | 92 ++++++++++++++++++++++++---------
7 files changed, 256 insertions(+), 76 deletions(-)
diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h
index 8937fc2cd748a..7f6520072eb82 100644
--- a/include/SDL3/SDL_gpu.h
+++ b/include/SDL3/SDL_gpu.h
@@ -94,6 +94,8 @@ typedef enum SDL_GPUIndexElementSize
* - R8G8B8A8_UNORM
* - B8G8R8A8_UNORM
* - R8_UNORM
+ * - R8_SNORM
+ * - R8G8_UNORM
* - R8G8_SNORM
* - R8G8B8A8_SNORM
* - R16_FLOAT
@@ -102,6 +104,7 @@ typedef enum SDL_GPUIndexElementSize
* - R32_FLOAT
* - R32G32_FLOAT
* - R32G32B32A32_FLOAT
+ * - R11G11B10_UFLOAT
* - R8G8B8A8_UNORM_SRGB
* - B8G8R8A8_UNORM_SRGB
* - D16_UNORM
@@ -122,6 +125,12 @@ typedef enum SDL_GPUIndexElementSize
* - R16_UINT
* - R16G16_UINT
* - R16G16B16A16_UINT
+ * - R8_INT
+ * - R8G8_INT
+ * - R8G8B8A8_INT
+ * - R16_INT
+ * - R16G16_INT
+ * - R16G16B16A16_INT
* - R8G8B8A8_UNORM_SRGB
* - B8G8R8A8_UNORM_SRGB
*
@@ -132,12 +141,10 @@ typedef enum SDL_GPUIndexElementSize
* - R32_FLOAT
* - R32G32_FLOAT
* - R32G32B32A32_FLOAT
- * - R8_UINT
- * - R8G8_UINT
* - R8G8B8A8_UINT
- * - R16_UINT
- * - R16G16_UINT
* - R16G16B16A16_UINT
+ * - R8G8B8A8_INT
+ * - R16G16B16A16_IINT
*
* For DEPTH_STENCIL_TARGET usage, the following formats are universally supported:
* - D16_UNORM
@@ -152,24 +159,36 @@ typedef enum SDL_GPUTextureFormat
SDL_GPU_TEXTUREFORMAT_INVALID = -1,
/* Unsigned Normalized Float Color Formats */
+ SDL_GPU_TEXTUREFORMAT_A8_UNORM,
+ SDL_GPU_TEXTUREFORMAT_R8_UNORM,
+ SDL_GPU_TEXTUREFORMAT_R8G8_UNORM,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
- SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM,
+ SDL_GPU_TEXTUREFORMAT_R16_UNORM,
+ SDL_GPU_TEXTUREFORMAT_R16G16_UNORM,
+ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM,
+ SDL_GPU_TEXTUREFORMAT_R10G10B10A2_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,
+ SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM,
/* Compressed Unsigned Normalized Float Color Formats */
- SDL_GPU_TEXTUREFORMAT_BC1_UNORM,
- SDL_GPU_TEXTUREFORMAT_BC2_UNORM,
- SDL_GPU_TEXTUREFORMAT_BC3_UNORM,
- SDL_GPU_TEXTUREFORMAT_BC7_UNORM,
+ SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM,
+ SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM,
+ SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM,
+ SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM,
+ SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM,
+ SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM,
+ /* Compressed Signed Float Color Formats */
+ SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT,
+ /* Compressed Unsigned Float Color Formats */
+ SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT,
/* Signed Normalized Float Color Formats */
+ SDL_GPU_TEXTUREFORMAT_R8_SNORM,
SDL_GPU_TEXTUREFORMAT_R8G8_SNORM,
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM,
+ SDL_GPU_TEXTUREFORMAT_R16_SNORM,
+ SDL_GPU_TEXTUREFORMAT_R16G16_SNORM,
+ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM,
/* Signed Float Color Formats */
SDL_GPU_TEXTUREFORMAT_R16_FLOAT,
SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT,
@@ -177,6 +196,8 @@ typedef enum SDL_GPUTextureFormat
SDL_GPU_TEXTUREFORMAT_R32_FLOAT,
SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT,
SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT,
+ /* Unsigned Float Color Formats */
+ SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT,
/* Unsigned Integer Color Formats */
SDL_GPU_TEXTUREFORMAT_R8_UINT,
SDL_GPU_TEXTUREFORMAT_R8G8_UINT,
@@ -184,12 +205,21 @@ typedef enum SDL_GPUTextureFormat
SDL_GPU_TEXTUREFORMAT_R16_UINT,
SDL_GPU_TEXTUREFORMAT_R16G16_UINT,
SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT,
+ /* Signed Integer Color Formats */
+ SDL_GPU_TEXTUREFORMAT_R8_INT,
+ SDL_GPU_TEXTUREFORMAT_R8G8_INT,
+ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT,
+ SDL_GPU_TEXTUREFORMAT_R16_INT,
+ SDL_GPU_TEXTUREFORMAT_R16G16_INT,
+ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT,
/* 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,
+ SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB,
+ SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB,
+ SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB,
+ SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB,
/* Depth Formats */
SDL_GPU_TEXTUREFORMAT_D16_UNORM,
SDL_GPU_TEXTUREFORMAT_D24_UNORM,
diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c
index 811216ff08b7f..6f12b88830255 100644
--- a/src/gpu/SDL_gpu.c
+++ b/src/gpu/SDL_gpu.c
@@ -502,15 +502,22 @@ Uint32 SDL_GPUTextureFormatTexelBlockSize(
SDL_GPUTextureFormat textureFormat)
{
switch (textureFormat) {
- case SDL_GPU_TEXTUREFORMAT_BC1_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM:
return 8;
- 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:
+ case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT:
+ case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT:
+ case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB:
return 16;
case SDL_GPU_TEXTUREFORMAT_R8_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R8_SNORM:
case SDL_GPU_TEXTUREFORMAT_A8_UNORM:
case SDL_GPU_TEXTUREFORMAT_R8_UINT:
return 1;
@@ -519,7 +526,10 @@ Uint32 SDL_GPUTextureFormatTexelBlockSize(
case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM:
case SDL_GPU_TEXTUREFORMAT_R16_FLOAT:
case SDL_GPU_TEXTUREFORMAT_R8G8_SNORM:
+ case SDL_GPU_TEXTUREFORMAT_R8G8_UNORM:
case SDL_GPU_TEXTUREFORMAT_R8G8_UINT:
+ case SDL_GPU_TEXTUREFORMAT_R16_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16_SNORM:
case SDL_GPU_TEXTUREFORMAT_R16_UINT:
return 2;
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM:
@@ -528,14 +538,17 @@ Uint32 SDL_GPUTextureFormatTexelBlockSize(
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB:
case SDL_GPU_TEXTUREFORMAT_R32_FLOAT:
case SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT:
+ case SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT:
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM:
case SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM:
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT:
case SDL_GPU_TEXTUREFORMAT_R16G16_UINT:
case SDL_GPU_TEXTUREFORMAT_R16G16_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16G16_SNORM:
return 4;
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT:
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM:
case SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT:
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT:
return 8;
diff --git a/src/gpu/SDL_sysgpu.h b/src/gpu/SDL_sysgpu.h
index 79e1ea09a7cae..720acb43ccc09 100644
--- a/src/gpu/SDL_sysgpu.h
+++ b/src/gpu/SDL_sysgpu.h
@@ -77,12 +77,17 @@ static inline Sint32 Texture_GetBlockSize(
SDL_GPUTextureFormat format)
{
switch (format) {
- 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:
+ case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT:
+ case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT:
+ case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB:
return 4;
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM:
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM:
@@ -90,24 +95,37 @@ static inline Sint32 Texture_GetBlockSize(
case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM:
case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM:
case SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R8G8_UNORM:
case SDL_GPU_TEXTUREFORMAT_R16G16_UNORM:
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM:
case SDL_GPU_TEXTUREFORMAT_R8_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16_UNORM:
case SDL_GPU_TEXTUREFORMAT_A8_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_R8_SNORM:
case SDL_GPU_TEXTUREFORMAT_R8G8_SNORM:
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16_SNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16G16_SNORM:
+ case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM:
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_R11G11B10_UFLOAT:
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_R8_INT:
+ case SDL_GPU_TEXTUREFORMAT_R8G8_INT:
+ case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT:
+ case SDL_GPU_TEXTUREFORMAT_R16_INT:
+ case SDL_GPU_TEXTUREFORMAT_R16G16_INT:
+ case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT:
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB:
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB:
return 1;
@@ -156,6 +174,12 @@ static inline bool IsIntegerFormat(
case SDL_GPU_TEXTUREFORMAT_R16_UINT:
case SDL_GPU_TEXTUREFORMAT_R16G16_UINT:
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT:
+ case SDL_GPU_TEXTUREFORMAT_R8_INT:
+ case SDL_GPU_TEXTUREFORMAT_R8G8_INT:
+ case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT:
+ case SDL_GPU_TEXTUREFORMAT_R16_INT:
+ case SDL_GPU_TEXTUREFORMAT_R16G16_INT:
+ case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT:
return true;
default:
diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c
index c231005981454..f59630eab5632 100644
--- a/src/gpu/d3d11/SDL_gpu_d3d11.c
+++ b/src/gpu/d3d11/SDL_gpu_d3d11.c
@@ -169,36 +169,55 @@ static DXGI_COLOR_SPACE_TYPE SwapchainCompositionToColorSpace[] = {
};
static DXGI_FORMAT SDLToD3D11_TextureFormat[] = {
+ DXGI_FORMAT_A8_UNORM, // A8_UNORM
+ DXGI_FORMAT_R8_UNORM, // R8_UNORM
+ DXGI_FORMAT_R8G8_UNORM, // R8G8_UNORM
DXGI_FORMAT_R8G8B8A8_UNORM, // R8G8B8A8_UNORM
- DXGI_FORMAT_B8G8R8A8_UNORM, // B8G8R8A8_UNORM
+ DXGI_FORMAT_R16_UNORM, // R16_UNORM
+ DXGI_FORMAT_R16G16_UNORM, // R16G16_UNORM
+ DXGI_FORMAT_R16G16B16A16_UNORM, // R16G16B16A16_UNORM
+ DXGI_FORMAT_R10G10B10A2_UNORM, // R10G10B10A2_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_B8G8R8A8_UNORM, // B8G8R8A8_UNORM
DXGI_FORMAT_BC1_UNORM, // BC1_UNORM
DXGI_FORMAT_BC2_UNORM, // BC2_UNORM
DXGI_FORMAT_BC3_UNORM, // BC3_UNORM
+ DXGI_FORMAT_BC4_UNORM, // BC4_UNORM
+ DXGI_FORMAT_BC5_UNORM, // BC5_UNORM
DXGI_FORMAT_BC7_UNORM, // BC7_UNORM
+ DXGI_FORMAT_BC6H_SF16, // BC6H_FLOAT
+ DXGI_FORMAT_BC6H_UF16, // BC6H_UFLOAT
+ DXGI_FORMAT_R8_SNORM, // R8_SNORM
DXGI_FORMAT_R8G8_SNORM, // R8G8_SNORM
DXGI_FORMAT_R8G8B8A8_SNORM, // R8G8B8A8_SNORM
+ DXGI_FORMAT_R16_SNORM, // R16_SNORM
+ DXGI_FORMAT_R16G16_SNORM, // R16G16_SNORM
+ DXGI_FORMAT_R16G16B16A16_SNORM, // R16G16B16A16_SNORM
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_R11G11B10_FLOAT, // R11G11B10_UFLOAT
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_R8_SINT, // R8_INT
+ DXGI_FORMAT_R8G8_SINT, // R8G8_INT
+ DXGI_FORMAT_R8G8B8A8_SINT, // R8G8B8A8_INT
+ DXGI_FORMAT_R16_SINT, // R16_INT
+ DXGI_FORMAT_R16G16_SINT, // R16G16_INT
+ DXGI_FORMAT_R16G16B16A16_SINT, // R16G16B16A16_INT
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, // R8G8B8A8_UNORM_SRGB
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, // B8G8R8A8_UNORM_SRGB
+ DXGI_FORMAT_BC1_UNORM_SRGB, // BC1_UNORM_SRGB
+ DXGI_FORMAT_BC2_UNORM_SRGB, // BC2_UNORM_SRGB
DXGI_FORMAT_BC3_UNORM_SRGB, // BC3_UNORM_SRGB
DXGI_FORMAT_BC7_UNORM_SRGB, // BC7_UNORM_SRGB
DXGI_FORMAT_D16_UNORM, // D16_UNORM
diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c
index 2c19b365aea04..fbd270b69298f 100644
--- a/src/gpu/d3d12/SDL_gpu_d3d12.c
+++ b/src/gpu/d3d12/SDL_gpu_d3d12.c
@@ -225,36 +225,55 @@ static D3D12_BLEND_OP SDLToD3D12_BlendOp[] = {
};
static DXGI_FORMAT SDLToD3D12_TextureFormat[] = {
+ DXGI_FORMAT_A8_UNORM, // A8_UNORM
+ DXGI_FORMAT_R8_UNORM, // R8_UNORM
+ DXGI_FORMAT_R8G8_UNORM, // R8G8_UNORM
DXGI_FORMAT_R8G8B8A8_UNORM, // R8G8B8A8_UNORM
- DXGI_FORMAT_B8G8R8A8_UNORM, // B8G8R8A8_UNORM
+ DXGI_FORMAT_R16_UNORM, // R16_UNORM
+ DXGI_FORMAT_R16G16_UNORM, // R16G16_UNORM
+ DXGI_FORMAT_R16G16B16A16_UNORM, // R16G16B16A16_UNORM
+ DXGI_FORMAT_R10G10B10A2_UNORM, // R10G10B10A2_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_B8G8R8A8_UNORM, // B8G8R8A8_UNORM
DXGI_FORMAT_BC1_UNORM, // BC1_UNORM
DXGI_FORMAT_BC2_UNORM, // BC2_UNORM
DXGI_FORMAT_BC3_UNORM, // BC3_UNORM
+ DXGI_FORMAT_BC4_UNORM, // BC4_UNORM
+ DXGI_FORMAT_BC5_UNORM, // BC5_UNORM
DXGI_FORMAT_BC7_UNORM, // BC7_UNORM
+ DXGI_FORMAT_BC6H_SF16, // BC6H_FLOAT
+ DXGI_FORMAT_BC6H_UF16, // BC6H_UFLOAT
+ DXGI_FORMAT_R8_SNORM, // R8_SNORM
DXGI_FORMAT_R8G8_SNORM, // R8G8_SNORM
DXGI_FORMAT_R8G8B8A8_SNORM, // R8G8B8A8_SNORM
+ DXGI_FORMAT_R16_SNORM, // R16_SNORM
+ DXGI_FORMAT_R16G16_SNORM, // R16G16_SNORM
+ DXGI_FORMAT_R16G16B16A16_SNORM, // R16G16B16A16_SNORM
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_R11G11B10_FLOAT, // R11G11B10_UFLOAT
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_R8_SINT, // R8_INT
+ DXGI_FORMAT_R8G8_SINT, // R8G8_INT
+ DXGI_FORMAT_R8G8B8A8_SINT, // R8G8B8A8_INT
+ DXGI_FORMAT_R16_SINT, // R16_INT
+ DXGI_FORMAT_R16G16_SINT, // R16G16_INT
+ DXGI_FORMAT_R16G16B16A16_SINT, // R16G16B16A16_INT
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, // R8G8B8A8_UNORM_SRGB
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, // B8G8R8A8_UNORM_SRGB
+ DXGI_FORMAT_BC1_UNORM_SRGB, // BC1_UNORM_SRGB
+ DXGI_FORMAT_BC2_UNORM_SRGB, // BC2_UNORM_SRGB
DXGI_FORMAT_BC3_UNORM_SRGB, // BC3_UNORM_SRGB
DXGI_FORMAT_BC7_UNORM_SRGB, // BC7_UNORM_SRGB
DXGI_FORMAT_D16_UNORM, // D16_UNORM
diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m
index ad55e74991eaa..b0f20f2a3a0e2 100644
--- a/src/gpu/metal/SDL_gpu_metal.m
+++ b/src/gpu/metal/SDL_gpu_metal.m
@@ -68,47 +68,72 @@ static void METAL_ReleaseWindow(
// Conversions
static MTLPixelFormat SDLToMetal_SurfaceFormat[] = {
+ MTLPixelFormatA8Unorm, // A8_UNORM
+ MTLPixelFormatR8Unorm, // R8_UNORM
+ MTLPixelFormatRG8Unorm, // R8G8_UNORM
MTLPixelFormatRGBA8Unorm, // R8G8B8A8_UNORM
- MTLPixelFormatBGRA8Unorm, // B8G8R8A8_UNORM
+ MTLPixelFormatR16Unorm, // R16_UNORM
+ MTLPixelFormatRG16Unorm, // R16G16_UNORM
+ MTLPixelFormatRGBA16Unorm, // R16G16B16A16_UNORM
+ MTLPixelFormatRGB10A2Unorm, // A2R10G10B10_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
+ MTLPixelFormatBGRA8Unorm, // B8G8R8A8_UNORM
#ifdef SDL_PLATFORM_MACOS
MTLPixelFormatBC1_RGBA, // BC1_UNORM
MTLPixelFormatBC2_RGBA, // BC2_UNORM
MTLPixelFormatBC3_RGBA, // BC3_UNORM
+ MTLPixelFormatBC4_RUnorm, // BC4_UNORM
+ MTLPixelFormatBC5_RGUnorm, // BC5_UNORM
MTLPixelFormatBC7_RGBAUnorm, // BC7_UNORM
+ MTLPixelFormatBC6H_RGBFloat, // BC6H_FLOAT
+ MTLPixelFormatBC6H_RGBUfloat,// BC6H_UFLOAT
#else
MTLPixelFormatInvalid, // BC1_UNORM
MTLPixelFormatInvalid, // BC2_UNORM
MTLPixelFormatInvalid, // BC3_UNORM
+ MTLPixelFormatInvalid, // BC4_UNORM
+ MTLPixelFormatInvalid, // BC5_UNORM
MTLPixelFormatInvalid, // BC7_UNORM
+ MTLPixelFormatInvalid, // BC6H_FLOAT
+ MTLPixelFormatInvalid, // BC6H_UFLOAT
#endif
+ MTLPixelFormatR8Snorm, // R8_SNORM
MTLPixelFormatRG8Snorm, // R8G8_SNORM
MTLPixelFormatRGBA8Snorm, // R8G8B8A8_SNORM
+ MTLPixelFormatR16Snorm, // R16_SNORM
+ MTLPixelFormatRG16Snorm, // R16G16_SNORM
+ MTLPixelFormatRGBA16Snorm, // R16G16B16A16_SNORM
MTLPixelFormatR16Float, // R16_FLOAT
MTLPixelFormatRG16Float, // R16G16_FLOAT
MTLPixelFormatRGBA16Float, // R16G16B16A16_FLOAT
MTLPixelFormatR32Float, // R32_FLOAT
MTLPixelFormatRG32Float, // R32G32_FLOAT
MTLPixelFormatRGBA32Float, // R32G32B32A32_FLOAT
+ MTLPixelFormatRG11B10Float, // R11G11B10_UFLOAT
MTLPixelFormatR8Uint, // R8_UINT
MTLPixelFormatRG8Uint, // R8G8_UINT
MTLPixelFormatRGBA8Uint, // R8G8B8A8_UINT
MTLPixelFormatR16Uint, // R16_UINT
MTLPixelFormatRG16Uint, // R16G16_UINT
MTLPixelFormatRGBA16Uint, // R16G16B16A16_UINT
+ MTLPixelFormatR8Sint, // R8_UINT
+ MTLPixelFormatRG8Sint, // R8G8_UINT
+ MTLPixelFormatRGBA8Sint, // R8G8B8A8_UINT
+ MTLPixelFormatR16Sint, // R16_UINT
+ MTLPixelFormatRG16Sint, // R16G16_UINT
+ MTLPixelFormatRGBA16Sint, // R16G16B16A16_UINT
MTLPixelFormatRGBA8Unorm_sRGB, // R8G8B8A8_UNORM_SRGB
MTLPixelFormatBGRA8Unorm_sRGB, // B8G8R8A8_UNORM_SRGB
#ifdef SDL_PLATFORM_MACOS
+ MTLPixelFormatBC1_RGBA_sRGB, // BC1_UNORM_SRGB
+ MTLPixelFormatBC2_RGBA_sRGB, // BC2_UNORM_SRGB
MTLPixelFormatBC3_RGBA_sRGB, // BC3_UNORM_SRGB
MTLPixelFormatBC7_RGBAUnorm_sRGB, // BC7_UNORM_SRGB
#else
+ MTLPixelFormatInvalid, // BC1_UNORM_SRGB
+ MTLPixelFormatInvalid, // BC2_UNORM_SRGB
MTLPixelFormatInvalid, // BC3_UNORM_SRGB
MTLPixelFormatInvalid, // BC7_UNORM_SRGB
#endif
@@ -3697,12 +3722,18 @@ static bool METAL_SupportsTextureFormat(
return [renderer->device supportsFamily:MTLGPUFamilyApple1];
// Requires BC compression support
- 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:
+ case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM:
+ case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT:
+ case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT:
+ case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB:
+ case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_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 e841b5a9ea836..de236b79ad5ed 100644
--- a/src/gpu/vulkan/SDL_gpu_vulkan.c
+++ b/src/gpu/vulkan/SDL_gpu_vulkan.c
@@ -136,36 +136,55 @@ static VkPresentModeKHR SDLToVK_PresentMode[] = {
};
static VkFormat SDLToVK_SurfaceFormat[] = {
+ VK_FORMAT_R8_UNORM, // A8_UNORM
+ VK_FORMAT_R8_UNORM, // R8_UNORM
+ VK_FORMAT_R8G8_UNORM, // R8G8_UNORM
VK_FORMAT_R8G8B8A8_UNORM, // R8G8B8A8_UNORM
- VK_FORMAT_B8G8R8A8_UNORM, // B8G8R8A8_UNORM
+ VK_FORMAT_R16_UNORM, // R16_UNORM
+ VK_FORMAT_R16G16_UNORM, // R16G16_UNORM
+ VK_FORMAT_R16G16B16A16_UNORM, // R16G16B16A16_UNORM
+ VK_FORMAT_A2B10G10R10_UNORM_PACK32, // R10G10B10A2_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_B8G8R8A8_UNORM, // B8G8R8A8_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_BC4_UNORM_BLOCK, // BC4_UNORM
+ VK_FORMAT_BC5_UNORM_BLOCK, // BC5_UNORM
VK_FORMAT_BC7_UNORM_BLOCK, // BC7_UNORM
+ VK_FORMAT_BC6H_SFLOAT_BLOCK, // BC6H_FLOAT
+ VK_FORMAT_BC6H_UFLOAT_BLOCK, // BC6H_UFLOAT
+ VK_FORMAT_R8_SNORM, // R8_SNORM
VK_FORMAT_R8G8_SNORM, // R8G8_SNORM
VK_FORMAT_R8G8B8A8_SNORM, // R8G8B8A8_SNORM
+ VK_FORMAT_R16_SNORM, // R16_SNORM
+ VK_FORMAT_R16G16_SNORM, // R16G16_SNORM
+ VK_FORMAT_R16G16B16A16_SNORM, // R16G16B16A16_SNORM
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_B10G11R11_UFLOAT_PACK32, // R11G11B10_UFLOAT
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_R8_SINT, // R8_INT
+ VK_FORMAT_R8G8_SINT, // R8G8_INT
+ VK_FORMAT_R8G8B8A8_SINT, // R8G8B8A8_INT
+ VK_FORMAT_R16_SINT, // R16_INT
+ VK_FORMAT_R16G16_SINT, // R16G16_INT
+ VK_FORMAT_R16G16B16A16_SINT, // R16G16B16A16_INT
VK_FORMAT_R8G8B8A8_SRGB, // R8G8B8A8_UNORM_SRGB
VK_FORMAT_B8G8R8A8_SRGB, // B8G8R8A8_UNORM_SRGB
+ VK_FORMAT_BC1_RGBA_SRGB_BLOCK, // BC1_UNORM_SRGB
+ VK_FORMAT_BC2_SRGB_BLOCK, // BC3_UNORM_SRGB
VK_FORMAT_BC3_SRGB_BLOCK, // BC3_UNORM_SRGB
VK_FORMAT_BC7_SRGB_BLOCK, // BC7_UNORM_SRGB
VK_FORMAT_D16_UNORM, // D16_UNORM
@@ -177,8 +196,26 @@ static VkFormat SDLToVK_SurfaceFormat[] = {
SDL_COMPILE_TIME_ASSERT(SDLToVK_SurfaceFormat, SDL_arraysize(SDLToVK_SurfaceFormat) == SDL_GPU_TEXTUREFORMAT_MAX);
static VkComponentMapping SDLToVK_SurfaceSwizzle[] = {
+ {
+ // A8
+ VK_COMPONENT_SWIZZLE_ZERO,
+ VK_COMPONENT_SWIZZLE_ZERO,
+ VK_COMPONENT_SWIZZLE_ZERO,
+ VK_COMPONENT_SWIZZLE_R,
+ },
+ IDENTITY_SWIZZLE, // R8
+ IDENTITY_SWIZZLE, // R8G8
IDENTITY_SWIZZLE, // R8G8B8A8
- IDENTITY_SWIZZLE, // B8G8R8A8
+ IDENTITY_SWIZZLE, // R16
+ IDENTITY_SWIZZLE, // R16G16
+ IDENTITY_SWIZZLE, // R16G16B16A16
+ {
+ // R10G10B10A2
+ VK_COMPONENT_SWIZZLE_R,
+ VK_COMPONENT_SWIZZLE_G,
+ VK_COMPONENT_SWIZZLE_B,
+ VK_COMPONENT_SWIZZLE_A,
+ },
{
// B5G6R5
VK_COMPONENT_SWIZZLE_B,
@@ -194,43 +231,50 @@ static VkComponentMapping SDLToVK_SurfaceSwizzle[] = {
VK_COMPONENT_SWIZZLE_A,
},
IDENTITY_SWIZZLE, // B4G4R4A4
- {
- // R10G10B10A2
- VK_COMPONENT_SWIZZLE_R,
- VK_COMPONENT_SWIZZLE_G,
- VK_COMPONENT_SWIZZLE_B,
- VK_COMPONENT_SWIZZLE_A,
- },
- IDENTITY_SWIZZLE, // R16G16
- IDENTITY_SWIZZLE, // R16G16B16A16
- IDENTITY_SWIZZLE, // R8
- {
- // A8
- VK_COMPONENT_SWIZZLE_ZERO,
- VK_COMPONENT_SWIZZLE_ZERO,
- VK_COMPONENT_SWIZZLE_ZERO,
- VK_COMPONENT_SWIZZLE_R,
- },
+ IDENTITY_SWIZZLE, // B8G8R8A8
IDENTITY_SWIZZLE, // BC1
IDENTITY_SWIZZLE, // BC2
IDENTITY_SWIZZLE, // BC3
+ IDENTITY_SWIZZLE, // BC4
+ IDENTITY_SWIZZLE, // BC5
IDENTITY_SWIZZLE, // BC7
+ IDENTITY_SWIZZLE, // BC6H_FLOAT
+ IDENTITY_SWIZZLE, // BC6H_UFLOAT
+ IDENTITY_SWIZZLE, // R8_SNORM
IDENTITY_SWIZZLE, // R8G8_SNORM
IDENTITY_SWIZZLE, // R8G8B8A8_SNORM
+ IDENTITY_SWIZZLE, // R16_SNORM
+ IDENTITY_SWIZZLE, // R16G16_SNORM
+ IDENTITY_SWIZZLE, // R16G16B16A16_SNORM
IDENTITY_SWIZZLE, // R16_SFLOAT
IDENTITY_SWIZZLE, // R16G16_SFLOAT
IDENTITY_SWIZZLE, // R16G16B16A16_SFLOAT
IDENTITY_SWIZZLE, // R32_SFLOAT
IDENTITY_SWIZZLE, // R32G32_SFLOAT
IDENTITY_SWIZZLE, // R32G32B32A32_SFLOAT
+ {
+ // R11G11B10_UFLOAT
+ VK_COMPONENT_SWIZZLE_R,
+ VK_COMPONENT_SWIZZLE_G,
+ VK_COMPONENT_SWIZZLE_B,
+ VK_COMPONENT_SWIZZLE_ONE,
+ },
IDENTITY_SWIZZLE, // R8_UINT
IDENTITY_SWIZZLE, // R8G8_UINT
IDENTITY_SWIZZLE, // R8G8B8A8_UINT
IDENTITY_SWIZZLE, // R16_UINT
IDENTITY_SWIZZLE, // R16G16_UINT
IDENTITY_SWIZZLE, // R16G16B16A16_UINT
+ IDENTITY_SWIZZLE, // R8_INT
+ IDENTITY_SWIZZLE, // R8G8_INT
+ IDENTITY_SWIZZLE, // R8G8B8A8_INT
+ IDENTITY_SWIZZLE, // R16_INT
+ IDENTITY_SWIZZLE, // R16G16_INT
+ IDENTITY_SWIZZLE, // R16G16B16A16_INT
IDENTITY_SWIZZLE, // R8G8B8A8_SRGB
IDENTITY_SWIZZLE, // B8G8R8A8_SRGB
+ IDENTITY_SWIZZLE, // BC1_SRGB
+ IDENTITY_SWIZZLE, // BC2_SRGB
IDENTITY_SWIZZLE, // BC3_SRGB
IDENTITY_SWIZZLE, // BC7_SRGB
IDENTITY_SWIZZLE, // D16_UNORM