From: Louis-Francis Ratté-Boulianne Date: Mon, 29 Jun 2020 07:21:54 +0000 (-0400) Subject: st/mesa: Enable clip planes lowering for geometry shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=916110e17f2e04d685978e6b385b3fe0d3231fe9;p=mesa.git st/mesa: Enable clip planes lowering for geometry shaders Reviewed-By: Mike Blumenkrantz Part-of: --- diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index b349c2a1f17..d92a542922e 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -228,7 +228,8 @@ st_update_vp( struct st_context *st ) !st_point_size_per_vertex(st->ctx); /* _NEW_TRANSFORM */ - if (st->lower_ucp && st_user_clip_planes_enabled(st->ctx)) + if (st->lower_ucp && st_user_clip_planes_enabled(st->ctx) && + !st->ctx->GeometryProgram._Current) key.lower_ucp = st->ctx->Transform.ClipPlanesEnabled; st->vp_variant = st_get_vp_variant(st, stvp, &key); @@ -285,6 +286,9 @@ st_update_common_program(struct st_context *st, struct gl_program *prog, key.clip_negative_one_to_one = st->ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE; + if (st->lower_ucp && st_user_clip_planes_enabled(st->ctx) && + pipe_shader == PIPE_SHADER_GEOMETRY) + key.lower_ucp = st->ctx->Transform.ClipPlanesEnabled; } return st_get_common_variant(st, stp, &key)->driver_shader; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 490e959d6da..6c8ba9dd732 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -553,7 +553,7 @@ st_init_driver_flags(struct st_context *st) } if (st->lower_ucp) - f->NewClipPlaneEnable = ST_NEW_VS_STATE; + f->NewClipPlaneEnable = ST_NEW_VS_STATE | ST_NEW_GS_STATE; else f->NewClipPlaneEnable = ST_NEW_RASTERIZER; @@ -722,10 +722,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, assert(!ctx->Extensions.OES_geometry_shader || !st->lower_point_size); assert(!ctx->Extensions.ARB_tessellation_shader || !st->lower_point_size); - /* FIXME: add support for geometry and tessellation shaders for - * lower_ucp - */ - assert(!ctx->Extensions.OES_geometry_shader || !st->lower_ucp); + /* FIXME: add support for tessellation shaders for lower_ucp */ assert(!ctx->Extensions.ARB_tessellation_shader || !st->lower_ucp); if (st_have_perfmon(st)) { @@ -808,7 +805,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, 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->clamp_vert_color_in_shader && + !st->lower_ucp; st->shader_has_one_variant[MESA_SHADER_COMPUTE] = st->has_shareable_shaders; st->bitmap.cache.empty = true; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index aad4d4d9922..7e7373dc85e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -695,8 +695,14 @@ lower_ucp(struct st_context *st, _mesa_add_state_reference(params, clipplane_state[i]); } - NIR_PASS_V(nir, nir_lower_clip_vs, ucp_enables, - true, can_compact, clipplane_state); + if (nir->info.stage == MESA_SHADER_VERTEX) { + NIR_PASS_V(nir, nir_lower_clip_vs, ucp_enables, + true, can_compact, clipplane_state); + } else if (nir->info.stage == MESA_SHADER_GEOMETRY) { + NIR_PASS_V(nir, nir_lower_clip_gs, ucp_enables, + can_compact, clipplane_state); + } + NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), true, false); NIR_PASS_V(nir, nir_lower_global_vars_to_local); @@ -1782,6 +1788,7 @@ st_get_common_variant(struct st_context *st, struct pipe_context *pipe = st->pipe; struct st_variant *v; struct pipe_shader_state state = {0}; + struct gl_program_parameter_list *params = prog->Base.Parameters; /* Search for existing variant */ for (v = prog->variants; v; v = v->next) { @@ -1804,6 +1811,11 @@ st_get_common_variant(struct st_context *st, finalize = true; } + if (key->lower_ucp) { + lower_ucp(st, state.ir.nir, key->lower_ucp, params); + finalize = true; + } + state.stream_output = prog->state.stream_output; if (finalize || !st->allow_st_finalize_nir_twice) {