From 4746f514ffdee75f5ada963f41f7a11e7b5b8591 Mon Sep 17 00:00:00 2001 From: psucien Date: Wed, 8 May 2024 22:53:55 +0200 Subject: [PATCH] gnm_driver: various fixes --- src/core/libraries/gnmdriver/gnmdriver.cpp | 32 +++++++++++----------- src/video_core/amdgpu/pm4_cmds.h | 19 ++++++++----- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/core/libraries/gnmdriver/gnmdriver.cpp b/src/core/libraries/gnmdriver/gnmdriver.cpp index 85b59bcb..ddd96cea 100644 --- a/src/core/libraries/gnmdriver/gnmdriver.cpp +++ b/src/core/libraries/gnmdriver/gnmdriver.cpp @@ -238,7 +238,7 @@ u32 PS4_SYSV_ABI sceGnmDispatchInitDefaultHardwareState(u32* cmdbuf, u32 size) { cmdbuf = WriteHeader(cmdbuf, 0xef); cmdbuf = WriteBody(cmdbuf, 0xau, 0u); } else { - cmdbuf = cmdbuf = WriteHeader(cmdbuf, 0x100); + cmdbuf = cmdbuf = WriteHeader(cmdbuf, 0xff); } return 0x100; // it is a size, not a retcode } @@ -347,7 +347,7 @@ u32 PS4_SYSV_ABI sceGnmDrawInitDefaultHardwareState200(u32* cmdbuf, u32 size) { if constexpr (g_fair_hw_init) { ASSERT_MSG(0, "Not implemented"); } else { - cmdbuf = cmdbuf = WriteHeader(cmdbuf, 0x100); + cmdbuf = cmdbuf = WriteHeader(cmdbuf, 0xff); } return 0x100; // it is a size, not a retcode } @@ -361,7 +361,7 @@ u32 PS4_SYSV_ABI sceGnmDrawInitDefaultHardwareState350(u32* cmdbuf, u32 size) { if constexpr (g_fair_hw_init) { ASSERT_MSG(0, "Not implemented"); } else { - cmdbuf = cmdbuf = WriteHeader(cmdbuf, 0x100); + cmdbuf = cmdbuf = WriteHeader(cmdbuf, 0xff); } return 0x100; // it is a size, not a retcode } @@ -591,9 +591,9 @@ s32 PS4_SYSV_ABI sceGnmInsertPopMarker(u32* cmdbuf, u32 size) { LOG_TRACE(Lib_GnmDriver, "called"); if (cmdbuf && (size == 6)) { - cmdbuf = WritePacket( - cmdbuf, PM4ShaderType::ShaderGraphics, - static_cast(PM4CmdNop::PayloadType::DebugMarkerPop), 0u, 0u, 0u, 0u); + cmdbuf = + WritePacket(cmdbuf, PM4ShaderType::ShaderGraphics, + PM4CmdNop::PayloadType::DebugMarkerPop, 0u, 0u, 0u, 0u); return ORBIS_OK; } return -1; @@ -614,7 +614,7 @@ s32 PS4_SYSV_ABI sceGnmInsertPushMarker(u32* cmdbuf, u32 size, const char* marke auto* nop = reinterpret_cast(cmdbuf); nop->header = PM4Type3Header{PM4ItOpcode::Nop, packet_size, PM4ShaderType::ShaderGraphics}; - nop->data_block[0] = static_cast(PM4CmdNop::PayloadType::DebugMarkerPush); + nop->data_block[0] = PM4CmdNop::PayloadType::DebugMarkerPush; const auto marker_len = len + 1; std::memcpy(&nop->data_block[1], marker, marker_len); std::memset(reinterpret_cast(&nop->data_block[1]) + marker_len, 0, @@ -650,15 +650,15 @@ s32 PS4_SYSV_ABI sceGnmInsertWaitFlipDone(u32* cmdbuf, u32 size, s32 vo_handle, uintptr_t label_addr{}; VideoOut::sceVideoOutGetBufferLabelAddress(vo_handle, &label_addr); - auto* write_reg_mem = reinterpret_cast(cmdbuf); - write_reg_mem->header = PM4Type3Header{PM4ItOpcode::WaitRegMem, 5}; - write_reg_mem->function.Assign(3u); - write_reg_mem->mem_space.Assign(1u); - *reinterpret_cast(&write_reg_mem->poll_addr_lo) = + auto* wait_reg_mem = reinterpret_cast(cmdbuf); + wait_reg_mem->header = PM4Type3Header{PM4ItOpcode::WaitRegMem, 5}; + wait_reg_mem->function.Assign(3u); + wait_reg_mem->mem_space.Assign(1u); + *reinterpret_cast(&wait_reg_mem->poll_addr_lo) = (label_addr + buf_idx * sizeof(uintptr_t)) & 0xffff'fffcu; - write_reg_mem->ref = 0u; - write_reg_mem->mask = 0xffff'ffffu; - write_reg_mem->poll_interval = 10u; + wait_reg_mem->ref = 0u; + wait_reg_mem->mask = 0xffff'ffffu; + wait_reg_mem->poll_interval = 10u; return ORBIS_OK; } @@ -1311,7 +1311,7 @@ s32 PS4_SYSV_ABI sceGnmSubmitCommandBuffers(u32 count, void* dcb_gpu_addrs[], } } - liverpool->ProcessCmdList(reinterpret_cast(dcb_sizes_in_bytes[0]), dcb_sizes_in_bytes[0]); + liverpool->ProcessCmdList(reinterpret_cast(dcb_gpu_addrs[0]), dcb_sizes_in_bytes[0]); return ORBIS_OK; } diff --git a/src/video_core/amdgpu/pm4_cmds.h b/src/video_core/amdgpu/pm4_cmds.h index eb258dc3..bc60ab8d 100644 --- a/src/video_core/amdgpu/pm4_cmds.h +++ b/src/video_core/amdgpu/pm4_cmds.h @@ -201,13 +201,18 @@ struct PM4CmdNop { PM4Type3Header header; u32 data_block[0]; - enum class PayloadType : u32 { - DebugMarkerPush = 0x68750001, ///< Begin of GPU event scope - DebugMarkerPop = 0x68750002, ///< End of GPU event scope - SetVsharpInUdata = 0x68750004, ///< Indicates that V# will be set in the next packet - SetTsharpInUdata = 0x68750005, ///< Indicates that T# will be set in the next packet - SetSsharpInUdata = 0x68750006, ///< Indicates that S# will be set in the next packet - DebugColorMarkerPush = 0x6875000e, ///< Begin of GPU event scope with color + enum PayloadType : u32 { + DebugMarkerPush = 0x68750001u, ///< Begin of GPU event scope + DebugMarkerPop = 0x68750002u, ///< End of GPU event scope + SetVsharpInUdata = 0x68750004u, ///< Indicates that V# will be set in the next packet + SetTsharpInUdata = 0x68750005u, ///< Indicates that T# will be set in the next packet + SetSsharpInUdata = 0x68750006u, ///< Indicates that S# will be set in the next packet + DebugColorMarkerPush = 0x6875000eu, ///< Begin of GPU event scope with color + PatchedFlip = 0x68750776u, ///< Patched flip marker + PrepareFlip = 0x68750777u, ///< Flip marker + PrepareFlipLabel = 0x68750778u, ///< Flip marker with label address + PrepareFlipInterrupt = 0x68750780u, ///< Flip marker with interrupt + PrepareFlipInterruptLabel = 0x68750781u, ///< Flip marker with interrupt and label }; };