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 <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
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;
}
/* 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)
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