From: Kenneth Graunke Date: Sat, 8 Nov 2014 10:34:43 +0000 (-0800) Subject: i965: Set prog_data->uses_kill if simulating alpha test via discards. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=133280120b4bc714bbb7665e383f36ab262c280a;p=mesa.git 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 Reviewed-by: Jordan Justen Reviewed-by: Matt Turner --- 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