Go to the documentation of this file.
34 #include <unordered_map>
35 #include <unordered_set>
71 const char* ShaderName,
72 const char* SignatureName) noexcept(
false);
76 void CopyRTShaderGroupNames(std::unordered_map<HashMapStringKey, Uint32, HashMapStringKey::Hasher>& NameToGroupIndex,
78 FixedLinearAllocator& MemPool) noexcept;
83 static constexpr
Uint32 InvalidPipelineResourceLayoutVariableIndex = ~0u;
93 const char* CombinedSamplerSuffix);
98 template <
typename EngineImplTraits>
103 using BaseInterface =
typename EngineImplTraits::PipelineStateInterface;
106 using RenderDeviceImplType =
typename EngineImplTraits::RenderDeviceImplType;
109 using PipelineStateImplType =
typename EngineImplTraits::PipelineStateImplType;
112 using PipelineResourceSignatureImplType =
typename EngineImplTraits::PipelineResourceSignatureImplType;
122 RenderDeviceImplType* pDevice,
124 bool bIsDeviceInternal =
false) :
128 Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask();
130 "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask,
131 ") correspond to one of ", pDevice->GetCommandQueueCount(),
" available device command queues.");
144 RenderDeviceImplType* pDevice,
146 bool bIsDeviceInternal =
false) :
168 RenderDeviceImplType* pDevice,
170 bool bIsDeviceInternal =
false) :
192 RenderDeviceImplType* pDevice,
194 bool bIsDeviceInternal =
false) :
200 RayTracingPipelineCI, pDevice->GetDeviceCaps().Features);
229 VERIFY(m_IsDestructed,
"This object must be explicitly destructed with Destruct()");
234 VERIFY(!m_IsDestructed,
"This object has already been destructed");
258 m_IsDestructed =
true;
308 VERIFY(ShaderHandleSize <= DataSize,
"DataSize (", DataSize,
") must be at least as large as the shader handle size (", ShaderHandleSize,
").");
310 if (Name ==
nullptr || Name[0] ==
'\0')
313 std::memset(pData, 0, ShaderHandleSize);
324 UNEXPECTED(
"Can't find shader group '", Name,
"'.");
328 bool InitStaticResources)
override final
330 *ppShaderResourceBinding =
nullptr;
334 LOG_ERROR_MESSAGE(
"IPipelineState::CreateShaderResourceBinding is not allowed for pipelines that use explicit "
335 "resource signatures. Use IPipelineResourceSignature::CreateShaderResourceBinding instead.");
339 return this->
GetResourceSignature(0)->CreateShaderResourceBinding(ppShaderResourceBinding, InitStaticResources);
343 const Char* Name)
override final
347 LOG_ERROR_MESSAGE(
"IPipelineState::CreateShaderResourceBinding is not allowed for pipelines that use explicit "
348 "resource signatures. Use IPipelineResourceSignature::GetStaticVariableByName instead.");
355 " as the stage is inactive in PSO '", this->
m_Desc.
Name,
"'.");
363 Uint32 Index)
override final
367 LOG_ERROR_MESSAGE(
"IPipelineState::GetStaticVariableByIndex is not allowed for pipelines that use explicit "
368 "resource signatures. Use IPipelineResourceSignature::GetStaticVariableByIndex instead.");
375 " as the stage is inactive in PSO '", this->
m_Desc.
Name,
"'.");
386 LOG_ERROR_MESSAGE(
"IPipelineState::GetStaticVariableCount is not allowed for pipelines that use explicit "
387 "resource signatures. Use IPipelineResourceSignature::GetStaticVariableCount instead.");
394 " as the stage is inactive in PSO '", this->
m_Desc.
Name,
"'.");
405 LOG_ERROR_MESSAGE(
"IPipelineState::BindStaticResources is not allowed for pipelines that use explicit "
406 "resource signatures. Use IPipelineResourceSignature::BindStaticResources instead.");
417 LOG_ERROR_MESSAGE(
"IPipelineState::InitializeStaticSRBResources is not allowed for pipelines that use explicit "
418 "resource signatures. Use IPipelineResourceSignature::InitializeStaticSRBResources instead.");
446 const auto& lhs = *
static_cast<const PipelineStateImplType*
>(
this);
447 const auto& rhs = *ValidatedCast<const PipelineStateImplType>(pPSO);
449 const auto SignCount = lhs.GetResourceSignatureCount();
450 if (SignCount != rhs.GetResourceSignatureCount())
453 for (
Uint32 s = 0; s < SignCount; ++s)
456 const auto* pRhsSign = rhs.GetResourceSignature(s);
457 if (!PipelineResourceSignatureImplType::SignaturesCompatible(pLhsSign, pRhsSign))
475 MemPool.AddSpace<GraphicsPipelineData>();
477 ReserveResourceSignatures(CreateInfo, MemPool);
479 const auto& InputLayout = CreateInfo.GraphicsPipeline.InputLayout;
480 Uint32 BufferSlotsUsed = 0;
482 for (
Uint32 i = 0; i < InputLayout.NumElements; ++i)
484 auto& LayoutElem = InputLayout.LayoutElements[i];
485 MemPool.AddSpaceForString(LayoutElem.HLSLSemantic);
486 BufferSlotsUsed =
std::max(BufferSlotsUsed, LayoutElem.BufferSlot + 1);
489 MemPool.AddSpace<
Uint32>(BufferSlotsUsed);
491 static_assert(std::is_trivially_destructible<decltype(*InputLayout.LayoutElements)>::value,
"Add destructor for this object to Destruct()");
498 ReserveResourceSignatures(CreateInfo, MemPool);
504 size_t RTDataSize =
sizeof(RayTracingPipelineData);
506 const auto ShaderHandleSize = this->
m_pDevice->GetProperties().ShaderGroupHandleSize;
507 RTDataSize += ShaderHandleSize * (CreateInfo.GeneralShaderCount + CreateInfo.TriangleHitShaderCount + CreateInfo.ProceduralHitShaderCount);
510 MemPool.AddSpace(RTDataSize,
alignof(RayTracingPipelineData));
512 for (
Uint32 i = 0; i < CreateInfo.GeneralShaderCount; ++i)
514 MemPool.AddSpaceForString(CreateInfo.pGeneralShaders[i].Name);
516 for (
Uint32 i = 0; i < CreateInfo.TriangleHitShaderCount; ++i)
518 MemPool.AddSpaceForString(CreateInfo.pTriangleHitShaders[i].Name);
520 for (
Uint32 i = 0; i < CreateInfo.ProceduralHitShaderCount; ++i)
522 MemPool.AddSpaceForString(CreateInfo.pProceduralHitShaders[i].Name);
526 ReserveResourceSignatures(CreateInfo, MemPool);
530 template <
typename ShaderImplType,
typename TShaderStages>
532 TShaderStages& ShaderStages)
536 ShaderStages.clear();
537 auto AddShaderStage = [&](
IShader* pShader) {
538 if (pShader !=
nullptr)
540 ShaderStages.emplace_back(ValidatedCast<ShaderImplType>(pShader));
541 const auto ShaderType = pShader->GetDesc().ShaderType;
545 #ifdef DILIGENT_DEBUG
546 for (
Uint32 i = 0; i + 1 < ShaderStages.size(); ++i)
556 AddShaderStage(CreateInfo.
pVS);
557 AddShaderStage(CreateInfo.
pHS);
558 AddShaderStage(CreateInfo.
pDS);
559 AddShaderStage(CreateInfo.
pGS);
560 AddShaderStage(CreateInfo.
pPS);
561 VERIFY(CreateInfo.
pVS !=
nullptr,
"Vertex shader must not be null");
567 AddShaderStage(CreateInfo.
pAS);
568 AddShaderStage(CreateInfo.
pMS);
569 AddShaderStage(CreateInfo.
pPS);
570 VERIFY(CreateInfo.
pMS !=
nullptr,
"Mesh shader must not be null");
581 template <
typename ShaderImplType,
typename TShaderStages>
583 TShaderStages& ShaderStages)
587 ShaderStages.clear();
593 ShaderStages.emplace_back(ValidatedCast<ShaderImplType>(CreateInfo.
pCS));
599 template <
typename ShaderImplType,
typename TShaderStages>
601 TShaderStages& ShaderStages)
605 std::unordered_set<IShader*> UniqueShaders;
607 auto AddShader = [&ShaderStages, &UniqueShaders,
this](
IShader* pShader) {
608 if (pShader !=
nullptr && UniqueShaders.insert(pShader).second)
610 const auto ShaderType = pShader->GetDesc().ShaderType;
612 auto& Stage = ShaderStages[StageInd];
614 Stage.Append(ValidatedCast<ShaderImplType>(pShader));
618 ShaderStages.clear();
619 ShaderStages.resize(MAX_SHADERS_IN_PIPELINE);
638 LOG_ERROR_AND_THROW(
"At least one shader with type SHADER_TYPE_RAY_GEN must be provided.");
641 for (
auto iter = ShaderStages.begin(); iter != ShaderStages.end();)
643 if (iter->Count() == 0)
645 iter = ShaderStages.erase(iter);
672 CopyResourceSignatures(CreateInfo, MemPool);
674 pRenderPass = GraphicsPipeline.pRenderPass;
677 const auto& RPDesc = pRenderPass->GetDesc();
678 VERIFY_EXPR(GraphicsPipeline.SubpassIndex < RPDesc.SubpassCount);
679 const auto& Subpass = RPDesc.pSubpasses[GraphicsPipeline.SubpassIndex];
681 GraphicsPipeline.NumRenderTargets =
static_cast<Uint8>(Subpass.RenderTargetAttachmentCount);
682 for (
Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt)
684 const auto& RTAttachmentRef = Subpass.pRenderTargetAttachments[rt];
687 VERIFY_EXPR(RTAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
688 GraphicsPipeline.RTVFormats[rt] = RPDesc.pAttachments[RTAttachmentRef.AttachmentIndex].Format;
692 if (Subpass.pDepthStencilAttachment !=
nullptr)
694 const auto& DSAttachmentRef = *Subpass.pDepthStencilAttachment;
697 VERIFY_EXPR(DSAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
698 GraphicsPipeline.DSVFormat = RPDesc.pAttachments[DSAttachmentRef.AttachmentIndex].Format;
703 const auto& InputLayout = GraphicsPipeline.InputLayout;
705 for (
size_t Elem = 0; Elem < InputLayout.NumElements; ++Elem)
707 const auto& SrcElem = InputLayout.LayoutElements[Elem];
708 pLayoutElements[Elem] = SrcElem;
712 GraphicsPipeline.InputLayout.LayoutElements = pLayoutElements;
716 std::array<Uint32, MAX_BUFFER_SLOTS> Strides, TightStrides = {};
718 Strides.fill(LAYOUT_ELEMENT_AUTO_STRIDE);
720 for (
Uint32 i = 0; i < InputLayout.NumElements; ++i)
722 auto& LayoutElem = pLayoutElements[i];
727 auto BuffSlot = LayoutElem.BufferSlot;
728 if (BuffSlot >= Strides.size())
730 UNEXPECTED(
"Buffer slot (", BuffSlot,
") exceeds the maximum allowed value (", Strides.size() - 1,
")");
733 BufferSlotsUsed =
std::max(BufferSlotsUsed,
static_cast<Uint8>(BuffSlot + 1));
735 auto& CurrAutoStride = TightStrides[BuffSlot];
737 if (LayoutElem.RelativeOffset == LAYOUT_ELEMENT_AUTO_OFFSET)
739 LayoutElem.RelativeOffset = CurrAutoStride;
743 if (LayoutElem.Stride != LAYOUT_ELEMENT_AUTO_STRIDE)
746 if (Strides[BuffSlot] != LAYOUT_ELEMENT_AUTO_STRIDE && Strides[BuffSlot] != LayoutElem.Stride)
748 LOG_ERROR_MESSAGE(
"Inconsistent strides are specified for buffer slot ", BuffSlot,
749 ". Input element at index ", LayoutElem.InputIndex,
" explicitly specifies stride ",
750 LayoutElem.Stride,
", while current value is ", Strides[BuffSlot],
751 ". Specify consistent strides or use LAYOUT_ELEMENT_AUTO_STRIDE to allow "
752 "the engine compute strides automatically.");
754 Strides[BuffSlot] = LayoutElem.Stride;
757 CurrAutoStride =
std::max(CurrAutoStride, LayoutElem.RelativeOffset + LayoutElem.NumComponents *
GetValueSize(LayoutElem.ValueType));
760 for (
Uint32 i = 0; i < InputLayout.NumElements; ++i)
762 auto& LayoutElem = pLayoutElements[i];
766 if (Strides[BuffSlot] == LAYOUT_ELEMENT_AUTO_STRIDE)
768 Strides[BuffSlot] = TightStrides[BuffSlot];
772 if (Strides[BuffSlot] < TightStrides[BuffSlot])
774 LOG_ERROR_MESSAGE(
"Stride ", Strides[BuffSlot],
" explicitly specified for slot ", BuffSlot,
775 " is smaller than the minimum stride ", TightStrides[BuffSlot],
776 " required to accomodate all input elements.");
779 if (LayoutElem.Stride == LAYOUT_ELEMENT_AUTO_STRIDE)
780 LayoutElem.Stride = Strides[BuffSlot];
786 for (
Uint32 i = 0; i < BufferSlotsUsed; ++i)
788 auto Stride = Strides[i];
789 pStrides[i] = Stride != LAYOUT_ELEMENT_AUTO_STRIDE ? Stride : 0;
799 CopyResourceSignatures(CreateInfo, MemPool);
805 size_t RTDataSize =
sizeof(RayTracingPipelineData);
807 const auto ShaderHandleSize = this->
m_pDevice->GetProperties().ShaderGroupHandleSize;
808 const auto ShaderDataSize = ShaderHandleSize * (CreateInfo.GeneralShaderCount + CreateInfo.TriangleHitShaderCount + CreateInfo.ProceduralHitShaderCount);
809 RTDataSize += ShaderDataSize;
813 this->
m_pRayTracingPipelineData =
static_cast<RayTracingPipelineData*
>(MemPool.Allocate(RTDataSize,
alignof(RayTracingPipelineData)));
819 void* Ptr = MemPool.ReleaseOwnership();
826 CopyResourceSignatures(CreateInfo, MemPool);
837 const PipelineResourceSignatureImplType*
pSignature =
nullptr;
857 explicit operator bool()
const
871 const auto*
const pThis =
static_cast<const PipelineStateImplType*
>(
this);
873 const auto SignCount = pThis->GetResourceSignatureCount();
874 for (
Uint32 sign = 0; sign < SignCount; ++sign)
876 const PipelineResourceSignatureImplType*
const pSignature = pThis->GetResourceSignature(sign);
877 if (pSignature ==
nullptr)
880 const auto ResIndex = pSignature->FindResource(Stage, Name);
882 return ResourceAttribution{pSignature, sign, ResIndex};
885 const auto ImtblSamIndex = pSignature->FindImmutableSampler(Stage, Name);
890 return ResourceAttribution{};
896 if (SrcLayout.Variables !=
nullptr)
899 for (
Uint32 i = 0; i < SrcLayout.NumVariables; ++i)
901 VERIFY(SrcLayout.Variables[i].Name !=
nullptr,
"Variable name can't be null");
902 MemPool.AddSpaceForString(SrcLayout.Variables[i].Name);
906 if (SrcLayout.ImmutableSamplers !=
nullptr)
909 for (
Uint32 i = 0; i < SrcLayout.NumImmutableSamplers; ++i)
911 VERIFY(SrcLayout.ImmutableSamplers[i].SamplerOrTextureName !=
nullptr,
"Immutable sampler or texture name can't be null");
912 MemPool.AddSpaceForString(SrcLayout.ImmutableSamplers[i].SamplerOrTextureName);
916 static_assert(std::is_trivially_destructible<decltype(*SrcLayout.Variables)>::value,
"Add destructor for this object to Destruct()");
917 static_assert(std::is_trivially_destructible<decltype(*SrcLayout.ImmutableSamplers)>::value,
"Add destructor for this object to Destruct()");
922 if (SrcLayout.Variables !=
nullptr)
925 DstLayout.Variables = Variables;
926 for (
Uint32 i = 0; i < SrcLayout.NumVariables; ++i)
928 const auto& SrcVar = SrcLayout.Variables[i];
929 Variables[i] = SrcVar;
930 Variables[i].
Name = MemPool.CopyString(SrcVar.Name);
934 if (SrcLayout.ImmutableSamplers !=
nullptr)
936 auto*
const ImmutableSamplers = MemPool.ConstructArray<
ImmutableSamplerDesc>(SrcLayout.NumImmutableSamplers);
937 DstLayout.ImmutableSamplers = ImmutableSamplers;
938 for (
Uint32 i = 0; i < SrcLayout.NumImmutableSamplers; ++i)
940 const auto& SrcSmplr = SrcLayout.ImmutableSamplers[i];
941 #ifdef DILIGENT_DEVELOPMENT
944 if (!((BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 0) ||
945 (BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 1) ||
946 (BorderColor[0] == 1 && BorderColor[1] == 1 && BorderColor[2] == 1 && BorderColor[3] == 1)))
948 LOG_WARNING_MESSAGE(
"Immutable sampler for variable \"", SrcSmplr.SamplerOrTextureName,
"\" specifies border color (",
949 BorderColor[0],
", ", BorderColor[1],
", ", BorderColor[2],
", ", BorderColor[3],
950 "). D3D12 static samplers only allow transparent black (0,0,0,0), opaque black (0,0,0,1) or opaque white (1,1,1,1) as border colors");
955 ImmutableSamplers[i] = SrcSmplr;
956 ImmutableSamplers[i].SamplerOrTextureName = MemPool.CopyString(SrcSmplr.SamplerOrTextureName);
965 VERIFY_EXPR(CreateInfo.ResourceSignaturesCount == 0 || CreateInfo.ppResourceSignatures ==
nullptr);
970 VERIFY_EXPR(CreateInfo.ResourceSignaturesCount > 0 && CreateInfo.ppResourceSignatures !=
nullptr);
971 Uint32 MaxSignatureBindingIndex = 0;
972 for (
Uint32 i = 0; i < CreateInfo.ResourceSignaturesCount; ++i)
974 const auto* pSignature = ValidatedCast<PipelineResourceSignatureImplType>(CreateInfo.ppResourceSignatures[i]);
975 VERIFY(pSignature !=
nullptr,
"Pipeline resource signature at index ", i,
" is null. This error should've been caught by ValidatePipelineResourceSignatures.");
977 Uint32 Index = pSignature->GetDesc().BindingIndex;
978 VERIFY(Index < MAX_RESOURCE_SIGNATURES,
979 "Pipeline resource signature specifies binding index ",
Uint32{Index},
" that exceeds the limit (", MAX_RESOURCE_SIGNATURES - 1,
980 "). This error should've been caught by ValidatePipelineResourceSignatureDesc.");
982 MaxSignatureBindingIndex =
std::max(MaxSignatureBindingIndex,
Uint32{Index});
984 VERIFY_EXPR(MaxSignatureBindingIndex < MAX_RESOURCE_SIGNATURES);
997 VERIFY_EXPR(CreateInfo.ResourceSignaturesCount != 0 && CreateInfo.ppResourceSignatures !=
nullptr);
998 for (
Uint32 i = 0; i < CreateInfo.ResourceSignaturesCount; ++i)
1000 auto* pSignature = ValidatedCast<PipelineResourceSignatureImplType>(CreateInfo.ppResourceSignatures[i]);
1003 const Uint32 Index = pSignature->GetDesc().BindingIndex;
1005 #ifdef DILIGENT_DEBUG
1009 "Pipeline resource signature '", pSignature->GetDesc().Name,
"' at index ",
Uint32{Index},
1010 " conflicts with another resource signature '",
m_Signatures[Index]->GetDesc().Name,
1011 "' that uses the same index. This error should've been caught by ValidatePipelineResourceSignatures.");
1013 for (
Uint32 s = 0, StageCount = pSignature->GetNumActiveShaderStages(); s < StageCount; ++s)
1015 const auto ShaderType = pSignature->GetActiveShaderStageType(s);
1017 "Pipeline resource signature '", pSignature->GetDesc().Name,
"' at index ",
Uint32{Index},
1073 static_assert(offsetof(RayTracingPipelineData, ShaderHandles) %
sizeof(
void*) == 0,
"ShaderHandles member is expected to be sizeof(void*)-aligned");
1082 #ifdef DILIGENT_DEBUG
1083 bool m_IsDestructed =
false;
void ValidateComputePipelineCreateInfo(const ComputePipelineStateCreateInfo &CreateInfo, const DeviceFeatures &Features) noexcept(false)
Definition: PipelineStateBase.cpp:454
Implementation of a linear allocator on a fixed-size memory page.
Definition: FixedLinearAllocator.hpp:45
PIPELINE_TYPE PipelineType
Pipeline type.
Definition: PipelineState.h:320
RefCntAutoPtr< PipelineResourceSignatureImplType > SignatureAutoPtrType
Resource signatures arranged by their binding indices.
Definition: PipelineStateBase.hpp:1042
Description of a single element of the input layout.
Definition: InputLayout.h:63
bool IsRayTracingPipeline() const
Definition: PipelineState.h:338
Uint32 ProceduralHitShaderCount
The number of procedural shader groups.
Definition: PipelineState.h:466
ResourceAttribution() noexcept
Definition: PipelineStateBase.hpp:843
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
const Char * Name
Shader variable name.
Definition: PipelineState.h:84
@ SHADER_TYPE_RAY_GEN
Ray generation shader.
Definition: GraphicsTypes.h:76
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
RefCntAutoPtr< IRenderPass > & GetRenderPassPtr()
Definition: PipelineStateBase.hpp:282
struct SamplerDesc Desc
Sampler description.
Definition: PipelineResourceSignature.h:61
void ReserveSpaceForPipelineDesc(const GraphicsPipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool) noexcept
Definition: PipelineStateBase.hpp:472
static constexpr Uint32 InvalidResourceIndex
Definition: PipelineStateBase.hpp:834
Shader resource variable.
Definition: ShaderResourceVariable.h:117
Graphics pipeline state creation attributes.
Definition: PipelineState.h:397
char Char
Definition: BasicTypes.h:64
EngineImplTraits::RenderDeviceImplType *const m_pDevice
Pointer to the device.
Definition: DeviceObjectBase.hpp:179
Shader resource binding interface.
Definition: ShaderResourceBinding.h:58
TNameToGroupIndexMap NameToGroupIndex
Definition: PipelineStateBase.hpp:1061
IShader * pMS
Mesh shader to be used with the pipeline.
Definition: PipelineState.h:421
SHADER_TYPE m_ActiveShaderStages
Shader stages that are active in this PSO.
Definition: PipelineStateBase.hpp:1030
Uint32 BufferSlot
Buffer slot index that this element is read from.
Definition: InputLayout.h:76
void ReserveSpaceForPipelineDesc(const ComputePipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool) noexcept
Definition: PipelineStateBase.hpp:494
const char * HLSLSemantic
HLSL semantic. Default value ("ATTRIB") allows HLSL shaders to be converted to GLSL and used in OpenG...
Definition: InputLayout.h:69
struct DeviceFeatures DeviceFeatures
Definition: GraphicsTypes.h:1750
Ray tracing pipeline state description.
Definition: PipelineState.h:443
virtual const ShaderDesc &METHOD() GetDesc() const override=0
Returns the shader description.
#define LOG_ERROR_AND_THROW(...)
Definition: Errors.hpp:101
RayTracingPipelineDesc Desc
Definition: PipelineStateBase.hpp:1057
SHADER_TYPE
Describes the shader type.
Definition: GraphicsTypes.h:65
Uint32 GetBufferStride(Uint32 BufferSlot) const
Definition: PipelineStateBase.hpp:264
SHADER_RESOURCE_TYPE
Describes shader resource type.
Definition: Shader.h:356
Pipeline state interface.
Definition: PipelineState.h:505
Float32 BorderColor[4]
Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV,...
Definition: Sampler.h:100
IShader * pCS
Compute shader to be used with the pipeline.
Definition: PipelineState.h:430
IShader * pClosestHitShader
Closest hit shader. Can be null. The shader type must be SHADER_TYPE_RAY_CLOSEST_HIT.
Definition: PipelineState.h:256
struct GraphicsPipelineStateCreateInfo GraphicsPipelineStateCreateInfo
Definition: PipelineState.h:423
Uint32 Flags
Definition: DXBCUtils.cpp:71
This structure describes the ray tracing pipeline state and is part of the RayTracingPipelineStateCre...
Definition: PipelineState.h:280
void * m_pPipelineDataRawMem
Definition: PipelineStateBase.hpp:1079
Shader interface.
Definition: Shader.h:428
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
struct ComputePipelineStateCreateInfo ComputePipelineStateCreateInfo
Definition: PipelineState.h:439
IShader * pIntersectionShader
Intersection shader. The shader type must be SHADER_TYPE_RAY_INTERSECTION.
Definition: PipelineState.h:252
@ PIPELINE_TYPE_RAY_TRACING
Ray tracing pipeline, which is used by IDeviceContext::TraceRays().
Definition: PipelineState.h:308
virtual IShaderResourceVariable * GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final
Definition: PipelineStateBase.hpp:362
#define UNEXPECTED(...)
Definition: DebugUtilities.hpp:77
void CorrectGraphicsPipelineDesc(GraphicsPipelineDesc &GraphicsPipeline) noexcept
Definition: PipelineStateBase.cpp:642
IPipelineResourceSignature ** ppResourceSignatures
An array of ResourceSignaturesCount shader resource signatures that define the layout of shader resou...
Definition: PipelineState.h:388
NODISCARD void * ReleaseOwnership() noexcept
Definition: FixedLinearAllocator.hpp:95
const RayTracingTriangleHitShaderGroup * pTriangleHitShaders
A pointer to an array of TriangleHitShaderCount RayTracingTriangleHitShaderGroup structures that cont...
Definition: PipelineState.h:456
@ SHADER_TYPE_COMPUTE
Compute shader.
Definition: GraphicsTypes.h:73
PipelineStateDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
void InitializePipelineDesc(const GraphicsPipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool)
Definition: PipelineStateBase.hpp:656
virtual PipelineResourceSignatureImplType * GetResourceSignature(Uint32 Index) const override final
Implementation of IPipelineState::GetResourceSignature().
Definition: PipelineStateBase.hpp:432
NODISCARD T * ConstructArray(size_t count, const Args &... args)
Definition: FixedLinearAllocator.hpp:224
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
struct ShaderResourceVariableDesc ShaderResourceVariableDesc
Definition: PipelineState.h:99
ResourceAttribution GetResourceAttribution(const char *Name, SHADER_TYPE Stage) const
Definition: PipelineStateBase.hpp:869
IShader * pClosestHitShader
Closest hit shader. The shader type must be SHADER_TYPE_RAY_CLOSEST_HIT.
Definition: PipelineState.h:223
PipelineResourceLayoutDesc ResourceLayout
Pipeline layout description.
Definition: PipelineState.h:333
RefCntAutoPtr< IRenderPass > const & GetRenderPassPtr() const
Definition: PipelineStateBase.hpp:276
void InitializePipelineDesc(const RayTracingPipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool) noexcept
Definition: PipelineStateBase.hpp:802
Uint32 GetValueSize(VALUE_TYPE Val)
Returns the size of the specified value type.
Definition: GraphicsAccessories.hpp:149
ResourceAttribution(const PipelineResourceSignatureImplType *_pSignature, Uint32 _SignatureIndex, Uint32 _ResourceIndex, Uint32 _ImmutableSamplerIndex=InvalidResourceIndex) noexcept
Definition: PipelineStateBase.hpp:844
__forceinline SHADER_TYPE GetShaderStageType(const ShaderD3D11Impl *pShader)
Definition: PipelineStateD3D11Impl.cpp:43
virtual void CreateShaderResourceBinding(IShaderResourceBinding **ppShaderResourceBinding, bool InitStaticResources) override final
Definition: PipelineStateBase.hpp:327
SHADER_TYPE ShaderType
Shader type. See Diligent::SHADER_TYPE.
Definition: Shader.h:113
virtual const GraphicsPipelineDesc & GetGraphicsPipelineDesc() const override final
Definition: PipelineStateBase.hpp:288
RayTracingPipelineData * m_pRayTracingPipelineData
Definition: PipelineStateBase.hpp:1078
Graphics pipeline state description.
Definition: PipelineState.h:131
NODISCARD Char * CopyString(const char *Str)
Definition: FixedLinearAllocator.hpp:251
void CopyShaderHandle(const char *Name, void *pData, size_t DataSize) const
Definition: PipelineStateBase.hpp:302
IShader * pHS
Hull shader to be used with the pipeline.
Definition: PipelineState.h:412
Uint32 TriangleHitShaderCount
The number of triangle hit shader groups.
Definition: PipelineState.h:459
virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const override final
Definition: PipelineStateBase.hpp:382
GraphicsPipelineDesc Desc
Definition: PipelineStateBase.hpp:1047
@ VT_FLOAT16
Half-precision 16-bit floating point.
Definition: GraphicsTypes.h:58
virtual void InitializeStaticSRBResources(IShaderResourceBinding *pSRB) const override final
Definition: PipelineStateBase.hpp:413
void ValidateGraphicsPipelineCreateInfo(const GraphicsPipelineStateCreateInfo &CreateInfo, const DeviceFeatures &Features) noexcept(false)
Definition: PipelineStateBase.cpp:373
IMemoryAllocator & GetRawAllocator()
Returns raw memory allocator.
Definition: EngineMemory.cpp:51
PipelineStateBase(IReferenceCounters *pRefCounters, RenderDeviceImplType *pDevice, const ComputePipelineStateCreateInfo &ComputePipelineCI, bool bIsDeviceInternal=false)
Initializes the object as compute pipeline.
Definition: PipelineStateBase.hpp:167
IShader * pAnyHitShader
Any-hit shader. Can be null. The shader type must be SHADER_TYPE_RAY_ANY_HIT.
Definition: PipelineState.h:227
bool IsConsistentShaderType(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineType)
Definition: GraphicsAccessories.cpp:1388
@ PIPELINE_TYPE_MESH
Mesh pipeline, which is used by IDeviceContext::DrawMesh(), IDeviceContext::DrawMeshIndirect().
Definition: PipelineState.h:305
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Pipeline state creation attributes.
Definition: PipelineState.h:370
Describes shader variable.
Definition: PipelineState.h:76
virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping *pResourceMapping, Uint32 Flags) override final
Definition: PipelineStateBase.hpp:401
Int32 GetShaderTypePipelineIndex(SHADER_TYPE ShaderType, PIPELINE_TYPE PipelineType)
Definition: GraphicsAccessories.cpp:1422
Template class that implements reference counting.
Definition: RefCntAutoPtr.hpp:73
Uint32 ShaderHandleSize
Definition: PipelineStateBase.hpp:1063
SignatureAutoPtrType * m_Signatures
Definition: PipelineStateBase.hpp:1043
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
IShader * pAS
Amplification shader to be used with the pipeline.
Definition: PipelineState.h:418
PipelineStateBase(IReferenceCounters *pRefCounters, RenderDeviceImplType *pDevice, const RayTracingPipelineStateCreateInfo &RayTracingPipelineCI, bool bIsDeviceInternal=false)
Initializes the object as ray tracing pipeline.
Definition: PipelineStateBase.hpp:191
const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type
Definition: PipelineStateD3D12Impl.cpp:69
Compute pipeline state description.
Definition: PipelineState.h:427
void ExtractShaders(const GraphicsPipelineStateCreateInfo &CreateInfo, TShaderStages &ShaderStages)
Definition: PipelineStateBase.hpp:531
@ PIPELINE_TYPE_COMPUTE
Compute pipeline, which is used by IDeviceContext::DispatchCompute(), IDeviceContext::DispatchCompute...
Definition: PipelineState.h:302
virtual const RayTracingPipelineDesc & GetRayTracingPipelineDesc() const override final
Definition: PipelineStateBase.hpp:295
IShader * pDS
Domain shader to be used with the pipeline.
Definition: PipelineState.h:409
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Uint8 BufferSlotsUsed
Definition: PipelineStateBase.hpp:1052
GraphicsPipelineData * m_pGraphicsPipelineData
Definition: PipelineStateBase.hpp:1077
@ SHADER_TYPE_UNKNOWN
Unknown shader type.
Definition: GraphicsTypes.h:67
Uint8 m_SignatureCount
The number of signatures in m_Signatures array. Note that this is not necessarily the same as the num...
Definition: PipelineStateBase.hpp:1039
PipelineStateBase(IReferenceCounters *pRefCounters, RenderDeviceImplType *pDevice, const GraphicsPipelineStateCreateInfo &GraphicsPipelineCI, bool bIsDeviceInternal=false)
Initializes the object as graphics pipeline.
Definition: PipelineStateBase.hpp:143
const RayTracingProceduralHitShaderGroup * pProceduralHitShaders
A pointer to an array of ProceduralHitShaderCount RayTracingProceduralHitShaderGroup structures that ...
Definition: PipelineState.h:463
struct PipelineResourceLayoutDesc PipelineResourceLayoutDesc
Definition: PipelineState.h:125
IShader * pPS
Pixel shader to be used with the pipeline.
Definition: PipelineState.h:406
PipelineStateDesc PSODesc
Pipeline state description.
Definition: PipelineState.h:373
~PipelineStateBase()
Definition: PipelineStateBase.hpp:210
void CopyRTShaderGroupNames(std::unordered_map< HashMapStringKey, Uint32, HashMapStringKey::Hasher > &NameToGroupIndex, const RayTracingPipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool) noexcept
Copies ray tracing shader group names and also initializes the mapping from the group name to its ind...
Definition: PipelineStateBase.cpp:557
NODISCARD T * Construct(Args &&... args)
Definition: FixedLinearAllocator.hpp:216
struct GraphicsPipelineDesc GraphicsPipelineDesc
Definition: PipelineState.h:190
virtual Uint32 GetResourceSignatureCount() const override final
Implementation of IPipelineState::GetResourceSignatureCount().
Definition: PipelineStateBase.hpp:426
Uint8 ShaderHandles[sizeof(void *)]
Definition: PipelineStateBase.hpp:1071
Bool IsNormalized
For signed and unsigned integer value types (VT_INT8, VT_INT16, VT_INT32, VT_UINT8,...
Definition: InputLayout.h:89
Uint32 FindPipelineResourceLayoutVariable(const PipelineResourceLayoutDesc &LayoutDesc, const char *Name, SHADER_TYPE ShaderStage, const char *CombinedSamplerSuffix)
Finds a pipeline resource layout variable with the name 'Name' in shader stage 'ShaderStage' in the l...
Definition: PipelineStateBase.cpp:648
bool IsAnyGraphicsPipeline() const
Definition: PipelineState.h:336
Uint32 ResourceIndex
Definition: PipelineStateBase.hpp:840
SHADER_TYPE GetActiveShaderStages() const
Definition: PipelineStateBase.hpp:464
const PipelineResourceSignatureImplType * pSignature
Definition: PipelineStateBase.hpp:837
void InitializePipelineDesc(const ComputePipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool)
Definition: PipelineStateBase.hpp:793
Uint32 ResourceSignaturesCount
The number of elements in ppResourceSignatures array.
Definition: PipelineState.h:391
Uint32 GetNumBufferSlotsUsed() const
Definition: PipelineStateBase.hpp:270
const bool m_UsingImplicitSignature
True if the pipeline was created using implicit root signature.
Definition: PipelineStateBase.hpp:1033
struct PipelineStateCreateInfo PipelineStateCreateInfo
Definition: PipelineState.h:393
#define LOG_WARNING_MESSAGE(...)
Definition: Errors.hpp:123
PIPELINE_RESOURCE_FLAGS
Flags that define pipeline resource properties.
Definition: PipelineResourceSignature.h:79
Definition: PipelineStateBase.hpp:1045
IShader * pShader
Shader type must be SHADER_TYPE_RAY_GEN, SHADER_TYPE_RAY_MISS or SHADER_TYPE_CALLABLE.
Definition: PipelineState.h:200
std::unordered_map< HashMapStringKey, Uint32, HashMapStringKey::Hasher > TNameToGroupIndexMap
Definition: PipelineStateBase.hpp:470
Uint32 ImmutableSamplerIndex
Definition: PipelineStateBase.hpp:841
Uint32 ShaderDataSize
Definition: PipelineStateBase.hpp:1064
Uint32 GeneralShaderCount
The number of general shader groups.
Definition: PipelineState.h:452
static constexpr Uint32 InvalidSamplerIndex
Definition: PipelineStateBase.hpp:835
struct ImmutableSamplerDesc ImmutableSamplerDesc
Definition: PipelineResourceSignature.h:75
IShader * pAnyHitShader
Any-hit shader. Can be null. The shader type must be SHADER_TYPE_RAY_ANY_HIT.
Definition: PipelineState.h:260
Diligent::Vector2< T > max(const Diligent::Vector2< T > &Left, const Diligent::Vector2< T > &Right)
Definition: BasicMath.hpp:2261
static constexpr Uint32 InvalidSignatureIndex
Definition: PipelineStateBase.hpp:833
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
const char * GetPipelineTypeString(PIPELINE_TYPE PipelineType)
Definition: GraphicsAccessories.cpp:1145
struct PipelineResourceDesc PipelineResourceDesc
Definition: PipelineResourceSignature.h:162
virtual bool IsCompatibleWith(const IPipelineState *pPSO) const override
Implementation of IPipelineState::IsCompatibleWith().
Definition: PipelineStateBase.hpp:439
void ValidateRayTracingPipelineCreateInfo(IRenderDevice *pDevice, Uint32 MaxRecursion, const RayTracingPipelineStateCreateInfo &CreateInfo, const DeviceFeatures &Features) noexcept(false)
Definition: PipelineStateBase.cpp:470
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
const Char * GetShaderTypeLiteralName(SHADER_TYPE ShaderType)
Returns the literal name of a shader type. For instance, for a pixel shader, "SHADER_TYPE_PIXEL" will...
Definition: GraphicsAccessories.cpp:476
struct RayTracingPipelineStateCreateInfo RayTracingPipelineStateCreateInfo
Definition: PipelineState.h:488
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
Template class implementing base functionality of the pipeline state object.
Definition: PipelineStateBase.hpp:99
@ VT_FLOAT32
Full-precision 32-bit floating point.
Definition: GraphicsTypes.h:59
void ValidatePipelineResourceCompatibility(const PipelineResourceDesc &ResDesc, SHADER_RESOURCE_TYPE Type, PIPELINE_RESOURCE_FLAGS ResourceFlags, Uint32 ArraySize, const char *ShaderName, const char *SignatureName) noexcept(false)
Validates that pipeline resource description 'ResDesc' is compatible with the actual resource attribu...
Definition: PipelineStateBase.cpp:588
IShader * pVS
Vertex shader to be used with the pipeline.
Definition: PipelineState.h:403
Uint64 CommandQueueMask
Defines which command queues this pipeline state can be used with.
Definition: PipelineState.h:330
IShader * pGS
Geometry shader to be used with the pipeline.
Definition: PipelineState.h:415
Uint32 * pStrides
Definition: PipelineStateBase.hpp:1051
void ReserveSpaceForPipelineDesc(const RayTracingPipelineStateCreateInfo &CreateInfo, FixedLinearAllocator &MemPool) noexcept
Definition: PipelineStateBase.hpp:501
virtual IShaderResourceVariable * GetStaticVariableByName(SHADER_TYPE ShaderType, const Char *Name) override final
Definition: PipelineStateBase.hpp:342
Uint16 ShaderType
Definition: DXBCUtils.cpp:70
Definition: PipelineStateBase.hpp:831
Definition: PipelineStateBase.hpp:1055
GraphicsPipelineDesc GraphicsPipeline
Graphics pipeline state description.
Definition: PipelineState.h:400
RefCntAutoPtr< IRenderPass > pRenderPass
Strong reference to the render pass object.
Definition: PipelineStateBase.hpp:1049
bool IsComputePipeline() const
Definition: PipelineState.h:337
virtual void Free(void *Ptr)=0
Releases memory.
void ExtractShaders(const RayTracingPipelineStateCreateInfo &CreateInfo, TShaderStages &ShaderStages)
Definition: PipelineStateBase.hpp:600
#define ATTACHMENT_UNUSED
Definition: RenderPass.h:143
Pipeline layout description.
Definition: PipelineState.h:103
@ PIPELINE_TYPE_GRAPHICS
Graphics pipeline, which is used by IDeviceContext::Draw(), IDeviceContext::DrawIndexed(),...
Definition: PipelineState.h:299
const RayTracingGeneralShaderGroup * pGeneralShaders
A pointer to an array of GeneralShaderCount RayTracingGeneralShaderGroup structures that contain shad...
Definition: PipelineState.h:449
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
bool IsImmutableSampler() const
Definition: PipelineStateBase.hpp:863
Uint32 SignatureIndex
Definition: PipelineStateBase.hpp:839
Template class implementing base functionality of the device object.
Definition: DeviceObjectBase.hpp:45
void Destruct()
Definition: PipelineStateBase.hpp:232
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
void ExtractShaders(const ComputePipelineStateCreateInfo &CreateInfo, TShaderStages &ShaderStages)
Definition: PipelineStateBase.hpp:582
Resouce mapping.
Definition: ResourceMapping.h:107