summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-05-17 17:44:34 +0200
committerNicolai Hähnle <[email protected]>2017-07-05 12:27:11 +0200
commit497b95fdf641eb5e52de1a6a51d251ee2b3bdb2d (patch)
treef704eeaba07ff65ede142ce9e88f064ba14f21d9 /src/mesa
parentd91f97f91db4a826f7d5909a2a63a028a81188bb (diff)
tgsi,st/mesa: move varying slot to semantic mapping into a helper for VS
We will use this helper in radeonsi's NIR path. Reviewed-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_program.c86
-rw-r--r--src/mesa/state_tracker/st_program.h21
2 files changed, 8 insertions, 99 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 6de61741dcf..eb44fc57b57 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -417,87 +417,11 @@ st_translate_vertex_program(struct st_context *st,
stvp->result_to_output[attr] = slot;
- switch (attr) {
- case VARYING_SLOT_POS:
- output_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_COL0:
- output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_COL1:
- output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
- output_semantic_index[slot] = 1;
- break;
- case VARYING_SLOT_BFC0:
- output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_BFC1:
- output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
- output_semantic_index[slot] = 1;
- break;
- case VARYING_SLOT_FOGC:
- output_semantic_name[slot] = TGSI_SEMANTIC_FOG;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_PSIZ:
- output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_CLIP_DIST0:
- output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_CLIP_DIST1:
- output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
- output_semantic_index[slot] = 1;
- break;
- case VARYING_SLOT_CULL_DIST0:
- case VARYING_SLOT_CULL_DIST1:
- /* these should have been lowered by GLSL */
- assert(0);
- break;
- case VARYING_SLOT_EDGE:
- assert(0);
- break;
- case VARYING_SLOT_CLIP_VERTEX:
- output_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_LAYER:
- output_semantic_name[slot] = TGSI_SEMANTIC_LAYER;
- output_semantic_index[slot] = 0;
- break;
- case VARYING_SLOT_VIEWPORT:
- output_semantic_name[slot] = TGSI_SEMANTIC_VIEWPORT_INDEX;
- output_semantic_index[slot] = 0;
- break;
-
- case VARYING_SLOT_TEX0:
- case VARYING_SLOT_TEX1:
- case VARYING_SLOT_TEX2:
- case VARYING_SLOT_TEX3:
- case VARYING_SLOT_TEX4:
- case VARYING_SLOT_TEX5:
- case VARYING_SLOT_TEX6:
- case VARYING_SLOT_TEX7:
- if (st->needs_texcoord_semantic) {
- output_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD;
- output_semantic_index[slot] = attr - VARYING_SLOT_TEX0;
- break;
- }
- /* fall through */
- case VARYING_SLOT_VAR0:
- default:
- assert(attr >= VARYING_SLOT_VAR0 ||
- (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7));
- output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- output_semantic_index[slot] =
- st_get_generic_varying_index(st, attr);
- break;
- }
+ unsigned semantic_name, semantic_index;
+ tgsi_get_gl_varying_semantic(attr, st->needs_texcoord_semantic,
+ &semantic_name, &semantic_index);
+ output_semantic_name[slot] = semantic_name;
+ output_semantic_index[slot] = semantic_index;
}
}
/* similar hack to above, presetup potentially unused edgeflag output */
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 3f0cf49f025..8e9f4c5e826 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -38,11 +38,11 @@
#include "main/atifragshader.h"
#include "program/program.h"
#include "pipe/p_state.h"
+#include "tgsi/tgsi_from_mesa.h"
#include "st_context.h"
#include "st_texture.h"
#include "st_glsl_to_tgsi.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -358,23 +358,8 @@ st_reference_compprog(struct st_context *st,
static inline unsigned
st_get_generic_varying_index(struct st_context *st, GLuint attr)
{
- if (attr >= VARYING_SLOT_VAR0) {
- if (st->needs_texcoord_semantic)
- return attr - VARYING_SLOT_VAR0;
- else
- return 9 + (attr - VARYING_SLOT_VAR0);
- }
- if (attr == VARYING_SLOT_PNTC) {
- assert(!st->needs_texcoord_semantic);
- return 8;
- }
- if (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) {
- assert(!st->needs_texcoord_semantic);
- return attr - VARYING_SLOT_TEX0;
- }
-
- assert(0);
- return 0;
+ return tgsi_get_generic_gl_varying_index((gl_varying_slot)attr,
+ st->needs_texcoord_semantic);
}
extern void