[virglrenderer-devel] [PATCH 09/19] tessellation: add shader property support
Dave Airlie
airlied at gmail.com
Fri Jun 8 05:14:13 UTC 2018
From: Dave Airlie <airlied at redhat.com>
This takes the tgsi shader properties and emits the correct GLSL
layouts.
---
src/vrend_shader.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 89e9fa7..07f9555 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -166,6 +166,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[] = {
@@ -283,6 +289,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) {
@@ -967,6 +996,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;
}
@@ -2998,6 +3047,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)
--
2.14.3
More information about the virglrenderer-devel
mailing list