diff options
author | Eric Anholt <[email protected]> | 2018-04-26 09:24:32 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-04-26 11:30:22 -0700 |
commit | 76ee9edcb4f5be8699cfb9a6c4aa231c4e7d4183 (patch) | |
tree | 27556d81315aa8bf857050be0c86dec24a15306b /src/broadcom/compiler/nir_to_vir.c | |
parent | e2f33178010a9612d8d89bf128e3a01a69e1dd82 (diff) |
broadcom/vc5: Add support for centroid varyings.
It would be nice to share the flags packet emit logic with flat shade
flags, but I couldn't come up with a good way while still using our pack
macros. We need to refactor this to shader record setup at compile time,
anyway.
Fixes ext_framebuffer_multisample-interpolation * centroid-*
Diffstat (limited to 'src/broadcom/compiler/nir_to_vir.c')
-rw-r--r-- | src/broadcom/compiler/nir_to_vir.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index d6c2d1902b6..ec8f22321f3 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -436,6 +436,7 @@ emit_fragment_varying(struct v3d_compile *c, nir_variable *var, /* FALLTHROUGH */ case INTERP_MODE_SMOOTH: if (var->data.centroid) { + BITSET_SET(c->centroid_flags, i); return vir_FADD(c, vir_FMUL(c, vary, c->payload_w_centroid), r5); } else { @@ -1985,6 +1986,36 @@ 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. + */ +static void +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; + return; + } + } + } + +} + void v3d_nir_to_vir(struct v3d_compile *c) { @@ -2024,6 +2055,8 @@ v3d_nir_to_vir(struct v3d_compile *c) vir_optimize(c); vir_lower_uniforms(c); + vir_check_payload_w(c); + /* XXX: vir_schedule_instructions(c); */ if (V3D_DEBUG & (V3D_DEBUG_VIR | |