mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-23 03:00:37 +02:00
freedreno/drm: Inline iova calculation
The shift/or are frequently zero, so this lets the compiler optimize out some draw-overhead hotpath. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9581>
This commit is contained in:
parent
93d5349fa5
commit
b5e1e99da1
4 changed files with 19 additions and 22 deletions
|
|
@ -163,6 +163,7 @@ fd_ringbuffer_emit(struct fd_ringbuffer *ring,
|
|||
|
||||
struct fd_reloc {
|
||||
struct fd_bo *bo;
|
||||
uint64_t iova;
|
||||
#define FD_RELOC_READ 0x0001
|
||||
#define FD_RELOC_WRITE 0x0002
|
||||
#define FD_RELOC_DUMP 0x0004
|
||||
|
|
@ -247,8 +248,19 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
|
|||
(uint32_t)(ring->cur - ring->start), bo, offset, shift);
|
||||
}
|
||||
debug_assert(offset < fd_bo_size(bo));
|
||||
|
||||
uint64_t iova = fd_bo_get_iova(bo) + offset;
|
||||
|
||||
if (shift < 0)
|
||||
iova >>= -shift;
|
||||
else
|
||||
iova <<= shift;
|
||||
|
||||
iova |= or;
|
||||
|
||||
fd_ringbuffer_reloc(ring, &(struct fd_reloc){
|
||||
.bo = bo,
|
||||
.iova = iova,
|
||||
.offset = offset,
|
||||
.or = or,
|
||||
.shift = shift,
|
||||
|
|
|
|||
|
|
@ -573,6 +573,7 @@ msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
|
|||
|
||||
msm_ringbuffer_emit_reloc(ring, &(struct fd_reloc){
|
||||
.bo = bo,
|
||||
.iova = bo->iova + msm_target->offset,
|
||||
.offset = msm_target->offset,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -35,21 +35,9 @@
|
|||
static void
|
||||
X(emit_reloc_common)(struct fd_ringbuffer *ring, const struct fd_reloc *reloc)
|
||||
{
|
||||
uint64_t iova = reloc->bo->iova + reloc->offset;
|
||||
int shift = reloc->shift;
|
||||
|
||||
if (shift < 0)
|
||||
iova >>= -shift;
|
||||
else
|
||||
iova <<= shift;
|
||||
|
||||
uint32_t dword = iova;
|
||||
|
||||
(*ring->cur++) = dword | reloc->or;
|
||||
|
||||
(*ring->cur++) = (uint32_t)reloc->iova;
|
||||
#if PTRSZ == 64
|
||||
dword = iova >> 32;
|
||||
(*ring->cur++) = dword | reloc->orhi;
|
||||
(*ring->cur++) = (uint32_t)(reloc->iova >> 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -117,11 +105,13 @@ X(msm_ringbuffer_sp_emit_reloc_ring)(struct fd_ringbuffer *ring,
|
|||
if (ring->flags & _FD_RINGBUFFER_OBJECT) {
|
||||
X(msm_ringbuffer_sp_emit_reloc_obj)(ring, &(struct fd_reloc){
|
||||
.bo = bo,
|
||||
.iova = bo->iova + msm_target->offset,
|
||||
.offset = msm_target->offset,
|
||||
});
|
||||
} else {
|
||||
X(msm_ringbuffer_sp_emit_reloc_nonobj)(ring, &(struct fd_reloc){
|
||||
.bo = bo,
|
||||
.iova = bo->iova + msm_target->offset,
|
||||
.offset = msm_target->offset,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,16 +56,10 @@ 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) { \
|
||||
struct fd_reloc reloc = { \
|
||||
.bo = regs[i].bo, \
|
||||
.offset = regs[i].bo_offset, \
|
||||
.or = regs[i].value, \
|
||||
.shift = regs[i].bo_shift, \
|
||||
.orhi = regs[i].value >> 32 \
|
||||
}; \
|
||||
ring->cur = p; \
|
||||
p += 2; \
|
||||
fd_ringbuffer_reloc(ring, &reloc); \
|
||||
OUT_RELOC(ring, regs[i].bo, regs[i].bo_offset, \
|
||||
regs[i].value, regs[i].bo_shift); \
|
||||
} else { \
|
||||
*p++ = regs[i].value; \
|
||||
if (regs[i].is_address) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue