mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-15 17:11:24 +00:00
- tell the memory allocator when we are going to persistently map something
This commit is contained in:
parent
2e0b34ca72
commit
9a5112c1c9
3 changed files with 8 additions and 7 deletions
|
@ -40,7 +40,7 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
|
|||
else
|
||||
{
|
||||
BufferBuilder builder;
|
||||
builder.setUsage(mBufferType, VMA_MEMORY_USAGE_CPU_TO_GPU);
|
||||
builder.setUsage(mBufferType, VMA_MEMORY_USAGE_CPU_TO_GPU, mPersistent ? VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT : 0);
|
||||
builder.setSize(size);
|
||||
mBuffer = builder.create(fb->device);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
void setSize(int width, int height, int miplevels = 1);
|
||||
void setFormat(VkFormat format);
|
||||
void setUsage(VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY);
|
||||
void setUsage(VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
||||
void setLinearTiling();
|
||||
|
||||
std::unique_ptr<VulkanImage> create(VulkanDevice *device);
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
BufferBuilder();
|
||||
|
||||
void setSize(size_t size);
|
||||
void setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY);
|
||||
void setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY, VmaAllocationCreateFlags allocFlags = 0);
|
||||
|
||||
std::unique_ptr<VulkanBuffer> create(VulkanDevice *device);
|
||||
|
||||
|
@ -337,10 +337,11 @@ inline void ImageBuilder::setLinearTiling()
|
|||
imageInfo.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
}
|
||||
|
||||
inline void ImageBuilder::setUsage(VkImageUsageFlags usage, VmaMemoryUsage memoryUsage)
|
||||
inline void ImageBuilder::setUsage(VkImageUsageFlags usage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocFlags)
|
||||
{
|
||||
imageInfo.usage = usage;
|
||||
allocInfo.usage = memoryUsage;
|
||||
allocInfo.flags = allocFlags;
|
||||
}
|
||||
|
||||
inline std::unique_ptr<VulkanImage> ImageBuilder::create(VulkanDevice *device)
|
||||
|
@ -469,10 +470,11 @@ inline void BufferBuilder::setSize(size_t size)
|
|||
bufferInfo.size = size;
|
||||
}
|
||||
|
||||
inline void BufferBuilder::setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage)
|
||||
inline void BufferBuilder::setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocFlags)
|
||||
{
|
||||
bufferInfo.usage = bufferUsage;
|
||||
allocInfo.usage = memoryUsage;
|
||||
allocInfo.flags = allocFlags;
|
||||
}
|
||||
|
||||
inline std::unique_ptr<VulkanBuffer> BufferBuilder::create(VulkanDevice *device)
|
||||
|
@ -480,7 +482,6 @@ inline std::unique_ptr<VulkanBuffer> BufferBuilder::create(VulkanDevice *device)
|
|||
VkBuffer buffer;
|
||||
VmaAllocation allocation;
|
||||
|
||||
allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; // we want this to be mappable.
|
||||
VkResult result = vmaCreateBuffer(device->allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("could not allocate memory for vulkan buffer");
|
||||
|
|
|
@ -218,7 +218,7 @@ void VkHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
|
|||
ImageBuilder imgbuilder;
|
||||
imgbuilder.setFormat(format);
|
||||
imgbuilder.setSize(w, h);
|
||||
imgbuilder.setUsage(VK_IMAGE_USAGE_SAMPLED_BIT, VMA_MEMORY_USAGE_CPU_TO_GPU);
|
||||
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();
|
||||
mImage = imgbuilder.create(fb->device);
|
||||
mImageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
|
|
Loading…
Reference in a new issue