panfrost: Remove staging SFBD for pan_context

The fragment framebuffer descriptor should not be a context entry;
rather, it should be constructed only at fragment time to keep analysis
tractable.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig 2019-03-12 22:01:23 +00:00
parent 9dd84db7a5
commit d47f090738
4 changed files with 31 additions and 40 deletions

View File

@ -140,7 +140,6 @@ struct panfrost_context {
* e.g. clearing information */
union {
struct mali_single_framebuffer fragment_sfbd;
struct {
struct bifrost_framebuffer fragment_mfbd;
struct bifrost_fb_extra fragment_extra;
@ -371,10 +370,10 @@ bool
panfrost_is_scanout(struct panfrost_context *ctx);
mali_ptr
panfrost_sfbd_fragment(struct panfrost_context *ctx);
panfrost_sfbd_fragment(struct panfrost_context *ctx, bool flip_y);
mali_ptr
panfrost_mfbd_fragment(struct panfrost_context *ctx);
panfrost_mfbd_fragment(struct panfrost_context *ctx, bool flip_y);
struct bifrost_framebuffer
panfrost_emit_mfbd(struct panfrost_context *ctx);

View File

@ -34,9 +34,12 @@
mali_ptr
panfrost_fragment_job(struct panfrost_context *ctx)
{
/* TODO: Check viewport or something */
bool flip_y = panfrost_is_scanout(ctx);
mali_ptr framebuffer = ctx->require_sfbd ?
panfrost_sfbd_fragment(ctx) :
panfrost_mfbd_fragment(ctx);
panfrost_sfbd_fragment(ctx, flip_y) :
panfrost_mfbd_fragment(ctx, flip_y);
struct mali_job_descriptor_header header = {
.job_type = JOB_TYPE_FRAGMENT,

View File

@ -234,7 +234,7 @@ panfrost_mfbd_upload(struct panfrost_context *ctx)
/* Creates an MFBD for the FRAGMENT section of the bound framebuffer */
mali_ptr
panfrost_mfbd_fragment(struct panfrost_context *ctx)
panfrost_mfbd_fragment(struct panfrost_context *ctx, bool flip_y)
{
struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);

View File

@ -36,16 +36,11 @@ panfrost_sfbd_format(struct pipe_surface *surf)
}
static void
panfrost_sfbd_enable_msaa(struct panfrost_context *ctx)
{
ctx->fragment_sfbd.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
}
static void
panfrost_sfbd_clear(struct panfrost_job *job)
panfrost_sfbd_clear(
struct panfrost_job *job,
struct mali_single_framebuffer *sfbd)
{
struct panfrost_context *ctx = job->ctx;
struct mali_single_framebuffer *sfbd = &ctx->fragment_sfbd;
if (job->clear & PIPE_CLEAR_COLOR) {
sfbd->clear_color_1 = job->clear_color;
@ -91,60 +86,54 @@ panfrost_sfbd_clear(struct panfrost_job *job)
static void
panfrost_sfbd_set_cbuf(
struct panfrost_context *ctx,
struct pipe_surface *surf)
struct mali_single_framebuffer *fb,
struct pipe_surface *surf,
bool flip_y)
{
struct panfrost_resource *rsrc = pan_resource(surf->texture);
signed stride =
util_format_get_stride(surf->format, surf->texture->width0);
ctx->fragment_sfbd.format = panfrost_sfbd_format(surf);
fb->format = panfrost_sfbd_format(surf);
if (rsrc->bo->layout == PAN_LINEAR) {
mali_ptr framebuffer = rsrc->bo->gpu[0];
/* The default is upside down from OpenGL's perspective. */
if (panfrost_is_scanout(ctx)) {
if (flip_y) {
framebuffer += stride * (surf->texture->height0 - 1);
stride = -stride;
}
ctx->fragment_sfbd.framebuffer = framebuffer;
ctx->fragment_sfbd.stride = stride;
fb->framebuffer = framebuffer;
fb->stride = stride;
} else {
fprintf(stderr, "Invalid render layout\n");
assert(0);
}
}
static void
panfrost_sfbd_set_targets(struct panfrost_context *ctx)
/* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
mali_ptr
panfrost_sfbd_fragment(struct panfrost_context *ctx, bool flip_y)
{
struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx);
panfrost_sfbd_clear(job, &fb);
/* SFBD does not support MRT natively; sanity check */
assert(ctx->pipe_framebuffer.nr_cbufs == 1);
panfrost_sfbd_set_cbuf(ctx, ctx->pipe_framebuffer.cbufs[0]);
panfrost_sfbd_set_cbuf(&fb, ctx->pipe_framebuffer.cbufs[0], flip_y);
if (ctx->pipe_framebuffer.zsbuf) {
/* TODO */
}
}
/* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
mali_ptr
panfrost_sfbd_fragment(struct panfrost_context *ctx)
{
struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx);
memcpy(&ctx->fragment_sfbd, &fb, sizeof(fb));
panfrost_sfbd_clear(job);
panfrost_sfbd_set_targets(ctx);
if (job->msaa)
panfrost_sfbd_enable_msaa(ctx);
fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
return MALI_SFBD |
panfrost_upload_transient(ctx, &ctx->fragment_sfbd, sizeof(fb));
return panfrost_upload_transient(ctx, &fb, sizeof(fb)) | MALI_SFBD;
}