mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 22:10:10 +01:00
mesa/gallium: automatically lower alpha-testing
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
6d7e02e37d
commit
b1c4c4c7f5
8 changed files with 27 additions and 1 deletions
|
|
@ -395,6 +395,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
|
|||
return 1;
|
||||
|
||||
case PIPE_CAP_FLATSHADE:
|
||||
case PIPE_CAP_ALPHA_TEST:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -559,6 +559,7 @@ The integer capabilities:
|
|||
* ``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:
|
||||
|
||||
|
|
|
|||
|
|
@ -905,6 +905,7 @@ enum pipe_cap
|
|||
PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION,
|
||||
PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE,
|
||||
PIPE_CAP_FLATSHADE,
|
||||
PIPE_CAP_ALPHA_TEST,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -122,6 +122,11 @@ st_update_fp( struct st_context *st )
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -500,7 +500,12 @@ st_init_driver_flags(struct st_context *st)
|
|||
f->NewFramebufferSRGB = ST_NEW_FB_STATE;
|
||||
f->NewScissorRect = ST_NEW_SCISSOR;
|
||||
f->NewScissorTest = ST_NEW_SCISSOR | ST_NEW_RASTERIZER;
|
||||
|
||||
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;
|
||||
|
|
@ -670,6 +675,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
|
|||
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,
|
||||
|
|
@ -738,6 +745,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ struct st_context
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -1150,6 +1150,8 @@ st_create_fp_variant(struct st_context *st,
|
|||
{ 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;
|
||||
|
|
@ -1164,6 +1166,12 @@ st_create_fp_variant(struct st_context *st,
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ struct st_fp_variant_key
|
|||
struct st_external_sampler_key external;
|
||||
|
||||
GLuint lower_flatshade:1;
|
||||
enum compare_func lower_alpha_func:3;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue