diff --git a/src/common/rendering/vulkan/system/vk_builders.h b/src/common/rendering/vulkan/system/vk_builders.h index 1ce120cb2f2..e30f91157b4 100644 --- a/src/common/rendering/vulkan/system/vk_builders.h +++ b/src/common/rendering/vulkan/system/vk_builders.h @@ -449,7 +449,7 @@ inline std::unique_ptr ImageBuilder::create(VulkanDevice *device, V *allocatedBytes = allocatedInfo.size; } - return std::make_unique(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels); + return std::make_unique(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels, imageInfo.arrayLayers); } inline std::unique_ptr ImageBuilder::tryCreate(VulkanDevice *device) @@ -461,7 +461,7 @@ inline std::unique_ptr ImageBuilder::tryCreate(VulkanDevice *device if (result != VK_SUCCESS) return nullptr; - return std::make_unique(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels); + return std::make_unique(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels, imageInfo.arrayLayers); } ///////////////////////////////////////////////////////////////////////////// @@ -487,6 +487,7 @@ inline void ImageViewBuilder::setImage(VulkanImage *image, VkFormat format, VkIm viewInfo.format = format; viewInfo.subresourceRange.levelCount = image->mipLevels; viewInfo.subresourceRange.aspectMask = aspectMask; + viewInfo.subresourceRange.layerCount = image->layerCount; } inline std::unique_ptr ImageViewBuilder::create(VulkanDevice *device) diff --git a/src/common/rendering/vulkan/system/vk_framebuffer.cpp b/src/common/rendering/vulkan/system/vk_framebuffer.cpp index 978969186b4..e3bf5aa2b53 100644 --- a/src/common/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/common/rendering/vulkan/system/vk_framebuffer.cpp @@ -635,7 +635,7 @@ void VulkanFrameBuffer::InitLightmap(FLevelLocals* Level) stagingBuffer->Unmap(); VkImageTransition imageTransition; - imageTransition.addImage(&lightmap, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, true); + imageTransition.addImage(&lightmap, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, true, 0, count); imageTransition.execute(cmdbuffer); VkBufferImageCopy region = {}; @@ -647,7 +647,7 @@ void VulkanFrameBuffer::InitLightmap(FLevelLocals* Level) cmdbuffer->copyBufferToImage(stagingBuffer->buffer, lightmap.Image->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); VkImageTransition barrier; - barrier.addImage(&lightmap, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, true); + barrier.addImage(&lightmap, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, false, 0, count); barrier.execute(cmdbuffer); FrameTextureUpload.Buffers.push_back(std::move(stagingBuffer)); diff --git a/src/common/rendering/vulkan/system/vk_objects.h b/src/common/rendering/vulkan/system/vk_objects.h index dd320451788..7735a508d25 100644 --- a/src/common/rendering/vulkan/system/vk_objects.h +++ b/src/common/rendering/vulkan/system/vk_objects.h @@ -79,7 +79,7 @@ class VulkanFramebuffer class VulkanImage { public: - VulkanImage(VulkanDevice *device, VkImage image, VmaAllocation allocation, int width, int height, int mipLevels); + VulkanImage(VulkanDevice *device, VkImage image, VmaAllocation allocation, int width, int height, int mipLevels, int layerCount); ~VulkanImage(); void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); } @@ -88,6 +88,7 @@ class VulkanImage int width = 0; int height = 0; int mipLevels = 1; + int layerCount = 1; void *Map(size_t offset, size_t size); void Unmap(); @@ -989,7 +990,7 @@ inline VulkanFramebuffer::~VulkanFramebuffer() ///////////////////////////////////////////////////////////////////////////// -inline VulkanImage::VulkanImage(VulkanDevice *device, VkImage image, VmaAllocation allocation, int width, int height, int mipLevels) : image(image), width(width), height(height), mipLevels(mipLevels), device(device), allocation(allocation) +inline VulkanImage::VulkanImage(VulkanDevice *device, VkImage image, VmaAllocation allocation, int width, int height, int mipLevels, int layerCount) : image(image), width(width), height(height), mipLevels(mipLevels), layerCount(layerCount), device(device), allocation(allocation) { } diff --git a/src/common/rendering/vulkan/textures/vk_imagetransition.cpp b/src/common/rendering/vulkan/textures/vk_imagetransition.cpp index a5f2892969d..a62cb3c2dd1 100644 --- a/src/common/rendering/vulkan/textures/vk_imagetransition.cpp +++ b/src/common/rendering/vulkan/textures/vk_imagetransition.cpp @@ -22,7 +22,7 @@ #include "vk_imagetransition.h" -void VkImageTransition::addImage(VkTextureImage *image, VkImageLayout targetLayout, bool undefinedSrcLayout) +void VkImageTransition::addImage(VkTextureImage *image, VkImageLayout targetLayout, bool undefinedSrcLayout, int baseMipLevel, int levelCount) { if (image->Layout == targetLayout) return; @@ -91,7 +91,7 @@ void VkImageTransition::addImage(VkTextureImage *image, VkImageLayout targetLayo I_FatalError("Unimplemented dst image layout transition\n"); } - barrier.addImage(image->Image.get(), undefinedSrcLayout ? VK_IMAGE_LAYOUT_UNDEFINED : image->Layout, targetLayout, srcAccess, dstAccess, aspectMask); + barrier.addImage(image->Image.get(), undefinedSrcLayout ? VK_IMAGE_LAYOUT_UNDEFINED : image->Layout, targetLayout, srcAccess, dstAccess, aspectMask, baseMipLevel, levelCount); needbarrier = true; image->Layout = targetLayout; } diff --git a/src/common/rendering/vulkan/textures/vk_imagetransition.h b/src/common/rendering/vulkan/textures/vk_imagetransition.h index 916f20c2487..c8071989aa7 100644 --- a/src/common/rendering/vulkan/textures/vk_imagetransition.h +++ b/src/common/rendering/vulkan/textures/vk_imagetransition.h @@ -33,7 +33,7 @@ class VkTextureImage class VkImageTransition { public: - void addImage(VkTextureImage *image, VkImageLayout targetLayout, bool undefinedSrcLayout); + void addImage(VkTextureImage *image, VkImageLayout targetLayout, bool undefinedSrcLayout, int baseMipLevel = 0, int levelCount = 1); void execute(VulkanCommandBuffer *cmdbuffer); private: