#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:
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);
}
/* 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);
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_ */