summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:40:05 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:40:05 +0000
commit21ab4c9f31674b113c24177398ed39f29b7cd8e6 (patch)
tree8be392d7a792d9663c2586396be77bfd506f5164 /lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h
parenta8f0a7916e26e550dd2a26e7188835c481978004 (diff)
Import Mesa 13.0.2
Diffstat (limited to 'lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h')
-rw-r--r--lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h51
1 files changed, 35 insertions, 16 deletions
diff --git a/lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h b/lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h
index 47dd467f4..30097008e 100644
--- a/lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/lib/mesa/src/gallium/drivers/freedreno/freedreno_util.h
@@ -73,6 +73,10 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
#define FD_DBG_GLSL120 0x0400
#define FD_DBG_SHADERDB 0x0800
#define FD_DBG_FLUSH 0x1000
+#define FD_DBG_DEQP 0x2000
+#define FD_DBG_NIR 0x4000
+#define FD_DBG_REORDER 0x8000
+#define FD_DBG_BSTAT 0x10000
extern int fd_mesa_debug;
extern bool fd_binning_enabled;
@@ -180,7 +184,7 @@ OUT_RING(struct fd_ringbuffer *ring, uint32_t data)
DBG("ring[%p]: OUT_RING %04x: %08x", ring,
(uint32_t)(ring->cur - ring->last_start), data);
}
- *(ring->cur++) = data;
+ fd_ringbuffer_emit(ring, data);
}
/* like OUT_RING() but appends a cmdstream patch point to 'buf' */
@@ -206,6 +210,7 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
DBG("ring[%p]: OUT_RELOC %04x: %p+%u << %d", ring,
(uint32_t)(ring->cur - ring->last_start), bo, offset, shift);
}
+ debug_assert(offset < fd_bo_size(bo));
fd_ringbuffer_reloc(ring, &(struct fd_reloc){
.bo = bo,
.flags = FD_RELOC_READ,
@@ -223,6 +228,7 @@ OUT_RELOCW(struct fd_ringbuffer *ring, struct fd_bo *bo,
DBG("ring[%p]: OUT_RELOCW %04x: %p+%u << %d", ring,
(uint32_t)(ring->cur - ring->last_start), bo, offset, shift);
}
+ debug_assert(offset < fd_bo_size(bo));
fd_ringbuffer_reloc(ring, &(struct fd_reloc){
.bo = bo,
.flags = FD_RELOC_READ | FD_RELOC_WRITE,
@@ -234,13 +240,8 @@ OUT_RELOCW(struct fd_ringbuffer *ring, struct fd_bo *bo,
static inline void BEGIN_RING(struct fd_ringbuffer *ring, uint32_t ndwords)
{
- if ((ring->cur + ndwords) >= ring->end) {
- /* this probably won't really work if we have multiple tiles..
- * but it is ok for 2d.. we might need different behavior
- * depending on 2d or 3d pipe.
- */
- DBG("uh oh..");
- }
+ if (ring->cur + ndwords >= ring->end)
+ fd_ringbuffer_grow(ring, ndwords);
}
static inline void
@@ -251,6 +252,13 @@ OUT_PKT0(struct fd_ringbuffer *ring, uint16_t regindx, uint16_t cnt)
}
static inline void
+OUT_PKT2(struct fd_ringbuffer *ring)
+{
+ BEGIN_RING(ring, 1);
+ OUT_RING(ring, CP_TYPE2_PKT);
+}
+
+static inline void
OUT_PKT3(struct fd_ringbuffer *ring, uint8_t opcode, uint16_t cnt)
{
BEGIN_RING(ring, cnt+1);
@@ -265,12 +273,9 @@ OUT_WFI(struct fd_ringbuffer *ring)
}
static inline void
-__OUT_IB(struct fd_ringbuffer *ring, bool prefetch,
- struct fd_ringmarker *start, struct fd_ringmarker *end)
+__OUT_IB(struct fd_ringbuffer *ring, bool prefetch, struct fd_ringbuffer *target)
{
- uint32_t dwords = fd_ringmarker_dwords(start, end);
-
- assert(dwords > 0);
+ unsigned count = fd_ringbuffer_cmd_count(target);
/* for debug after a lock up, write a unique counter value
* to scratch6 for each IB, to make it easier to match up
@@ -280,9 +285,14 @@ __OUT_IB(struct fd_ringbuffer *ring, bool prefetch,
*/
emit_marker(ring, 6);
- OUT_PKT3(ring, prefetch ? CP_INDIRECT_BUFFER_PFE : CP_INDIRECT_BUFFER_PFD, 2);
- fd_ringbuffer_emit_reloc_ring(ring, start, end);
- OUT_RING(ring, dwords);
+ for (unsigned i = 0; i < count; i++) {
+ uint32_t dwords;
+ OUT_PKT3(ring, prefetch ? CP_INDIRECT_BUFFER_PFE : CP_INDIRECT_BUFFER_PFD, 2);
+ dwords = fd_ringbuffer_emit_reloc_ring_full(ring, target, i) / 4;
+ assert(dwords > 0);
+ OUT_RING(ring, dwords);
+ OUT_PKT2(ring);
+ }
emit_marker(ring, 6);
}
@@ -322,4 +332,13 @@ pack_rgba(enum pipe_format format, const float *rgba)
return uc.ui[0];
}
+/*
+ * swap - swap value of @a and @b
+ */
+#define swap(a, b) \
+ do { __typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+
+#define foreach_bit(b, mask) \
+ for (uint32_t _m = (mask); _m && ({(b) = u_bit_scan(&_m); 1;});)
+
#endif /* FREEDRENO_UTIL_H_ */