radv: improve gathering of load_push_constants with dynamic bindings

For example, if a pipeline has two stages VS and FS. And if only
the fragment stage needs dynamic bindings, we shouldn't allocate
an extra user SGPR for the vertex stage. Of course, if the vertex
stage loads constants, it needs an user SGPR.

This should reduce the number of SET_SH_REG packets that are emitted.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Samuel Pitoiset
2019-01-22 19:30:20 +01:00
parent e0485a1dd7
commit 698afa177e
3 changed files with 7 additions and 1 deletions
+3
View File
@@ -345,6 +345,7 @@ VkResult radv_CreatePipelineLayout(
layout->num_sets = pCreateInfo->setLayoutCount;
unsigned dynamic_offset_count = 0;
uint16_t dynamic_shader_stages = 0;
_mesa_sha1_init(&ctx);
@@ -356,6 +357,7 @@ VkResult radv_CreatePipelineLayout(
layout->set[set].dynamic_offset_start = dynamic_offset_count;
for (uint32_t b = 0; b < set_layout->binding_count; b++) {
dynamic_offset_count += set_layout->binding[b].array_size * set_layout->binding[b].dynamic_offset_count;
dynamic_shader_stages |= set_layout->dynamic_shader_stages;
if (set_layout->binding[b].immutable_samplers_offset)
_mesa_sha1_update(&ctx, radv_immutable_samplers(set_layout, set_layout->binding + b),
set_layout->binding[b].array_size * 4 * sizeof(uint32_t));
@@ -365,6 +367,7 @@ VkResult radv_CreatePipelineLayout(
}
layout->dynamic_offset_count = dynamic_offset_count;
layout->dynamic_shader_stages = dynamic_shader_stages;
layout->push_constant_size = 0;
for (unsigned i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
+1
View File
@@ -85,6 +85,7 @@ struct radv_pipeline_layout {
uint32_t num_sets;
uint32_t push_constant_size;
uint32_t dynamic_offset_count;
uint16_t dynamic_shader_stages;
unsigned char sha1[20];
};
+3 -1
View File
@@ -512,8 +512,10 @@ radv_nir_shader_info_pass(const struct nir_shader *nir,
struct nir_function *func =
(struct nir_function *)exec_list_get_head_const(&nir->functions);
if (options->layout && options->layout->dynamic_offset_count)
if (options->layout && options->layout->dynamic_offset_count &&
(options->layout->dynamic_shader_stages & mesa_to_vk_shader_stage(nir->info.stage))) {
info->loads_push_constants = true;
}
nir_foreach_variable(variable, &nir->inputs)
gather_info_input_decl(nir, variable, info);