On 10/31/2017 09:37 AM, Bas Nieuwenhuizen wrote:
Reviewed-by: Bas Nieuwenhuizen <[email protected]>

Since we store buffer and offset, do we want to calculate index_va at
emit time, so we don't have to store it?

I wasn't sure myself because the draw code path is really the hot spot. Though, this could save 12 bytes (max_index_count can also be computed at emit time).



On Mon, Oct 30, 2017 at 5:12 PM, Samuel Pitoiset
<[email protected]> wrote:
DOW3 appears to hit this path.

Signed-off-by: Samuel Pitoiset <[email protected]>
---
  src/amd/vulkan/radv_cmd_buffer.c | 9 +++++++++
  src/amd/vulkan/radv_private.h    | 5 +++++
  2 files changed, 14 insertions(+)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 12fd70f512..00ed7182a7 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -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;
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 381afb777f..1b1fa93ee3 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -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;
--
2.14.3

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to