diff options
author | Gert Wollny <[email protected]> | 2019-07-25 10:33:36 +0200 |
---|---|---|
committer | Gert Wollny <[email protected]> | 2019-08-01 05:58:53 +0000 |
commit | fefb152067bd81b0e7ecc1af3794494dcc389421 (patch) | |
tree | a6ba72196dd4822d5bbb4d9d524e091e65305f61 /src/mesa/state_tracker/st_program.c | |
parent | b048d8bf8f056759d1845a799d4ba2ac84bce30f (diff) |
mesa/st: Tie depth clamp lowering in to the VP code
v1: implemented by Erik Faye-Lund <[email protected]>
v2: Add handling of the ARB_clip_control depth mode
v3: Move depth_range_state to file scope and remove training zeros (Erik)
v4: - don't use the one_shader_variant property, as this is not correct (Marek)
- also use tests on available shader stages to enable depth_clamp lowering
V5: Don't use key.st, use st directly (Marek)
Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_program.c')
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 81065612adb..23e9f15cd60 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -55,6 +55,7 @@ #include "st_cb_bitmap.h" #include "st_cb_drawpixels.h" #include "st_context.h" +#include "st_tgsi_lower_depth_clamp.h" #include "st_tgsi_lower_yuv.h" #include "st_program.h" #include "st_mesa_to_tgsi.h" @@ -633,6 +634,9 @@ st_translate_vertex_program(struct st_context *st, return stvp->tgsi.tokens != NULL; } +static const gl_state_index16 depth_range_state[STATE_LENGTH] = + { STATE_DEPTH_RANGE }; + static struct st_vp_variant * st_create_vp_variant(struct st_context *st, struct st_vertex_program *stvp, @@ -640,6 +644,7 @@ st_create_vp_variant(struct st_context *st, { struct st_vp_variant *vpv = CALLOC_STRUCT(st_vp_variant); struct pipe_context *pipe = st->pipe; + struct gl_program_parameter_list *params = stvp->Base.Parameters; vpv->key = *key; vpv->tgsi.stream_output = stvp->tgsi.stream_output; @@ -691,6 +696,18 @@ st_create_vp_variant(struct st_context *st, fprintf(stderr, "mesa: cannot emulate deprecated features\n"); } + 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(vpv->tgsi.tokens, depth_range_const, + key->clip_negative_one_to_one); + if (tokens != vpv->tgsi.tokens) + tgsi_free_tokens(vpv->tgsi.tokens); + vpv->tgsi.tokens = tokens; + } + if (ST_DEBUG & DEBUG_TGSI) { tgsi_dump(vpv->tgsi.tokens, 0); debug_printf("\n"); |