summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-10-04 23:59:33 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-10-04 23:59:33 +0000
commit73fd82a29d3175e156754010f5de261d6f561f16 (patch)
treef04b71a06b71addb56d2a79885e53d253caa417e /Graphics
parentAdded KHR extension emulation via NV extension (diff)
downloadDiligentCore-73fd82a29d3175e156754010f5de261d6f561f16.tar.gz
DiligentCore-73fd82a29d3175e156754010f5de261d6f561f16.zip
A few random fixes to ray tracing API and implementation
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp49
-rw-r--r--Graphics/GraphicsEngine/include/BottomLevelASBase.hpp58
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.hpp18
-rw-r--r--Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp22
-rw-r--r--Graphics/GraphicsEngine/include/TopLevelASBase.hpp28
-rw-r--r--Graphics/GraphicsEngine/interface/BottomLevelAS.h27
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h35
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h1
-rw-r--r--Graphics/GraphicsEngine/interface/RenderDevice.h28
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderBindingTable.h2
-rw-r--r--Graphics/GraphicsEngine/interface/TopLevelAS.h12
-rw-r--r--Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp1
-rw-r--r--Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp20
-rw-r--r--Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.hpp10
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.hpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/BottomLevelASVk.h4
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/BufferVk.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h11
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/TopLevelASVk.h7
-rw-r--r--Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp7
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp43
-rw-r--r--Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp6
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderBindingTableVkImpl.cpp16
-rw-r--r--Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp3
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp52
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanRayTracingKHRviaNV.cpp149
-rw-r--r--Graphics/ShaderTools/src/GLSLangUtils.cpp2
-rw-r--r--Graphics/ShaderTools/src/SPIRVShaderResources.cpp2
35 files changed, 361 insertions, 274 deletions
diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
index 3f1b3f72..00cb22e4 100644
--- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
+++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp
@@ -474,7 +474,7 @@ const Char* GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType)
const Char* GetShaderTypeLiteralName(SHADER_TYPE ShaderType)
{
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please handle the new shader type in the switch below");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please handle the new shader type in the switch below");
switch (ShaderType)
{
// clang-format off
@@ -819,23 +819,23 @@ const Char* GetResourceDimString(RESOURCE_DIMENSION TexType)
const Char* GetBindFlagString(Uint32 BindFlag)
{
- static_assert(BIND_FLAGS_LAST == 0x400L, "AZ TODO");
+ VERIFY((BindFlag & (BindFlag - 1)) == 0, "More than one bind flag is specified");
- VERIFY((BindFlag & (BindFlag - 1)) == 0, "More than one bind flag specified");
+ static_assert(BIND_FLAGS_LAST == BIND_RAY_TRACING, "Please handle the new bind flag in the switch below");
switch (BindFlag)
{
// clang-format off
#define BIND_FLAG_STR_CASE(Flag) case Flag: return #Flag;
- BIND_FLAG_STR_CASE( BIND_VERTEX_BUFFER )
- BIND_FLAG_STR_CASE( BIND_INDEX_BUFFER )
- BIND_FLAG_STR_CASE( BIND_UNIFORM_BUFFER )
- BIND_FLAG_STR_CASE( BIND_SHADER_RESOURCE )
- BIND_FLAG_STR_CASE( BIND_STREAM_OUTPUT )
- BIND_FLAG_STR_CASE( BIND_RENDER_TARGET )
- BIND_FLAG_STR_CASE( BIND_DEPTH_STENCIL )
- BIND_FLAG_STR_CASE( BIND_UNORDERED_ACCESS )
- BIND_FLAG_STR_CASE( BIND_INDIRECT_DRAW_ARGS )
- BIND_FLAG_STR_CASE( BIND_RAY_TRACING )
+ BIND_FLAG_STR_CASE(BIND_VERTEX_BUFFER)
+ BIND_FLAG_STR_CASE(BIND_INDEX_BUFFER)
+ BIND_FLAG_STR_CASE(BIND_UNIFORM_BUFFER)
+ BIND_FLAG_STR_CASE(BIND_SHADER_RESOURCE)
+ BIND_FLAG_STR_CASE(BIND_STREAM_OUTPUT)
+ BIND_FLAG_STR_CASE(BIND_RENDER_TARGET)
+ BIND_FLAG_STR_CASE(BIND_DEPTH_STENCIL)
+ BIND_FLAG_STR_CASE(BIND_UNORDERED_ACCESS)
+ BIND_FLAG_STR_CASE(BIND_INDIRECT_DRAW_ARGS)
+ BIND_FLAG_STR_CASE(BIND_RAY_TRACING)
#undef BIND_FLAG_STR_CASE
// clang-format on
default: UNEXPECTED("Unexpected bind flag ", BindFlag); return "";
@@ -1034,7 +1034,7 @@ String GetBufferDescString(const BufferDesc& Desc)
const Char* GetResourceStateFlagString(RESOURCE_STATE State)
{
VERIFY((State & (State - 1)) == 0, "Single state is expected");
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "Please update this function to handle the new resource state");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "Please update this function to handle the new resource state");
switch (State)
{
// clang-format off
@@ -1187,7 +1187,7 @@ Uint32 ComputeMipLevelsCount(Uint32 Width, Uint32 Height, Uint32 Depth)
bool VerifyResourceStates(RESOURCE_STATE State, bool IsTexture)
{
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "Please update this function to handle the new resource state");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "Please update this function to handle the new resource state");
// clang-format off
#define VERIFY_EXCLUSIVE_STATE(ExclusiveState)\
@@ -1301,7 +1301,7 @@ ADAPTER_VENDOR VendorIdToAdapterVendor(Uint32 VendorId)
bool IsConsistentShaderType(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineType)
{
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type");
switch (PipelineType)
{
case PIPELINE_TYPE_GRAPHICS:
@@ -1339,7 +1339,7 @@ Int32 GetShaderTypePipelineIndex(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineT
" is inconsistent with pipeline type ", GetPipelineTypeString(PipelineType));
VERIFY(IsPowerOfTwo(Uint32{ShaderType}), "Only single shader stage should be provided");
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type");
switch (ShaderType)
{
case SHADER_TYPE_UNKNOWN:
@@ -1363,6 +1363,15 @@ Int32 GetShaderTypePipelineIndex(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineT
case SHADER_TYPE_PIXEL: // Graphics or Mesh
return 4;
+ case SHADER_TYPE_RAY_GEN:
+ case SHADER_TYPE_RAY_MISS:
+ case SHADER_TYPE_RAY_CLOSEST_HIT:
+ case SHADER_TYPE_RAY_ANY_HIT:
+ case SHADER_TYPE_RAY_INTERSECTION:
+ case SHADER_TYPE_CALLABLE:
+ UNEXPECTED("This function is not currently indended to handle ray-tracing shader types");
+ return -1;
+
default:
UNEXPECTED("Unexpected shader type (", ShaderType, ")");
return -1;
@@ -1371,7 +1380,7 @@ Int32 GetShaderTypePipelineIndex(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineT
SHADER_TYPE GetShaderTypeFromPipelineIndex(Int32 Index, PIPELINE_TYPE PipelineType)
{
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type");
switch (PipelineType)
{
case PIPELINE_TYPE_GRAPHICS:
@@ -1410,6 +1419,10 @@ SHADER_TYPE GetShaderTypeFromPipelineIndex(Int32 Index, PIPELINE_TYPE PipelineTy
return SHADER_TYPE_UNKNOWN;
}
+ case PIPELINE_TYPE_RAY_TRACING:
+ UNEXPECTED("Ray tracing pipeline is not supported by this function");
+ return SHADER_TYPE_UNKNOWN;
+
default:
UNEXPECTED("Unexpected pipeline type");
return SHADER_TYPE_UNKNOWN;
diff --git a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
index e0fcde4f..7f1e402f 100644
--- a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
+++ b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp
@@ -30,12 +30,14 @@
/// \file
/// Implementation of the Diligent::BottomLevelASBase template class
+#include <map>
+#include <memory>
+
#include "BottomLevelAS.h"
#include "DeviceObjectBase.hpp"
#include "RenderDeviceBase.hpp"
#include "StringPool.hpp"
#include "StringView.hpp"
-#include <map>
namespace Diligent
{
@@ -52,27 +54,24 @@ class BottomLevelASBase : public DeviceObjectBase<BaseInterface, RenderDeviceImp
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BottomLevelASDesc>;
- /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS.
- /// \param pDevice - pointer to the device.
- /// \param Desc - BLAS description.
+ /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS.
+ /// \param pDevice - pointer to the device.
+ /// \param Desc - BLAS description.
/// \param bIsDeviceInternal - flag indicating if the BLAS is an internal device object and
/// must not keep a strong reference to the device.
- BottomLevelASBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const BottomLevelASDesc& Desc, bool bIsDeviceInternal = false) :
+ BottomLevelASBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const BottomLevelASDesc& Desc,
+ bool bIsDeviceInternal = false) :
TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
{
ValidateBottomLevelASDesc(Desc);
- // Memory must be released even if exception was thrown.
- struct MemOwner
- {
- void* ptr = nullptr;
-
- ~MemOwner()
- {
- if (ptr != nullptr)
- GetRawAllocator().Free(ptr);
- }
- } memOwner;
+ // Memory must be released if an exception is thrown.
+ auto RawMemDeleter = [](void* ptr) {
+ if (ptr != nullptr)
+ GetRawAllocator().Free(ptr);
+ };
if (Desc.pTriangles != nullptr)
{
@@ -87,12 +86,12 @@ public:
m_StringPool.Reserve(StringPoolSize, GetRawAllocator());
- auto* pTriangles = ALLOCATE(GetRawAllocator(), "Memory for BLASTriangleDesc array", BLASTriangleDesc, Desc.TriangleCount);
- memOwner.ptr = pTriangles;
+ std::unique_ptr<BLASTriangleDesc[], decltype(RawMemDeleter)> pTriangles{
+ ALLOCATE(GetRawAllocator(), "Memory for BLASTriangleDesc array", BLASTriangleDesc, Desc.TriangleCount),
+ RawMemDeleter};
- std::memcpy(pTriangles, Desc.pTriangles, sizeof(*Desc.pTriangles) * Desc.TriangleCount);
- this->m_Desc.pTriangles = pTriangles;
- this->m_Desc.pBoxes = nullptr;
+ std::memcpy(pTriangles.get(), Desc.pTriangles, sizeof(*Desc.pTriangles) * Desc.TriangleCount);
+ this->m_Desc.pBoxes = nullptr;
// copy strings
for (Uint32 i = 0; i < Desc.TriangleCount; ++i)
@@ -102,6 +101,7 @@ public:
if (!IsUniqueName)
LOG_ERROR_AND_THROW("Geometry name must be unique!");
}
+ this->m_Desc.pTriangles = pTriangles.release();
}
else if (Desc.pBoxes != nullptr)
{
@@ -116,11 +116,11 @@ public:
m_StringPool.Reserve(StringPoolSize, GetRawAllocator());
- auto* pBoxes = ALLOCATE(GetRawAllocator(), "Memory for BLASBoundingBoxDesc array", BLASBoundingBoxDesc, Desc.BoxCount);
- memOwner.ptr = pBoxes;
+ std::unique_ptr<BLASBoundingBoxDesc[], decltype(RawMemDeleter)> pBoxes{
+ ALLOCATE(GetRawAllocator(), "Memory for BLASBoundingBoxDesc array", BLASBoundingBoxDesc, Desc.BoxCount),
+ RawMemDeleter};
- std::memcpy(pBoxes, Desc.pBoxes, sizeof(*Desc.pBoxes) * Desc.BoxCount);
- this->m_Desc.pBoxes = pBoxes;
+ std::memcpy(pBoxes.get(), Desc.pBoxes, sizeof(*Desc.pBoxes) * Desc.BoxCount);
this->m_Desc.pTriangles = nullptr;
// copy strings
@@ -131,10 +131,8 @@ public:
if (!IsUniqueName)
LOG_ERROR_AND_THROW("Geometry name must be unique!");
}
+ this->m_Desc.pBoxes = pBoxes.release();
}
-
- // Constructor completed successfully and memory will be released in destructor.
- memOwner.ptr = nullptr;
}
~BottomLevelASBase()
@@ -168,7 +166,7 @@ protected:
if (!((Desc.pBoxes != nullptr) ^ (Desc.pTriangles != nullptr)))
{
- LOG_BLAS_ERROR_AND_THROW("Only one of pTriangles and pBoxes must be defined");
+ LOG_BLAS_ERROR_AND_THROW("Exactly one of pTriangles and pBoxes must be defined");
}
if (Desc.pBoxes == nullptr && Desc.BoxCount > 0)
@@ -187,7 +185,7 @@ protected:
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BottomLevelAS, TDeviceObjectBase)
protected:
- std::map<StringView, Uint32> m_NameToIndex;
+ std::map<StringView, Uint32> m_NameToIndex; // TODO (AZ): use unordered_map?
StringPool m_StringPool;
};
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
index 57c2ba16..dd8851c7 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
@@ -1909,7 +1909,7 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::BuildBLAS(const BLA
if ((Attribs.pTriangleData != nullptr) ^ (Attribs.pBoxData != nullptr))
{
- LOG_ERROR_MESSAGE("IDeviceContext::BuildBLAS: only one of pTriangles and pBoxes must be defined");
+ LOG_ERROR_MESSAGE("IDeviceContext::BuildBLAS: exactly one of pTriangles and pBoxes must be defined");
return false;
}
@@ -2164,14 +2164,16 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBLAS(const Copy
auto& SrcTri = SrcDesc.pTriangles[i];
auto& DstTri = DstDesc.pTriangles[i];
- if (SrcTri.MaxVertexCount != DstTri.MaxVertexCount ||
- SrcTri.VertexValueType != DstTri.VertexValueType ||
+ // clang-format off
+ if (SrcTri.MaxVertexCount != DstTri.MaxVertexCount ||
+ SrcTri.VertexValueType != DstTri.VertexValueType ||
SrcTri.VertexComponentCount != DstTri.VertexComponentCount ||
- SrcTri.MaxIndexCount != DstTri.MaxIndexCount ||
- SrcTri.IndexType != DstTri.IndexType ||
- SrcTri.AllowsTransforms != DstTri.AllowsTransforms)
+ SrcTri.MaxIndexCount != DstTri.MaxIndexCount ||
+ SrcTri.IndexType != DstTri.IndexType ||
+ SrcTri.AllowsTransforms != DstTri.AllowsTransforms)
+ // clang-format on
{
- LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different triangles description at index: ", i, ", pDst must have been created with the same parameters as pSrc");
+ LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different triangle descriptions at index: ", i, ", pDst must have been created with the same parameters as pSrc");
return false;
}
}
@@ -2180,7 +2182,7 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBLAS(const Copy
{
if (SrcDesc.pBoxes[i].MaxBoxCount != DstDesc.pBoxes[i].MaxBoxCount)
{
- LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different boxes description at index: ", i, ", pDst must have been created with the same parameters as pSrc");
+ LOG_ERROR_MESSAGE("IDeviceContext::CopyBLAS: different box descriptions at index: ", i, ", pDst must have been created with the same parameters as pSrc");
return false;
}
}
diff --git a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
index d615450a..44c99c7c 100644
--- a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
+++ b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp
@@ -30,12 +30,13 @@
/// \file
/// Implementation of the Diligent::ShaderBindingTableBase template class
+#include <map>
+
#include "ShaderBindingTable.h"
#include "DeviceObjectBase.hpp"
#include "RenderDeviceBase.hpp"
#include "StringPool.hpp"
#include "StringView.hpp"
-#include <map>
namespace Diligent
{
@@ -52,12 +53,15 @@ class ShaderBindingTableBase : public DeviceObjectBase<BaseInterface, RenderDevi
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderBindingTableDesc>;
- /// \param pRefCounters - reference counters object that controls the lifetime of this SBT.
- /// \param pDevice - pointer to the device.
- /// \param Desc - SBT description.
+ /// \param pRefCounters - reference counters object that controls the lifetime of this SBT.
+ /// \param pDevice - pointer to the device.
+ /// \param Desc - SBT description.
/// \param bIsDeviceInternal - flag indicating if the BLAS is an internal device object and
/// must not keep a strong reference to the device.
- ShaderBindingTableBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const ShaderBindingTableDesc& Desc, bool bIsDeviceInternal = false) :
+ ShaderBindingTableBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const ShaderBindingTableDesc& Desc,
+ bool bIsDeviceInternal = false) :
TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
{
ValidateShaderBindingTableDesc(Desc);
@@ -74,12 +78,12 @@ protected:
if (Desc.pPSO == nullptr)
{
- LOG_SBT_ERROR_AND_THROW("PipelineState must not be null");
+ LOG_SBT_ERROR_AND_THROW("pPSO must not be null");
}
if (Desc.pPSO->GetDesc().PipelineType != PIPELINE_TYPE_RAY_TRACING)
{
- LOG_SBT_ERROR_AND_THROW("PipelineState must be ray tracing pipeline");
+ LOG_SBT_ERROR_AND_THROW("pPSO must be ray tracing pipeline");
}
#undef LOG_SBT_ERROR_AND_THROW
@@ -88,9 +92,9 @@ protected:
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_ShaderBindingTable, TDeviceObjectBase)
protected:
- std::map<StringView, Uint32> m_NameToIndex;
+ std::map<StringView, Uint32> m_NameToIndex; // TODO (AZ): use unordered_map?
StringPool m_StringPool;
- std::map<StringView, TLASInstanceDesc> m_Instances;
+ std::map<StringView, TLASInstanceDesc> m_Instances; // TODO (AZ): use unordered_map?
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp
index 143cf54f..7c207a9d 100644
--- a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp
+++ b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp
@@ -52,12 +52,15 @@ class TopLevelASBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplTy
public:
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, TopLevelASDesc>;
- /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS.
- /// \param pDevice - pointer to the device.
- /// \param Desc - TLAS description.
+ /// \param pRefCounters - reference counters object that controls the lifetime of this BLAS.
+ /// \param pDevice - pointer to the device.
+ /// \param Desc - TLAS description.
/// \param bIsDeviceInternal - flag indicating if the BLAS is an internal device object and
/// must not keep a strong reference to the device.
- TopLevelASBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const TopLevelASDesc& Desc, bool bIsDeviceInternal = false) :
+ TopLevelASBase(IReferenceCounters* pRefCounters,
+ RenderDeviceImplType* pDevice,
+ const TopLevelASDesc& Desc,
+ bool bIsDeviceInternal = false) :
TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal}
{
ValidateTopLevelASDesc(Desc);
@@ -89,7 +92,7 @@ public:
Desc.contributionToHitGroupIndex = inst.contributionToHitGroupIndex;
Desc.pBLAS = inst.pBLAS;
- bool IsUniqueName = m_Instances.insert_or_assign(StringView{NameCopy}, Desc).second;
+ bool IsUniqueName = m_Instances.emplace(StringView{NameCopy}, Desc).second;
if (!IsUniqueName)
LOG_ERROR_AND_THROW("Instance name must be unique!");
}
@@ -104,12 +107,14 @@ public:
auto iter = m_Instances.find(StringView{Name});
if (iter != m_Instances.end())
{
- Result.contributionToHitGroupIndex = iter->second.contributionToHitGroupIndex;
+ Result.ContributionToHitGroupIndex = iter->second.contributionToHitGroupIndex;
Result.pBLAS = iter->second.pBLAS;
- return Result;
+ }
+ else
+ {
+ UNEXPECTED("Can't find instance with the specified name ('", Name, "')");
}
- UNEXPECTED("Can't find instance with specified name");
return Result;
}
@@ -123,9 +128,10 @@ protected:
LOG_TLAS_ERROR_AND_THROW("MaxInstanceCount must not be zero");
}
- if (!!(Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_TRACE) + !!(Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_BUILD))
+ if ((Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_TRACE) != 0 ||
+ (Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_BUILD) != 0)
{
- LOG_TLAS_ERROR_AND_THROW("Used incompatible flags: RAYTRACING_BUILD_AS_PREFER_FAST_TRACE and RAYTRACING_BUILD_AS_PREFER_FAST_BUILD");
+ LOG_TLAS_ERROR_AND_THROW("RAYTRACING_BUILD_AS_PREFER_FAST_TRACE and RAYTRACING_BUILD_AS_PREFER_FAST_BUILD are invalid");
}
#undef LOG_TLAS_ERROR_AND_THROW
@@ -141,7 +147,7 @@ protected:
};
StringPool m_StringPool;
- std::map<StringView, InstanceDesc> m_Instances;
+ std::map<StringView, InstanceDesc> m_Instances; // TODO(AZ): use unordered_map?
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/BottomLevelAS.h b/Graphics/GraphicsEngine/interface/BottomLevelAS.h
index 507f461c..cc8c4aec 100644
--- a/Graphics/GraphicsEngine/interface/BottomLevelAS.h
+++ b/Graphics/GraphicsEngine/interface/BottomLevelAS.h
@@ -49,15 +49,15 @@ static const INTERFACE_ID IID_BottomLevelAS =
/// AZ TODO
struct BLASTriangleDesc
{
- /// The geometry name.
- /// Name used only to map BLASBuildTriangleData to this geometry.
+ /// Geometry name.
+ /// The name is used to map BLASBuildTriangleData to this geometry.
const char* GeometryName DEFAULT_INITIALIZER(nullptr);
/// The maximum vertex count for this geometry.
- /// Current number of vertices defined in BLASBuildTriangleData::VertexCount.
+ /// Current number of vertices is defined in BLASBuildTriangleData::VertexCount.
Uint32 MaxVertexCount DEFAULT_INITIALIZER(0);
- /// The vertices value type of this geometry.
+ /// The type of vertices in this geometry.
/// Float, Int16 are supported.
VALUE_TYPE VertexValueType DEFAULT_INITIALIZER(VT_UNDEFINED);
@@ -66,11 +66,11 @@ struct BLASTriangleDesc
Uint8 VertexComponentCount DEFAULT_INITIALIZER(0);
/// The maximum index count for this geometry.
- /// Current number of indices defined in BLASBuildTriangleData::IndexCount.
- /// Must be 0 if IndexType is VT_UNDEFINED and greater than zero otherwise.
+ /// The current number of indices is defined in BLASBuildTriangleData::IndexCount.
+ /// It must be 0 if IndexType is VT_UNDEFINED and greater than zero otherwise.
Uint32 MaxIndexCount DEFAULT_INITIALIZER(0);
- /// The indices type of this geometry.
+ /// Index type of this geometry.
/// Must be VT_UINT16, VT_UINT32 or VT_UNDEFINED.
VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED);
@@ -90,8 +90,8 @@ typedef struct BLASTriangleDesc BLASTriangleDesc;
/// AZ TODO
struct BLASBoundingBoxDesc
{
- /// The geometry name.
- /// Name used only to map BLASBuildBoundingBoxData to this geometry.
+ /// Geometry name.
+ /// The name is used to map BLASBuildBoundingBoxData to this geometry.
const char* GeometryName DEFAULT_INITIALIZER(nullptr);
/// The maximum AABBs count.
@@ -127,7 +127,8 @@ DILIGENT_TYPED_ENUM(RAYTRACING_BUILD_AS_FLAGS, Uint8)
/// Indicates that the given acceleration structure build should prioritize build time over trace performance.
RAYTRACING_BUILD_AS_PREFER_FAST_BUILD = 0x08,
- /// Indicates that this acceleration structure should minimize the size of the scratch memory and the final result build, potentially at the expense of build time or trace performance.
+ /// Indicates that this acceleration structure should minimize the size of the scratch memory and the final
+ /// result build, potentially at the expense of build time or trace performance.
RAYTRACING_BUILD_AS_LOW_MEMORY = 0x10,
RAYTRACING_BUILD_AS_FLAGS_LAST = 0x10
@@ -144,16 +145,16 @@ struct BottomLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// Array of triangle geometry descriptions.
const BLASTriangleDesc* pTriangles DEFAULT_INITIALIZER(nullptr);
- /// Number of triangle geometries.
+ /// The number of triangle geometries in pTriangles array.
Uint32 TriangleCount DEFAULT_INITIALIZER(0);
/// Array of AABB geometry descriptions.
const BLASBoundingBoxDesc* pBoxes DEFAULT_INITIALIZER(nullptr);
- /// Number of AABB geometries;
+ /// The number of AABB geometries in pBoxes array.
Uint32 BoxCount DEFAULT_INITIALIZER(0);
- /// AZ TODO
+ /// Ray tracing build flags, see Diligent::RAYTRACING_BUILD_AS_FLAGS.
RAYTRACING_BUILD_AS_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_BUILD_AS_NONE);
/// Defines which command queues this BLAS can be used with
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index 7491a14f..a294b066 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -725,19 +725,20 @@ DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8)
/// AZ TODO
RAYTRACING_INSTANCE_NONE = 0,
- // Disables face culling for this instance.
+ /// Disables face culling for this instance.
RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE = 0x01,
- // Indicates that the front face of the triangle for culling purposes is the face that is counter clockwise in object space relative to the ray origin.
- // Because the facing is determined in object space, an instance transform matrix does not change the winding, but a geometry transform does.
+ /// Indicates that the front face of the triangle for culling purposes is the face that is counter
+ /// clockwise in object space relative to the ray origin. Because the facing is determined in object
+ /// space, an instance transform matrix does not change the winding, but a geometry transform does.
RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x02,
- // Causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were specified on all geometries referenced by this instance.
- // This behavior can be overridden by the SPIR-V NoOpaqueKHR ray flag.
+ /// Causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were specified on all
+ /// geometries referenced by this instance. This behavior can be overridden by the SPIR-V NoOpaqueKHR ray flag.
RAYTRACING_INSTANCE_FORCE_OPAQUE = 0x04,
- // causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were not specified on all geometries referenced by this instance.
- // This behavior can be overridden by the SPIR-V OpaqueKHR ray flag.
+ /// causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were not specified on all
+ /// geometries referenced by this instance. This behavior can be overridden by the SPIR-V OpaqueKHR ray flag.
RAYTRACING_INSTANCE_FORCE_NO_OPAQUE = 0x08,
RAYTRACING_INSTANCE_FLAGS_LAST = 0x08
@@ -746,8 +747,8 @@ DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8)
/// AZ TODO
DILIGENT_TYPED_ENUM(COPY_AS_MODE, Uint8)
{
- // creates a direct copy of the acceleration structure specified in src into the one specified by dst.
- // The dst acceleration structure must have been created with the same parameters as src.
+ /// Creates a direct copy of the acceleration structure specified in src into the one specified by dst.
+ /// The dst acceleration structure must have been created with the same parameters as src.
COPY_AS_MODE_CLONE = 0,
// creates a more compact version of an acceleration structure src into dst.
@@ -766,11 +767,11 @@ DILIGENT_TYPED_ENUM(RAYTRACING_GEOMETRY_FLAGS, Uint8)
/// AZ TODO
RAYTRACING_GEOMETRY_NONE = 0,
- // Indicates that this geometry does not invoke the any-hit shaders even if present in a hit group.
+ /// Indicates that this geometry does not invoke the any-hit shaders even if present in a hit group.
RAYTRACING_GEOMETRY_OPAQUE = 0x01,
- // Indicates that the implementation must only call the any-hit shader a single time for each primitive in this geometry.
- // If this bit is absent an implementation may invoke the any-hit shader more than once for this geometry.
+ /// Indicates that the implementation must only call the any-hit shader a single time for each primitive in this geometry.
+ /// If this bit is absent an implementation may invoke the any-hit shader more than once for this geometry.
RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION = 0x02,
RAYTRACING_GEOMETRY_FLAGS_LAST = 0x02
@@ -860,6 +861,7 @@ struct BLASBuildBoundingBoxData
};
typedef struct BLASBuildBoundingBoxData BLASBuildBoundingBoxData;
+
/// AZ TODO
struct BLASBuildAttribs
{
@@ -897,8 +899,10 @@ struct BLASBuildAttribs
};
typedef struct BLASBuildAttribs BLASBuildAttribs;
+
/// AZ TODO
-const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u;
+static const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u;
+
/// AZ TODO
struct TLASBuildInstanceData
@@ -931,6 +935,7 @@ struct TLASBuildInstanceData
};
typedef struct TLASBuildInstanceData TLASBuildInstanceData;
+
/// AZ TODO
struct TLASBuildAttribs
{
@@ -974,6 +979,7 @@ struct TLASBuildAttribs
};
typedef struct TLASBuildAttribs TLASBuildAttribs;
+
/// AZ TODO
struct CopyBLASAttribs
{
@@ -996,6 +1002,7 @@ struct CopyBLASAttribs
};
typedef struct CopyBLASAttribs CopyBLASAttribs;
+
/// AZ TODO
struct CopyTLASAttribs
{
@@ -1018,6 +1025,7 @@ struct CopyTLASAttribs
};
typedef struct CopyTLASAttribs CopyTLASAttribs;
+
/// AZ TODO
struct TraceRaysAttribs
{
@@ -1039,6 +1047,7 @@ struct TraceRaysAttribs
};
typedef struct TraceRaysAttribs TraceRaysAttribs;
+
#define DILIGENT_INTERFACE_NAME IDeviceContext
#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index 7e17cdd4..2ea0d224 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -354,6 +354,7 @@ struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// Compute pipeline state description. This memeber is ignored if PipelineType is not PIPELINE_TYPE_COMPUTE
ComputePipelineDesc ComputePipeline;
+ // TODO (AZ): use pointer
/// Ray tracing pipeline state description. This memeber is ignored if PipelineType is not PIPELINE_TYPE_RAY_TRACING.
RayTracingPipelineDesc RayTracingPipeline;
diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h
index 69657254..027d0f5c 100644
--- a/Graphics/GraphicsEngine/interface/RenderDevice.h
+++ b/Graphics/GraphicsEngine/interface/RenderDevice.h
@@ -216,21 +216,43 @@ DILIGENT_BEGIN_INTERFACE(IRenderDevice, IObject)
const FramebufferDesc REF Desc,
IFramebuffer** ppFramebuffer) PURE;
- /// AZ TODO
+
+ /// Creates a bottom-level acceleration structure object (BLAS).
+
+ /// \param [in] Desc - BLAS description, see Diligent::BottomLevelASDesc for details.
+ /// \param [out] ppBLAS - Address of the memory location where the pointer to the
+ /// BLAS interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one reference.
VIRTUAL void METHOD(CreateBLAS)(THIS_
const BottomLevelASDesc REF Desc,
IBottomLevelAS** ppBLAS) PURE;
- /// AZ TODO
+
+ /// Creates a top-level acceleration structure object (TLAS).
+
+ /// \param [in] Desc - TLAS description, see Diligent::TopLevelASDesc for details.
+ /// \param [out] ppTLAS - Address of the memory location where the pointer to the
+ /// TLAS interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one reference.
VIRTUAL void METHOD(CreateTLAS)(THIS_
const TopLevelASDesc REF Desc,
ITopLevelAS** ppTLAS) PURE;
- /// AZ TODO
+
+ /// Creates a shader resource binding table object (SBT).
+
+ /// \param [in] Desc - SBT description, see Diligent::ShaderBindingTableDesc for details.
+ /// \param [out] ppSBT - Address of the memory location where the pointer to the
+ /// SBT interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one reference.
VIRTUAL void METHOD(CreateSBT)(THIS_
const ShaderBindingTableDesc REF Desc,
IShaderBindingTable** ppSBT) PURE;
+
/// Gets the device capabilities, see Diligent::DeviceCaps for details
VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE;
diff --git a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
index c2b8309c..514f9b7c 100644
--- a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
+++ b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
@@ -51,7 +51,7 @@ struct ShaderBindingTableDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// AZ TODO
IPipelineState* pPSO DEFAULT_INITIALIZER(nullptr);
- // size of additional data that passed to a shader, maximum size is 4064
+ // Size of the additional data passed to the shader, maximum size is 4064 bytes.
Uint32 ShaderRecordSize DEFAULT_INITIALIZER(0);
/// AZ TODO
diff --git a/Graphics/GraphicsEngine/interface/TopLevelAS.h b/Graphics/GraphicsEngine/interface/TopLevelAS.h
index 1cc30f2f..0e427864 100644
--- a/Graphics/GraphicsEngine/interface/TopLevelAS.h
+++ b/Graphics/GraphicsEngine/interface/TopLevelAS.h
@@ -48,21 +48,21 @@ static const INTERFACE_ID IID_TopLevelAS =
/// AZ TODO
DILIGENT_TYPED_ENUM(SHADER_BINDING_MODE, Uint8)
{
- /// Each geometry in each instance can have unique shader.
+ /// Each geometry in each instance can have a unique shader.
SHADER_BINDING_MODE_PER_GEOMETRY = 0,
- /// Each instance can have unique shader. In this mode SBT buffer will use less memory.
+ /// Each instance can have a unique shader. In this mode SBT buffer will use less memory.
SHADER_BINDING_MODE_PER_INSTANCE,
- // User must specify TLASBuildInstanceData::InstanceContributionToHitGroupIndex and use only IShaderBindingTable::BindAll()
+ /// The user must specify TLASBuildInstanceData::InstanceContributionToHitGroupIndex and only use IShaderBindingTable::BindAll().
SHADER_BINDING_USER_DEFINED,
};
/// AZ TODO
struct TopLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs)
- // Here we allocate space for instances.
- // Instances can be dynamicaly updated.
+ /// Here we allocate space for instances.
+ /// Instances can be dynamicaly updated.
Uint32 MaxInstanceCount DEFAULT_INITIALIZER(0);
/// AZ TODO
@@ -86,7 +86,7 @@ typedef struct TopLevelASDesc TopLevelASDesc;
struct TLASInstanceDesc
{
/// AZ TODO
- Uint32 contributionToHitGroupIndex DEFAULT_INITIALIZER(0);
+ Uint32 ContributionToHitGroupIndex DEFAULT_INITIALIZER(0);
/// AZ TODO
IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr);
diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
index 5793508a..d0d4957b 100644
--- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
@@ -147,7 +147,7 @@ RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCo
UNSUPPORTED_FEATURE(BindlessResources, "Bindless resources are");
UNSUPPORTED_FEATURE(VertexPipelineUAVWritesAndAtomics, "Vertex pipeline UAV writes and atomics are");
UNSUPPORTED_FEATURE(MeshShaders, "Mesh shaders are");
- UNSUPPORTED_FEATURE(RayTracing, "Ray tracing are");
+ UNSUPPORTED_FEATURE(RayTracing, "Ray tracing is");
{
bool ShaderFloat16Supported = false;
diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
index 2ce314c4..c833f68e 100644
--- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp
@@ -329,7 +329,7 @@ D3D12_STATIC_BORDER_COLOR BorderColorToD3D12StaticBorderColor(const Float32 Bord
static D3D12_RESOURCE_STATES ResourceStateFlagToD3D12ResourceState(RESOURCE_STATE StateFlag)
{
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "This function must be updated to handle new resource state flag");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "This function must be updated to handle new resource state flag");
VERIFY((StateFlag & (StateFlag - 1)) == 0, "Only single bit must be set");
switch (StateFlag)
{
@@ -401,7 +401,7 @@ D3D12_RESOURCE_STATES ResourceStateFlagsToD3D12ResourceStates(RESOURCE_STATE Sta
static RESOURCE_STATE D3D12ResourceStateToResourceStateFlags(D3D12_RESOURCE_STATES state)
{
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "This function must be updated to handle new resource state flag");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "This function must be updated to handle new resource state flag");
VERIFY((state & (state - 1)) == 0, "Only single state must be set");
switch (state)
{
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index a4c8a35a..b7bdf993 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -310,6 +310,7 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
SET_FEATURE_STATE(VertexPipelineUAVWritesAndAtomics, false, "Vertex pipeline UAV writes and atomics are");
SET_FEATURE_STATE(MeshShaders, false, "Mesh shaders are");
+ SET_FEATURE_STATE(RayTracing, false, "Ray tracing is");
{
bool WireframeFillSupported = (glPolygonMode != nullptr);
diff --git a/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp
index ccf8f574..eb485370 100644
--- a/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp
@@ -59,7 +59,7 @@ public:
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BottomLevelASVk, TBottomLevelASBase);
private:
- VkDeviceAddress m_DeviceAddress;
+ VkDeviceAddress m_DeviceAddress = 0;
VulkanUtilities::AccelStructWrapper m_VulkanBLAS;
VulkanUtilities::VulkanMemoryAllocation m_MemoryAllocation;
ScratchBufferSizes m_ScratchSize;
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp
index bba64381..92d83160 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp
@@ -96,17 +96,15 @@ private:
private:
RefCntAutoPtr<BufferVkImpl> m_pBuffer;
std::vector<Uint32> m_ShaderRecords;
- Uint32 m_MissShadersOffset;
- Uint32 m_HitGroupsOffset;
- Uint32 m_CallbaleShadersOffset;
- Uint32 m_MissShaderCount;
- Uint32 m_HitGroupCount;
- Uint32 m_CallableShaderCount;
- Uint32 m_ShaderGroupHandleSize;
- Uint32 m_ShaderGroupBaseAlignment;
-
-#ifdef DILIGENT_DEBUG
-#endif
+
+ Uint32 m_MissShadersOffset = 0;
+ Uint32 m_HitGroupsOffset = 0;
+ Uint32 m_CallbaleShadersOffset = 0;
+ Uint32 m_MissShaderCount = 0;
+ Uint32 m_HitGroupCount = 0;
+ Uint32 m_CallableShaderCount = 0;
+ Uint32 m_ShaderGroupHandleSize = 0;
+ Uint32 m_ShaderGroupBaseAlignment = 0;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp
index 311266e7..11c1ebef 100644
--- a/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp
@@ -59,7 +59,7 @@ public:
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_TopLevelASVk, TTopLevelASBase);
private:
- VkDeviceAddress m_DeviceAddress;
+ VkDeviceAddress m_DeviceAddress = 0;
VulkanUtilities::AccelStructWrapper m_VulkanTLAS;
VulkanUtilities::VulkanMemoryAllocation m_MemoryAllocation;
ScratchBufferSizes m_ScratchSize;
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.hpp b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.hpp
index 04189820..0cd6de63 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.hpp
@@ -147,7 +147,7 @@ public:
vkCmdDrawMeshTasksNV(m_VkCmdBuffer, TaskCount, FirstTask);
#else
- UNSUPPORTED("DrawMesh is not supported when vulkan library linked statically");
+ UNSUPPORTED("DrawMesh is not supported when vulkan library is linked statically");
#endif
}
@@ -160,7 +160,7 @@ public:
vkCmdDrawMeshTasksIndirectNV(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
#else
- UNSUPPORTED("DrawMeshIndirect is not supported when vulkan library linked statically");
+ UNSUPPORTED("DrawMeshIndirect is not supported when vulkan library is linked statically");
#endif
}
@@ -577,7 +577,7 @@ public:
#if DILIGENT_USE_VOLK
vkCmdBuildAccelerationStructureKHR(m_VkCmdBuffer, infoCount, pInfos, ppOffsetInfos);
#else
- UNSUPPORTED("Ray tracing is not supported when vulkan library linked statically");
+ UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
#endif
}
@@ -586,7 +586,7 @@ public:
#if DILIGENT_USE_VOLK
vkCmdCopyAccelerationStructureKHR(m_VkCmdBuffer, &Info);
#else
- UNSUPPORTED("Ray tracing is not supported when vulkan library linked statically");
+ UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
#endif
}
@@ -601,7 +601,7 @@ public:
#if DILIGENT_USE_VOLK
vkCmdTraceRaysKHR(m_VkCmdBuffer, &RaygenShaderBindingTable, &MissShaderBindingTable, &HitShaderBindingTable, &CallableShaderBindingTable, width, height, depth);
#else
- UNSUPPORTED("Ray tracing is not supported when vulkan library linked statically");
+ UNSUPPORTED("Ray tracing is not supported when vulkan library is linked statically");
#endif
}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h
index 769391cf..4b352cd6 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h
@@ -31,7 +31,7 @@
# define VK_NO_PROTOTYPES
#endif
-// TODO: remove it when ray tracing will be released
+// TODO: remove when ray tracing is released
#define VK_ENABLE_BETA_EXTENSIONS
#include "vulkan/vulkan.h"
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.hpp b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.hpp
index b9bf651c..0adde0d6 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.hpp
@@ -44,7 +44,7 @@ public:
VkPhysicalDevice8BitStorageFeaturesKHR Storage8Bit = {};
VkPhysicalDeviceShaderFloat16Int8FeaturesKHR ShaderFloat16Int8 = {};
VkPhysicalDeviceRayTracingFeaturesKHR RayTracing = {};
- bool RayTracingNV = false; // indicates that KHR extension emulated by NV extension
+ bool RayTracingNV = false; // indicates that KHR extension is emulated by NV extension
VkPhysicalDeviceBufferDeviceAddressFeaturesKHR BufferDeviceAddress = {};
VkPhysicalDeviceDescriptorIndexingFeaturesEXT DescriptorIndexing = {};
};
diff --git a/Graphics/GraphicsEngineVulkan/interface/BottomLevelASVk.h b/Graphics/GraphicsEngineVulkan/interface/BottomLevelASVk.h
index eb0c2da5..345b0f3b 100644
--- a/Graphics/GraphicsEngineVulkan/interface/BottomLevelASVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/BottomLevelASVk.h
@@ -49,10 +49,10 @@ static const INTERFACE_ID IID_BottomLevelASVk =
/// Exposes Vulkan-specific functionality of a Bottom-level acceleration structure object.
DILIGENT_BEGIN_INTERFACE(IBottomLevelASVk, IBottomLevelAS)
{
- /// Returns a Vulkan BLAS object handle
+ /// Returns a Vulkan BLAS object handle.
VIRTUAL VkAccelerationStructureKHR METHOD(GetVkBLAS)(THIS) CONST PURE;
- /// Returns a Vulkan BLAS device address
+ /// Returns a Vulkan BLAS device address.
VIRTUAL VkDeviceAddress METHOD(GetVkDeviceAddress)(THIS) CONST PURE;
};
DILIGENT_END_INTERFACE
diff --git a/Graphics/GraphicsEngineVulkan/interface/BufferVk.h b/Graphics/GraphicsEngineVulkan/interface/BufferVk.h
index 0c95af96..af1f8673 100644
--- a/Graphics/GraphicsEngineVulkan/interface/BufferVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/BufferVk.h
@@ -63,7 +63,7 @@ DILIGENT_BEGIN_INTERFACE(IBufferVk, IBuffer)
/// returns Vulkan access flags corresponding to the state. If the state is unknown, returns 0.
VIRTUAL VkAccessFlags METHOD(GetAccessFlags)(THIS) CONST PURE;
- /// Returns a vulkan device address
+ /// Returns a Vulkan device address.
VIRTUAL VkDeviceAddress METHOD(GetVkDeviceAddress)(THIS) CONST PURE;
};
DILIGENT_END_INTERFACE
diff --git a/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h b/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h
index e3222728..76e0eadd 100644
--- a/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h
@@ -45,16 +45,19 @@ static const INTERFACE_ID IID_ShaderBindingTableVk =
IShaderBindingTableInclusiveMethods; \
IShaderBindingTableVkMethods ShaderBindingTableVk
+// clang-format off
/// Exposes Vulkan-specific functionality of a Shader binding table object.
DILIGENT_BEGIN_INTERFACE(IShaderBindingTableVk, IShaderBindingTable)
{
/// AZ TODO
- VIRTUAL void METHOD(GetVkStridedBufferRegions)(VkStridedBufferRegionKHR & RaygenShaderBindingTable,
- VkStridedBufferRegionKHR & MissShaderBindingTable,
- VkStridedBufferRegionKHR & HitShaderBindingTable,
- VkStridedBufferRegionKHR & CallableShaderBindingTable) PURE;
+ VIRTUAL void METHOD(GetVkStridedBufferRegions)(THIS_
+ VkStridedBufferRegionKHR REF RaygenShaderBindingTable,
+ VkStridedBufferRegionKHR REF MissShaderBindingTable,
+ VkStridedBufferRegionKHR REF HitShaderBindingTable,
+ VkStridedBufferRegionKHR REF CallableShaderBindingTable) PURE;
};
DILIGENT_END_INTERFACE
+// clang-format on
#include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
diff --git a/Graphics/GraphicsEngineVulkan/interface/TopLevelASVk.h b/Graphics/GraphicsEngineVulkan/interface/TopLevelASVk.h
index 3d0b8b09..c09f10c0 100644
--- a/Graphics/GraphicsEngineVulkan/interface/TopLevelASVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/TopLevelASVk.h
@@ -48,10 +48,10 @@ static const INTERFACE_ID IID_TopLevelASVk =
/// Exposes Vulkan-specific functionality of a Top-level acceleration structure object.
DILIGENT_BEGIN_INTERFACE(ITopLevelASVk, ITopLevelAS)
{
- /// Returns a Vulkan TLAS object handle
+ /// Returns a Vulkan TLAS object handle.
VIRTUAL VkAccelerationStructureKHR METHOD(GetVkTLAS)(THIS) CONST PURE;
- /// Returns a Vulkan TLAS device address
+ /// Returns a Vulkan TLAS device address.
VIRTUAL VkDeviceAddress METHOD(GetVkDeviceAddress)(THIS) CONST PURE;
};
DILIGENT_END_INTERFACE
@@ -60,7 +60,8 @@ DILIGENT_END_INTERFACE
#if DILIGENT_C_INTERFACE
-# define ITopLevelASVk_GetVkTLAS(This) CALL_IFACE_METHOD(TopLevelASVk, GetVkTLAS, This)
+# define ITopLevelASVk_GetVkTLAS(This) CALL_IFACE_METHOD(TopLevelASVk, GetVkTLAS, This)
+# define ITopLevelASVk_GetVkDeviceAddress(This) CALL_IFACE_METHOD(TopLevelASVk, GetVkDeviceAddress, This)
#endif
diff --git a/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp
index 85c74834..6e0bcbb8 100644
--- a/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp
@@ -36,8 +36,7 @@ BottomLevelASVkImpl::BottomLevelASVkImpl(IReferenceCounters* pRefCounters,
RenderDeviceVkImpl* pRenderDeviceVk,
const BottomLevelASDesc& Desc,
bool bIsDeviceInternal) :
- TBottomLevelASBase{pRefCounters, pRenderDeviceVk, Desc, bIsDeviceInternal},
- m_DeviceAddress{0}
+ TBottomLevelASBase{pRefCounters, pRenderDeviceVk, Desc, bIsDeviceInternal}
{
const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice();
const auto& PhysicalDevice = pRenderDeviceVk->GetPhysicalDevice();
@@ -100,6 +99,10 @@ BottomLevelASVkImpl::BottomLevelASVkImpl(IReferenceCounters* pRefCounters,
}
VERIFY_EXPR(MaxBoxCount <= Limits.maxPrimitiveCount);
}
+ else
+ {
+ UNEXPECTED("Either pTriangles or pBoxes must not be null");
+ }
m_VulkanBLAS = LogicalDevice.CreateAccelStruct(CreateInfo, m_Desc.Name);
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index d3f87287..ba36ff7c 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -579,9 +579,12 @@ void DeviceContextVkImpl::DrawMesh(const DrawMeshAttribs& Attribs)
return;
#ifdef DILIGENT_DEBUG
- auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
- VERIFY_EXPR(PhysicalDevice.GetExtFeatures().MeshShader.meshShader == VK_TRUE && PhysicalDevice.GetExtFeatures().MeshShader.taskShader == VK_TRUE);
- VERIFY_EXPR(Attribs.ThreadGroupCount <= PhysicalDevice.GetExtProperties().MeshShader.maxDrawMeshTasksCount);
+ {
+ const auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
+ const auto& MeshShaderFeats = PhysicalDevice.GetExtFeatures().MeshShader;
+ VERIFY_EXPR(MeshShaderFeats.meshShader != VK_FALSE && MeshShaderFeats.taskShader != VK_FALSE);
+ VERIFY_EXPR(Attribs.ThreadGroupCount <= PhysicalDevice.GetExtProperties().MeshShader.maxDrawMeshTasksCount);
+ }
#endif
PrepareForDraw(Attribs.Flags);
@@ -596,8 +599,10 @@ void DeviceContextVkImpl::DrawMeshIndirect(const DrawMeshIndirectAttribs& Attrib
return;
#ifdef DILIGENT_DEBUG
- auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
- VERIFY_EXPR(PhysicalDevice.GetExtFeatures().MeshShader.meshShader == VK_TRUE && PhysicalDevice.GetExtFeatures().MeshShader.taskShader == VK_TRUE);
+ {
+ const auto& MeshShaderFeats = m_pDevice->GetPhysicalDevice().GetExtFeatures().MeshShader;
+ VERIFY_EXPR(MeshShaderFeats.meshShader != VK_FALSE && MeshShaderFeats.taskShader != VK_FALSE);
+ }
#endif
// We must prepare indirect draw attribs buffer first because state transitions must
@@ -2620,8 +2625,10 @@ void DeviceContextVkImpl::BuildBLAS(const BLASBuildAttribs& Attribs)
// AZ TODO: transitions
#ifdef DILIGENT_DEBUG
- auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
- VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing == VK_TRUE);
+ {
+ const auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
+ VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing != VK_FALSE);
+ }
#endif
auto* pBLASVk = ValidatedCast<BottomLevelASVkImpl>(Attribs.pBLAS);
@@ -2721,6 +2728,10 @@ void DeviceContextVkImpl::BuildBLAS(const BLASBuildAttribs& Attribs)
off.primitiveCount = src.BoxCount;
}
}
+ else
+ {
+ UNEXPECTED("pTriangleData or pBoxData must not be null");
+ }
VkAccelerationStructureGeometryKHR const* GeometriesPtr = Geometries.data();
VkAccelerationStructureBuildOffsetInfoKHR const* OffsetsPtr = Offsets.data();
@@ -2750,8 +2761,10 @@ void DeviceContextVkImpl::BuildTLAS(const TLASBuildAttribs& Attribs)
// AZ TODO: transitions
#ifdef DILIGENT_DEBUG
- auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
- VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing == VK_TRUE);
+ {
+ const auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
+ VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing != VK_FALSE);
+ }
#endif
auto* pTLASVk = ValidatedCast<TopLevelASVkImpl>(Attribs.pTLAS);
@@ -2823,8 +2836,10 @@ void DeviceContextVkImpl::CopyBLAS(const CopyBLASAttribs& Attribs)
// AZ TODO: transitions
#ifdef DILIGENT_DEBUG
- auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
- VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing == VK_TRUE);
+ {
+ const auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
+ VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing != VK_FALSE);
+ }
#endif
auto* pSrcVk = ValidatedCast<BottomLevelASVkImpl>(Attribs.pSrc);
@@ -2875,8 +2890,10 @@ void DeviceContextVkImpl::TraceRays(const TraceRaysAttribs& Attribs)
// AZ TODO: transitions
#ifdef DILIGENT_DEBUG
- auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
- VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing == VK_TRUE);
+ {
+ const auto& PhysicalDevice = m_pDevice->GetPhysicalDevice();
+ VERIFY_EXPR(PhysicalDevice.GetExtFeatures().RayTracing.rayTracing == VK_TRUE);
+ }
#endif
VkStridedBufferRegionKHR RaygenShaderBindingTable = {};
diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
index 692b5428..7a7d8a07 100644
--- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp
@@ -273,7 +273,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _E
auto RayTracingFeats = DeiceExtFeatures.RayTracing;
auto BufferDeviceAddressFeats = DeiceExtFeatures.BufferDeviceAddress;
auto DescriptorIndexingFeats = DeiceExtFeatures.DescriptorIndexing;
- ENABLE_FEATURE(RayTracingFeats.rayTracing != VK_FALSE || DeiceExtFeatures.RayTracingNV, MeshShaders, "Ray tracing are");
+ ENABLE_FEATURE(RayTracingFeats.rayTracing != VK_FALSE || DeiceExtFeatures.RayTracingNV, RayTracing, "Ray tracing is");
#undef FeatureSupport
@@ -418,6 +418,10 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _E
*NextExt = &BufferDeviceAddressFeats;
NextExt = &BufferDeviceAddressFeats.pNext;
}
+ else
+ {
+ UNEXPECTED("Either KHR or NV extension must be enabled");
+ }
}
// make sure that last pNext is null
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp
index 32c0cb29..b7d2b1f4 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp
@@ -43,7 +43,7 @@ namespace Diligent
static VkShaderStageFlagBits ShaderTypeToVkShaderStageFlagBit(SHADER_TYPE ShaderType)
{
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please update the switch below to handle the new shader type");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please update the switch below to handle the new shader type");
switch (ShaderType)
{
// clang-format off
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderBindingTableVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderBindingTableVkImpl.cpp
index 21b06fb3..36fa5af0 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderBindingTableVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderBindingTableVkImpl.cpp
@@ -36,17 +36,11 @@ ShaderBindingTableVkImpl::ShaderBindingTableVkImpl(IReferenceCounters*
RenderDeviceVkImpl* pRenderDeviceVk,
const ShaderBindingTableDesc& Desc,
bool bIsDeviceInternal) :
- TShaderBindingTableBase{pRefCounters, pRenderDeviceVk, Desc, bIsDeviceInternal},
- m_MissShadersOffset{0},
- m_HitGroupsOffset{0},
- m_CallbaleShadersOffset{0},
- m_MissShaderCount{0},
- m_HitGroupCount{0},
- m_CallableShaderCount{0}
+ TShaderBindingTableBase{pRefCounters, pRenderDeviceVk, Desc, bIsDeviceInternal}
{
ValidateDesc(Desc);
- auto& Props = GetDevice()->GetPhysicalDevice().GetExtProperties().RayTracing;
+ const auto& Props = GetDevice()->GetPhysicalDevice().GetExtProperties().RayTracing;
m_ShaderGroupHandleSize = Props.shaderGroupHandleSize;
m_ShaderGroupBaseAlignment = Props.shaderGroupBaseAlignment;
@@ -58,7 +52,7 @@ ShaderBindingTableVkImpl::~ShaderBindingTableVkImpl()
void ShaderBindingTableVkImpl::ValidateDesc(const ShaderBindingTableDesc& Desc) const
{
- auto& Props = GetDevice()->GetPhysicalDevice().GetExtProperties().RayTracing;
+ const auto& Props = GetDevice()->GetPhysicalDevice().GetExtProperties().RayTracing;
if (Desc.ShaderRecordSize + Props.shaderGroupHandleSize > Props.maxShaderGroupStride)
{
@@ -87,7 +81,7 @@ void ShaderBindingTableVkImpl::Reset(const ShaderBindingTableDesc& Desc)
m_Desc = Desc;
// free memory
- decltype(m_ShaderRecords) temp;
+ decltype(m_ShaderRecords) temp{};
std::swap(temp, m_ShaderRecords);
m_MissShadersOffset = 0;
@@ -152,7 +146,7 @@ void ShaderBindingTableVkImpl::GetVkStridedBufferRegions(VkStridedBufferRegionKH
VkStridedBufferRegionKHR& HitShaderBindingTable,
VkStridedBufferRegionKHR& CallableShaderBindingTable)
{
- auto& Props = GetDevice()->GetPhysicalDevice().GetExtProperties().RayTracing;
+ const auto& Props = GetDevice()->GetPhysicalDevice().GetExtProperties().RayTracing;
const VkDeviceSize Stride = m_Desc.ShaderRecordSize + Props.shaderGroupHandleSize;
VERIFY_EXPR(Stride <= Props.maxShaderGroupStride);
diff --git a/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp
index 0fb2f334..76248d41 100644
--- a/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/TopLevelASVkImpl.cpp
@@ -36,8 +36,7 @@ TopLevelASVkImpl::TopLevelASVkImpl(IReferenceCounters* pRefCounters,
RenderDeviceVkImpl* pRenderDeviceVk,
const TopLevelASDesc& Desc,
bool bIsDeviceInternal) :
- TTopLevelASBase{pRefCounters, pRenderDeviceVk, Desc, bIsDeviceInternal},
- m_DeviceAddress{0}
+ TTopLevelASBase{pRefCounters, pRenderDeviceVk, Desc, bIsDeviceInternal}
{
const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice();
const auto& PhysicalDevice = pRenderDeviceVk->GetPhysicalDevice();
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp
index b797968c..fa03bca6 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp
@@ -444,7 +444,7 @@ public:
TEXTURE_FORMAT operator[](VkFormat VkFmt) const
{
- if (VkFmt < _countof(m_VkFmtToTexFmtMap))
+ if (VkFmt < VK_FORMAT_RANGE_SIZE)
{
return m_VkFmtToTexFmtMap[VkFmt];
}
@@ -456,7 +456,7 @@ public:
}
private:
- TEXTURE_FORMAT m_VkFmtToTexFmtMap[VK_FORMAT_ASTC_12x12_SRGB_BLOCK + 1] = {};
+ TEXTURE_FORMAT m_VkFmtToTexFmtMap[VK_FORMAT_RANGE_SIZE] = {};
std::unordered_map<VkFormat, TEXTURE_FORMAT> m_VkFmtToTexFmtMapExt;
};
@@ -640,7 +640,7 @@ VkIndexType TypeToVkIndexType(VALUE_TYPE IndexType)
case VT_UNDEFINED: return VK_INDEX_TYPE_NONE_KHR; // only for ray tracing
case VT_UINT16: return VK_INDEX_TYPE_UINT16;
case VT_UINT32: return VK_INDEX_TYPE_UINT32;
- // clang-format on
+ // clang-format on
default:
UNEXPECTED("Unexpected index type");
return VK_INDEX_TYPE_UINT32;
@@ -1167,7 +1167,7 @@ static VkAccessFlags ResourceStateFlagToVkAccessFlags(RESOURCE_STATE StateFlag)
//VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT
//VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "This function must be updated to handle new resource state flag");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "This function must be updated to handle new resource state flag");
VERIFY((StateFlag & (StateFlag - 1)) == 0, "Only single bit must be set");
switch (StateFlag)
{
@@ -1332,7 +1332,7 @@ VkImageLayout ResourceStateToVkImageLayout(RESOURCE_STATE StateFlag, bool IsInsi
//VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL,
//VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL,
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "This function must be updated to handle new resource state flag");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "This function must be updated to handle new resource state flag");
VERIFY((StateFlag & (StateFlag - 1)) == 0, "Only single bit must be set");
switch (StateFlag)
{
@@ -1366,7 +1366,7 @@ VkImageLayout ResourceStateToVkImageLayout(RESOURCE_STATE StateFlag, bool IsInsi
RESOURCE_STATE VkImageLayoutToResourceState(VkImageLayout Layout)
{
- static_assert(RESOURCE_STATE_MAX_BIT == 0x40000, "This function must be updated to handle new resource state flag");
+ static_assert(RESOURCE_STATE_MAX_BIT == RESOURCE_STATE_RAY_TRACING, "This function must be updated to handle new resource state flag");
switch (Layout)
{
// clang-format off
@@ -1530,7 +1530,8 @@ VkAccessFlags AccessFlagsToVkAccessFlags(ACCESS_FLAGS AccessFlags)
VkBuildAccelerationStructureFlagsKHR BuildASFlagsToVkBuildAccelerationStructureFlags(RAYTRACING_BUILD_AS_FLAGS Flags)
{
- static_assert(RAYTRACING_BUILD_AS_FLAGS_LAST == 0x10, "AZ TODO");
+ static_assert(RAYTRACING_BUILD_AS_FLAGS_LAST == RAYTRACING_BUILD_AS_LOW_MEMORY,
+ "Please update the switch below to handle the new ray tracing build flag");
VkBuildAccelerationStructureFlagsKHR Result = 0;
for (Uint32 Bit = 1; Bit <= Flags; Bit <<= 1)
@@ -1538,7 +1539,7 @@ VkBuildAccelerationStructureFlagsKHR BuildASFlagsToVkBuildAccelerationStructureF
if ((Flags & Bit) != Bit)
continue;
- switch (RAYTRACING_BUILD_AS_FLAGS(Bit))
+ switch (static_cast<RAYTRACING_BUILD_AS_FLAGS>(Bit))
{
// clang-format off
case RAYTRACING_BUILD_AS_ALLOW_UPDATE: Result |= VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR; break;
@@ -1546,8 +1547,8 @@ VkBuildAccelerationStructureFlagsKHR BuildASFlagsToVkBuildAccelerationStructureF
case RAYTRACING_BUILD_AS_PREFER_FAST_TRACE: Result |= VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR; break;
case RAYTRACING_BUILD_AS_PREFER_FAST_BUILD: Result |= VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR; break;
case RAYTRACING_BUILD_AS_LOW_MEMORY: Result |= VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR; break;
+ // clang-format on
default: UNEXPECTED("unknown build AS flag");
- // clang-format on
}
}
return Result;
@@ -1555,7 +1556,8 @@ VkBuildAccelerationStructureFlagsKHR BuildASFlagsToVkBuildAccelerationStructureF
VkGeometryFlagsKHR GeometryFlagsToVkGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flags)
{
- static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == 0x02, "AZ TODO");
+ static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION,
+ "Please update the switch below to handle the new ray tracing geometry flag");
VkGeometryFlagsKHR Result = 0;
for (Uint32 Bit = 1; Bit <= Flags; Bit <<= 1)
@@ -1563,13 +1565,13 @@ VkGeometryFlagsKHR GeometryFlagsToVkGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flag
if ((Flags & Bit) != Bit)
continue;
- switch (RAYTRACING_GEOMETRY_FLAGS(Bit))
+ switch (static_cast<RAYTRACING_GEOMETRY_FLAGS>(Bit))
{
// clang-format off
case RAYTRACING_GEOMETRY_OPAQUE: Result |= VK_GEOMETRY_OPAQUE_BIT_KHR; break;
case RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR; break;
+ // clang-format on
default: UNEXPECTED("unknown geometry flag");
- // clang-format on
}
}
return Result;
@@ -1577,7 +1579,8 @@ VkGeometryFlagsKHR GeometryFlagsToVkGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flag
VkGeometryInstanceFlagsKHR InstanceFlagsToVkGeometryInstanceFlags(RAYTRACING_INSTANCE_FLAGS Flags)
{
- static_assert(RAYTRACING_INSTANCE_FLAGS_LAST == 0x08, "AZ TODO");
+ static_assert(RAYTRACING_INSTANCE_FLAGS_LAST == RAYTRACING_INSTANCE_FORCE_NO_OPAQUE,
+ "Please update the switch below to handle the new ray tracing instance flag");
VkGeometryInstanceFlagsKHR Result = 0;
for (Uint32 Bit = 1; Bit <= Flags; Bit <<= 1)
@@ -1585,15 +1588,15 @@ VkGeometryInstanceFlagsKHR InstanceFlagsToVkGeometryInstanceFlags(RAYTRACING_INS
if ((Flags & Bit) != Bit)
continue;
- switch (RAYTRACING_INSTANCE_FLAGS(Bit))
+ switch (static_cast<RAYTRACING_INSTANCE_FLAGS>(Bit))
{
// clang-format off
- case RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE: return VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR;
- case RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE: return VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR;
- case RAYTRACING_INSTANCE_FORCE_OPAQUE: return VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR;
- case RAYTRACING_INSTANCE_FORCE_NO_OPAQUE: return VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR;
+ case RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE: Result |= VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR; break;
+ case RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE: Result |= VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR; break;
+ case RAYTRACING_INSTANCE_FORCE_OPAQUE: Result |= VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR; break;
+ case RAYTRACING_INSTANCE_FORCE_NO_OPAQUE: Result |= VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR; break;
+ // clang-format on
default: UNEXPECTED("unknown instance flag");
- // clang-format on
}
}
return Result;
@@ -1601,17 +1604,18 @@ VkGeometryInstanceFlagsKHR InstanceFlagsToVkGeometryInstanceFlags(RAYTRACING_INS
VkCopyAccelerationStructureModeKHR CopyASModeToVkCopyAccelerationStructureMode(COPY_AS_MODE Mode)
{
- static_assert(COPY_AS_MODE_LAST == 0, "AZ TODO");
+ static_assert(COPY_AS_MODE_LAST == COPY_AS_MODE_CLONE,
+ "Please update the switch below to handle the new copy AS mode");
switch (Mode)
{
// clang-format off
case COPY_AS_MODE_CLONE: return VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR;
- // clang-format on
+ // clang-format on
+ default:
+ UNEXPECTED("unknown AS copy mode");
+ return static_cast<VkCopyAccelerationStructureModeKHR>(0);
}
-
- UNEXPECTED("unknown AS copy mode");
- return VkCopyAccelerationStructureModeKHR(0);
}
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp
index 22659277..3e5f28d4 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanPhysicalDevice.cpp
@@ -143,7 +143,7 @@ VulkanPhysicalDevice::VulkanPhysicalDevice(VkPhysicalDevice vkDevice,
RayTracingNV.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV;
}
- // Additional extension that required for ray tracing.
+ // Additional extension that is required for ray tracing.
if (IsExtensionSupported(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))
{
*NextFeat = &m_ExtFeatures.BufferDeviceAddress;
@@ -152,7 +152,7 @@ VulkanPhysicalDevice::VulkanPhysicalDevice(VkPhysicalDevice vkDevice,
m_ExtFeatures.BufferDeviceAddress.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR;
}
- // Additional extension that required for ray tracing.
+ // Additional extension that is required for ray tracing.
if (IsExtensionSupported(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME))
{
*NextFeat = &m_ExtFeatures.DescriptorIndexing;
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanRayTracingKHRviaNV.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanRayTracingKHRviaNV.cpp
index de16fe6a..f7a6b8f6 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanRayTracingKHRviaNV.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanRayTracingKHRviaNV.cpp
@@ -25,44 +25,49 @@
* of the possibility of such damages.
*/
-#include "VulkanErrors.hpp"
-#include "VulkanUtilities/VulkanLogicalDevice.hpp"
-// for KHR ray tracing emulation
+// KHR ray tracing emulation through NVidia extension.
+// Will be deprecated after the release of KHR extension.
+
#include <mutex>
#include <unordered_map>
+#include <vector>
+
+#include "VulkanErrors.hpp"
+#include "VulkanUtilities/VulkanLogicalDevice.hpp"
namespace VulkanUtilities
{
-// KHR ray tracing emulation.
-// Will be deprecated after the release of KHR extension.
#if DILIGENT_USE_VOLK
-static_assert(sizeof(VkAccelerationStructureKHR) == sizeof(VkAccelerationStructureNV), "not compatible with NV extension");
-static_assert(sizeof(VkDeviceAddress) == 8, "not compatible with NV extension");
-
-static std::mutex g_BufferDeviceAddressGuard;
-static std::unordered_map<VkDeviceAddress, VkBuffer> g_DeviceAddressToBuffer;
-static std::unordered_map<VkBuffer, VkDeviceAddress> g_BufferToDeviceAddress;
-static uint32_t g_BufferDeviceAddressCounter = 0;
-static const VkDeviceAddress g_BufferMask = 0xFFFFFFFF00000000ull;
-
-static PFN_vkCreateBuffer Origin_vkCreateBuffer = nullptr;
-static PFN_vkDestroyBuffer Origin_vkDestroyBuffer = nullptr;
-static PFN_vkGetBufferDeviceAddressKHR Origin_vkGetBufferDeviceAddressKHR = nullptr;
-
-static VkResult VKAPI_CALL Wrap_vkCreateBuffer(VkDevice device,
- const VkBufferCreateInfo* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkBuffer* pBuffer)
+static_assert(sizeof(VkAccelerationStructureKHR) == sizeof(VkAccelerationStructureNV), "KHR is incompatible with NV extension");
+static_assert(sizeof(VkDeviceAddress) == 8, "KHR is incompatible with NV extension");
+
+namespace
+{
+
+std::mutex g_BufferDeviceAddressGuard;
+std::unordered_map<VkDeviceAddress, VkBuffer> g_DeviceAddressToBuffer;
+std::unordered_map<VkBuffer, VkDeviceAddress> g_BufferToDeviceAddress;
+uint32_t g_BufferDeviceAddressCounter = 0;
+constexpr VkDeviceAddress g_BufferMask = 0xFFFFFFFF00000000ull;
+
+PFN_vkCreateBuffer Origin_vkCreateBuffer = nullptr;
+PFN_vkDestroyBuffer Origin_vkDestroyBuffer = nullptr;
+PFN_vkGetBufferDeviceAddressKHR Origin_vkGetBufferDeviceAddressKHR = nullptr;
+
+VkResult VKAPI_CALL Wrap_vkCreateBuffer(VkDevice device,
+ const VkBufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkBuffer* pBuffer)
{
const_cast<VkBufferCreateInfo*>(pCreateInfo)->usage &= ~VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
return Origin_vkCreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
}
-static void VKAPI_CALL Wrap_vkDestroyBuffer(VkDevice device,
- VkBuffer buffer,
- const VkAllocationCallbacks* pAllocator)
+void VKAPI_CALL Wrap_vkDestroyBuffer(VkDevice device,
+ VkBuffer buffer,
+ const VkAllocationCallbacks* pAllocator)
{
Origin_vkDestroyBuffer(device, buffer, pAllocator);
@@ -76,8 +81,8 @@ static void VKAPI_CALL Wrap_vkDestroyBuffer(VkDevice device,
}
}
-static VkDeviceAddress VKAPI_CALL Wrap_vkGetBufferDeviceAddressKHR(VkDevice device,
- const VkBufferDeviceAddressInfo* pInfo)
+VkDeviceAddress VKAPI_CALL Wrap_vkGetBufferDeviceAddressKHR(VkDevice device,
+ const VkBufferDeviceAddressInfo* pInfo)
{
VERIFY_EXPR(pInfo->sType == VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_KHR);
VERIFY_EXPR(pInfo->pNext == nullptr);
@@ -90,9 +95,9 @@ static VkDeviceAddress VKAPI_CALL Wrap_vkGetBufferDeviceAddressKHR(VkDevice
return iter->second;
// create new device address
- VkDeviceAddress Addr = VkDeviceAddress(++g_BufferDeviceAddressCounter) << 32;
- g_BufferToDeviceAddress.insert_or_assign(pInfo->buffer, Addr);
- g_DeviceAddressToBuffer.insert_or_assign(Addr, pInfo->buffer);
+ VkDeviceAddress Addr = VkDeviceAddress{++g_BufferDeviceAddressCounter} << 32;
+ g_BufferToDeviceAddress[pInfo->buffer] = Addr;
+ g_DeviceAddressToBuffer[Addr] = pInfo->buffer;
return Addr;
}
@@ -101,7 +106,7 @@ struct BufferAndOffset
VkBuffer Buffer;
VkDeviceSize Offset;
};
-static BufferAndOffset DeviceAddressToBuffer(VkDeviceAddress Addr)
+BufferAndOffset DeviceAddressToBuffer(VkDeviceAddress Addr)
{
if (Addr == 0)
return {VK_NULL_HANDLE, 0};
@@ -118,21 +123,21 @@ static BufferAndOffset DeviceAddressToBuffer(VkDeviceAddress Addr)
return {iter->second, Addr & ~g_BufferMask};
}
-static BufferAndOffset DeviceAddressToBuffer(const VkDeviceOrHostAddressConstKHR& Addr)
+BufferAndOffset DeviceAddressToBuffer(const VkDeviceOrHostAddressConstKHR& Addr)
{
return DeviceAddressToBuffer(Addr.deviceAddress);
}
-static BufferAndOffset DeviceAddressToBuffer(const VkDeviceOrHostAddressKHR& Addr)
+BufferAndOffset DeviceAddressToBuffer(const VkDeviceOrHostAddressKHR& Addr)
{
return DeviceAddressToBuffer(Addr.deviceAddress);
}
-static VkResult VKAPI_CALL Redirect_vkCreateAccelerationStructureKHR(VkDevice device,
- const VkAccelerationStructureCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- VkAccelerationStructureKHR* pAccelerationStructure)
+VkResult VKAPI_CALL Redirect_vkCreateAccelerationStructureKHR(VkDevice device,
+ const VkAccelerationStructureCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkAccelerationStructureKHR* pAccelerationStructure)
{
VERIFY_EXPR(pCreateInfo->sType == VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR);
VERIFY_EXPR(pCreateInfo->pNext == nullptr);
@@ -219,9 +224,9 @@ static VkResult VKAPI_CALL Redirect_vkCreateAccelerationStructureKHR(VkDevice
return vkCreateAccelerationStructureNV(device, &CreateInfo, pAllocator, reinterpret_cast<VkAccelerationStructureNV*>(pAccelerationStructure));
}
-static void VKAPI_CALL Redirect_vkGetAccelerationStructureMemoryRequirementsKHR(VkDevice device,
- const VkAccelerationStructureMemoryRequirementsInfoKHR* pInfo,
- VkMemoryRequirements2* pMemoryRequirements)
+void VKAPI_CALL Redirect_vkGetAccelerationStructureMemoryRequirementsKHR(VkDevice device,
+ const VkAccelerationStructureMemoryRequirementsInfoKHR* pInfo,
+ VkMemoryRequirements2* pMemoryRequirements)
{
VERIFY_EXPR(pInfo->sType == VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_KHR);
VERIFY_EXPR(pInfo->pNext == nullptr);
@@ -236,16 +241,16 @@ static void VKAPI_CALL Redirect_vkGetAccelerationStructureMemoryRequirementsKHR(
return vkGetAccelerationStructureMemoryRequirementsNV(device, &Info, pMemoryRequirements);
}
-static VkResult VKAPI_CALL Redirect_vkBindAccelerationStructureMemoryKHR(VkDevice device,
- uint32_t bindInfoCount,
- const VkBindAccelerationStructureMemoryInfoKHR* pBindInfos)
+VkResult VKAPI_CALL Redirect_vkBindAccelerationStructureMemoryKHR(VkDevice device,
+ uint32_t bindInfoCount,
+ const VkBindAccelerationStructureMemoryInfoKHR* pBindInfos)
{
VERIFY_EXPR(pBindInfos->sType == VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV);
return vkBindAccelerationStructureMemoryNV(device, bindInfoCount, pBindInfos);
}
-static VkDeviceAddress VKAPI_CALL Redirect_vkGetAccelerationStructureDeviceAddressKHR(VkDevice device,
- const VkAccelerationStructureDeviceAddressInfoKHR* pInfo)
+VkDeviceAddress VKAPI_CALL Redirect_vkGetAccelerationStructureDeviceAddressKHR(VkDevice device,
+ const VkAccelerationStructureDeviceAddressInfoKHR* pInfo)
{
VERIFY_EXPR(pInfo->sType == VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR);
VERIFY_EXPR(pInfo->pNext == nullptr);
@@ -255,10 +260,10 @@ static VkDeviceAddress VKAPI_CALL Redirect_vkGetAccelerationStructureDeviceAddre
return result;
}
-static void VKAPI_CALL Redirect_vkCmdBuildAccelerationStructureKHR(VkCommandBuffer commandBuffer,
- uint32_t infoCount,
- const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
- const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos)
+void VKAPI_CALL Redirect_vkCmdBuildAccelerationStructureKHR(VkCommandBuffer commandBuffer,
+ uint32_t infoCount,
+ const VkAccelerationStructureBuildGeometryInfoKHR* pInfos,
+ const VkAccelerationStructureBuildOffsetInfoKHR* const* ppOffsetInfos)
{
std::vector<VkGeometryNV> Geometries;
@@ -384,8 +389,8 @@ static void VKAPI_CALL Redirect_vkCmdBuildAccelerationStructureKHR(VkCommandBuff
}
}
-static void VKAPI_CALL Redirect_vkCmdCopyAccelerationStructureKHR(VkCommandBuffer commandBuffer,
- const VkCopyAccelerationStructureInfoKHR* pInfo)
+void VKAPI_CALL Redirect_vkCmdCopyAccelerationStructureKHR(VkCommandBuffer commandBuffer,
+ const VkCopyAccelerationStructureInfoKHR* pInfo)
{
VERIFY_EXPR(pInfo->sType == VK_STRUCTURE_TYPE_COPY_ACCELERATION_STRUCTURE_INFO_KHR);
VERIFY_EXPR(pInfo->pNext == nullptr);
@@ -393,14 +398,14 @@ static void VKAPI_CALL Redirect_vkCmdCopyAccelerationStructureKHR(VkCommandBuffe
vkCmdCopyAccelerationStructureNV(commandBuffer, pInfo->dst, pInfo->src, pInfo->mode);
}
-static void VKAPI_CALL Redirect_vkCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
- const VkStridedBufferRegionKHR* pRaygenShaderBindingTable,
- const VkStridedBufferRegionKHR* pMissShaderBindingTable,
- const VkStridedBufferRegionKHR* pHitShaderBindingTable,
- const VkStridedBufferRegionKHR* pCallableShaderBindingTable,
- uint32_t width,
- uint32_t height,
- uint32_t depth)
+void VKAPI_CALL Redirect_vkCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
+ const VkStridedBufferRegionKHR* pRaygenShaderBindingTable,
+ const VkStridedBufferRegionKHR* pMissShaderBindingTable,
+ const VkStridedBufferRegionKHR* pHitShaderBindingTable,
+ const VkStridedBufferRegionKHR* pCallableShaderBindingTable,
+ uint32_t width,
+ uint32_t height,
+ uint32_t depth)
{
vkCmdTraceRaysNV(commandBuffer,
pRaygenShaderBindingTable->buffer, pRaygenShaderBindingTable->offset,
@@ -410,22 +415,22 @@ static void VKAPI_CALL Redirect_vkCmdTraceRaysKHR(VkCommandBuffer
width, height, depth);
}
-static VkResult VKAPI_CALL Redirect_vkGetRayTracingShaderGroupHandlesKHR(VkDevice device,
- VkPipeline pipeline,
- uint32_t firstGroup,
- uint32_t groupCount,
- size_t dataSize,
- void* pData)
+VkResult VKAPI_CALL Redirect_vkGetRayTracingShaderGroupHandlesKHR(VkDevice device,
+ VkPipeline pipeline,
+ uint32_t firstGroup,
+ uint32_t groupCount,
+ size_t dataSize,
+ void* pData)
{
return vkGetRayTracingShaderGroupHandlesNV(device, pipeline, firstGroup, groupCount, dataSize, pData);
}
-static VkResult VKAPI_CALL Redirect_vkCreateRayTracingPipelinesKHR(VkDevice device,
- VkPipelineCache pipelineCache,
- uint32_t createInfoCount,
- const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
- const VkAllocationCallbacks* pAllocator,
- VkPipeline* pPipelines)
+VkResult VKAPI_CALL Redirect_vkCreateRayTracingPipelinesKHR(VkDevice device,
+ VkPipelineCache pipelineCache,
+ uint32_t createInfoCount,
+ const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
+ VkPipeline* pPipelines)
{
std::vector<VkRayTracingPipelineCreateInfoNV> Infos;
std::vector<VkRayTracingShaderGroupCreateInfoNV> Groups;
@@ -488,6 +493,8 @@ static VkResult VKAPI_CALL Redirect_vkCreateRayTracingPipelinesKHR(VkDevice
return vkCreateRayTracingPipelinesNV(device, pipelineCache, createInfoCount, Infos.data(), pAllocator, pPipelines);
}
+} // namespace
+
void EnableRayTracingKHRviaNV()
{
vkCreateAccelerationStructureKHR = &Redirect_vkCreateAccelerationStructureKHR;
diff --git a/Graphics/ShaderTools/src/GLSLangUtils.cpp b/Graphics/ShaderTools/src/GLSLangUtils.cpp
index 4382f67f..f23a46a3 100644
--- a/Graphics/ShaderTools/src/GLSLangUtils.cpp
+++ b/Graphics/ShaderTools/src/GLSLangUtils.cpp
@@ -70,7 +70,7 @@ void FinalizeGlslang()
static EShLanguage ShaderTypeToShLanguage(SHADER_TYPE ShaderType)
{
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please handle the new shader type in the switch below");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please handle the new shader type in the switch below");
switch (ShaderType)
{
// clang-format off
diff --git a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
index b20394a4..f21d2075 100644
--- a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp
@@ -150,7 +150,7 @@ ShaderResourceDesc SPIRVShaderResourceAttribs::GetResourceDesc() const
static spv::ExecutionModel ShaderTypeToExecutionModel(SHADER_TYPE ShaderType)
{
- static_assert(SHADER_TYPE_LAST == 0x2000, "Please handle the new shader type in the switch below");
+ static_assert(SHADER_TYPE_LAST == SHADER_TYPE_CALLABLE, "Please handle the new shader type in the switch below");
switch (ShaderType)
{
// clang-format off