diff options
author | Bas Nieuwenhuizen <[email protected]> | 2017-06-06 18:22:23 +0200 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2017-06-06 23:23:43 +0200 |
commit | fe0b8d1e8b3343389b466cbd2b823716ead77399 (patch) | |
tree | c6131ad80d051fd7963750a3676db8b90c50b024 /src/amd/vulkan | |
parent | 7063696b71b995388f247e108a6b2b53a521d385 (diff) |
radv: Don't use a divide by index_size.
Divides are pretty slow, and this is in the hot path of a draw.
Signed-off-by: Bas Nieuwenhuizen <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r-- | src/amd/vulkan/radv_cmd_buffer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index c91c7b91880..ed0aa8020ce 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -2643,6 +2643,12 @@ void radv_CmdDraw( radv_cmd_buffer_trace_emit(cmd_buffer); } +static +uint32_t radv_get_max_index_count(struct radv_cmd_buffer *cmd_buffer) { + int index_size_shift = cmd_buffer->state.index_type ? 2 : 1; + return (cmd_buffer->state.index_buffer->size - cmd_buffer->state.index_offset) >> index_size_shift; +} + void radv_CmdDrawIndexed( VkCommandBuffer commandBuffer, uint32_t indexCount, @@ -2653,7 +2659,7 @@ void radv_CmdDrawIndexed( { RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); int index_size = cmd_buffer->state.index_type ? 4 : 2; - uint32_t index_max_size = (cmd_buffer->state.index_buffer->size - cmd_buffer->state.index_offset) / index_size; + uint32_t index_max_size = radv_get_max_index_count(cmd_buffer); uint64_t index_va; radv_cmd_buffer_flush_state(cmd_buffer, true, (instanceCount > 1), false, indexCount); @@ -2789,8 +2795,7 @@ radv_cmd_draw_indexed_indirect_count( uint32_t stride) { RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); - int index_size = cmd_buffer->state.index_type ? 4 : 2; - uint32_t index_max_size = (cmd_buffer->state.index_buffer->size - cmd_buffer->state.index_offset) / index_size; + uint32_t index_max_size = radv_get_max_index_count(cmd_buffer); uint64_t index_va; radv_cmd_buffer_flush_state(cmd_buffer, true, false, true, 0); |