panfrost: Move small compute functions to pan_context.c
So we can use pan_compute.c for just programs. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19363>
This commit is contained in:

committed by
Marge Bot

parent
2e1a69105d
commit
4860b0f59e
@@ -79,55 +79,10 @@ panfrost_delete_compute_state(struct pipe_context *pipe, void *cso)
|
||||
free(cso);
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_set_global_binding(struct pipe_context *pctx,
|
||||
unsigned first, unsigned count,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
{
|
||||
if (!resources)
|
||||
return;
|
||||
|
||||
struct panfrost_context *ctx = pan_context(pctx);
|
||||
struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
|
||||
|
||||
for (unsigned i = first; i < first + count; ++i) {
|
||||
struct panfrost_resource *rsrc = pan_resource(resources[i]);
|
||||
panfrost_batch_write_rsrc(batch, rsrc, PIPE_SHADER_COMPUTE);
|
||||
|
||||
util_range_add(&rsrc->base, &rsrc->valid_buffer_range,
|
||||
0, rsrc->base.width0);
|
||||
|
||||
/* The handle points to uint32_t, but space is allocated for 64
|
||||
* bits. We need to respect the offset passed in. This interface
|
||||
* is so bad.
|
||||
*/
|
||||
mali_ptr addr = 0;
|
||||
static_assert(sizeof(addr) == 8, "size out of sync");
|
||||
|
||||
memcpy(&addr, handles[i], sizeof(addr));
|
||||
addr += rsrc->image.data.bo->ptr.gpu;
|
||||
|
||||
memcpy(handles[i], &addr, sizeof(addr));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_memory_barrier(struct pipe_context *pctx, unsigned flags)
|
||||
{
|
||||
/* TODO: Be smart and only flush the minimum needed, maybe emitting a
|
||||
* cache flush job if that would help */
|
||||
panfrost_flush_all_batches(pan_context(pctx), "Memory barrier");
|
||||
}
|
||||
|
||||
void
|
||||
panfrost_compute_context_init(struct pipe_context *pctx)
|
||||
{
|
||||
pctx->create_compute_state = panfrost_create_compute_state;
|
||||
pctx->bind_compute_state = panfrost_bind_compute_state;
|
||||
pctx->delete_compute_state = panfrost_delete_compute_state;
|
||||
|
||||
pctx->set_global_binding = panfrost_set_global_binding;
|
||||
|
||||
pctx->memory_barrier = panfrost_memory_barrier;
|
||||
}
|
||||
|
@@ -1084,6 +1084,47 @@ panfrost_set_stream_output_targets(struct pipe_context *pctx,
|
||||
ctx->dirty |= PAN_DIRTY_SO;
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_set_global_binding(struct pipe_context *pctx,
|
||||
unsigned first, unsigned count,
|
||||
struct pipe_resource **resources,
|
||||
uint32_t **handles)
|
||||
{
|
||||
if (!resources)
|
||||
return;
|
||||
|
||||
struct panfrost_context *ctx = pan_context(pctx);
|
||||
struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
|
||||
|
||||
for (unsigned i = first; i < first + count; ++i) {
|
||||
struct panfrost_resource *rsrc = pan_resource(resources[i]);
|
||||
panfrost_batch_write_rsrc(batch, rsrc, PIPE_SHADER_COMPUTE);
|
||||
|
||||
util_range_add(&rsrc->base, &rsrc->valid_buffer_range,
|
||||
0, rsrc->base.width0);
|
||||
|
||||
/* The handle points to uint32_t, but space is allocated for 64
|
||||
* bits. We need to respect the offset passed in. This interface
|
||||
* is so bad.
|
||||
*/
|
||||
mali_ptr addr = 0;
|
||||
static_assert(sizeof(addr) == 8, "size out of sync");
|
||||
|
||||
memcpy(&addr, handles[i], sizeof(addr));
|
||||
addr += rsrc->image.data.bo->ptr.gpu;
|
||||
|
||||
memcpy(handles[i], &addr, sizeof(addr));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_memory_barrier(struct pipe_context *pctx, unsigned flags)
|
||||
{
|
||||
/* TODO: Be smart and only flush the minimum needed, maybe emitting a
|
||||
* cache flush job if that would help */
|
||||
panfrost_flush_all_batches(pan_context(pctx), "Memory barrier");
|
||||
}
|
||||
|
||||
struct pipe_context *
|
||||
panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
|
||||
{
|
||||
@@ -1158,6 +1199,9 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
|
||||
|
||||
gallium->set_blend_color = panfrost_set_blend_color;
|
||||
|
||||
gallium->set_global_binding = panfrost_set_global_binding;
|
||||
gallium->memory_barrier = panfrost_memory_barrier;
|
||||
|
||||
pan_screen(screen)->vtbl.context_init(gallium);
|
||||
|
||||
panfrost_resource_context_init(gallium);
|
||||
|
Reference in New Issue
Block a user