From eedd2039f92b0b3ad49a728050d4d64cd423dd64 Mon Sep 17 00:00:00 2001
From: cosmonaut <[EMAIL REDACTED]>
Date: Fri, 27 Sep 2024 12:52:22 -0700
Subject: [PATCH] GPU: 32-bit component texture formats
---
include/SDL3/SDL_gpu.h | 9 +++++++++
src/gpu/d3d11/SDL_gpu_d3d11.c | 6 ++++++
src/gpu/d3d12/SDL_gpu_d3d12.c | 6 ++++++
src/gpu/metal/SDL_gpu_metal.m | 6 ++++++
src/gpu/vulkan/SDL_gpu_vulkan.c | 6 ++++++
5 files changed, 33 insertions(+)
diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h
index 914ce76562253..24031de9cc074 100644
--- a/include/SDL3/SDL_gpu.h
+++ b/include/SDL3/SDL_gpu.h
@@ -309,6 +309,9 @@ typedef enum SDL_GPUIndexElementSize
* a format is supported before using it. However, there are a few guaranteed
* formats.
*
+ * FIXME: Check universal support for 32-bit component formats
+ * FIXME: Check universal support for SIMULTANEOUS_READ_WRITE
+ *
* For SAMPLER usage, the following formats are universally supported:
*
* - R8G8B8A8_UNORM
@@ -435,6 +438,9 @@ typedef enum SDL_GPUTextureFormat
SDL_GPU_TEXTUREFORMAT_R16_UINT,
SDL_GPU_TEXTUREFORMAT_R16G16_UINT,
SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT,
+ SDL_GPU_TEXTUREFORMAT_R32_UINT,
+ SDL_GPU_TEXTUREFORMAT_R32G32_UINT,
+ SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT,
/* Signed Integer Color Formats */
SDL_GPU_TEXTUREFORMAT_R8_INT,
SDL_GPU_TEXTUREFORMAT_R8G8_INT,
@@ -442,6 +448,9 @@ typedef enum SDL_GPUTextureFormat
SDL_GPU_TEXTUREFORMAT_R16_INT,
SDL_GPU_TEXTUREFORMAT_R16G16_INT,
SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT,
+ SDL_GPU_TEXTUREFORMAT_R32_INT,
+ SDL_GPU_TEXTUREFORMAT_R32G32_INT,
+ SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT,
/* SRGB Unsigned Normalized Color Formats */
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB,
SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB,
diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c
index af0f6e93ed4bd..877621441033b 100644
--- a/src/gpu/d3d11/SDL_gpu_d3d11.c
+++ b/src/gpu/d3d11/SDL_gpu_d3d11.c
@@ -214,12 +214,18 @@ static DXGI_FORMAT SDLToD3D11_TextureFormat[] = {
DXGI_FORMAT_R16_UINT, // R16_UINT
DXGI_FORMAT_R16G16_UINT, // R16G16_UINT
DXGI_FORMAT_R16G16B16A16_UINT, // R16G16B16A16_UINT
+ DXGI_FORMAT_R32_UINT, // R32_UINT
+ DXGI_FORMAT_R32G32_UINT, // R32G32_UINT
+ DXGI_FORMAT_R32G32B32A32_UINT, // R32G32B32A32_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_R32_SINT, // R32_INT
+ DXGI_FORMAT_R32G32_SINT, // R32G32_INT
+ DXGI_FORMAT_R32G32B32A32_SINT, // R32G32B32A32_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
diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c
index df81d6a595fe8..37cedb86a8e65 100644
--- a/src/gpu/d3d12/SDL_gpu_d3d12.c
+++ b/src/gpu/d3d12/SDL_gpu_d3d12.c
@@ -290,12 +290,18 @@ static DXGI_FORMAT SDLToD3D12_TextureFormat[] = {
DXGI_FORMAT_R16_UINT, // R16_UINT
DXGI_FORMAT_R16G16_UINT, // R16G16_UINT
DXGI_FORMAT_R16G16B16A16_UINT, // R16G16B16A16_UINT
+ DXGI_FORMAT_R32_UINT, // R32_UINT
+ DXGI_FORMAT_R32G32_UINT, // R32G32_UINT
+ DXGI_FORMAT_R32G32B32A32_UINT, // R32G32B32A32_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_R32_SINT, // R32_INT
+ DXGI_FORMAT_R32G32_SINT, // R32G32_INT
+ DXGI_FORMAT_R32G32B32A32_SINT, // R32G32B32A32_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
diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m
index ac06b1cea285b..a9c93d5971e7a 100644
--- a/src/gpu/metal/SDL_gpu_metal.m
+++ b/src/gpu/metal/SDL_gpu_metal.m
@@ -128,12 +128,18 @@ static void METAL_ReleaseWindow(
MTLPixelFormatR16Uint, // R16_UINT
MTLPixelFormatRG16Uint, // R16G16_UINT
MTLPixelFormatRGBA16Uint, // R16G16B16A16_UINT
+ MTLPixelFormatR32Uint, // R32_UINT
+ MTLPixelFormatRG32Uint, // R32G32_UINT
+ MTLPixelFormatRGBA32Uint, // R32G32B32A32_UINT
MTLPixelFormatR8Sint, // R8_UINT
MTLPixelFormatRG8Sint, // R8G8_UINT
MTLPixelFormatRGBA8Sint, // R8G8B8A8_UINT
MTLPixelFormatR16Sint, // R16_UINT
MTLPixelFormatRG16Sint, // R16G16_UINT
MTLPixelFormatRGBA16Sint, // R16G16B16A16_UINT
+ MTLPixelFormatR32Sint, // R32_INT
+ MTLPixelFormatRG32Sint, // R32G32_INT
+ MTLPixelFormatRGBA32Sint, // R32G32B32A32_INT
MTLPixelFormatRGBA8Unorm_sRGB, // R8G8B8A8_UNORM_SRGB
MTLPixelFormatBGRA8Unorm_sRGB, // B8G8R8A8_UNORM_SRGB
#ifdef SDL_PLATFORM_MACOS
diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c
index 69750620ebf2c..fc2e5fa27983d 100644
--- a/src/gpu/vulkan/SDL_gpu_vulkan.c
+++ b/src/gpu/vulkan/SDL_gpu_vulkan.c
@@ -176,12 +176,18 @@ static VkFormat SDLToVK_TextureFormat[] = {
VK_FORMAT_R16_UINT, // R16_UINT
VK_FORMAT_R16G16_UINT, // R16G16_UINT
VK_FORMAT_R16G16B16A16_UINT, // R16G16B16A16_UINT
+ VK_FORMAT_R32_UINT, // R32_UINT
+ VK_FORMAT_R32G32_UINT, // R32G32_UINT
+ VK_FORMAT_R32G32B32A32_UINT, // R32G32B32A32_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_R32_SINT, // R32_INT
+ VK_FORMAT_R32G32_SINT, // R32G32_INT
+ VK_FORMAT_R32G32B32A32_SINT, // R32G32B32A32_INT
VK_FORMAT_R8G8B8A8_SRGB, // R8G8B8A8_UNORM_SRGB
VK_FORMAT_B8G8R8A8_SRGB, // B8G8R8A8_UNORM_SRGB
VK_FORMAT_BC1_RGBA_SRGB_BLOCK, // BC1_UNORM_SRGB