- 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue