Fixes for Vulkan validation warnings related to RayTracing and DiffuseGI.
Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com>
This commit is contained in:
@@ -61,7 +61,11 @@ namespace AZ
|
||||
(RayTracingAccelerationStructure , AZ_BIT(9)),
|
||||
|
||||
/// Supports ray tracing shader table usage.
|
||||
(RayTracingShaderTable , AZ_BIT(10)));
|
||||
(RayTracingShaderTable , AZ_BIT(10)),
|
||||
|
||||
/// Supports ray tracing scratch buffer usage.
|
||||
(RayTracingScratchBuffer, AZ_BIT(11)));
|
||||
|
||||
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::RHI::BufferBindFlags);
|
||||
|
||||
|
||||
@@ -736,7 +736,7 @@ namespace AZ
|
||||
|
||||
if (RHI::CheckBitsAny(bindFlags, BindFlags::RayTracingAccelerationStructure))
|
||||
{
|
||||
usageFlags |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR;
|
||||
usageFlags |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR;
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAny(bindFlags, BindFlags::RayTracingShaderTable))
|
||||
@@ -756,7 +756,7 @@ namespace AZ
|
||||
{
|
||||
return RHI::CheckBitsAny(
|
||||
bindFlags,
|
||||
RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::DynamicInputAssembly | RHI::BufferBindFlags::RayTracingShaderTable);
|
||||
RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::DynamicInputAssembly | RHI::BufferBindFlags::RayTracingShaderTable | RHI::BufferBindFlags::RayTracingAccelerationStructure | RHI::BufferBindFlags::RayTracingScratchBuffer);
|
||||
}
|
||||
|
||||
VkPipelineStageFlags GetSupportedPipelineStages(RHI::PipelineStateType type)
|
||||
@@ -1154,15 +1154,20 @@ namespace AZ
|
||||
return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
|
||||
case RHI::ScopeAttachmentUsage::Shader:
|
||||
case RHI::ScopeAttachmentUsage::SubpassInput:
|
||||
// If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one.
|
||||
if (RHI::CheckBitsAny(imageAspects, RHI::ImageAspectFlags::DepthStencil))
|
||||
{
|
||||
return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
|
||||
// If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one.
|
||||
// Note that if the Image is ShaderWrite we always set VK_IMAGE_LAYOUT_GENERAL, even in a read scope.
|
||||
if (RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ||
|
||||
RHI::CheckBitsAny(imageView->GetImage().GetDescriptor().m_bindFlags, RHI::ImageBindFlags::ShaderWrite))
|
||||
{
|
||||
return VK_IMAGE_LAYOUT_GENERAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RHI::CheckBitsAny(imageAspects, RHI::ImageAspectFlags::DepthStencil) ?
|
||||
VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
}
|
||||
case RHI::ScopeAttachmentUsage::Copy:
|
||||
return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
default:
|
||||
|
||||
@@ -149,16 +149,17 @@ namespace AZ
|
||||
{
|
||||
imageInfo.imageView = imageView->GetNativeImageView();
|
||||
|
||||
// Depending on the access (read or readwrite) and if it's a depth/stencil image, we choose the expected layout.
|
||||
switch (layout.GetDescriptorType(layoutIndex))
|
||||
// If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one.
|
||||
// Note that if the Image is ShaderWrite we always set VK_IMAGE_LAYOUT_GENERAL, even if the descriptor layout wants a read-only input.
|
||||
if (layout.GetDescriptorType(layoutIndex) == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE ||
|
||||
RHI::CheckBitsAny(imageView->GetImage().GetDescriptor().m_bindFlags, RHI::ImageBindFlags::ShaderWrite))
|
||||
{
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
imageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
else
|
||||
{
|
||||
imageInfo.imageLayout = RHI::CheckBitsAny(imageView->GetImage().GetAspectFlags(), RHI::ImageAspectFlags::DepthStencil) ?
|
||||
VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -216,11 +216,24 @@ namespace AZ
|
||||
float16Int8.pNext = &separateDepthStencil;
|
||||
|
||||
robustness2.pNext = &float16Int8;
|
||||
|
||||
|
||||
deviceInfo.pNext = &descriptorIndexingFeatures;
|
||||
}
|
||||
|
||||
// set raytracing features if we are running Vulkan >= 1.2
|
||||
VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationStructureFeatures = {};
|
||||
VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineFeatures = {};
|
||||
|
||||
if (majorVersion >= 1 && minorVersion >= 2)
|
||||
{
|
||||
accelerationStructureFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR;
|
||||
accelerationStructureFeatures.accelerationStructure = physicalDevice.GetPhysicalDeviceAccelerationStructureFeatures().accelerationStructure;
|
||||
vulkan12Features.pNext = &accelerationStructureFeatures;
|
||||
|
||||
rayTracingPipelineFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR;
|
||||
rayTracingPipelineFeatures.rayTracingPipeline = physicalDevice.GetPhysicalDeviceRayTracingPipelineFeatures().rayTracingPipeline;
|
||||
accelerationStructureFeatures.pNext = &rayTracingPipelineFeatures;
|
||||
}
|
||||
|
||||
deviceInfo.flags = 0;
|
||||
deviceInfo.queueCreateInfoCount = static_cast<uint32_t>(queueCreationInfo.size());
|
||||
deviceInfo.pQueueCreateInfos = queueCreationInfo.data();
|
||||
|
||||
@@ -111,11 +111,21 @@ namespace AZ
|
||||
return m_accelerationStructureProperties;
|
||||
}
|
||||
|
||||
const VkPhysicalDeviceAccelerationStructureFeaturesKHR& PhysicalDevice::GetPhysicalDeviceAccelerationStructureFeatures() const
|
||||
{
|
||||
return m_accelerationStructureFeatures;
|
||||
}
|
||||
|
||||
const VkPhysicalDeviceRayTracingPipelinePropertiesKHR& PhysicalDevice::GetPhysicalDeviceRayTracingPipelineProperties() const
|
||||
{
|
||||
return m_rayTracingPipelineProperties;
|
||||
}
|
||||
|
||||
const VkPhysicalDeviceRayTracingPipelineFeaturesKHR& PhysicalDevice::GetPhysicalDeviceRayTracingPipelineFeatures() const
|
||||
{
|
||||
return m_rayTracingPipelineFeatures;
|
||||
}
|
||||
|
||||
const VkPhysicalDeviceShaderFloat16Int8FeaturesKHR& PhysicalDevice::GetPhysicalDeviceFloat16Int8Features() const
|
||||
{
|
||||
return m_float16Int8Features;
|
||||
@@ -349,6 +359,16 @@ namespace AZ
|
||||
vulkan12Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||
separateDepthStencilFeatures.pNext = &vulkan12Features;
|
||||
|
||||
VkPhysicalDeviceAccelerationStructureFeaturesKHR& accelerationStructureFeatures = m_accelerationStructureFeatures;
|
||||
accelerationStructureFeatures = {};
|
||||
accelerationStructureFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR;
|
||||
vulkan12Features.pNext = &accelerationStructureFeatures;
|
||||
|
||||
VkPhysicalDeviceRayTracingPipelineFeaturesKHR& rayTracingPipelineFeatures = m_rayTracingPipelineFeatures;
|
||||
rayTracingPipelineFeatures = {};
|
||||
rayTracingPipelineFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR;
|
||||
accelerationStructureFeatures.pNext = &rayTracingPipelineFeatures;
|
||||
|
||||
VkPhysicalDeviceFeatures2 deviceFeatures2 = {};
|
||||
deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
deviceFeatures2.pNext = &descriptorIndexingFeatures;
|
||||
|
||||
@@ -82,7 +82,9 @@ namespace AZ
|
||||
const VkPhysicalDeviceVulkan12Features& GetPhysicalDeviceVulkan12Features() const;
|
||||
const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR& GetPhysicalDeviceSeparateDepthStencilFeatures() const;
|
||||
const VkPhysicalDeviceAccelerationStructurePropertiesKHR& GetPhysicalDeviceAccelerationStructureProperties() const;
|
||||
const VkPhysicalDeviceAccelerationStructureFeaturesKHR& GetPhysicalDeviceAccelerationStructureFeatures() const;
|
||||
const VkPhysicalDeviceRayTracingPipelinePropertiesKHR& GetPhysicalDeviceRayTracingPipelineProperties() const;
|
||||
const VkPhysicalDeviceRayTracingPipelineFeaturesKHR& GetPhysicalDeviceRayTracingPipelineFeatures() const;
|
||||
VkFormatProperties GetFormatProperties(RHI::Format format, bool raiseAsserts = true) const;
|
||||
StringList GetDeviceLayerNames() const;
|
||||
StringList GetDeviceExtensionNames(const char* layerName = nullptr) const;
|
||||
@@ -116,7 +118,9 @@ namespace AZ
|
||||
VkPhysicalDeviceBufferDeviceAddressFeaturesEXT m_bufferDeviceAddressFeatures{};
|
||||
VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR m_separateDepthStencilFeatures{};
|
||||
VkPhysicalDeviceAccelerationStructurePropertiesKHR m_accelerationStructureProperties{};
|
||||
VkPhysicalDeviceAccelerationStructureFeaturesKHR m_accelerationStructureFeatures{};
|
||||
VkPhysicalDeviceRayTracingPipelinePropertiesKHR m_rayTracingPipelineProperties{};
|
||||
VkPhysicalDeviceRayTracingPipelineFeaturesKHR m_rayTracingPipelineFeatures{};
|
||||
VkPhysicalDeviceVulkan12Features m_vulkan12Features{};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace AZ
|
||||
// create scratch buffer
|
||||
buffers.m_scratchBuffer = RHI::Factory::Get().CreateBuffer();
|
||||
AZ::RHI::BufferDescriptor scratchBufferDescriptor;
|
||||
scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite;
|
||||
scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer;
|
||||
scratchBufferDescriptor.m_byteCount = buildSizesInfo.buildScratchSize;
|
||||
|
||||
AZ::RHI::BufferInitRequest scratchBufferRequest;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace AZ
|
||||
|
||||
protected:
|
||||
virtual RHI::BufferBindFlags GetShaderTableBufferBindFlags() const override { return RHI::BufferBindFlags::CopyRead | RHI::BufferBindFlags::RayTracingShaderTable; }
|
||||
virtual RHI::BufferBindFlags GetScratchBufferBindFlags() const override { return RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; }
|
||||
virtual RHI::BufferBindFlags GetTlasInstancesBufferBindFlags() const override { return RHI::BufferBindFlags::ShaderRead | RHI::BufferBindFlags::RayTracingAccelerationStructure; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace AZ
|
||||
// create scratch buffer
|
||||
buffers.m_scratchBuffer = RHI::Factory::Get().CreateBuffer();
|
||||
AZ::RHI::BufferDescriptor scratchBufferDescriptor;
|
||||
scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite;
|
||||
scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer;
|
||||
scratchBufferDescriptor.m_byteCount = buildSizesInfo.buildScratchSize;
|
||||
|
||||
AZ::RHI::BufferInitRequest scratchBufferRequest;
|
||||
|
||||
@@ -8028,19 +8028,25 @@ typedef struct VkBindAccelerationStructureMemoryInfoKHR {
|
||||
|
||||
typedef struct VkBindAccelerationStructureMemoryInfoKHR VkBindAccelerationStructureMemoryInfoNV;
|
||||
|
||||
typedef struct VkPhysicalDeviceRayTracingFeaturesKHR {
|
||||
typedef struct VkPhysicalDeviceRayTracingPipelineFeaturesKHR {
|
||||
VkStructureType sType;
|
||||
void * pNext;
|
||||
VkBool32 rayTracing;
|
||||
VkBool32 rayTracingShaderGroupHandleCaptureReplay;
|
||||
VkBool32 rayTracingShaderGroupHandleCaptureReplayMixed;
|
||||
VkBool32 rayTracingAccelerationStructureCaptureReplay;
|
||||
VkBool32 rayTracingIndirectTraceRays;
|
||||
VkBool32 rayTracingIndirectAccelerationStructureBuild;
|
||||
VkBool32 rayTracingHostAccelerationStructureCommands;
|
||||
VkBool32 rayQuery;
|
||||
VkBool32 rayTracingPrimitiveCulling;
|
||||
} VkPhysicalDeviceRayTracingFeaturesKHR;
|
||||
void* pNext;
|
||||
VkBool32 rayTracingPipeline;
|
||||
VkBool32 rayTracingPipelineShaderGroupHandleCaptureReplay;
|
||||
VkBool32 rayTracingPipelineShaderGroupHandleCaptureReplayMixed;
|
||||
VkBool32 rayTracingPipelineTraceRaysIndirect;
|
||||
VkBool32 rayTraversalPrimitiveCulling;
|
||||
} VkPhysicalDeviceRayTracingPipelineFeaturesKHR;
|
||||
|
||||
typedef struct VkPhysicalDeviceAccelerationStructureFeaturesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 accelerationStructure;
|
||||
VkBool32 accelerationStructureCaptureReplay;
|
||||
VkBool32 accelerationStructureIndirectBuild;
|
||||
VkBool32 accelerationStructureHostCommands;
|
||||
VkBool32 descriptorBindingAccelerationStructureUpdateAfterBind;
|
||||
} VkPhysicalDeviceAccelerationStructureFeaturesKHR;
|
||||
|
||||
typedef struct VkStridedBufferRegionKHR {
|
||||
VkBuffer buffer;
|
||||
|
||||
Reference in New Issue
Block a user