radv: bail out when binding the same index buffer
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 30 Oct 2017 16:12:05 +0000 (17:12 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 31 Oct 2017 09:16:35 +0000 (10:16 +0100)
DOW3 appears to hit this path.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_private.h

index 12fd70f512230495915c7556e56c1b5d04cef746..00ed7182a7d03f343009bd99e0d98946ed2dde7c 100644 (file)
@@ -2281,6 +2281,15 @@ void radv_CmdBindIndexBuffer(
        RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
        RADV_FROM_HANDLE(radv_buffer, index_buffer, buffer);
 
+       if (cmd_buffer->state.index_buffer == index_buffer &&
+           cmd_buffer->state.index_offset == offset &&
+           cmd_buffer->state.index_type == indexType) {
+               /* No state changes. */
+               return;
+       }
+
+       cmd_buffer->state.index_buffer = index_buffer;
+       cmd_buffer->state.index_offset = offset;
        cmd_buffer->state.index_type = indexType; /* vk matches hw */
        cmd_buffer->state.index_va = radv_buffer_get_va(index_buffer->bo);
        cmd_buffer->state.index_va += index_buffer->offset + offset;
index 381afb777f3ebe374ad42528feeb1012177fc0f3..1b1fa93ee3c8c02eedec61fd4a25400edfe79972 100644 (file)
@@ -815,9 +815,14 @@ struct radv_cmd_state {
        struct radv_descriptor_set *                  descriptors[MAX_SETS];
        struct radv_attachment_state *                attachments;
        VkRect2D                                     render_area;
+
+       /* Index buffer */
+       struct radv_buffer                           *index_buffer;
+       uint64_t                                     index_offset;
        uint32_t                                     index_type;
        uint32_t                                     max_index_count;
        uint64_t                                     index_va;
+
        int32_t                                      last_primitive_reset_en;
        uint32_t                                     last_primitive_reset_index;
        enum radv_cmd_flush_bits                     flush_bits;