[Mesa-dev] [PATCH v3 031/104] nir: Support deref instructions in lower_pos_center
Jason Ekstrand
jason at jlekstrand.net
Tue Apr 3 18:32:58 UTC 2018
---
src/compiler/nir/nir_lower_wpos_center.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_lower_wpos_center.c b/src/compiler/nir/nir_lower_wpos_center.c
index dca810d..5b68cac 100644
--- a/src/compiler/nir/nir_lower_wpos_center.c
+++ b/src/compiler/nir/nir_lower_wpos_center.c
@@ -81,7 +81,18 @@ lower_wpos_center_block(nir_builder *b, nir_block *block,
nir_foreach_instr(instr, block) {
if (instr->type == nir_instr_type_intrinsic) {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
- if (intr->intrinsic == nir_intrinsic_load_var) {
+ if (intr->intrinsic == nir_intrinsic_load_deref) {
+ nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
+ nir_variable *var = nir_deref_instr_get_variable(deref);
+
+ if (var->data.mode == nir_var_shader_in &&
+ var->data.location == VARYING_SLOT_POS) {
+ /* gl_FragCoord should not have array/struct derefs: */
+ assert(deref->deref_type == nir_deref_type_var);
+ update_fragcoord(b, intr, for_sample_shading);
+ progress = true;
+ }
+ } else if (intr->intrinsic == nir_intrinsic_load_var) {
nir_deref_var *dvar = intr->variables[0];
nir_variable *var = dvar->var;
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list