Merge branch 'lightmaps2' of https://github.com/dpjudas/gzdoom into lightmaps2

This commit is contained in:
nashmuhandes 2021-11-15 02:56:10 +08:00
commit 2ed99c735d
5 changed files with 11 additions and 9 deletions

View file

@ -449,7 +449,7 @@ inline std::unique_ptr<VulkanImage> ImageBuilder::create(VulkanDevice *device, V
*allocatedBytes = allocatedInfo.size; *allocatedBytes = allocatedInfo.size;
} }
return std::make_unique<VulkanImage>(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels); return std::make_unique<VulkanImage>(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels, imageInfo.arrayLayers);
} }
inline std::unique_ptr<VulkanImage> ImageBuilder::tryCreate(VulkanDevice *device) inline std::unique_ptr<VulkanImage> ImageBuilder::tryCreate(VulkanDevice *device)
@ -461,7 +461,7 @@ inline std::unique_ptr<VulkanImage> ImageBuilder::tryCreate(VulkanDevice *device
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
return nullptr; return nullptr;
return std::make_unique<VulkanImage>(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels); return std::make_unique<VulkanImage>(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.format = format;
viewInfo.subresourceRange.levelCount = image->mipLevels; viewInfo.subresourceRange.levelCount = image->mipLevels;
viewInfo.subresourceRange.aspectMask = aspectMask; viewInfo.subresourceRange.aspectMask = aspectMask;
viewInfo.subresourceRange.layerCount = image->layerCount;
} }
inline std::unique_ptr<VulkanImageView> ImageViewBuilder::create(VulkanDevice *device) inline std::unique_ptr<VulkanImageView> ImageViewBuilder::create(VulkanDevice *device)

View file

@ -635,7 +635,7 @@ void VulkanFrameBuffer::InitLightmap(FLevelLocals* Level)
stagingBuffer->Unmap(); stagingBuffer->Unmap();
VkImageTransition imageTransition; 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); imageTransition.execute(cmdbuffer);
VkBufferImageCopy region = {}; 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, &region); cmdbuffer->copyBufferToImage(stagingBuffer->buffer, lightmap.Image->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);
VkImageTransition barrier; 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); barrier.execute(cmdbuffer);
FrameTextureUpload.Buffers.push_back(std::move(stagingBuffer)); FrameTextureUpload.Buffers.push_back(std::move(stagingBuffer));

View file

@ -79,7 +79,7 @@ private:
class VulkanImage class VulkanImage
{ {
public: 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(); ~VulkanImage();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); } void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); }
@ -88,6 +88,7 @@ public:
int width = 0; int width = 0;
int height = 0; int height = 0;
int mipLevels = 1; int mipLevels = 1;
int layerCount = 1;
void *Map(size_t offset, size_t size); void *Map(size_t offset, size_t size);
void Unmap(); 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)
{ {
} }

View file

@ -22,7 +22,7 @@
#include "vk_imagetransition.h" #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) if (image->Layout == targetLayout)
return; return;
@ -91,7 +91,7 @@ void VkImageTransition::addImage(VkTextureImage *image, VkImageLayout targetLayo
I_FatalError("Unimplemented dst image layout transition\n"); 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; needbarrier = true;
image->Layout = targetLayout; image->Layout = targetLayout;
} }

View file

@ -33,7 +33,7 @@ public:
class VkImageTransition class VkImageTransition
{ {
public: 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); void execute(VulkanCommandBuffer *cmdbuffer);
private: private: