Diligent Engine  v.2.4.g
ShaderResourceVariableBase.hpp
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 <vector>
34 
35 #include "Atomics.hpp"
36 #include "ShaderResourceVariable.h"
37 #include "PipelineState.h"
38 #include "StringTools.hpp"
39 #include "GraphicsAccessories.hpp"
40 
41 namespace Diligent
42 {
43 
44 template <typename TNameCompare>
46  SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType,
47  const ShaderResourceVariableDesc* Variables,
48  Uint32 NumVars,
49  TNameCompare NameCompare)
50 {
51  for (Uint32 v = 0; v < NumVars; ++v)
52  {
53  const auto& CurrVarDesc = Variables[v];
54  if (((CurrVarDesc.ShaderStages & ShaderStage) != 0) && NameCompare(CurrVarDesc.Name))
55  {
56  return CurrVarDesc.Type;
57  }
58  }
59  return DefaultVariableType;
60 }
61 
63  const Char* Name,
64  SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType,
65  const ShaderResourceVariableDesc* Variables,
66  Uint32 NumVars)
67 {
68  return GetShaderVariableType(ShaderStage, DefaultVariableType, Variables, NumVars,
69  [&](const char* VarName) //
70  {
71  return strcmp(VarName, Name) == 0;
72  });
73 }
74 
76  const Char* Name,
77  const PipelineResourceLayoutDesc& LayoutDesc)
78 {
79  return GetShaderVariableType(ShaderStage, Name, LayoutDesc.DefaultVariableType, LayoutDesc.Variables, LayoutDesc.NumVariables);
80 }
81 
83  const String& Name,
84  SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType,
85  const ShaderResourceVariableDesc* Variables,
86  Uint32 NumVars)
87 {
88  return GetShaderVariableType(ShaderStage, DefaultVariableType, Variables, NumVars,
89  [&](const char* VarName) //
90  {
91  return Name.compare(VarName) == 0;
92  });
93 }
94 
96  const String& Name,
97  const PipelineResourceLayoutDesc& LayoutDesc)
98 {
99  return GetShaderVariableType(ShaderStage, Name, LayoutDesc.DefaultVariableType, LayoutDesc.Variables, LayoutDesc.NumVariables);
100 }
101 
102 inline bool IsAllowedType(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 AllowedTypeBits) noexcept
103 {
104  return ((1 << VarType) & AllowedTypeBits) != 0;
105 }
106 
108 {
109  return 1 << static_cast<Uint32>(VarType);
110 }
111 
112 inline Uint32 GetAllowedTypeBits(const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes) noexcept
113 {
114  if (AllowedVarTypes == nullptr)
115  return 0xFFFFFFFF;
116 
117  Uint32 AllowedTypeBits = 0;
118  for (Uint32 i = 0; i < NumAllowedTypes; ++i)
119  AllowedTypeBits |= GetAllowedTypeBit(AllowedVarTypes[i]);
120  return AllowedTypeBits;
121 }
122 
123 template <typename BufferImplType>
125  Uint32 ArrayIndex,
126  const IDeviceObject* pBuffer,
127  const BufferImplType* pBufferImpl,
128  const IDeviceObject* pCachedBuffer,
129  const char* SignatureName)
130 {
131  if (pBuffer != nullptr && pBufferImpl == nullptr)
132  {
133  std::stringstream ss;
134  ss << "Failed to bind resource '" << pBuffer->GetDesc().Name << "' to variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
135  if (SignatureName != nullptr)
136  {
137  ss << " defined by signature '" << SignatureName << '\'';
138  }
139  ss << ". Invalid resource type: buffer is expected.";
140  LOG_ERROR_MESSAGE(ss.str());
141  return false;
142  }
143 
144  bool BindingOK = true;
145  if (pBufferImpl != nullptr)
146  {
147  const auto& BuffDesc = pBufferImpl->GetDesc();
148  if ((BuffDesc.BindFlags & BIND_UNIFORM_BUFFER) == 0)
149  {
150  std::stringstream ss;
151  ss << "Error binding buffer '" << BuffDesc.Name << "' to variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
152  if (SignatureName != nullptr)
153  {
154  ss << " defined by signature '" << SignatureName << '\'';
155  }
156  ss << ". The buffer was not created with BIND_UNIFORM_BUFFER flag.";
157  LOG_ERROR_MESSAGE(ss.str());
158  BindingOK = false;
159  }
160 
161  if (BuffDesc.Usage == USAGE_DYNAMIC && (ResDesc.Flags & PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS) != 0)
162  {
163  std::stringstream ss;
164  ss << "Error binding USAGE_DYNAMIC buffer '" << BuffDesc.Name << "' to variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
165  if (SignatureName != nullptr)
166  {
167  ss << " defined by signature '" << SignatureName << '\'';
168  }
169  ss << ". The variable was initialized with PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS flag.";
170  LOG_ERROR_MESSAGE(ss.str());
171  BindingOK = false;
172  }
173  }
174 
175  if (ResDesc.VarType != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && pCachedBuffer != nullptr && pCachedBuffer != pBufferImpl)
176  {
177  auto VarTypeStr = GetShaderVariableTypeLiteralName(ResDesc.VarType);
178 
179  std::stringstream ss;
180  ss << "Non-null constant (uniform) buffer '" << pCachedBuffer->GetDesc().Name << "' is already bound to " << VarTypeStr
181  << " shader variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
182  if (SignatureName != nullptr)
183  {
184  ss << " defined by signature '" << SignatureName << '\'';
185  }
186  ss << ". Attempting to bind ";
187  if (pBufferImpl)
188  {
189  ss << "another resource ('" << pBufferImpl->GetDesc().Name << "')";
190  }
191  else
192  {
193  ss << "null";
194  }
195  ss << " is an error and may cause unpredicted behavior.";
196 
198  ss << " Use another shader resource binding instance or label the variable as dynamic.";
199 
200  LOG_ERROR_MESSAGE(ss.str());
201 
202  BindingOK = false;
203  }
204 
205  return BindingOK;
206 }
207 
208 template <typename TViewTypeEnum>
209 const char* GetResourceTypeName();
210 
211 template <>
213 {
214  return "texture view";
215 }
216 
217 template <>
219 {
220  return "buffer view";
221 }
222 
224 {
225  VERIFY_EXPR(pTexView != nullptr);
226  return pTexView->GetDesc().TextureDim;
227 }
228 
230 {
231  return RESOURCE_DIM_BUFFER;
232 }
233 
235 {
236  VERIFY_EXPR(pTexView != nullptr);
237  return const_cast<ITextureView*>(pTexView)->GetTexture()->GetDesc().SampleCount;
238 }
239 
240 inline Uint32 GetResourceSampleCount(const IBufferView* /*pBuffView*/)
241 {
242  return 0;
243 }
244 
245 
246 
247 template <typename TextureViewImplType>
248 bool ValidateResourceViewDimension(const char* ResName,
249  Uint32 ArraySize,
250  Uint32 ArrayInd,
251  const TextureViewImplType* pViewImpl,
252  RESOURCE_DIMENSION ExpectedResourceDim,
253  bool IsMultisample)
254 {
255  bool BindingsOK = true;
256 
257  if (ExpectedResourceDim != RESOURCE_DIM_UNDEFINED)
258  {
259  const auto ResourceDim = GetResourceViewDimension(pViewImpl);
260  if (ResourceDim != ExpectedResourceDim)
261  {
262  LOG_ERROR_MESSAGE("The dimension of resource view '", pViewImpl->GetDesc().Name,
263  "' bound to variable '", GetShaderResourcePrintName(ResName, ArraySize, ArrayInd), "' is ", GetResourceDimString(ResourceDim),
264  ", but resource dimension expected by the shader is ", GetResourceDimString(ExpectedResourceDim), ".");
265  }
266 
267  if (ResourceDim == RESOURCE_DIM_TEX_2D || ResourceDim == RESOURCE_DIM_TEX_2D_ARRAY)
268  {
269  auto SampleCount = GetResourceSampleCount(pViewImpl);
270  if (IsMultisample && SampleCount == 1)
271  {
272  LOG_ERROR_MESSAGE("Texture view '", pViewImpl->GetDesc().Name, "' bound to variable '",
273  GetShaderResourcePrintName(ResName, ArraySize, ArrayInd), "' is invalid: multisample texture is expected.");
274  BindingsOK = false;
275  }
276  else if (!IsMultisample && SampleCount > 1)
277  {
278  LOG_ERROR_MESSAGE("Texture view '", pViewImpl->GetDesc().Name, "' bound to variable '",
279  GetShaderResourcePrintName(ResName, ArraySize, ArrayInd), "' is invalid: single-sample texture is expected.");
280  BindingsOK = false;
281  }
282  }
283  }
284 
285  return BindingsOK;
286 }
287 
288 
289 template <typename ResourceViewImplType,
290  typename ViewTypeEnumType>
292  Uint32 ArrayIndex,
293  const IDeviceObject* pView,
294  const ResourceViewImplType* pViewImpl,
295  std::initializer_list<ViewTypeEnumType> ExpectedViewTypes,
296  RESOURCE_DIMENSION ExpectedResourceDimension,
297  bool IsMultisample,
298  const IDeviceObject* pCachedView,
299  const char* SignatureName)
300 {
301  const char* ExpectedResourceType = GetResourceTypeName<ViewTypeEnumType>();
302 
303  if (pView != nullptr && pViewImpl == nullptr)
304  {
305  std::stringstream ss;
306  ss << "Failed to bind resource '" << pView->GetDesc().Name << "' to variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
307  if (SignatureName != nullptr)
308  {
309  ss << " defined by signature '" << SignatureName << '\'';
310  }
311  ss << ". Invalid resource type: " << ExpectedResourceType << " is expected.";
312  LOG_ERROR_MESSAGE(ss.str());
313  return false;
314  }
315 
316  bool BindingOK = true;
317  if (pViewImpl)
318  {
319  auto ViewType = pViewImpl->GetDesc().ViewType;
320  bool IsExpectedViewType = false;
321  for (auto ExpectedViewType : ExpectedViewTypes)
322  {
323  if (ExpectedViewType == ViewType)
324  IsExpectedViewType = true;
325  }
326 
327  if (!IsExpectedViewType)
328  {
329  std::stringstream ss;
330  ss << "Error binding " << ExpectedResourceType << " '" << pViewImpl->GetDesc().Name << "' to variable '"
331  << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
332  if (SignatureName != nullptr)
333  {
334  ss << " defined by signature '" << SignatureName << '\'';
335  }
336  ss << ". Incorrect view type: ";
337  bool IsFirstViewType = true;
338  for (auto ExpectedViewType : ExpectedViewTypes)
339  {
340  if (!IsFirstViewType)
341  {
342  ss << " or ";
343  }
344  ss << GetViewTypeLiteralName(ExpectedViewType);
345  IsFirstViewType = false;
346  }
347  ss << " is expected, " << GetViewTypeLiteralName(ViewType) << " is provided.";
348  LOG_ERROR_MESSAGE(ss.str());
349 
350  BindingOK = false;
351  }
352 
353  if (!ValidateResourceViewDimension(ResDesc.Name, ResDesc.ArraySize, ArrayIndex, pViewImpl, ExpectedResourceDimension, IsMultisample))
354  {
355  BindingOK = false;
356  }
357  }
358 
359  if (ResDesc.VarType != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && pCachedView != nullptr && pCachedView != pViewImpl)
360  {
361  const auto* VarTypeStr = GetShaderVariableTypeLiteralName(ResDesc.VarType);
362 
363  std::stringstream ss;
364  ss << "Non-null resource '" << pCachedView->GetDesc().Name << "' is already bound to " << VarTypeStr
365  << " shader variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
366  if (SignatureName != nullptr)
367  {
368  ss << " defined by signature '" << SignatureName << '\'';
369  }
370  ss << ". Attempting to bind ";
371  if (pViewImpl)
372  {
373  ss << "another resource ('" << pViewImpl->GetDesc().Name << "')";
374  }
375  else
376  {
377  ss << "null";
378  }
379  ss << " is an error and may cause unpredicted behavior.";
380 
382  ss << " Use another shader resource binding instance or label the variable as dynamic.";
383 
384  LOG_ERROR_MESSAGE(ss.str());
385 
386  BindingOK = false;
387  }
388 
389  return BindingOK;
390 }
391 
392 template <typename BufferViewImplType>
394  Uint32 ArrayIndex,
395  const BufferViewImplType* pBufferView)
396 {
397  bool BindingOK = true;
398  if (pBufferView != nullptr)
399  {
400  const auto& BuffDesc = pBufferView->GetBuffer()->GetDesc();
402  {
403  if (BuffDesc.Mode != BUFFER_MODE_FORMATTED)
404  {
405  LOG_ERROR_MESSAGE("Error binding buffer view '", pBufferView->GetDesc().Name, "' of buffer '", BuffDesc.Name, "' to shader variable '",
406  GetShaderResourcePrintName(ResDesc, ArrayIndex), "': formatted buffer view is expected.");
407  BindingOK = false;
408  }
409  }
410  else
411  {
412  if (BuffDesc.Mode != BUFFER_MODE_STRUCTURED && BuffDesc.Mode != BUFFER_MODE_RAW)
413  {
414  LOG_ERROR_MESSAGE("Error binding buffer view '", pBufferView->GetDesc().Name, "' of buffer '", BuffDesc.Name, "' to shader variable '",
415  GetShaderResourcePrintName(ResDesc, ArrayIndex), "': structured or raw buffer view is expected.");
416  BindingOK = false;
417  }
418  }
419  }
420 
421  return BindingOK;
422 }
423 
424 
425 template <typename TLASImplType>
427  Uint32 ArrayIndex,
428  const IDeviceObject* pTLAS,
429  const TLASImplType* pTLASImpl,
430  const IDeviceObject* pCachedAS,
431  const char* SignatureName)
432 {
433  if (pTLAS != nullptr && pTLASImpl == nullptr)
434  {
435  std::stringstream ss;
436  ss << "Failed to bind resource '" << pCachedAS->GetDesc().Name << "' to variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
437  if (SignatureName != nullptr)
438  {
439  ss << " defined by signature '" << SignatureName << '\'';
440  }
441  ss << ". Invalid resource type: TLAS is expected.";
442  LOG_ERROR_MESSAGE(ss.str());
443  return false;
444  }
445 
446  bool BindingOK = true;
447 
448  if (ResDesc.VarType != SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC && pCachedAS != nullptr && pCachedAS != pTLAS)
449  {
450  const auto* VarTypeStr = GetShaderVariableTypeLiteralName(ResDesc.VarType);
451 
452  std::stringstream ss;
453  ss << "Non-null resource '" << pCachedAS->GetDesc().Name << "' is already bound to " << VarTypeStr
454  << " shader variable '" << GetShaderResourcePrintName(ResDesc, ArrayIndex) << '\'';
455  if (SignatureName != nullptr)
456  {
457  ss << " defined by signature '" << SignatureName << '\'';
458  }
459  ss << ". Attempting to bind ";
460  if (pTLAS)
461  {
462  ss << "another resource ('" << pTLAS->GetDesc().Name << "')";
463  }
464  else
465  {
466  ss << "null";
467  }
468  ss << " is an error and may cause unpredicted behavior.";
469 
471  ss << " Use another shader resource binding instance or label the variable as dynamic.";
472 
473  LOG_ERROR_MESSAGE(ss.str());
474 
475  BindingOK = false;
476  }
477 
478  return BindingOK;
479 }
480 
481 inline void VerifyAndCorrectSetArrayArguments(const char* Name, Uint32 ArraySize, Uint32& FirstElement, Uint32& NumElements)
482 {
483  if (FirstElement >= ArraySize)
484  {
485  LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name, "' variable: FirstElement (", FirstElement, ") is out of allowed range 0 .. ", ArraySize - 1);
486  FirstElement = ArraySize - 1;
487  NumElements = 0;
488  }
489 
490  if (FirstElement + NumElements > ArraySize)
491  {
492  LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name, "' variable: specified element range (", FirstElement, " .. ",
493  FirstElement + NumElements - 1, ") is out of array bounds 0 .. ", ArraySize - 1);
494  NumElements = ArraySize - FirstElement;
495  }
496 }
497 
498 template <typename ShaderVectorType>
499 std::string GetShaderGroupName(const ShaderVectorType& Shaders)
500 {
501  std::string Name;
502  if (Shaders.size() == 1)
503  {
504  Name = Shaders[0]->GetDesc().Name;
505  }
506  else
507  {
508  Name = "{";
509  for (size_t s = 0; s < Shaders.size(); ++s)
510  {
511  if (s > 0)
512  Name += ", ";
513  Name += Shaders[s]->GetDesc().Name;
514  }
515  Name += "}";
516  }
517  return Name;
518 }
519 
521 template <typename ThisImplType,
522  typename VarManagerType,
523  typename ResourceVariableBaseInterface = IShaderResourceVariable>
524 struct ShaderVariableBase : public ResourceVariableBaseInterface
525 {
526  ShaderVariableBase(VarManagerType& ParentManager, Uint32 ResIndex) :
527  m_ParentManager{ParentManager},
528  m_ResIndex{ResIndex}
529  {
530  }
531 
532  virtual void DILIGENT_CALL_TYPE QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override
533  {
534  if (ppInterface == nullptr)
535  return;
536 
537  *ppInterface = nullptr;
538  if (IID == IID_ShaderResourceVariable || IID == IID_Unknown)
539  {
540  *ppInterface = this;
541  (*ppInterface)->AddRef();
542  }
543  }
544 
545  virtual Atomics::Long DILIGENT_CALL_TYPE AddRef() override final
546  {
547  return m_ParentManager.GetOwner().AddRef();
548  }
549 
550  virtual Atomics::Long DILIGENT_CALL_TYPE Release() override final
551  {
552  return m_ParentManager.GetOwner().Release();
553  }
554 
556  {
557  return m_ParentManager.GetOwner().GetReferenceCounters();
558  }
559 
560  virtual void DILIGENT_CALL_TYPE Set(IDeviceObject* pObject) override final
561  {
562  static_cast<ThisImplType*>(this)->BindResource(pObject, 0);
563  }
564 
565  virtual void DILIGENT_CALL_TYPE SetArray(IDeviceObject* const* ppObjects,
566  Uint32 FirstElement,
567  Uint32 NumElements) override final
568  {
569  const auto& Desc = GetDesc();
570  VerifyAndCorrectSetArrayArguments(Desc.Name, Desc.ArraySize, FirstElement, NumElements);
571  for (Uint32 elem = 0; elem < NumElements; ++elem)
572  static_cast<ThisImplType*>(this)->BindResource(ppObjects[elem], FirstElement + elem);
573  }
574 
576  {
577  return GetDesc().VarType;
578  }
579 
580  virtual void DILIGENT_CALL_TYPE GetResourceDesc(ShaderResourceDesc& ResourceDesc) const override final
581  {
582  const auto& Desc = GetDesc();
583  ResourceDesc.Name = Desc.Name;
584  ResourceDesc.Type = Desc.ResourceType;
585  ResourceDesc.ArraySize = Desc.ArraySize;
586  }
587 
588  virtual Uint32 DILIGENT_CALL_TYPE GetIndex() const override final
589  {
590  return m_ParentManager.GetVariableIndex(*static_cast<const ThisImplType*>(this));
591  }
592 
593  void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags)
594  {
595  auto* const pThis = static_cast<ThisImplType*>(this);
596 
597  const auto& ResDesc = pThis->GetDesc();
598 
599  if ((Flags & (1u << ResDesc.VarType)) == 0)
600  return;
601 
602  for (Uint32 ArrInd = 0; ArrInd < ResDesc.ArraySize; ++ArrInd)
603  {
604  if ((Flags & BIND_SHADER_RESOURCES_KEEP_EXISTING) != 0 && pThis->IsBound(ArrInd))
605  continue;
606 
608  pResourceMapping->GetResource(ResDesc.Name, &pObj, ArrInd);
609  if (pObj)
610  {
611  pThis->BindResource(pObj, ArrInd);
612  }
613  else
614  {
615  if ((Flags & BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED) && !pThis->IsBound(ArrInd))
616  {
617  LOG_ERROR_MESSAGE("Unable to bind resource to shader variable '",
618  GetShaderResourcePrintName(ResDesc, ArrInd),
619  "': resource is not found in the resource mapping. "
620  "Do not use BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED flag to suppress the message if this is not an issue.");
621  }
622  }
623  }
624  }
625 
626  const PipelineResourceDesc& GetDesc() const { return m_ParentManager.GetResourceDesc(m_ResIndex); }
627 
628 protected:
629  // Variable manager that owns this variable
630  VarManagerType& m_ParentManager;
631 
632  // Resource index in pipeline resource signature m_Desc.Resources[]
634 };
635 
636 } // namespace Diligent
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::PipelineResourceLayoutDesc::NumVariables
Uint32 NumVariables
Number of elements in Variables array
Definition: PipelineState.h:111
LOG_ERROR_MESSAGE
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
BasicAtomics::Long
long Long
Definition: BasicAtomics.hpp:34
GraphicsAccessories.hpp
Atomics.hpp
Diligent::ShaderVariableBase
Base implementation of a shader variable.
Definition: ShaderResourceVariableBase.hpp:524
Diligent::Char
char Char
Definition: BasicTypes.h:64
Diligent::RESOURCE_DIM_TEX_2D_ARRAY
@ RESOURCE_DIM_TEX_2D_ARRAY
Two-dimensional texture array.
Definition: GraphicsTypes.h:263
Diligent::GetResourceTypeName
const char * GetResourceTypeName()
Diligent::SHADER_TYPE
SHADER_TYPE
Describes the shader type.
Definition: GraphicsTypes.h:65
Diligent::ShaderVariableBase::AddRef
virtual Atomics::Long AddRef() override final
Definition: ShaderResourceVariableBase.hpp:545
Diligent::PipelineResourceLayoutDesc::Variables
const ShaderResourceVariableDesc * Variables
Array of shader resource variable descriptions
Definition: PipelineState.h:117
Flags
Uint32 Flags
Definition: DXBCUtils.cpp:71
Diligent::RESOURCE_DIM_BUFFER
@ RESOURCE_DIM_BUFFER
Buffer.
Definition: GraphicsTypes.h:259
Diligent::PipelineResourceDesc::ArraySize
Uint32 ArraySize
Resource array size (must be 1 for non-array resources).
Definition: PipelineResourceSignature.h:133
Diligent::IsAllowedType
bool IsAllowedType(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 AllowedTypeBits) noexcept
Definition: ShaderResourceVariableBase.hpp:102
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::GetAllowedTypeBits
Uint32 GetAllowedTypeBits(const SHADER_RESOURCE_VARIABLE_TYPE *AllowedVarTypes, Uint32 NumAllowedTypes) noexcept
Definition: ShaderResourceVariableBase.hpp:112
Diligent::ITextureView::GetDesc
virtual const TextureViewDesc &METHOD() GetDesc() const override=0
Returns the texture view description used to create the object.
Diligent::SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC
@ SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC
Shader variable binding is dynamic. It can be set multiple times for every instance of shader resourc...
Definition: ShaderResourceVariable.h:62
Diligent::ValidateBufferMode
bool ValidateBufferMode(const PipelineResourceDesc &ResDesc, Uint32 ArrayIndex, const BufferViewImplType *pBufferView)
Definition: ShaderResourceVariableBase.hpp:393
Diligent::GetViewTypeLiteralName
const Char * GetViewTypeLiteralName(TEXTURE_VIEW_TYPE TexViewType)
Overloaded function that returns the literal name of a texture view type. see GetTexViewTypeLiteralNa...
Definition: GraphicsAccessories.hpp:244
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::ITextureView
Texture view interface.
Definition: TextureView.h:202
Diligent::ShaderVariableBase::Release
virtual Atomics::Long Release() override final
Definition: ShaderResourceVariableBase.hpp:550
Diligent::USAGE_DYNAMIC
@ USAGE_DYNAMIC
A resource that can be read by the GPU and written at least once per frame by the CPU....
Definition: GraphicsTypes.h:161
Diligent::GetResourceViewDimension
RESOURCE_DIMENSION GetResourceViewDimension(const ITextureView *pTexView)
Definition: ShaderResourceVariableBase.hpp:223
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::ShaderVariableBase::GetType
virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const override final
Definition: ShaderResourceVariableBase.hpp:575
Diligent::GetShaderResourcePrintName
String GetShaderResourcePrintName(const char *Name, Uint32 ArraySize, Uint32 ArrayIndex)
Definition: GraphicsAccessories.hpp:622
Diligent::ShaderVariableBase::GetReferenceCounters
virtual IReferenceCounters * GetReferenceCounters() const override final
Definition: ShaderResourceVariableBase.hpp:555
Diligent::PipelineResourceDesc::VarType
SHADER_RESOURCE_VARIABLE_TYPE VarType
Resource variable type, see Diligent::SHADER_RESOURCE_VARIABLE_TYPE.
Definition: PipelineResourceSignature.h:139
Diligent::GetShaderGroupName
std::string GetShaderGroupName(const ShaderVectorType &Shaders)
Definition: ShaderResourceVariableBase.hpp:499
Diligent::ShaderVariableBase::GetDesc
const PipelineResourceDesc & GetDesc() const
Definition: ShaderResourceVariableBase.hpp:626
Diligent::IObject::AddRef
virtual ReferenceCounterValueType AddRef()=0
Increments the number of strong references by 1.
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::BIND_UNIFORM_BUFFER
@ BIND_UNIFORM_BUFFER
A buffer can be bound as a uniform buffer.
Definition: GraphicsTypes.h:120
Diligent::ShaderVariableBase::GetIndex
virtual Uint32 GetIndex() const override final
Definition: ShaderResourceVariableBase.hpp:588
Diligent::ValidateResourceViewDimension
bool ValidateResourceViewDimension(const char *ResName, Uint32 ArraySize, Uint32 ArrayInd, const TextureViewImplType *pViewImpl, RESOURCE_DIMENSION ExpectedResourceDim, bool IsMultisample)
Definition: ShaderResourceVariableBase.hpp:248
Diligent::IDeviceObject::GetDesc
virtual const DeviceObjectAttribs &METHOD() GetDesc() const
Returns the object description.
Diligent::GetResourceTypeName< BUFFER_VIEW_TYPE >
const char * GetResourceTypeName< BUFFER_VIEW_TYPE >()
Definition: ShaderResourceVariableBase.hpp:218
Diligent::VerifyResourceViewBinding
bool VerifyResourceViewBinding(const PipelineResourceDesc &ResDesc, Uint32 ArrayIndex, const IDeviceObject *pView, const ResourceViewImplType *pViewImpl, std::initializer_list< ViewTypeEnumType > ExpectedViewTypes, RESOURCE_DIMENSION ExpectedResourceDimension, bool IsMultisample, const IDeviceObject *pCachedView, const char *SignatureName)
Definition: ShaderResourceVariableBase.hpp:291
Diligent::ShaderResourceVariableDesc
Describes shader variable.
Definition: PipelineState.h:76
Diligent::BUFFER_MODE_FORMATTED
@ BUFFER_MODE_FORMATTED
Formated buffer. Access to the buffer will use format conversion operations. In this mode,...
Definition: Buffer.h:56
Diligent::RefCntAutoPtr
Template class that implements reference counting.
Definition: RefCntAutoPtr.hpp:73
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::BIND_SHADER_RESOURCES_KEEP_EXISTING
@ BIND_SHADER_RESOURCES_KEEP_EXISTING
If this flag is specified, all existing bindings will be preserved and only unresolved ones will be u...
Definition: ShaderResourceVariable.h:94
Diligent::RESOURCE_DIM_UNDEFINED
@ RESOURCE_DIM_UNDEFINED
Texture type undefined.
Definition: GraphicsTypes.h:258
Diligent::GetResourceTypeName< TEXTURE_VIEW_TYPE >
const char * GetResourceTypeName< TEXTURE_VIEW_TYPE >()
Definition: ShaderResourceVariableBase.hpp:212
Diligent::VerifyAndCorrectSetArrayArguments
void VerifyAndCorrectSetArrayArguments(const char *Name, Uint32 ArraySize, Uint32 &FirstElement, Uint32 &NumElements)
Definition: ShaderResourceVariableBase.hpp:481
Diligent::PipelineResourceDesc
Pipeline resource description.
Definition: PipelineResourceSignature.h:120
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::ShaderVariableBase::GetResourceDesc
virtual void GetResourceDesc(ShaderResourceDesc &ResourceDesc) const override final
Definition: ShaderResourceVariableBase.hpp:580
Diligent::ShaderResourceVariableDesc::Type
SHADER_RESOURCE_VARIABLE_TYPE Type
Shader variable type. See Diligent::SHADER_RESOURCE_VARIABLE_TYPE for a list of allowed types.
Definition: PipelineState.h:87
Diligent::VerifyTLASResourceBinding
bool VerifyTLASResourceBinding(const PipelineResourceDesc &ResDesc, Uint32 ArrayIndex, const IDeviceObject *pTLAS, const TLASImplType *pTLASImpl, const IDeviceObject *pCachedAS, const char *SignatureName)
Definition: ShaderResourceVariableBase.hpp:426
Diligent::TextureViewDesc::TextureDim
RESOURCE_DIMENSION TextureDim
View interpretation of the original texture. For instance, one slice of a 2D texture array can be vie...
Definition: TextureView.h:90
Diligent::VerifyConstantBufferBinding
bool VerifyConstantBufferBinding(const PipelineResourceDesc &ResDesc, Uint32 ArrayIndex, const IDeviceObject *pBuffer, const BufferImplType *pBufferImpl, const IDeviceObject *pCachedBuffer, const char *SignatureName)
Definition: ShaderResourceVariableBase.hpp:124
PipelineState.h
Diligent::GetShaderVariableType
SHADER_RESOURCE_VARIABLE_TYPE GetShaderVariableType(SHADER_TYPE ShaderStage, SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType, const ShaderResourceVariableDesc *Variables, Uint32 NumVars, TNameCompare NameCompare)
Definition: ShaderResourceVariableBase.hpp:45
Diligent::RESOURCE_DIM_TEX_2D
@ RESOURCE_DIM_TEX_2D
Two-dimensional texture.
Definition: GraphicsTypes.h:262
StringTools.hpp
Diligent::ShaderVariableBase::SetArray
virtual void SetArray(IDeviceObject *const *ppObjects, Uint32 FirstElement, Uint32 NumElements) override final
Definition: ShaderResourceVariableBase.hpp:565
Diligent::ShaderVariableBase::BindResources
void BindResources(IResourceMapping *pResourceMapping, Uint32 Flags)
Definition: ShaderResourceVariableBase.hpp:593
Diligent::GetResourceSampleCount
Uint32 GetResourceSampleCount(const ITextureView *pTexView)
Definition: ShaderResourceVariableBase.hpp:234
Diligent::PipelineResourceDesc::Name
const char * Name
Resource name in the shader.
Definition: PipelineResourceSignature.h:123
Diligent::ShaderResourceDesc
Shader resource description.
Definition: Shader.h:390
Diligent::GetShaderVariableTypeLiteralName
const Char * GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarType, bool bGetFullName=false)
Returns the literal name of a shader variable type. For instance, for SHADER_RESOURCE_VARIABLE_TYPE_S...
Definition: GraphicsAccessories.cpp:524
Diligent::BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED
@ BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED
If this flag is specified, all shader bindings are expected to be resolved after the call....
Definition: ShaderResourceVariable.h:102
Diligent::String
std::basic_string< Char > String
String variable.
Definition: BasicTypes.h:66
Diligent::ShaderVariableBase::m_ResIndex
const Uint32 m_ResIndex
Definition: ShaderResourceVariableBase.hpp:633
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
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Diligent::GetAllowedTypeBit
Uint32 GetAllowedTypeBit(SHADER_RESOURCE_VARIABLE_TYPE VarType)
Definition: ShaderResourceVariableBase.hpp:107
Diligent::ShaderVariableBase::Set
virtual void Set(IDeviceObject *pObject) override final
Definition: ShaderResourceVariableBase.hpp:560
Diligent::BUFFER_MODE_STRUCTURED
@ BUFFER_MODE_STRUCTURED
Structured buffer. In this mode, ElementByteStride member of BufferDesc defines the structure stride.
Definition: Buffer.h:60
Diligent::IResourceMapping::GetResource
virtual void METHOD() GetResource(const Char *Name, IDeviceObject **ppResource, Uint32 ArrayIndex=0)
Finds a resource in the mapping.
ShaderResourceVariable.h
Diligent::BUFFER_MODE_RAW
@ BUFFER_MODE_RAW
Raw buffer. In this mode, the buffer is accessed as raw bytes. Formatted views of a raw buffer can al...
Definition: Buffer.h:67
Diligent::RESOURCE_DIMENSION
RESOURCE_DIMENSION
Describes resource dimension.
Definition: GraphicsTypes.h:256
Diligent::IBufferView
Buffer view interface.
Definition: BufferView.h:155
Diligent::PipelineResourceDesc::Flags
PIPELINE_RESOURCE_FLAGS Flags
Special resource flags, see Diligent::PIPELINE_RESOURCE_FLAGS.
Definition: PipelineResourceSignature.h:142
Diligent::ShaderVariableBase::QueryInterface
virtual void QueryInterface(const INTERFACE_ID &IID, IObject **ppInterface) override
Definition: ShaderResourceVariableBase.hpp:532
Diligent::ShaderVariableBase::ShaderVariableBase
ShaderVariableBase(VarManagerType &ParentManager, Uint32 ResIndex)
Definition: ShaderResourceVariableBase.hpp:526
Diligent::GetResourceDimString
const Char * GetResourceDimString(RESOURCE_DIMENSION TexType)
Returns the string containing the texture type.
Definition: GraphicsAccessories.cpp:804
Diligent::PipelineResourceLayoutDesc::DefaultVariableType
SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType
Default shader resource variable type. This type will be used if shader variable description is not f...
Definition: PipelineState.h:108
Diligent::PipelineResourceLayoutDesc
Pipeline layout description.
Definition: PipelineState.h:103
Diligent::DeviceObjectAttribs::Name
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
Diligent::ShaderVariableBase::m_ParentManager
VarManagerType & m_ParentManager
Definition: ShaderResourceVariableBase.hpp:630
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
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