diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-15 08:13:10 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-15 16:12:55 -0700 |
commit | b5a28f61aef6f030e4cc1c8678c964ba8b81b51d (patch) | |
tree | bc3a918ba5a0ae361be793e8c0f8ab41eca0456f /src/gallium | |
parent | fea953e6c2519560371b29303e0bd014963c14d9 (diff) |
panfrost: Stub out panfrost_bo_cache_get
We will use this function to fetch cached BOs instead of freshly
allocating them.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/panfrost/meson.build | 1 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_bo_cache.c | 36 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_drm.c | 34 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.h | 5 |
4 files changed, 66 insertions, 10 deletions
diff --git a/src/gallium/drivers/panfrost/meson.build b/src/gallium/drivers/panfrost/meson.build index 03dd4f5c20a..a050a286d5e 100644 --- a/src/gallium/drivers/panfrost/meson.build +++ b/src/gallium/drivers/panfrost/meson.build @@ -33,6 +33,7 @@ files_panfrost = files( 'pan_context.c', 'pan_afbc.c', + 'pan_bo_cache.c', 'pan_blit.c', 'pan_job.c', 'pan_drm.c', diff --git a/src/gallium/drivers/panfrost/pan_bo_cache.c b/src/gallium/drivers/panfrost/pan_bo_cache.c new file mode 100644 index 00000000000..b64f9fe2fba --- /dev/null +++ b/src/gallium/drivers/panfrost/pan_bo_cache.c @@ -0,0 +1,36 @@ +/* + * Copyright 2019 Collabora, Ltd. + * + * 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): + * Alyssa Rosenzweig <[email protected]> + */ + +#include "pan_screen.h" + +struct panfrost_bo * +panfrost_bo_cache_fetch( + struct panfrost_screen *screen, + size_t size, uint32_t flags) +{ + /* Stub */ + return NULL; +} diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c index c64117ce014..135eb4d8291 100644 --- a/src/gallium/drivers/panfrost/pan_drm.c +++ b/src/gallium/drivers/panfrost/pan_drm.c @@ -83,7 +83,7 @@ struct panfrost_bo * panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size, uint32_t flags) { - struct panfrost_bo *bo = rzalloc(screen, struct panfrost_bo); + struct panfrost_bo *bo; /* Kernel will fail (confusingly) with EPERM otherwise */ assert(size > 0); @@ -96,17 +96,31 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size, .size = size, .flags = translated_flags, }; - int ret; - ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo); - if (ret) { - fprintf(stderr, "DRM_IOCTL_PANFROST_CREATE_BO failed: %d\n", ret); - assert(0); - } + /* Before creating a BO, we first want to check the cache */ + + bo = panfrost_bo_cache_fetch(screen, size, flags); - bo->size = create_bo.size; - bo->gpu = create_bo.offset; - bo->gem_handle = create_bo.handle; + if (bo == NULL) { + /* Otherwise, the cache misses and we need to allocate a BO fresh from + * the kernel */ + + int ret; + + ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo); + if (ret) { + fprintf(stderr, "DRM_IOCTL_PANFROST_CREATE_BO failed: %d\n", ret); + assert(0); + } + + /* We have a BO allocated from the kernel; fill in the userspace + * version */ + + bo = rzalloc(screen, struct panfrost_bo); + bo->size = create_bo.size; + bo->gpu = create_bo.offset; + bo->gem_handle = create_bo.handle; + } /* Only mmap now if we know we need to. For CPU-invisible buffers, we * never map since we don't care about their contents; they're purely diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index a0c6e2df63d..d34574f7a75 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -161,5 +161,10 @@ panfrost_drm_fence_finish(struct pipe_screen *pscreen, struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout); +struct panfrost_bo * +panfrost_bo_cache_fetch( + struct panfrost_screen *screen, + size_t size, uint32_t flags); + #endif /* PAN_SCREEN_H */ |