From bcd0d52cd2dd460a4c2ea16ea531fb506d74be36 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 4 Apr 2023 13:10:01 +0200 Subject: [PATCH] radv: fix VS prologs with GPL and static binding stride When a graphics pipeline library is created with only the vertex input state, the driver binds this state at pipeline bind time. Though the vertex binding stride is not necessarily dynamic, in this case the pipeline stride should be used. This fixes GPU hangs with recent dEQP-VK.pipeline.fast_linked_library.vertex_input.*. Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: (cherry picked from commit 9085c9d43e37c643ee9c9fb01b6184fa7c60bffd) --- .pick_status.json | 2 +- src/amd/vulkan/radv_cmd_buffer.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7a622d0b7b6..7f40305ecab 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -7804,7 +7804,7 @@ "description": "radv: fix VS prologs with GPL and static binding stride", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index ae95f4c0449..963d1533b7c 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -3692,8 +3692,8 @@ lookup_vs_prolog(struct radv_cmd_buffer *cmd_buffer, const struct radv_shader *v STATIC_ASSERT(sizeof(union vs_prolog_key_header) == 4); assert(vs_shader->info.vs.dynamic_inputs); + const struct radv_graphics_pipeline *pipeline = cmd_buffer->state.graphics_pipeline; const struct radv_vs_input_state *state = &cmd_buffer->state.dynamic_vs_input; - struct radv_graphics_pipeline *pipeline = cmd_buffer->state.graphics_pipeline; struct radv_device *device = cmd_buffer->device; unsigned num_attributes = pipeline->last_vertex_attrib_bit; @@ -3711,10 +3711,20 @@ lookup_vs_prolog(struct radv_cmd_buffer *cmd_buffer, const struct radv_shader *v uint8_t binding = state->bindings[index]; if (!(cmd_buffer->state.vbo_bound_mask & BITFIELD_BIT(binding))) continue; + uint8_t req = state->format_align_req_minus_1[index]; - struct radv_vertex_binding *vb = &cmd_buffer->vertex_bindings[binding]; - VkDeviceSize offset = vb->offset + state->offsets[index]; - if ((offset & req) || (vb->stride & req)) + uint64_t vb_offset = cmd_buffer->vertex_bindings[binding].offset; + uint64_t vb_stride; + + if (pipeline->dynamic_states & (RADV_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE | + RADV_DYNAMIC_VERTEX_INPUT)) { + vb_stride = cmd_buffer->vertex_bindings[binding].stride; + } else { + vb_stride = pipeline->binding_stride[binding]; + } + + VkDeviceSize offset = vb_offset + state->offsets[index]; + if ((offset & req) || (vb_stride & req)) misaligned_mask |= BITFIELD_BIT(index); } cmd_buffer->state.vbo_misaligned_mask = misaligned_mask;