diff options
author | Chia-I Wu <[email protected]> | 2013-06-20 12:46:36 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2013-06-25 11:54:14 +0800 |
commit | f0afedeb750d9f696242294c730827a28bdaac70 (patch) | |
tree | 1b3aaf271ce10f7fca03598a14eacf3bd2934f57 /src/gallium/drivers/ilo/ilo_shader.c | |
parent | 4d789c76dce580d754fe146041d7a1118524a4ff (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/gallium/drivers/ilo/ilo_shader.c')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_shader.c | 84 |
1 files changed, 66 insertions, 18 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); +} |