From 7a6aef60b6ae70909447a19c0cf01a9f3db608c0 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sun, 21 May 2023 15:19:56 +0300 Subject: [PATCH] anv: fix push descriptor deferred surface state packing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Yuzu is running into a segfault because it writes the push descriptor twice with 2 different layouts, but without a draw/dispatch in between. First vkCmdPushDescriptorSetKHR() writes descriptor 0 & 1 with a uniform buffer. We toggle the 2 first bits of anv_descriptor_set::generate_surface_states. Second vkCmdPushDescriptorSetKHR() writes descriptor 0 with uniform buffer and descriptor 1 with an image view. The first bit of anv_descriptor_set::generate_surface_states stays, but the second bit was already set before and it should now be off. When we finally flush the push descriptor, we try to generate a surface state for descriptor 1, but there is no valid buffer view for it, we access an invalid pointer and segfault. This fix resets the anv_descriptor_set::generate_surface_states when the descriptor layout changes. Signed-off-by: Lionel Landwerlin Fixes: b49b18f0b7 ("anv: reduce BT emissions & surface state writes with push descriptors") Reviewed-by: Tapani Pälli Part-of: (cherry picked from commit cab7ba00e2ea57ba8205ff11bae29aabfd37b8c4) --- .pick_status.json | 2 +- src/intel/vulkan/anv_cmd_buffer.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 13ea2e0f05b..79d8712a4be 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -679,7 +679,7 @@ "description": "anv: fix push descriptor deferred surface state packing", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b49b18f0b7acb4c64a0a9fd2ee55aeea868e701d" }, diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index f79ff5d09d0..f7f6d3784e5 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -864,6 +864,7 @@ anv_cmd_buffer_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer, anv_descriptor_set_layout_unref(cmd_buffer->device, set->layout); anv_descriptor_set_layout_ref(layout); set->layout = layout; + set->generate_surface_states = 0; } set->is_push = true; set->size = anv_descriptor_set_layout_size(layout, false /* host_only */, 0);