diff --git a/src/rendering/vulkan/renderer/vk_renderpass.h b/src/rendering/vulkan/renderer/vk_renderpass.h index 16475e7d68..e19e82fffb 100644 --- a/src/rendering/vulkan/renderer/vk_renderpass.h +++ b/src/rendering/vulkan/renderer/vk_renderpass.h @@ -22,7 +22,7 @@ public: bool operator<(const VkRenderPassKey &other) const { - return memcmp(this, &other, sizeof(VkRenderPassKey)); + return memcmp(this, &other, sizeof(VkRenderPassKey)) < 0; } }; diff --git a/src/rendering/vulkan/system/vk_buffers.cpp b/src/rendering/vulkan/system/vk_buffers.cpp index 661329508d..e794c0714e 100644 --- a/src/rendering/vulkan/system/vk_buffers.cpp +++ b/src/rendering/vulkan/system/vk_buffers.cpp @@ -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); diff --git a/src/rendering/vulkan/system/vk_objects.h b/src/rendering/vulkan/system/vk_objects.h index 2fdbf14d44..095b04aee7 100644 --- a/src/rendering/vulkan/system/vk_objects.h +++ b/src/rendering/vulkan/system/vk_objects.h @@ -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() diff --git a/src/rendering/vulkan/textures/vk_hwtexture.cpp b/src/rendering/vulkan/textures/vk_hwtexture.cpp index 8ac88b1c03..e96afd3245 100644 --- a/src/rendering/vulkan/textures/vk_hwtexture.cpp +++ b/src/rendering/vulkan/textures/vk_hwtexture.cpp @@ -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()