LLVM 22.0.0git
HLSLRootSignature.h
Go to the documentation of this file.
1//===- HLSLRootSignature.h - HLSL Root Signature helper objects -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file This file contains structure definitions of HLSL Root Signature
10/// objects.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_FRONTEND_HLSL_HLSLROOTSIGNATURE_H
15#define LLVM_FRONTEND_HLSL_HLSLROOTSIGNATURE_H
16
21#include <limits>
22#include <variant>
23
24namespace llvm {
25namespace hlsl {
26namespace rootsig {
27
28// Definitions of the in-memory data layout structures
29
30// Models the different registers: bReg | tReg | uReg | sReg
31enum class RegisterType { BReg, TReg, UReg, SReg };
36
37// Models the parameter values of root constants
44
45// Models RootDescriptor : CBV | SRV | UAV, by collecting like parameters
50 dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
52
55 Flags = dxbc::RootDescriptorFlags::DataVolatile;
56 return;
57 }
58
61 "Specified an invalid root signature version");
62 switch (Type) {
65 Flags = dxbc::RootDescriptorFlags::DataStaticWhileSetAtExecute;
66 break;
68 Flags = dxbc::RootDescriptorFlags::DataVolatile;
69 break;
72 "ResourceClass::Sampler is not valid for RootDescriptors");
73 }
74 }
75};
76
77// Models the end of a descriptor table and stores its visibility
79 dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
80 // Denotes that the previous NumClauses in the RootElement array
81 // are the clauses in the table.
83};
84
85static const uint32_t NumDescriptorsUnbounded = 0xffffffff;
86static const uint32_t DescriptorTableOffsetAppend = 0xffffffff;
87// Models DTClause : CBV | SRV | UAV | Sampler, by collecting like parameters
95
98 Flags = dxbc::DescriptorRangeFlags::DescriptorsVolatile;
100 Flags |= dxbc::DescriptorRangeFlags::DataVolatile;
101 return;
102 }
103
106 "Specified an invalid root signature version");
107 switch (Type) {
110 Flags = dxbc::DescriptorRangeFlags::DataStaticWhileSetAtExecute;
111 break;
113 Flags = dxbc::DescriptorRangeFlags::DataVolatile;
114 break;
116 Flags = dxbc::DescriptorRangeFlags::None;
117 break;
118 }
119 }
120};
121
124 dxbc::SamplerFilter Filter = dxbc::SamplerFilter::Anisotropic;
125 dxbc::TextureAddressMode AddressU = dxbc::TextureAddressMode::Wrap;
126 dxbc::TextureAddressMode AddressV = dxbc::TextureAddressMode::Wrap;
127 dxbc::TextureAddressMode AddressW = dxbc::TextureAddressMode::Wrap;
128 float MipLODBias = 0.f;
130 dxbc::ComparisonFunc CompFunc = dxbc::ComparisonFunc::LessEqual;
131 dxbc::StaticBorderColor BorderColor = dxbc::StaticBorderColor::OpaqueWhite;
132 float MinLOD = 0.f;
133 float MaxLOD = std::numeric_limits<float>::max();
135 dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
136 dxbc::StaticSamplerFlags Flags = dxbc::StaticSamplerFlags::None;
137};
138
139/// Models RootElement : RootFlags | RootConstants | RootParam
140/// | DescriptorTable | DescriptorTableClause | StaticSampler
141///
142/// A Root Signature is modeled in-memory by an array of RootElements. These
143/// aim to map closely to their DSL grammar reprsentation defined in the spec.
144///
145/// Each optional parameter has its default value defined in the struct, and,
146/// each mandatory parameter does not have a default initialization.
147///
148/// For the variants RootFlags, RootConstants, RootParam, StaticSampler and
149/// DescriptorTableClause: each data member maps directly to a parameter in the
150/// grammar.
151///
152/// The DescriptorTable is modelled by having its Clauses as the previous
153/// RootElements in the array, and it holds a data member for the Visibility
154/// parameter.
158
159/// The following contains the serialization interface for root elements
162 const RootConstants &Constants);
167 const RootDescriptor &Descriptor);
171
173
174} // namespace rootsig
175} // namespace hlsl
176} // namespace llvm
177
178#endif // LLVM_FRONTEND_HLSL_HLSLROOTSIGNATURE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const uint32_t NumDescriptorsUnbounded
static const uint32_t DescriptorTableOffsetAppend
LLVM_ABI void dumpRootElements(raw_ostream &OS, ArrayRef< RootElement > Elements)
std::variant< dxbc::RootFlags, RootConstants, RootDescriptor, DescriptorTable, DescriptorTableClause, StaticSampler > RootElement
Models RootElement : RootFlags | RootConstants | RootParam | DescriptorTable | DescriptorTableClause ...
LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const dxbc::RootFlags &Flags)
The following contains the serialization interface for root elements.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
void setDefaultFlags(dxbc::RootSignatureVersion Version)
void setDefaultFlags(dxbc::RootSignatureVersion Version)