struct tgsi_parse_context parse;
struct tgsi_token * tokens;
struct si_pipe_shader *shader;
+ struct si_shader_key key;
unsigned type; /* TGSI_PROCESSOR_* specifies the type of shader. */
unsigned ninput_emitted;
/* struct list_head inputs; */
if (cbuf >= 0 && cbuf < 8) {
struct r600_context *rctx = si_shader_ctx->rctx;
- compressed = (rctx->export_16bpc >> cbuf) & 0x1;
+ compressed = (si_shader_ctx->key.export_16bpc >> cbuf) & 0x1;
}
}
int si_pipe_shader_create(
struct pipe_context *ctx,
- struct si_pipe_shader *shader)
+ struct si_pipe_shader *shader,
+ struct si_shader_key key)
{
struct r600_context *rctx = (struct r600_context*)ctx;
struct si_pipe_shader_selector *sel = shader->selector;
si_shader_ctx.tokens = sel->tokens;
tgsi_parse_init(&si_shader_ctx.parse, si_shader_ctx.tokens);
si_shader_ctx.shader = shader;
+ si_shader_ctx.key = key;
si_shader_ctx.type = si_shader_ctx.parse.FullHeader.Processor.Processor;
si_shader_ctx.rctx = rctx;
unsigned nr_cbufs;
};
+struct si_shader_key {
+ unsigned export_16bpc:8;
+ unsigned nr_cbufs:4;
+};
+
struct si_pipe_shader {
struct si_pipe_shader_selector *selector;
struct si_pipe_shader *next_variant;
unsigned spi_ps_input_ena;
unsigned sprite_coord_enable;
unsigned so_strides[4];
- unsigned key;
+ struct si_shader_key key;
};
/* radeonsi_shader.c */
-int si_pipe_shader_create(struct pipe_context *ctx, struct si_pipe_shader *shader);
+int si_pipe_shader_create(struct pipe_context *ctx, struct si_pipe_shader *shader,
+ struct si_shader_key key);
void si_pipe_shader_destroy(struct pipe_context *ctx, struct si_pipe_shader *shader);
#endif
*/
/* Compute the key for the hw shader variant */
-static INLINE unsigned si_shader_selector_key(struct pipe_context *ctx,
- struct si_pipe_shader_selector *sel)
+static INLINE struct si_shader_key si_shader_selector_key(struct pipe_context *ctx,
+ struct si_pipe_shader_selector *sel)
{
struct r600_context *rctx = (struct r600_context *)ctx;
- unsigned key = 0;
+ struct si_shader_key key;
+ memset(&key, 0, sizeof(key));
if (sel->type == PIPE_SHADER_FRAGMENT) {
if (sel->fs_write_all)
- key |= rctx->framebuffer.nr_cbufs;
- key |= rctx->export_16bpc << 4;
+ key.nr_cbufs = rctx->framebuffer.nr_cbufs;
+ key.export_16bpc = rctx->export_16bpc;
/*if (rctx->queued.named.rasterizer)
- key |= rctx->queued.named.rasterizer->flatshade << 12;*/
- /*key |== rctx->two_side << 13;*/
+ key.flatshade = rctx->queued.named.rasterizer->flatshade;*/
+ /*key.color_two_side |== rctx->two_side;*/
}
return key;
struct si_pipe_shader_selector *sel,
unsigned *dirty)
{
- unsigned key;
+ struct si_shader_key key;
struct si_pipe_shader * shader = NULL;
int r;
* This path is also used for most shaders that don't need multiple
* variants, it will cost just a computation of the key and this
* test. */
- if (likely(sel->current && sel->current->key == key)) {
+ if (likely(sel->current && memcmp(&sel->current->key, &key, sizeof(key)) == 0)) {
return 0;
}
if (sel->num_shaders > 1) {
struct si_pipe_shader *p = sel->current, *c = p->next_variant;
- while (c && c->key != key) {
+ while (c && memcmp(&c->key, &key, sizeof(key)) != 0) {
p = c;
c = c->next_variant;
}
shader = CALLOC(1, sizeof(struct si_pipe_shader));
shader->selector = sel;
- r = si_pipe_shader_create(ctx, shader);
+ r = si_pipe_shader_create(ctx, shader, key);
if (unlikely(r)) {
- R600_ERR("Failed to build shader variant (type=%u, key=%u) %d\n",
- sel->type, key, r);
+ R600_ERR("Failed to build shader variant (type=%u) %d\n",
+ sel->type, r);
sel->current = NULL;
return r;
}