On 1/9/19 3:22 PM, Rhys Perry wrote:
Fixes artifacts in World of Warcraft when Multi-sample Alpha-Test is
enabled.
It also fixes various piglit interpolateAt*() tests with NIR.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106595
Signed-off-by: Rhys Perry <pendingchao...@gmail.com>
---
  src/amd/common/ac_nir_to_llvm.c              | 2 +-
  src/amd/common/ac_shader_abi.h               | 2 ++
  src/amd/vulkan/radv_nir_to_llvm.c            | 2 ++
  src/gallium/drivers/radeonsi/si_shader_nir.c | 3 +++
  4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 6d97212b805..8fd8580087f 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2829,7 +2829,7 @@ static LLVMValueRef visit_interp(struct ac_nir_context 
*ctx,
        LLVMValueRef src0 = NULL;
nir_variable *var = nir_deref_instr_get_variable(nir_instr_as_deref(instr->src[0].ssa->parent_instr));
-       int input_index = var->data.location - VARYING_SLOT_VAR0;
+       int input_index = ctx->abi->fs_input_attr_indices[var->data.location - 
VARYING_SLOT_VAR0];
        switch (instr->intrinsic) {
        case nir_intrinsic_interp_deref_at_centroid:
                location = INTERP_CENTROID;
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index 6b9a91c92a9..4f51aa9b0c0 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -76,6 +76,8 @@ struct ac_shader_abi {
         * driver_location.
         */
        LLVMValueRef *inputs;

newline

Also, missing Fixes tag?

Other than that, patch is:

Reviewed-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>

+       /* Varying -> attribute number mapping. Also NIR-only */
+       unsigned fs_input_attr_indices[MAX_VARYING];
void (*emit_outputs)(struct ac_shader_abi *abi,
                             unsigned max_outputs,
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c 
b/src/amd/vulkan/radv_nir_to_llvm.c
index 322b10b67a0..cd58167b766 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -2239,6 +2239,8 @@ handle_fs_inputs(struct radv_shader_context *ctx,
if (LLVMIsUndef(interp_param))
                                ctx->shader_info->fs.flat_shaded_mask |= 1u << 
index;
+                       if (i >= VARYING_SLOT_VAR0)
+                               ctx->abi.fs_input_attr_indices[i - 
VARYING_SLOT_VAR0] = index;
                        ++index;
                } else if (i == VARYING_SLOT_CLIP_DIST0) {
                        int length = 
ctx->shader_info->info.ps.num_input_clips_culls;
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 0a692277f64..d5b8a8416d9 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -1019,6 +1019,9 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, 
struct nir_shader *nir)
                        LLVMValueRef data[4];
                        unsigned loc = variable->data.location;
+ if (loc >= VARYING_SLOT_VAR0 && nir->info.stage == MESA_SHADER_FRAGMENT)
+                               ctx->abi.fs_input_attr_indices[loc - 
VARYING_SLOT_VAR0] = input_idx / 4;
+
                        for (unsigned i = 0; i < attrib_count; i++) {
                                /* Packed components share the same location so 
skip
                                 * them if we have already processed the 
location.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to