From 06095918a943f3d7bc8036525a8f4932e17d3a29 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 12 Nov 2022 13:58:15 +0000 Subject: [PATCH] Introduce per-channel sequence number for invalidation tracking For cases like shaders, which may be uploaded through I2M (which no longer causes an execution) we need a way to cause an invalidation on all writes --- app/src/main/cpp/skyline/soc/gm20b/channel.cpp | 6 +++++- app/src/main/cpp/skyline/soc/gm20b/channel.h | 1 + app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp | 3 +++ .../main/cpp/skyline/soc/gm20b/engines/inline2memory.cpp | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/soc/gm20b/channel.cpp b/app/src/main/cpp/skyline/soc/gm20b/channel.cpp index 848c10d5..16d30428 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/channel.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/channel.cpp @@ -13,5 +13,9 @@ namespace skyline::soc::gm20b { keplerCompute{state, *this}, inline2Memory{state, *this}, gpfifo{state, *this, numEntries}, - globalChannelLock{state.gpu->channelLock} {} + globalChannelLock{state.gpu->channelLock} { + executor.AddFlushCallback([this] { + channelSequenceNumber++; + }); + } } diff --git a/app/src/main/cpp/skyline/soc/gm20b/channel.h b/app/src/main/cpp/skyline/soc/gm20b/channel.h index b79a60b1..75f73cbd 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/channel.h +++ b/app/src/main/cpp/skyline/soc/gm20b/channel.h @@ -31,6 +31,7 @@ namespace skyline::soc::gm20b { engine::Inline2Memory inline2Memory; ChannelGpfifo gpfifo; std::mutex &globalChannelLock; + size_t channelSequenceNumber{}; ChannelContext(const DeviceState &state, std::shared_ptr asCtx, size_t numEntries); 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 1b760ef2..33477212 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/gpfifo.cpp @@ -26,6 +26,7 @@ namespace skyline::soc::gm20b::engine { // Wait forever for another channel to increment + channelCtx.executor.Submit(); channelCtx.Unlock(); syncpoints.at(action.index).Wait(registers.syncpoint->payload, std::chrono::steady_clock::duration::max()); channelCtx.Lock(); @@ -44,6 +45,7 @@ namespace skyline::soc::gm20b::engine { switch (action.operation) { case Registers::Semaphore::Operation::Acquire: Logger::Debug("Acquire semaphore: 0x{:X} payload: {}", address, registers.semaphore->payload); + channelCtx.executor.Submit(); channelCtx.Unlock(); while (channelCtx.asCtx->gmmu.Read(address) != registers.semaphore->payload) @@ -57,6 +59,7 @@ namespace skyline::soc::gm20b::engine { break; case Registers::Semaphore::Operation::AcqGeq : Logger::Debug("Acquire semaphore: 0x{:X} payload: {}", address, registers.semaphore->payload); + channelCtx.executor.Submit(); channelCtx.Unlock(); while (channelCtx.asCtx->gmmu.Read(address) < registers.semaphore->payload) diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/inline2memory.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/inline2memory.cpp index 130f9744..22aa5e8a 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/inline2memory.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/inline2memory.cpp @@ -21,6 +21,7 @@ namespace skyline::soc::gm20b::engine { if (state.launchDma.layout == RegisterState::DmaDstMemoryLayout::Pitch && state.lineCount == 1) { Logger::Debug("range: 0x{:X} -> 0x{:X}", u64{state.offsetOut}, u64{state.offsetOut} + buffer.size() * 0x4); + channelCtx.channelSequenceNumber++; interconnect.Upload(u64{state.offsetOut}, span{buffer}); } else { channelCtx.executor.Submit();