radv: pre-calc vertex buffer descriptor size on pipeline object
util_bitcount has a nonzero cost, and calling it like this in a hotpath generates unnecessary overhead Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11525>
This commit is contained in:
committed by
Marge Bot
parent
936c21d376
commit
c0397a42ce
@@ -1053,7 +1053,7 @@ radv_emit_prefetch_L2(struct radv_cmd_buffer *cmd_buffer, struct radv_pipeline *
|
||||
radv_emit_shader_prefetch(cmd_buffer, pipeline->shaders[MESA_SHADER_VERTEX]);
|
||||
|
||||
if (mask & RADV_PREFETCH_VBO_DESCRIPTORS)
|
||||
si_cp_dma_prefetch(cmd_buffer, state->vb_va, state->vb_size);
|
||||
si_cp_dma_prefetch(cmd_buffer, state->vb_va, pipeline->vb_desc_alloc_size);
|
||||
|
||||
if (mask & RADV_PREFETCH_TCS)
|
||||
radv_emit_shader_prefetch(cmd_buffer, pipeline->shaders[MESA_SHADER_TESS_CTRL]);
|
||||
@@ -2837,11 +2837,10 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer, bool pipeline_
|
||||
void *vb_ptr;
|
||||
unsigned desc_index = 0;
|
||||
uint32_t mask = pipeline->vb_desc_usage_mask;
|
||||
uint32_t count = util_bitcount(mask);
|
||||
uint64_t va;
|
||||
|
||||
/* allocate some descriptor state for vertex buffers */
|
||||
if (!radv_cmd_buffer_upload_alloc(cmd_buffer, count * 16, &vb_offset, &vb_ptr))
|
||||
if (!radv_cmd_buffer_upload_alloc(cmd_buffer, pipeline->vb_desc_alloc_size, &vb_offset, &vb_ptr))
|
||||
return;
|
||||
|
||||
while (mask) {
|
||||
@@ -2924,7 +2923,6 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer, bool pipeline_
|
||||
va);
|
||||
|
||||
cmd_buffer->state.vb_va = va;
|
||||
cmd_buffer->state.vb_size = count * 16;
|
||||
cmd_buffer->state.prefetch_L2_mask |= RADV_PREFETCH_VBO_DESCRIPTORS;
|
||||
|
||||
if (unlikely(cmd_buffer->device->trace_bo))
|
||||
|
||||
@@ -5305,6 +5305,7 @@ radv_pipeline_init_vertex_input_state(struct radv_pipeline *pipeline,
|
||||
|
||||
pipeline->use_per_attribute_vb_descs = info->vs.use_per_attribute_vb_descs;
|
||||
pipeline->vb_desc_usage_mask = info->vs.vb_desc_usage_mask;
|
||||
pipeline->vb_desc_alloc_size = util_bitcount(pipeline->vb_desc_usage_mask) * 16;
|
||||
}
|
||||
|
||||
static struct radv_shader_variant *
|
||||
|
||||
@@ -1342,7 +1342,6 @@ enum rgp_flush_bits {
|
||||
struct radv_cmd_state {
|
||||
/* Vertex descriptors */
|
||||
uint64_t vb_va;
|
||||
unsigned vb_size;
|
||||
|
||||
bool predicating;
|
||||
uint64_t dirty;
|
||||
@@ -1730,6 +1729,7 @@ struct radv_pipeline {
|
||||
|
||||
bool use_per_attribute_vb_descs;
|
||||
uint32_t vb_desc_usage_mask;
|
||||
uint32_t vb_desc_alloc_size;
|
||||
|
||||
uint32_t user_data_0[MESA_SHADER_STAGES];
|
||||
union {
|
||||
|
||||
Reference in New Issue
Block a user