From 94335ebabd61a96b7f1c8783b9f57e14a4153e48 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 7 Jan 2022 14:50:47 +0100 Subject: [PATCH] shader: rely on the shader key for clip_dist in GS If we always emit the glip distance in GS we might end up having too many outputs, which will result in failures. Hence, for GS only emit the clip distance evaluation code when the clip planes are enabled. Fixes: 072f30955b427c0e9bbc7b1c290e196b846a7598 shader: Always write code to toggle clip plane Closes: #254 Signed-off-by: Gert Wollny Reviewed-by: Italo Nicola --- src/vrend_renderer.c | 3 +++ src/vrend_shader.c | 2 +- src/vrend_shader.h | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index c0a64d6..fa99dbb 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3581,6 +3581,9 @@ static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx, if (type != PIPE_SHADER_COMPUTE) vrend_sync_shader_io(sub_ctx, sel, key); + if (type == PIPE_SHADER_GEOMETRY) + key->gs.emit_clip_distance = sub_ctx->rs_state.clip_plane_enable != 0; + for (int i = 0; i < sub_ctx->views[type].num_views; i++) { struct vrend_sampler_view *view = sub_ctx->views[type].views[i]; if (view && view->texture->target == GL_TEXTURE_BUFFER && diff --git a/src/vrend_shader.c b/src/vrend_shader.c index abd1e59..38412cb 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -5438,7 +5438,7 @@ iter_instruction(struct tgsi_iterate_context *iter, struct immed *imd = &ctx->imm[(inst->Src[0].Register.Index)]; if (ctx->so && ctx->key->gs_present) emit_so_movs(ctx, &ctx->glsl_strbufs, &ctx->has_clipvertex_so); - if (ctx->cfg->has_cull_distance) + if (ctx->cfg->has_cull_distance && ctx->key->gs.emit_clip_distance) emit_clip_dist_movs(ctx, &ctx->glsl_strbufs); emit_prescale(&ctx->glsl_strbufs); if (imd->val[inst->Src[0].Register.SwizzleX].ui > 0) { diff --git a/src/vrend_shader.h b/src/vrend_shader.h index 30bbe5f..021a3da 100644 --- a/src/vrend_shader.h +++ b/src/vrend_shader.h @@ -173,6 +173,10 @@ struct vrend_shader_key { uint32_t attrib_unsigned_int_bitmask; uint32_t fog_fixup_mask; } vs; + + struct { + uint32_t emit_clip_distance : 1; + } gs; }; uint32_t sampler_views_lower_swizzle_mask;