mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Remove Implicit Command Executor Resource Attachment
Any usage of a resource in a command now requires attaching that resource externally and will not be implicitly attached on usage, this makes attaching of resources consistent and allows for more lax locking requirements on resources as they can be locked while attaching and don't need to be for any commands, it also avoids redundantly attaching a resource in certain cases.
This commit is contained in:
parent
f0e9c42097
commit
934130b3e6
@ -30,9 +30,9 @@ namespace skyline::gpu::interconnect {
|
||||
if (!syncTextures.contains(texture)) {
|
||||
texture->WaitOnFence();
|
||||
texture->cycle = cycle;
|
||||
cycle->AttachObject(view->shared_from_this());
|
||||
syncTextures.emplace(texture);
|
||||
}
|
||||
cycle->AttachObject(view->shared_from_this());
|
||||
}
|
||||
|
||||
void CommandExecutor::AttachBuffer(BufferView *view) {
|
||||
@ -45,17 +45,11 @@ namespace skyline::gpu::interconnect {
|
||||
}
|
||||
}
|
||||
|
||||
void CommandExecutor::AttachDependency(std::shared_ptr<FenceCycleDependency> dependency) {
|
||||
void CommandExecutor::AttachDependency(const std::shared_ptr<FenceCycleDependency> &dependency) {
|
||||
cycle->AttachObject(dependency);
|
||||
}
|
||||
|
||||
void CommandExecutor::AddSubpass(std::function<void(vk::raii::CommandBuffer &, const std::shared_ptr<FenceCycle> &, GPU &, vk::RenderPass, u32)> &&function, vk::Rect2D renderArea, span<TextureView *> inputAttachments, span<TextureView *> colorAttachments, TextureView *depthStencilAttachment) {
|
||||
for (const auto &attachments : {inputAttachments, colorAttachments})
|
||||
for (const auto &attachment : attachments)
|
||||
AttachTexture(attachment);
|
||||
if (depthStencilAttachment)
|
||||
AttachTexture(depthStencilAttachment);
|
||||
|
||||
bool newRenderPass{CreateRenderPass(renderArea)};
|
||||
renderPass->AddSubpass(inputAttachments, colorAttachments, depthStencilAttachment ? &*depthStencilAttachment : nullptr);
|
||||
if (newRenderPass)
|
||||
@ -65,8 +59,6 @@ namespace skyline::gpu::interconnect {
|
||||
}
|
||||
|
||||
void CommandExecutor::AddClearColorSubpass(TextureView *attachment, const vk::ClearColorValue &value) {
|
||||
AttachTexture(attachment);
|
||||
|
||||
bool newRenderPass{CreateRenderPass(vk::Rect2D{
|
||||
.extent = attachment->texture->dimensions,
|
||||
})};
|
||||
@ -96,8 +88,6 @@ namespace skyline::gpu::interconnect {
|
||||
}
|
||||
|
||||
void CommandExecutor::AddClearDepthStencilSubpass(TextureView *attachment, const vk::ClearDepthStencilValue &value) {
|
||||
AttachTexture(attachment);
|
||||
|
||||
bool newRenderPass{CreateRenderPass(vk::Rect2D{
|
||||
.extent = attachment->texture->dimensions,
|
||||
})};
|
||||
|
@ -49,24 +49,23 @@ namespace skyline::gpu::interconnect {
|
||||
/**
|
||||
* @brief Attach the lifetime of the fence cycle dependency to the command buffer
|
||||
*/
|
||||
void AttachDependency(std::shared_ptr<FenceCycleDependency> dependency);
|
||||
void AttachDependency(const std::shared_ptr<FenceCycleDependency> &dependency);
|
||||
|
||||
/**
|
||||
* @brief Adds a command that needs to be executed inside a subpass configured with certain attachments
|
||||
* @note Any texture supplied to this **must** be locked by the calling thread, it should also undergo no persistent layout transitions till execution
|
||||
* @note All attachments will automatically be attached and aren't required to be attached prior
|
||||
* @note Any supplied texture should be attached prior and not undergo any persistent layout transitions till execution
|
||||
*/
|
||||
void AddSubpass(std::function<void(vk::raii::CommandBuffer &, const std::shared_ptr<FenceCycle> &, GPU &, vk::RenderPass, u32)> &&function, vk::Rect2D renderArea, span<TextureView *> inputAttachments = {}, span<TextureView *> colorAttachments = {}, TextureView *depthStencilAttachment = {});
|
||||
|
||||
/**
|
||||
* @brief Adds a subpass that clears the entirety of the specified attachment with a color value, it may utilize VK_ATTACHMENT_LOAD_OP_CLEAR for a more efficient clear when possible
|
||||
* @note Any texture supplied to this **must** be locked by the calling thread, it should also undergo no persistent layout transitions till execution
|
||||
* @note Any supplied texture should be attached prior and not undergo any persistent layout transitions till execution
|
||||
*/
|
||||
void AddClearColorSubpass(TextureView *attachment, const vk::ClearColorValue &value);
|
||||
|
||||
/**
|
||||
* @brief Adds a subpass that clears the entirety of the specified attachment with a depth/stencil value, it may utilize VK_ATTACHMENT_LOAD_OP_CLEAR for a more efficient clear when possible
|
||||
* @note Any texture supplied to this **must** be locked by the calling thread, it should also undergo no persistent layout transitions till execution
|
||||
* @note Any supplied texture should be attached prior and not undergo any persistent layout transitions till execution
|
||||
*/
|
||||
void AddClearDepthStencilSubpass(TextureView *attachment, const vk::ClearDepthStencilValue &value);
|
||||
|
||||
|
@ -442,6 +442,7 @@ namespace skyline::gpu::interconnect {
|
||||
|
||||
void ClearColorRt(TextureView *renderTarget, vk::Rect2D scissor, u32 layerIndex) {
|
||||
std::lock_guard lock(*renderTarget);
|
||||
executor.AttachTexture(renderTarget);
|
||||
|
||||
scissor.extent.width = static_cast<u32>(std::min(static_cast<i32>(renderTarget->texture->dimensions.width) - scissor.offset.x,
|
||||
static_cast<i32>(scissor.extent.width)));
|
||||
@ -473,6 +474,7 @@ namespace skyline::gpu::interconnect {
|
||||
|
||||
void ClearDepthStencilRt(TextureView *renderTarget, vk::ImageAspectFlags aspect, u32 layerIndex) {
|
||||
std::lock_guard lock(*renderTarget);
|
||||
executor.AttachTexture(renderTarget);
|
||||
|
||||
if (renderTarget->range.layerCount == 1 && layerIndex == 0) {
|
||||
executor.AddClearDepthStencilSubpass(renderTarget, clearDepthValue);
|
||||
@ -2112,7 +2114,6 @@ namespace skyline::gpu::interconnect {
|
||||
depthTargetLock.emplace(*depthRenderTargetView);
|
||||
|
||||
// Vertex Buffer Setup
|
||||
boost::container::static_vector<std::scoped_lock<BufferView>, maxwell3d::VertexBufferCount> vertexBufferLocks;
|
||||
std::array<vk::Buffer, maxwell3d::VertexBufferCount> vertexBufferHandles{};
|
||||
std::array<vk::DeviceSize, maxwell3d::VertexBufferCount> vertexBufferOffsets{};
|
||||
|
||||
@ -2126,7 +2127,7 @@ namespace skyline::gpu::interconnect {
|
||||
vertexBindingDescriptions.push_back(vertexBuffer.bindingDescription);
|
||||
vertexBindingDivisorsDescriptions.push_back(vertexBuffer.bindingDivisorDescription);
|
||||
|
||||
vertexBufferLocks.emplace_back(*vertexBufferView);
|
||||
std::scoped_lock vertexBufferLock(*vertexBufferView);
|
||||
executor.AttachBuffer(vertexBufferView);
|
||||
vertexBufferHandles[index] = vertexBufferView->buffer->GetBacking();
|
||||
vertexBufferOffsets[index] = vertexBufferView->offset;
|
||||
|
Loading…
Reference in New Issue
Block a user