aboutsummaryrefslogtreecommitdiffstats
path: root/src/broadcom/compiler/vir.c
diff options
context:
space:
mode:
authorNeil Roberts <[email protected]>2020-06-22 14:26:02 +0200
committerMarge Bot <[email protected]>2020-07-06 21:59:16 +0000
commitee4d51f8b2de004b04d02c7edf66ca0608adf16f (patch)
tree7b3a32fcd42b915bcd32bc94e1f093cd32a552af /src/broadcom/compiler/vir.c
parent207da33a86d1a2b45995a7fd123afb761b1d841f (diff)
v3d: Add a lowering pass for line smoothing
When line smoothing is enabled, the driver now increases the width of the line so that it can add some semi-transparent pixels to either side of the line. A lowering pass is added which modifies the alpha component of every write to fragment output 0 so that if the fragment is outside the width of the line then the alpha is reduced. It additionally discards fragments that are completely invisible. It might seem bad to use discard on a tiled renderer but the assumption is that any bad effects from using discard will also happen anyway because of enabling alpha blending. v2: Disable the line smoothing pass entirely when the framebuffer contains an integer colour output or one with no alpha channel. Calculate the coverage once upfront and store in a global variable instead of calculating each time an output write is modified. Also do the conditional discard once upfront. v3: Don’t check whether the output buffer has an alpha channel. Only look at output 0. Use aa_line_width intrinsic instead of calculating the real line width in the shader. Clamp the coverage as part of the global variable, not per output write. Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5624>
Diffstat (limited to 'src/broadcom/compiler/vir.c')
-rw-r--r--src/broadcom/compiler/vir.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index ff2e0290122..d26a3250ead 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -890,6 +890,13 @@ v3d_nir_lower_fs_early(struct v3d_compile *c)
NIR_PASS_V(c->s, v3d_nir_lower_logic_ops, c);
+ if (c->fs_key->line_smoothing) {
+ v3d_nir_lower_line_smooth(c->s);
+ NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
+ /* The lowering pass can introduce new sysval reads */
+ nir_shader_gather_info(c->s, nir_shader_get_entrypoint(c->s));
+ }
+
/* If the shader has no non-TLB side effects, we can promote it to
* enabling early_fragment_tests even if the user didn't.
*/