Revert "Implement support for GPU-side constant buffer updating"

This reverts commit d79635772f.
This commit is contained in:
Billy Laws 2022-04-17 16:03:27 +01:00
parent 7bf3580031
commit 5c3559e888
3 changed files with 8 additions and 20 deletions

View File

@ -45,7 +45,7 @@ namespace skyline::gpu {
} }
void Buffer::MarkGpuDirty() { void Buffer::MarkGpuDirty() {
if (dirtyState == DirtyState::GpuDirty || !guest) { if (dirtyState == DirtyState::GpuDirty || !guest)
return; return;
gpu.state.nce->RetrapRegions(*trapHandle, false); gpu.state.nce->RetrapRegions(*trapHandle, false);
dirtyState = DirtyState::GpuDirty; dirtyState = DirtyState::GpuDirty;
@ -145,10 +145,10 @@ namespace skyline::gpu {
std::memcpy(data.data(), backing.data() + offset, data.size()); std::memcpy(data.data(), backing.data() + offset, data.size());
} }
void Buffer::Write(span<u8> data, vk::DeviceSize offset, bool skipCleanHostWrite) { void Buffer::Write(span<u8> data, vk::DeviceSize offset) {
if (dirtyState == DirtyState::CpuDirty || dirtyState == DirtyState::Clean) if (dirtyState == DirtyState::CpuDirty || dirtyState == DirtyState::Clean)
std::memcpy(mirror.data() + offset, data.data(), data.size()); 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()); std::memcpy(backing.data() + offset, data.data(), data.size());
} }
@ -234,7 +234,7 @@ namespace skyline::gpu {
bufferDelegate->buffer->Read(data, offset + bufferDelegate->view->offset); bufferDelegate->buffer->Read(data, offset + bufferDelegate->view->offset);
} }
void BufferView::Write(span<u8> data, vk::DeviceSize offset, bool skipCleanHostWrite) const { void BufferView::Write(span<u8> data, vk::DeviceSize offset) const {
bufferDelegate->buffer->Write(data, offset + bufferDelegate->view->offset, skipCleanHostWrite); bufferDelegate->buffer->Write(data, offset + bufferDelegate->view->offset);
} }
} }

View File

@ -171,9 +171,8 @@ namespace skyline::gpu {
/** /**
* @brief Writes data at the specified offset in the buffer * @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<u8> data, vk::DeviceSize offset, bool skipCleanHostWrite = false); void Write(span<u8> data, vk::DeviceSize offset);
/** /**
* @return A cached or newly created view into this buffer with the supplied attributes * @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 * @brief Writes data at the specified offset in the view
* @note The view **must** be locked prior to calling this * @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<u8> data, vk::DeviceSize offset, bool skipCleanHostWrite = false) const; void Write(span<u8> data, vk::DeviceSize offset) const;
}; };
} }

View File

@ -631,7 +631,7 @@ namespace skyline::gpu::interconnect {
template<typename T> template<typename T>
void Write(span<T> buf, size_t offset) { void Write(span<T> buf, size_t offset) {
std::scoped_lock lock{view}; std::scoped_lock lock{view};
view.Write(buf.template cast<u8>(), offset, true); view.Write(buf.template cast<u8>(), offset);
} }
}; };
ConstantBuffer constantBufferSelector; //!< The constant buffer selector is used to bind a constant buffer to a stage or update data in it 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) { if (!view) {
auto mappings{channelCtx.asCtx->gmmu.TranslateRange(constantBufferSelector.iova, constantBufferSelector.size)}; auto mappings{channelCtx.asCtx->gmmu.TranslateRange(constantBufferSelector.iova, constantBufferSelector.size)};
view = gpu.buffer.FindOrCreate(mappings.front(), executor.cycle); 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); constantBufferCache.Insert(constantBufferSelector.size, constantBufferSelector.iova, *view);
} }
@ -715,11 +710,6 @@ namespace skyline::gpu::interconnect {
void ConstantBufferUpdate(std::vector<u32> data, u32 offset) { void ConstantBufferUpdate(std::vector<u32> data, u32 offset) {
auto constantBuffer{GetConstantBufferSelector().value()}; auto constantBuffer{GetConstantBufferSelector().value()};
constantBuffer.Write<u32>(data, offset); constantBuffer.Write<u32>(data, offset);
executor.AddOutsideRpCommand([constantBufferView = constantBuffer.view, data = std::move(data), offset](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr<FenceCycle> &cycle, GPU &) {
std::scoped_lock lock{constantBufferView};
commandBuffer.updateBuffer<u32>(constantBufferView->buffer->GetBacking(), constantBufferView->view->offset + offset, vk::ArrayProxy(static_cast<u32>(data.size()), data.data()));
});
} }
/* Shader Program */ /* Shader Program */