summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_program.c
diff options
context:
space:
mode:
authorBryan Cain <[email protected]>2013-02-15 10:02:18 -0600
committerDave Airlie <[email protected]>2013-10-17 08:35:42 +0100
commit9bfa475684fb20afacce01fa02b1a39bc3f23bdc (patch)
tree4531ac95142dbd2334b517f94a434b9ddbf794c9 /src/mesa/state_tracker/st_program.c
parent6b0df34ae5c0a8332559383c900241596eb2ac87 (diff)
st/mesa, glsl_to_tgsi: add support for geometry shaders
v2 (Bryan Cain <[email protected]>): fix 2D array indexing order. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_program.c')
-rw-r--r--src/mesa/state_tracker/st_program.c107
1 files changed, 80 insertions, 27 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 211b879e0d8..925ea80403f 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -828,7 +828,6 @@ st_translate_geometry_program(struct st_context *st,
GLuint attr;
GLbitfield64 inputsRead;
GLuint vslot = 0;
- GLuint num_generic = 0;
uint gs_num_inputs = 0;
uint gs_builtin_inputs = 0;
@@ -848,7 +847,9 @@ st_translate_geometry_program(struct st_context *st,
if (!gpv)
return NULL;
- _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT);
+ if (!stgp->glsl_to_tgsi) {
+ _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT);
+ }
ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY );
if (ureg == NULL) {
@@ -910,6 +911,18 @@ st_translate_geometry_program(struct st_context *st,
stgp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
stgp->input_semantic_index[slot] = 0;
break;
+ case VARYING_SLOT_CLIP_VERTEX:
+ stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
+ stgp->input_semantic_index[slot] = 0;
+ break;
+ case VARYING_SLOT_CLIP_DIST0:
+ stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ stgp->input_semantic_index[slot] = 0;
+ break;
+ case VARYING_SLOT_CLIP_DIST1:
+ stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ stgp->input_semantic_index[slot] = 1;
+ break;
case VARYING_SLOT_TEX0:
case VARYING_SLOT_TEX1:
case VARYING_SLOT_TEX2:
@@ -919,13 +932,17 @@ st_translate_geometry_program(struct st_context *st,
case VARYING_SLOT_TEX6:
case VARYING_SLOT_TEX7:
stgp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- stgp->input_semantic_index[slot] = num_generic++;
+ stgp->input_semantic_index[slot] = (attr - VARYING_SLOT_TEX0);
break;
case VARYING_SLOT_VAR0:
- /* fall-through */
default:
+ assert(attr >= VARYING_SLOT_VAR0 && attr < VARYING_SLOT_MAX);
stgp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- stgp->input_semantic_index[slot] = num_generic++;
+ stgp->input_semantic_index[slot] = (VARYING_SLOT_VAR0 -
+ VARYING_SLOT_TEX0 +
+ attr -
+ VARYING_SLOT_VAR0);
+ break;
}
}
}
@@ -936,7 +953,6 @@ st_translate_geometry_program(struct st_context *st,
gs_output_semantic_index[i] = 0;
}
- num_generic = 0;
/*
* Determine number of outputs, the (default) output register
* mapping and the semantic information for each output.
@@ -979,6 +995,18 @@ st_translate_geometry_program(struct st_context *st,
gs_output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
gs_output_semantic_index[slot] = 0;
break;
+ case VARYING_SLOT_CLIP_VERTEX:
+ gs_output_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
+ gs_output_semantic_index[slot] = 0;
+ break;
+ case VARYING_SLOT_CLIP_DIST0:
+ gs_output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ gs_output_semantic_index[slot] = 0;
+ break;
+ case VARYING_SLOT_CLIP_DIST1:
+ gs_output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ gs_output_semantic_index[slot] = 1;
+ break;
case VARYING_SLOT_TEX0:
case VARYING_SLOT_TEX1:
case VARYING_SLOT_TEX2:
@@ -987,14 +1015,18 @@ st_translate_geometry_program(struct st_context *st,
case VARYING_SLOT_TEX5:
case VARYING_SLOT_TEX6:
case VARYING_SLOT_TEX7:
- /* fall-through */
+ gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+ gs_output_semantic_index[slot] = (attr - VARYING_SLOT_TEX0);
+ break;
case VARYING_SLOT_VAR0:
- /* fall-through */
default:
assert(slot < Elements(gs_output_semantic_name));
- /* use default semantic info */
+ assert(attr >= VARYING_SLOT_VAR0);
gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- gs_output_semantic_index[slot] = num_generic++;
+ gs_output_semantic_index[slot] = (VARYING_SLOT_VAR0 -
+ VARYING_SLOT_TEX0 +
+ attr -
+ VARYING_SLOT_VAR0);
}
}
}
@@ -1038,23 +1070,44 @@ st_translate_geometry_program(struct st_context *st,
ureg_property_gs_output_prim(ureg, stgp->Base.OutputType);
ureg_property_gs_max_vertices(ureg, stgp->Base.VerticesOut);
- st_translate_mesa_program(st->ctx,
- TGSI_PROCESSOR_GEOMETRY,
- ureg,
- &stgp->Base.Base,
- /* inputs */
- gs_num_inputs,
- inputMapping,
- stgp->input_semantic_name,
- stgp->input_semantic_index,
- NULL,
- /* outputs */
- gs_num_outputs,
- outputMapping,
- gs_output_semantic_name,
- gs_output_semantic_index,
- FALSE,
- FALSE);
+ if (stgp->glsl_to_tgsi)
+ st_translate_program(st->ctx,
+ TGSI_PROCESSOR_GEOMETRY,
+ ureg,
+ stgp->glsl_to_tgsi,
+ &stgp->Base.Base,
+ /* inputs */
+ gs_num_inputs,
+ inputMapping,
+ stgp->input_semantic_name,
+ stgp->input_semantic_index,
+ NULL,
+ NULL,
+ /* outputs */
+ gs_num_outputs,
+ outputMapping,
+ gs_output_semantic_name,
+ gs_output_semantic_index,
+ FALSE,
+ FALSE);
+ else
+ st_translate_mesa_program(st->ctx,
+ TGSI_PROCESSOR_GEOMETRY,
+ ureg,
+ &stgp->Base.Base,
+ /* inputs */
+ gs_num_inputs,
+ inputMapping,
+ stgp->input_semantic_name,
+ stgp->input_semantic_index,
+ NULL,
+ /* outputs */
+ gs_num_outputs,
+ outputMapping,
+ gs_output_semantic_name,
+ gs_output_semantic_index,
+ FALSE,
+ FALSE);
stgp->num_inputs = gs_num_inputs;
stgp->tgsi.tokens = ureg_get_tokens( ureg, NULL );