From 54b79d0f504004a7aef772e3eff19efe00b966f5 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 21 Aug 2025 10:35:10 +0200 Subject: [PATCH] radv: add a new dirty bit for the sample locations state Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 13 +++++++++---- src/amd/vulkan/radv_cmd_buffer.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index bc205939f23..3964dc79d81 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -1181,7 +1181,7 @@ radv_compute_centroid_priority(struct radv_cmd_buffer *cmd_buffer, VkOffset2D *s * Emit the sample locations that are specified with VK_EXT_sample_locations. */ static void -radv_emit_sample_locations(struct radv_cmd_buffer *cmd_buffer) +radv_emit_sample_locations_state(struct radv_cmd_buffer *cmd_buffer) { const struct radv_device *device = radv_cmd_buffer_device(cmd_buffer); const struct radv_physical_device *pdev = radv_device_physical(device); @@ -1192,6 +1192,8 @@ radv_emit_sample_locations(struct radv_cmd_buffer *cmd_buffer) VkOffset2D sample_locs[4][8]; /* 8 is the max. sample count supported */ uint64_t centroid_priority; + cmd_buffer->state.dirty &= ~RADV_CMD_DIRTY_SAMPLE_LOCATIONS_STATE; + if (!d->sample_location.count || !d->vk.ms.sample_locations_enable) return; @@ -5388,9 +5390,6 @@ radv_cmd_buffer_flush_dynamic_state(struct radv_cmd_buffer *cmd_buffer, const ui if (states & (RADV_DYNAMIC_SCISSOR | RADV_DYNAMIC_VIEWPORT) && !pdev->info.has_gfx9_scissor_bug) radv_emit_scissor(cmd_buffer); - if (states & (RADV_DYNAMIC_SAMPLE_LOCATIONS | RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE)) - radv_emit_sample_locations(cmd_buffer); - if ((states & RADV_DYNAMIC_PRIMITIVE_TOPOLOGY) || (pdev->info.gfx_level >= GFX12 && states & RADV_DYNAMIC_PATCH_CONTROL_POINTS)) radv_emit_primitive_topology(cmd_buffer); @@ -11466,6 +11465,9 @@ radv_validate_dynamic_states(struct radv_cmd_buffer *cmd_buffer, uint64_t dynami if (dynamic_states & RADV_DYNAMIC_BLEND_CONSTANTS) cmd_buffer->state.dirty |= RADV_CMD_DIRTY_BLEND_CONSTANTS_STATE; + + if (dynamic_states & (RADV_DYNAMIC_SAMPLE_LOCATIONS | RADV_DYNAMIC_SAMPLE_LOCATIONS_ENABLE)) + cmd_buffer->state.dirty |= RADV_CMD_DIRTY_SAMPLE_LOCATIONS_STATE; } static void @@ -11585,6 +11587,9 @@ radv_emit_all_graphics_states(struct radv_cmd_buffer *cmd_buffer, const struct r if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_CB_RENDER_STATE) radv_emit_cb_render_state(cmd_buffer); + if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_SAMPLE_LOCATIONS_STATE) + radv_emit_sample_locations_state(cmd_buffer); + if (cmd_buffer->state.dirty & RADV_CMD_DIRTY_MSAA_STATE) radv_emit_msaa_state(cmd_buffer); diff --git a/src/amd/vulkan/radv_cmd_buffer.h b/src/amd/vulkan/radv_cmd_buffer.h index 93c59cb842c..bd2bbc38f9a 100644 --- a/src/amd/vulkan/radv_cmd_buffer.h +++ b/src/amd/vulkan/radv_cmd_buffer.h @@ -113,7 +113,8 @@ enum radv_cmd_dirty_bits { RADV_CMD_DIRTY_DEPTH_BIAS_STATE = 1ull << 27, RADV_CMD_DIRTY_VS_PROLOG_STATE = 1ull << 28, RADV_CMD_DIRTY_BLEND_CONSTANTS_STATE = 1ull << 29, - RADV_CMD_DIRTY_ALL = (1ull << 30) - 1, + RADV_CMD_DIRTY_SAMPLE_LOCATIONS_STATE = 1ull << 30, + RADV_CMD_DIRTY_ALL = (1ull << 31) - 1, RADV_CMD_DIRTY_SHADER_QUERY = RADV_CMD_DIRTY_NGG_STATE | RADV_CMD_DIRTY_TASK_STATE, };