summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorGert Wollny <[email protected]>2019-07-25 10:34:48 +0200
committerGert Wollny <[email protected]>2019-08-01 05:58:53 +0000
commitd81ba38b02cb1ef8f87b5551e6d668fa245e138e (patch)
treed287adffded2948157143ec4eff4db74ffda0fe3 /src/mesa
parentfefb152067bd81b0e7ecc1af3794494dcc389421 (diff)
mesa/st: Tie depth_clamp lowering into the FS
v1 implemented by Erik Faye-Lund <[email protected]> v2: Use different call for FS v3: Use file scope defined depth_range_state Signed-off-by: Gert Wollny <[email protected]> Reviewed-by: Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c5
-rw-r--r--src/mesa/state_tracker/st_program.c10
-rw-r--r--src/mesa/state_tracker/st_program.h3
3 files changed, 18 insertions, 0 deletions
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];