mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 03:14:19 +01:00
Don't break RPs on view pointer changes
Sometimes view pointers may change despite the underlying Vulkan image view not actually changing, so use vk::ImageViews for tracking to keep RP breaks to a minimum.
This commit is contained in:
parent
a02e1a2536
commit
7a759326b3
@ -275,34 +275,26 @@ namespace skyline::gpu::interconnect {
|
|||||||
allocator = &slot->allocator;
|
allocator = &slot->allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ViewsEqual(vk::ImageView a, TextureView *b) {
|
||||||
|
return (!a && !b) || (a && b && b->GetView() == a);
|
||||||
|
}
|
||||||
|
|
||||||
bool CommandExecutor::CreateRenderPassWithSubpass(vk::Rect2D renderArea, span<TextureView *> sampledImages, span<TextureView *> inputAttachments, span<TextureView *> colorAttachments, TextureView *depthStencilAttachment, bool noSubpassCreation) {
|
bool CommandExecutor::CreateRenderPassWithSubpass(vk::Rect2D renderArea, span<TextureView *> sampledImages, span<TextureView *> inputAttachments, span<TextureView *> colorAttachments, TextureView *depthStencilAttachment, bool noSubpassCreation) {
|
||||||
auto addSubpass{[&] {
|
auto addSubpass{[&] {
|
||||||
renderPass->AddSubpass(inputAttachments, colorAttachments, depthStencilAttachment, gpu);
|
renderPass->AddSubpass(inputAttachments, colorAttachments, depthStencilAttachment, gpu);
|
||||||
|
lastSubpassColorAttachments.clear();
|
||||||
|
lastSubpassInputAttachments.clear();
|
||||||
|
|
||||||
lastSubpassAttachments.clear();
|
ranges::transform(colorAttachments, std::back_inserter(lastSubpassColorAttachments), [](TextureView *view){ return view ? view->GetView() : vk::ImageView{};});
|
||||||
auto insertAttachmentRange{[this](auto &attachments) -> std::pair<size_t, size_t> {
|
ranges::transform(inputAttachments, std::back_inserter(lastSubpassInputAttachments), [](TextureView *view){ return view ? view->GetView() : vk::ImageView{};});
|
||||||
size_t beginIndex{lastSubpassAttachments.size()};
|
lastSubpassDepthStencilAttachment = depthStencilAttachment ? depthStencilAttachment->GetView() : vk::ImageView{};
|
||||||
lastSubpassAttachments.insert(lastSubpassAttachments.end(), attachments.begin(), attachments.end());
|
|
||||||
return {beginIndex, attachments.size()};
|
|
||||||
}};
|
|
||||||
|
|
||||||
auto rangeToSpan{[this](auto &range) -> span<TextureView *> {
|
|
||||||
return {lastSubpassAttachments.data() + range.first, range.second};
|
|
||||||
}};
|
|
||||||
|
|
||||||
auto inputAttachmentRange{insertAttachmentRange(inputAttachments)};
|
|
||||||
auto colorAttachmentRange{insertAttachmentRange(colorAttachments)};
|
|
||||||
|
|
||||||
lastSubpassInputAttachments = rangeToSpan(inputAttachmentRange);
|
|
||||||
lastSubpassColorAttachments = rangeToSpan(colorAttachmentRange);
|
|
||||||
lastSubpassDepthStencilAttachment = depthStencilAttachment;
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
span<TextureView *> depthStencilAttachmentSpan{depthStencilAttachment ? span<TextureView *>(depthStencilAttachment) : span<TextureView *>()};
|
span<TextureView *> depthStencilAttachmentSpan{depthStencilAttachment ? span<TextureView *>(depthStencilAttachment) : span<TextureView *>()};
|
||||||
auto outputAttachmentViews{ranges::views::concat(colorAttachments, depthStencilAttachmentSpan)};
|
auto outputAttachmentViews{ranges::views::concat(colorAttachments, depthStencilAttachmentSpan)};
|
||||||
bool attachmentsMatch{ranges::equal(lastSubpassInputAttachments, inputAttachments) &&
|
bool attachmentsMatch{std::equal(lastSubpassInputAttachments.begin(), lastSubpassInputAttachments.end(), inputAttachments.begin(), inputAttachments.end(), ViewsEqual) &&
|
||||||
ranges::equal(lastSubpassColorAttachments, colorAttachments) &&
|
std::equal(lastSubpassColorAttachments.begin(), lastSubpassColorAttachments.end(), colorAttachments.begin(), colorAttachments.end(), ViewsEqual) &&
|
||||||
lastSubpassDepthStencilAttachment == depthStencilAttachment};
|
ViewsEqual(lastSubpassDepthStencilAttachment, depthStencilAttachment)};
|
||||||
|
|
||||||
bool splitRenderPass{renderPass == nullptr || renderPass->renderArea != renderArea || !attachmentsMatch ||
|
bool splitRenderPass{renderPass == nullptr || renderPass->renderArea != renderArea || !attachmentsMatch ||
|
||||||
!ranges::all_of(outputAttachmentViews, [this] (auto view) { return !view || view->texture->ValidateRenderPassUsage(renderPassIndex, texture::RenderPassUsage::RenderTarget); }) ||
|
!ranges::all_of(outputAttachmentViews, [this] (auto view) { return !view || view->texture->ValidateRenderPassUsage(renderPassIndex, texture::RenderPassUsage::RenderTarget); }) ||
|
||||||
@ -343,10 +335,9 @@ namespace skyline::gpu::interconnect {
|
|||||||
renderPass = nullptr;
|
renderPass = nullptr;
|
||||||
subpassCount = 0;
|
subpassCount = 0;
|
||||||
|
|
||||||
lastSubpassAttachments.clear();
|
lastSubpassInputAttachments.clear();
|
||||||
lastSubpassInputAttachments = nullptr;
|
lastSubpassColorAttachments.clear();
|
||||||
lastSubpassColorAttachments = nullptr;
|
lastSubpassDepthStencilAttachment = vk::ImageView{};
|
||||||
lastSubpassDepthStencilAttachment = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,10 +175,9 @@ namespace skyline::gpu::interconnect {
|
|||||||
std::vector<LockedBuffer> attachedBuffers; //!< All textures that are attached to the current execution
|
std::vector<LockedBuffer> attachedBuffers; //!< All textures that are attached to the current execution
|
||||||
|
|
||||||
|
|
||||||
std::vector<TextureView *> lastSubpassAttachments; //!< The storage backing for attachments used in the last subpass
|
std::vector<vk::ImageView> lastSubpassInputAttachments; //!< The set of input attachments used in the last subpass
|
||||||
span<TextureView *> lastSubpassInputAttachments; //!< The set of input attachments used in the last subpass
|
std::vector<vk::ImageView> lastSubpassColorAttachments; //!< The set of color attachments used in the last subpass
|
||||||
span<TextureView *> lastSubpassColorAttachments; //!< The set of color attachments used in the last subpass
|
vk::ImageView lastSubpassDepthStencilAttachment{}; //!< The depth stencil attachment used in the last subpass
|
||||||
TextureView *lastSubpassDepthStencilAttachment{}; //!< The depth stencil attachment used in the last subpass
|
|
||||||
|
|
||||||
std::vector<std::function<void()>> flushCallbacks; //!< Set of persistent callbacks that will be called at the start of Execute in order to flush data required for recording
|
std::vector<std::function<void()>> flushCallbacks; //!< Set of persistent callbacks that will be called at the start of Execute in order to flush data required for recording
|
||||||
std::vector<std::function<void()>> pipelineChangeCallbacks; //!< Set of persistent callbacks that will be called after any non-Maxwell 3D engine changes the active pipeline
|
std::vector<std::function<void()>> pipelineChangeCallbacks; //!< Set of persistent callbacks that will be called after any non-Maxwell 3D engine changes the active pipeline
|
||||||
|
Loading…
Reference in New Issue
Block a user