From 62c840dca2c0c8b2873ee171775e0e1dd94315ea Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 3 Feb 2017 10:25:20 +0000 Subject: [PATCH] Fix a problem with different mem requirements between capture and replay * If the usage flags on an image are different then the ICD might return different memory requirements at replay time, which are no longer respected by the offset/alignment that the application chose at capture time. * The real solution is to abstract the requirements and return our own set of pessimistic requirements that encompass most hardware. For the moment as a simpler solution we just add the same usage flags for both capture and replay, if a flag is needed for either. --- .../vulkan/wrappers/vk_resource_funcs.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index 7eb1cf203..85e1dcf36 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -822,7 +822,13 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(Serialiser *localSerialiser, VkDevi VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) { - VkResult ret = ObjDisp(device)->CreateBuffer(Unwrap(device), pCreateInfo, pAllocator, pBuffer); + VkBufferCreateInfo adjusted_info = *pCreateInfo; + + // TEMP HACK: Until we define a portable fake hardware, need to match the requirements for usage + // on replay, so that the memory requirements are the same + adjusted_info.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + + VkResult ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &adjusted_info, pAllocator, pBuffer); // SHARING: pCreateInfo sharingMode, queueFamilyCount, pQueueFamilyIndices @@ -1053,10 +1059,20 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo * createInfo_adjusted.usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + // TEMP HACK: Until we define a portable fake hardware, need to match the requirements for usage + // on replay, so that the memory requirements are the same + createInfo_adjusted.usage |= VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if(createInfo_adjusted.samples != VK_SAMPLE_COUNT_1_BIT) { createInfo_adjusted.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; createInfo_adjusted.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + + // TEMP HACK: matching replay requirements + if(!IsDepthOrStencilFormat(createInfo_adjusted.format)) + createInfo_adjusted.usage |= VK_IMAGE_USAGE_STORAGE_BIT; + else + createInfo_adjusted.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; } VkResult ret =