panfrost: Move pan_bo to root panfrost

Now that its Gallium dependencies have been resolved, we can move this
all out to root. The only nontrivial change here is keeping the
pandecode calls in Gallium-panfrost to avoid creating a circular
dependency between encoder/decoder. This could be solved with a third
drm folder but this seems less intrusive for now and Roman would
probably appreciate if I went longer than 8 hours without breaking the
Android build.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4382>
This commit is contained in:
Alyssa Rosenzweig 2020-03-23 19:36:46 -04:00 committed by Marge Bot
parent 3283c7f4da
commit 0f65f00a0d
13 changed files with 40 additions and 25 deletions

View file

@ -13,8 +13,6 @@ C_SOURCES := \
pan_blend_shaders.c \
pan_blend_shaders.h \
pan_blit.c \
pan_bo.c \
pan_bo.h \
pan_cmdstream.c \
pan_cmdstream.h \
pan_compute.c \
@ -31,4 +29,3 @@ C_SOURCES := \
pan_screen.c \
pan_screen.h \
pan_sfbd.c \
pan_util.h

View file

@ -30,7 +30,6 @@ files_panfrost = files(
'nir/nir_lower_framebuffer.c',
'pan_context.c',
'pan_bo.c',
'pan_blit.c',
'pan_job.c',
'pan_allocate.c',

View file

@ -76,7 +76,7 @@ panfrost_shader_compile(struct panfrost_context *ctx,
* that's how I'd do it. */
if (size) {
state->bo = panfrost_bo_create(dev, size, PAN_BO_EXECUTE);
state->bo = pan_bo_create(dev, size, PAN_BO_EXECUTE);
memcpy(state->bo->cpu, dst, size);
state->first_tag = program.first_tag;
} else {

View file

@ -922,7 +922,7 @@ panfrost_create_sampler_view(
template->u.tex.last_layer,
type, prsrc->layout);
so->bo = panfrost_bo_create(device, size, 0);
so->bo = pan_bo_create(device, size, 0);
panfrost_new_texture(
so->bo->cpu,
@ -1180,7 +1180,7 @@ panfrost_begin_query(struct pipe_context *pipe, struct pipe_query *q)
case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
/* Allocate a bo for the query results to be stored */
if (!query->bo) {
query->bo = panfrost_bo_create(
query->bo = pan_bo_create(
pan_device(ctx->base.screen),
sizeof(unsigned), 0);
}

View file

@ -603,12 +603,12 @@ panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
{
struct panfrost_bo *bo;
bo = panfrost_bo_create(pan_device(batch->ctx->base.screen), size,
bo = pan_bo_create(pan_device(batch->ctx->base.screen), size,
create_flags);
panfrost_batch_add_bo(batch, bo, access_flags);
/* panfrost_batch_add_bo() has retained a reference and
* panfrost_bo_create() initialize the refcnt to 1, so let's
* pan_bo_create() initialize the refcnt to 1, so let's
* unreference the BO here so it gets released when the batch is
* destroyed (unless it's retained by someone else in the meantime).
*/

View file

@ -47,8 +47,26 @@
#include "pan_resource.h"
#include "pan_util.h"
#include "pan_tiling.h"
#include "pandecode/decode.h"
#include "panfrost-quirks.h"
/* Wrapper around panfrost_bo_create that handles pandecode */
struct panfrost_bo *
pan_bo_create(struct panfrost_device *dev, size_t size, uint32_t flags)
{
struct panfrost_bo *bo = panfrost_bo_create(dev, size, flags);
if (pan_debug & (PAN_DBG_TRACE | PAN_DBG_SYNC)) {
if (flags & PAN_BO_INVISIBLE)
pandecode_inject_mmap(bo->gpu, NULL, bo->size, NULL);
else if (!(flags & PAN_BO_DELAY_MMAP))
pandecode_inject_mmap(bo->gpu, bo->cpu, bo->size, NULL);
}
return bo;
}
void
panfrost_resource_reset_damage(struct panfrost_resource *pres)
{
@ -406,7 +424,7 @@ panfrost_resource_create_bo(struct panfrost_device *dev, struct panfrost_resourc
/* We create a BO immediately but don't bother mapping, since we don't
* care to map e.g. FBOs which the CPU probably won't touch */
pres->bo = panfrost_bo_create(dev, bo_size, PAN_BO_DELAY_MMAP);
pres->bo = pan_bo_create(dev, bo_size, PAN_BO_DELAY_MMAP);
}
void
@ -562,6 +580,9 @@ panfrost_transfer_map(struct pipe_context *pctx,
/* If we haven't already mmaped, now's the time */
panfrost_bo_mmap(bo);
if (pan_debug & (PAN_DBG_TRACE | PAN_DBG_SYNC))
pandecode_inject_mmap(bo->gpu, bo->cpu, bo->size, NULL);
if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
/* If the BO is used by one of the pending batches or if it's
* not ready yet (still accessed by one of the already flushed
@ -580,7 +601,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
* doing to it.
*/
if (!(bo->flags & (PAN_BO_IMPORTED | PAN_BO_EXPORTED)))
newbo = panfrost_bo_create(dev, bo->size,
newbo = pan_bo_create(dev, bo->size,
flags);
if (newbo) {
@ -862,7 +883,7 @@ panfrost_resource_hint_layout(
/* If we grew in size, reallocate the BO */
if (new_size > rsrc->bo->size) {
panfrost_bo_unreference(rsrc->bo);
rsrc->bo = panfrost_bo_create(dev, new_size, PAN_BO_DELAY_MMAP);
rsrc->bo = pan_bo_create(dev, new_size, PAN_BO_DELAY_MMAP);
}
/* TODO: If there are textures bound, regenerate their descriptors */

View file

@ -118,4 +118,8 @@ panfrost_resource_set_damage_region(struct pipe_screen *screen,
unsigned int nrects,
const struct pipe_box *rects);
struct panfrost_bo *
pan_bo_create(struct panfrost_device *dev, size_t size, uint32_t flags);
#endif /* PAN_RESOURCE_H */

View file

@ -17,6 +17,8 @@ bifrost_FILES := \
encoder_FILES := \
encoder/pan_afbc.c \
encoder/pan_attributes.c \
encoder/pan_bo.c \
encoder/pan_bo.h \
encoder/pan_device.h \
encoder/pan_encoder.h \
encoder/pan_format.c \
@ -25,7 +27,8 @@ encoder_FILES := \
encoder/pan_sampler.c \
encoder/pan_tiler.c \
encoder/pan_texture.c \
encoder/pan_scratch.c
encoder/pan_scratch.c \
encoder/pan_util.h
midgard_FILES := \
midgard/compiler.h \

View file

@ -24,6 +24,7 @@ libpanfrost_encoder_files = files(
'pan_afbc.c',
'pan_attributes.c',
'pan_bo.c',
'pan_format.c',
'pan_invocation.c',
'pan_sampler.c',

View file

@ -31,8 +31,6 @@
#include "drm-uapi/panfrost_drm.h"
#include "pan_bo.h"
#include "pan_util.h"
#include "pandecode/decode.h"
#include "os/os_mman.h"
@ -72,7 +70,7 @@ panfrost_bo_alloc(struct panfrost_device *dev, size_t size,
ret = drmIoctl(dev->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo);
if (ret) {
DBG("DRM_IOCTL_PANFROST_CREATE_BO failed: %m\n");
fprintf(stderr, "DRM_IOCTL_PANFROST_CREATE_BO failed: %m\n");
return NULL;
}
@ -344,10 +342,6 @@ panfrost_bo_mmap(struct panfrost_bo *bo)
fprintf(stderr, "mmap failed: %p %m\n", bo->cpu);
assert(0);
}
/* Record the mmap if we're tracing */
if (pan_debug & (PAN_DBG_TRACE | PAN_DBG_SYNC))
pandecode_inject_mmap(bo->gpu, bo->cpu, bo->size, NULL);
}
static void
@ -404,10 +398,6 @@ panfrost_bo_create(struct panfrost_device *dev, size_t size,
if (!(flags & (PAN_BO_INVISIBLE | PAN_BO_DELAY_MMAP)))
panfrost_bo_mmap(bo);
else if (flags & PAN_BO_INVISIBLE) {
if (pan_debug & (PAN_DBG_TRACE | PAN_DBG_SYNC))
pandecode_inject_mmap(bo->gpu, NULL, bo->size, NULL);
}
p_atomic_set(&bo->refcnt, 1);

View file

@ -34,9 +34,9 @@
#include "util/u_dynarray.h"
#include "util/bitset.h"
#include "util/set.h"
#include "util/list.h"
#include <panfrost-misc.h>
#include "pan_allocate.h"
/* Driver limits */
#define PAN_MAX_CONST_BUFFERS 16