From ee13e4b9b7bcc72848de244bb6964493118968fb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 26 Mar 2018 17:48:26 +1000 Subject: [PATCH] shader: handle declaring fragment shader clip distance input. We weren't always sizing this correctly, so size it properly now. Tested-by: Jakob Bornecrantz --- src/vrend_renderer.c | 2 +- src/vrend_shader.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index d1be721..038a9dc 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -2127,7 +2127,7 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx, if (ctx->sub->shaders[PIPE_SHADER_GEOMETRY]) key->gs_present = true; - if (type == PIPE_SHADER_GEOMETRY && ctx->sub->shaders[PIPE_SHADER_VERTEX]) { + if ((type == PIPE_SHADER_GEOMETRY || type == PIPE_SHADER_FRAGMENT) && ctx->sub->shaders[PIPE_SHADER_VERTEX]) { key->prev_stage_pervertex_out = ctx->sub->shaders[PIPE_SHADER_VERTEX]->sinfo.has_pervertex_out; key->prev_stage_num_clip_out = ctx->sub->shaders[PIPE_SHADER_VERTEX]->sinfo.num_clip_out; } diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 21717f1..a7afb83 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -2566,6 +2566,13 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr) } } + if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && ctx->num_in_clip_dist) { + if (ctx->key->prev_stage_num_clip_out) { + snprintf(buf, 255, "in float gl_ClipDistance[%d];\n", ctx->key->prev_stage_num_clip_out); + STRCAT_WITH_RET(glsl_hdr, buf); + } + } + if (ctx->so) { char outtype[6] = {0}; for (i = 0; i < ctx->so->num_outputs; i++) {