Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_batch_cache.h
4570 views
/*1* Copyright (C) 2016 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FREEDRENO_BATCH_CACHE_H_27#define FREEDRENO_BATCH_CACHE_H_2829#include "pipe/p_state.h"3031#include "freedreno_util.h"3233struct fd_resource;34struct fd_batch;35struct fd_context;36struct fd_screen;3738struct hash_table;3940struct fd_batch_cache {41struct hash_table *ht;42unsigned cnt;4344/* set of active batches.. there is an upper limit on the number of45* in-flight batches, for two reasons:46* 1) to avoid big spikes in number of batches in edge cases, such as47* game startup (ie, lots of texture uploads, but no usages yet of48* the textures), etc.49* 2) so we can use a simple bitmask in fd_resource to track which50* batches have reference to the resource51*/52struct fd_batch *batches[32];53uint32_t batch_mask;54};5556/* note: if batches get unref'd in the body of the loop, they are removed57* from the various masks.. but since we copy the mask at the beginning of58* the loop into _m, we need the &= at the end of the loop to make sure59* we don't have stale bits in _m60*/61#define foreach_batch(batch, cache, mask) \62for (uint32_t _m = (mask); \63_m && ((batch) = (cache)->batches[u_bit_scan(&_m)]); _m &= (mask))6465void fd_bc_init(struct fd_batch_cache *cache);66void fd_bc_fini(struct fd_batch_cache *cache);6768void fd_bc_flush(struct fd_context *ctx, bool deferred) assert_dt;69void fd_bc_flush_writer(struct fd_context *ctx, struct fd_resource *rsc) assert_dt;70void fd_bc_flush_readers(struct fd_context *ctx, struct fd_resource *rsc) assert_dt;71void fd_bc_dump(struct fd_context *ctx, const char *fmt, ...)72_util_printf_format(2, 3);7374void fd_bc_invalidate_batch(struct fd_batch *batch, bool destroy);75void fd_bc_invalidate_resource(struct fd_resource *rsc, bool destroy);76struct fd_batch *fd_bc_alloc_batch(struct fd_context *ctx,77bool nondraw) assert_dt;7879struct fd_batch *80fd_batch_from_fb(struct fd_context *ctx,81const struct pipe_framebuffer_state *pfb) assert_dt;8283#endif /* FREEDRENO_BATCH_CACHE_H_ */848586