From 616f3207456c8165d15232ec80bfccb8c2826bcf Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Thu, 25 Jul 2019 10:40:36 +0200 Subject: [PATCH] mesa/st: Signal state changes when depth_clamp is emulated MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v1 implemented by Erik Faye-Lund 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 Reviewed-by: Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_context.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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; -- 2.30.2