summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/broadcom/compiler/nir_to_vir.c15
-rw-r--r--src/broadcom/compiler/v3d_compiler.h12
-rw-r--r--src/broadcom/compiler/vir.c18
-rw-r--r--src/gallium/drivers/vc5/vc5_emit.c2
-rw-r--r--src/gallium/drivers/vc5/vc5_program.c4
5 files changed, 31 insertions, 20 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 89d18f85061..acfeba4cb71 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -564,6 +564,21 @@ emit_fragment_varying(struct v3d_compile *c, nir_variable *var,
switch (var->data.interpolation) {
case INTERP_MODE_NONE:
+ /* If a gl_FrontColor or gl_BackColor input has no interp
+ * qualifier, then flag it for glShadeModel() handling by the
+ * driver.
+ */
+ switch (var->data.location) {
+ case VARYING_SLOT_COL0:
+ case VARYING_SLOT_COL1:
+ case VARYING_SLOT_BFC0:
+ case VARYING_SLOT_BFC1:
+ BITSET_SET(c->shade_model_flags, i);
+ break;
+ default:
+ break;
+ }
+ /* FALLTHROUGH */
case INTERP_MODE_SMOOTH:
if (var->data.centroid) {
return vir_FADD(c, vir_FMUL(c, vary,
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h
index 84957b75124..a29b08ac1ab 100644
--- a/src/broadcom/compiler/v3d_compiler.h
+++ b/src/broadcom/compiler/v3d_compiler.h
@@ -421,6 +421,11 @@ struct v3d_compile {
*/
BITSET_WORD flat_shade_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
+ /* Booleans for whether the corresponding QFILE_VARY[i] uses the
+ * default glShadeModel() behavior.
+ */
+ BITSET_WORD shade_model_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
+
struct v3d_ubo_range *ubo_ranges;
bool *ubo_range_used;
uint32_t ubo_ranges_array_size;
@@ -570,13 +575,14 @@ struct v3d_fs_prog_data {
struct v3d_varying_slot input_slots[V3D_MAX_FS_INPUTS];
- /** bitmask of which inputs are color inputs, for flat shade handling. */
- uint32_t color_inputs[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
-
/* Bitmask for whether the corresponding input is flat-shaded,
* independent of rasterizer (gl_FragColor) flat-shading.
*/
BITSET_WORD flat_shade_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
+ /* Bitmask for whether the corresponding input uses the default
+ * glShadeModel() behavior.
+ */
+ BITSET_WORD shade_model_flags[BITSET_WORDS(V3D_MAX_FS_INPUTS)];
bool writes_z;
bool discard;
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 1c25da6193c..227f2e39a6b 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -705,20 +705,10 @@ v3d_set_fs_prog_data_inputs(struct v3d_compile *c,
memcpy(prog_data->input_slots, c->input_slots,
c->num_inputs * sizeof(*c->input_slots));
- for (int i = 0; i < c->num_inputs; i++) {
- struct v3d_varying_slot v3d_slot = c->input_slots[i];
- uint8_t slot = v3d_slot_get_slot(v3d_slot);
-
- if (slot == VARYING_SLOT_COL0 ||
- slot == VARYING_SLOT_COL1 ||
- slot == VARYING_SLOT_BFC0 ||
- slot == VARYING_SLOT_BFC1) {
- BITSET_SET(prog_data->color_inputs, i);
- }
-
- if (BITSET_TEST(c->flat_shade_flags, i))
- BITSET_SET(prog_data->flat_shade_flags, i);
- }
+ memcpy(prog_data->flat_shade_flags, c->flat_shade_flags,
+ sizeof(c->flat_shade_flags));
+ memcpy(prog_data->shade_model_flags, c->shade_model_flags,
+ sizeof(c->shade_model_flags));
}
uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,
diff --git a/src/gallium/drivers/vc5/vc5_emit.c b/src/gallium/drivers/vc5/vc5_emit.c
index 29ccfcdacdb..60883d96d4b 100644
--- a/src/gallium/drivers/vc5/vc5_emit.c
+++ b/src/gallium/drivers/vc5/vc5_emit.c
@@ -408,7 +408,7 @@ vc5_emit_state(struct pipe_context *pctx)
if (vc5->rasterizer->base.flatshade) {
flags.flat_shade_flags_for_varyings_v024 |=
- vc5->prog.fs->prog_data.fs->color_inputs[0] & 0xfffff;
+ vc5->prog.fs->prog_data.fs->shade_model_flags[0] & 0xfffff;
}
}
}
diff --git a/src/gallium/drivers/vc5/vc5_program.c b/src/gallium/drivers/vc5/vc5_program.c
index 02625ed192b..107c9c05335 100644
--- a/src/gallium/drivers/vc5/vc5_program.c
+++ b/src/gallium/drivers/vc5/vc5_program.c
@@ -367,8 +367,8 @@ vc5_update_compiled_fs(struct vc5_context *vc5, uint8_t prim_mode)
(vc5->prog.fs->prog_data.fs->flat_shade_flags !=
old_fs->prog_data.fs->flat_shade_flags ||
(vc5->rasterizer->base.flatshade &&
- vc5->prog.fs->prog_data.fs->color_inputs !=
- old_fs->prog_data.fs->color_inputs))) {
+ vc5->prog.fs->prog_data.fs->shade_model_flags !=
+ old_fs->prog_data.fs->shade_model_flags))) {
vc5->dirty |= VC5_DIRTY_FLAT_SHADE_FLAGS;
}