From 2b5d07d74912205cf9d9eba4ef7a911573aa0156 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 17 Apr 2017 12:05:46 +0100 Subject: [PATCH] Assert that the whole-memory buffer created has valid requirements * This keeps the validation layers happy --- .../driver/vulkan/wrappers/vk_resource_funcs.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index eeb1bd088..9afb15b74 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -187,6 +187,14 @@ bool WrappedVulkan::Serialise_vkAllocateMemory(Serialiser *localSerialiser, VkDe ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &bufInfo, NULL, &buf); RDCASSERTEQUAL(ret, VK_SUCCESS); + // we already validated at replay time that the memory size is aligned/etc as necessary so we + // can create a buffer of the whole size, but just to keep the validation layers happy let's + // check the requirements here again. + VkMemoryRequirements mrq = {}; + ObjDisp(device)->GetBufferMemoryRequirements(Unwrap(device), buf, &mrq); + + RDCASSERT(mrq.size <= info.allocationSize, mrq.size, info.allocationSize); + ResourceId bufid = GetResourceManager()->WrapResource(Unwrap(device), buf); ObjDisp(device)->BindBufferMemory(Unwrap(device), Unwrap(buf), Unwrap(mem), 0); @@ -440,6 +448,14 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &bufInfo, NULL, &buf); RDCASSERTEQUAL(ret, VK_SUCCESS); + // we already validated above that the memory size is aligned/etc as necessary so we can + // create a buffer of the whole size, but just to keep the validation layers happy let's check + // the requirements here again. + VkMemoryRequirements mrq = {}; + ObjDisp(device)->GetBufferMemoryRequirements(Unwrap(device), buf, &mrq); + + RDCASSERTEQUAL(mrq.size, info.allocationSize); + ResourceId bufid = GetResourceManager()->WrapResource(Unwrap(device), buf); ObjDisp(device)->BindBufferMemory(Unwrap(device), Unwrap(buf), Unwrap(*pMemory), 0);