Various Vulkan fixes (#5880)

* Various Vulkan fixes
- Swapchain related fix for UI editor
  -  Object of type VkQueue is simultaneously used in the main thread and the queue thread. Pushed the swapchain invalidation to the presentation queue thread

- Added padding for DepthOfFieldData to ensure it is 16 byte aligned
- Added aspect flag for SMAAEdgeDetectionTemplate pass
- Reduced MaxUnboundedArrayDescriptors so that it is under the maxDescriptorSetSampledImages limit
- Added CopyRead flag for ReflectionScreenSpaceBlurPass related transient resources.

Signed-off-by: moudgils <47460854+moudgils@users.noreply.github.com>

* Missed file

Signed-off-by: moudgils <47460854+moudgils@users.noreply.github.com>
This commit is contained in:
moudgils
2021-11-29 13:33:48 -08:00
committed by GitHub
parent c0fb80fd99
commit 1294cd0d7f
5 changed files with 22 additions and 10 deletions
@@ -15,7 +15,12 @@
{
"Name": "InputDepth",
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
"ScopeAttachmentUsage": "Shader",
"ImageViewDesc": {
"AspectFlags": [
"Depth"
]
}
},
{
"Name": "OutputEdgeDetectionResult",
@@ -26,8 +26,9 @@ partial ShaderResourceGroup ViewSrg
// circle of confusion to screen ratio;
float m_cocToScreenRatio;
[[pad_to(16)]]
};
DepthOfFieldData m_dof;
struct ExposureControlParameters
@@ -127,7 +127,7 @@ namespace AZ
{
RHI::Size mipSize = imageSize.GetReducedMip(mip);
RHI::ImageBindFlags imageBindFlags = RHI::ImageBindFlags::Color | RHI::ImageBindFlags::ShaderReadWrite;
RHI::ImageBindFlags imageBindFlags = RHI::ImageBindFlags::Color | RHI::ImageBindFlags::ShaderReadWrite | RHI::ImageBindFlags::CopyRead;
auto transientImageDesc = RHI::ImageDescriptor::Create2D(imageBindFlags, mipSize.m_width, mipSize.m_height, RHI::Format::R16G16B16A16_FLOAT);
RPI::PassAttachment* transientPassAttachment = aznew RPI::PassAttachment();
@@ -76,7 +76,7 @@ namespace AZ
const AZStd::vector<VkDescriptorBindingFlags>& GetNativeBindingFlags() const;
const RHI::ShaderResourceGroupLayout* GetShaderResourceGroupLayout() const;
static const uint32_t MaxUnboundedArrayDescriptors = (1024 * 1024 * 2); // 2M
static const uint32_t MaxUnboundedArrayDescriptors = 900000; //Using this number as it needs to be less than maxDescriptorSetSampledImages limit of 1048576
bool GetHasUnboundedArray() const { return m_hasUnboundedArray; }
private:
@@ -483,12 +483,18 @@ namespace AZ
void SwapChain::InvalidateNativeSwapChain()
{
auto& device = static_cast<Device&>(GetDevice());
vkDeviceWaitIdle(device.GetNativeDevice());
if (m_nativeSwapChain != VK_NULL_HANDLE)
auto presentCommand = [this, &device]([[maybe_unused]] void* queue)
{
vkDestroySwapchainKHR(device.GetNativeDevice(), m_nativeSwapChain, nullptr);
m_nativeSwapChain = VK_NULL_HANDLE;
}
vkDeviceWaitIdle(device.GetNativeDevice());
if (m_nativeSwapChain != VK_NULL_HANDLE)
{
vkDestroySwapchainKHR(device.GetNativeDevice(), m_nativeSwapChain, nullptr);
m_nativeSwapChain = VK_NULL_HANDLE;
}
};
m_presentationQueue->QueueCommand(AZStd::move(presentCommand));
m_presentationQueue->FlushCommands();
}
RHI::ResultCode SwapChain::CreateSwapchain()
@@ -496,7 +502,7 @@ namespace AZ
auto& device = static_cast<Device&>(GetDevice());
m_surfaceCapabilities = GetSurfaceCapabilities();
m_surfaceFormat = GetSupportedSurfaceFormat(GetDescriptor().m_dimensions.m_imageFormat);
m_surfaceFormat = GetSupportedSurfaceFormat(m_dimensions.m_imageFormat);
m_presentMode = GetSupportedPresentMode(GetDescriptor().m_verticalSyncInterval);
m_compositeAlphaFlagBits = GetSupportedCompositeAlpha();