From a00a5d3d8bee21fe119cdce84f17fb3b19444b4c Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 10 Jan 2018 11:48:26 -0500 Subject: [PATCH] TextureVk: Transition to the first usage if needed In Vulkan images are created in no particular layout and must be transitioned before they can be used. This didn't appear before because the test were creating the textures with not initial usage and then transitioned them. This isn't the case with InputStateTest, which is what uncovered this issue. --- src/backend/vulkan/TextureVk.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/vulkan/TextureVk.cpp b/src/backend/vulkan/TextureVk.cpp index fd985bf3b7..f5ddc19dc0 100644 --- a/src/backend/vulkan/TextureVk.cpp +++ b/src/backend/vulkan/TextureVk.cpp @@ -252,6 +252,12 @@ namespace backend { namespace vulkan { mMemoryAllocation.GetMemoryOffset()) != VK_SUCCESS) { ASSERT(false); } + + // Vulkan requires images to be transitioned to their first usage. Do the transition if the + // texture has an initial usage. + if (GetUsage() != nxt::TextureUsageBit::None) { + TransitionUsageImpl(nxt::TextureUsageBit::None, GetUsage()); + } } Texture::~Texture() {