diff options
author | Boris Brezillon <boris.brezillon@collabora.com> | 2019-09-01 10:30:39 +0200 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@collabora.com> | 2019-09-13 16:25:06 +0200 |
commit | aa851a62b964c1c73d699739ce07d6ba773605d7 (patch) | |
tree | bf960d4b95f9384a1109beba9d6d30bf02f2d02b | |
parent | 07a68835a153c808a530a277396bd9f212e2bc06 (diff) |
panfrost: Pass a batch to functions emitting FB descs
So we can emit such jobs to a batch that's not currently bound to the
context.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 36 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.h | 10 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_drm.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_fragment.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_mfbd.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_sfbd.c | 13 |
6 files changed, 44 insertions, 53 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 3f036ce4b5f..f3950b05391 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -54,14 +54,12 @@ /* Framebuffer descriptor */ static struct midgard_tiler_descriptor -panfrost_emit_midg_tiler( - struct panfrost_context *ctx, - unsigned width, - unsigned height, - unsigned vertex_count) +panfrost_emit_midg_tiler(struct panfrost_batch *batch, unsigned vertex_count) { + struct panfrost_context *ctx = batch->ctx; struct midgard_tiler_descriptor t = {}; - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); + unsigned height = batch->key.height; + unsigned width = batch->key.width; t.hierarchy_mask = panfrost_choose_hierarchy_mask(width, height, vertex_count); @@ -104,10 +102,11 @@ panfrost_emit_midg_tiler( } struct mali_single_framebuffer -panfrost_emit_sfbd(struct panfrost_context *ctx, unsigned vertex_count) +panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count) { - unsigned width = ctx->pipe_framebuffer.width; - unsigned height = ctx->pipe_framebuffer.height; + struct panfrost_context *ctx = batch->ctx; + unsigned width = batch->key.width; + unsigned height = batch->key.height; struct mali_single_framebuffer framebuffer = { .width = MALI_POSITIVE(width), @@ -116,18 +115,18 @@ panfrost_emit_sfbd(struct panfrost_context *ctx, unsigned vertex_count) .format = 0x30000000, .clear_flags = 0x1000, .unknown_address_0 = ctx->scratchpad->gpu, - .tiler = panfrost_emit_midg_tiler(ctx, - width, height, vertex_count), + .tiler = panfrost_emit_midg_tiler(batch, vertex_count), }; return framebuffer; } struct bifrost_framebuffer -panfrost_emit_mfbd(struct panfrost_context *ctx, unsigned vertex_count) +panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count) { - unsigned width = ctx->pipe_framebuffer.width; - unsigned height = ctx->pipe_framebuffer.height; + struct panfrost_context *ctx = batch->ctx; + unsigned width = batch->key.width; + unsigned height = batch->key.height; struct bifrost_framebuffer framebuffer = { .unk0 = 0x1e5, /* 1e4 if no spill */ @@ -138,14 +137,13 @@ panfrost_emit_mfbd(struct panfrost_context *ctx, unsigned vertex_count) .unk1 = 0x1080, - .rt_count_1 = MALI_POSITIVE(ctx->pipe_framebuffer.nr_cbufs), + .rt_count_1 = MALI_POSITIVE(batch->key.nr_cbufs), .rt_count_2 = 4, .unknown2 = 0x1f, .scratchpad = ctx->scratchpad->gpu, - .tiler = panfrost_emit_midg_tiler(ctx, - width, height, vertex_count) + .tiler = panfrost_emit_midg_tiler(batch, vertex_count) }; return framebuffer; @@ -168,7 +166,7 @@ static mali_ptr panfrost_attach_vt_mfbd(struct panfrost_context *ctx) { struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - struct bifrost_framebuffer mfbd = panfrost_emit_mfbd(ctx, ~0); + struct bifrost_framebuffer mfbd = panfrost_emit_mfbd(batch, ~0); return panfrost_upload_transient(batch, &mfbd, sizeof(mfbd)) | MALI_MFBD; } @@ -177,7 +175,7 @@ static mali_ptr panfrost_attach_vt_sfbd(struct panfrost_context *ctx) { struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - struct mali_single_framebuffer sfbd = panfrost_emit_sfbd(ctx, ~0); + struct mali_single_framebuffer sfbd = panfrost_emit_sfbd(batch, ~0); return panfrost_upload_transient(batch, &sfbd, sizeof(sfbd)) | MALI_SFBD; } diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 02552ed23de..8400b7541e9 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -315,17 +315,17 @@ panfrost_flush( struct pipe_fence_handle **fence, unsigned flags); -mali_ptr panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws); -mali_ptr panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws); +mali_ptr panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws); +mali_ptr panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws); struct bifrost_framebuffer -panfrost_emit_mfbd(struct panfrost_context *ctx, unsigned vertex_count); +panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count); struct mali_single_framebuffer -panfrost_emit_sfbd(struct panfrost_context *ctx, unsigned vertex_count); +panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count); mali_ptr -panfrost_fragment_job(struct panfrost_context *ctx, bool has_draws); +panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws); void panfrost_shader_compile( diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c index e7dcd2e5875..81f922abd1c 100644 --- a/src/gallium/drivers/panfrost/pan_drm.c +++ b/src/gallium/drivers/panfrost/pan_drm.c @@ -286,7 +286,7 @@ panfrost_drm_submit_vs_fs_batch(struct panfrost_batch *batch, bool has_draws) if (batch->first_tiler.gpu || batch->clear) { ret = panfrost_drm_submit_batch(batch, - panfrost_fragment_job(ctx, has_draws), + panfrost_fragment_job(batch, has_draws), PANFROST_JD_REQ_FS); assert(!ret); } diff --git a/src/gallium/drivers/panfrost/pan_fragment.c b/src/gallium/drivers/panfrost/pan_fragment.c index dc89bce1b76..2b6ffd841fe 100644 --- a/src/gallium/drivers/panfrost/pan_fragment.c +++ b/src/gallium/drivers/panfrost/pan_fragment.c @@ -51,19 +51,18 @@ panfrost_initialize_surface( * presentations, this is supposed to correspond to eglSwapBuffers) */ mali_ptr -panfrost_fragment_job(struct panfrost_context *ctx, bool has_draws) +panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws) { - struct panfrost_screen *screen = pan_screen(ctx->base.screen); + struct panfrost_screen *screen = pan_screen(batch->ctx->base.screen); mali_ptr framebuffer = screen->require_sfbd ? - panfrost_sfbd_fragment(ctx, has_draws) : - panfrost_mfbd_fragment(ctx, has_draws); + panfrost_sfbd_fragment(batch, has_draws) : + panfrost_mfbd_fragment(batch, has_draws); /* Mark the affected buffers as initialized, since we're writing to it. * Also, add the surfaces we're writing to to the batch */ - struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer; - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); + struct pipe_framebuffer_state *fb = &batch->key; for (unsigned i = 0; i < fb->nr_cbufs; ++i) { panfrost_initialize_surface(batch, fb->cbufs[i]); diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index da1827a30ca..fcddec2bf22 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -345,8 +345,7 @@ panfrost_mfbd_set_zsbuf( } static mali_ptr -panfrost_mfbd_upload( - struct panfrost_context *ctx, +panfrost_mfbd_upload(struct panfrost_batch *batch, struct bifrost_framebuffer *fb, struct bifrost_fb_extra *fbx, struct bifrost_render_target *rts, @@ -364,7 +363,6 @@ panfrost_mfbd_upload( (has_extra ? sizeof(struct bifrost_fb_extra) : 0) + sizeof(struct bifrost_render_target) * 4; - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); struct panfrost_transfer m_f_trans = panfrost_allocate_transient(batch, total_sz); @@ -393,18 +391,15 @@ panfrost_mfbd_upload( /* Creates an MFBD for the FRAGMENT section of the bound framebuffer */ mali_ptr -panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws) +panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws) { - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - - struct bifrost_framebuffer fb = panfrost_emit_mfbd(ctx, has_draws); + struct bifrost_framebuffer fb = panfrost_emit_mfbd(batch, has_draws); struct bifrost_fb_extra fbx = {}; struct bifrost_render_target rts[4] = {}; /* We always upload at least one dummy GL_NONE render target */ - unsigned rt_descriptors = - MAX2(ctx->pipe_framebuffer.nr_cbufs, 1); + unsigned rt_descriptors = MAX2(batch->key.nr_cbufs, 1); fb.rt_count_1 = MALI_POSITIVE(rt_descriptors); fb.rt_count_2 = rt_descriptors; @@ -417,7 +412,7 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws) /* Upload either the render target or a dummy GL_NONE target */ for (int cb = 0; cb < rt_descriptors; ++cb) { - struct pipe_surface *surf = ctx->pipe_framebuffer.cbufs[cb]; + struct pipe_surface *surf = batch->key.cbufs[cb]; if (surf) { panfrost_mfbd_set_cbuf(&rts[cb], surf); @@ -443,8 +438,8 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws) rts[cb].format.unk1 |= (cb * 0x400); } - if (ctx->pipe_framebuffer.zsbuf) { - panfrost_mfbd_set_zsbuf(&fb, &fbx, ctx->pipe_framebuffer.zsbuf); + if (batch->key.zsbuf) { + panfrost_mfbd_set_zsbuf(&fb, &fbx, batch->key.zsbuf); } /* When scanning out, the depth buffer is immediately invalidated, so @@ -473,8 +468,8 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws) /* Checksumming only works with a single render target */ - if (ctx->pipe_framebuffer.nr_cbufs == 1) { - struct pipe_surface *surf = ctx->pipe_framebuffer.cbufs[0]; + if (batch->key.nr_cbufs == 1) { + struct pipe_surface *surf = batch->key.cbufs[0]; struct panfrost_resource *rsrc = pan_resource(surf->texture); struct panfrost_bo *bo = rsrc->bo; @@ -489,5 +484,5 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws) } } - return panfrost_mfbd_upload(ctx, &fb, &fbx, rts, rt_descriptors); + return panfrost_mfbd_upload(batch, &fb, &fbx, rts, rt_descriptors); } diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c index 843e5632491..bf49ddfc1a0 100644 --- a/src/gallium/drivers/panfrost/pan_sfbd.c +++ b/src/gallium/drivers/panfrost/pan_sfbd.c @@ -130,19 +130,18 @@ panfrost_sfbd_set_zsbuf( /* Creates an SFBD for the FRAGMENT section of the bound framebuffer */ mali_ptr -panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws) +panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws) { - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); - struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx, has_draws); + struct mali_single_framebuffer fb = panfrost_emit_sfbd(batch, has_draws); panfrost_sfbd_clear(batch, &fb); /* SFBD does not support MRT natively; sanity check */ - assert(ctx->pipe_framebuffer.nr_cbufs == 1); - panfrost_sfbd_set_cbuf(&fb, ctx->pipe_framebuffer.cbufs[0]); + assert(batch->key.nr_cbufs == 1); + panfrost_sfbd_set_cbuf(&fb, batch->key.cbufs[0]); - if (ctx->pipe_framebuffer.zsbuf) - panfrost_sfbd_set_zsbuf(&fb, ctx->pipe_framebuffer.zsbuf); + if (batch->key.zsbuf) + panfrost_sfbd_set_zsbuf(&fb, batch->key.zsbuf); if (batch->requirements & PAN_REQ_MSAA) fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B; |