summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nouveau/nv50/nv50_state.c
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2016-06-19 16:57:50 -0400
committerIlia Mirkin <imirkin@alum.mit.edu>2016-07-16 11:45:30 -0400
commit062c6b8e54c14adcc1ec603fad524f38fe058e67 (patch)
treebcb4774e8d9225d7f8bf557f299061f310f6f85f /src/gallium/drivers/nouveau/nv50/nv50_state.c
parentcc46fc3c0921c86baa0fbe25ba6a9c4858f04ab3 (diff)
nv50: fix alphatest for non-blendable formats
The hardware can only do alphatest when using a blendable format. This means that the various *16 norm formats didn't work with alphatest. It appears that Talos Principle uses such formats, as well as alpha tests, for some internal renders, which made them be incorrect. However this does not appear to affect the final renders, but in a different game it easily could. The approach we take is that when alphatests are enabled and a suitable format is used (which we anticipate is the vast minority of the time), we insert code into the shader to perform the comparison and discard. Once inserted, that code lives in the shader forever, and we re-upload it each time the function changes with a fixed-up compare. To avoid re-uploading too often, if we switch back to a blendable format, the test is (effectively) disabled and the hw alphatest functionality is used. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Diffstat (limited to 'src/gallium/drivers/nouveau/nv50/nv50_state.c')
-rw-r--r--src/gallium/drivers/nouveau/nv50/nv50_state.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c
index a84c9e27992..b6741140e50 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_state.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c
@@ -416,6 +416,11 @@ nv50_zsa_state_create(struct pipe_context *pipe,
SB_DATA (so, 0);
}
+ SB_BEGIN_3D(so, CB_ADDR, 1);
+ SB_DATA (so, NV50_CB_AUX_ALPHATEST_OFFSET << (8 - 2) | NV50_CB_AUX);
+ SB_BEGIN_3D(so, CB_DATA(0), 1);
+ SB_DATA (so, fui(cso->alpha.ref_value));
+
assert(so->size <= ARRAY_SIZE(so->state));
return (void *)so;
}