summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-10-05 03:26:48 +0200
committerMarek Olšák <[email protected]>2015-10-09 22:02:18 +0200
commit897177020bb702cd18eafcc1d8c4e7f502a8a65d (patch)
tree30fadd230e3354b952d6ac780479e4d56635e19d /src/mesa
parenta907b5dd162b7911b8c21f6d54837831bc078059 (diff)
st/mesa: translate geometry shaders into TGSI when we get them
Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Brian Paul <[email protected]> Tested-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_cb_program.c2
-rw-r--r--src/mesa/state_tracker/st_program.c38
-rw-r--r--src/mesa/state_tracker/st_program.h5
3 files changed, 30 insertions, 15 deletions
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 40eeb0f703e..dff06dd2608 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -244,6 +244,8 @@ st_program_string_notify( struct gl_context *ctx,
struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
st_release_gp_variants(st, stgp);
+ if (!st_translate_geometry_program(st, stgp))
+ return false;
if (st->gp == stgp)
st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 5eded93650c..37e7a09daf7 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -170,6 +170,11 @@ st_release_gp_variants(struct st_context *st, struct st_geometry_program *stgp)
}
stgp->variants = NULL;
+
+ if (stgp->tgsi.tokens) {
+ ureg_free_tokens(stgp->tgsi.tokens);
+ stgp->tgsi.tokens = NULL;
+ }
}
@@ -1276,19 +1281,15 @@ st_translate_program_common(struct st_context *st,
/**
* Translate a geometry program to create a new variant.
*/
-static struct st_gp_variant *
+bool
st_translate_geometry_program(struct st_context *st,
- struct st_geometry_program *stgp,
- const struct st_gp_variant_key *key)
+ struct st_geometry_program *stgp)
{
- struct pipe_context *pipe = st->pipe;
struct ureg_program *ureg;
- struct st_gp_variant *gpv;
- struct pipe_shader_state state;
ureg = ureg_create_with_screen(TGSI_PROCESSOR_GEOMETRY, st->pipe->screen);
if (ureg == NULL)
- return NULL;
+ return false;
ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType);
ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType);
@@ -1297,19 +1298,26 @@ st_translate_geometry_program(struct st_context *st,
ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations);
st_translate_program_common(st, &stgp->Base.Base, stgp->glsl_to_tgsi, ureg,
- TGSI_PROCESSOR_GEOMETRY, &state);
+ TGSI_PROCESSOR_GEOMETRY, &stgp->tgsi);
+ return true;
+}
+
+
+static struct st_gp_variant *
+st_create_gp_variant(struct st_context *st,
+ struct st_geometry_program *stgp,
+ const struct st_gp_variant_key *key)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct st_gp_variant *gpv;
gpv = CALLOC_STRUCT(st_gp_variant);
- if (!gpv) {
- ureg_free_tokens(state.tokens);
+ if (!gpv)
return NULL;
- }
/* fill in new variant */
- gpv->driver_shader = pipe->create_gs_state(pipe, &state);
+ gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi);
gpv->key = *key;
-
- ureg_free_tokens(state.tokens);
return gpv;
}
@@ -1333,7 +1341,7 @@ st_get_gp_variant(struct st_context *st,
if (!gpv) {
/* create new */
- gpv = st_translate_geometry_program(st, stgp, key);
+ gpv = st_create_gp_variant(st, stgp, key);
if (gpv) {
/* insert into list */
gpv->next = stgp->variants;
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index d4b5c1f427a..3a4c2604812 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -200,6 +200,7 @@ struct st_gp_variant
struct st_geometry_program
{
struct gl_geometry_program Base; /**< The Mesa geometry program */
+ struct pipe_shader_state tgsi;
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
struct st_gp_variant *variants;
@@ -442,6 +443,10 @@ extern bool
st_translate_fragment_program(struct st_context *st,
struct st_fragment_program *stfp);
+extern bool
+st_translate_geometry_program(struct st_context *st,
+ struct st_geometry_program *stgp);
+
extern void
st_print_current_vertex_program(void);