summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-12-22 12:28:28 +1000
committerDave Airlie <airlied@redhat.com>2016-02-19 11:18:23 +1000
commitcc899b6ff5c0e9d84f28fd9519fb39bfcbb93dbc (patch)
treebb64d94579238b61a32fba7fb7310478fce742cd
parent9e0709104e8b5b4625841b63ee153a271bcd9b82 (diff)
handle patch variables properly
-rw-r--r--src/vrend_shader.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 3d0c94d..4807dfa 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -476,6 +476,8 @@ iter_declaration(struct tgsi_iterate_context *iter,
snprintf(ctx->inputs[i].glsl_name, 64, "%s_c%d", name_prefix, ctx->inputs[i].sid);
else if (ctx->inputs[i].name == TGSI_SEMANTIC_GENERIC)
snprintf(ctx->inputs[i].glsl_name, 64, "%s_g%d", name_prefix, ctx->inputs[i].sid);
+ else if (ctx->inputs[i].name == TGSI_SEMANTIC_PATCH)
+ snprintf(ctx->inputs[i].glsl_name, 64, "%s_p%d", name_prefix, ctx->inputs[i].sid);
else
snprintf(ctx->inputs[i].glsl_name, 64, "%s_%d", name_prefix, ctx->inputs[i].first);
}
@@ -674,6 +676,8 @@ iter_declaration(struct tgsi_iterate_context *iter,
snprintf(ctx->outputs[i].glsl_name, 64, "%s_c%d", name_prefix, ctx->outputs[i].sid);
else if (ctx->outputs[i].name == TGSI_SEMANTIC_BCOLOR)
snprintf(ctx->outputs[i].glsl_name, 64, "%s_bc%d", name_prefix, ctx->outputs[i].sid);
+ else if (ctx->outputs[i].name == TGSI_SEMANTIC_PATCH)
+ snprintf(ctx->outputs[i].glsl_name, 64, "%s_p%d", name_prefix, ctx->outputs[i].sid);
else if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC)
snprintf(ctx->outputs[i].glsl_name, 64, "%s_g%d", name_prefix, ctx->outputs[i].sid);
else
@@ -1593,7 +1597,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL ? "gl_InvocationID" : "0",
ctx->outputs[j].glsl_name,
ctx->outputs[j].override_no_wm ? "" : writemask);
- } else if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL)
+ } else if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL && ctx->outputs[j].name != TGSI_SEMANTIC_PATCH)
snprintf(dsts[i], 255, "%s[gl_InvocationID]%s", ctx->outputs[j].glsl_name, ctx->outputs[j].override_no_wm ? "" : writemask);
else
snprintf(dsts[i], 255, "%s%s", ctx->outputs[j].glsl_name, ctx->outputs[j].override_no_wm ? "" : writemask);
@@ -2524,7 +2528,9 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
snprintf(buf, 255, "layout(location=%d) ", ctx->inputs[i].first);
STRCAT_WITH_RET(glsl_hdr, buf);
}
- if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT &&
+ if (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL && ctx->inputs[i].name == TGSI_SEMANTIC_PATCH)
+ prefix = "patch ";
+ else if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT &&
(ctx->inputs[i].name == TGSI_SEMANTIC_GENERIC ||
ctx->inputs[i].name == TGSI_SEMANTIC_COLOR)) {
prefix = get_interp_string(ctx->inputs[i].interpolate, ctx->key->flatshade);
@@ -2535,7 +2541,8 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) {
snprintf(postfix, 8, "[%d]", gs_input_prim_to_size(ctx->gs_in_prim));
- } else if (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL) {
+ } else if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL ||
+ (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL && ctx->inputs[i].name != TGSI_SEMANTIC_PATCH)) {
snprintf(postfix, 8, "[]");
} else
postfix[0] = 0;
@@ -2576,9 +2583,12 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} else
prefix = "";
/* ugly leave spaces to patch interp in later */
- if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL)
- snprintf(buf, 255, "%sout vec4 %s[];\n", prefix, ctx->outputs[i].glsl_name);
- else if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY && ctx->outputs[i].stream)
+ if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL) {
+ if (ctx->outputs[i].name == TGSI_SEMANTIC_PATCH)
+ snprintf(buf, 255, "patch out vec4 %s;\n", ctx->outputs[i].glsl_name);
+ else
+ snprintf(buf, 255, "%sout vec4 %s[];\n", prefix, ctx->outputs[i].glsl_name);
+ } else if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY && ctx->outputs[i].stream)
snprintf(buf, 255, "layout (stream = %d) %sout vec4 %s;\n", ctx->outputs[i].stream, prefix, ctx->outputs[i].glsl_name);
else
snprintf(buf, 255, "%sout vec4 %s;\n", prefix, ctx->outputs[i].glsl_name);