bool nir_move_vec_src_uses_to_dest(nir_shader *shader);
bool nir_lower_vec_to_movs(nir_shader *shader);
void nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
- bool alpha_to_one);
+ bool alpha_to_one,
+ const gl_state_index16 *alpha_ref_state_tokens);
bool nir_lower_alu(nir_shader *shader);
bool nir_lower_flrp(nir_shader *shader, unsigned lowering_mask,
void
nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
- bool alpha_to_one)
+ bool alpha_to_one,
+ const gl_state_index16 *alpha_ref_state_tokens)
{
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
3);
}
+ nir_ssa_def *alpha_ref;
+ if (alpha_ref_state_tokens) {
+ nir_variable *var = nir_variable_create(shader,
+ nir_var_uniform,
+ glsl_float_type(),
+ "gl_AlphaRefMESA");
+ var->num_state_slots = 1;
+ var->state_slots = ralloc_array(var, nir_state_slot, 1);
+ memcpy(var->state_slots[0].tokens,
+ alpha_ref_state_tokens,
+ sizeof(var->state_slots[0].tokens));
+ alpha_ref = nir_load_var(&b, var);
+ } else
+ alpha_ref = nir_load_alpha_ref_float(&b);
+
nir_ssa_def *condition =
- nir_compare_func(&b, func,
- alpha, nir_load_alpha_ref_float(&b));
+ nir_compare_func(&b, func, alpha, alpha_ref);
nir_intrinsic_instr *discard =
nir_intrinsic_instr_create(b.shader,
/* Inject the alpha test now if we need to */
if (state->alpha_state.enabled) {
- NIR_PASS_V(s, nir_lower_alpha_test, state->alpha_state.func, false);
+ NIR_PASS_V(s, nir_lower_alpha_test,
+ state->alpha_state.func, false, NULL);
}
}
NIR_PASS_V(c->s, nir_lower_alpha_test,
c->fs_key->alpha_test_func,
c->fs_key->sample_alpha_to_one &&
- c->fs_key->msaa);
+ c->fs_key->msaa,
+ NULL);
}
NIR_PASS_V(c->s, vc4_nir_lower_blend, c);
}