[Mesa-dev] [PATCH 12/92] tgsi_from_mesa: add tgsi_get_gl_frag_result_semantic
Nicolai Hähnle
nhaehnle at gmail.com
Mon Jun 26 14:09:51 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/gallium/auxiliary/tgsi/tgsi_from_mesa.c | 35 +++++++++++++++++++++++++++++
src/gallium/auxiliary/tgsi/tgsi_from_mesa.h | 5 +++++
2 files changed, 40 insertions(+)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
index 44fae1c..b7a21f2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
@@ -141,10 +141,45 @@ tgsi_get_gl_varying_semantic(gl_varying_slot attr,
case VARYING_SLOT_VAR0:
default:
assert(attr >= VARYING_SLOT_VAR0 ||
(attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7));
*semantic_name = TGSI_SEMANTIC_GENERIC;
*semantic_index =
tgsi_get_generic_gl_varying_index(attr, needs_texcoord_semantic);
break;
}
}
+
+/**
+ * Determine the semantic name and index used for the given fragment shader
+ * result.
+ */
+void
+tgsi_get_gl_frag_result_semantic(gl_frag_result frag_result,
+ unsigned *semantic_name,
+ unsigned *semantic_index)
+{
+ if (frag_result >= FRAG_RESULT_DATA0) {
+ *semantic_name = TGSI_SEMANTIC_COLOR;
+ *semantic_index = frag_result - FRAG_RESULT_DATA0;
+ return;
+ }
+
+ *semantic_index = 0;
+
+ switch (frag_result) {
+ case FRAG_RESULT_DEPTH:
+ *semantic_name = TGSI_SEMANTIC_POSITION;
+ break;
+ case FRAG_RESULT_STENCIL:
+ *semantic_name = TGSI_SEMANTIC_STENCIL;
+ break;
+ case FRAG_RESULT_COLOR:
+ *semantic_name = TGSI_SEMANTIC_COLOR;
+ break;
+ case FRAG_RESULT_SAMPLE_MASK:
+ *semantic_name = TGSI_SEMANTIC_SAMPLEMASK;
+ break;
+ default:
+ assert(false);
+ }
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h
index d0f211e..bfaa48d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.h
@@ -35,20 +35,25 @@
void
tgsi_get_gl_varying_semantic(gl_varying_slot attr,
bool needs_texcoord_semantic,
unsigned *semantic_name,
unsigned *semantic_index);
unsigned
tgsi_get_generic_gl_varying_index(gl_varying_slot attr,
bool needs_texcoord_semantic);
+void
+tgsi_get_gl_frag_result_semantic(gl_frag_result frag_result,
+ unsigned *semantic_name,
+ unsigned *semantic_index);
+
static inline enum pipe_shader_type
pipe_shader_type_from_mesa(gl_shader_stage stage)
{
switch (stage) {
case MESA_SHADER_VERTEX:
return PIPE_SHADER_VERTEX;
case MESA_SHADER_TESS_CTRL:
return PIPE_SHADER_TESS_CTRL;
case MESA_SHADER_TESS_EVAL:
return PIPE_SHADER_TESS_EVAL;
--
2.9.3
More information about the mesa-dev
mailing list