summaryrefslogtreecommitdiffstats
path: root/src/broadcom/compiler
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-06-14 11:04:05 -0700
committerEric Anholt <[email protected]>2018-06-15 16:09:39 -0700
commite130ada24310f0e3adc0349c0fb2098ad20d65d9 (patch)
treed8c52e111ec057dcd5d898a8c4f67814541e8de0 /src/broadcom/compiler
parent0d4f338a116f6be23706c0ab7a253561c02a2145 (diff)
v3d: Fix shaders using pixel center W but no varyings.
The docs called this field "uses both center W and centroid W", but actually it's "do you need center W even if varyings don't obviously call for it?" Fixes dEQP-GLES3.functional.shaders.builtin_variable.fragcoord_w
Diffstat (limited to 'src/broadcom/compiler')
-rw-r--r--src/broadcom/compiler/nir_to_vir.c17
-rw-r--r--src/broadcom/compiler/v3d_compiler.h4
-rw-r--r--src/broadcom/compiler/vir.c2
3 files changed, 8 insertions, 15 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 51b4fd6848d..4cbdb764eab 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -2006,9 +2006,10 @@ vir_emit_last_thrsw(struct v3d_compile *c)
c->last_thrsw->is_last_thrsw = true;
}
-/* There's a flag in the shader for "centroid W used in addition to center W",
- * so we need to walk the program after VIR optimization to see if both are
- * used.
+/* There's a flag in the shader for "center W is needed for reasons other than
+ * non-centroid varyings", so we just walk the program after VIR optimization
+ * to see if it's used. It should be harmless to set even if we only use
+ * center W for varyings.
*/
static void
vir_check_payload_w(struct v3d_compile *c)
@@ -2016,19 +2017,11 @@ vir_check_payload_w(struct v3d_compile *c)
if (c->s->info.stage != MESA_SHADER_FRAGMENT)
return;
- bool any_centroid = false;
- for (int i = 0; i < ARRAY_SIZE(c->centroid_flags); i++) {
- if (c->centroid_flags[i])
- any_centroid = true;
- }
- if (!any_centroid)
- return;
-
vir_for_each_inst_inorder(inst, c) {
for (int i = 0; i < vir_get_nsrc(inst); i++) {
if (inst->src[i].file == QFILE_REG &&
inst->src[i].index == 0) {
- c->uses_centroid_and_center_w = true;
+ c->uses_center_w = true;
return;
}
}
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h
index 4eeda23f5de..24af18e8f9e 100644
--- a/src/broadcom/compiler/v3d_compiler.h
+++ b/src/broadcom/compiler/v3d_compiler.h
@@ -478,7 +478,7 @@ struct v3d_compile {
uint32_t centroid_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
- bool uses_centroid_and_center_w;
+ bool uses_center_w;
struct v3d_ubo_range *ubo_ranges;
bool *ubo_range_used;
@@ -663,7 +663,7 @@ struct v3d_fs_prog_data {
bool writes_z;
bool discard;
- bool uses_centroid_and_center_w;
+ bool uses_center_w;
};
/* Special nir_load_input intrinsic index for loading the current TLB
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 0de5335d12a..28e25cb23e2 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -841,7 +841,7 @@ uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,
prog_data->writes_z = (c->s->info.outputs_written &
(1 << FRAG_RESULT_DEPTH));
prog_data->discard = c->s->info.fs.uses_discard;
- prog_data->uses_centroid_and_center_w = c->uses_centroid_and_center_w;
+ prog_data->uses_center_w = c->uses_center_w;
return v3d_return_qpu_insts(c, final_assembly_size);
}