Replace faulty layout transition deduplication algorithm.
This commit is contained in:
parent
894ab45677
commit
a7642bac15
2 changed files with 12 additions and 9 deletions
|
@ -163,6 +163,10 @@ struct TransitionRequest {
|
||||||
VKRFramebuffer *fb;
|
VKRFramebuffer *fb;
|
||||||
VkImageAspectFlags aspect; // COLOR or DEPTH
|
VkImageAspectFlags aspect; // COLOR or DEPTH
|
||||||
VkImageLayout targetLayout;
|
VkImageLayout targetLayout;
|
||||||
|
|
||||||
|
bool operator == (const TransitionRequest &other) const {
|
||||||
|
return fb == other.fb && aspect == other.aspect && targetLayout == other.targetLayout;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VKRRenderPass;
|
class VKRRenderPass;
|
||||||
|
|
|
@ -1137,6 +1137,10 @@ void VulkanRenderManager::BlitFramebuffer(VKRFramebuffer *src, VkRect2D srcRect,
|
||||||
|
|
||||||
VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBit, int attachment) {
|
VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBit, int attachment) {
|
||||||
_dbg_assert_(curRenderStep_ != nullptr);
|
_dbg_assert_(curRenderStep_ != nullptr);
|
||||||
|
|
||||||
|
// We don't support texturing from stencil, neither do we support texturing from depth|stencil together (nonsensical).
|
||||||
|
_dbg_assert_(aspectBit == VK_IMAGE_ASPECT_COLOR_BIT || aspectBit == VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||||
|
|
||||||
// Mark the dependency, check for required transitions, and return the image.
|
// Mark the dependency, check for required transitions, and return the image.
|
||||||
|
|
||||||
// Optimization: If possible, use final*Layout to put the texture into the correct layout "early".
|
// Optimization: If possible, use final*Layout to put the texture into the correct layout "early".
|
||||||
|
@ -1163,15 +1167,10 @@ VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, in
|
||||||
// Track dependencies fully.
|
// Track dependencies fully.
|
||||||
curRenderStep_->dependencies.insert(fb);
|
curRenderStep_->dependencies.insert(fb);
|
||||||
|
|
||||||
if (!curRenderStep_->preTransitions.empty() &&
|
// Add this pretransition unless we already have it.
|
||||||
curRenderStep_->preTransitions.back().fb == fb &&
|
TransitionRequest rq{ fb, aspectBit, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL };
|
||||||
curRenderStep_->preTransitions.back().targetLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
|
curRenderStep_->preTransitions.insert(rq); // Note that insert avoids inserting duplicates.
|
||||||
// We're done.
|
return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.imageView : fb->depth.depthSampleView;
|
||||||
return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.imageView : fb->depth.depthSampleView;
|
|
||||||
} else {
|
|
||||||
curRenderStep_->preTransitions.push_back({ fb, aspectBit, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL });
|
|
||||||
return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.imageView : fb->depth.depthSampleView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on main thread.
|
// Called on main thread.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue