diff options
author | Marek Olšák <[email protected]> | 2015-12-06 19:38:26 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-12-11 15:25:12 +0100 |
commit | 2b396eeed983ae35d63a64bd6052aaaffda07adb (patch) | |
tree | 4ddb4216e35f1b9d7977c8e602abff1ff4ab4ad7 /src/gallium/auxiliary/pipebuffer/pb_cache.h | |
parent | 1a24f443b492972eec8f01ffb36d0ae300acd7c8 (diff) |
gallium/pb_cache: add a copy of cache bufmgr independent of pb_manager
This simplified (basically duplicated) version of pb_cache_manager will
allow removing some ugly hacks from radeon and amdgpu winsyses and
flatten simplify their design.
The difference is that winsyses must manually add buffers to the cache
in "destroy" functions and the cache doesn't know about the buffers before
that. The integration is therefore trivial and the impact on the winsys
design is negligible.
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Edward O'Callaghan <[email protected]>
Acked-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer/pb_cache.h')
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_cache.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_cache.h b/src/gallium/auxiliary/pipebuffer/pb_cache.h new file mode 100644 index 00000000000..f0fa0122602 --- /dev/null +++ b/src/gallium/auxiliary/pipebuffer/pb_cache.h @@ -0,0 +1,74 @@ +/************************************************************************** + * + * Copyright 2007-2008 VMware, Inc. + * Copyright 2015 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * 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, sub license, 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL AUTHORS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#ifndef PB_CACHE_H +#define PB_CACHE_H + +#include "pb_buffer.h" +#include "util/list.h" +#include "os/os_thread.h" + +/** + * Statically inserted into the driver-specific buffer structure. + */ +struct pb_cache_entry +{ + struct list_head head; + struct pb_buffer *buffer; /**< Pointer to the structure this is part of. */ + struct pb_cache *mgr; + int64_t start, end; /**< Caching time interval */ +}; + +struct pb_cache +{ + struct list_head cache; + pipe_mutex mutex; + uint64_t cache_size; + uint64_t max_cache_size; + unsigned usecs; + unsigned num_buffers; + unsigned bypass_usage; + float size_factor; + + void (*destroy_buffer)(struct pb_buffer *buf); + bool (*can_reclaim)(struct pb_buffer *buf); +}; + +void pb_cache_add_buffer(struct pb_cache_entry *entry); +struct pb_buffer *pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size, + unsigned alignment, unsigned usage); +void pb_cache_release_all_buffers(struct pb_cache *mgr); +void pb_cache_init_entry(struct pb_cache *mgr, struct pb_cache_entry *entry, + struct pb_buffer *buf); +void pb_cache_init(struct pb_cache *mgr, uint usecs, float size_factor, + unsigned bypass_usage, uint64_t maximum_cache_size, + void (*destroy_buffer)(struct pb_buffer *buf), + bool (*can_reclaim)(struct pb_buffer *buf)); +void pb_cache_deinit(struct pb_cache *mgr); + +#endif |