diff --git a/core/rend/vulkan/texture.cpp b/core/rend/vulkan/texture.cpp index a184c0412..671071a3c 100644 --- a/core/rend/vulkan/texture.cpp +++ b/core/rend/vulkan/texture.cpp @@ -254,7 +254,12 @@ void Texture::SetImage(u32 srcSize, void *srcData, bool isNew, bool genMipmaps) void* data; if (needsStaging) + { + if (!stagingBufferData) + // This can happen if a texture is first created for RTT, then later updated + stagingBufferData = std::unique_ptr(new BufferData(srcSize, vk::BufferUsageFlagBits::eTransferSrc)); data = stagingBufferData->MapMemory(); + } else data = allocation.MapMemory(); verify(data != nullptr); diff --git a/core/rend/vulkan/texture.h b/core/rend/vulkan/texture.h index d1504225a..8d5a0b85a 100644 --- a/core/rend/vulkan/texture.h +++ b/core/rend/vulkan/texture.h @@ -180,6 +180,14 @@ public: BaseTextureCache::Clear(); for (auto& set : inFlightTextures) set.clear(); + for (auto& v : trashedImageViews) + v.clear(); + for (auto& v : trashedImages) + v.clear(); + for (auto& v : trashedMem) + v.clear(); + for (auto& v : trashedBuffers) + v.clear(); } private: