panfrost: Refactor blitting code
We refactor the wallpaper rendering code to separate the wallpaper-specific bits from the general blitting capabilities. In the (hopefully near) future, we'll turn this on to implement real Gallium blits, e.g. for automatic mipmap generation. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
@@ -44,6 +44,7 @@ files_panfrost = files(
|
|||||||
|
|
||||||
'pan_context.c',
|
'pan_context.c',
|
||||||
'pan_afbc.c',
|
'pan_afbc.c',
|
||||||
|
'pan_blit.c',
|
||||||
'pan_job.c',
|
'pan_job.c',
|
||||||
'pan_trace.c',
|
'pan_trace.c',
|
||||||
'pan_drm.c',
|
'pan_drm.c',
|
||||||
|
133
src/gallium/drivers/panfrost/pan_blit.c
Normal file
133
src/gallium/drivers/panfrost/pan_blit.c
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Broadcom
|
||||||
|
* Copyright (C) 2019 Collabora
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
* Authors (Collabora):
|
||||||
|
* Tomeu Vizoso <tomeu.vizoso@collabora.com>
|
||||||
|
* Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pan_context.h"
|
||||||
|
#include "util/u_format.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
panfrost_blitter_save(struct panfrost_context *ctx)
|
||||||
|
{
|
||||||
|
|
||||||
|
util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vertex_buffers);
|
||||||
|
util_blitter_save_vertex_elements(ctx->blitter, ctx->vertex);
|
||||||
|
util_blitter_save_vertex_shader(ctx->blitter, ctx->vs);
|
||||||
|
util_blitter_save_rasterizer(ctx->blitter, ctx->rasterizer);
|
||||||
|
util_blitter_save_viewport(ctx->blitter, &ctx->pipe_viewport);
|
||||||
|
util_blitter_save_scissor(ctx->blitter, &ctx->scissor);
|
||||||
|
util_blitter_save_fragment_shader(ctx->blitter, ctx->fs);
|
||||||
|
util_blitter_save_blend(ctx->blitter, ctx->blend);
|
||||||
|
util_blitter_save_depth_stencil_alpha(ctx->blitter, ctx->depth_stencil);
|
||||||
|
util_blitter_save_stencil_ref(ctx->blitter, &ctx->stencil_ref);
|
||||||
|
util_blitter_save_so_targets(ctx->blitter, 0, NULL);
|
||||||
|
|
||||||
|
/* For later */
|
||||||
|
// util_blitter_save_sample_mask(ctx->blitter, ctx->sample_mask);
|
||||||
|
|
||||||
|
util_blitter_save_framebuffer(ctx->blitter, &ctx->pipe_framebuffer);
|
||||||
|
util_blitter_save_fragment_sampler_states(ctx->blitter,
|
||||||
|
ctx->sampler_count[PIPE_SHADER_FRAGMENT],
|
||||||
|
(void **)(&ctx->samplers[PIPE_SHADER_FRAGMENT]));
|
||||||
|
util_blitter_save_fragment_sampler_views(ctx->blitter,
|
||||||
|
ctx->sampler_view_count[PIPE_SHADER_FRAGMENT],
|
||||||
|
(struct pipe_sampler_view **)&ctx->sampler_views[PIPE_SHADER_FRAGMENT]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
panfrost_u_blitter_blit(struct pipe_context *pipe,
|
||||||
|
const struct pipe_blit_info *info)
|
||||||
|
{
|
||||||
|
struct panfrost_context *ctx = pan_context(pipe);
|
||||||
|
|
||||||
|
if (!util_blitter_is_blit_supported(ctx->blitter, info)) {
|
||||||
|
fprintf(stderr, "blit unsupported %s -> %s\n",
|
||||||
|
util_format_short_name(info->src.resource->format),
|
||||||
|
util_format_short_name(info->dst.resource->format));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: Scissor */
|
||||||
|
|
||||||
|
panfrost_blitter_save(ctx);
|
||||||
|
util_blitter_blit(ctx->blitter, info);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
panfrost_blit(struct pipe_context *pipe,
|
||||||
|
const struct pipe_blit_info *info)
|
||||||
|
{
|
||||||
|
/* We don't have a hardware blit, so we just fake it with
|
||||||
|
* u_blitter. We could do a little better by culling
|
||||||
|
* vertex jobs, though. */
|
||||||
|
|
||||||
|
/* TODO: Implement blitting. Commented out because u_blitter is not
|
||||||
|
* fully integrated and creates bugs in other places. */
|
||||||
|
#if 0
|
||||||
|
if (panfrost_u_blitter_blit(pipe, info))
|
||||||
|
return;
|
||||||
|
|
||||||
|
fprintf(stderr, "Unhandled blit");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Blits a framebuffer to "itself". Mali is a tiler, so the
|
||||||
|
* framebuffer is implicitly cleared every frame, so if there is
|
||||||
|
* no actual glClear(), we have to blit it back ourselves.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
panfrost_blit_wallpaper(struct panfrost_context *ctx)
|
||||||
|
{
|
||||||
|
struct pipe_blit_info binfo = { };
|
||||||
|
|
||||||
|
panfrost_blitter_save(ctx);
|
||||||
|
|
||||||
|
binfo.src.resource = binfo.dst.resource = ctx->pipe_framebuffer.cbufs[0]->texture;
|
||||||
|
binfo.src.level = binfo.dst.level = 0;
|
||||||
|
binfo.src.box.x = binfo.dst.box.x = 0;
|
||||||
|
binfo.src.box.y = binfo.dst.box.y = 0;
|
||||||
|
binfo.src.box.width = binfo.dst.box.width = ctx->pipe_framebuffer.width;
|
||||||
|
binfo.src.box.height = binfo.dst.box.height = ctx->pipe_framebuffer.height;
|
||||||
|
|
||||||
|
/* This avoids an assert due to missing nir_texop_txb support */
|
||||||
|
//binfo.src.box.depth = binfo.dst.box.depth = 1;
|
||||||
|
|
||||||
|
binfo.src.format = binfo.dst.format = ctx->pipe_framebuffer.cbufs[0]->texture->format;
|
||||||
|
|
||||||
|
assert(ctx->pipe_framebuffer.nr_cbufs == 1);
|
||||||
|
binfo.mask = PIPE_MASK_RGBA;
|
||||||
|
binfo.filter = PIPE_TEX_FILTER_LINEAR;
|
||||||
|
binfo.scissor_enable = FALSE;
|
||||||
|
|
||||||
|
util_blitter_blit(ctx->blitter, &binfo);
|
||||||
|
}
|
||||||
|
|
@@ -1320,54 +1320,13 @@ static void
|
|||||||
panfrost_draw_wallpaper(struct pipe_context *pipe)
|
panfrost_draw_wallpaper(struct pipe_context *pipe)
|
||||||
{
|
{
|
||||||
struct panfrost_context *ctx = pan_context(pipe);
|
struct panfrost_context *ctx = pan_context(pipe);
|
||||||
struct pipe_blit_info binfo = { };
|
|
||||||
|
|
||||||
/* Nothing to reload? */
|
/* Nothing to reload? */
|
||||||
if (ctx->pipe_framebuffer.cbufs[0] == NULL)
|
if (ctx->pipe_framebuffer.cbufs[0] == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vertex_buffers);
|
/* Blit the wallpaper in */
|
||||||
util_blitter_save_vertex_elements(ctx->blitter, ctx->vertex);
|
panfrost_blit_wallpaper(ctx);
|
||||||
util_blitter_save_vertex_shader(ctx->blitter, ctx->vs);
|
|
||||||
util_blitter_save_rasterizer(ctx->blitter, ctx->rasterizer);
|
|
||||||
util_blitter_save_viewport(ctx->blitter, &ctx->pipe_viewport);
|
|
||||||
util_blitter_save_scissor(ctx->blitter, &ctx->scissor);
|
|
||||||
util_blitter_save_fragment_shader(ctx->blitter, ctx->fs);
|
|
||||||
util_blitter_save_blend(ctx->blitter, ctx->blend);
|
|
||||||
util_blitter_save_depth_stencil_alpha(ctx->blitter, ctx->depth_stencil);
|
|
||||||
util_blitter_save_stencil_ref(ctx->blitter, &ctx->stencil_ref);
|
|
||||||
util_blitter_save_so_targets(ctx->blitter, 0, NULL);
|
|
||||||
|
|
||||||
/* For later */
|
|
||||||
// util_blitter_save_sample_mask(ctx->blitter, vc4->sample_mask);
|
|
||||||
|
|
||||||
util_blitter_save_framebuffer(ctx->blitter, &ctx->pipe_framebuffer);
|
|
||||||
util_blitter_save_fragment_sampler_states(ctx->blitter,
|
|
||||||
ctx->sampler_count[PIPE_SHADER_FRAGMENT],
|
|
||||||
(void **)(&ctx->samplers[PIPE_SHADER_FRAGMENT]));
|
|
||||||
util_blitter_save_fragment_sampler_views(ctx->blitter,
|
|
||||||
ctx->sampler_view_count[PIPE_SHADER_FRAGMENT],
|
|
||||||
(struct pipe_sampler_view **)&ctx->sampler_views[PIPE_SHADER_FRAGMENT]);
|
|
||||||
|
|
||||||
|
|
||||||
binfo.src.resource = binfo.dst.resource = ctx->pipe_framebuffer.cbufs[0]->texture;
|
|
||||||
binfo.src.level = binfo.dst.level = 0;
|
|
||||||
binfo.src.box.x = binfo.dst.box.x = 0;
|
|
||||||
binfo.src.box.y = binfo.dst.box.y = 0;
|
|
||||||
binfo.src.box.width = binfo.dst.box.width = ctx->pipe_framebuffer.width;
|
|
||||||
binfo.src.box.height = binfo.dst.box.height = ctx->pipe_framebuffer.height;
|
|
||||||
|
|
||||||
/* This avoids an assert due to missing nir_texop_txb support */
|
|
||||||
//binfo.src.box.depth = binfo.dst.box.depth = 1;
|
|
||||||
|
|
||||||
binfo.src.format = binfo.dst.format = ctx->pipe_framebuffer.cbufs[0]->texture->format;
|
|
||||||
|
|
||||||
assert(ctx->pipe_framebuffer.nr_cbufs == 1);
|
|
||||||
binfo.mask = PIPE_MASK_RGBA;
|
|
||||||
binfo.filter = PIPE_TEX_FILTER_LINEAR;
|
|
||||||
binfo.scissor_enable = FALSE;
|
|
||||||
|
|
||||||
util_blitter_blit(ctx->blitter, &binfo);
|
|
||||||
|
|
||||||
/* We are flushing all queued draws and we know that no more jobs will
|
/* We are flushing all queued draws and we know that no more jobs will
|
||||||
* be added until the next frame.
|
* be added until the next frame.
|
||||||
|
@@ -1,31 +1,33 @@
|
|||||||
/**************************************************************************
|
/*
|
||||||
*
|
* Copyright (C) 2008 VMware, Inc.
|
||||||
* Copyright 2008 VMware, Inc.
|
* Copyright (C) 2014 Broadcom
|
||||||
* Copyright 2014 Broadcom
|
* Copyright (C) 2018-2019 Alyssa Rosenzweig
|
||||||
* Copyright 2018 Alyssa Rosenzweig
|
* Copyright (C) 2019 Collabora
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* to deal in the Software without restriction, including without limitation
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice (including the
|
* The above copyright notice and this permission notice (including the next
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
* of the Software.
|
* Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE.
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
* Authors (Collabora):
|
||||||
|
* Tomeu Vizoso <tomeu.vizoso@collabora.com>
|
||||||
|
* Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -129,19 +131,6 @@ panfrost_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
|
|||||||
//DBG("TODO %s\n", __func__);
|
//DBG("TODO %s\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
panfrost_blit(struct pipe_context *pipe,
|
|
||||||
const struct pipe_blit_info *info)
|
|
||||||
{
|
|
||||||
if (util_try_blit_via_copy_region(pipe, info))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
DBG("Unhandled blit.\n");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct pipe_surface *
|
static struct pipe_surface *
|
||||||
panfrost_create_surface(struct pipe_context *pipe,
|
panfrost_create_surface(struct pipe_context *pipe,
|
||||||
struct pipe_resource *pt,
|
struct pipe_resource *pt,
|
||||||
|
@@ -133,4 +133,13 @@ panfrost_format_supports_afbc(enum pipe_format format);
|
|||||||
void
|
void
|
||||||
panfrost_enable_afbc(struct panfrost_context *ctx, struct panfrost_resource *rsrc, bool ds);
|
panfrost_enable_afbc(struct panfrost_context *ctx, struct panfrost_resource *rsrc, bool ds);
|
||||||
|
|
||||||
|
/* Blitting */
|
||||||
|
|
||||||
|
void
|
||||||
|
panfrost_blit(struct pipe_context *pipe,
|
||||||
|
const struct pipe_blit_info *info);
|
||||||
|
|
||||||
|
void
|
||||||
|
panfrost_blit_wallpaper(struct panfrost_context *ctx);
|
||||||
|
|
||||||
#endif /* PAN_RESOURCE_H */
|
#endif /* PAN_RESOURCE_H */
|
||||||
|
Reference in New Issue
Block a user