Skip to content

Commit e5976ee

Browse files
committed
making updateOngoingOffset shared
1 parent cf84fcf commit e5976ee

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,9 +1378,8 @@ bool SemaHLSL::handleRootSignatureElements(
13781378
Diag(Loc, diag::err_hlsl_offset_overflow) << Offset << RangeBound;
13791379
}
13801380

1381-
Offset = RangeBound == llvm::hlsl::rootsig::NumDescriptorsUnbounded
1382-
? uint32_t(RangeBound)
1383-
: uint32_t(RangeBound + 1);
1381+
Offset = llvm::hlsl::rootsig::updateOngoingOffset(
1382+
Offset, Clause->NumDescriptors, Clause->Offset);
13841383

13851384
// Compute the register bounds and track resource binding
13861385
uint32_t LowerBound(Clause->Reg.Number);

llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ LLVM_ABI bool verifyLOD(float LOD);
4545
LLVM_ABI bool verifyBoundOffset(uint32_t Offset);
4646
LLVM_ABI bool verifyNoOverflowedOffset(uint64_t Offset);
4747
LLVM_ABI uint64_t computeRangeBound(uint32_t Offset, uint32_t Size);
48+
LLVM_ABI uint64_t updateOngoingOffset(uint64_t CurOffset,
49+
uint64_t NumDescriptors, uint64_t Offset);
4850

4951
} // namespace rootsig
5052
} // namespace hlsl

llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ extractShaderVisibility(MDNode *Node, unsigned int OpId) {
6868
return make_error<InvalidRSMetadataValue>("ShaderVisibility");
6969
}
7070

71-
static uint64_t updateOngoingOffset(uint64_t CurOfset, uint64_t NumDescriptors,
72-
uint64_t Offset) {
73-
// Append to the current offset if DescriptorTableOffsetAppend is set,
74-
// otherwise calculate the new Offset.
75-
return Offset == DescriptorTableOffsetAppend ? CurOfset + NumDescriptors
76-
: Offset + NumDescriptors;
77-
}
78-
7971
namespace {
8072

8173
// We use the OverloadVisit with std::visit to ensure the compiler catches if a
@@ -586,7 +578,6 @@ Error validateDescriptorTableRegisterOverflow(mcdxbc::DescriptorTable Table,
586578
if (!verifyNoOverflowedOffset(OffsetBound))
587579
return make_error<DescriptorRangeOverflowError>(
588580
RangeType, Range.BaseShaderRegister, Range.RegisterSpace);
589-
590581
Offset = updateOngoingOffset(Offset, Range.NumDescriptors,
591582
Range.OffsetInDescriptorsFromTableStart);
592583
}

llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ uint64_t computeRangeBound(uint32_t Offset, uint32_t Size) {
182182
return uint64_t(Offset) + uint64_t(Size) - 1;
183183
}
184184

185+
uint64_t updateOngoingOffset(uint64_t CurOffset, uint64_t NumDescriptors,
186+
uint64_t Offset) {
187+
// Append to the current offset if DescriptorTableOffsetAppend is set,
188+
// otherwise calculate the new Offset.
189+
return Offset == DescriptorTableOffsetAppend ? CurOffset + NumDescriptors
190+
: Offset + NumDescriptors;
191+
}
192+
185193
} // namespace rootsig
186194
} // namespace hlsl
187195
} // namespace llvm

0 commit comments

Comments
 (0)