* e.g. clearing information */
union {
- struct mali_single_framebuffer fragment_sfbd;
struct {
struct bifrost_framebuffer fragment_mfbd;
struct bifrost_fb_extra fragment_extra;
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);
}
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;
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)
-{
- assert(ctx->pipe_framebuffer.nr_cbufs == 1);
- panfrost_sfbd_set_cbuf(ctx, ctx->pipe_framebuffer.cbufs[0]);
-
- 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)
+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);
- memcpy(&ctx->fragment_sfbd, &fb, sizeof(fb));
- panfrost_sfbd_clear(job);
- panfrost_sfbd_set_targets(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(&fb, ctx->pipe_framebuffer.cbufs[0], flip_y);
+
+ if (ctx->pipe_framebuffer.zsbuf) {
+ /* TODO */
+ }
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;
}