summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2015-09-23 20:40:02 +1000
committerDave Airlie <airlied@redhat.com>2016-02-19 11:17:26 +1000
commit6a93e6eaac48713e164ef920fd796638d9886ae3 (patch)
tree87ff51d7ac828687744e0c3559f3e5b4d4a9c206
parenta9f193c8f0e634e4ce4874454c9dab0806ff6cb3 (diff)
gpu_shader5: add invocation id support
-rw-r--r--src/vrend_shader.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 40dc8b0..8f08192 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -121,6 +121,7 @@ struct dump_ctx {
int fs_coord_origin, fs_pixel_center;
int gs_in_prim, gs_out_prim, gs_max_out_verts;
+ int gs_num_invocations;
struct vrend_shader_key *key;
int indent_level;
@@ -603,6 +604,10 @@ iter_declaration(struct tgsi_iterate_context *iter,
} else if (decl->Semantic.Name == TGSI_SEMANTIC_VERTEXID) {
name_prefix = "gl_VertexID";
ctx->has_ints = true;
+ } else if (decl->Semantic.Name == TGSI_SEMANTIC_INVOCATIONID) {
+ name_prefix = "gl_InvocationID";
+ ctx->has_ints = true;
+ ctx->uses_gpu_shader5 = true;
} else {
fprintf(stderr, "unsupported system value %d\n", decl->Semantic.Name);
name_prefix = "unknown";
@@ -647,6 +652,10 @@ iter_property(struct tgsi_iterate_context *iter,
if (prop->Property.PropertyName == TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES) {
ctx->gs_max_out_verts = prop->u[0].Data;
}
+
+ if (prop->Property.PropertyName == TGSI_PROPERTY_GS_INVOCATIONS) {
+ ctx->gs_num_invocations = prop->u[0].Data;
+ }
return TRUE;
}
@@ -1535,7 +1544,8 @@ iter_instruction(struct tgsi_iterate_context *iter,
} else if (src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
for (j = 0; j < ctx->num_system_values; j++)
if (ctx->system_values[j].first == src->Register.Index) {
- if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID)
+ if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID ||
+ ctx->system_values[j].name == TGSI_SEMANTIC_INVOCATIONID)
snprintf(srcs[i], 255, "%s(vec4(intBitsToFloat(%s)))", stypeprefix, ctx->system_values[j].glsl_name);
else
snprintf(srcs[i], 255, "%s%s", prefix, ctx->system_values[j].glsl_name);
@@ -2086,7 +2096,13 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
}
}
if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) {
- snprintf(buf, 255, "layout(%s) in;\n", prim_to_name(ctx->gs_in_prim));
+ char invocbuf[25];
+
+ if (ctx->gs_num_invocations)
+ snprintf(invocbuf, 25, ", invocations = %d", ctx->gs_num_invocations);
+
+ snprintf(buf, 255, "layout(%s%s) in;\n", prim_to_name(ctx->gs_in_prim),
+ ctx->gs_num_invocations > 1 ? invocbuf : "");
STRCAT_WITH_RET(glsl_hdr, buf);
snprintf(buf, 255, "layout(%s, max_vertices = %d) out;\n", prim_to_name(ctx->gs_out_prim), ctx->gs_max_out_verts);
STRCAT_WITH_RET(glsl_hdr, buf);