mesa/st: Tie depth_clamp lowering into the FS

v1 implemented by Erik Faye-Lund <erik.faye-lund@collabora.com>
v2: Use different call for FS
v3: Use file scope defined depth_range_state

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Gert Wollny 2019-07-25 10:34:48 +02:00 committed by Gert Wollny
parent fefb152067
commit d81ba38b02
3 changed files with 18 additions and 0 deletions

View File

@ -131,6 +131,11 @@ st_update_fp( struct st_context *st )
st->ctx->Multisample.MinSampleShadingValue *
_mesa_geometric_samples(st->ctx->DrawBuffer) > 1;
key.lower_depth_clamp =
st->clamp_frag_depth_in_shader &&
(st->ctx->Transform.DepthClampNear ||
st->ctx->Transform.DepthClampFar);
if (stfp->ati_fs) {
key.fog = st->ctx->Fog._PackedEnabledMode;

View File

@ -1365,6 +1365,16 @@ st_create_fp_variant(struct st_context *st,
}
}
if (key->lower_depth_clamp) {
unsigned depth_range_const = _mesa_add_state_reference(params, depth_range_state);
const struct tgsi_token *tokens;
tokens = st_tgsi_lower_depth_clamp_fs(tgsi.tokens, depth_range_const);
if (tgsi.tokens != stfp->tgsi.tokens)
tgsi_free_tokens(tgsi.tokens);
tgsi.tokens = tokens;
}
if (ST_DEBUG & DEBUG_TGSI) {
tgsi_dump(tgsi.tokens, 0);
debug_printf("\n");

View File

@ -123,6 +123,9 @@ struct st_fp_variant_key
/** needed for ATI_fragment_shader */
GLuint fog:2;
/** for ARB_depth_clamp */
GLuint lower_depth_clamp:1;
/** needed for ATI_fragment_shader */
char texture_targets[MAX_NUM_FRAGMENT_REGISTERS_ATI];