[virglrenderer-devel] [PATCH 10/21] tessellation: add shader property support (v2)

Dave Airlie airlied at gmail.com
Wed Jun 13 00:56:44 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This takes the tgsi shader properties and emits the correct GLSL
layouts.

It also exports the tes prim and point info to the renderer,
for transform feedback

v2: add prim/point for transform feedback
---
 src/vrend_shader.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/vrend_shader.h |  2 ++
 2 files changed, 66 insertions(+)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 83d1410..180923d 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -167,6 +167,12 @@ struct dump_ctx {
    bool has_clipvertex_so;
    bool vs_has_pervertex;
    bool write_mul_temp;
+
+   int tcs_vertices_out;
+   int tes_prim_mode;
+   int tes_spacing;
+   int tes_vertex_order;
+   int tes_point_mode;
 };
 
 static const struct vrend_shader_table shader_req_table[] = {
@@ -289,6 +295,29 @@ static inline const char *prim_to_name(int prim)
    };
 }
 
+static inline const char *prim_to_tes_name(int prim)
+{
+   switch (prim) {
+   case PIPE_PRIM_QUADS: return "quads";
+   case PIPE_PRIM_TRIANGLES: return "triangles";
+   case PIPE_PRIM_LINES: return "isolines";
+   default: return "UNKNOWN";
+   }
+}
+
+static const char *get_spacing_string(int spacing)
+{
+   switch (spacing) {
+   case PIPE_TESS_SPACING_FRACTIONAL_ODD:
+      return "fractional_odd_spacing";
+   case PIPE_TESS_SPACING_FRACTIONAL_EVEN:
+      return "fractional_even_spacing";
+   case PIPE_TESS_SPACING_EQUAL:
+   default:
+      return "equal_spacing";
+   }
+}
+
 static inline int gs_input_prim_to_size(int prim)
 {
    switch (prim) {
@@ -986,6 +1015,26 @@ iter_property(struct tgsi_iterate_context *iter,
    if (prop->Property.PropertyName == TGSI_PROPERTY_NUM_CULLDIST_ENABLED) {
       ctx->num_cull_dist_prop = prop->u[0].Data;
    }
+
+   if (prop->Property.PropertyName == TGSI_PROPERTY_TCS_VERTICES_OUT) {
+      ctx->tcs_vertices_out = prop->u[0].Data;
+   }
+
+   if (prop->Property.PropertyName == TGSI_PROPERTY_TES_PRIM_MODE) {
+      ctx->tes_prim_mode = prop->u[0].Data;
+   }
+
+   if (prop->Property.PropertyName == TGSI_PROPERTY_TES_SPACING) {
+      ctx->tes_spacing = prop->u[0].Data;
+   }
+
+   if (prop->Property.PropertyName == TGSI_PROPERTY_TES_VERTEX_ORDER_CW) {
+      ctx->tes_vertex_order = prop->u[0].Data;
+   }
+
+   if (prop->Property.PropertyName == TGSI_PROPERTY_TES_POINT_MODE) {
+      ctx->tes_point_mode = prop->u[0].Data;
+   }
    return TRUE;
 }
 
@@ -3146,6 +3195,19 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
          STRCAT_WITH_RET(glsl_hdr, buf);
       }
    }
+   if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL) {
+      snprintf(buf, 255, "layout(vertices = %d) out;\n", ctx->tcs_vertices_out);
+      STRCAT_WITH_RET(glsl_hdr, buf);
+   }
+   if (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL) {
+      snprintf(buf, 255, "layout(%s, %s, %s%s) in;\n",
+               prim_to_tes_name(ctx->tes_prim_mode),
+               get_spacing_string(ctx->tes_spacing),
+               ctx->tes_vertex_order ? "cw" : "ccw",
+               ctx->tes_point_mode ? ", point_mode" : "");
+      STRCAT_WITH_RET(glsl_hdr, buf);
+   }
+
    if (ctx->write_all_cbufs) {
       for (i = 0; i < 8; i++) {
          if (ctx->cfg->use_gles)
@@ -3567,6 +3629,8 @@ char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
    sinfo->shadow_samp_mask = ctx.shadow_samp_mask;
    sinfo->glsl_ver = ctx.glsl_ver_required;
    sinfo->gs_out_prim = ctx.gs_out_prim;
+   sinfo->tes_prim = ctx.tes_prim_mode;
+   sinfo->tes_point_mode = ctx.tes_point_mode;
    sinfo->so_names = ctx.so_names;
    sinfo->attrib_input_mask = ctx.attrib_input_mask;
    sinfo->sampler_arrays = ctx.sampler_arrays;
diff --git a/src/vrend_shader.h b/src/vrend_shader.h
index 2fe9f28..38b7219 100644
--- a/src/vrend_shader.h
+++ b/src/vrend_shader.h
@@ -60,6 +60,8 @@ struct vrend_shader_info {
    uint8_t num_cull_out;
    uint32_t shadow_samp_mask;
    int gs_out_prim;
+   int tes_prim;
+   bool tes_point_mode;
    uint32_t attrib_input_mask;
 
    struct vrend_sampler_array *sampler_arrays;
-- 
2.14.3



More information about the virglrenderer-devel mailing list