[virglrenderer-devel] [PATCH 1/3] shader: rename shader outputs for easier distinction.
Dave Airlie
airlied at gmail.com
Fri Mar 9 06:51:30 UTC 2018
From: Dave Airlie <airlied at redhat.com>
outputs from vertex shaders are now vso
and outputs from geometry shaders are now gso.
This allows adding tessellation a bit easier.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/vrend_renderer.c | 4 ++--
src/vrend_shader.c | 40 +++++++++++++++++++++++++++-------------
src/vrend_shader.h | 2 +-
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 597f14e..8f8a00e 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -858,11 +858,11 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
if (gs)
vrend_patch_vertex_shader_interpolants(&ctx->shader_cfg, gs->glsl_prog,
&gs->sel->sinfo,
- &fs->sel->sinfo, true, fs->key.flatshade);
+ &fs->sel->sinfo, "gso", fs->key.flatshade);
else
vrend_patch_vertex_shader_interpolants(&ctx->shader_cfg, vs->glsl_prog,
&vs->sel->sinfo,
- &fs->sel->sinfo, false, fs->key.flatshade);
+ &fs->sel->sinfo, "vso", fs->key.flatshade);
ret = vrend_compile_shader(ctx, gs ? gs : vs);
if (ret == false) {
glDeleteShader(gs ? gs->id : vs->id);
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 498e45c..f3b245a 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -418,15 +418,21 @@ iter_declaration(struct tgsi_iterate_context *iter,
}
}
default:
- if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT ||
- iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) {
- if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
- ctx->key->gs_present)
- name_prefix = "out";
+ switch (iter->processor.Processor) {
+ case TGSI_PROCESSOR_FRAGMENT:
+ if (ctx->key->gs_present)
+ name_prefix = "gso";
else
- name_prefix = "ex";
- } else
+ name_prefix = "vso";
+ break;
+ case TGSI_PROCESSOR_GEOMETRY:
+ name_prefix = "vso";
+ break;
+ case TGSI_PROCESSOR_VERTEX:
+ default:
name_prefix = "in";
+ break;
+ }
break;
}
@@ -596,12 +602,20 @@ iter_declaration(struct tgsi_iterate_context *iter,
if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC)
color_offset = -1;
default:
- if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX)
- name_prefix = "ex";
- else if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT)
+ switch (iter->processor.Processor) {
+ case TGSI_PROCESSOR_FRAGMENT:
name_prefix = "fsout";
- else
+ break;
+ case TGSI_PROCESSOR_GEOMETRY:
+ name_prefix = "gso";
+ break;
+ case TGSI_PROCESSOR_VERTEX:
+ name_prefix = "vso";
+ break;
+ default:
name_prefix = "out";
+ break;
+ }
break;
}
@@ -2729,7 +2743,7 @@ static void replace_interp(char *program,
bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg, char *program,
struct vrend_shader_info *vs_info,
- struct vrend_shader_info *fs_info, bool is_gs, bool flatshade)
+ struct vrend_shader_info *fs_info, const char *oprefix, bool flatshade)
{
int i;
const char *pstring;
@@ -2764,7 +2778,7 @@ bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg, char *
}
break;
case TGSI_SEMANTIC_GENERIC:
- snprintf(glsl_name, 64, "%s_g%d", is_gs ? "out" : "ex", fs_info->interpinfo[i].semantic_index);
+ snprintf(glsl_name, 64, "%s_g%d", oprefix, fs_info->interpinfo[i].semantic_index);
replace_interp(program, glsl_name, pstring);
break;
default:
diff --git a/src/vrend_shader.h b/src/vrend_shader.h
index f0dd9cb..646dddc 100644
--- a/src/vrend_shader.h
+++ b/src/vrend_shader.h
@@ -80,7 +80,7 @@ bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg,
char *program,
struct vrend_shader_info *vs_info,
struct vrend_shader_info *fs_info,
- bool is_gs, bool flatshade);
+ const char *oprefix, bool flatshade);
char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
const struct tgsi_token *tokens,
--
2.14.3
More information about the virglrenderer-devel
mailing list