diff --git a/Common/GPU/Vulkan/VulkanImage.cpp b/Common/GPU/Vulkan/VulkanImage.cpp index c6b99f28d9..564729a99a 100644 --- a/Common/GPU/Vulkan/VulkanImage.cpp +++ b/Common/GPU/Vulkan/VulkanImage.cpp @@ -31,6 +31,11 @@ static bool IsDepthStencilFormat(VkFormat format) { } bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *allocator, int w, int h, int numMips, VkFormat format, VkImageLayout initialLayout, VkImageUsageFlags usage, const VkComponentMapping *mapping) { + if (w == 0 || h == 0 || numMips == 0) { + ERROR_LOG(G3D, "Can't create a zero-size VulkanTexture"); + return false; + } + Wipe(); width_ = w; diff --git a/UI/TextureUtil.cpp b/UI/TextureUtil.cpp index cdfe9440e2..3d986e765a 100644 --- a/UI/TextureUtil.cpp +++ b/UI/TextureUtil.cpp @@ -124,25 +124,26 @@ bool ManagedTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, Imag } int potentialLevels = std::min(log2i(width[0]), log2i(height[0])); - - TextureDesc desc{}; - desc.type = TextureType::LINEAR2D; - desc.format = fmt; - desc.width = width[0]; - desc.height = height[0]; - desc.depth = 1; - desc.mipLevels = generateMips ? potentialLevels : num_levels; - desc.generateMips = generateMips && potentialLevels > num_levels; - desc.tag = name; - for (int i = 0; i < num_levels; i++) { - desc.initData.push_back(image[i]); + if (width[0] > 0 && height[0] > 0) { + TextureDesc desc{}; + desc.type = TextureType::LINEAR2D; + desc.format = fmt; + desc.width = width[0]; + desc.height = height[0]; + desc.depth = 1; + desc.mipLevels = generateMips ? potentialLevels : num_levels; + desc.generateMips = generateMips && potentialLevels > num_levels; + desc.tag = name; + for (int i = 0; i < num_levels; i++) { + desc.initData.push_back(image[i]); + } + texture_ = draw_->CreateTexture(desc); } - texture_ = draw_->CreateTexture(desc); for (int i = 0; i < num_levels; i++) { if (image[i]) free(image[i]); } - return texture_; + return texture_ != nullptr; } bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType type, bool generateMips) {