X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Ffreedreno%2Ffreedreno_resource.h;h=60ba7e6961fbd68d97ff65cb7df7fa95f3c3ecd4;hb=fd6ed7b5628678ada0db3bf6ae1bcf80628c6947;hp=a2a540ce5069cf31824857a66d62beaa66953094;hpb=bde2045fa247b4d1de98a3bc7585d1b60f9b58b7;p=mesa.git diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h index a2a540ce506..60ba7e6961f 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.h +++ b/src/gallium/drivers/freedreno/freedreno_resource.h @@ -29,10 +29,11 @@ #ifndef FREEDRENO_RESOURCE_H_ #define FREEDRENO_RESOURCE_H_ -#include "util/u_double_list.h" +#include "util/list.h" #include "util/u_range.h" #include "util/u_transfer.h" +#include "freedreno_batch.h" #include "freedreno_util.h" /* Texture Layout on a3xx: @@ -60,28 +61,78 @@ struct fd_resource_slice { uint32_t size0; /* size of first layer in slice */ }; +struct set; + struct fd_resource { struct u_resource base; struct fd_bo *bo; uint32_t cpp; + enum pipe_format internal_format; bool layer_first; /* see above description */ uint32_t layer_size; struct fd_resource_slice slices[MAX_MIP_LEVELS]; uint32_t timestamp; - bool dirty, reading; /* buffer range that has been initialized */ struct util_range valid_buffer_range; - struct list_head list; + /* reference to the resource holding stencil data for a z32_s8 texture */ + /* TODO rename to secondary or auxiliary? */ + struct fd_resource *stencil; + + /* bitmask of in-flight batches which reference this resource. Note + * that the batch doesn't hold reference to resources (but instead + * the fd_ringbuffer holds refs to the underlying fd_bo), but in case + * the resource is destroyed we need to clean up the batch's weak + * references to us. + */ + uint32_t batch_mask; + + /* reference to batch that writes this resource: */ + struct fd_batch *write_batch; + + /* Set of batches whose batch-cache key references this resource. + * We need to track this to know which batch-cache entries to + * invalidate if, for example, the resource is invalidated or + * shadowed. + */ + uint32_t bc_batch_mask; }; -static INLINE struct fd_resource * +static inline struct fd_resource * fd_resource(struct pipe_resource *ptex) { return (struct fd_resource *)ptex; } -static INLINE struct fd_resource_slice * +static inline bool +pending(struct fd_resource *rsc, bool write) +{ + /* if we have a pending GPU write, we are busy in any case: */ + if (rsc->write_batch) + return true; + + /* if CPU wants to write, but we are pending a GPU read, we are busy: */ + if (write && rsc->batch_mask) + return true; + + if (rsc->stencil && pending(rsc->stencil, write)) + return true; + + return false; +} + +struct fd_transfer { + struct pipe_transfer base; + void *staging; +}; + +static inline struct fd_transfer * +fd_transfer(struct pipe_transfer *ptrans) +{ + return (struct fd_transfer *)ptrans; +} + +static inline struct fd_resource_slice * fd_resource_slice(struct fd_resource *rsc, unsigned level) { assert(level <= rsc->base.b.last_level); @@ -89,7 +140,7 @@ fd_resource_slice(struct fd_resource *rsc, unsigned level) } /* get offset for specified mipmap level and texture/array layer */ -static INLINE uint32_t +static inline uint32_t fd_resource_offset(struct fd_resource *rsc, unsigned level, unsigned layer) { struct fd_resource_slice *slice = fd_resource_slice(rsc, level); @@ -103,7 +154,15 @@ fd_resource_offset(struct fd_resource *rsc, unsigned level, unsigned layer) return offset; } +void fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard, + enum fd_render_stage stage); +void fd_blitter_pipe_end(struct fd_context *ctx); + void fd_resource_screen_init(struct pipe_screen *pscreen); void fd_resource_context_init(struct pipe_context *pctx); +void fd_resource_resize(struct pipe_resource *prsc, uint32_t sz); + +bool fd_render_condition_check(struct pipe_context *pctx); + #endif /* FREEDRENO_RESOURCE_H_ */