From: Gert Wollny Date: Thu, 25 Jul 2019 08:34:48 +0000 (+0200) Subject: mesa/st: Tie depth_clamp lowering into the FS X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d81ba38b02cb1ef8f87b5551e6d668fa245e138e;p=mesa.git mesa/st: Tie depth_clamp lowering into the FS v1 implemented by Erik Faye-Lund v2: Use different call for FS v3: Use file scope defined depth_range_state Signed-off-by: Gert Wollny Reviewed-by: Reviewed-by: Marek Olšák --- diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 97abe72d3ef..a10cc21021c 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -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; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 23e9f15cd60..fa7552b2592 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -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"); diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index ef55fe33320..eefa340e5cb 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -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];