23bool ResourceInfo::isStruct()
const {
27bool ResourceInfo::isTyped()
const {
56bool ResourceInfo::isFeedback()
const {
61bool ResourceInfo::isMultiSample()
const {
70 assert(RI.isTyped() && !(RI.isStruct() || RI.isMultiSample()) &&
71 "Invalid ResourceKind for SRV constructor.");
72 RI.
Typed.ElementTy = ElementTy;
87 RI.
Struct.Alignment = Alignment;
96 RI.
Typed.ElementTy = ElementTy;
98 RI.MultiSample.Count = SampleCount;
108 RI.
Typed.ElementTy = ElementTy;
110 RI.MultiSample.Count = SampleCount;
116 bool GloballyCoherent,
bool IsROV,
119 assert(RI.isTyped() && !(RI.isStruct() || RI.isMultiSample()) &&
120 "Invalid ResourceKind for UAV constructor.");
121 RI.
Typed.ElementTy = ElementTy;
123 RI.
UAVFlags.GloballyCoherent = GloballyCoherent;
130 bool GloballyCoherent,
bool IsROV) {
132 RI.
UAVFlags.GloballyCoherent = GloballyCoherent;
140 bool GloballyCoherent,
bool IsROV,
144 RI.
Struct.Stride = Stride;
145 RI.
Struct.Alignment = Alignment;
146 RI.
UAVFlags.GloballyCoherent = GloballyCoherent;
148 RI.
UAVFlags.HasCounter = HasCounter;
156 bool GloballyCoherent) {
158 RI.
Typed.ElementTy = ElementTy;
160 RI.
UAVFlags.GloballyCoherent = GloballyCoherent;
163 RI.MultiSample.Count = SampleCount;
171 bool GloballyCoherent) {
174 RI.
Typed.ElementTy = ElementTy;
176 RI.
UAVFlags.GloballyCoherent = GloballyCoherent;
179 RI.MultiSample.Count = SampleCount;
187 RI.
UAVFlags.GloballyCoherent =
false;
199 RI.
UAVFlags.GloballyCoherent =
false;
221 if (std::tie(Symbol, Name, Binding, RC, Kind) !=
235 if (isTyped() &&
Typed !=
RHS.Typed)
239 return MultiSample ==
RHS.MultiSample;
250 auto getIntMD = [&I32Ty](
uint32_t V) {
254 auto getBoolMD = [&I1Ty](
uint32_t V) {
259 MDVals.
push_back(getIntMD(Binding.UniqueID));
262 MDVals.
push_back(getIntMD(Binding.Space));
263 MDVals.
push_back(getIntMD(Binding.LowerBound));
264 MDVals.
push_back(getIntMD(Binding.Size));
269 }
else if (isSampler()) {
283 uint32_t SampleCount = isMultiSample() ? MultiSample.Count : 0;
293 }
else if (isTyped()) {
296 }
else if (isFeedback()) {
310 bool IsUAV = isUAV();
311 bool IsROV = IsUAV &&
UAVFlags.IsROV;
312 bool IsGloballyCoherent = IsUAV &&
UAVFlags.GloballyCoherent;
313 uint8_t SamplerCmpOrHasCounter = 0;
315 SamplerCmpOrHasCounter =
UAVFlags.HasCounter;
316 else if (isSampler())
323 Word0 |= (AlignLog2 & 0xF) << 8;
324 Word0 |= (IsUAV & 1) << 12;
325 Word0 |= (IsROV & 1) << 13;
326 Word0 |= (IsGloballyCoherent & 1) << 14;
327 Word0 |= (SamplerCmpOrHasCounter & 1) << 15;
332 else if (isCBuffer())
334 else if (isFeedback())
336 else if (isTyped()) {
339 uint32_t SampleCount = isMultiSample() ? MultiSample.Count : 0;
341 Word1 |= (CompType & 0xFF) << 0;
342 Word1 |= (CompCount & 0xFF) << 8;
343 Word1 |= (SampleCount & 0xFF) << 16;
346 return {Word0, Word1};
349#define DEBUG_TYPE "dxil-resource"
This file implements a class to represent arbitrary precision integral constant values and operations...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
static Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
This is an important class for using LLVM in a threaded context.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDString * get(LLVMContext &Context, StringRef Str)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt1Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
static ResourceInfo Texture2DMSArray(Value *Symbol, StringRef Name, dxil::ElementType ElementTy, uint32_t ElementCount, uint32_t SampleCount)
static ResourceInfo RawBuffer(Value *Symbol, StringRef Name)
static ResourceInfo FeedbackTexture2D(Value *Symbol, StringRef Name, dxil::SamplerFeedbackType FeedbackTy)
static ResourceInfo Texture2DMS(Value *Symbol, StringRef Name, dxil::ElementType ElementTy, uint32_t ElementCount, uint32_t SampleCount)
static ResourceInfo RWTexture2DMS(Value *Symbol, StringRef Name, dxil::ElementType ElementTy, uint32_t ElementCount, uint32_t SampleCount, bool GloballyCoherent)
static ResourceInfo RWStructuredBuffer(Value *Symbol, StringRef Name, uint32_t Stride, Align Alignment, bool GloballyCoherent, bool IsROV, bool HasCounter)
std::pair< uint32_t, uint32_t > getAnnotateProps() const
static ResourceInfo Sampler(Value *Symbol, StringRef Name, dxil::SamplerType SamplerTy)
static ResourceInfo UAV(Value *Symbol, StringRef Name, dxil::ElementType ElementTy, uint32_t ElementCount, bool GloballyCoherent, bool IsROV, dxil::ResourceKind Kind)
static ResourceInfo RWRawBuffer(Value *Symbol, StringRef Name, bool GloballyCoherent, bool IsROV)
dxil::SamplerType SamplerTy
static ResourceInfo SRV(Value *Symbol, StringRef Name, dxil::ElementType ElementTy, uint32_t ElementCount, dxil::ResourceKind Kind)
bool operator==(const ResourceInfo &RHS) const
static ResourceInfo FeedbackTexture2DArray(Value *Symbol, StringRef Name, dxil::SamplerFeedbackType FeedbackTy)
static ResourceInfo StructuredBuffer(Value *Symbol, StringRef Name, uint32_t Stride, Align Alignment)
static ResourceInfo RWTexture2DMSArray(Value *Symbol, StringRef Name, dxil::ElementType ElementTy, uint32_t ElementCount, uint32_t SampleCount, bool GloballyCoherent)
MDTuple * getAsMetadata(LLVMContext &Ctx) const
static ResourceInfo CBuffer(Value *Symbol, StringRef Name, uint32_t Size)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ResourceKind
The kind of resource for an SRV or UAV resource.
@ RTAccelerationStructure
ElementType
The element type of an SRV or UAV resource.
This is an optimization pass for GlobalISel generic memory operations.
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
unsigned Log2(Align A)
Returns the log2 of the alignment.
This struct is a compact representation of a valid (non-zero power of two) alignment.