shader.compiler = compiler;
struct util_debug_callback debug = {}; // TODO: proper debug callback
- struct etna_shader_variant *v = etna_shader_variant(&shader, key, &debug);
+ struct etna_shader_variant *v = etna_shader_variant(&shader, &key, &debug);
if (!v) {
fprintf(stderr, "shader variant creation failed!\n");
return 1;
}
static bool
-etna_get_vs(struct etna_context *ctx, struct etna_shader_key key)
+etna_get_vs(struct etna_context *ctx, struct etna_shader_key* const key)
{
const struct etna_shader_variant *old = ctx->shader.vs;
}
static bool
-etna_get_fs(struct etna_context *ctx, struct etna_shader_key key)
+etna_get_fs(struct etna_context *ctx, struct etna_shader_key* const key)
{
const struct etna_shader_variant *old = ctx->shader.fs;
if (ctx->sampler[i]->compare_mode == PIPE_TEX_COMPARE_NONE)
continue;
- key.has_sample_tex_compare = 1;
- key.num_texture_states = ctx->num_fragment_sampler_views;
+ key->has_sample_tex_compare = 1;
+ key->num_texture_states = ctx->num_fragment_sampler_views;
- key.tex_swizzle[i].swizzle_r = ctx->sampler_view[i]->swizzle_r;
- key.tex_swizzle[i].swizzle_g = ctx->sampler_view[i]->swizzle_g;
- key.tex_swizzle[i].swizzle_b = ctx->sampler_view[i]->swizzle_b;
- key.tex_swizzle[i].swizzle_a = ctx->sampler_view[i]->swizzle_a;
+ key->tex_swizzle[i].swizzle_r = ctx->sampler_view[i]->swizzle_r;
+ key->tex_swizzle[i].swizzle_g = ctx->sampler_view[i]->swizzle_g;
+ key->tex_swizzle[i].swizzle_b = ctx->sampler_view[i]->swizzle_b;
+ key->tex_swizzle[i].swizzle_a = ctx->sampler_view[i]->swizzle_a;
- key.tex_compare_func[i] = ctx->sampler[i]->compare_func;
+ key->tex_compare_func[i] = ctx->sampler[i]->compare_func;
}
}
if (pfb->cbufs[0])
key.frag_rb_swap = !!translate_pe_format_rb_swap(pfb->cbufs[0]->format);
- if (!etna_get_vs(ctx, key) || !etna_get_fs(ctx, key)) {
+ if (!etna_get_vs(ctx, &key) || !etna_get_fs(ctx, &key)) {
BUG("compiled shaders are not okay");
return;
}
}
static struct etna_shader_variant *
-create_variant(struct etna_shader *shader, struct etna_shader_key key)
+create_variant(struct etna_shader *shader,
+ const struct etna_shader_key* const key)
{
struct etna_shader_variant *v = CALLOC_STRUCT(etna_shader_variant);
int ret;
return NULL;
v->shader = shader;
- v->key = key;
+ v->key = *key;
v->id = ++shader->variant_count;
if (etna_disk_cache_retrieve(shader->compiler, v))
}
struct etna_shader_variant *
-etna_shader_variant(struct etna_shader *shader, struct etna_shader_key key,
- struct util_debug_callback *debug)
+etna_shader_variant(struct etna_shader *shader,
+ const struct etna_shader_key* const key,
+ struct util_debug_callback *debug)
{
struct etna_shader_variant *v;
- assert(shader->specs->fragment_sampler_count <= ARRAY_SIZE(key.tex_swizzle));
+ assert(shader->specs->fragment_sampler_count <= ARRAY_SIZE(key->tex_swizzle));
for (v = shader->variants; v; v = v->next)
- if (etna_shader_key_equal(&key, &v->key))
+ if (etna_shader_key_equal(key, &v->key))
return v;
/* compile new variant if it doesn't exist already */
struct util_debug_callback debug = {};
static struct etna_shader_key key;
- etna_shader_variant(shader, key, &debug);
+ etna_shader_variant(shader, &key, &debug);
}
static void *
if (initial_variants_synchronous(ctx)) {
struct etna_shader_key key = {};
- etna_shader_variant(shader, key, &ctx->base.debug);
+ etna_shader_variant(shader, &key, &ctx->base.debug);
} else {
struct etna_screen *screen = ctx->screen;
util_queue_add_job(&screen->shader_compiler_queue, shader, &shader->ready,
};
static inline bool
-etna_shader_key_equal(struct etna_shader_key *a, struct etna_shader_key *b)
+etna_shader_key_equal(const struct etna_shader_key* const a,
+ const struct etna_shader_key* const b)
{
/* slow-path if we need to check tex_{swizzle,compare_func} */
if (unlikely(a->has_sample_tex_compare || b->has_sample_tex_compare))
etna_shader_update_vertex(struct etna_context *ctx);
struct etna_shader_variant *
-etna_shader_variant(struct etna_shader *shader, struct etna_shader_key key,
- struct util_debug_callback *debug);
+etna_shader_variant(struct etna_shader *shader,
+ const struct etna_shader_key* const key,
+ struct util_debug_callback *debug);
void
etna_shader_init(struct pipe_context *pctx);