diff --git a/src/freedreno/drm/freedreno_ringbuffer.h b/src/freedreno/drm/freedreno_ringbuffer.h index cd8241f229f..0576834b1d0 100644 --- a/src/freedreno/drm/freedreno_ringbuffer.h +++ b/src/freedreno/drm/freedreno_ringbuffer.h @@ -288,6 +288,21 @@ OUT_RING(struct fd_ringbuffer *ring, uint32_t data) fd_ringbuffer_emit(ring, data); } +static inline uint64_t +__reloc_iova(struct fd_bo *bo, uint32_t offset, uint64_t orval, int32_t shift) +{ + uint64_t iova = fd_bo_get_iova(bo) + offset; + + if (shift < 0) + iova >>= -shift; + else + iova <<= shift; + + iova |= orval; + + return iova; +} + /* * NOTE: OUT_RELOC() is 2 dwords (64b) on a5xx+ */ @@ -301,15 +316,14 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t offset, } assert(offset < fd_bo_size(bo)); - uint64_t iova = fd_bo_get_iova(bo) + offset; - - if (shift < 0) - iova >>= -shift; - else - iova <<= shift; - - iova |= orval; + uint64_t iova = __reloc_iova(bo, offset, orval, shift); +#if FD_BO_NO_HARDPIN + uint64_t *cur = (uint64_t *)ring->cur; + *cur = iova; + ring->cur += 2; + fd_ringbuffer_attach_bo(ring, bo); +#else struct fd_reloc reloc = { .bo = bo, .iova = iova, @@ -319,6 +333,7 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t offset, }; fd_ringbuffer_reloc(ring, &reloc); +#endif } static inline void diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blend.c b/src/gallium/drivers/freedreno/a6xx/fd6_blend.c index e62d1a863e5..6d5c8969742 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blend.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blend.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_blend.h" #include "util/u_dual_blend.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 1c01a4ad02a..bc9c75849bc 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "util/format_srgb.h" #include "util/half_float.h" #include "util/u_dump.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c index f8f5648b2d2..774e1603cb6 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c @@ -24,6 +24,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_dump.h" #include "u_tracepoints.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_const.c b/src/gallium/drivers/freedreno/a6xx/fd6_const.c index 868d2268217..559a5fd98d0 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_const.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_const.c @@ -22,6 +22,8 @@ * SOFTWARE. */ +#define FD_BO_NO_HARDPIN 1 + #include "fd6_const.h" #include "fd6_pack.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_context.c b/src/gallium/drivers/freedreno/a6xx/fd6_context.c index af001e36739..179d7992893 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_context.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_context.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "freedreno_query_acc.h" #include "freedreno_state.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c index a61af126240..fbcddd78b54 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_prim.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c index 014f1c7e71d..348bb8ea71b 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/format/u_format.h" #include "util/u_helpers.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c index 74b7dbdebb4..ad8250924f3 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include #include "pipe/p_state.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index 64a2ca2e650..9ffbd83a5fe 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "freedreno_resource.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_pack.h b/src/gallium/drivers/freedreno/a6xx/fd6_pack.h index ada71da2e4a..f6d1fbf092a 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_pack.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_pack.h @@ -50,6 +50,10 @@ struct fd_reg_pair { } \ } while (0) +#if !FD_BO_NO_HARDPIN +# error 'Hardpin unsupported' +#endif + #define __ONE_REG(i, ...) \ do { \ const struct fd_reg_pair regs[] = {__VA_ARGS__}; \ @@ -57,10 +61,11 @@ struct fd_reg_pair { if (i < ARRAY_SIZE(regs) && (i == 0 || regs[i].reg > 0)) { \ __assert_eq(regs[0].reg + i, regs[i].reg); \ if (regs[i].bo) { \ - ring->cur = p; \ + uint64_t *p64 = (uint64_t *)p; \ + *p64 = __reloc_iova(regs[i].bo, regs[i].bo_offset, regs[i].value, \ + regs[i].bo_shift); \ p += 2; \ - OUT_RELOC(ring, regs[i].bo, regs[i].bo_offset, regs[i].value, \ - regs[i].bo_shift); \ + fd_ringbuffer_attach_bo(ring, regs[i].bo); \ } else { \ *p++ = regs[i].value; \ if (regs[i].is_address) \ diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_program.c b/src/gallium/drivers/freedreno/a6xx/fd6_program.c index c0125ef1c03..dcc3f710132 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_program.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_program.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/bitset.h" #include "util/format/u_format.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_query.c b/src/gallium/drivers/freedreno/a6xx/fd6_query.c index 5343690c90e..15af1a5dc98 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_query.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_query.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + /* NOTE: see https://gitlab.freedesktop.org/freedreno/freedreno/-/wikis/A5xx-Queries */ #include "freedreno_query_acc.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c b/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c index 6f42dad6558..80c6e9e66c5 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_string.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c index f13ef134f81..34eab33a62e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "drm-uapi/drm_fourcc.h" #include "fd6_resource.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_screen.c b/src/gallium/drivers/freedreno/a6xx/fd6_screen.c index 86f9ad42139..94b3a5eb570 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_screen.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_screen.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "drm-uapi/drm_fourcc.h" #include "pipe/p_screen.h" #include "util/format/u_format.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index 72551513738..ce80d50dd40 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/format/u_format.h" #include "util/hash_table.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c b/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c index f419b939a38..caa8f8b346e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c @@ -21,6 +21,8 @@ * SOFTWARE. */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_prim.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c b/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c index a00ad61c403..5f99822b790 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_string.h"