aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-06-08 19:36:59 +0200
committerNicolai Hähnle <[email protected]>2017-07-05 12:27:11 +0200
commitc7ecbd11539e1497f65072d18773a12d1726f099 (patch)
tree60478956af5a3e577051a1207c82ab00a9672d73 /src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
parentfb1c4e3d4764f64a1a5e2f84bc1d825bb392a847 (diff)
tgsi_from_mesa: add tgsi_get_gl_frag_result_semantic
Reviewed-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_from_mesa.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_from_mesa.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
index 44fae1c28e6..b7a21f29bad 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c
@@ -148,3 +148,38 @@ tgsi_get_gl_varying_semantic(gl_varying_slot attr,
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);
+ }
+}