6#include <unordered_map>
12#include "misc/Error.h"
13#include "SpecialRootParameterSlot.hpp"
16#include "directx/d3dx12.h"
17#include <DirectXShaderCompiler/inc/d3d12shader.h>
20#include <wrl/client.h>
24 class DirectXRenderer;
26 using namespace Microsoft::WRL;
29 enum class SamplerType {
47 enum class Type { CONSTANTS, CBV, SRV, UAV };
119 D3D12_SHADER_VISIBILITY
visibility = D3D12_SHADER_VISIBILITY_ALL;
172 std::array<UINT, static_cast<unsigned int>(SpecialRootParameterSlot::SIZE)>
195 ID3D12Device* pDevice,
const ComPtr<ID3D12ShaderReflection>& pShaderReflection);
215 static std::variant<Generated, Error>
229 static std::variant<Generated, Error>
240 static std::variant<SamplerType, Error>
257 std::unordered_map<std::string, std::pair<UINT, RootSignatureGenerator::RootParameter>>&
258 shaderRootParameterIndices,
259 std::vector<CD3DX12_ROOT_PARAMETER>& vRootParameters,
260 std::vector<CD3DX12_DESCRIPTOR_RANGE>& vTableRanges,
261 std::set<std::string>& addedRootParameterNames,
262 std::unordered_map<std::string, UINT>& rootParameterIndices,
263 std::array<UINT,
static_cast<unsigned int>(SpecialRootParameterSlot::SIZE)>&
264 vSpecialRootParameterIndices);
279 std::unordered_map<std::string, std::pair<UINT, RootParameter>>& mapToAddTo,
280 const std::string& sResourceName,
281 UINT iRootParameterIndex,
294 std::vector<RootParameter>& vRootParameters,
295 std::unordered_map<std::string, std::pair<UINT, RootParameter>>& rootParameterIndices,
296 const D3D12_SHADER_INPUT_BIND_DESC& resourceDescription);
309 std::vector<RootParameter>& vRootParameters,
310 std::unordered_map<std::string, std::pair<UINT, RootParameter>>& rootParameterIndices,
311 const D3D12_SHADER_INPUT_BIND_DESC& resourceDescription,
325 std::vector<RootParameter>& vRootParameters,
326 std::unordered_map<std::string, std::pair<UINT, RootParameter>>& rootParameterIndices,
327 const D3D12_SHADER_INPUT_BIND_DESC& resourceDescription,
344 const ComPtr<ID3D12ShaderReflection>& pShaderReflection,
345 const D3D12_SHADER_INPUT_BIND_DESC& resourceDescription,
346 std::unordered_map<std::string, size_t>& rootConstantOffsets,
347 std::vector<RootParameter>& vRootParameters,
348 std::unordered_map<std::string, std::pair<UINT, RootParameter>>& rootParameterIndices);
Definition: DirectXRenderer.h:36
Definition: HlslShader.h:31
Definition: RootSignatureGenerator.h:44
bool bIsTable
Definition: RootSignatureGenerator.h:116
bool isTable() const
Definition: RootSignatureGenerator.cpp:1074
CD3DX12_ROOT_PARAMETER generateSingleDescriptorDescription() const
Definition: RootSignatureGenerator.cpp:984
Type
Definition: RootSignatureGenerator.h:47
UINT iBindPoint
Definition: RootSignatureGenerator.h:100
UINT iSpace
Definition: RootSignatureGenerator.h:103
Type type
Definition: RootSignatureGenerator.h:106
UINT iCount
Definition: RootSignatureGenerator.h:113
CD3DX12_DESCRIPTOR_RANGE generateTableRange() const
Definition: RootSignatureGenerator.cpp:1024
D3D12_SHADER_VISIBILITY getVisibility() const
Definition: RootSignatureGenerator.cpp:1070
D3D12_SHADER_VISIBILITY visibility
Definition: RootSignatureGenerator.h:119
Definition: RootSignatureGenerator.h:37
static std::optional< Error > addCbufferRootParameter(std::vector< RootParameter > &vRootParameters, std::unordered_map< std::string, std::pair< UINT, RootParameter > > &rootParameterIndices, const D3D12_SHADER_INPUT_BIND_DESC &resourceDescription)
Definition: RootSignatureGenerator.cpp:765
static const std::string sRootConstantsTypeName
Definition: RootSignatureGenerator.h:354
static std::variant< Generated, Error > generateCompute(DirectXRenderer *pRenderer, HlslShader *pComputeShader)
Definition: RootSignatureGenerator.cpp:473
static std::variant< CollectedInfo, Error > collectInfoFromReflection(ID3D12Device *pDevice, const ComPtr< ID3D12ShaderReflection > &pShaderReflection)
Definition: RootSignatureGenerator.cpp:16
static std::variant< Generated, Error > generateGraphics(DirectXRenderer *pRenderer, HlslShader *pVertexShader, HlslShader *pPixelShader)
Definition: RootSignatureGenerator.cpp:193
static std::variant< bool, Error > processRootConstantsIfFound(const ComPtr< ID3D12ShaderReflection > &pShaderReflection, const D3D12_SHADER_INPUT_BIND_DESC &resourceDescription, std::unordered_map< std::string, size_t > &rootConstantOffsets, std::vector< RootParameter > &vRootParameters, std::unordered_map< std::string, std::pair< UINT, RootParameter > > &rootParameterIndices)
Definition: RootSignatureGenerator.cpp:849
static void addSpecialResourceRootParametersIfUsed(std::unordered_map< std::string, std::pair< UINT, RootSignatureGenerator::RootParameter > > &shaderRootParameterIndices, std::vector< CD3DX12_ROOT_PARAMETER > &vRootParameters, std::vector< CD3DX12_DESCRIPTOR_RANGE > &vTableRanges, std::set< std::string > &addedRootParameterNames, std::unordered_map< std::string, UINT > &rootParameterIndices, std::array< UINT, static_cast< unsigned int >(SpecialRootParameterSlot::SIZE)> &vSpecialRootParameterIndices)
Definition: RootSignatureGenerator.cpp:636
static std::optional< Error > addTexture2DRootParameter(std::vector< RootParameter > &vRootParameters, std::unordered_map< std::string, std::pair< UINT, RootParameter > > &rootParameterIndices, const D3D12_SHADER_INPUT_BIND_DESC &resourceDescription, bool bIsReadWrite)
Definition: RootSignatureGenerator.cpp:791
static std::optional< Error > addStructuredBufferRootParameter(std::vector< RootParameter > &vRootParameters, std::unordered_map< std::string, std::pair< UINT, RootParameter > > &rootParameterIndices, const D3D12_SHADER_INPUT_BIND_DESC &resourceDescription, bool bIsReadWrite)
Definition: RootSignatureGenerator.cpp:821
static const std::string sRootConstantsVariableName
Definition: RootSignatureGenerator.h:351
static std::variant< SamplerType, Error > findStaticSamplerForSamplerResource(const D3D12_SHADER_INPUT_BIND_DESC &samplerResourceDescription)
Definition: RootSignatureGenerator.cpp:582
static std::optional< Error > addUniquePairResourceNameRootParameterIndex(std::unordered_map< std::string, std::pair< UINT, RootParameter > > &mapToAddTo, const std::string &sResourceName, UINT iRootParameterIndex, const RootParameter ¶meter)
Definition: RootSignatureGenerator.cpp:744
Definition: RootSignatureGenerator.h:123
std::vector< RootParameter > vRootParameters
Definition: RootSignatureGenerator.h:128
std::set< SamplerType > staticSamplers
Definition: RootSignatureGenerator.h:125
std::unordered_map< std::string, std::pair< UINT, RootParameter > > rootParameterIndices
Definition: RootSignatureGenerator.h:135
std::unordered_map< std::string, size_t > rootConstantOffsets
Definition: RootSignatureGenerator.h:145
Definition: RootSignatureGenerator.h:149
std::array< UINT, static_cast< unsigned int >(SpecialRootParameterSlot::SIZE)> vSpecialRootParameterIndices
Definition: RootSignatureGenerator.h:173
ComPtr< ID3D12RootSignature > pRootSignature
Definition: RootSignatureGenerator.h:151
std::unordered_map< std::string, size_t > rootConstantOffsets
Definition: RootSignatureGenerator.h:183
std::unordered_map< std::string, UINT > rootParameterIndices
Definition: RootSignatureGenerator.h:160