From e7d092cdafe192b5f746998a2d94e29f954f96d5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 3 Aug 2017 11:05:18 +0100 Subject: [PATCH] Check format/sample support for creating MSAA <-> Array renderpasses --- renderdoc/driver/vulkan/vk_debug.cpp | 38 +++++++++++++++---- .../vulkan/wrappers/vk_device_funcs.cpp | 5 +++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 44d197ed3..3eff1246d 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -917,6 +917,20 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) attDesc.format = formats[f]; stages[1].module = modules[MS2ARR]; + // initialise to NULL + m_DepthMS2ArrayPipe[f] = NULL; + for(size_t s = 0; s < ARRAY_COUNT(sampleCounts); s++) + m_DepthArray2MSPipe[f][s] = NULL; + + // if the format isn't supported at all, bail out and don't try to create anything + if(!(m_pDriver->GetFormatProperties(attDesc.format).optimalTilingFeatures & + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) + { + RDCDEBUG("Depth copies MSAA -> Array not supported for format %s", + ToStr::Get(attDesc.format).c_str()); + continue; + } + VkRenderPass rp; vkr = m_pDriver->vkCreateRenderPass(dev, &rpinfo, NULL, &rp); @@ -931,13 +945,22 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) m_pDriver->vkDestroyRenderPass(dev, rp, NULL); stages[1].module = modules[ARR2MS]; + msaa.sampleShadingEnable = true; + msaa.minSampleShading = 1.0f; for(size_t s = 0; s < ARRAY_COUNT(sampleCounts); s++) { attDesc.samples = sampleCounts[s]; msaa.rasterizationSamples = sampleCounts[s]; - msaa.sampleShadingEnable = true; - msaa.minSampleShading = 1.0f; + + // if this sample count isn't supported, don't create it + if(!(m_pDriver->GetDeviceProps().limits.framebufferDepthSampleCounts & + (uint32_t)attDesc.samples)) + { + RDCDEBUG("Depth copies Array -> MSAA not supported for sample count %u on format %s", + attDesc.samples, ToStr::Get(attDesc.format).c_str()); + continue; + } vkr = m_pDriver->vkCreateRenderPass(dev, &rpinfo, NULL, &rp); RDCASSERTEQUAL(vkr, VK_SUCCESS); @@ -949,12 +972,13 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) RDCASSERTEQUAL(vkr, VK_SUCCESS); m_pDriver->vkDestroyRenderPass(dev, rp, NULL); - - attDesc.samples = VK_SAMPLE_COUNT_1_BIT; - msaa.sampleShadingEnable = false; - msaa.minSampleShading = 0.0f; - msaa.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; } + + attDesc.samples = VK_SAMPLE_COUNT_1_BIT; + msaa.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + + msaa.sampleShadingEnable = false; + msaa.minSampleShading = 0.0f; } // restore pipeline state to normal diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 7af5aadc9..a5001abb4 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -1472,6 +1472,11 @@ VkResult WrappedVulkan::vkCreateDevice(VkPhysicalDevice physicalDevice, ObjDisp(physicalDevice) ->GetPhysicalDeviceFeatures(Unwrap(physicalDevice), &m_PhysicalDeviceData.features); + for(int i = VK_FORMAT_BEGIN_RANGE + 1; i < VK_FORMAT_END_RANGE; i++) + ObjDisp(physicalDevice) + ->GetPhysicalDeviceFormatProperties(Unwrap(physicalDevice), VkFormat(i), + &m_PhysicalDeviceData.fmtprops[i]); + m_PhysicalDeviceData.readbackMemIndex = m_PhysicalDeviceData.GetMemoryIndex(~0U, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 0); m_PhysicalDeviceData.uploadMemIndex =