diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp index 2decb78c..95d3ab53 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp @@ -30,16 +30,19 @@ namespace skyline::soc::gm20b::engine { }) ENGINE_STRUCT_CASE(semaphore, action, { + u64 address{registers.semaphore->address}; + // Write timestamp first to ensure ordering if (action.releaseSize == Registers::Semaphore::ReleaseSize::SixteenBytes) { - channelCtx.asCtx->gmmu.Write(registers.semaphore->address + 4, 0); - channelCtx.asCtx->gmmu.Write(registers.semaphore->address + 8, GetGpuTimeTicks()); + channelCtx.asCtx->gmmu.Write(address + 4, 0); + channelCtx.asCtx->gmmu.Write(address + 8, GetGpuTimeTicks()); } if (action.operation == Registers::Semaphore::Operation::Release) { - channelCtx.asCtx->gmmu.Write(registers.semaphore->address, registers.semaphore->payload); + channelCtx.asCtx->gmmu.Write(address, registers.semaphore->payload); + Logger::Debug("SemaphoreRelease: address: 0x{:X} payload: {}", address, registers.semaphore->payload); } else if (action.operation == Registers::Semaphore::Operation::Reduction) { - u32 origVal{channelCtx.asCtx->gmmu.Read(registers.semaphore->address)}; + u32 origVal{channelCtx.asCtx->gmmu.Read(address)}; bool isSigned{action.format == Registers::Semaphore::Format::Signed}; // https://github.com/NVIDIA/open-gpu-doc/blob/b7d1bd16fe62135ebaec306b39dfdbd9e5657827/manuals/turing/tu104/dev_pbdma.ref.txt#L3549 @@ -72,8 +75,10 @@ namespace skyline::soc::gm20b::engine { return (origVal == 0 || origVal > payload) ? payload : origVal - 1; } }(registers.semaphore->action.reduction, origVal, registers.semaphore->payload, isSigned)}; + Logger::Debug("SemaphoreReduction: address: 0x{:X} op: {} payload: {} original value: {} reduced value: {}", + address, static_cast(registers.semaphore->action.reduction), registers.semaphore->payload, origVal, val); - channelCtx.asCtx->gmmu.Write(registers.semaphore->address, val); + channelCtx.asCtx->gmmu.Write(address, val); } else { Logger::Warn("Unimplemented semaphore operation: 0x{:X}", static_cast(registers.semaphore->action.operation)); } diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp index 6462a0ff..b1ef1b3f 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp @@ -754,15 +754,21 @@ namespace skyline::soc::gm20b::engine::maxwell3d { } void Maxwell3D::WriteSemaphoreResult(u64 result) { + u64 address{registers.semaphore->address}; + switch (registers.semaphore->info.structureSize) { case type::SemaphoreInfo::StructureSize::OneWord: - channelCtx.asCtx->gmmu.Write(registers.semaphore->address, static_cast(result)); + channelCtx.asCtx->gmmu.Write(address, static_cast(result)); + Logger::Debug("address: 0x{:X} payload: {}", address, result); break; case type::SemaphoreInfo::StructureSize::FourWords: { // Write timestamp first to ensure correct ordering - channelCtx.asCtx->gmmu.Write(registers.semaphore->address + 8, GetGpuTimeTicks()); - channelCtx.asCtx->gmmu.Write(registers.semaphore->address, result); + u64 timestamp{GetGpuTimeTicks()}; + channelCtx.asCtx->gmmu.Write(address + 8, timestamp); + channelCtx.asCtx->gmmu.Write(address, result); + Logger::Debug("address: 0x{:X} payload: {} timestamp: {}", address, result, timestamp); + break; } } diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_dma.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_dma.cpp index 1c83c74c..67e8a804 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_dma.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_dma.cpp @@ -61,15 +61,21 @@ namespace skyline::soc::gm20b::engine { if (registers.launchDma->reductionEnable) Logger::Warn("Semaphore reduction is unimplemented!"); + u64 address{registers.semaphore->address}; + u64 payload{registers.semaphore->payload}; switch (registers.launchDma->semaphoreType) { case Registers::LaunchDma::SemaphoreType::ReleaseOneWordSemaphore: - channelCtx.asCtx->gmmu.Write(registers.semaphore->address, registers.semaphore->payload); + channelCtx.asCtx->gmmu.Write(address, registers.semaphore->payload); + Logger::Debug("address: 0x{:X} payload: {}", address, payload); break; - case Registers::LaunchDma::SemaphoreType::ReleaseFourWordSemaphore: + case Registers::LaunchDma::SemaphoreType::ReleaseFourWordSemaphore: { // Write timestamp first to ensure correct ordering - channelCtx.asCtx->gmmu.Write(registers.semaphore->address + 8, GetGpuTimeTicks()); - channelCtx.asCtx->gmmu.Write(registers.semaphore->address, static_cast(registers.semaphore->payload)); + u64 timestamp{GetGpuTimeTicks()}; + channelCtx.asCtx->gmmu.Write(address + 8, timestamp); + channelCtx.asCtx->gmmu.Write(address, static_cast(payload)); + Logger::Debug("address: 0x{:X} payload: {} timestamp: {}", address, payload, timestamp); break; + } default: break; }