From d3091b95389a657c041d50e5d80df28f2e1e4dbb Mon Sep 17 00:00:00 2001
From: cosmonaut <[EMAIL REDACTED]>
Date: Mon, 9 Sep 2024 10:40:14 -0700
Subject: [PATCH] Remove SDL_GPUDepthStencilValue struct
---
include/SDL3/SDL_gpu.h | 21 ++-------------------
src/gpu/d3d11/SDL_gpu_d3d11.c | 4 ++--
src/gpu/d3d12/SDL_gpu_d3d12.c | 4 ++--
src/gpu/metal/SDL_gpu_metal.m | 4 ++--
src/gpu/vulkan/SDL_gpu_vulkan.c | 4 ++--
test/testgpu_spinning_cube.c | 2 +-
6 files changed, 11 insertions(+), 28 deletions(-)
diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h
index 7a1c29657a423..ffbc51a9692b7 100644
--- a/include/SDL3/SDL_gpu.h
+++ b/include/SDL3/SDL_gpu.h
@@ -943,23 +943,6 @@ typedef enum SDL_GPUDriver
/* Structures */
-/**
- * A structure specifying a depth-stencil clear value.
- *
- * \since This struct is available since SDL 3.0.0
- *
- * \sa SDL_GPUDepthStencilTargetInfo
- * \sa SDL_BeginGPURenderPass
- */
-typedef struct SDL_GPUDepthStencilValue
-{
- float depth; /**< The clear value for the depth aspect of the depth-stencil target. */
- Uint8 stencil; /**< The clear value for the stencil aspect of the depth-stencil target. */
- Uint8 padding1;
- Uint8 padding2;
- Uint8 padding3;
-} SDL_GPUDepthStencilValue;
-
/**
* A structure specifying a viewport.
*
@@ -1592,15 +1575,15 @@ typedef struct SDL_GPUColorTargetInfo
typedef struct SDL_GPUDepthStencilTargetInfo
{
SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */
- SDL_GPUDepthStencilValue clear_value; /**< The depth-stencil clear values. Can be ignored by the render pass if SDL_GPU_LOADOP_CLEAR is not used. */
+ float clear_depth; /**< The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */
SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */
SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */
SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */
SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */
SDL_bool cycle; /**< SDL_TRUE cycles the texture if the texture is bound and any load ops are not LOAD */
+ Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */
Uint8 padding1;
Uint8 padding2;
- Uint8 padding3;
} SDL_GPUDepthStencilTargetInfo;
/**
diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c
index f657452c2d5d6..bd741c0422e11 100644
--- a/src/gpu/d3d11/SDL_gpu_d3d11.c
+++ b/src/gpu/d3d11/SDL_gpu_d3d11.c
@@ -3561,8 +3561,8 @@ static void D3D11_BeginRenderPass(
d3d11CommandBuffer->context,
dsv,
dsClearFlags,
- depthStencilTargetInfo->clear_value.depth,
- depthStencilTargetInfo->clear_value.stencil);
+ depthStencilTargetInfo->clear_depth,
+ depthStencilTargetInfo->clear_stencil);
}
}
diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c
index 4f0dd720c7587..2792bde7478e1 100644
--- a/src/gpu/d3d12/SDL_gpu_d3d12.c
+++ b/src/gpu/d3d12/SDL_gpu_d3d12.c
@@ -3905,8 +3905,8 @@ static void D3D12_BeginRenderPass(
d3d12CommandBuffer->graphicsCommandList,
subresource->dsvHandle.cpuHandle,
clearFlags,
- depthStencilTargetInfo->clear_value.depth,
- depthStencilTargetInfo->clear_value.stencil,
+ depthStencilTargetInfo->clear_depth,
+ depthStencilTargetInfo->clear_stencil,
0,
NULL);
}
diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m
index 851c775c39912..c251267ea3675 100644
--- a/src/gpu/metal/SDL_gpu_metal.m
+++ b/src/gpu/metal/SDL_gpu_metal.m
@@ -2204,7 +2204,7 @@ static void METAL_BeginRenderPass(
passDescriptor.depthAttachment.storeAction = SDLToMetal_StoreOp(
depthStencilTargetInfo->store_op,
texture->msaaHandle ? 1 : 0);
- passDescriptor.depthAttachment.clearDepth = depthStencilTargetInfo->clear_value.depth;
+ passDescriptor.depthAttachment.clearDepth = depthStencilTargetInfo->clear_depth;
if (IsStencilFormat(container->header.info.format)) {
if (texture->msaaHandle) {
@@ -2217,7 +2217,7 @@ static void METAL_BeginRenderPass(
passDescriptor.stencilAttachment.storeAction = SDLToMetal_StoreOp(
depthStencilTargetInfo->store_op,
texture->msaaHandle ? 1 : 0);
- passDescriptor.stencilAttachment.clearStencil = depthStencilTargetInfo->clear_value.stencil;
+ passDescriptor.stencilAttachment.clearStencil = depthStencilTargetInfo->clear_stencil;
}
METAL_INTERNAL_TrackTexture(metalCommandBuffer, texture);
diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c
index 757e4789bad48..174be59033507 100644
--- a/src/gpu/vulkan/SDL_gpu_vulkan.c
+++ b/src/gpu/vulkan/SDL_gpu_vulkan.c
@@ -8011,9 +8011,9 @@ static void VULKAN_BeginRenderPass(
if (depthStencilTargetInfo != NULL) {
clearValues[totalColorAttachmentCount].depthStencil.depth =
- depthStencilTargetInfo->clear_value.depth;
+ depthStencilTargetInfo->clear_depth;
clearValues[totalColorAttachmentCount].depthStencil.stencil =
- depthStencilTargetInfo->clear_value.stencil;
+ depthStencilTargetInfo->clear_stencil;
}
VkRenderPassBeginInfo renderPassBeginInfo;
diff --git a/test/testgpu_spinning_cube.c b/test/testgpu_spinning_cube.c
index 47705b678016f..653cadc60c15e 100644
--- a/test/testgpu_spinning_cube.c
+++ b/test/testgpu_spinning_cube.c
@@ -369,7 +369,7 @@ Render(SDL_Window *window, const int windownum)
color_target.texture = winstate->tex_msaa ? winstate->tex_msaa : swapchain;
SDL_zero(depth_target);
- depth_target.clear_value.depth = 1.0f;
+ depth_target.clear_depth = 1.0f;
depth_target.load_op = SDL_GPU_LOADOP_CLEAR;
depth_target.store_op = SDL_GPU_STOREOP_DONT_CARE;
depth_target.texture = winstate->tex_depth;