From f87c58dde38902d9bfb5a046b4bf1b5e56c55fcf Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 8 Nov 2017 12:12:31 +0100 Subject: [PATCH] radv: prefetch VBO descriptors at the right place Just after the vertex shader. This seems to give a minor boost for, at least, Serious Sam Fusion 2017 and Dawn of War 3. I don't see any real impacts with The Talos Principle. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_cmd_buffer.c | 16 ++++++++++++++++ src/amd/vulkan/radv_private.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 1d552e2..a2ad9fa 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -669,6 +669,17 @@ radv_emit_prefetch_TC_L2_async(struct radv_cmd_buffer *cmd_buffer, uint64_t va, } static void +radv_emit_VBO_descriptors_prefetch(struct radv_cmd_buffer *cmd_buffer) +{ + if (cmd_buffer->state.vb_prefetch_dirty) { + radv_emit_prefetch_TC_L2_async(cmd_buffer, + cmd_buffer->state.vb_va, + cmd_buffer->state.vb_size); + cmd_buffer->state.vb_prefetch_dirty = false; + } +} + +static void radv_emit_shader_prefetch(struct radv_cmd_buffer *cmd_buffer, struct radv_shader_variant *shader) { @@ -691,6 +702,7 @@ radv_emit_prefetch(struct radv_cmd_buffer *cmd_buffer, { radv_emit_shader_prefetch(cmd_buffer, pipeline->shaders[MESA_SHADER_VERTEX]); + radv_emit_VBO_descriptors_prefetch(cmd_buffer); radv_emit_shader_prefetch(cmd_buffer, pipeline->shaders[MESA_SHADER_TESS_CTRL]); radv_emit_shader_prefetch(cmd_buffer, @@ -1814,6 +1826,10 @@ radv_cmd_buffer_update_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer, bo radv_emit_userdata_address(cmd_buffer, cmd_buffer->state.pipeline, MESA_SHADER_VERTEX, AC_UD_VS_VERTEX_BUFFERS, va); + + cmd_buffer->state.vb_va = va; + cmd_buffer->state.vb_size = count * 16; + cmd_buffer->state.vb_prefetch_dirty = true; } cmd_buffer->state.vb_dirty = false; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 58b9f46..79f52c6 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -809,7 +809,12 @@ struct radv_attachment_state { }; struct radv_cmd_state { + /* Vertex descriptors */ bool vb_dirty; + bool vb_prefetch_dirty; + uint64_t vb_va; + unsigned vb_size; + bool push_descriptors_dirty; bool predicating; radv_cmd_dirty_mask_t dirty; -- 2.7.4