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 };
32struct Register {
35};
36
37// Models the parameter values of root constants
42 dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
43};
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
60 "Specified an invalid root signature version");
61 switch (Type) {
64 Flags = dxbc::RootDescriptorFlags::DataStaticWhileSetAtExecute;
65 break;
67 Flags = dxbc::RootDescriptorFlags::DataVolatile;
68 break;
71 "ResourceClass::Sampler is not valid for RootDescriptors");
72 }
73 }
74};
75
76// Models the end of a descriptor table and stores its visibility
78 dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
79 // Denotes that the previous NumClauses in the RootElement array
80 // are the clauses in the table.
82};
83
84static const uint32_t NumDescriptorsUnbounded = 0xffffffff;
85static const uint32_t DescriptorTableOffsetAppend = 0xffffffff;
86// Models DTClause : CBV | SRV | UAV | Sampler, by collecting like parameters
94
97 Flags = dxbc::DescriptorRangeFlags::DescriptorsVolatile;
99 Flags |= dxbc::DescriptorRangeFlags::DataVolatile;
100 return;
101 }
102
104 "Specified an invalid root signature version");
105 switch (Type) {
108 Flags = dxbc::DescriptorRangeFlags::DataStaticWhileSetAtExecute;
109 break;
111 Flags = dxbc::DescriptorRangeFlags::DataVolatile;
112 break;
114 Flags = dxbc::DescriptorRangeFlags::None;
115 break;
116 }
117 }
118};
119
122 dxbc::SamplerFilter Filter = dxbc::SamplerFilter::Anisotropic;
123 dxbc::TextureAddressMode AddressU = dxbc::TextureAddressMode::Wrap;
124 dxbc::TextureAddressMode AddressV = dxbc::TextureAddressMode::Wrap;
125 dxbc::TextureAddressMode AddressW = dxbc::TextureAddressMode::Wrap;
126 float MipLODBias = 0.f;
128 dxbc::ComparisonFunc CompFunc = dxbc::ComparisonFunc::LessEqual;
129 dxbc::StaticBorderColor BorderColor = dxbc::StaticBorderColor::OpaqueWhite;
130 float MinLOD = 0.f;
131 float MaxLOD = std::numeric_limits<float>::max();
133 dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
134};
135
136/// Models RootElement : RootFlags | RootConstants | RootParam
137/// | DescriptorTable | DescriptorTableClause | StaticSampler
138///
139/// A Root Signature is modeled in-memory by an array of RootElements. These
140/// aim to map closely to their DSL grammar reprsentation defined in the spec.
141///
142/// Each optional parameter has its default value defined in the struct, and,
143/// each mandatory parameter does not have a default initialization.
144///
145/// For the variants RootFlags, RootConstants, RootParam, StaticSampler and
146/// DescriptorTableClause: each data member maps directly to a parameter in the
147/// grammar.
148///
149/// The DescriptorTable is modelled by having its Clauses as the previous
150/// RootElements in the array, and it holds a data member for the Visibility
151/// parameter.
155
156/// The following contains the serialization interface for root elements
159 const RootConstants &Constants);
164 const RootDescriptor &Descriptor);
168
170
171} // namespace rootsig
172} // namespace hlsl
173} // namespace llvm
174
175#endif // LLVM_FRONTEND_HLSL_HLSLROOTSIGNATURE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition: Compiler.h:213
raw_pwrite_stream & OS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
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.
ResourceClass
Definition: DXILABI.h:26
static const uint32_t NumDescriptorsUnbounded
std::variant< dxbc::RootFlags, RootConstants, RootDescriptor, DescriptorTable, DescriptorTableClause, StaticSampler > RootElement
Models RootElement : RootFlags | RootConstants | RootParam | DescriptorTable | DescriptorTableClause ...
static const uint32_t DescriptorTableOffsetAppend
LLVM_ABI void dumpRootElements(raw_ostream &OS, ArrayRef< RootElement > Elements)
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.
Definition: AddressRanges.h:18
void setDefaultFlags(dxbc::RootSignatureVersion Version)
dxbc::RootDescriptorFlags Flags
void setDefaultFlags(dxbc::RootSignatureVersion Version)
dxbc::TextureAddressMode AddressU
dxbc::StaticBorderColor BorderColor
dxbc::TextureAddressMode AddressW
dxbc::TextureAddressMode AddressV