Diligent Engine  v.2.4.g
ShaderBindingTable.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include "../../../Primitives/interface/Object.h"
34 #include "../../../Primitives/interface/FlagEnum.h"
35 #include "GraphicsTypes.h"
36 #include "Constants.h"
37 #include "Buffer.h"
38 #include "PipelineState.h"
39 #include "TopLevelAS.h"
40 
42 
43 // {1EE12101-7010-4825-AA8E-AC6BB9858BD6}
44 static const INTERFACE_ID IID_ShaderBindingTable =
45  {0x1ee12101, 0x7010, 0x4825, {0xaa, 0x8e, 0xac, 0x6b, 0xb9, 0x85, 0x8b, 0xd6}};
46 
47 // clang-format off
48 
51 
54 
55 #if DILIGENT_CPP_INTERFACE
56  ShaderBindingTableDesc() noexcept {}
57 #endif
58 };
60 
61 
64 {
67 
70 
74 
79 };
81 
82 
83 #define DILIGENT_INTERFACE_NAME IShaderBindingTable
84 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
85 
86 #define IShaderBindingTableInclusiveMethods \
87  IDeviceObjectInclusiveMethods; \
88  IShaderBindingTableMethods ShaderBindingTable
89 
91 
94 {
95 #if DILIGENT_CPP_INTERFACE
96  virtual const ShaderBindingTableDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
98 #endif
99 
101 
109  VIRTUAL Bool METHOD(Verify)(THIS_
111 
112 
114 
118  VIRTUAL void METHOD(Reset)(THIS_
119  IPipelineState* pPSO) PURE;
120 
121 
124 
128  VIRTUAL void METHOD(ResetHitGroups)(THIS) PURE;
129 
130 
132 
141  VIRTUAL void METHOD(BindRayGenShader)(THIS_
142  const char* pShaderGroupName,
143  const void* pData DEFAULT_INITIALIZER(nullptr),
144  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
145 
146 
148 
160  VIRTUAL void METHOD(BindMissShader)(THIS_
161  const char* pShaderGroupName,
162  Uint32 MissIndex,
163  const void* pData DEFAULT_INITIALIZER(nullptr),
164  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
165 
166 
168 
190  VIRTUAL void METHOD(BindHitGroupForGeometry)(THIS_
191  ITopLevelAS* pTLAS,
192  const char* pInstanceName,
193  const char* pGeometryName,
194  Uint32 RayOffsetInHitGroupIndex,
195  const char* pShaderGroupName,
196  const void* pData DEFAULT_INITIALIZER(nullptr),
197  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
198 
199 
201 
215  VIRTUAL void METHOD(BindHitGroupByIndex)(THIS_
216  Uint32 BindingIndex,
217  const char* pShaderGroupName,
218  const void* pData DEFAULT_INITIALIZER(nullptr),
219  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
220 
221 
223 
240  VIRTUAL void METHOD(BindHitGroupForInstance)(THIS_
241  ITopLevelAS* pTLAS,
242  const char* pInstanceName,
243  Uint32 RayOffsetInHitGroupIndex,
244  const char* pShaderGroupName,
245  const void* pData DEFAULT_INITIALIZER(nullptr),
246  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
247 
248 
250 
265  VIRTUAL void METHOD(BindHitGroupForTLAS)(THIS_
266  ITopLevelAS* pTLAS,
267  Uint32 RayOffsetInHitGroupIndex,
268  const char* pShaderGroupName,
269  const void* pData DEFAULT_INITIALIZER(nullptr),
270  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
271 
272 
274 
286  VIRTUAL void METHOD(BindCallableShader)(THIS_
287  const char* pShaderGroupName,
288  Uint32 CallableIndex,
289  const void* pData DEFAULT_INITIALIZER(nullptr),
290  Uint32 DataSize DEFAULT_INITIALIZER(0)) PURE;
291 };
293 
294 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
295 
296 #if DILIGENT_C_INTERFACE
297 
298 // clang-format off
299 
300 # define IShaderBindingTable_Verify(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, Verify, This, __VA_ARGS__)
301 # define IShaderBindingTable_Reset(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, Reset, This, __VA_ARGS__)
302 # define IShaderBindingTable_ResetHitGroups(This) CALL_IFACE_METHOD(ShaderBindingTable, ResetHitGroups, This)
303 # define IShaderBindingTable_BindRayGenShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindRayGenShader, This, __VA_ARGS__)
304 # define IShaderBindingTable_BindMissShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindMissShader, This, __VA_ARGS__)
305 # define IShaderBindingTable_BindHitGroupByIndex(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroupByIndex, This, __VA_ARGS__)
306 # define IShaderBindingTable_BindHitGroupForGeometry(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroupForGeometry, This, __VA_ARGS__)
307 # define IShaderBindingTable_BindHitGroupForInstance(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroupForInstance, This, __VA_ARGS__)
308 # define IShaderBindingTable_BindHitGroupForTLAS(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindHitGroupForTLAS, This, __VA_ARGS__)
309 # define IShaderBindingTable_BindCallableShader(This, ...) CALL_IFACE_METHOD(ShaderBindingTable, BindCallableShader, This, __VA_ARGS__)
310 
311 // clang-format on
312 
313 #endif
314 
315 DILIGENT_END_NAMESPACE // namespace Diligent
TopLevelAS.h
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
Diligent::IShaderBindingTable
Shader binding table interface.
Definition: ShaderBindingTable.h:93
Diligent::IPipelineState
Pipeline state interface.
Definition: PipelineState.h:505
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
Flags
Uint32 Flags
Definition: DXBCUtils.cpp:71
Diligent::ITopLevelAS
Top-level AS interface.
Definition: TopLevelAS.h:151
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:52
THIS
#define THIS
Definition: DefineInterfaceHelperMacros.h:81
Constants.h
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
Diligent::ShaderBindingTableDesc
Shader binding table description.
Definition: ShaderBindingTable.h:50
Diligent::DeviceObjectAttribs
Describes common device object attributes.
Definition: GraphicsTypes.h:1196
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
CONST
#define CONST
Definition: DefineInterfaceHelperMacros.h:84
DILIGENT_DERIVE
#define DILIGENT_DERIVE(TypeName)
Definition: CommonDefinitions.h:90
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Buffer.h
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::Bool
bool Bool
Boolean.
Definition: BasicTypes.h:59
PipelineState.h
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
Diligent::ShaderBindingTableDesc::ShaderBindingTableDesc
ShaderBindingTableDesc() noexcept
Definition: ShaderBindingTable.h:56
DILIGENT_TYPED_ENUM
#define DILIGENT_TYPED_ENUM(EnumName, EnumType)
Definition: CommonDefinitions.h:88
Diligent::VERIFY_SBT_FLAG_SHADER_ONLY
@ VERIFY_SBT_FLAG_SHADER_ONLY
Check that all shaders are bound or inactive.
Definition: ShaderBindingTable.h:66
Diligent::VERIFY_SBT_FLAG_TLAS
@ VERIFY_SBT_FLAG_TLAS
Check that all TLASes that were used in the SBT are alive and shader binding indices have not changed...
Definition: ShaderBindingTable.h:73
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
GraphicsTypes.h
Diligent::VERIFY_SBT_FLAGS
VERIFY_SBT_FLAGS
Defines shader binding table validation flags, see IShaderBindingTable::Verify().
Definition: ShaderBindingTable.h:63
DEFINE_FLAG_ENUM_OPERATORS
DEFINE_FLAG_ENUM_OPERATORS(FILE_DIALOG_FLAGS)
Diligent::VERIFY_SBT_FLAG_SHADER_RECORD
@ VERIFY_SBT_FLAG_SHADER_RECORD
Check that shader record data are initialized.
Definition: ShaderBindingTable.h:69
Diligent::VERIFY_SBT_FLAG_ALL
@ VERIFY_SBT_FLAG_ALL
Enable all validations.
Definition: ShaderBindingTable.h:76
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
THIS_
#define THIS_
Definition: DefineInterfaceHelperMacros.h:82