}
}
-static void
-panfrost_emit_compute_shader(struct panfrost_context *ctx,
- enum pipe_shader_type st,
- struct mali_shader_meta *meta)
-{
- const struct panfrost_device *dev = pan_device(ctx->base.screen);
- struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, st);
-
- memset(meta, 0, sizeof(*meta));
- memcpy(&meta->shader, &ss->shader, sizeof(ss->shader));
- memcpy(&meta->midgard_props, &ss->properties, sizeof(ss->properties));
-
- if (dev->quirks & IS_BIFROST)
- memcpy(&meta->bifrost_preload, &ss->preload, sizeof(ss->preload));
-}
-
static unsigned
translate_tex_wrap(enum pipe_tex_wrap w)
{
}
}
-void
-panfrost_emit_shader_meta(struct panfrost_batch *batch,
- enum pipe_shader_type st,
- struct mali_vertex_tiler_postfix *postfix)
+mali_ptr
+panfrost_emit_compute_shader_meta(struct panfrost_batch *batch, enum pipe_shader_type stage)
{
- struct panfrost_context *ctx = batch->ctx;
- struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, st);
+ struct panfrost_shader_state *ss = panfrost_get_shader_state(batch->ctx, stage);
- if (!ss) {
- postfix->shader = 0;
- return;
- }
-
- struct mali_shader_meta meta;
-
- /* Add the shader BO to the batch. */
panfrost_batch_add_bo(batch, ss->bo,
PAN_BO_ACCESS_PRIVATE |
PAN_BO_ACCESS_READ |
- panfrost_bo_access_for_stage(st));
+ PAN_BO_ACCESS_VERTEX_TILER);
- mali_ptr shader_ptr;
+ panfrost_batch_add_bo(batch, pan_resource(ss->upload.rsrc)->bo,
+ PAN_BO_ACCESS_PRIVATE |
+ PAN_BO_ACCESS_READ |
+ PAN_BO_ACCESS_VERTEX_TILER);
- if (st == PIPE_SHADER_FRAGMENT) {
- struct panfrost_device *dev = pan_device(ctx->base.screen);
- unsigned rt_count = MAX2(ctx->pipe_framebuffer.nr_cbufs, 1);
- size_t desc_size = sizeof(meta);
- void *rts = NULL;
- struct panfrost_transfer xfer;
- unsigned rt_size;
+ return pan_resource(ss->upload.rsrc)->bo->gpu + ss->upload.offset;
+}
- if (dev->quirks & MIDGARD_SFBD)
- rt_size = 0;
- else if (dev->quirks & IS_BIFROST)
- rt_size = sizeof(struct bifrost_blend_rt);
- else
- rt_size = sizeof(struct midgard_blend_rt);
+mali_ptr
+panfrost_emit_frag_shader_meta(struct panfrost_batch *batch)
+{
+ struct panfrost_context *ctx = batch->ctx;
+ struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
+ struct mali_shader_meta meta;
- desc_size += rt_size * rt_count;
+ /* Add the shader BO to the batch. */
+ panfrost_batch_add_bo(batch, ss->bo,
+ PAN_BO_ACCESS_PRIVATE |
+ PAN_BO_ACCESS_READ |
+ PAN_BO_ACCESS_FRAGMENT);
- if (rt_size)
- rts = rzalloc_size(ctx, rt_size * rt_count);
+ struct panfrost_device *dev = pan_device(ctx->base.screen);
+ unsigned rt_count = MAX2(ctx->pipe_framebuffer.nr_cbufs, 1);
+ size_t desc_size = sizeof(meta);
+ void *rts = NULL;
+ struct panfrost_transfer xfer;
+ unsigned rt_size;
+
+ if (dev->quirks & MIDGARD_SFBD)
+ rt_size = 0;
+ else if (dev->quirks & IS_BIFROST)
+ rt_size = sizeof(struct bifrost_blend_rt);
+ else
+ rt_size = sizeof(struct midgard_blend_rt);
- struct panfrost_blend_final blend[PIPE_MAX_COLOR_BUFS];
+ desc_size += rt_size * rt_count;
- for (unsigned c = 0; c < ctx->pipe_framebuffer.nr_cbufs; ++c)
- blend[c] = panfrost_get_blend_for_context(ctx, c);
+ if (rt_size)
+ rts = rzalloc_size(ctx, rt_size * rt_count);
- panfrost_emit_frag_shader(ctx, &meta, blend);
+ struct panfrost_blend_final blend[PIPE_MAX_COLOR_BUFS];
- if (!(dev->quirks & MIDGARD_SFBD))
- panfrost_emit_blend(batch, rts, blend);
- else
- batch->draws |= PIPE_CLEAR_COLOR0;
+ for (unsigned c = 0; c < ctx->pipe_framebuffer.nr_cbufs; ++c)
+ blend[c] = panfrost_get_blend_for_context(ctx, c);
- xfer = panfrost_pool_alloc_aligned(&batch->pool, desc_size, sizeof(meta));
+ panfrost_emit_frag_shader(ctx, &meta, blend);
- memcpy(xfer.cpu, &meta, sizeof(meta));
- memcpy(xfer.cpu + sizeof(meta), rts, rt_size * rt_count);
+ if (!(dev->quirks & MIDGARD_SFBD))
+ panfrost_emit_blend(batch, rts, blend);
+ else
+ batch->draws |= PIPE_CLEAR_COLOR0;
- if (rt_size)
- ralloc_free(rts);
+ xfer = panfrost_pool_alloc_aligned(&batch->pool, desc_size, sizeof(meta));
- shader_ptr = xfer.gpu;
- } else {
- panfrost_emit_compute_shader(ctx, st, &meta);
+ memcpy(xfer.cpu, &meta, sizeof(meta));
+ memcpy(xfer.cpu + sizeof(meta), rts, rt_size * rt_count);
- shader_ptr = panfrost_pool_upload(&batch->pool, &meta,
- sizeof(meta));
- }
+ if (rt_size)
+ ralloc_free(rts);
- postfix->shader = shader_ptr;
+ return xfer.gpu;
}
void
ctx->instance_count,
&vertex_postfix, &tiler_postfix,
&primitive_size);
- panfrost_emit_shader_meta(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
- panfrost_emit_shader_meta(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
panfrost_emit_const_buf(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
panfrost_emit_viewport(batch, &tiler_postfix);
+ vertex_postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);
+ tiler_postfix.shader = panfrost_emit_frag_shader_meta(batch);
+
panfrost_vt_update_primitive_size(ctx, &tiler_prefix, &primitive_size);
/* Fire off the draw itself */