freedreno/cffdump: Emulate RMW

Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38001>
This commit is contained in:
Karmjit Mahil 2025-10-24 11:32:37 +01:00 committed by Marge Bot
parent 265aa40a8a
commit b86ca63853
3 changed files with 73 additions and 17 deletions

View file

@ -2653,15 +2653,18 @@ cp_mem_write(uint32_t *dwords, uint32_t sizedwords, int level)
static void
cp_rmw(uint32_t *dwords, uint32_t sizedwords, int level)
{
uint32_t val = dwords[0] & 0xffff;
uint32_t and = dwords[1];
uint32_t or = dwords[2];
printl(3, "%srmw (%s & 0x%08x) | 0x%08x)\n", levels[level], regname(val, 1),
and, or);
struct rnndomain *domain;
const char *str;
domain = rnn_finddomain(rnn->db, "CP_REG_RMW");
str = internal_packet(dwords, sizedwords, rnn, domain);
printl(3, "%srmw %s", levels[level], str);
if (needs_wfi)
printl(2, "NEEDS WFI: rmw (%s & 0x%08x) | 0x%08x)\n", regname(val, 1),
and, or);
reg_set(val, (reg_val(val) & and) | or);
printl(2, "NEEDS WFI: rmw %s", str);
free((void *)str);
}
static void

View file

@ -1,3 +1,56 @@
-- SPDX-License-Identifier: MIT
-- `r` is predefined in the environment and is the equivalent of rnn.init(<gpu>)
function CP_REG_RMW(pkt, size)
local dst_reg = pkt[0].DST_REG
local dst_scratch = pkt[0].DST_SCRATCH
local rotate = pkt[0].ROTATE
local src1_add = pkt[0].SRC1_ADD
local src1_is_reg = pkt[0].SRC1_IS_REG
local src0_is_reg = pkt[0].SRC0_IS_REG
local src0 = pkt[1].SRC0
local src1 = pkt[2].SRC1
local dst = regs.val(dst_reg)
local dst_reg_str = string.format("%s", rnn.regname(r, dst_reg))
if dst_scratch then
dst_reg_str = string.format("CP_SCRATCH[%s]", dst_reg)
end
local src0_str = string.format("0x%08x", src0)
if src0_is_reg then
src0_str = string.format("%s", rnn.regname(r, src0))
src0 = regs.val(src0)
end
local src1_str = string.format("0x%08x", src1)
if src1_is_reg then
src1_str = string.format("%s", rnn.regname(r, src1))
src1 = regs.val(src1)
end
local result = dst & src0
result = (result << rotate) | result >> (32 - rotate)
local op_str
if src1_add then
op_str = '+'
result = result + src1
else
op_str = '|'
result = result | src1
end
result = (dst &~ 0xFFFFFFFF) | result & 0xFFFFFFFF
if dst_scratch then
io.stderr:write("WARNING: Write to CP_SCRATCH is not emulated.")
else
priv.reg_set(dst_reg, result)
end
return string.format("%s = ((%s & %s) rot_l %d) %s %s\n",
dst_reg_str, dst_reg_str, src0_str, rotate,
op_str, src1_str)
end

View file

@ -224,7 +224,7 @@ cmdstream[0]: 488 dwords
{ DST_REG = 0x20c1 | ROTATE = 0 }
{ SRC0 = 4294955023 }
{ SRC1 = 8272 }
rmw (RB_RENDER_CONTROL & 0xffffd00f) | 0x00002050)
rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0xffffd00f) rot_l 0) | 0x00002050
118488f4: 0000: c0022100 000020c1 ffffd00f 00002050
write RB_WINDOW_OFFSET (210e)
RB_WINDOW_OFFSET: { X = 0 | Y = 0 }
@ -263,7 +263,7 @@ cmdstream[0]: 488 dwords
{ DST_REG = 0x20c1 | ROTATE = 0 }
{ SRC0 = 12272 }
{ SRC1 = 0 }
rmw (RB_RENDER_CONTROL & 0x00002ff0) | 0x00000000)
rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0x00002ff0) rot_l 0) | 0x00000000
118423a8: 0000: c0022100 000020c1 00002ff0 00000000
write RB_DEPTH_CONTROL (2100)
RB_DEPTH_CONTROL: { Z_TEST_ENABLE | Z_WRITE_ENABLE | ZFUNC = FUNC_ALWAYS }
@ -621,7 +621,7 @@ NEEDS WFI: CP_SCRATCH_REG7 (57f)
{ DST_REG = 0x20c1 | ROTATE = 0 }
{ SRC0 = 12272 }
{ SRC1 = 0 }
rmw (RB_RENDER_CONTROL & 0x00002ff0) | 0x00000000)
rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0x00002ff0) rot_l 0) | 0x00000000
118425b0: 0000: c0022100 000020c1 00002ff0 00000000
write RB_ALPHA_REF (20c3)
RB_ALPHA_REF: { UINT = 0 | FLOAT = 0.000000 }
@ -14477,8 +14477,8 @@ NEEDS WFI: CP_SCRATCH_REG6 (57e)
{ DST_REG = 0x20c1 | ROTATE = 0 }
{ SRC0 = 12272 }
{ SRC1 = 4096 }
rmw (RB_RENDER_CONTROL & 0x00002ff0) | 0x00001000)
NEEDS WFI: rmw (RB_RENDER_CONTROL & 0x00002ff0) | 0x00001000)
rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0x00002ff0) rot_l 0) | 0x00001000
NEEDS WFI: rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0x00002ff0) rot_l 0) | 0x00001000
11848984: 0000: c0022100 000020c1 00002ff0 00001000
write GRAS_SC_CONTROL (2072)
GRAS_SC_CONTROL: { RENDER_MODE = RB_RESOLVE_PASS | MSAA_SAMPLES = MSAA_ONE | RASTER_MODE = 0x1 }
@ -14758,8 +14758,8 @@ NEEDS WFI: RB_FRAME_BUFFER_DIMENSION (ce0)
{ DST_REG = 0x20c1 | ROTATE = 0 }
{ SRC0 = 4294955023 }
{ SRC1 = 8272 }
rmw (RB_RENDER_CONTROL & 0xffffd00f) | 0x00002050)
NEEDS WFI: rmw (RB_RENDER_CONTROL & 0xffffd00f) | 0x00002050)
rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0xffffd00f) rot_l 0) | 0x00002050
NEEDS WFI: rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0xffffd00f) rot_l 0) | 0x00002050
11848bb4: 0000: c0022100 000020c1 ffffd00f 00002050
write RB_WINDOW_OFFSET (210e)
RB_WINDOW_OFFSET: { X = 160 | Y = 0 }
@ -14813,8 +14813,8 @@ NEEDS WFI: CP_SCRATCH_REG6 (57e)
{ DST_REG = 0x20c1 | ROTATE = 0 }
{ SRC0 = 12272 }
{ SRC1 = 4096 }
rmw (RB_RENDER_CONTROL & 0x00002ff0) | 0x00001000)
NEEDS WFI: rmw (RB_RENDER_CONTROL & 0x00002ff0) | 0x00001000)
rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0x00002ff0) rot_l 0) | 0x00001000
NEEDS WFI: rmw RB_RENDER_CONTROL = ((RB_RENDER_CONTROL & 0x00002ff0) rot_l 0) | 0x00001000
11848c44: 0000: c0022100 000020c1 00002ff0 00001000
write GRAS_SC_CONTROL (2072)
GRAS_SC_CONTROL: { RENDER_MODE = RB_RESOLVE_PASS | MSAA_SAMPLES = MSAA_ONE | RASTER_MODE = 0x1 }