intel/fs: Use compare_func for wm_prog_key::alpha_test_func
Because 0 is no longer a recognizable value (it's NEVER, which isn't a good default), we add an emit_alpha_test bool to tell the back-end when to bother alpha testing. This lets us only touch crocus with the change. Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14157>
This commit is contained in:

committed by
Marge Bot

parent
460a953df5
commit
a1de102479
@@ -4751,22 +4751,6 @@ crocus_populate_gs_key(const struct crocus_context *ice,
|
||||
key->nr_userclip_plane_consts = cso_rast->num_clip_plane_consts;
|
||||
}
|
||||
|
||||
static inline GLenum
|
||||
compare_func_to_gl(enum pipe_compare_func pipe_func)
|
||||
{
|
||||
static const unsigned map[] = {
|
||||
[PIPE_FUNC_NEVER] = GL_NEVER,
|
||||
[PIPE_FUNC_LESS] = GL_LESS,
|
||||
[PIPE_FUNC_EQUAL] = GL_EQUAL,
|
||||
[PIPE_FUNC_LEQUAL] = GL_LEQUAL,
|
||||
[PIPE_FUNC_GREATER] = GL_GREATER,
|
||||
[PIPE_FUNC_NOTEQUAL] = GL_NOTEQUAL,
|
||||
[PIPE_FUNC_GEQUAL] = GL_GEQUAL,
|
||||
[PIPE_FUNC_ALWAYS] = GL_ALWAYS,
|
||||
};
|
||||
return map[pipe_func];
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate FS program key fields based on the current state.
|
||||
*/
|
||||
@@ -4851,7 +4835,8 @@ crocus_populate_fs_key(const struct crocus_context *ice,
|
||||
|
||||
#if GFX_VER <= 5
|
||||
if (fb->nr_cbufs > 1 && zsa->cso.alpha_enabled) {
|
||||
key->alpha_test_func = compare_func_to_gl(zsa->cso.alpha_func);
|
||||
key->emit_alpha_test = true;
|
||||
key->alpha_test_func = zsa->cso.alpha_func;
|
||||
key->alpha_test_ref = zsa->cso.alpha_ref_value;
|
||||
}
|
||||
#endif
|
||||
|
@@ -486,6 +486,8 @@ struct brw_wm_prog_key {
|
||||
bool stats_wm:1;
|
||||
bool flat_shade:1;
|
||||
unsigned nr_color_regions:5;
|
||||
bool emit_alpha_test:1;
|
||||
enum compare_func alpha_test_func:3; /* < For Gfx4/5 MRT alpha test */
|
||||
bool alpha_test_replicate_alpha:1;
|
||||
bool alpha_to_coverage:1;
|
||||
bool clamp_fragment_color:1;
|
||||
@@ -499,7 +501,6 @@ struct brw_wm_prog_key {
|
||||
|
||||
uint8_t color_outputs_valid;
|
||||
uint64_t input_slots_valid;
|
||||
GLenum alpha_test_func; /* < For Gfx4/5 MRT alpha test */
|
||||
float alpha_test_ref;
|
||||
};
|
||||
|
||||
|
@@ -9081,7 +9081,7 @@ fs_visitor::run_fs(bool allow_spilling, bool do_rep_send)
|
||||
if (failed)
|
||||
return false;
|
||||
|
||||
if (wm_key->alpha_test_func)
|
||||
if (wm_key->emit_alpha_test)
|
||||
emit_alpha_test();
|
||||
|
||||
emit_fb_writes();
|
||||
@@ -9506,7 +9506,7 @@ brw_nir_populate_wm_prog_data(const nir_shader *shader,
|
||||
* so the shader definitely kills pixels.
|
||||
*/
|
||||
prog_data->uses_kill = shader->info.fs.uses_discard ||
|
||||
key->alpha_test_func;
|
||||
key->emit_alpha_test;
|
||||
prog_data->uses_omask = !key->ignore_sample_mask_out &&
|
||||
(shader->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK));
|
||||
prog_data->computed_depth_mode = computed_depth_mode(shader);
|
||||
|
@@ -559,23 +559,23 @@ fs_visitor::emit_interpolation_setup_gfx6()
|
||||
}
|
||||
|
||||
static enum brw_conditional_mod
|
||||
cond_for_alpha_func(GLenum func)
|
||||
cond_for_alpha_func(enum compare_func func)
|
||||
{
|
||||
switch(func) {
|
||||
case GL_GREATER:
|
||||
return BRW_CONDITIONAL_G;
|
||||
case GL_GEQUAL:
|
||||
return BRW_CONDITIONAL_GE;
|
||||
case GL_LESS:
|
||||
return BRW_CONDITIONAL_L;
|
||||
case GL_LEQUAL:
|
||||
return BRW_CONDITIONAL_LE;
|
||||
case GL_EQUAL:
|
||||
return BRW_CONDITIONAL_EQ;
|
||||
case GL_NOTEQUAL:
|
||||
return BRW_CONDITIONAL_NEQ;
|
||||
default:
|
||||
unreachable("Not reached");
|
||||
case COMPARE_FUNC_GREATER:
|
||||
return BRW_CONDITIONAL_G;
|
||||
case COMPARE_FUNC_GEQUAL:
|
||||
return BRW_CONDITIONAL_GE;
|
||||
case COMPARE_FUNC_LESS:
|
||||
return BRW_CONDITIONAL_L;
|
||||
case COMPARE_FUNC_LEQUAL:
|
||||
return BRW_CONDITIONAL_LE;
|
||||
case COMPARE_FUNC_EQUAL:
|
||||
return BRW_CONDITIONAL_EQ;
|
||||
case COMPARE_FUNC_NOTEQUAL:
|
||||
return BRW_CONDITIONAL_NEQ;
|
||||
default:
|
||||
unreachable("Not reached");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,10 +591,10 @@ fs_visitor::emit_alpha_test()
|
||||
const fs_builder abld = bld.annotate("Alpha test");
|
||||
|
||||
fs_inst *cmp;
|
||||
if (key->alpha_test_func == GL_ALWAYS)
|
||||
if (key->alpha_test_func == COMPARE_FUNC_ALWAYS)
|
||||
return;
|
||||
|
||||
if (key->alpha_test_func == GL_NEVER) {
|
||||
if (key->alpha_test_func == COMPARE_FUNC_NEVER) {
|
||||
/* f0.1 = 0 */
|
||||
fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
|
||||
BRW_REGISTER_TYPE_UW));
|
||||
|
Reference in New Issue
Block a user