summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2019-06-26 15:11:02 +0200
committerSamuel Pitoiset <[email protected]>2019-07-01 14:59:24 +0200
commite3baa54195b665461bce7eb76a4b30a919b36213 (patch)
tree1354449cc81d01571bc2a3c4ad5e132e7c2f0c7c
parent17cb7ea6fced033d4b8daaf8311d09aa693c7fd7 (diff)
radv: gather if a vertex shaders needs the instance ID
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r--src/amd/vulkan/radv_shader_info.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c
index e771ad79878..dcf8d395374 100644
--- a/src/amd/vulkan/radv_shader_info.c
+++ b/src/amd/vulkan/radv_shader_info.c
@@ -376,12 +376,21 @@ gather_info_block(const nir_shader *nir, const nir_block *block,
static void
gather_info_input_decl_vs(const nir_shader *nir, const nir_variable *var,
- struct radv_shader_info *info)
+ struct radv_shader_info *info,
+ const struct radv_nir_compiler_options *options)
{
+ unsigned attrib_count = glsl_count_attribute_slots(var->type, true);
int idx = var->data.location;
if (idx >= VERT_ATTRIB_GENERIC0 && idx <= VERT_ATTRIB_GENERIC15)
info->vs.has_vertex_buffers = true;
+
+ for (unsigned i = 0; i < attrib_count; ++i) {
+ unsigned attrib_index = var->data.location + i - VERT_ATTRIB_GENERIC0;
+
+ if (options->key.vs.instance_rate_inputs & (1u << attrib_index))
+ info->vs.needs_instance_id = true;
+ }
}
static void
@@ -418,11 +427,12 @@ gather_info_input_decl_ps(const nir_shader *nir, const nir_variable *var,
static void
gather_info_input_decl(const nir_shader *nir, const nir_variable *var,
- struct radv_shader_info *info)
+ struct radv_shader_info *info,
+ const struct radv_nir_compiler_options *options)
{
switch (nir->info.stage) {
case MESA_SHADER_VERTEX:
- gather_info_input_decl_vs(nir, var, info);
+ gather_info_input_decl_vs(nir, var, info, options);
break;
case MESA_SHADER_FRAGMENT:
gather_info_input_decl_ps(nir, var, info);
@@ -557,7 +567,7 @@ radv_nir_shader_info_pass(const struct nir_shader *nir,
}
nir_foreach_variable(variable, &nir->inputs)
- gather_info_input_decl(nir, variable, info);
+ gather_info_input_decl(nir, variable, info, options);
nir_foreach_block(block, func->impl) {
gather_info_block(nir, block, info);