summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_context.c
diff options
context:
space:
mode:
authorGert Wollny <[email protected]>2019-07-25 10:40:36 +0200
committerGert Wollny <[email protected]>2019-08-01 05:58:53 +0000
commit616f3207456c8165d15232ec80bfccb8c2826bcf (patch)
tree5337ea75065ef58a364630b8e74f28246ef39a59 /src/mesa/state_tracker/st_context.c
parentd004fcc04a52dd53c4e7008f55c5a9a2d8101ad5 (diff)
mesa/st: Signal state changes when depth_clamp is emulated
v1 implemented by Erik Faye-Lund <[email protected]> v2: - Add GS and TES - fix constants state update flags (Erik) v3: don't update rasterizer when depth_clamp is lowered (Erik) v4: Correct NewDepthClamp and also set flags for NewClipControl (Erik) v5: Also set shader_has_one_variant property acording to possible depth_clamp lowering (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_context.c')
-rw-r--r--src/mesa/state_tracker/st_context.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index fada76437b2..00e77250eb8 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -237,6 +237,16 @@ st_invalidate_state(struct gl_context *ctx)
if (new_state & _NEW_CURRENT_ATTRIB && st_vp_uses_current_values(ctx))
st->dirty |= ST_NEW_VERTEX_ARRAYS;
+ if (st->clamp_frag_depth_in_shader && (new_state & _NEW_VIEWPORT)) {
+ if (ctx->GeometryProgram._Current)
+ st->dirty |= ST_NEW_GS_CONSTANTS;
+ else if (ctx->TessEvalProgram._Current)
+ st->dirty |= ST_NEW_TES_CONSTANTS;
+ else
+ st->dirty |= ST_NEW_VS_CONSTANTS;
+ st->dirty |= ST_NEW_FS_CONSTANTS;
+ }
+
/* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) {
st->dirty |= ST_NEW_VS_STATE;
@@ -511,7 +521,17 @@ st_init_driver_flags(struct st_context *st)
f->NewClipControl = ST_NEW_VIEWPORT | ST_NEW_RASTERIZER;
f->NewClipPlane = ST_NEW_CLIP_STATE;
f->NewClipPlaneEnable = ST_NEW_RASTERIZER;
- f->NewDepthClamp = ST_NEW_RASTERIZER;
+
+ if (st->clamp_frag_depth_in_shader) {
+ f->NewClipControl |= ST_NEW_VS_STATE | ST_NEW_GS_STATE |
+ ST_NEW_TES_STATE;
+
+ f->NewDepthClamp = ST_NEW_FS_STATE | ST_NEW_VS_STATE |
+ ST_NEW_GS_STATE | ST_NEW_TES_STATE;
+ } else {
+ f->NewDepthClamp = ST_NEW_RASTERIZER;
+ }
+
f->NewLineState = ST_NEW_RASTERIZER;
f->NewPolygonState = ST_NEW_RASTERIZER;
f->NewPolygonStipple = ST_NEW_POLY_STIPPLE;
@@ -698,19 +718,23 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
/* Set which shader types can be compiled at link time. */
st->shader_has_one_variant[MESA_SHADER_VERTEX] =
st->has_shareable_shaders &&
+ !st->clamp_frag_depth_in_shader &&
!st->clamp_vert_color_in_shader;
st->shader_has_one_variant[MESA_SHADER_FRAGMENT] =
st->has_shareable_shaders &&
!st->clamp_frag_color_in_shader &&
+ !st->clamp_frag_depth_in_shader &&
!st->force_persample_in_shader;
st->shader_has_one_variant[MESA_SHADER_TESS_CTRL] = st->has_shareable_shaders;
st->shader_has_one_variant[MESA_SHADER_TESS_EVAL] =
st->has_shareable_shaders &&
+ !st->clamp_frag_depth_in_shader &&
!st->clamp_vert_color_in_shader;
st->shader_has_one_variant[MESA_SHADER_GEOMETRY] =
st->has_shareable_shaders &&
+ !st->clamp_frag_depth_in_shader &&
!st->clamp_vert_color_in_shader;
st->shader_has_one_variant[MESA_SHADER_COMPUTE] = st->has_shareable_shaders;