/**
* 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)
{
/* 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;
}
}
/**
- * 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
/* 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;
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);
+}
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 */
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);
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 *
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);
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 *
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);
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 *
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);
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
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;
}
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);
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;
}
}