memcpy(cpu + lima_reload_varying_offset, reload_varying,
sizeof(reload_varying));
- lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_READ);
pipe_resource_reference(&pres, NULL);
PLBU_CMD_BEGIN(&ctx->plbu_cmd_head, 20);
lima_generate_pp_stream(ctx, bound.minx, bound.miny, tiled_w, tiled_h);
- lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_READ);
pipe_resource_reference(&pres, NULL);
}
lima_generate_pp_stream(ctx, 0, 0, fb->tiled_w, fb->tiled_h);
}
- lima_submit_add_bo(ctx->pp_submit, s->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, s->bo, LIMA_SUBMIT_BO_READ);
}
static bool
if (fb->base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0) &&
!(ctx->resolve & PIPE_CLEAR_COLOR0)) {
struct lima_resource *res = lima_resource(fb->base.cbufs[0]->texture);
- lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_WRITE);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
}
/* add to submit when the buffer is dirty and resolve is clear (not added before) */
if (fb->base.zsbuf && (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) &&
!(ctx->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
struct lima_resource *res = lima_resource(fb->base.zsbuf->texture);
- lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_WRITE);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
}
ctx->resolve |= buffers;
static void
lima_update_submit_bo(struct lima_context *ctx)
{
- lima_submit_add_bo(ctx->gp_submit, ctx->plb_gp_stream, LIMA_SUBMIT_BO_READ);
- lima_submit_add_bo(ctx->gp_submit, ctx->plb[ctx->plb_index], LIMA_SUBMIT_BO_WRITE);
- lima_submit_add_bo(ctx->gp_submit, ctx->gp_tile_heap[ctx->plb_index], LIMA_SUBMIT_BO_WRITE);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, ctx->plb_gp_stream,
+ LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, ctx->plb[ctx->plb_index],
+ LIMA_SUBMIT_BO_WRITE);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, ctx->gp_tile_heap[ctx->plb_index],
+ LIMA_SUBMIT_BO_WRITE);
lima_dump_command_stream_print(
ctx->plb_gp_stream->map + ctx->plb_index * ctx->plb_gp_size,
ctx->plb_gp_size, false, "gp plb stream at va %x\n",
ctx->plb_gp_stream->va + ctx->plb_index * ctx->plb_gp_size);
- lima_submit_add_bo(ctx->pp_submit, ctx->plb[ctx->plb_index], LIMA_SUBMIT_BO_READ);
- lima_submit_add_bo(ctx->pp_submit, ctx->gp_tile_heap[ctx->plb_index], LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, ctx->plb[ctx->plb_index],
+ LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, ctx->gp_tile_heap[ctx->plb_index],
+ LIMA_SUBMIT_BO_READ);
struct lima_screen *screen = lima_screen(ctx->base.screen);
- lima_submit_add_bo(ctx->pp_submit, screen->pp_buffer, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, screen->pp_buffer, LIMA_SUBMIT_BO_READ);
}
static void
struct pipe_vertex_buffer *pvb = vb->vb + pve->vertex_buffer_index;
struct lima_resource *res = lima_resource(pvb->buffer.resource);
- lima_submit_add_bo(ctx->gp_submit, res->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, res->bo, LIMA_SUBMIT_BO_READ);
unsigned start = info->index_size ? (ctx->min_index + info->index_bias) : info->start;
attribute[n++] = res->bo->va + pvb->buffer_offset + pve->src_offset
*/
ctx->gp_output = lima_bo_create(screen, gp_output_size, 0);
assert(ctx->gp_output);
- lima_submit_add_bo(ctx->gp_submit, ctx->gp_output, LIMA_SUBMIT_BO_WRITE);
- lima_submit_add_bo(ctx->pp_submit, ctx->gp_output, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, ctx->gp_output, LIMA_SUBMIT_BO_WRITE);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, ctx->gp_output, LIMA_SUBMIT_BO_READ);
for (int i = 0; i < vs->num_outputs; i++) {
struct lima_varying_info *v = vs->varying + i;
ctx->index_offset = 0;
}
- lima_submit_add_bo(ctx->gp_submit, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
- lima_submit_add_bo(ctx->pp_submit, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
lima_draw_vbo_update(pctx, info);
if (indexbuf)
ctx->fs->bo->map, ctx->fs->shader_size, false,
"add fs at va %x\n", ctx->fs->bo->va);
- lima_submit_add_bo(ctx->gp_submit, ctx->vs->bo, LIMA_SUBMIT_BO_READ);
- lima_submit_add_bo(ctx->pp_submit, ctx->fs->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_GP, ctx->vs->bo, LIMA_SUBMIT_BO_READ);
+ lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, ctx->fs->bo, LIMA_SUBMIT_BO_READ);
if (info->index_size)
lima_draw_vbo_indexed(pctx, info);
lima_dump_command_stream_print(
&gp_frame, sizeof(gp_frame), false, "add gp frame\n");
- if (!lima_submit_start(ctx->gp_submit, &gp_frame, sizeof(gp_frame)))
+ if (!lima_submit_start(ctx->submit, LIMA_PIPE_GP, &gp_frame, sizeof(gp_frame)))
fprintf(stderr, "gp submit error\n");
if (lima_dump_command_stream) {
- if (lima_submit_wait(ctx->gp_submit, PIPE_TIMEOUT_INFINITE)) {
+ if (lima_submit_wait(ctx->submit, LIMA_PIPE_GP, PIPE_TIMEOUT_INFINITE)) {
if (ctx->gp_output) {
float *pos = lima_bo_map(ctx->gp_output);
lima_dump_command_stream_print(
lima_dump_command_stream_print(
&pp_frame, sizeof(pp_frame), false, "add pp frame\n");
- if (!lima_submit_start(ctx->pp_submit, &pp_frame, sizeof(pp_frame)))
+ if (!lima_submit_start(ctx->submit, LIMA_PIPE_PP, &pp_frame, sizeof(pp_frame)))
fprintf(stderr, "pp submit error\n");
}
else {
lima_dump_command_stream_print(
&pp_frame, sizeof(pp_frame), false, "add pp frame\n");
- if (!lima_submit_start(ctx->pp_submit, &pp_frame, sizeof(pp_frame)))
+ if (!lima_submit_start(ctx->submit, LIMA_PIPE_PP, &pp_frame, sizeof(pp_frame)))
fprintf(stderr, "pp submit error\n");
}
if (lima_dump_command_stream) {
- if (!lima_submit_wait(ctx->pp_submit, PIPE_TIMEOUT_INFINITE)) {
+ if (!lima_submit_wait(ctx->submit, LIMA_PIPE_PP, PIPE_TIMEOUT_INFINITE)) {
fprintf(stderr, "pp wait error\n");
exit(1);
}
struct lima_submit {
int fd;
- uint32_t pipe;
struct lima_context *ctx;
- struct util_dynarray gem_bos;
- struct util_dynarray bos;
+ struct util_dynarray gem_bos[2];
+ struct util_dynarray bos[2];
};
#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
-struct lima_submit *lima_submit_create(struct lima_context *ctx, uint32_t pipe)
+struct lima_submit *lima_submit_create(struct lima_context *ctx)
{
struct lima_submit *s;
return NULL;
s->fd = lima_screen(ctx->base.screen)->fd;
- s->pipe = pipe;
s->ctx = ctx;
- util_dynarray_init(&s->gem_bos, s);
- util_dynarray_init(&s->bos, s);
+ for (int i = 0; i < 2; i++) {
+ util_dynarray_init(s->gem_bos + i, s);
+ util_dynarray_init(s->bos + i, s);
+ }
return s;
}
}
-bool lima_submit_add_bo(struct lima_submit *submit, struct lima_bo *bo, uint32_t flags)
+bool lima_submit_add_bo(struct lima_submit *submit, int pipe,
+ struct lima_bo *bo, uint32_t flags)
{
- util_dynarray_foreach(&submit->gem_bos, struct drm_lima_gem_submit_bo, gem_bo) {
+ util_dynarray_foreach(submit->gem_bos + pipe, struct drm_lima_gem_submit_bo, gem_bo) {
if (bo->handle == gem_bo->handle) {
gem_bo->flags |= flags;
return true;
}
struct drm_lima_gem_submit_bo *submit_bo =
- util_dynarray_grow(&submit->gem_bos, struct drm_lima_gem_submit_bo, 1);
+ util_dynarray_grow(submit->gem_bos + pipe, struct drm_lima_gem_submit_bo, 1);
submit_bo->handle = bo->handle;
submit_bo->flags = flags;
- struct lima_bo **jbo = util_dynarray_grow(&submit->bos, struct lima_bo *, 1);
+ struct lima_bo **jbo = util_dynarray_grow(submit->bos + pipe, struct lima_bo *, 1);
*jbo = bo;
/* prevent bo from being freed when submit start */
return true;
}
-bool lima_submit_start(struct lima_submit *submit, void *frame, uint32_t size)
+bool lima_submit_start(struct lima_submit *submit, int pipe, void *frame, uint32_t size)
{
struct lima_context *ctx = submit->ctx;
struct drm_lima_gem_submit req = {
.ctx = ctx->id,
- .pipe = submit->pipe,
- .nr_bos = submit->gem_bos.size / sizeof(struct drm_lima_gem_submit_bo),
- .bos = VOID2U64(util_dynarray_begin(&submit->gem_bos)),
+ .pipe = pipe,
+ .nr_bos = submit->gem_bos[pipe].size / sizeof(struct drm_lima_gem_submit_bo),
+ .bos = VOID2U64(util_dynarray_begin(submit->gem_bos + pipe)),
.frame = VOID2U64(frame),
.frame_size = size,
- .out_sync = ctx->out_sync[submit->pipe],
+ .out_sync = ctx->out_sync[pipe],
};
if (ctx->in_sync_fd >= 0) {
- int err = drmSyncobjImportSyncFile(submit->fd, ctx->in_sync[submit->pipe],
+ int err = drmSyncobjImportSyncFile(submit->fd, ctx->in_sync[pipe],
ctx->in_sync_fd);
if (err)
return false;
- req.in_sync[0] = ctx->in_sync[submit->pipe];
+ req.in_sync[0] = ctx->in_sync[pipe];
close(ctx->in_sync_fd);
ctx->in_sync_fd = -1;
}
bool ret = drmIoctl(submit->fd, DRM_IOCTL_LIMA_GEM_SUBMIT, &req) == 0;
- util_dynarray_foreach(&submit->bos, struct lima_bo *, bo) {
+ util_dynarray_foreach(submit->bos + pipe, struct lima_bo *, bo) {
lima_bo_unreference(*bo);
}
- util_dynarray_clear(&submit->gem_bos);
- util_dynarray_clear(&submit->bos);
+ util_dynarray_clear(submit->gem_bos + pipe);
+ util_dynarray_clear(submit->bos + pipe);
return ret;
}
-bool lima_submit_wait(struct lima_submit *submit, uint64_t timeout_ns)
+bool lima_submit_wait(struct lima_submit *submit, int pipe, uint64_t timeout_ns)
{
int64_t abs_timeout = os_time_get_absolute_timeout(timeout_ns);
if (abs_timeout == OS_TIMEOUT_INFINITE)
abs_timeout = INT64_MAX;
struct lima_context *ctx = submit->ctx;
- return !drmSyncobjWait(submit->fd, ctx->out_sync + submit->pipe, 1, abs_timeout, 0, NULL);
+ return !drmSyncobjWait(submit->fd, ctx->out_sync + pipe, 1, abs_timeout, 0, NULL);
}
bool lima_submit_has_bo(struct lima_submit *submit, struct lima_bo *bo, bool all)
{
- util_dynarray_foreach(&submit->gem_bos, struct drm_lima_gem_submit_bo, gem_bo) {
- if (bo->handle == gem_bo->handle) {
- if (all)
- return true;
- else
- return gem_bo->flags & LIMA_SUBMIT_BO_WRITE;
+ for (int i = 0; i < 2; i++) {
+ util_dynarray_foreach(submit->gem_bos + i, struct drm_lima_gem_submit_bo, gem_bo) {
+ if (bo->handle == gem_bo->handle) {
+ if (all || gem_bo->flags & LIMA_SUBMIT_BO_WRITE)
+ return true;
+ else
+ break;
+ }
}
}