mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +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
|
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();
|
auto fb = GetVulkanFrameBuffer();
|
||||||
|
|
||||||
mPersistent = screen->BuffersArePersistent() && !staticdata;
|
|
||||||
|
|
||||||
if (staticdata)
|
if (staticdata)
|
||||||
{
|
{
|
||||||
BufferBuilder builder;
|
mPersistent = false;
|
||||||
builder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY);
|
|
||||||
builder.setSize(size);
|
|
||||||
mBuffer = builder.create(fb->device);
|
|
||||||
|
|
||||||
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);
|
void *dst = mStaging->Map(0, size);
|
||||||
memcpy(dst, data, size);
|
memcpy(dst, data, size);
|
||||||
|
@ -40,6 +46,8 @@ void VKBuffer::SetData(size_t size, const void *data, bool staticdata)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
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_CPU_TO_GPU, mPersistent ? VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT : 0);
|
||||||
builder.setSize(size);
|
builder.setSize(size);
|
||||||
|
|
|
@ -376,7 +376,7 @@ inline void *VulkanBuffer::Map(size_t offset, size_t size)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
VkResult result = vmaMapMemory(device->allocator, allocation, &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()
|
inline void VulkanBuffer::Unmap()
|
||||||
|
@ -888,7 +888,7 @@ inline void *VulkanImage::Map(size_t offset, size_t size)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
VkResult result = vmaMapMemory(device->allocator, allocation, &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()
|
inline void VulkanImage::Unmap()
|
||||||
|
|
|
@ -49,7 +49,8 @@ VkHardwareTexture::VkHardwareTexture()
|
||||||
VkHardwareTexture::~VkHardwareTexture()
|
VkHardwareTexture::~VkHardwareTexture()
|
||||||
{
|
{
|
||||||
if (Next) Next->Prev = Prev;
|
if (Next) Next->Prev = Prev;
|
||||||
if (!Prev) First = Next;
|
if (Prev) Prev->Next = Next;
|
||||||
|
else First = Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkHardwareTexture::Reset()
|
void VkHardwareTexture::Reset()
|
||||||
|
|
Loading…
Reference in a new issue