From a9213debc7aebfba75827a71fcf15a8c1e091104 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 17 Sep 2022 13:10:01 +0100 Subject: [PATCH] Implement constant buffer reading --- .../interconnect/maxwell_3d/constant_buffers.cpp | 15 ++++++++++----- .../interconnect/maxwell_3d/constant_buffers.h | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp index 0dff81ba..6aa7d523 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp @@ -24,17 +24,22 @@ namespace skyline::gpu::interconnect::maxwell3d { view.PurgeCaches(); } + static void FlushHostCallback() { + // TODO: here we should trigger `Execute()`, however that doesn't currently work due to Read being called mid-draw and attached objects not handling this case + Logger::Warn("GPU dirty buffer reads for attached buffers are unimplemented"); + } + + void ConstantBuffer::Read(CommandExecutor &executor, span dstBuffer, size_t srcOffset) { + ContextLock lock{executor.tag, view}; + view.Read(lock.IsFirstUsage(), FlushHostCallback, dstBuffer, srcOffset); + } + ConstantBuffers::ConstantBuffers(DirtyManager &manager, const ConstantBufferSelectorState::EngineRegisters &constantBufferSelectorRegisters) : selectorState{manager, constantBufferSelectorRegisters} {} void ConstantBuffers::MarkAllDirty() { selectorState.MarkDirty(true); } - static void FlushHostCallback() { - // TODO: here we should trigger `Execute()`, however that doesn't currently work due to Read being called mid-draw and attached objects not handling this case - Logger::Warn("GPU dirty buffer reads for attached buffers are unimplemented"); - } - void ConstantBuffers::Load(InterconnectContext &ctx, span data, u32 offset) { auto &view{*selectorState.UpdateGet(ctx).view}; auto srcCpuBuf{data.cast()}; diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h index cda23b9f..91623139 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.h @@ -30,10 +30,10 @@ namespace skyline::gpu::interconnect::maxwell3d { struct ConstantBuffer { BufferView view; - void Read(CommandExecutor &executor, span dstBuffer, size_t srcOffset) const; + void Read(CommandExecutor &executor, span dstBuffer, size_t srcOffset); template - T Read(CommandExecutor &executor, size_t srcOffset) const { + T Read(CommandExecutor &executor, size_t srcOffset) { T object; Read(executor, span{object}.template cast(), srcOffset); return object;