[virglrenderer-devel] [PATCH 13/19] tessellation: handle tess inner/outer/coord

Dave Airlie airlied at gmail.com
Fri Jun 8 05:14:17 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This adds support for tess factors and tess coord semantics
---
 src/vrend_shader.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index c3b92e9..55d1b46 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -846,6 +846,24 @@ iter_declaration(struct tgsi_iterate_context *iter,
                ctx->shader_req_bits |= SHADER_REQ_VIEWPORT_IDX;
             break;
          }
+      case TGSI_SEMANTIC_TESSOUTER:
+         if (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) {
+            ctx->outputs[i].glsl_predefined_no_emit = true;
+            ctx->outputs[i].glsl_no_index = true;
+            ctx->outputs[i].override_no_wm = true;
+            name_prefix = "gl_TessLevelOuter";
+            break;
+         }
+
+      case TGSI_SEMANTIC_TESSINNER:
+         if (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) {
+            ctx->outputs[i].glsl_predefined_no_emit = true;
+            ctx->outputs[i].glsl_no_index = true;
+            ctx->outputs[i].override_no_wm = true;
+            name_prefix = "gl_TessLevelInner";
+            break;
+         }
+
       case TGSI_SEMANTIC_GENERIC:
          if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX)
             if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC)
@@ -956,6 +974,18 @@ iter_declaration(struct tgsi_iterate_context *iter,
       } else if (decl->Semantic.Name == TGSI_SEMANTIC_PRIMID) {
          name_prefix = "gl_PrimitiveID";
          ctx->shader_req_bits |= (SHADER_REQ_INTS | SHADER_REQ_GPU_SHADER5);
+      } else if (decl->Semantic.Name == TGSI_SEMANTIC_TESSCOORD) {
+         name_prefix = "gl_TessCoord";
+         ctx->system_values[i].override_no_wm = false;
+      } else if (decl->Semantic.Name == TGSI_SEMANTIC_VERTICESIN) {
+         name_prefix = "gl_PatchVerticesIn";
+         ctx->system_values[i].override_no_wm = false;
+      } else if (decl->Semantic.Name == TGSI_SEMANTIC_TESSOUTER) {
+         name_prefix = "gl_TessLevelOuter";
+         ctx->system_values[i].override_no_wm = false;
+      } else if (decl->Semantic.Name == TGSI_SEMANTIC_TESSINNER) {
+         name_prefix = "gl_TessLevelInner";
+         ctx->system_values[i].override_no_wm = false;
       } else {
          fprintf(stderr, "unsupported system value %d\n", decl->Semantic.Name);
          name_prefix = "unknown";
@@ -1997,7 +2027,9 @@ get_destination_info(struct dump_ctx *ctx,
                   snprintf(dsts[i], 255, "clipv_tmp");
                } else if (ctx->outputs[j].name == TGSI_SEMANTIC_CLIPDIST) {
                   snprintf(dsts[i], 255, "clip_dist_temp[%d]", ctx->outputs[j].sid);
-               } else if (ctx->outputs[j].name == TGSI_SEMANTIC_SAMPLEMASK) {
+               } else if (ctx->outputs[j].name == TGSI_SEMANTIC_TESSOUTER ||
+                          ctx->outputs[j].name == TGSI_SEMANTIC_TESSINNER ||
+                          ctx->outputs[j].name == TGSI_SEMANTIC_SAMPLEMASK) {
                   int idx;
                   switch (dst_reg->Register.WriteMask) {
                   case 0x1: idx = 0; break;
@@ -2314,7 +2346,11 @@ get_source_info(struct dump_ctx *ctx,
                    ctx->system_values[j].name == TGSI_SEMANTIC_INVOCATIONID ||
                    ctx->system_values[j].name == TGSI_SEMANTIC_SAMPLEID)
                   snprintf(srcs[i], 255, "%s(vec4(intBitsToFloat(%s)))", get_string(stypeprefix), ctx->system_values[j].glsl_name);
-               else if (ctx->system_values[j].name == TGSI_SEMANTIC_SAMPLEPOS) {
+               else if (ctx->system_values[j].name == TGSI_SEMANTIC_TESSINNER ||
+                        ctx->system_values[j].name == TGSI_SEMANTIC_TESSOUTER) {
+                  snprintf(srcs[i], 255, "%s%s[%d]", prefix, ctx->system_values[j].glsl_name, src->Register.SwizzleX);
+               } else if (ctx->system_values[j].name == TGSI_SEMANTIC_SAMPLEPOS ||
+                          ctx->system_values[j].name == TGSI_SEMANTIC_TESSCOORD) {
                   snprintf(srcs[i], 255, "vec4(%s.%c, %s.%c, %s.%c, %s.%c)",
                            ctx->system_values[j].glsl_name, get_swiz_char(src->Register.SwizzleX),
                            ctx->system_values[j].glsl_name, get_swiz_char(src->Register.SwizzleY),
-- 
2.14.3



More information about the virglrenderer-devel mailing list