[virglrenderer-devel] [PATCH 03/12] tgsi: handle parsing vertex streams
Dave Airlie
airlied at gmail.com
Tue May 15 04:38:01 UTC 2018
From: Dave Airlie <airlied at redhat.com>
These are needed for ARB_gpu_shader5
---
src/gallium/auxiliary/tgsi/tgsi_build.c | 18 +++++++++--
src/gallium/auxiliary/tgsi/tgsi_text.c | 48 ++++++++++++++++++++++++++++++
src/gallium/include/pipe/p_shader_tokens.h | 5 +++-
3 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index e243c46..a57f2e3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -233,7 +233,10 @@ tgsi_default_declaration_semantic( void )
ds.Name = TGSI_SEMANTIC_POSITION;
ds.Index = 0;
- ds.Padding = 0;
+ ds.StreamX = 0;
+ ds.StreamY = 0;
+ ds.StreamZ = 0;
+ ds.StreamW = 0;
return ds;
}
@@ -242,6 +245,10 @@ static struct tgsi_declaration_semantic
tgsi_build_declaration_semantic(
unsigned semantic_name,
unsigned semantic_index,
+ unsigned streamx,
+ unsigned streamy,
+ unsigned streamz,
+ unsigned streamw,
struct tgsi_declaration *declaration,
struct tgsi_header *header )
{
@@ -252,7 +259,10 @@ tgsi_build_declaration_semantic(
ds.Name = semantic_name;
ds.Index = semantic_index;
- ds.Padding = 0;
+ ds.StreamX = streamx;
+ ds.StreamY = streamy;
+ ds.StreamZ = streamz;
+ ds.StreamW = streamw;
declaration_grow( declaration, header );
@@ -450,6 +460,10 @@ tgsi_build_full_declaration(
*ds = tgsi_build_declaration_semantic(
full_decl->Semantic.Name,
full_decl->Semantic.Index,
+ full_decl->Semantic.StreamX,
+ full_decl->Semantic.StreamY,
+ full_decl->Semantic.StreamZ,
+ full_decl->Semantic.StreamW,
declaration,
header );
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 3378148..c1b1916 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1377,6 +1377,54 @@ static boolean parse_declaration( struct translate_ctx *ctx )
}
}
+ cur = ctx->cur;
+ eat_opt_white( &cur );
+ if (*cur == ',' &&
+ file == TGSI_FILE_OUTPUT && ctx->processor == PIPE_SHADER_GEOMETRY) {
+ cur++;
+ eat_opt_white(&cur);
+ if (str_match_nocase_whole(&cur, "STREAM")) {
+ uint stream[4];
+
+ eat_opt_white(&cur);
+ if (*cur != '(') {
+ report_error(ctx, "Expected '('");
+ return FALSE;
+ }
+ cur++;
+
+ for (int i = 0; i < 4; ++i) {
+ eat_opt_white(&cur);
+ if (!parse_uint(&cur, &stream[i])) {
+ report_error(ctx, "Expected literal integer");
+ return FALSE;
+ }
+
+ eat_opt_white(&cur);
+ if (i < 3) {
+ if (*cur != ',') {
+ report_error(ctx, "Expected ','");
+ return FALSE;
+ }
+ cur++;
+ }
+ }
+
+ if (*cur != ')') {
+ report_error(ctx, "Expected ')'");
+ return FALSE;
+ }
+ cur++;
+
+ decl.Semantic.StreamX = stream[0];
+ decl.Semantic.StreamY = stream[1];
+ decl.Semantic.StreamZ = stream[2];
+ decl.Semantic.StreamW = stream[3];
+
+ ctx->cur = cur;
+ }
+ }
+
cur = ctx->cur;
eat_opt_white( &cur );
if (*cur == ',' && !is_vs_input) {
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index c778e70..0ff543e 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -192,7 +192,10 @@ struct tgsi_declaration_semantic
{
unsigned Name : 8; /**< one of TGSI_SEMANTIC_x */
unsigned Index : 16; /**< UINT */
- unsigned Padding : 8;
+ unsigned StreamX : 2; /**< vertex stream (for GS output) */
+ unsigned StreamY : 2;
+ unsigned StreamZ : 2;
+ unsigned StreamW : 2;
};
struct tgsi_declaration_resource {
--
2.14.3
More information about the virglrenderer-devel
mailing list