st/mesa: Enable clip planes lowering for geometry shaders
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6218>
This commit is contained in:

committed by
Marge Bot

parent
584f27326c
commit
916110e17f
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user