From 2ed84bbe35ef56391846ca2e67225026ad052b2c Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 22 Aug 2025 10:42:07 +0200 Subject: [PATCH] radv: add radv_cmd_set_depth_clamp_range() Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index a17124759f4..32464dfc37b 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -96,6 +96,20 @@ radv_cmd_set_patch_control_points(struct radv_cmd_buffer *cmd_buffer, uint32_t p state->dirty_dynamic |= RADV_DYNAMIC_PATCH_CONTROL_POINTS; } +ALWAYS_INLINE static void +radv_cmd_set_depth_clamp_range(struct radv_cmd_buffer *cmd_buffer, VkDepthClampModeEXT depth_clamp_mode, + const VkDepthClampRangeEXT *depth_clamp_range) +{ + struct radv_cmd_state *state = &cmd_buffer->state; + + state->dynamic.vk.vp.depth_clamp_mode = depth_clamp_mode; + if (depth_clamp_mode == VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT) { + state->dynamic.vk.vp.depth_clamp_range = *depth_clamp_range; + } + + state->dirty_dynamic |= RADV_DYNAMIC_DEPTH_CLAMP_RANGE; +} + static void radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const struct radv_dynamic_state *src) { @@ -213,9 +227,6 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const struct radv_dy RADV_CMP_COPY(vk.ia.primitive_restart_enable, RADV_DYNAMIC_PRIMITIVE_RESTART_ENABLE); RADV_CMP_COPY(vk.vp.depth_clip_negative_one_to_one, RADV_DYNAMIC_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE); - RADV_CMP_COPY(vk.vp.depth_clamp_mode, RADV_DYNAMIC_DEPTH_CLAMP_RANGE); - RADV_CMP_COPY(vk.vp.depth_clamp_range.minDepthClamp, RADV_DYNAMIC_DEPTH_CLAMP_RANGE); - RADV_CMP_COPY(vk.vp.depth_clamp_range.maxDepthClamp, RADV_DYNAMIC_DEPTH_CLAMP_RANGE); if (copy_mask & RADV_DYNAMIC_LINE_WIDTH) { if (dest->vk.rs.line.width != src->vk.rs.line.width) { @@ -235,6 +246,14 @@ radv_bind_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const struct radv_dy } } + if (copy_mask & RADV_DYNAMIC_DEPTH_CLAMP_RANGE) { + if (dest->vk.vp.depth_clamp_mode != src->vk.vp.depth_clamp_mode || + dest->vk.vp.depth_clamp_range.minDepthClamp != src->vk.vp.depth_clamp_range.minDepthClamp || + dest->vk.vp.depth_clamp_range.maxDepthClamp != src->vk.vp.depth_clamp_range.maxDepthClamp) { + radv_cmd_set_depth_clamp_range(cmd_buffer, src->vk.vp.depth_clamp_mode, &src->vk.vp.depth_clamp_range); + } + } + RADV_CMP_COPY(vk.rs.depth_bias.constant_factor, RADV_DYNAMIC_DEPTH_BIAS); RADV_CMP_COPY(vk.rs.depth_bias.clamp, RADV_DYNAMIC_DEPTH_BIAS); RADV_CMP_COPY(vk.rs.depth_bias.slope_factor, RADV_DYNAMIC_DEPTH_BIAS); @@ -14874,12 +14893,5 @@ radv_CmdSetDepthClampRangeEXT(VkCommandBuffer commandBuffer, VkDepthClampModeEXT const VkDepthClampRangeEXT *pDepthClampRange) { VK_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); - struct radv_cmd_state *state = &cmd_buffer->state; - - state->dynamic.vk.vp.depth_clamp_mode = depthClampMode; - if (depthClampMode == VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT) { - state->dynamic.vk.vp.depth_clamp_range = *pDepthClampRange; - } - - state->dirty_dynamic |= RADV_DYNAMIC_DEPTH_CLAMP_RANGE; + radv_cmd_set_depth_clamp_range(cmd_buffer, depthClampMode, pDepthClampRange); }