return 1;
case PIPE_CAP_FLATSHADE:
+ case PIPE_CAP_ALPHA_TEST:
return 1;
default:
* ``PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION``: True if driver supports demote keyword in GLSL programs.
* ``PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE``: True if driver wants the TG4 component encoded in sampler swizzle rather than as a separate source.
* ``PIPE_CAP_FLATSHADE``: Driver supports pipe_rasterizer_state::flatshade.
+* ``PIPE_CAP_ALPHA_TEST``: Driver supports alpha-testing.
.. _pipe_capf:
PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION,
PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE,
PIPE_CAP_FLATSHADE,
+ PIPE_CAP_ALPHA_TEST,
};
/**
key.lower_flatshade = st->lower_flatshade &&
st->ctx->Light.ShadeModel == GL_FLAT;
+ /* _NEW_COLOR */
+ key.lower_alpha_func = COMPARE_FUNC_NEVER;
+ if (st->lower_alpha_test && _mesa_is_alpha_test_enabled(st->ctx))
+ key.lower_alpha_func = st->ctx->Color.AlphaFunc;
+
/* _NEW_FRAG_CLAMP */
key.clamp_color = st->clamp_frag_color_in_shader &&
st->ctx->Color._ClampFragmentColor;
f->NewFramebufferSRGB = ST_NEW_FB_STATE;
f->NewScissorRect = ST_NEW_SCISSOR;
f->NewScissorTest = ST_NEW_SCISSOR | ST_NEW_RASTERIZER;
- f->NewAlphaTest = ST_NEW_DSA;
+
+ if (st->lower_alpha_test)
+ f->NewAlphaTest = ST_NEW_FS_STATE;
+ else
+ f->NewAlphaTest = ST_NEW_DSA;
+
f->NewBlend = ST_NEW_BLEND;
f->NewBlendColor = ST_NEW_BLEND_COLOR;
f->NewColorMask = ST_NEW_BLEND;
screen->get_param(screen, PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET);
st->lower_flatshade =
!screen->get_param(screen, PIPE_CAP_FLATSHADE);
+ st->lower_alpha_test =
+ !screen->get_param(screen, PIPE_CAP_ALPHA_TEST);
st->has_hw_atomics =
screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
st->shader_has_one_variant[MESA_SHADER_FRAGMENT] =
st->has_shareable_shaders &&
!st->lower_flatshade &&
+ !st->lower_alpha_test &&
!st->clamp_frag_color_in_shader &&
!st->clamp_frag_depth_in_shader &&
!st->force_persample_in_shader;
boolean can_bind_const_buffer_as_vertex;
boolean has_signed_vertex_buffer_offset;
boolean lower_flatshade;
+ boolean lower_alpha_test;
/**
* If a shader can be created when we get its source.
{ STATE_INTERNAL, STATE_PT_SCALE };
static const gl_state_index16 bias_state[STATE_LENGTH] =
{ STATE_INTERNAL, STATE_PT_BIAS };
+ static const gl_state_index16 alpha_ref_state[STATE_LENGTH] =
+ { STATE_INTERNAL, STATE_ALPHA_REF };
if (!variant)
return NULL;
if (key->lower_flatshade)
NIR_PASS_V(tgsi.ir.nir, nir_lower_flatshade);
+ if (key->lower_alpha_func != COMPARE_FUNC_NEVER) {
+ _mesa_add_state_reference(params, alpha_ref_state);
+ NIR_PASS_V(tgsi.ir.nir, nir_lower_alpha_test, key->lower_alpha_func,
+ false, alpha_ref_state);
+ }
+
if (key->persample_shading) {
nir_shader *shader = tgsi.ir.nir;
nir_foreach_variable(var, &shader->inputs)
struct st_external_sampler_key external;
GLuint lower_flatshade:1;
+ enum compare_func lower_alpha_func:3;
};