2 * Copyright (C) 2019 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
28 #include "pan_context.h"
29 #include "util/u_memory.h"
32 panfrost_create_compute_state(
33 struct pipe_context
*pctx
,
34 const struct pipe_compute_state
*cso
)
36 return mem_dup(cso
, sizeof(*cso
));
40 panfrost_bind_compute_state(struct pipe_context
*pipe
, void *cso
)
42 struct pipe_compute_state
*state
= (struct pipe_compute_state
*) cso
;
44 printf("Binding compute %p\n", state
);
49 panfrost_delete_compute_state(struct pipe_context
*pipe
, void *cso
)
54 /* Launch grid is the compute equivalent of draw_vbo, so in this routine, we
55 * construct the COMPUTE job and some of its payload.
59 panfrost_launch_grid(struct pipe_context
*pipe
,
60 const struct pipe_grid_info
*info
)
62 struct panfrost_context
*ctx
= pan_context(pipe
);
64 struct mali_job_descriptor_header job
= {
65 .job_type
= JOB_TYPE_COMPUTE
,
66 .job_descriptor_size
= 1,
71 struct midgard_payload_vertex_tiler
*payload
= &ctx
->payloads
[PIPE_SHADER_COMPUTE
];
73 struct panfrost_transfer transfer
= panfrost_allocate_transient(ctx
, sizeof(job
) + sizeof(*payload
));
74 memcpy(transfer
.cpu
, &job
, sizeof(job
));
75 memcpy(transfer
.cpu
+ sizeof(job
), payload
, sizeof(*payload
));
77 /* TODO: Do we want a special compute-only batch? */
78 struct panfrost_job
*batch
= panfrost_get_job_for_fbo(ctx
);
81 panfrost_scoreboard_queue_compute_job(batch
, transfer
);
85 panfrost_compute_context_init(struct pipe_context
*pctx
)
87 pctx
->create_compute_state
= panfrost_create_compute_state
;
88 pctx
->bind_compute_state
= panfrost_bind_compute_state
;
89 pctx
->delete_compute_state
= panfrost_delete_compute_state
;
91 pctx
->launch_grid
= panfrost_launch_grid
;