agc: encode acquire-memory byte ranges in standard packets

This commit is contained in:
nmzik
2026-10-15 23:34:42 +02:00
parent c8caa27936
commit a5ceb48184
6 changed files with 75 additions and 68 deletions
@@ -231,7 +231,6 @@ constexpr auto MakeCustomOpcodeDispatchTable() {
g_cp_op_custom_func[Pm4::R_WAIT_FLIP_DONE] = CpOpWaitFlipDone;
g_cp_op_custom_func[Pm4::R_PUSH_MARKER] = CpOpPushMarker;
g_cp_op_custom_func[Pm4::R_POP_MARKER] = CpOpPopMarker;
g_cp_op_custom_func[Pm4::R_ACQUIRE_MEM] = CpOpAcquireMem;
g_cp_op_custom_func[Pm4::R_FLIP] = CpOpFlip;
g_cp_op_custom_func[Pm4::R_RELEASE_MEM] = CpOpReleaseMem;
g_cp_op_custom_func[Pm4::R_CONTEXT_STATE] = CpOpContextState;
@@ -1290,8 +1290,8 @@ KYTY_HW_UC_PARSER(HwUcSetGdsOaRegisters) {
KYTY_CP_OP_PARSER(CpOpAcquireMem) {
KYTY_PROFILER_FUNCTION();
EXIT_NOT_IMPLEMENTED(cmd_id != 0xC0055800 && cmd_id != 0xc0061050);
return (cmd_id == 0xc0061050 ? 7 : 6);
EXIT_NOT_IMPLEMENTED(cmd_id != 0xc0055800 && cmd_id != 0xc0065800);
return KYTY_PM4_LEN(cmd_id) - 1;
}
KYTY_CP_OP_PARSER(CpOpDispatchDirect) {
-1
View File
@@ -23,7 +23,6 @@ constexpr auto MakeRegisterNames() {
names[R_DISPATCH_RESET] = "R_DISPATCH_RESET";
names[R_PUSH_MARKER] = "R_PUSH_MARKER";
names[R_POP_MARKER] = "R_POP_MARKER";
names[R_ACQUIRE_MEM] = "R_ACQUIRE_MEM";
names[R_WRITE_DATA] = "R_WRITE_DATA";
names[R_FLIP] = "R_FLIP";
names[R_RELEASE_MEM] = "R_RELEASE_MEM";
-1
View File
@@ -86,7 +86,6 @@ constexpr uint32_t R_WAIT_FLIP_DONE = 0x06;
constexpr uint32_t R_DISPATCH_RESET = 0x09;
constexpr uint32_t R_PUSH_MARKER = 0x0B;
constexpr uint32_t R_POP_MARKER = 0x0C;
constexpr uint32_t R_ACQUIRE_MEM = 0x14;
constexpr uint32_t R_WRITE_DATA = 0x15;
constexpr uint32_t R_FLIP = 0x17;
constexpr uint32_t R_RELEASE_MEM = 0x18;
+13 -39
View File
@@ -3022,39 +3022,8 @@ uint32_t* KYTY_SYSV_ABI AgcDcbAcquireMem(CommandBuffer* buf, uint8_t engine, uin
engine, cb_db_op, gcr_cntl, reinterpret_cast<uint64_t>(base), size_bytes, poll_cycles);
}
bool no_size = (static_cast<int64_t>(size_bytes) == -1);
auto vaddr = reinterpret_cast<uint64_t>(base);
EXIT_NOT_IMPLEMENTED(buf == nullptr);
static std::atomic<uint32_t> warning_log_count {0};
const bool log_warning = (warning_log_count.fetch_add(1) < 64);
if (!no_size && (size_bytes & 0xffu) != 0) {
if (log_warning) {
LOGF_COLOR(Log::Color::Red, "\t warning: size_bytes is not 256-byte aligned\n");
}
}
if (!no_size && (size_bytes >> 40u) != 0) {
if (log_warning) {
LOGF_COLOR(Log::Color::Red, "\t warning: size_bytes is too large\n");
}
}
if ((vaddr & 0xffu) != 0) {
if (log_warning) {
LOGF_COLOR(Log::Color::Red, "\t warning: base is not 256-byte aligned\n");
}
}
if ((vaddr >> 40u) != 0) {
if (log_warning) {
LOGF_COLOR(Log::Color::Red, "\t warning: base is too high\n");
}
}
if (engine > 1) {
if (log_warning) {
LOGF_COLOR(Log::Color::Red, "\t warning: unsupported engine 0x%02" PRIx8 "\n", engine);
}
}
auto* cmd = buf->AllocateDW(8);
if (cmd == nullptr) {
@@ -3062,14 +3031,19 @@ uint32_t* KYTY_SYSV_ABI AgcDcbAcquireMem(CommandBuffer* buf, uint8_t engine, uin
return nullptr;
}
cmd[0] = KYTY_PM4(8, Pm4::IT_NOP, Pm4::R_ACQUIRE_MEM);
cmd[1] = (static_cast<uint32_t>(engine & 1u) << 31u) | cb_db_op;
cmd[2] = (no_size ? 0 : static_cast<uint32_t>(size_bytes >> 8u));
cmd[3] = 0;
constexpr uint64_t address_mask = 0xffffffffffffull;
const auto vaddr = reinterpret_cast<uint64_t>(base);
// Cover the byte range in 256-byte units, bounded by the 48-bit address space.
const auto size = std::min((((vaddr & 0xffu) + size_bytes) & address_mask) + 0xffu,
(address_mask & ~uint64_t {0xff}) - vaddr) >> 8u;
cmd[0] = KYTY_PM4(8, Pm4::IT_ACQUIRE_MEM, 0u);
cmd[1] = (static_cast<uint32_t>(engine) << 31u) | (cb_db_op & 0x06007fc0u);
cmd[2] = static_cast<uint32_t>(size);
cmd[3] = static_cast<uint32_t>((size >> 32u) & 0xffu);
cmd[4] = static_cast<uint32_t>(vaddr >> 8u);
cmd[5] = 0;
cmd[6] = poll_cycles / 40;
cmd[7] = gcr_cntl;
cmd[5] = static_cast<uint32_t>(vaddr >> 40u);
cmd[6] = std::min(poll_cycles >> 4u, 0xffffu);
cmd[7] = gcr_cntl & 0x7ffffu;
return cmd;
}
@@ -3083,7 +3057,7 @@ uint32_t KYTY_SYSV_ABI AgcDcbAcquireMemGetSize() {
uint32_t* KYTY_SYSV_ABI AgcAcbAcquireMem(CommandBuffer* buf, uint32_t gcr_cntl,
const volatile void* base, uint64_t size_bytes,
uint32_t poll_cycles) {
return AgcDcbAcquireMem(buf, 1, 0, gcr_cntl, base, size_bytes, poll_cycles);
return AgcDcbAcquireMem(buf, 0, 0, gcr_cntl, base, size_bytes, poll_cycles);
}
uint32_t KYTY_SYSV_ABI AgcAcbAcquireMemGetSize() {