From 1b89de449766344ca07b4c2a1026e3e7be1e6d22 Mon Sep 17 00:00:00 2001 From: slime Date: Thu, 22 Sep 2022 22:20:42 -0300 Subject: [PATCH] vulkan: clean up texture creation flags --- src/modules/graphics/vulkan/Texture.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/modules/graphics/vulkan/Texture.cpp b/src/modules/graphics/vulkan/Texture.cpp index fedf4c102..fbcb44d05 100644 --- a/src/modules/graphics/vulkan/Texture.cpp +++ b/src/modules/graphics/vulkan/Texture.cpp @@ -48,11 +48,11 @@ bool Texture::loadVolatile() allocator = vgfx->getVmaAllocator(); device = vgfx->getDevice(); - if (isPixelFormatDepthStencil(format)) - imageAspect |= VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; - else if (isPixelFormatDepth(format)) + if (isPixelFormatDepth(format)) imageAspect |= VK_IMAGE_ASPECT_DEPTH_BIT; - else + if (isPixelFormatStencil(format)) + imageAspect |= VK_IMAGE_ASPECT_STENCIL_BIT; + if (isPixelFormatColor(format)) imageAspect |= VK_IMAGE_ASPECT_COLOR_BIT; auto vulkanFormat = Vulkan::getTextureFormat(format, sRGB); @@ -62,13 +62,10 @@ bool Texture::loadVolatile() VK_IMAGE_USAGE_TRANSFER_DST_BIT; if (readable) - { - if (!isPixelFormatDepthStencil(format)) - usageFlags |= VK_IMAGE_USAGE_SAMPLED_BIT; + usageFlags |= VK_IMAGE_USAGE_SAMPLED_BIT; - if (!isPixelFormatCompressed(format) && !isPixelFormatDepthStencil(format)) - usageFlags |= VK_IMAGE_USAGE_STORAGE_BIT; - } + if (computeWrite) + usageFlags |= VK_IMAGE_USAGE_STORAGE_BIT; if (renderTarget) { @@ -133,6 +130,7 @@ bool Texture::loadVolatile() bool hasdata = slices.get(0, 0) != nullptr; if (hasdata) + { for (int mip = 0; mip < getMipmapCount(); mip++) { int sliceCount; @@ -148,6 +146,7 @@ bool Texture::loadVolatile() uploadImageData(id, mip, slice, 0, 0); } } + } else clear();