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().
This commit is contained in:
@@ -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,28 +533,13 @@ 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;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user