That is, index elements of vk_uav_counter_views by their index in uav_counters,
rather than by their register index. This is necessary because multiple UAVs can
share the same register index but differ in register space.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d/command.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 8a7ff66..7c6b758 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -2653,9 +2653,10 @@ static void d3d12_command_list_update_descriptor_table(struct d3d12_command_list
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
struct VkDescriptorImageInfo image_infos[24], *current_image_info;
const struct d3d12_root_descriptor_table *descriptor_table;
+ const struct d3d12_pipeline_state *state = list->state;
const struct d3d12_root_descriptor_table_range *range;
VkDevice vk_device = list->device->vk_device;
- unsigned int i, j, descriptor_count;
+ unsigned int i, j, k, descriptor_count;
struct d3d12_desc *descriptor;
descriptor_table = root_signature_get_descriptor_table(root_signature, index);
@@ -2678,14 +2679,20 @@ static void d3d12_command_list_update_descriptor_table(struct d3d12_command_list
unsigned int register_idx = range->base_register_idx + j;
/* Track UAV counters. */
- if (range->descriptor_magic == VKD3D_DESCRIPTOR_MAGIC_UAV
- && register_idx < ARRAY_SIZE(bindings->vk_uav_counter_views))
+ if (range->descriptor_magic == VKD3D_DESCRIPTOR_MAGIC_UAV)
{
- VkBufferView vk_counter_view = descriptor->magic == VKD3D_DESCRIPTOR_MAGIC_UAV
- ? descriptor->u.view->vk_counter_view : VK_NULL_HANDLE;
- if (bindings->vk_uav_counter_views[register_idx] != vk_counter_view)
- bindings->uav_counter_dirty_mask |= 1u << register_idx;
- bindings->vk_uav_counter_views[register_idx] = vk_counter_view;
+ for (k = 0; k < vkd3d_popcount(state->uav_counter_mask); ++k)
+ {
+ if (state->uav_counters[k].register_index == register_idx)
+ {
+ VkBufferView vk_counter_view = descriptor->magic == VKD3D_DESCRIPTOR_MAGIC_UAV
+ ? descriptor->u.view->vk_counter_view : VK_NULL_HANDLE;
+ if (bindings->vk_uav_counter_views[k] != vk_counter_view)
+ bindings->uav_counter_dirty_mask |= 1u << k;
+ bindings->vk_uav_counter_views[k] = vk_counter_view;
+ break;
+ }
+ }
}
if (!vk_write_descriptor_set_from_d3d12_desc(current_descriptor_write,
@@ -2826,7 +2833,7 @@ static void d3d12_command_list_update_uav_counter_descriptors(struct d3d12_comma
unsigned int uav_counter_count;
unsigned int i;
- if (!state || !(state->uav_counter_mask & bindings->uav_counter_dirty_mask))
+ if (!state || !bindings->uav_counter_dirty_mask)
return;
uav_counter_count = vkd3d_popcount(state->uav_counter_mask);
@@ -2841,7 +2848,7 @@ static void d3d12_command_list_update_uav_counter_descriptors(struct d3d12_comma
const struct vkd3d_shader_uav_counter_binding *uav_counter = &state->uav_counters[i];
const VkBufferView *vk_uav_counter_views = bindings->vk_uav_counter_views;
- assert(vk_uav_counter_views[uav_counter->register_index]);
+ assert(vk_uav_counter_views[i]);
vk_descriptor_writes[i].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
vk_descriptor_writes[i].pNext = NULL;
@@ -2852,7 +2859,7 @@ static void d3d12_command_list_update_uav_counter_descriptors(struct d3d12_comma
vk_descriptor_writes[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
vk_descriptor_writes[i].pImageInfo = NULL;
vk_descriptor_writes[i].pBufferInfo = NULL;
- vk_descriptor_writes[i].pTexelBufferView = &vk_uav_counter_views[uav_counter->register_index];
+ vk_descriptor_writes[i].pTexelBufferView = &vk_uav_counter_views[i];
}
VK_CALL(vkUpdateDescriptorSets(vk_device, uav_counter_count, vk_descriptor_writes, 0, NULL));
--
2.26.2