summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-11-08 02:34:43 -0800
committerKenneth Graunke <[email protected]>2014-11-27 20:25:24 -0800
commit133280120b4bc714bbb7665e383f36ab262c280a (patch)
treee969c54ade347d76002238c96dbc0e665ad059a8 /src/mesa
parent06372c3fa9940b6ebbc03ebb2cdfdedc87076cc0 (diff)
i965: Set prog_data->uses_kill if simulating alpha test via discards.
When using MRT on Gen4-5, we have to simulate GL's alpha test feature by emitting discards in the fragment shader. In this case, it makes sense to set prog_data->uses_kill, which means the fragment shader may kill pixels via the discard mechanism. This saves us from having to look an extra key value in a couple of places, including in the generator. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_generator.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c5
3 files changed, 6 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 68305eff3dc..028eff23efa 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3620,7 +3620,7 @@ fs_visitor::run()
bool alpha_test_func =
(stage == MESA_SHADER_FRAGMENT) &&
((brw_wm_prog_key*) this->key)->alpha_test_func;
- if (uses_kill || alpha_test_func) {
+ if (uses_kill) {
fs_inst *discard_init = emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS);
discard_init->flag_subreg = 1;
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 16aa268946c..8d3f0932ed0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -179,7 +179,7 @@ fs_generator::generate_fb_write(fs_inst *inst, struct brw_reg payload)
/* On HSW, the GPU will use the predicate on SENDC, unless the header is
* present.
*/
- if (prog_data->uses_kill || key->alpha_test_func) {
+ if (prog_data->uses_kill) {
struct brw_reg pixel_mask;
if (brw->gen >= 6)
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 58635736e36..34500e21eeb 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -156,7 +156,10 @@ bool do_wm_prog(struct brw_context *brw,
fs = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
memset(&prog_data, 0, sizeof(prog_data));
- prog_data.uses_kill = fp->program.UsesKill;
+ /* key->alpha_test_func means simulating alpha testing via discards,
+ * so the shader definitely kills pixels.
+ */
+ prog_data.uses_kill = fp->program.UsesKill || key->alpha_test_func;
/* Allocate the references to the uniforms that will end up in the
* prog_data associated with the compiled program, and which will be freed