radv: Take variable descriptor counts into account for buffer entries.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 29 Jul 2019 14:52:23 +0000 (16:52 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 29 Jul 2019 18:42:53 +0000 (20:42 +0200)
Fixes: b5e04e9217b "radv: Support allocating variable size descriptor sets."
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111019
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_descriptor_set.c

index bf926288aa025504da436c1581ec2dd1e5defa26..7d3e6812b4e9d9ee96f7d2d0fdc230c2a9358f25 100644 (file)
@@ -477,8 +477,17 @@ radv_descriptor_set_create(struct radv_device *device,
                           struct radv_descriptor_set **out_set)
 {
        struct radv_descriptor_set *set;
+       uint32_t buffer_count = layout->buffer_count;
+       if (variable_count) {
+               unsigned stride = 1;
+               if (layout->binding[layout->binding_count - 1].type == VK_DESCRIPTOR_TYPE_SAMPLER ||
+                   layout->binding[layout->binding_count - 1].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT)
+                       stride = 0;
+               buffer_count = layout->binding[layout->binding_count - 1].buffer_offset +
+                              *variable_count * stride;
+       }
        unsigned range_offset = sizeof(struct radv_descriptor_set) +
-               sizeof(struct radeon_winsys_bo *) * layout->buffer_count;
+               sizeof(struct radeon_winsys_bo *) * buffer_count;
        unsigned mem_size = range_offset +
                sizeof(struct radv_descriptor_range) * layout->dynamic_offset_count;