Diligent Engine  v.2.4.g
PipelineResourceSignature.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 
30 // clang-format off
31 
34 
35 #include "../../../Primitives/interface/Object.h"
36 #include "../../../Platforms/interface/PlatformDefinitions.h"
37 #include "GraphicsTypes.h"
38 #include "Shader.h"
39 #include "Sampler.h"
40 #include "ShaderResourceVariable.h"
41 #include "ShaderResourceBinding.h"
42 
44 
45 
46 
52 {
55 
58  const Char* SamplerOrTextureName DEFAULT_INITIALIZER(nullptr);
59 
61  struct SamplerDesc Desc;
62 
63 #if DILIGENT_CPP_INTERFACE
65 
67  const Char* _SamplerOrTextureName,
68  const SamplerDesc& _Desc)noexcept :
69  ShaderStages {_ShaderStages },
70  SamplerOrTextureName{_SamplerOrTextureName},
71  Desc {_Desc }
72  {}
73 #endif
74 };
76 
77 
80 {
83 
96 
100 
110 
113 
115 };
117 
118 
121 {
123  const char* Name DEFAULT_INITIALIZER(nullptr);
124 
131 
134 
137 
140 
143 
144 #if DILIGENT_CPP_INTERFACE
146 
148  const char* _Name,
149  Uint32 _ArraySize,
150  SHADER_RESOURCE_TYPE _ResourceType,
153  Name {_Name },
154  ArraySize {_ArraySize },
155  ResourceType{_ResourceType},
156  ShaderStages{_ShaderStages},
157  VarType {_VarType },
158  Flags {_Flags }
159  {}
160 #endif
161 };
163 
164 
167 
169  const PipelineResourceDesc* Resources DEFAULT_INITIALIZER(nullptr);
170 
172  Uint32 NumResources DEFAULT_INITIALIZER(0);
173 
175  const ImmutableSamplerDesc* ImmutableSamplers DEFAULT_INITIALIZER(nullptr);
176 
178  Uint32 NumImmutableSamplers DEFAULT_INITIALIZER(0);
179 
181 
186  Uint8 BindingIndex DEFAULT_INITIALIZER(0);
187 
194  bool UseCombinedTextureSamplers DEFAULT_INITIALIZER(false);
195 
201  const Char* CombinedSamplerSuffix DEFAULT_INITIALIZER("_sampler");
202 
204 
207  Uint32 SRBAllocationGranularity DEFAULT_INITIALIZER(1);
208 };
210 
211 
212 // {DCE499A5-F812-4C93-B108-D684A0B56118}
213 static const INTERFACE_ID IID_PipelineResourceSignature =
214  {0xdce499a5, 0xf812, 0x4c93, {0xb1, 0x8, 0xd6, 0x84, 0xa0, 0xb5, 0x61, 0x18}};
215 
216 #define DILIGENT_INTERFACE_NAME IPipelineResourceSignature
217 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
218 
219 #define IPipelineResourceSignatureInclusiveMethods \
220  IDeviceObjectInclusiveMethods; \
221  IPipelineResourceSignatureMethods PipelineResourceSignature
222 
223 // clang-format off
224 
227 {
228 #if DILIGENT_CPP_INTERFACE
229  virtual const PipelineResourceSignatureDesc& METHOD(GetDesc)() const override = 0;
231 #endif
232 
234 
240  VIRTUAL void METHOD(CreateShaderResourceBinding)(THIS_
241  IShaderResourceBinding** ppShaderResourceBinding,
242  bool InitStaticResources DEFAULT_VALUE(false)) PURE;
243 
244 
246 
251  VIRTUAL void METHOD(BindStaticResources)(THIS_
252  Uint32 ShaderFlags,
253  IResourceMapping* pResourceMapping,
254  Uint32 Flags) PURE;
255 
256 
259 
277  VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByName)(THIS_
279  const Char* Name) PURE;
280 
281 
283 
304  VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByIndex)(THIS_
306  Uint32 Index) PURE;
307 
308 
310 
315  VIRTUAL Uint32 METHOD(GetStaticVariableCount)(THIS_
317 
319 
331  VIRTUAL void METHOD(InitializeStaticSRBResources)(THIS_
332  struct IShaderResourceBinding* pShaderResourceBinding) CONST PURE;
333 
335 
338  VIRTUAL bool METHOD(IsCompatibleWith)(THIS_
339  const struct IPipelineResourceSignature* pPRS) CONST PURE;
340 };
342 
343 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
344 
345 #if DILIGENT_C_INTERFACE
346 
347 // clang-format off
348 
349 # define IPipelineResourceSignature_GetDesc(This) (const struct PipelineResourceSignatureDesc*)IDeviceObject_GetDesc(This)
350 
351 # define IPipelineResourceSignature_CreateShaderResourceBinding(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, CreateShaderResourceBinding, This, __VA_ARGS__)
352 # define IPipelineResourceSignature_BindStaticResources(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, BindStaticResources, This, __VA_ARGS__)
353 # define IPipelineResourceSignature_GetStaticVariableByName(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, GetStaticVariableByName, This, __VA_ARGS__)
354 # define IPipelineResourceSignature_GetStaticVariableByIndex(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, GetStaticVariableByIndex, This, __VA_ARGS__)
355 # define IPipelineResourceSignature_GetStaticVariableCount(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, GetStaticVariableCount, This, __VA_ARGS__)
356 # define IPipelineResourceSignature_InitializeStaticSRBResources(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, InitializeStaticSRBResources,This, __VA_ARGS__)
357 # define IPipelineResourceSignature_IsCompatibleWith(This, ...) CALL_IFACE_METHOD(PipelineResourceSignature, IsCompatibleWith, This, __VA_ARGS__)
358 
359 // clang-format on
360 
361 #endif
362 
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
Diligent::IShaderResourceVariable
Shader resource variable.
Definition: ShaderResourceVariable.h:117
Diligent::Char
char Char
Definition: BasicTypes.h:64
Diligent::SamplerDesc
Sampler description.
Definition: Sampler.h:58
Diligent::IShaderResourceBinding
Shader resource binding interface.
Definition: ShaderResourceBinding.h:58
Diligent::IPipelineResourceSignature
Pipeline resource signature interface.
Definition: PipelineResourceSignature.h:226
Diligent::PipelineResourceSignatureDesc
Pipeline resource signature description.
Definition: PipelineResourceSignature.h:166
Diligent::SHADER_TYPE
SHADER_TYPE
Describes the shader type.
Definition: GraphicsTypes.h:65
Diligent::SHADER_RESOURCE_TYPE
SHADER_RESOURCE_TYPE
Describes shader resource type.
Definition: Shader.h:356
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
Flags
Uint32 Flags
Definition: DXBCUtils.cpp:71
Shader.h
Diligent::PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER
@ PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER
Indicates that a texture SRV will be combined with a sampler. Applies to SHADER_RESOURCE_TYPE_TEXTURE...
Definition: PipelineResourceSignature.h:99
Diligent::PIPELINE_RESOURCE_FLAG_LAST
@ PIPELINE_RESOURCE_FLAG_LAST
Definition: PipelineResourceSignature.h:114
Diligent::PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER
@ PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER
Indicates that this variable will be used to bind formatted buffers. Applies to SHADER_RESOURCE_TYPE_...
Definition: PipelineResourceSignature.h:109
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:52
Diligent::INTERFACE_ID
Unique interface identifier.
Definition: InterfaceID.h:37
Diligent::PipelineResourceDesc::PipelineResourceDesc
PipelineResourceDesc() noexcept
Definition: PipelineResourceSignature.h:145
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
Diligent::PIPELINE_RESOURCE_FLAG_UNKNOWN
@ PIPELINE_RESOURCE_FLAG_UNKNOWN
Resource has no special properties.
Definition: PipelineResourceSignature.h:82
Diligent::SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE
@ SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE
Shader resource bound to the variable is specific to the shader resource binding instance (see Dilige...
Definition: ShaderResourceVariable.h:58
Diligent::ImmutableSamplerDesc::ImmutableSamplerDesc
ImmutableSamplerDesc(SHADER_TYPE _ShaderStages, const Char *_SamplerOrTextureName, const SamplerDesc &_Desc) noexcept
Definition: PipelineResourceSignature.h:66
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::PipelineResourceDesc
Pipeline resource description.
Definition: PipelineResourceSignature.h:120
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::SHADER_TYPE_UNKNOWN
@ SHADER_TYPE_UNKNOWN
Unknown shader type.
Definition: GraphicsTypes.h:67
Diligent::PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY
@ PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY
Indicates that resource is a run-time sized shader array (e.g. an array without a specific size).
Definition: PipelineResourceSignature.h:112
Diligent::PipelineResourceDesc::PipelineResourceDesc
PipelineResourceDesc(SHADER_TYPE _ShaderStages, const char *_Name, Uint32 _ArraySize, SHADER_RESOURCE_TYPE _ResourceType, SHADER_RESOURCE_VARIABLE_TYPE _VarType, PIPELINE_RESOURCE_FLAGS _Flags=PIPELINE_RESOURCE_FLAG_UNKNOWN) noexcept
Definition: PipelineResourceSignature.h:147
ShaderResourceBinding.h
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
DEFAULT_VALUE
#define DEFAULT_VALUE(x)
Definition: CommonDefinitions.h:99
Diligent::PIPELINE_RESOURCE_FLAGS
PIPELINE_RESOURCE_FLAGS
Flags that define pipeline resource properties.
Definition: PipelineResourceSignature.h:79
DILIGENT_TYPED_ENUM
#define DILIGENT_TYPED_ENUM(EnumName, EnumType)
Definition: CommonDefinitions.h:88
Diligent::Uint8
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
Diligent::PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS
@ PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS
Indicates that dynamic buffers will never be bound to the resource variable. Applies to SHADER_RESOUR...
Definition: PipelineResourceSignature.h:95
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
GraphicsTypes.h
ShaderResourceVariable.h
DEFINE_FLAG_ENUM_OPERATORS
DEFINE_FLAG_ENUM_OPERATORS(FILE_DIALOG_FLAGS)
Sampler.h
Diligent::ImmutableSamplerDesc::ImmutableSamplerDesc
ImmutableSamplerDesc() noexcept
Definition: PipelineResourceSignature.h:64
ShaderType
Uint16 ShaderType
Definition: DXBCUtils.cpp:70
Diligent::SHADER_RESOURCE_TYPE_UNKNOWN
@ SHADER_RESOURCE_TYPE_UNKNOWN
Shader resource type is unknown.
Definition: Shader.h:359
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
THIS_
#define THIS_
Definition: DefineInterfaceHelperMacros.h:82
Diligent::SHADER_RESOURCE_VARIABLE_TYPE
SHADER_RESOURCE_VARIABLE_TYPE
Describes the type of the shader resource variable.
Definition: ShaderResourceVariable.h:48
Diligent::IResourceMapping
Resouce mapping.
Definition: ResourceMapping.h:107
Diligent::ImmutableSamplerDesc
Immutable sampler description.
Definition: PipelineResourceSignature.h:51