mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- do not use persistent buffers for models as it is a limited resource where each consumes a vkDeviceMemory object
This commit is contained in:
parent
4fff8a41b7
commit
0c6d0de3ab
2 changed files with 19 additions and 3 deletions
|
@ -110,15 +110,29 @@ void VKBuffer::Unmap()
|
|||
|
||||
void *VKBuffer::Lock(unsigned int size)
|
||||
{
|
||||
SetData(size, nullptr, false);
|
||||
if (!mPersistent)
|
||||
if (!mBuffer)
|
||||
{
|
||||
// The model mesh loaders lock multiple non-persistent buffers at the same time. This is not allowed in vulkan.
|
||||
// VkDeviceMemory can only be mapped once and multiple non-persistent buffers may come from the same device memory object.
|
||||
mStaticUpload.Resize(size);
|
||||
map = mStaticUpload.Data();
|
||||
}
|
||||
else if (!mPersistent)
|
||||
{
|
||||
map = mBuffer->Map(0, size);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
void VKBuffer::Unlock()
|
||||
{
|
||||
if (!mPersistent)
|
||||
if (!mBuffer)
|
||||
{
|
||||
map = nullptr;
|
||||
SetData(mStaticUpload.Size(), mStaticUpload.Data(), true);
|
||||
mStaticUpload.Clear();
|
||||
}
|
||||
else if (!mPersistent)
|
||||
{
|
||||
mBuffer->Unmap();
|
||||
map = nullptr;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
#include "vk_objects.h"
|
||||
#include "utility/tarray.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// silence bogus warning C4250: 'VKVertexBuffer': inherits 'VKBuffer::VKBuffer::SetData' via dominance
|
||||
|
@ -28,6 +29,7 @@ public:
|
|||
std::unique_ptr<VulkanBuffer> mBuffer;
|
||||
std::unique_ptr<VulkanBuffer> mStaging;
|
||||
bool mPersistent = false;
|
||||
TArray<uint8_t> mStaticUpload;
|
||||
};
|
||||
|
||||
class VKVertexBuffer : public IVertexBuffer, public VKBuffer
|
||||
|
|
Loading…
Reference in a new issue