Check for sparse buffer memory requirements when unbinding. Refs #580

* If a buffer is small, its memory requirements might be aligned up to
  a larger value for sparse binding.
This commit is contained in:
baldurk
2017-04-17 12:12:18 +01:00
parent af40baca4e
commit 9278af463a
+6 -2
View File
@@ -740,10 +740,14 @@ bool WrappedVulkan::Apply_SparseInitialState(WrappedVkBuffer *buf,
// unbind the entire buffer so that any new areas that are bound are unbound again
VkSparseMemoryBind unbind = {0, m_CreationInfo.m_Buffer[buf->id].size, VK_NULL_HANDLE, 0, 0};
VkQueue q = GetQ();
VkMemoryRequirements mrq = {};
ObjDisp(q)->GetBufferMemoryRequirements(Unwrap(GetDev()), buf->real.As<VkBuffer>(), &mrq);
VkSparseMemoryBind unbind = {0, RDCMAX(mrq.size, m_CreationInfo.m_Buffer[buf->id].size),
VK_NULL_HANDLE, 0, 0};
VkSparseBufferMemoryBindInfo bufBind = {buf->real.As<VkBuffer>(), 1, &unbind};
// this semaphore separates the unbind and bind, as there isn't an ordering guarantee