summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-10-04 20:19:28 +0000
committerazhirnov <zh1dron@gmail.com>2020-10-04 20:19:28 +0000
commited77a78d7da575785f07b50a19f277624ccc1fd6 (patch)
tree1507e44d15836b95bbef328fc301a6807d1ff8d0 /Graphics/GraphicsEngine
parentAdded device features to inidicate 8-bit types support (API240074) (diff)
downloadDiligentCore-ed77a78d7da575785f07b50a19f277624ccc1fd6.tar.gz
DiligentCore-ed77a78d7da575785f07b50a19f277624ccc1fd6.zip
Added ray tracing types
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/CMakeLists.txt6
-rw-r--r--Graphics/GraphicsEngine/interface/BottomLevelAS.h217
-rw-r--r--Graphics/GraphicsEngine/interface/Buffer.h2
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h350
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h43
-rw-r--r--Graphics/GraphicsEngine/interface/PipelineState.h73
-rw-r--r--Graphics/GraphicsEngine/interface/RenderDevice.h17
-rw-r--r--Graphics/GraphicsEngine/interface/Shader.h26
-rw-r--r--Graphics/GraphicsEngine/interface/ShaderBindingTable.h191
-rw-r--r--Graphics/GraphicsEngine/interface/TopLevelAS.h138
-rw-r--r--Graphics/GraphicsEngine/src/BufferBase.cpp5
11 files changed, 1039 insertions, 29 deletions
diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt
index b99138ca..3162b6a0 100644
--- a/Graphics/GraphicsEngine/CMakeLists.txt
+++ b/Graphics/GraphicsEngine/CMakeLists.txt
@@ -28,6 +28,9 @@ set(INCLUDE
include/SwapChainBase.hpp
include/TextureBase.hpp
include/TextureViewBase.hpp
+ include/BottomLevelASBase.hpp
+ include/TopLevelASBase.hpp
+ include/ShaderBindingTableBase.hpp
)
set(INTERFACE
@@ -58,6 +61,9 @@ set(INTERFACE
interface/SwapChain.h
interface/Texture.h
interface/TextureView.h
+ interface/BottomLevelAS.h
+ interface/TopLevelAS.h
+ interface/ShaderBindingTable.h
)
set(SOURCE
diff --git a/Graphics/GraphicsEngine/interface/BottomLevelAS.h b/Graphics/GraphicsEngine/interface/BottomLevelAS.h
new file mode 100644
index 00000000..507f461c
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/BottomLevelAS.h
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Definition of the Diligent::IBottomLevelAS interface and related data structures
+
+#include "../../../Primitives/interface/Object.h"
+#include "../../../Primitives/interface/FlagEnum.h"
+#include "GraphicsTypes.h"
+#include "Constants.h"
+#include "Buffer.h"
+
+DILIGENT_BEGIN_NAMESPACE(Diligent)
+
+// {E56F5755-FE5E-496C-BFA7-BCD535360FF7}
+static const INTERFACE_ID IID_BottomLevelAS =
+ {0xe56f5755, 0xfe5e, 0x496c, {0xbf, 0xa7, 0xbc, 0xd5, 0x35, 0x36, 0xf, 0xf7}};
+
+// clang-format off
+
+/// Defines bottom level acceleration structure triangles description.
+
+/// AZ TODO
+struct BLASTriangleDesc
+{
+ /// The geometry name.
+ /// Name used only 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.
+ Uint32 MaxVertexCount DEFAULT_INITIALIZER(0);
+
+ /// The vertices value type of this geometry.
+ /// Float, Int16 are supported.
+ VALUE_TYPE VertexValueType DEFAULT_INITIALIZER(VT_UNDEFINED);
+
+ /// The number of components in vertex.
+ /// 2 and 3 are supported.
+ 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.
+ Uint32 MaxIndexCount DEFAULT_INITIALIZER(0);
+
+ /// The indices type of this geometry.
+ /// Must be VT_UINT16, VT_UINT32 or VT_UNDEFINED.
+ VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED);
+
+ /// AZ TODO
+ Bool AllowsTransforms DEFAULT_INITIALIZER(False);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BLASTriangleDesc() noexcept {}
+#endif
+};
+typedef struct BLASTriangleDesc BLASTriangleDesc;
+
+
+/// Defines bottom level acceleration structure axis aligned bounding boxes description.
+
+/// AZ TODO
+struct BLASBoundingBoxDesc
+{
+ /// The geometry name.
+ /// Name used only to map BLASBuildBoundingBoxData to this geometry.
+ const char* GeometryName DEFAULT_INITIALIZER(nullptr);
+
+ /// The maximum AABBs count.
+ /// Current number of AABBs defined in BLASBuildBoundingBoxData::BoxCount.
+ Uint32 MaxBoxCount DEFAULT_INITIALIZER(0);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BLASBoundingBoxDesc() noexcept {}
+#endif
+};
+typedef struct BLASBoundingBoxDesc BLASBoundingBoxDesc;
+
+
+/// AZ TODO
+
+/// AZ TODO
+DILIGENT_TYPED_ENUM(RAYTRACING_BUILD_AS_FLAGS, Uint8)
+{
+ /// AZ TODO
+ RAYTRACING_BUILD_AS_NONE = 0,
+
+ /// AZ TODO
+ RAYTRACING_BUILD_AS_ALLOW_UPDATE = 0x01,
+
+ /// Indicates that the specified acceleration structure can act as the source for a copy acceleration structure command
+ /// with mode of COPY_AS_MODE_COMPACT to produce a compacted acceleration structure.
+ RAYTRACING_BUILD_AS_ALLOW_COMPACTION = 0x02,
+
+ /// Indicates that the given acceleration structure build should prioritize trace performance over build time.
+ RAYTRACING_BUILD_AS_PREFER_FAST_TRACE = 0x04,
+
+ /// 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.
+ RAYTRACING_BUILD_AS_LOW_MEMORY = 0x10,
+
+ RAYTRACING_BUILD_AS_FLAGS_LAST = 0x10
+};
+DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_BUILD_AS_FLAGS)
+
+
+/// AZ TODO
+
+// Here we allocate space for geometry data.
+// Geometry can be dynamically updated.
+struct BottomLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs)
+
+ /// Array of triangle geometry descriptions.
+ const BLASTriangleDesc* pTriangles DEFAULT_INITIALIZER(nullptr);
+
+ /// Number of triangle geometries.
+ Uint32 TriangleCount DEFAULT_INITIALIZER(0);
+
+ /// Array of AABB geometry descriptions.
+ const BLASBoundingBoxDesc* pBoxes DEFAULT_INITIALIZER(nullptr);
+
+ /// Number of AABB geometries;
+ Uint32 BoxCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RAYTRACING_BUILD_AS_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_BUILD_AS_NONE);
+
+ /// Defines which command queues this BLAS can be used with
+ Uint64 CommandQueueMask DEFAULT_INITIALIZER(1);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BottomLevelASDesc() noexcept {}
+#endif
+};
+typedef struct BottomLevelASDesc BottomLevelASDesc;
+
+struct ScratchBufferSizes
+{
+ Uint32 Build DEFAULT_INITIALIZER(0);
+ Uint32 Update DEFAULT_INITIALIZER(0);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ ScratchBufferSizes() noexcept {}
+#endif
+};
+typedef struct ScratchBufferSizes ScratchBufferSizes;
+
+#define DILIGENT_INTERFACE_NAME IBottomLevelAS
+#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
+
+#define IBottomLevelASInclusiveMethods \
+ IDeviceObjectInclusiveMethods; \
+ IBottomLevelASMethods IBottomLevelAS
+
+/// AZ TODO
+DILIGENT_BEGIN_INTERFACE(IBottomLevelAS, IDeviceObject)
+{
+#if DILIGENT_CPP_INTERFACE
+ /// Returns the bottom level AS description used to create the object
+ virtual const BottomLevelASDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
+#endif
+
+ /// AZ TODO
+ VIRTUAL Uint32 METHOD(GetGeometryIndex)(THIS_
+ const char* Name) CONST PURE;
+
+ /// AZ TODO
+ VIRTUAL ScratchBufferSizes METHOD(GetScratchBufferSizes)(THIS) CONST PURE;
+};
+DILIGENT_END_INTERFACE
+
+#include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
+
+#if DILIGENT_C_INTERFACE
+
+// clang-format off
+
+# define IBottomLevelAS_GetGeometryIndex(This, ...) CALL_IFACE_METHOD(BottomLevelAS, GetGeometryIndex, This, __VA_ARGS__)
+
+// clang-format on
+
+#endif
+
+DILIGENT_END_NAMESPACE // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h
index 417b8ac3..dd7f0c84 100644
--- a/Graphics/GraphicsEngine/interface/Buffer.h
+++ b/Graphics/GraphicsEngine/interface/Buffer.h
@@ -81,7 +81,7 @@ struct BufferDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// The following bind flags are allowed:
/// Diligent::BIND_VERTEX_BUFFER, Diligent::BIND_INDEX_BUFFER, Diligent::BIND_UNIFORM_BUFFER,
/// Diligent::BIND_SHADER_RESOURCE, Diligent::BIND_STREAM_OUTPUT, Diligent::BIND_UNORDERED_ACCESS,
- /// Diligent::BIND_INDIRECT_DRAW_ARGS
+ /// Diligent::BIND_INDIRECT_DRAW_ARGS, Diligent::BIND_RAY_TRACING
BIND_FLAGS BindFlags DEFAULT_INITIALIZER(BIND_NONE);
/// Buffer usage, see Diligent::USAGE for details
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index 6320f947..7491a14f 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -53,6 +53,9 @@
#include "Framebuffer.h"
#include "CommandList.h"
#include "SwapChain.h"
+#include "BottomLevelAS.h"
+#include "TopLevelAS.h"
+#include "ShaderBindingTable.h"
DILIGENT_BEGIN_NAMESPACE(Diligent)
@@ -716,6 +719,326 @@ struct BeginRenderPassAttribs
};
typedef struct BeginRenderPassAttribs BeginRenderPassAttribs;
+/// AZ TODO
+DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8)
+{
+ /// AZ TODO
+ RAYTRACING_INSTANCE_NONE = 0,
+
+ // 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.
+ 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.
+ 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.
+ RAYTRACING_INSTANCE_FORCE_NO_OPAQUE = 0x08,
+
+ RAYTRACING_INSTANCE_FLAGS_LAST = 0x08
+};
+
+/// 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.
+ COPY_AS_MODE_CLONE = 0,
+
+ // creates a more compact version of an acceleration structure src into dst.
+ // The acceleration structure dst must have been created with a compactedSize corresponding to the one returned by vkCmdWriteAccelerationStructuresPropertiesKHR
+ // after the build of the acceleration structure specified by src.
+ //COPY_AS_MODE_COMPACT,
+
+ COPY_AS_MODE_LAST = 0,
+};
+
+/// Defines geometry flags for ray tracing.
+
+/// AZ TODO
+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.
+ 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.
+ RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION = 0x02,
+
+ RAYTRACING_GEOMETRY_FLAGS_LAST = 0x02
+};
+DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_GEOMETRY_FLAGS)
+
+/// AZ TODO
+struct BLASBuildTriangleData
+{
+ // put geometry data to geometry that allocated by BLASTriangleDesc
+ const char* GeometryName DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IBuffer* pVertexBuffer DEFAULT_INITIALIZER(nullptr); // specs: Triangles are considered "inactive" (but legal input to acceleration structure build) if the x component of each vertex is NaN
+
+ /// AZ TODO
+ Uint32 VertexOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint32 VertexStride DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint32 VertexCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ VALUE_TYPE VertexValueType DEFAULT_INITIALIZER(VT_UNDEFINED); // optional, value may be taken from declaration
+ Uint8 VertexComponentCount DEFAULT_INITIALIZER(0); // optional, value may be taken from declaration
+
+ // optional
+
+ /// AZ TODO
+ IBuffer* pIndexBuffer DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 IndexOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint32 IndexCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ VALUE_TYPE IndexType DEFAULT_INITIALIZER(VT_UNDEFINED); // optional, value may be taken from declaration
+
+ // optional, buffer that contains 3x4 matrix with local transformation for this triangles/mesh
+
+ /// AZ TODO
+ IBuffer* pTransformBuffer DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 TransformBufferOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BLASBuildTriangleData() noexcept {}
+#endif
+};
+typedef struct BLASBuildTriangleData BLASBuildTriangleData;
+
+/// AZ TODO
+struct BLASBuildBoundingBoxData
+{
+ /// AZ TODO
+ // put geometry data to geometry that allocated by BLASBoundingBoxDesc
+ const char* GeometryName DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IBuffer* pBoxBuffer DEFAULT_INITIALIZER(nullptr); // specs: AABBs are considered inactive if AABB.MinX is NaN
+
+ /// AZ TODO
+ Uint32 BoxOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint32 BoxStride DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint32 BoxCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BLASBuildBoundingBoxData() noexcept {}
+#endif
+};
+typedef struct BLASBuildBoundingBoxData BLASBuildBoundingBoxData;
+
+/// AZ TODO
+struct BLASBuildAttribs
+{
+ /// AZ TODO
+ IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE BLASTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+ /// AZ TODO
+ BLASBuildTriangleData const* pTriangleData DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 TriangleDataCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ BLASBuildBoundingBoxData const* pBoxData DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 BoxDataCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ IBuffer* pScratchBuffer DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 ScratchBufferOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE ScratchBufferTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BLASBuildAttribs() noexcept {}
+#endif
+};
+typedef struct BLASBuildAttribs BLASBuildAttribs;
+
+/// AZ TODO
+const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u;
+
+/// AZ TODO
+struct TLASBuildInstanceData
+{
+ /// AZ TODO
+ const char* InstanceName DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr); // can be null to deactive instance
+
+ /// AZ TODO
+ float Transform[3][4] DEFAULT_INITIALIZER({});
+
+ /// AZ TODO
+ Uint32 customId DEFAULT_INITIALIZER(0); // 24 bits, in shader: gl_InstanceCustomIndexNV for GLSL, InstanceID() for HLSL
+
+ /// AZ TODO
+ RAYTRACING_INSTANCE_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_INSTANCE_NONE);
+
+ /// AZ TODO
+ Uint8 Mask DEFAULT_INITIALIZER(0xFF); // visibility mask for the geometry, the instance may only be hit if rayMask & instance.mask != 0
+
+ /// AZ TODO
+ Uint32 contributionToHitGroupIndex DEFAULT_INITIALIZER(TLAS_INSTANCE_OFFSET_AUTO); // used when TLAS created with SHADER_BINDING_USER_DEFINED, see IShaderBindingTangle::BindAll()
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ TLASBuildInstanceData() noexcept {}
+#endif
+};
+typedef struct TLASBuildInstanceData TLASBuildInstanceData;
+
+/// AZ TODO
+struct TLASBuildAttribs
+{
+ /// AZ TODO
+ ITopLevelAS* pTLAS DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE TLASTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+ /// AZ TODO
+ TLASBuildInstanceData const* pInstances DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 InstanceCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ IBuffer* pInstancesBuffer DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 InstancesBufferOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE InstanceBufferTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+ /// AZ TODO
+ Uint32 HitShadersPerInstance DEFAULT_INITIALIZER(1);
+
+ /// AZ TODO
+ IBuffer* pScratchBuffer DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 ScratchBufferOffset DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE ScratchBufferTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ TLASBuildAttribs() noexcept {}
+#endif
+};
+typedef struct TLASBuildAttribs TLASBuildAttribs;
+
+/// AZ TODO
+struct CopyBLASAttribs
+{
+ /// AZ TODO
+ IBottomLevelAS* pSrc DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IBottomLevelAS* pDst DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ COPY_AS_MODE Mode DEFAULT_INITIALIZER(COPY_AS_MODE_CLONE);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE TransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ CopyBLASAttribs() noexcept {}
+#endif
+};
+typedef struct CopyBLASAttribs CopyBLASAttribs;
+
+/// AZ TODO
+struct CopyTLASAttribs
+{
+ /// AZ TODO
+ ITopLevelAS* pSrc DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ ITopLevelAS* pDst DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ COPY_AS_MODE Mode DEFAULT_INITIALIZER(COPY_AS_MODE_CLONE);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE TransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ CopyTLASAttribs() noexcept {}
+#endif
+};
+typedef struct CopyTLASAttribs CopyTLASAttribs;
+
+/// AZ TODO
+struct TraceRaysAttribs
+{
+ /// AZ TODO
+ IShaderBindingTable* pSBT DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint32 DimensionX DEFAULT_INITIALIZER(1);
+ Uint32 DimensionY DEFAULT_INITIALIZER(1);
+ Uint32 DimensionZ DEFAULT_INITIALIZER(1);
+
+ /// AZ TODO
+ RESOURCE_STATE_TRANSITION_MODE TransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ TraceRaysAttribs() noexcept {}
+#endif
+};
+typedef struct TraceRaysAttribs TraceRaysAttribs;
+
#define DILIGENT_INTERFACE_NAME IDeviceContext
#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
@@ -1491,6 +1814,26 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject)
ITexture* pSrcTexture,
ITexture* pDstTexture,
const ResolveTextureSubresourceAttribs REF ResolveAttribs) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BuildBLAS)(THIS_
+ const BLASBuildAttribs REF Attribs) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BuildTLAS)(THIS_
+ const TLASBuildAttribs REF Attribs) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(CopyBLAS)(THIS_
+ const CopyBLASAttribs REF Attribs) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(CopyTLAS)(THIS_
+ const CopyTLASAttribs REF Attribs) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(TraceRays)(THIS_
+ const TraceRaysAttribs REF Attribs) PURE;
};
DILIGENT_END_INTERFACE
@@ -1515,6 +1858,8 @@ DILIGENT_END_INTERFACE
# define IDeviceContext_DrawIndexed(This, ...) CALL_IFACE_METHOD(DeviceContext, DrawIndexed, This, __VA_ARGS__)
# define IDeviceContext_DrawIndirect(This, ...) CALL_IFACE_METHOD(DeviceContext, DrawIndirect, This, __VA_ARGS__)
# define IDeviceContext_DrawIndexedIndirect(This, ...) CALL_IFACE_METHOD(DeviceContext, DrawIndexedIndirect, This, __VA_ARGS__)
+# define IDeviceContext_DrawMesh(This, ...) CALL_IFACE_METHOD(DeviceContext, DrawMesh, This, __VA_ARGS__)
+# define IDeviceContext_DrawMeshIndirect(This, ...) CALL_IFACE_METHOD(DeviceContext, DrawMeshIndirect, This, __VA_ARGS__)
# define IDeviceContext_DispatchCompute(This, ...) CALL_IFACE_METHOD(DeviceContext, DispatchCompute, This, __VA_ARGS__)
# define IDeviceContext_DispatchComputeIndirect(This, ...) CALL_IFACE_METHOD(DeviceContext, DispatchComputeIndirect, This, __VA_ARGS__)
# define IDeviceContext_ClearDepthStencil(This, ...) CALL_IFACE_METHOD(DeviceContext, ClearDepthStencil, This, __VA_ARGS__)
@@ -1539,6 +1884,11 @@ DILIGENT_END_INTERFACE
# define IDeviceContext_FinishFrame(This) CALL_IFACE_METHOD(DeviceContext, FinishFrame, This)
# define IDeviceContext_TransitionResourceStates(This, ...) CALL_IFACE_METHOD(DeviceContext, TransitionResourceStates, This, __VA_ARGS__)
# define IDeviceContext_ResolveTextureSubresource(This, ...) CALL_IFACE_METHOD(DeviceContext, ResolveTextureSubresource, This, __VA_ARGS__)
+# define IDeviceContext_BuildBLAS(This, ...) CALL_IFACE_METHOD(DeviceContext, BuildBLAS, This, __VA_ARGS__)
+# define IDeviceContext_BuildTLAS(This, ...) CALL_IFACE_METHOD(DeviceContext, BuildTLAS, This, __VA_ARGS__)
+# define IDeviceContext_CopyBLAS(This, ...) CALL_IFACE_METHOD(DeviceContext, CopyBLAS, This, __VA_ARGS__)
+# define IDeviceContext_CopyTLAS(This, ...) CALL_IFACE_METHOD(DeviceContext, CopyTLAS, This, __VA_ARGS__)
+# define IDeviceContext_TraceRays(This, ...) CALL_IFACE_METHOD(DeviceContext, TraceRays, This, __VA_ARGS__)
// clang-format on
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index b681c498..56db9e61 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -73,19 +73,21 @@ DILIGENT_TYPED_ENUM(VALUE_TYPE, Uint8)
/// - TextureDesc to describe bind flags for a texture
DILIGENT_TYPED_ENUM(BIND_FLAGS, Uint32)
{
- BIND_NONE = 0x0L, ///< Undefined binding
- BIND_VERTEX_BUFFER = 0x1L, ///< A buffer can be bound as a vertex buffer
- BIND_INDEX_BUFFER = 0x2L, ///< A buffer can be bound as an index buffer
- BIND_UNIFORM_BUFFER = 0x4L, ///< A buffer can be bound as a uniform buffer
- /// \warning This flag may not be combined with any other bind flag
- BIND_SHADER_RESOURCE = 0x8L, ///< A buffer or a texture can be bound as a shader resource
- /// \warning This flag cannot be used with MAP_WRITE_NO_OVERWRITE flag
- BIND_STREAM_OUTPUT = 0x10L,///< A buffer can be bound as a target for stream output stage
- BIND_RENDER_TARGET = 0x20L,///< A texture can be bound as a render target
- BIND_DEPTH_STENCIL = 0x40L,///< A texture can be bound as a depth-stencil target
- BIND_UNORDERED_ACCESS = 0x80L,///< A buffer or a texture can be bound as an unordered access view
- BIND_INDIRECT_DRAW_ARGS = 0x100L,///< A buffer can be bound as the source buffer for indirect draw commands
- BIND_INPUT_ATTACHMENT = 0x200L ///< A texture can be used as render pass input attachment
+ BIND_NONE = 0x0L, ///< Undefined binding
+ BIND_VERTEX_BUFFER = 0x1L, ///< A buffer can be bound as a vertex buffer
+ BIND_INDEX_BUFFER = 0x2L, ///< A buffer can be bound as an index buffer
+ BIND_UNIFORM_BUFFER = 0x4L, ///< A buffer can be bound as a uniform buffer
+ /// \warning This flag may not be combined with any other bind flag
+ BIND_SHADER_RESOURCE = 0x8L, ///< A buffer or a texture can be bound as a shader resource
+ /// \warning This flag cannot be used with MAP_WRITE_NO_OVERWRITE flag
+ BIND_STREAM_OUTPUT = 0x10L, ///< A buffer can be bound as a target for stream output stage
+ BIND_RENDER_TARGET = 0x20L, ///< A texture can be bound as a render target
+ BIND_DEPTH_STENCIL = 0x40L, ///< A texture can be bound as a depth-stencil target
+ BIND_UNORDERED_ACCESS = 0x80L, ///< A buffer or a texture can be bound as an unordered access view
+ BIND_INDIRECT_DRAW_ARGS = 0x100L, ///< A buffer can be bound as the source buffer for indirect draw commands
+ BIND_INPUT_ATTACHMENT = 0x200L, ///< A texture can be used as render pass input attachment
+ BIND_RAY_TRACING = 0x400L, ///< AZ TODO
+ BIND_FLAGS_LAST = 0x400L
};
DEFINE_FLAG_ENUM_OPERATORS(BIND_FLAGS)
@@ -1535,6 +1537,9 @@ struct DeviceFeatures
/// Indicates if device supports mesh and amplification shaders
DEVICE_FEATURE_STATE MeshShaders DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED);
+
+ /// Indicates if device supports ray tracing shaders
+ DEVICE_FEATURE_STATE RayTracing DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED);
/// Indicates if device supports bindless resources
DEVICE_FEATURE_STATE BindlessResources DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED);
@@ -1623,6 +1628,7 @@ struct DeviceFeatures
GeometryShaders {State},
Tessellation {State},
MeshShaders {State},
+ RayTracing {State},
BindlessResources {State},
OcclusionQueries {State},
BinaryOcclusionQueries {State},
@@ -1647,7 +1653,7 @@ struct DeviceFeatures
UniformBuffer8BitAccess {State}
{
# if defined(_MSC_VER) && defined(_WIN64)
- static_assert(sizeof(*this) == 30, "Did you add a new feature to DeviceFeatures? Please handle its status above.");
+ static_assert(sizeof(*this) == 31, "Did you add a new feature to DeviceFeatures? Please handle its status above.");
# endif
}
#endif
@@ -1866,8 +1872,8 @@ typedef struct EngineCreateInfo EngineCreateInfo;
/// Attributes of the OpenGL-based engine implementation
struct EngineGLCreateInfo DILIGENT_DERIVE(EngineCreateInfo)
- /// Native window wrapper
- NativeWindow Window;
+ /// Native window wrapper
+ NativeWindow Window;
/// Create debug OpenGL context and enable debug output.
@@ -2694,7 +2700,10 @@ DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32)
/// The resource is used for present
RESOURCE_STATE_PRESENT = 0x10000,
- RESOURCE_STATE_MAX_BIT = 0x10000,
+ RESOURCE_STATE_BUILD_AS = 0x20000,
+ RESOURCE_STATE_RAY_TRACING = 0x40000,
+
+ RESOURCE_STATE_MAX_BIT = 0x40000,
RESOURCE_STATE_GENERIC_READ = RESOURCE_STATE_VERTEX_BUFFER |
RESOURCE_STATE_CONSTANT_BUFFER |
diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h
index 9491168d..7e17cdd4 100644
--- a/Graphics/GraphicsEngine/interface/PipelineState.h
+++ b/Graphics/GraphicsEngine/interface/PipelineState.h
@@ -244,6 +244,73 @@ struct ComputePipelineDesc
};
typedef struct ComputePipelineDesc ComputePipelineDesc;
+/// AZ TODO
+struct RayTracingGeneralShaderGroup
+{
+ /// AZ TODO
+ const char* Name DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IShader* Shader DEFAULT_INITIALIZER(nullptr);
+};
+typedef struct RayTracingGeneralShaderGroup RayTracingGeneralShaderGroup;
+
+/// AZ TODO
+struct RayTracingTriangleHitShaderGroup
+{
+ /// AZ TODO
+ const char* Name DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IShader* ClosestHitShader DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IShader* AnyHitShader DEFAULT_INITIALIZER(nullptr); // can be null
+};
+typedef struct RayTracingTriangleHitShaderGroup RayTracingTriangleHitShaderGroup;
+
+/// AZ TODO
+struct RayTracingProceduralHitShaderGroup
+{
+ /// AZ TODO
+ const char* Name DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IShader* IntersectionShader DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ IShader* ClosestHitShader DEFAULT_INITIALIZER(nullptr); // can be null
+
+ /// AZ TODO
+ IShader* AnyHitShader DEFAULT_INITIALIZER(nullptr); // can be null
+};
+typedef struct RayTracingProceduralHitShaderGroup RayTracingProceduralHitShaderGroup;
+
+/// AZ TODO
+struct RayTracingPipelineDesc
+{
+ /// AZ TODO
+ const RayTracingGeneralShaderGroup* pGeneralShaders DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ const RayTracingTriangleHitShaderGroup* pTriangleHitShaders DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ const RayTracingProceduralHitShaderGroup* pProceduralHitShaders DEFAULT_INITIALIZER(nullptr);
+
+ /// AZ TODO
+ Uint16 GeneralShaderCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint16 TriangleHitShaderCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint16 ProceduralHitShaderCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint8 MaxRecursionDepth DEFAULT_INITIALIZER(0); // must be 0..31 (check current device limits)
+};
+typedef struct RayTracingPipelineDesc RayTracingPipelineDesc;
/// Pipeline type
DILIGENT_TYPED_ENUM(PIPELINE_TYPE, Uint8)
@@ -257,6 +324,9 @@ DILIGENT_TYPED_ENUM(PIPELINE_TYPE, Uint8)
/// Mesh pipeline, which is used by IDeviceContext::DrawMesh(), IDeviceContext::DrawMeshIndirect().
PIPELINE_TYPE_MESH,
+
+ /// Ray tracing pipeline, which is used by IDeviceContext::TraceRays().
+ PIPELINE_TYPE_RAY_TRACING,
};
@@ -284,6 +354,9 @@ struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// Compute pipeline state description. This memeber is ignored if PipelineType is not PIPELINE_TYPE_COMPUTE
ComputePipelineDesc ComputePipeline;
+ /// Ray tracing pipeline state description. This memeber is ignored if PipelineType is not PIPELINE_TYPE_RAY_TRACING.
+ RayTracingPipelineDesc RayTracingPipeline;
+
#if DILIGENT_CPP_INTERFACE
bool IsAnyGraphicsPipeline() const { return PipelineType == PIPELINE_TYPE_GRAPHICS || PipelineType == PIPELINE_TYPE_MESH; }
bool IsComputePipeline () const { return PipelineType == PIPELINE_TYPE_COMPUTE; }
diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h
index 0cea79eb..69657254 100644
--- a/Graphics/GraphicsEngine/interface/RenderDevice.h
+++ b/Graphics/GraphicsEngine/interface/RenderDevice.h
@@ -47,6 +47,9 @@
#include "Query.h"
#include "RenderPass.h"
#include "Framebuffer.h"
+#include "BottomLevelAS.h"
+#include "TopLevelAS.h"
+#include "ShaderBindingTable.h"
#include "DepthStencilState.h"
#include "RasterizerState.h"
@@ -213,6 +216,20 @@ DILIGENT_BEGIN_INTERFACE(IRenderDevice, IObject)
const FramebufferDesc REF Desc,
IFramebuffer** ppFramebuffer) PURE;
+ /// AZ TODO
+ VIRTUAL void METHOD(CreateBLAS)(THIS_
+ const BottomLevelASDesc REF Desc,
+ IBottomLevelAS** ppBLAS) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(CreateTLAS)(THIS_
+ const TopLevelASDesc REF Desc,
+ ITopLevelAS** ppTLAS) PURE;
+
+ /// AZ TODO
+ 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/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h
index e004f7f1..03dc06f0 100644
--- a/Graphics/GraphicsEngine/interface/Shader.h
+++ b/Graphics/GraphicsEngine/interface/Shader.h
@@ -45,16 +45,22 @@ static const INTERFACE_ID IID_Shader =
/// Describes the shader type
DILIGENT_TYPED_ENUM(SHADER_TYPE, Uint32)
{
- SHADER_TYPE_UNKNOWN = 0x000, ///< Unknown shader type
- SHADER_TYPE_VERTEX = 0x001, ///< Vertex shader
- SHADER_TYPE_PIXEL = 0x002, ///< Pixel (fragment) shader
- SHADER_TYPE_GEOMETRY = 0x004, ///< Geometry shader
- SHADER_TYPE_HULL = 0x008, ///< Hull (tessellation control) shader
- SHADER_TYPE_DOMAIN = 0x010, ///< Domain (tessellation evaluation) shader
- SHADER_TYPE_COMPUTE = 0x020, ///< Compute shader
- SHADER_TYPE_AMPLIFICATION = 0x040, ///< Amplification (task) shader
- SHADER_TYPE_MESH = 0x080, ///< Mesh shader
- SHADER_TYPE_LAST = SHADER_TYPE_MESH
+ SHADER_TYPE_UNKNOWN = 0x0000, ///< Unknown shader type
+ SHADER_TYPE_VERTEX = 0x0001, ///< Vertex shader
+ SHADER_TYPE_PIXEL = 0x0002, ///< Pixel (fragment) shader
+ SHADER_TYPE_GEOMETRY = 0x0004, ///< Geometry shader
+ SHADER_TYPE_HULL = 0x0008, ///< Hull (tessellation control) shader
+ SHADER_TYPE_DOMAIN = 0x0010, ///< Domain (tessellation evaluation) shader
+ SHADER_TYPE_COMPUTE = 0x0020, ///< Compute shader
+ SHADER_TYPE_AMPLIFICATION = 0x0040, ///< Amplification (task) shader
+ SHADER_TYPE_MESH = 0x0080, ///< Mesh shader
+ SHADER_TYPE_RAY_GEN = 0x0100, ///< Ray generation shader
+ SHADER_TYPE_RAY_MISS = 0x0200, ///< Ray miss shader
+ SHADER_TYPE_RAY_CLOSEST_HIT = 0x0400, ///< Ray closest hit shader
+ SHADER_TYPE_RAY_ANY_HIT = 0x0800, ///< Ray any hit shader
+ SHADER_TYPE_RAY_INTERSECTION = 0x1000, ///< Ray intersection shader
+ SHADER_TYPE_CALLABLE = 0x2000, ///< Callable shader
+ SHADER_TYPE_LAST = SHADER_TYPE_CALLABLE
};
DEFINE_FLAG_ENUM_OPERATORS(SHADER_TYPE);
diff --git a/Graphics/GraphicsEngine/interface/ShaderBindingTable.h b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
new file mode 100644
index 00000000..c2b8309c
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/ShaderBindingTable.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Definition of the Diligent::IShaderBindingTable interface and related data structures
+
+#include "../../../Primitives/interface/Object.h"
+#include "../../../Primitives/interface/FlagEnum.h"
+#include "GraphicsTypes.h"
+#include "Constants.h"
+#include "Buffer.h"
+#include "PipelineState.h"
+
+DILIGENT_BEGIN_NAMESPACE(Diligent)
+
+// {1EE12101-7010-4825-AA8E-AC6BB9858BD6}
+static const INTERFACE_ID IID_ShaderBindingTable =
+ {0x1ee12101, 0x7010, 0x4825, {0xaa, 0x8e, 0xac, 0x6b, 0xb9, 0x85, 0x8b, 0xd6}};
+
+// clang-format off
+
+/// AZ TODO
+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
+ Uint32 ShaderRecordSize DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ Uint32 HitShadersPerInstance DEFAULT_INITIALIZER(1);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ ShaderBindingTableDesc() noexcept {}
+#endif
+};
+typedef struct ShaderBindingTableDesc ShaderBindingTableDesc;
+
+/// AZ TODO
+struct BindAllAttribs
+{
+ /// AZ TODO
+ Uint32 RayGenShader DEFAULT_INITIALIZER(~0u);
+ const void* RayGenSRData DEFAULT_INITIALIZER(nullptr); // optional, can be null
+ Uint32 RayGenSRDataSize DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ const Uint32* MissShaders DEFAULT_INITIALIZER(nullptr);
+ Uint32 MissShaderCount DEFAULT_INITIALIZER(0);
+ const void* MissSRData DEFAULT_INITIALIZER(nullptr); // optional, can be null
+ Uint32 MissSRDataSize DEFAULT_INITIALIZER(0); // stride will be calculated as (MissSRDataSize / MissShaderCount)
+
+ /// AZ TODO
+ const Uint32* CallableShaders DEFAULT_INITIALIZER(nullptr);
+ Uint32 CallableShaderCount DEFAULT_INITIALIZER(0);
+ const void* CallableSRData DEFAULT_INITIALIZER(nullptr); // optional, can be null
+ Uint32 CallableSRDataSize DEFAULT_INITIALIZER(0); // stride will be calculated as (CallableSRDataSize / CallableShaderCount)
+
+ /// AZ TODO
+ const Uint32* HitGroups DEFAULT_INITIALIZER(nullptr); // optional, can be null
+ Uint32 HitGroupCount DEFAULT_INITIALIZER(0);
+ const void* HitSRData DEFAULT_INITIALIZER(nullptr); // optional, can be null
+ Uint32 HitSRDataSize DEFAULT_INITIALIZER(0); // stride will be calculated as (HitSRDataSize / HitGroupCount)
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ BindAllAttribs() noexcept {}
+#endif
+};
+typedef struct BindAllAttribs BindAllAttribs;
+
+#define DILIGENT_INTERFACE_NAME IShaderBindingTable
+#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
+
+#define IShaderBindingTableInclusiveMethods \
+ IDeviceObjectInclusiveMethods; \
+ IShaderBindingTableMethods ShaderBindingTable
+
+/// AZ TODO
+DILIGENT_BEGIN_INTERFACE(IShaderBindingTable, IDeviceObject)
+{
+#if DILIGENT_CPP_INTERFACE
+ /// Returns the shader binding table description used to create the object
+ virtual const ShaderBindingTableDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
+#endif
+
+ /// AZ TODO
+ VIRTUAL void METHOD(Verify)(THIS) CONST PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(Reset)(THIS_
+ const ShaderBindingTableDesc REF Desc) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(ResetHitGroups)(THIS_
+ Uint32 HitShadersPerInstance) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BindRayGenShader)(THIS_
+ const char* ShaderGroupName,
+ const void* Data DEFAULT_INITIALIZER(nullptr),
+ Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BindMissShader)(THIS_
+ const char* ShaderGroupName,
+ Uint32 MissIndex,
+ const void* Data DEFAULT_INITIALIZER(nullptr),
+ Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BindHitGroup)(THIS_
+ ITopLevelAS* pTLAS,
+ const char* InstanceName,
+ const char* GeometryName,
+ Uint32 RayOffsetInHitGroupIndex,
+ const char* ShaderGroupName,
+ const void* Data DEFAULT_INITIALIZER(nullptr),
+ Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BindHitGroups)(THIS_
+ ITopLevelAS* pTLAS,
+ const char* InstanceName,
+ Uint32 RayOffsetInHitGroupIndex,
+ const char* ShaderGroupName,
+ const void* Data DEFAULT_INITIALIZER(nullptr),
+ Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BindCallableShader)(THIS_
+ Uint32 Index,
+ const char* ShaderName,
+ const void* Data DEFAULT_INITIALIZER(nullptr),
+ Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
+
+ /// AZ TODO
+ VIRTUAL void METHOD(BindAll)(THIS_
+ const BindAllAttribs REF Attribs) PURE;
+};
+DILIGENT_END_INTERFACE
+
+#include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
+
+#if DILIGENT_C_INTERFACE
+
+// clang-format off
+
+# define IShaderBindingTable_Verify(This) CALL_IFACE_METHOD(ShaderBindingTable, Verify, This)
+# define IShaderBindingTable_Reset(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, Reset, This, __VA_ARGS__)
+# define IShaderBindingTable_ResetHitGroups(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, ResetHitGroups, This, __VA_ARGS__)
+# define IShaderBindingTable_BindRayGenShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindRayGenShader, This, __VA_ARGS__)
+# define IShaderBindingTable_BindMissShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindMissShader, This, __VA_ARGS__)
+# define IShaderBindingTable_BindHitGroup(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroup, This, __VA_ARGS__)
+# define IShaderBindingTable_BindHitGroups(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroups, This, __VA_ARGS__)
+# define IShaderBindingTable_BindCallableShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindCallableShader, This, __VA_ARGS__)
+# define IShaderBindingTable_BindAll(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindAll, This, __VA_ARGS__)
+
+// clang-format on
+
+#endif
+
+DILIGENT_END_NAMESPACE // namespace Diligent
diff --git a/Graphics/GraphicsEngine/interface/TopLevelAS.h b/Graphics/GraphicsEngine/interface/TopLevelAS.h
new file mode 100644
index 00000000..1cc30f2f
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/TopLevelAS.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Definition of the Diligent::ITopLevelAS interface and related data structures
+
+#include "../../../Primitives/interface/Object.h"
+#include "../../../Primitives/interface/FlagEnum.h"
+#include "GraphicsTypes.h"
+#include "Constants.h"
+#include "Buffer.h"
+#include "BottomLevelAS.h"
+
+DILIGENT_BEGIN_NAMESPACE(Diligent)
+
+// {16561861-294B-4804-96FA-1717333F769A}
+static const INTERFACE_ID IID_TopLevelAS =
+ {0x16561861, 0x294b, 0x4804, {0x96, 0xfa, 0x17, 0x17, 0x33, 0x3f, 0x76, 0x9a}};
+
+// clang-format off
+
+/// AZ TODO
+DILIGENT_TYPED_ENUM(SHADER_BINDING_MODE, Uint8)
+{
+ /// Each geometry in each instance can have unique shader.
+ SHADER_BINDING_MODE_PER_GEOMETRY = 0,
+
+ /// Each instance can have 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()
+ SHADER_BINDING_USER_DEFINED,
+};
+
+/// AZ TODO
+struct TopLevelASDesc DILIGENT_DERIVE(DeviceObjectAttribs)
+
+ // Here we allocate space for instances.
+ // Instances can be dynamicaly updated.
+ Uint32 MaxInstanceCount DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ RAYTRACING_BUILD_AS_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_BUILD_AS_NONE);
+
+ // binding mode used for instanceOffset calculation.
+ SHADER_BINDING_MODE BindingMode DEFAULT_INITIALIZER(SHADER_BINDING_MODE_PER_GEOMETRY);
+
+ /// Defines which command queues this BLAS can be used with
+ Uint64 CommandQueueMask DEFAULT_INITIALIZER(1);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ TopLevelASDesc() noexcept {}
+#endif
+};
+typedef struct TopLevelASDesc TopLevelASDesc;
+
+
+/// AZ TODO
+struct TLASInstanceDesc
+{
+ /// AZ TODO
+ Uint32 contributionToHitGroupIndex DEFAULT_INITIALIZER(0);
+
+ /// AZ TODO
+ IBottomLevelAS* pBLAS DEFAULT_INITIALIZER(nullptr);
+
+#if DILIGENT_CPP_INTERFACE
+ /// AZ TODO
+ TLASInstanceDesc() noexcept {}
+#endif
+};
+typedef struct TLASInstanceDesc TLASInstanceDesc;
+
+
+#define DILIGENT_INTERFACE_NAME ITopLevelAS
+#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
+
+#define ITopLevelASInclusiveMethods \
+ IDeviceObjectInclusiveMethods; \
+ ITopLevelASMethods TopLevelAS
+
+/// AZ TODO
+DILIGENT_BEGIN_INTERFACE(ITopLevelAS, IDeviceObject)
+{
+#if DILIGENT_CPP_INTERFACE
+ /// Returns the top level AS description used to create the object
+ virtual const TopLevelASDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
+#endif
+
+ /// AZ TODO
+ VIRTUAL TLASInstanceDesc METHOD(GetInstanceDesc)(THIS_
+ const char* Name) CONST PURE;
+
+ /// AZ TODO
+ VIRTUAL ScratchBufferSizes METHOD(GetScratchBufferSizes)(THIS) CONST PURE;
+};
+DILIGENT_END_INTERFACE
+
+#include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
+
+#if DILIGENT_C_INTERFACE
+
+// clang-format off
+
+# define ITopLevelAS_GetInstanceDesc(This, ...) CALL_IFACE_METHOD(TopLevelAS, GetInstanceDesc, This, __VA_ARGS__)
+
+// clang-format on
+
+#endif
+
+DILIGENT_END_NAMESPACE // namespace Diligent
diff --git a/Graphics/GraphicsEngine/src/BufferBase.cpp b/Graphics/GraphicsEngine/src/BufferBase.cpp
index 4aff91a0..c42fd698 100644
--- a/Graphics/GraphicsEngine/src/BufferBase.cpp
+++ b/Graphics/GraphicsEngine/src/BufferBase.cpp
@@ -45,6 +45,8 @@ namespace Diligent
void ValidateBufferDesc(const BufferDesc& Desc, const DeviceCaps& deviceCaps)
{
+ static_assert(BIND_FLAGS_LAST == 0x400L, "AZ TODO");
+
constexpr Uint32 AllowedBindFlags =
BIND_VERTEX_BUFFER |
BIND_INDEX_BUFFER |
@@ -52,7 +54,8 @@ void ValidateBufferDesc(const BufferDesc& Desc, const DeviceCaps& deviceCaps)
BIND_SHADER_RESOURCE |
BIND_STREAM_OUTPUT |
BIND_UNORDERED_ACCESS |
- BIND_INDIRECT_DRAW_ARGS;
+ BIND_INDIRECT_DRAW_ARGS |
+ BIND_RAY_TRACING;
VERIFY_BUFFER((Desc.BindFlags & ~AllowedBindFlags) == 0, "the following bind flags are not allowed for a buffer: ", GetBindFlagsString(Desc.BindFlags & ~AllowedBindFlags, ", "), '.');