From 5c3559e888b39c2e610742b28010a2c7748a3acd Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 17 Apr 2022 16:03:27 +0100 Subject: [PATCH] Revert "Implement support for GPU-side constant buffer updating" This reverts commit d79635772f025632bf5848987bca813a04d36631. --- app/src/main/cpp/skyline/gpu/buffer.cpp | 10 +++++----- app/src/main/cpp/skyline/gpu/buffer.h | 6 ++---- .../cpp/skyline/gpu/interconnect/graphics_context.h | 12 +----------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/buffer.cpp b/app/src/main/cpp/skyline/gpu/buffer.cpp index de081a76..4098e049 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.cpp +++ b/app/src/main/cpp/skyline/gpu/buffer.cpp @@ -45,7 +45,7 @@ namespace skyline::gpu { } void Buffer::MarkGpuDirty() { - if (dirtyState == DirtyState::GpuDirty || !guest) { + if (dirtyState == DirtyState::GpuDirty || !guest) return; gpu.state.nce->RetrapRegions(*trapHandle, false); dirtyState = DirtyState::GpuDirty; @@ -145,10 +145,10 @@ namespace skyline::gpu { std::memcpy(data.data(), backing.data() + offset, data.size()); } - void Buffer::Write(span data, vk::DeviceSize offset, bool skipCleanHostWrite) { + void Buffer::Write(span data, vk::DeviceSize offset) { if (dirtyState == DirtyState::CpuDirty || dirtyState == DirtyState::Clean) std::memcpy(mirror.data() + offset, data.data(), data.size()); - if ((!skipCleanHostWrite && dirtyState == DirtyState::Clean) || dirtyState == DirtyState::GpuDirty) + if (dirtyState == DirtyState::GpuDirty || dirtyState == DirtyState::Clean) std::memcpy(backing.data() + offset, data.data(), data.size()); } @@ -234,7 +234,7 @@ namespace skyline::gpu { bufferDelegate->buffer->Read(data, offset + bufferDelegate->view->offset); } - void BufferView::Write(span data, vk::DeviceSize offset, bool skipCleanHostWrite) const { - bufferDelegate->buffer->Write(data, offset + bufferDelegate->view->offset, skipCleanHostWrite); + void BufferView::Write(span data, vk::DeviceSize offset) const { + bufferDelegate->buffer->Write(data, offset + bufferDelegate->view->offset); } } diff --git a/app/src/main/cpp/skyline/gpu/buffer.h b/app/src/main/cpp/skyline/gpu/buffer.h index c1ba6632..b9a7b9d4 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.h +++ b/app/src/main/cpp/skyline/gpu/buffer.h @@ -171,9 +171,8 @@ namespace skyline::gpu { /** * @brief Writes data at the specified offset in the buffer - * @param skipCleanHostWrite Skip writing to the host buffer if it's clean, assumes the buffer data will be synchronised externally */ - void Write(span data, vk::DeviceSize offset, bool skipCleanHostWrite = false); + void Write(span data, vk::DeviceSize offset); /** * @return A cached or newly created view into this buffer with the supplied attributes @@ -251,8 +250,7 @@ namespace skyline::gpu { /** * @brief Writes data at the specified offset in the view * @note The view **must** be locked prior to calling this - * @param skipCleanHostWrite Skip writing to the host buffer if it's clean, assumes the buffer data will be synchronised externally */ - void Write(span data, vk::DeviceSize offset, bool skipCleanHostWrite = false) const; + void Write(span data, vk::DeviceSize offset) const; }; } diff --git a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h index 5f7c86c1..49aceaf9 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -631,7 +631,7 @@ namespace skyline::gpu::interconnect { template void Write(span buf, size_t offset) { std::scoped_lock lock{view}; - view.Write(buf.template cast(), offset, true); + view.Write(buf.template cast(), offset); } }; ConstantBuffer constantBufferSelector; //!< The constant buffer selector is used to bind a constant buffer to a stage or update data in it @@ -700,11 +700,6 @@ namespace skyline::gpu::interconnect { if (!view) { auto mappings{channelCtx.asCtx->gmmu.TranslateRange(constantBufferSelector.iova, constantBufferSelector.size)}; view = gpu.buffer.FindOrCreate(mappings.front(), executor.cycle); - { - std::scoped_lock lock{*view}; - view->bufferDelegate->buffer->SynchronizeHost(false); - } - constantBufferCache.Insert(constantBufferSelector.size, constantBufferSelector.iova, *view); } @@ -715,11 +710,6 @@ namespace skyline::gpu::interconnect { void ConstantBufferUpdate(std::vector data, u32 offset) { auto constantBuffer{GetConstantBufferSelector().value()}; constantBuffer.Write(data, offset); - - executor.AddOutsideRpCommand([constantBufferView = constantBuffer.view, data = std::move(data), offset](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr &cycle, GPU &) { - std::scoped_lock lock{constantBufferView}; - commandBuffer.updateBuffer(constantBufferView->buffer->GetBacking(), constantBufferView->view->offset + offset, vk::ArrayProxy(static_cast(data.size()), data.data())); - }); } /* Shader Program */