[Mesa-dev] [PATCH 4/4] i965/fs: Gen4-5: Implement alpha test in shader for MRT
Chris Forbes
chrisf at ijw.co.nz
Mon Oct 28 23:00:10 CET 2013
On Tue, Oct 29, 2013 at 10:48 AM, Eric Anholt <eric at anholt.net> wrote:
> Chris Forbes <chrisf at ijw.co.nz> writes:
>
>> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
>
> This function should probably have a comment:
>
> /**
> * Alpha test support for when we compile it into the shader instead
> * of using the normal fixed function alpha test.
> */
>
>> +void
>> +fs_visitor::emit_alpha_test()
>> +{
>> + this->current_annotation = "Alpha test";
>> +
>> + fs_inst *cmp;
>> + if (c->key.alpha_test_func == GL_ALWAYS)
>> + return;
>> +
>> + if (c->key.alpha_test_func == GL_NEVER) {
>> + /* f0.1 = 0 */
>> + fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
>> + BRW_REGISTER_TYPE_UW));
>> + cmp = emit(CMP(reg_null_f, some_reg, some_reg,
>> + BRW_CONDITIONAL_NEQ));
>> + } else {
>> + /* RT0 alpha */
>> + fs_reg color = outputs[0];
>> + color.reg_offset += 3;
>> +
>> + /* reference value */
>> + fs_reg ref = fs_reg(this, glsl_type::float_type);
>> + emit(MOV(ref, fs_reg(c->key.alpha_test_ref)));
>
> I don't think you need this temporary here, do you?
Turns out I don't, and it actually gets folded away. Will tidy this up.
>
>> + /* f0.1 &= func(color, ref) */
>> + cmp = emit(CMP(reg_null_f, color, ref,
>> cond_for_alpha_func(c->key.alpha_test_func)));
>
> weird indentation.
>
>> + }
>> + cmp->predicate = BRW_PREDICATE_NORMAL;
>> + cmp->flag_subreg = 1;
>> +}
>
More information about the mesa-dev
mailing list