@@ -69,8 +69,7 @@ ResourceInfo ResourceInfo::SRV(Value *Symbol, StringRef Name,
69
69
ResourceInfo RI (ResourceClass::SRV, Kind, Symbol, Name);
70
70
assert (RI.isTyped () && !(RI.isStruct () || RI.isMultiSample ()) &&
71
71
" Invalid ResourceKind for SRV constructor." );
72
- RI.Typed .ElementTy = ElementTy;
73
- RI.Typed .ElementCount = ElementCount;
72
+ RI.setTyped (ElementTy, ElementCount);
74
73
return RI;
75
74
}
76
75
@@ -80,11 +79,11 @@ ResourceInfo ResourceInfo::RawBuffer(Value *Symbol, StringRef Name) {
80
79
}
81
80
82
81
ResourceInfo ResourceInfo::StructuredBuffer (Value *Symbol, StringRef Name,
83
- uint32_t Stride, Align Alignment) {
82
+ uint32_t Stride,
83
+ MaybeAlign Alignment) {
84
84
ResourceInfo RI (ResourceClass::SRV, ResourceKind::StructuredBuffer, Symbol,
85
85
Name);
86
- RI.Struct .Stride = Stride;
87
- RI.Struct .Alignment = Alignment;
86
+ RI.setStruct (Stride, Alignment);
88
87
return RI;
89
88
}
90
89
@@ -93,9 +92,8 @@ ResourceInfo ResourceInfo::Texture2DMS(Value *Symbol, StringRef Name,
93
92
uint32_t ElementCount,
94
93
uint32_t SampleCount) {
95
94
ResourceInfo RI (ResourceClass::SRV, ResourceKind::Texture2DMS, Symbol, Name);
96
- RI.Typed .ElementTy = ElementTy;
97
- RI.Typed .ElementCount = ElementCount;
98
- RI.MultiSample .Count = SampleCount;
95
+ RI.setTyped (ElementTy, ElementCount);
96
+ RI.setMultiSample (SampleCount);
99
97
return RI;
100
98
}
101
99
@@ -105,9 +103,8 @@ ResourceInfo ResourceInfo::Texture2DMSArray(Value *Symbol, StringRef Name,
105
103
uint32_t SampleCount) {
106
104
ResourceInfo RI (ResourceClass::SRV, ResourceKind::Texture2DMSArray, Symbol,
107
105
Name);
108
- RI.Typed .ElementTy = ElementTy;
109
- RI.Typed .ElementCount = ElementCount;
110
- RI.MultiSample .Count = SampleCount;
106
+ RI.setTyped (ElementTy, ElementCount);
107
+ RI.setMultiSample (SampleCount);
111
108
return RI;
112
109
}
113
110
@@ -118,34 +115,27 @@ ResourceInfo ResourceInfo::UAV(Value *Symbol, StringRef Name,
118
115
ResourceInfo RI (ResourceClass::UAV, Kind, Symbol, Name);
119
116
assert (RI.isTyped () && !(RI.isStruct () || RI.isMultiSample ()) &&
120
117
" Invalid ResourceKind for UAV constructor." );
121
- RI.Typed .ElementTy = ElementTy;
122
- RI.Typed .ElementCount = ElementCount;
123
- RI.UAVFlags .GloballyCoherent = GloballyCoherent;
124
- RI.UAVFlags .IsROV = IsROV;
125
- RI.UAVFlags .HasCounter = false ;
118
+ RI.setTyped (ElementTy, ElementCount);
119
+ RI.setUAV (GloballyCoherent, /* HasCounter=*/ false , IsROV);
126
120
return RI;
127
121
}
128
122
129
123
ResourceInfo ResourceInfo::RWRawBuffer (Value *Symbol, StringRef Name,
130
124
bool GloballyCoherent, bool IsROV) {
131
125
ResourceInfo RI (ResourceClass::UAV, ResourceKind::RawBuffer, Symbol, Name);
132
- RI.UAVFlags .GloballyCoherent = GloballyCoherent;
133
- RI.UAVFlags .IsROV = IsROV;
134
- RI.UAVFlags .HasCounter = false ;
126
+ RI.setUAV (GloballyCoherent, /* HasCounter=*/ false , IsROV);
135
127
return RI;
136
128
}
137
129
138
130
ResourceInfo ResourceInfo::RWStructuredBuffer (Value *Symbol, StringRef Name,
139
- uint32_t Stride, Align Alignment,
131
+ uint32_t Stride,
132
+ MaybeAlign Alignment,
140
133
bool GloballyCoherent, bool IsROV,
141
134
bool HasCounter) {
142
135
ResourceInfo RI (ResourceClass::UAV, ResourceKind::StructuredBuffer, Symbol,
143
136
Name);
144
- RI.Struct .Stride = Stride;
145
- RI.Struct .Alignment = Alignment;
146
- RI.UAVFlags .GloballyCoherent = GloballyCoherent;
147
- RI.UAVFlags .IsROV = IsROV;
148
- RI.UAVFlags .HasCounter = HasCounter;
137
+ RI.setStruct (Stride, Alignment);
138
+ RI.setUAV (GloballyCoherent, HasCounter, IsROV);
149
139
return RI;
150
140
}
151
141
@@ -155,12 +145,9 @@ ResourceInfo ResourceInfo::RWTexture2DMS(Value *Symbol, StringRef Name,
155
145
uint32_t SampleCount,
156
146
bool GloballyCoherent) {
157
147
ResourceInfo RI (ResourceClass::UAV, ResourceKind::Texture2DMS, Symbol, Name);
158
- RI.Typed .ElementTy = ElementTy;
159
- RI.Typed .ElementCount = ElementCount;
160
- RI.UAVFlags .GloballyCoherent = GloballyCoherent;
161
- RI.UAVFlags .IsROV = false ;
162
- RI.UAVFlags .HasCounter = false ;
163
- RI.MultiSample .Count = SampleCount;
148
+ RI.setTyped (ElementTy, ElementCount);
149
+ RI.setUAV (GloballyCoherent, /* HasCounter=*/ false , /* IsROV=*/ false );
150
+ RI.setMultiSample (SampleCount);
164
151
return RI;
165
152
}
166
153
@@ -171,23 +158,18 @@ ResourceInfo ResourceInfo::RWTexture2DMSArray(Value *Symbol, StringRef Name,
171
158
bool GloballyCoherent) {
172
159
ResourceInfo RI (ResourceClass::UAV, ResourceKind::Texture2DMSArray, Symbol,
173
160
Name);
174
- RI.Typed .ElementTy = ElementTy;
175
- RI.Typed .ElementCount = ElementCount;
176
- RI.UAVFlags .GloballyCoherent = GloballyCoherent;
177
- RI.UAVFlags .IsROV = false ;
178
- RI.UAVFlags .HasCounter = false ;
179
- RI.MultiSample .Count = SampleCount;
161
+ RI.setTyped (ElementTy, ElementCount);
162
+ RI.setUAV (GloballyCoherent, /* HasCounter=*/ false , /* IsROV=*/ false );
163
+ RI.setMultiSample (SampleCount);
180
164
return RI;
181
165
}
182
166
183
167
ResourceInfo ResourceInfo::FeedbackTexture2D (Value *Symbol, StringRef Name,
184
168
SamplerFeedbackType FeedbackTy) {
185
169
ResourceInfo RI (ResourceClass::UAV, ResourceKind::FeedbackTexture2D, Symbol,
186
170
Name);
187
- RI.UAVFlags .GloballyCoherent = false ;
188
- RI.UAVFlags .IsROV = false ;
189
- RI.UAVFlags .HasCounter = false ;
190
- RI.Feedback .Type = FeedbackTy;
171
+ RI.setUAV (/* GloballyCoherent=*/ false , /* HasCounter=*/ false , /* IsROV=*/ false );
172
+ RI.setFeedback (FeedbackTy);
191
173
return RI;
192
174
}
193
175
@@ -196,24 +178,22 @@ ResourceInfo::FeedbackTexture2DArray(Value *Symbol, StringRef Name,
196
178
SamplerFeedbackType FeedbackTy) {
197
179
ResourceInfo RI (ResourceClass::UAV, ResourceKind::FeedbackTexture2DArray,
198
180
Symbol, Name);
199
- RI.UAVFlags .GloballyCoherent = false ;
200
- RI.UAVFlags .IsROV = false ;
201
- RI.UAVFlags .HasCounter = false ;
202
- RI.Feedback .Type = FeedbackTy;
181
+ RI.setUAV (/* GloballyCoherent=*/ false , /* HasCounter=*/ false , /* IsROV=*/ false );
182
+ RI.setFeedback (FeedbackTy);
203
183
return RI;
204
184
}
205
185
206
186
ResourceInfo ResourceInfo::CBuffer (Value *Symbol, StringRef Name,
207
187
uint32_t Size ) {
208
188
ResourceInfo RI (ResourceClass::CBuffer, ResourceKind::CBuffer, Symbol, Name);
209
- RI.CBufferSize = Size ;
189
+ RI.setCBuffer ( Size ) ;
210
190
return RI;
211
191
}
212
192
213
193
ResourceInfo ResourceInfo::Sampler (Value *Symbol, StringRef Name,
214
194
SamplerType SamplerTy) {
215
195
ResourceInfo RI (ResourceClass::Sampler, ResourceKind::Sampler, Symbol, Name);
216
- RI.SamplerTy = SamplerTy ;
196
+ RI.setSampler ( SamplerTy) ;
217
197
return RI;
218
198
}
219
199
@@ -306,7 +286,8 @@ MDTuple *ResourceInfo::getAsMetadata(LLVMContext &Ctx) const {
306
286
307
287
std::pair<uint32_t , uint32_t > ResourceInfo::getAnnotateProps () const {
308
288
uint32_t ResourceKind = llvm::to_underlying (Kind);
309
- uint32_t AlignLog2 = isStruct () ? Log2 (Struct.Alignment ) : 0 ;
289
+ uint32_t AlignLog2 =
290
+ isStruct () && Struct.Alignment ? Log2 (*Struct.Alignment ) : 0 ;
310
291
bool IsUAV = isUAV ();
311
292
bool IsROV = IsUAV && UAVFlags.IsROV ;
312
293
bool IsGloballyCoherent = IsUAV && UAVFlags.GloballyCoherent ;
0 commit comments