From fe03f1739a19e858e3d21bea72a64db2476757f6 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 22 Jan 2021 14:16:02 -0800 Subject: [PATCH] change Clear definition to make more sense --- include/Refresh.h | 14 ++++++-------- src/Refresh.c | 6 ++---- src/Refresh_Driver.h | 3 +-- src/Refresh_Driver_Vulkan.c | 15 +++++++-------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/include/Refresh.h b/include/Refresh.h index cef506e..383e861 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -742,12 +742,11 @@ REFRESHAPI void Refresh_DestroyDevice(Refresh_Device *device); * It is generally recommended to clear in BeginRenderPass * rather than by calling this function unless necessary. * - * clearRect: Area to clear. - * options: Bitflags to specify color/depth/stencil buffers for clearing. - * colors: An array of color values for the cleared color buffers. - * colorCount: The number of colors in the above array. - * depth: The new value of the cleared depth buffer. - * stencil: The new value of the cleared stencil buffer. + * clearRect: Area to clear. + * options: Bitflags to specify color/depth/stencil buffers for clearing. + * colors: An array of color values for the cleared color buffers. + * colorCount: The number of colors in the above array. + * depthStencil: Depth and stencil values for the cleared depth stencil buffer. */ REFRESHAPI void Refresh_Clear( Refresh_Device *device, @@ -756,8 +755,7 @@ REFRESHAPI void Refresh_Clear( Refresh_ClearOptions options, Refresh_Color *colors, uint32_t colorCount, - float depth, - int32_t stencil + Refresh_DepthStencilValue depthStencil ); /* Draws data from vertex/index buffers with instancing enabled. diff --git a/src/Refresh.c b/src/Refresh.c index 34daabe..5496752 100644 --- a/src/Refresh.c +++ b/src/Refresh.c @@ -174,8 +174,7 @@ void Refresh_Clear( Refresh_ClearOptions options, Refresh_Color *colors, uint32_t colorCount, - float depth, - int32_t stencil + Refresh_DepthStencilValue depthStencil ) { NULL_RETURN(device); device->Clear( @@ -185,8 +184,7 @@ void Refresh_Clear( options, colors, colorCount, - depth, - stencil + depthStencil ); } diff --git a/src/Refresh_Driver.h b/src/Refresh_Driver.h index a92f939..c4a2b9f 100644 --- a/src/Refresh_Driver.h +++ b/src/Refresh_Driver.h @@ -174,8 +174,7 @@ struct Refresh_Device Refresh_ClearOptions options, Refresh_Color *colors, uint32_t colorCount, - float depth, - int32_t stencil + Refresh_DepthStencilValue depthStencil ); void (*DrawInstancedPrimitives)( diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index e035896..ed7641c 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -3694,8 +3694,7 @@ static void VULKAN_Clear( Refresh_ClearOptions options, Refresh_Color *colors, uint32_t colorCount, - float depth, - int32_t stencil + Refresh_DepthStencilValue depthStencil ) { VulkanRenderer* renderer = (VulkanRenderer*) driverData; VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer; @@ -3762,16 +3761,16 @@ static void VULKAN_Clear( if (shouldClearDepth) { - if (depth < 0.0f) + if (depthStencil.depth < 0.0f) { - depth = 0.0f; + depthStencil.depth = 0.0f; } - else if (depth > 1.0f) + else if (depthStencil.depth > 1.0f) { - depth = 1.0f; + depthStencil.depth = 1.0f; } clearAttachments[attachmentCount].aspectMask |= VK_IMAGE_ASPECT_DEPTH_BIT; - clearAttachments[attachmentCount].clearValue.depthStencil.depth = depth; + clearAttachments[attachmentCount].clearValue.depthStencil.depth = depthStencil.depth; } else { @@ -3781,7 +3780,7 @@ static void VULKAN_Clear( if (shouldClearStencil) { clearAttachments[attachmentCount].aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; - clearAttachments[attachmentCount].clearValue.depthStencil.stencil = stencil; + clearAttachments[attachmentCount].clearValue.depthStencil.stencil = depthStencil.stencil; } else {