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 <kenn...@whitecape.org> --- src/mesa/drivers/dri/i965/brw_fs.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 2 +- src/mesa/drivers/dri/i965/brw_wm.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) This series was tested on 965, G45, Ironlake, Sandybridge, Ivybridge, Baytrail, and Haswell. 965 had a few random changes that looked totally unrelated, but everything else worked fine. Not tested on Broadwell. diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 0ffb07f..fdd1bb3 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3601,7 +3601,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 f61e7a1..67dfe81 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 5863573..34500e2 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 -- 2.1.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev