mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +00:00
- fix shutdown crash and some minor adjustments
This commit is contained in:
parent
d86a56086c
commit
1430d9012e
4 changed files with 21 additions and 12 deletions
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
bool operator<(const VkRenderPassKey &other) const
|
||||
{
|
||||
return memcmp(this, &other, sizeof(VkRenderPassKey));
|
||||
return memcmp(this, &other, sizeof(VkRenderPassKey)) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,17 +20,23 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
|
|||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
|
||||
mPersistent = screen->BuffersArePersistent() && !staticdata;
|
||||
|
||||
if (staticdata)
|
||||
{
|
||||
BufferBuilder builder;
|
||||
builder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY);
|
||||
builder.setSize(size);
|
||||
mBuffer = builder.create(fb->device);
|
||||
mPersistent = false;
|
||||
|
||||
builder.setUsage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY);
|
||||
mStaging = builder.create(fb->device);
|
||||
{
|
||||
BufferBuilder builder;
|
||||
builder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY);
|
||||
builder.setSize(size);
|
||||
mBuffer = builder.create(fb->device);
|
||||
}
|
||||
|
||||
{
|
||||
BufferBuilder builder;
|
||||
builder.setUsage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY);
|
||||
builder.setSize(size);
|
||||
mStaging = builder.create(fb->device);
|
||||
}
|
||||
|
||||
void *dst = mStaging->Map(0, size);
|
||||
memcpy(dst, data, size);
|
||||
|
@ -40,6 +46,8 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
|
|||
}
|
||||
else
|
||||
{
|
||||
mPersistent = screen->BuffersArePersistent();
|
||||
|
||||
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.setSize(size);
|
||||
|
|
|
@ -376,7 +376,7 @@ inline void *VulkanBuffer::Map(size_t offset, size_t size)
|
|||
{
|
||||
void *data;
|
||||
VkResult result = vmaMapMemory(device->allocator, allocation, &data);
|
||||
return (result == VK_SUCCESS) ? data : nullptr;
|
||||
return (result == VK_SUCCESS) ? ((uint8_t*)data) + offset : nullptr;
|
||||
}
|
||||
|
||||
inline void VulkanBuffer::Unmap()
|
||||
|
@ -888,7 +888,7 @@ inline void *VulkanImage::Map(size_t offset, size_t size)
|
|||
{
|
||||
void *data;
|
||||
VkResult result = vmaMapMemory(device->allocator, allocation, &data);
|
||||
return (result == VK_SUCCESS) ? data : nullptr;
|
||||
return (result == VK_SUCCESS) ? ((uint8_t*)data) + offset : nullptr;
|
||||
}
|
||||
|
||||
inline void VulkanImage::Unmap()
|
||||
|
|
|
@ -49,7 +49,8 @@ VkHardwareTexture::VkHardwareTexture()
|
|||
VkHardwareTexture::~VkHardwareTexture()
|
||||
{
|
||||
if (Next) Next->Prev = Prev;
|
||||
if (!Prev) First = Next;
|
||||
if (Prev) Prev->Next = Next;
|
||||
else First = Next;
|
||||
}
|
||||
|
||||
void VkHardwareTexture::Reset()
|
||||
|
|
Loading…
Reference in a new issue