@@ -180,48 +180,33 @@ bool verifyBorderColor(uint32_t BorderColor) {
180
180
181
181
bool verifyLOD (float LOD) { return !std::isnan (LOD); }
182
182
183
- /* * This validation logic was extracted from the DXC codebase
184
- * https://github.com/microsoft/DirectXShaderCompiler/blob/7a1b1df9b50a8350a63756720e85196e0285e664/lib/DxilRootSignature/DxilRootSignatureValidator.cpp#L205
185
- *
186
- * It checks if the registers in a descriptor table are overflowing, meaning,
187
- * they are trying to bind a register larger than MAX_UINT.
188
- * This will usually happen when the descriptor table appends a resource
189
- * after an unbounded range.
190
- **/
191
- bool verifyOffsetOverflowing (uint64_t &AppendingRegister,
192
- uint32_t OffsetInDescriptorsFromTableStart,
193
- uint32_t BaseRegister, uint32_t Space,
194
- uint32_t NumDescriptors) {
195
- uint64_t Register = AppendingRegister;
196
-
197
- // Checks if the current register should be appended to the previous range.
198
- if (OffsetInDescriptorsFromTableStart != ~0U )
199
- Register = OffsetInDescriptorsFromTableStart;
200
-
201
- // Check for overflow in the register value.
183
+ bool verifyOffsetOverflow (uint32_t Offset, uint64_t Register) {
184
+ if (Offset != ~0U )
185
+ Register = Offset;
186
+
202
187
if (Register > ~0U )
203
188
return true ;
204
- // Is the current range unbounded?
205
- if (NumDescriptors == ~0U ) {
206
- // No ranges should be appended to an unbounded range.
207
- AppendingRegister = (uint64_t )~0U + (uint64_t )1ULL ;
208
- } else {
209
- // Is the defined range, overflowing?
210
- uint64_t UpperBound =
211
- (uint64_t )BaseRegister + (uint64_t )NumDescriptors - (uint64_t )1U ;
212
- if (UpperBound > ~0U )
213
- return true ;
214
-
215
- // If we append this range, will it overflow?
216
- uint64_t AppendingUpperBound =
217
- (uint64_t )Register + (uint64_t )NumDescriptors - (uint64_t )1U ;
218
- if (AppendingUpperBound > ~0U )
219
- return true ;
220
- AppendingRegister = Register + NumDescriptors;
221
- }
222
189
return false ;
223
190
}
224
191
192
+ bool verifyRegisterOverflow (uint64_t Register, uint32_t NumDescriptors) {
193
+ if (NumDescriptors == ~0U )
194
+ return false ;
195
+
196
+ uint64_t UpperBound =
197
+ (uint64_t )Register + (uint64_t )NumDescriptors - (uint64_t )1U ;
198
+ if (UpperBound > ~0U )
199
+ return true ;
200
+
201
+ return false ;
202
+ }
203
+
204
+ uint64_t updateAppendingRegister (uint64_t AppendingRegisterRegister,
205
+ uint32_t NumDescriptors) {
206
+ if (NumDescriptors == ~0U )
207
+ return (uint64_t )~0U + (uint64_t )1ULL ;
208
+ return AppendingRegisterRegister + NumDescriptors;
209
+ }
225
210
} // namespace rootsig
226
211
} // namespace hlsl
227
212
} // namespace llvm
0 commit comments