mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
- VMA_MEMORY_USAGE_CPU_TO_GPU does not require VK_MEMORY_PROPERTY_HOST_COHERENT_BIT to bet set. Current implementation requires this flag as vkFlushMappedMemoryRanges is never called.
This commit is contained in:
parent
ea9be6c225
commit
d1554aed37
3 changed files with 41 additions and 3 deletions
|
@ -76,7 +76,10 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
|
||||||
mPersistent = screen->BuffersArePersistent();
|
mPersistent = screen->BuffersArePersistent();
|
||||||
|
|
||||||
BufferBuilder builder;
|
BufferBuilder builder;
|
||||||
builder.setUsage(mBufferType, VMA_MEMORY_USAGE_CPU_TO_GPU, mPersistent ? VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT : 0);
|
builder.setUsage(mBufferType, VMA_MEMORY_USAGE_UNKNOWN, mPersistent ? VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT : 0);
|
||||||
|
builder.setMemoryType(
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
builder.setSize(size);
|
builder.setSize(size);
|
||||||
mBuffer = builder.create(fb->device);
|
mBuffer = builder.create(fb->device);
|
||||||
|
|
||||||
|
@ -127,7 +130,10 @@ void VKBuffer::Resize(size_t newsize)
|
||||||
|
|
||||||
// Create new buffer
|
// Create new buffer
|
||||||
BufferBuilder builder;
|
BufferBuilder builder;
|
||||||
builder.setUsage(mBufferType, VMA_MEMORY_USAGE_CPU_TO_GPU, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
builder.setUsage(mBufferType, VMA_MEMORY_USAGE_UNKNOWN, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
||||||
|
builder.setMemoryType(
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
builder.setSize(newsize);
|
builder.setSize(newsize);
|
||||||
mBuffer = builder.create(fb->device);
|
mBuffer = builder.create(fb->device);
|
||||||
buffersize = newsize;
|
buffersize = newsize;
|
||||||
|
|
|
@ -42,11 +42,13 @@ public:
|
||||||
void setSamples(VkSampleCountFlagBits samples);
|
void setSamples(VkSampleCountFlagBits samples);
|
||||||
void setFormat(VkFormat format);
|
void setFormat(VkFormat format);
|
||||||
void setUsage(VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
void setUsage(VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
||||||
|
void setMemoryType(VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags preferredFlags, uint32_t memoryTypeBits = 0);
|
||||||
void setLinearTiling();
|
void setLinearTiling();
|
||||||
|
|
||||||
bool isFormatSupported(VulkanDevice *device);
|
bool isFormatSupported(VulkanDevice *device);
|
||||||
|
|
||||||
std::unique_ptr<VulkanImage> create(VulkanDevice *device);
|
std::unique_ptr<VulkanImage> create(VulkanDevice *device);
|
||||||
|
std::unique_ptr<VulkanImage> tryCreate(VulkanDevice *device);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VkImageCreateInfo imageInfo = {};
|
VkImageCreateInfo imageInfo = {};
|
||||||
|
@ -92,6 +94,7 @@ public:
|
||||||
|
|
||||||
void setSize(size_t size);
|
void setSize(size_t size);
|
||||||
void setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
void setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
||||||
|
void setMemoryType(VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags preferredFlags, uint32_t memoryTypeBits = 0);
|
||||||
|
|
||||||
std::unique_ptr<VulkanBuffer> create(VulkanDevice *device);
|
std::unique_ptr<VulkanBuffer> create(VulkanDevice *device);
|
||||||
|
|
||||||
|
@ -400,6 +403,13 @@ inline void ImageBuilder::setUsage(VkImageUsageFlags usage, VmaMemoryUsage memor
|
||||||
allocInfo.flags = allocFlags;
|
allocInfo.flags = allocFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void ImageBuilder::setMemoryType(VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags preferredFlags, uint32_t memoryTypeBits)
|
||||||
|
{
|
||||||
|
allocInfo.requiredFlags = requiredFlags;
|
||||||
|
allocInfo.preferredFlags = preferredFlags;
|
||||||
|
allocInfo.memoryTypeBits = memoryTypeBits;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool ImageBuilder::isFormatSupported(VulkanDevice *device)
|
inline bool ImageBuilder::isFormatSupported(VulkanDevice *device)
|
||||||
{
|
{
|
||||||
VkImageFormatProperties properties = { };
|
VkImageFormatProperties properties = { };
|
||||||
|
@ -426,6 +436,18 @@ inline std::unique_ptr<VulkanImage> ImageBuilder::create(VulkanDevice *device)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::unique_ptr<VulkanImage> ImageBuilder::tryCreate(VulkanDevice *device)
|
||||||
|
{
|
||||||
|
VkImage image;
|
||||||
|
VmaAllocation allocation;
|
||||||
|
|
||||||
|
VkResult result = vmaCreateImage(device->allocator, &imageInfo, &allocInfo, &image, &allocation, nullptr);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return std::make_unique<VulkanImage>(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline ImageViewBuilder::ImageViewBuilder()
|
inline ImageViewBuilder::ImageViewBuilder()
|
||||||
|
@ -547,6 +569,13 @@ inline void BufferBuilder::setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsa
|
||||||
allocInfo.flags = allocFlags;
|
allocInfo.flags = allocFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void BufferBuilder::setMemoryType(VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags preferredFlags, uint32_t memoryTypeBits)
|
||||||
|
{
|
||||||
|
allocInfo.requiredFlags = requiredFlags;
|
||||||
|
allocInfo.preferredFlags = preferredFlags;
|
||||||
|
allocInfo.memoryTypeBits = memoryTypeBits;
|
||||||
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<VulkanBuffer> BufferBuilder::create(VulkanDevice *device)
|
inline std::unique_ptr<VulkanBuffer> BufferBuilder::create(VulkanDevice *device)
|
||||||
{
|
{
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
|
|
|
@ -337,8 +337,11 @@ void VkHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
|
||||||
ImageBuilder imgbuilder;
|
ImageBuilder imgbuilder;
|
||||||
imgbuilder.setFormat(format);
|
imgbuilder.setFormat(format);
|
||||||
imgbuilder.setSize(w, h);
|
imgbuilder.setSize(w, h);
|
||||||
imgbuilder.setUsage(VK_IMAGE_USAGE_SAMPLED_BIT, VMA_MEMORY_USAGE_CPU_TO_GPU, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
|
||||||
imgbuilder.setLinearTiling();
|
imgbuilder.setLinearTiling();
|
||||||
|
imgbuilder.setUsage(VK_IMAGE_USAGE_SAMPLED_BIT, VMA_MEMORY_USAGE_UNKNOWN, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
||||||
|
imgbuilder.setMemoryType(
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
mImage = imgbuilder.create(fb->device);
|
mImage = imgbuilder.create(fb->device);
|
||||||
mImage->SetDebugName("VkHardwareTexture.mImage");
|
mImage->SetDebugName("VkHardwareTexture.mImage");
|
||||||
mImageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
mImageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
|
Loading…
Reference in a new issue