[Mesa-dev] [PATCH] ac/nir: fix potential issues when scanning flat_shaded_mask
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Mar 6 15:58:46 UTC 2018
As far as I understand, this might overflow and shifted by one
if for example, gl_PrimitiveID is used with flat generic varyings.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/amd/common/ac_nir_to_llvm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index ea51c3a54a..d4fdb8e8f4 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -5545,6 +5545,7 @@ handle_fs_inputs(struct radv_shader_context *ctx,
nir_foreach_variable(variable, &nir->inputs)
handle_fs_input_decl(ctx, variable);
+ uint64_t flat_shaded_mask = 0;
unsigned index = 0;
if (ctx->shader_info->info.ps.uses_input_attachments ||
@@ -5564,8 +5565,8 @@ handle_fs_inputs(struct radv_shader_context *ctx,
interp_fs_input(ctx, index, interp_param, ctx->abi.prim_mask,
inputs);
- if (!interp_param)
- ctx->shader_info->fs.flat_shaded_mask |= 1u << index;
+ if (i >= VARYING_SLOT_VAR0 && !interp_param)
+ flat_shaded_mask |= 1u << i;
++index;
} else if (i == VARYING_SLOT_POS) {
for(int i = 0; i < 3; ++i)
@@ -5575,7 +5576,9 @@ handle_fs_inputs(struct radv_shader_context *ctx,
ctx->abi.frag_pos[3]);
}
}
+
ctx->shader_info->fs.num_interp = index;
+ ctx->shader_info->fs.flat_shaded_mask = flat_shaded_mask >> VARYING_SLOT_VAR0;
ctx->shader_info->fs.input_mask = ctx->input_mask >> VARYING_SLOT_VAR0;
if (ctx->shader_info->info.needs_multiview_view_index)
--
2.16.2
More information about the mesa-dev
mailing list