summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-06-20 12:46:36 +0800
committerChia-I Wu <[email protected]>2013-06-25 11:54:14 +0800
commitf0afedeb750d9f696242294c730827a28bdaac70 (patch)
tree1b3aaf271ce10f7fca03598a14eacf3bd2934f57 /src
parent4d789c76dce580d754fe146041d7a1118524a4ff (diff)
ilo: use multiple entry points for shader creation
Replace ilo_shader_state_create() by ilo_shader_create_vs() ilo_shader_create_gs() ilo_shader_create_fs() ilo_shader_create_cs() Rename ilo_shader_state_destroy() to ilo_shader_destroy(). The old ilo_shader_destroy() is renamed to ilo_shader_destroy_kernel().
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/ilo/ilo_shader.c84
-rw-r--r--src/gallium/drivers/ilo/ilo_shader.h22
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c16
-rw-r--r--src/gallium/drivers/ilo/shader/ilo_shader_gs.c2
-rw-r--r--src/gallium/drivers/ilo/shader/ilo_shader_internal.h2
-rw-r--r--src/gallium/drivers/ilo/shader/ilo_shader_vs.c2
6 files changed, 96 insertions, 32 deletions
diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c
index 765cc037806..0f22ebb4dd8 100644
--- a/src/gallium/drivers/ilo/ilo_shader.c
+++ b/src/gallium/drivers/ilo/ilo_shader.c
@@ -495,7 +495,7 @@ ilo_shader_info_parse_tokens(struct ilo_shader_info *info)
/**
* Create a shader state.
*/
-struct ilo_shader_state *
+static struct ilo_shader_state *
ilo_shader_state_create(const struct ilo_context *ilo,
int type, const void *templ)
{
@@ -533,7 +533,7 @@ ilo_shader_state_create(const struct ilo_context *ilo,
/* guess and compile now */
ilo_shader_variant_guess(&variant, &state->info, ilo);
if (!ilo_shader_state_use_variant(state, &variant)) {
- ilo_shader_state_destroy(state);
+ ilo_shader_destroy(state);
return NULL;
}
@@ -541,21 +541,6 @@ ilo_shader_state_create(const struct ilo_context *ilo,
}
/**
- * Destroy a shader state.
- */
-void
-ilo_shader_state_destroy(struct ilo_shader_state *state)
-{
- struct ilo_shader *sh, *next;
-
- LIST_FOR_EACH_ENTRY_SAFE(sh, next, &state->variants, list)
- ilo_shader_destroy(sh);
-
- FREE((struct tgsi_token *) state->info.tokens);
- FREE(state);
-}
-
-/**
* Add a compiled shader to the shader state.
*/
static void
@@ -598,7 +583,7 @@ ilo_shader_state_gc(struct ilo_shader_state *state)
/* remove from the tail as the most recently ones are at the head */
LIST_FOR_EACH_ENTRY_SAFE_REV(sh, next, &state->variants, list) {
ilo_shader_state_remove_shader(state, sh);
- ilo_shader_destroy(sh);
+ ilo_shader_destroy_kernel(sh);
if (state->total_size <= limit / 2)
break;
@@ -692,3 +677,66 @@ ilo_shader_state_use_variant(struct ilo_shader_state *state,
return true;
}
+
+struct ilo_shader_state *
+ilo_shader_create_vs(const struct ilo_dev_info *dev,
+ const struct pipe_shader_state *state,
+ const struct ilo_context *precompile)
+{
+ struct ilo_shader_state *shader;
+
+ shader = ilo_shader_state_create(precompile, PIPE_SHADER_VERTEX, state);
+
+ return shader;
+}
+
+struct ilo_shader_state *
+ilo_shader_create_gs(const struct ilo_dev_info *dev,
+ const struct pipe_shader_state *state,
+ const struct ilo_context *precompile)
+{
+ struct ilo_shader_state *shader;
+
+ shader = ilo_shader_state_create(precompile, PIPE_SHADER_GEOMETRY, state);
+
+ return shader;
+}
+
+struct ilo_shader_state *
+ilo_shader_create_fs(const struct ilo_dev_info *dev,
+ const struct pipe_shader_state *state,
+ const struct ilo_context *precompile)
+{
+ struct ilo_shader_state *shader;
+
+ shader = ilo_shader_state_create(precompile, PIPE_SHADER_FRAGMENT, state);
+
+ return shader;
+}
+
+struct ilo_shader_state *
+ilo_shader_create_cs(const struct ilo_dev_info *dev,
+ const struct pipe_compute_state *state,
+ const struct ilo_context *precompile)
+{
+ struct ilo_shader_state *shader;
+
+ shader = ilo_shader_state_create(precompile, PIPE_SHADER_COMPUTE, state);
+
+ return shader;
+}
+
+/**
+ * Destroy a shader state.
+ */
+void
+ilo_shader_destroy(struct ilo_shader_state *shader)
+{
+ struct ilo_shader *sh, *next;
+
+ LIST_FOR_EACH_ENTRY_SAFE(sh, next, &shader->variants, list)
+ ilo_shader_destroy_kernel(sh);
+
+ FREE((struct tgsi_token *) shader->info.tokens);
+ FREE(shader);
+}
diff --git a/src/gallium/drivers/ilo/ilo_shader.h b/src/gallium/drivers/ilo/ilo_shader.h
index f286a9f785f..5e457b91e11 100644
--- a/src/gallium/drivers/ilo/ilo_shader.h
+++ b/src/gallium/drivers/ilo/ilo_shader.h
@@ -55,10 +55,26 @@ ilo_shader_cache_upload(struct ilo_shader_cache *shc,
bool incremental);
struct ilo_shader_state *
-ilo_shader_state_create(const struct ilo_context *ilo,
- int type, const void *templ);
+ilo_shader_create_vs(const struct ilo_dev_info *dev,
+ const struct pipe_shader_state *state,
+ const struct ilo_context *precompile);
+
+struct ilo_shader_state *
+ilo_shader_create_gs(const struct ilo_dev_info *dev,
+ const struct pipe_shader_state *state,
+ const struct ilo_context *precompile);
+
+struct ilo_shader_state *
+ilo_shader_create_fs(const struct ilo_dev_info *dev,
+ const struct pipe_shader_state *state,
+ const struct ilo_context *precompile);
+
+struct ilo_shader_state *
+ilo_shader_create_cs(const struct ilo_dev_info *dev,
+ const struct pipe_compute_state *state,
+ const struct ilo_context *precompile);
void
-ilo_shader_state_destroy(struct ilo_shader_state *state);
+ilo_shader_destroy(struct ilo_shader_state *shader);
#endif /* ILO_SHADER_H */
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 80fa7414e82..69fe3833793 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -354,7 +354,7 @@ ilo_create_fs_state(struct pipe_context *pipe,
struct ilo_context *ilo = ilo_context(pipe);
struct ilo_shader_state *shader;
- shader = ilo_shader_state_create(ilo, PIPE_SHADER_FRAGMENT, state);
+ shader = ilo_shader_create_fs(ilo->dev, state, ilo);
assert(shader);
ilo_shader_cache_add(ilo->shader_cache, shader);
@@ -379,7 +379,7 @@ ilo_delete_fs_state(struct pipe_context *pipe, void *state)
struct ilo_shader_state *fs = (struct ilo_shader_state *) state;
ilo_shader_cache_remove(ilo->shader_cache, fs);
- ilo_shader_state_destroy(fs);
+ ilo_shader_destroy(fs);
}
static void *
@@ -389,7 +389,7 @@ ilo_create_vs_state(struct pipe_context *pipe,
struct ilo_context *ilo = ilo_context(pipe);
struct ilo_shader_state *shader;
- shader = ilo_shader_state_create(ilo, PIPE_SHADER_VERTEX, state);
+ shader = ilo_shader_create_vs(ilo->dev, state, ilo);
assert(shader);
ilo_shader_cache_add(ilo->shader_cache, shader);
@@ -414,7 +414,7 @@ ilo_delete_vs_state(struct pipe_context *pipe, void *state)
struct ilo_shader_state *vs = (struct ilo_shader_state *) state;
ilo_shader_cache_remove(ilo->shader_cache, vs);
- ilo_shader_state_destroy(vs);
+ ilo_shader_destroy(vs);
}
static void *
@@ -424,7 +424,7 @@ ilo_create_gs_state(struct pipe_context *pipe,
struct ilo_context *ilo = ilo_context(pipe);
struct ilo_shader_state *shader;
- shader = ilo_shader_state_create(ilo, PIPE_SHADER_GEOMETRY, state);
+ shader = ilo_shader_create_gs(ilo->dev, state, ilo);
assert(shader);
ilo_shader_cache_add(ilo->shader_cache, shader);
@@ -449,7 +449,7 @@ ilo_delete_gs_state(struct pipe_context *pipe, void *state)
struct ilo_shader_state *gs = (struct ilo_shader_state *) state;
ilo_shader_cache_remove(ilo->shader_cache, gs);
- ilo_shader_state_destroy(gs);
+ ilo_shader_destroy(gs);
}
static void *
@@ -992,7 +992,7 @@ ilo_create_compute_state(struct pipe_context *pipe,
struct ilo_context *ilo = ilo_context(pipe);
struct ilo_shader_state *shader;
- shader = ilo_shader_state_create(ilo, PIPE_SHADER_COMPUTE, state);
+ shader = ilo_shader_create_cs(ilo->dev, state, ilo);
assert(shader);
ilo_shader_cache_add(ilo->shader_cache, shader);
@@ -1017,7 +1017,7 @@ ilo_delete_compute_state(struct pipe_context *pipe, void *state)
struct ilo_shader_state *cs = (struct ilo_shader_state *) state;
ilo_shader_cache_remove(ilo->shader_cache, cs);
- ilo_shader_state_destroy(cs);
+ ilo_shader_destroy(cs);
}
static void
diff --git a/src/gallium/drivers/ilo/shader/ilo_shader_gs.c b/src/gallium/drivers/ilo/shader/ilo_shader_gs.c
index c4266f41b0c..79a6acb7a28 100644
--- a/src/gallium/drivers/ilo/shader/ilo_shader_gs.c
+++ b/src/gallium/drivers/ilo/shader/ilo_shader_gs.c
@@ -1398,7 +1398,7 @@ append_gs_to_vs(struct ilo_shader *vs, struct ilo_shader *gs, int num_verts)
vs->gs_offsets[num_verts - 1] = gs_offset;
vs->gs_start_grf = gs->in.start_grf;
- ilo_shader_destroy(gs);
+ ilo_shader_destroy_kernel(gs);
return true;
}
diff --git a/src/gallium/drivers/ilo/shader/ilo_shader_internal.h b/src/gallium/drivers/ilo/shader/ilo_shader_internal.h
index c444e564dab..a73b3393fe3 100644
--- a/src/gallium/drivers/ilo/shader/ilo_shader_internal.h
+++ b/src/gallium/drivers/ilo/shader/ilo_shader_internal.h
@@ -203,7 +203,7 @@ ilo_shader_compile_cs(const struct ilo_shader_state *state,
const struct ilo_shader_variant *variant);
static inline void
-ilo_shader_destroy(struct ilo_shader *sh)
+ilo_shader_destroy_kernel(struct ilo_shader *sh)
{
FREE(sh->kernel);
FREE(sh);
diff --git a/src/gallium/drivers/ilo/shader/ilo_shader_vs.c b/src/gallium/drivers/ilo/shader/ilo_shader_vs.c
index fcb9cb53e55..dc166d7cc48 100644
--- a/src/gallium/drivers/ilo/shader/ilo_shader_vs.c
+++ b/src/gallium/drivers/ilo/shader/ilo_shader_vs.c
@@ -1280,7 +1280,7 @@ ilo_shader_compile_vs(const struct ilo_shader_state *state,
if (!ilo_shader_compile_gs_passthrough(state, variant,
so_mapping, vcc.shader)) {
- ilo_shader_destroy(vcc.shader);
+ ilo_shader_destroy_kernel(vcc.shader);
vcc.shader = NULL;
}
}