Skip to content
Merged
Show file tree
Hide file tree
Changes from 163 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
0e8828c
refactoring
Jun 26, 2025
2edd215
refactoring
Jun 26, 2025
242545e
clean up
Jul 2, 2025
3f8dec4
format
Jul 2, 2025
3b1ce3b
formating
Jul 2, 2025
f5720af
fix import issues
Jul 4, 2025
ea54904
formating
Jul 4, 2025
a49aa19
refactoring
Jun 26, 2025
d90676f
init refactoring
Jun 26, 2025
a04eb9f
adding validation
Jul 2, 2025
5994b8f
clean
Jul 2, 2025
e8b14bf
implementing
Jul 4, 2025
8f40e83
finish implementing && fix tests
Jul 4, 2025
28350b2
fix issue
Jul 5, 2025
4fd2e0b
sync parent
Jul 5, 2025
e25ee87
sync parent
Jul 5, 2025
01a558b
add validation
Jul 7, 2025
881dd36
address comments
Jul 7, 2025
8779ee9
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
Jul 7, 2025
43eb04e
adding validation
Jul 8, 2025
c16f15b
fix test
Jul 8, 2025
f67bec1
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 8, 2025
d7b4cf4
format
Jul 8, 2025
c7d5be7
format
Jul 8, 2025
cc5afae
address changes
Jul 8, 2025
571a0ef
fix tests
Jul 8, 2025
974d4bc
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
Jul 8, 2025
403b546
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 8, 2025
aea75da
fix test
Jul 8, 2025
e0bc862
add preserved
Jul 8, 2025
b5a0b32
addressing comments
Jul 10, 2025
00a74af
Merge branch 'main' into validation/check-descriptors-are-bound
Jul 10, 2025
5ccb842
updating
Jul 11, 2025
5423aba
format
Jul 14, 2025
a7637a7
adding tests
Jul 14, 2025
da42c0c
clean up
Jul 14, 2025
5af9199
update
Jul 14, 2025
46294cb
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 15, 2025
91ff1bf
clean up
Jul 15, 2025
edb015d
address comments
Jul 15, 2025
5f8bbeb
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 15, 2025
9f3888e
adding root constants
Jul 15, 2025
8459d14
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 15, 2025
578a03b
clean
Jul 15, 2025
34deb3a
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 15, 2025
b4a0e16
moving code arround
Jul 17, 2025
49f3bf2
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 17, 2025
ef14638
clean
Jul 17, 2025
662c3a8
addressing comments
Jul 21, 2025
848501d
address comments
Jul 21, 2025
8d97116
format test
Jul 21, 2025
9c34f3f
fix test
Jul 21, 2025
24040a0
Merge branch 'validation/check-descriptors-are-bound' into validation…
Jul 22, 2025
2c30cd9
addressing comments
Jul 22, 2025
260633c
address comments
Jul 25, 2025
d42f156
Merge branch 'main' into validation/check-descriptors-are-bound
Jul 31, 2025
9ee3a4b
Merge branch 'main' into validation/check-descriptors-are-bound
Jul 31, 2025
6db6224
update code
Aug 1, 2025
04658b8
cleanup
Aug 1, 2025
adf3feb
address comments from inbelic
Aug 5, 2025
c95ce68
refactoring
Jun 26, 2025
af6aa53
add tests
Aug 5, 2025
29eb893
cleanup
Aug 5, 2025
ed4c553
clean
Aug 5, 2025
28fb609
clean up
Aug 6, 2025
fc338b5
Merge branch 'validation/overlapping-ranges' into validation/check-de…
Aug 6, 2025
f5b5b3e
clean
Aug 6, 2025
03d571a
clean?
Aug 6, 2025
76048d4
Merge branch 'validation/check-descriptors-are-bound' into validation…
Aug 6, 2025
7c9bd62
clean?
Aug 6, 2025
ef51048
format
Aug 6, 2025
21675e6
formating
Aug 6, 2025
849ff86
format
Aug 6, 2025
7a1bc21
format
Aug 6, 2025
403972d
addressing comments from bogner and inbelic
joaosaffran-zz Aug 7, 2025
0f0435d
clean up
joaosaffran-zz Aug 7, 2025
e841a98
clean up
joaosaffran-zz Aug 7, 2025
ae6d67a
fix build
joaosaffran-zz Aug 7, 2025
41f32bd
fix tests
joaosaffran-zz Aug 8, 2025
47662f0
Merge branch 'validation/overlapping-ranges' into validation/check-de…
Aug 8, 2025
6da5fb0
format
Aug 8, 2025
108a7d5
Merge branch 'validation/check-descriptors-are-bound' into validation…
Aug 8, 2025
6f3d019
Merge branch 'main' into validation/overlapping-ranges
Aug 8, 2025
971ad57
Merge branch 'main' into validation/overlapping-ranges
Aug 8, 2025
db73d71
update
Aug 8, 2025
3b04c2d
address comment from inbelic
Aug 12, 2025
1ddffc3
address comments 2
Aug 12, 2025
1c10acf
fix merge mess
Aug 12, 2025
50e78d2
check if table mix samplers with others
Aug 12, 2025
aee4c56
validating register not overflow in table
Aug 12, 2025
7d1c13e
clean
Aug 12, 2025
85719af
format
Aug 12, 2025
cc304fd
format
Aug 12, 2025
3c28142
fix typo
Aug 12, 2025
81261ff
clean
Aug 12, 2025
db0008e
addressing comments from inbelic
Aug 12, 2025
0c72dcf
addressing inbelic comments
Aug 12, 2025
b4e5fb4
adding test
Aug 12, 2025
e5e73fe
address comments
Aug 12, 2025
ad0e1f3
address comments
Aug 12, 2025
d97eb7c
Merge branch 'validation/descriptor-tables' of https://github.com/joa…
Aug 13, 2025
8a4ee3c
fix comment
Aug 13, 2025
4a655a5
addressing comments from bogner
Aug 13, 2025
cc94561
addressing comments
Aug 13, 2025
98f48d2
address comments
Aug 13, 2025
eb334b8
refactoring
Aug 13, 2025
06c0da4
addressing comments
Aug 14, 2025
d58606f
Merge branch 'main' into validation/overlapping-ranges
Aug 14, 2025
74980c8
fix test
Aug 14, 2025
23537b5
addressing comment
Aug 14, 2025
d376abf
address comments
Aug 14, 2025
4abb40d
Merge branch 'validation/overlapping-ranges' into validation/check-de…
Aug 14, 2025
bb44eef
fix test
Aug 14, 2025
1cf2d1e
Merge branch 'main' into validation/check-descriptors-are-bound
Aug 14, 2025
373d871
clean up
Aug 14, 2025
d2750d7
format
Aug 14, 2025
777d544
Merge branch 'validation/check-descriptors-are-bound' into validation…
Aug 14, 2025
19e9baa
fix merge oopsi
Aug 14, 2025
708c4dc
format
Aug 14, 2025
a163d1b
clean up
Aug 15, 2025
4f120cc
clean up tests
Aug 15, 2025
def929f
Merge
Aug 15, 2025
d3349ce
clean up
Aug 15, 2025
bf5714d
moving code to where I think make sense
Aug 15, 2025
7cf513f
format
Aug 15, 2025
fe24637
format
Aug 15, 2025
6db8d93
refactoring to not create extra space
joaosaffran Aug 21, 2025
e3a65b6
remove copy of binding
joaosaffran Aug 21, 2025
e902add
making BindingRange const
joaosaffran Aug 21, 2025
9a6d64c
doing it again for other isBound
joaosaffran Aug 21, 2025
15b7592
adding DXILResourceTypeMap
joaosaffran Aug 21, 2025
11b9fb2
updating error messages and tests
joaosaffran Aug 21, 2025
0b8a997
Merge branch 'validation/check-descriptors-are-bound' into validation…
joaosaffran Aug 21, 2025
34619da
moving offset logic into shared validations
joaosaffran Aug 22, 2025
84d4579
refactoring suggested by inbelic
joaosaffran Aug 25, 2025
d2b4aea
adding multiple error messages
joaosaffran Aug 26, 2025
e2ba167
removing StartSlot
joaosaffran Aug 26, 2025
b395a47
removing unecessary code
joaosaffran Aug 26, 2025
17b425d
Merge branch 'main' into validation/textures-not-bind-root-signatures
joaosaffran Aug 28, 2025
f9c4b9c
refactoring
joaosaffran Aug 29, 2025
c7cedb4
adding comment
joaosaffran Aug 29, 2025
bf9b30c
refactoring isBound to return the bound reg
joaosaffran Aug 29, 2025
18e4c3d
formating
joaosaffran Aug 29, 2025
567bd15
Merge branch 'validation/textures-not-bind-root-signatures' into vali…
joaosaffran Aug 30, 2025
42518b2
clean up
joaosaffran Aug 30, 2025
f6abbf7
clean up
joaosaffran Aug 30, 2025
2971f5f
clean up
joaosaffran Aug 30, 2025
f0ed242
clean up: self review
joaosaffran Aug 30, 2025
a6a9fe9
clean up self review
joaosaffran Aug 30, 2025
3f83308
remove optional from type
joaosaffran Sep 10, 2025
8daa97b
changing small string size
joaosaffran Sep 10, 2025
79f1f48
fixing tests
joaosaffran Sep 10, 2025
3d10d92
removing type from handlefrombinding
joaosaffran Sep 10, 2025
f596ad5
Merge branch 'main' into validation/textures-not-bind-root-signatures
joaosaffran Sep 10, 2025
55c2b96
renamig tests
joaosaffran Sep 10, 2025
d1c31f1
Merge branch 'validation/textures-not-bind-root-signatures' of https:…
joaosaffran Sep 10, 2025
75d74ed
Merge branch 'validation/textures-not-bind-root-signatures' into vali…
joaosaffran Sep 10, 2025
fbf6776
refactoring to use existing funcs
joaosaffran Sep 10, 2025
5f429d2
Merge branch 'main' into validation/descriptor-tables
joaosaffran Sep 10, 2025
5633433
clean up
joaosaffran Sep 10, 2025
ec10db8
Merge branch 'validation/descriptor-tables' of https://github.com/joa…
joaosaffran Sep 10, 2025
b42630a
clean up
joaosaffran Sep 11, 2025
bce1ef9
improve comment message
joaosaffran Sep 11, 2025
cf84fcf
clean up
joaosaffran Sep 11, 2025
e5976ee
making updateOngoingOffset shared
joaosaffran Sep 11, 2025
eb84e14
refactoring
joaosaffran Sep 11, 2025
6a3c2ab
formating
joaosaffran Sep 11, 2025
1327b74
Merge branch 'main' into validation/descriptor-tables
joaosaffran Sep 12, 2025
c2d39ed
addressing comments from bogner
joaosaffran Sep 17, 2025
592dc62
adding edge case test
joaosaffran Sep 17, 2025
f3253ed
changing frontend check back to what it was
joaosaffran Sep 17, 2025
d442625
removing some copies
joaosaffran Sep 18, 2025
f785d25
adding same test as frontend
joaosaffran Sep 20, 2025
eefd22c
refactor to copy frontend
Sep 24, 2025
0c508d8
Merge branch 'main' into validation/descriptor-tables
Sep 24, 2025
b188df1
fix test and change error message
Sep 24, 2025
dabb9cd
format
joaosaffran Sep 24, 2025
0e08cea
format
joaosaffran Sep 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,93 @@ class RootSignatureValidationError
}
};

class OffsetOverflowError : public ErrorInfo<OffsetOverflowError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing needed for this PR as you're just following the established pattern, but we should probably come back and take a look at this error heirarchy at some point - I'm not really convinced we need this many distinct errors given all we ever do with them is print the error message (as opposed to handling specific errors in some way). We might be able to simplify these to something only a bit more structured than a StringError without any real loss to functionality or readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created an issue to check this in the future: #159429

public:
static char ID;
dxil::ResourceClass Type;
uint32_t Register;
uint32_t Space;

OffsetOverflowError(dxil::ResourceClass Type, uint32_t Register,
uint32_t Space)
: Type(Type), Register(Register), Space(Space) {}

void log(raw_ostream &OS) const override {
OS << "Cannot append range with implicit lower bound after an unbounded "
"range "
<< getResourceClassName(Type) << "(register=" << Register
<< ", space=" << Space << ").";
}

std::error_code convertToErrorCode() const override {
return llvm::inconvertibleErrorCode();
}
};

class ShaderRegisterOverflowError
: public ErrorInfo<ShaderRegisterOverflowError> {
public:
static char ID;
dxil::ResourceClass Type;
uint32_t Register;
uint32_t Space;

ShaderRegisterOverflowError(dxil::ResourceClass Type, uint32_t Register,
uint32_t Space)
: Type(Type), Register(Register), Space(Space) {}

void log(raw_ostream &OS) const override {
OS << "Overflow for shader register range: " << getResourceClassName(Type)
<< "(register=" << Register << ", space=" << Space << ").";
}

std::error_code convertToErrorCode() const override {
return llvm::inconvertibleErrorCode();
}
};

class DescriptorRangeOverflowError
: public ErrorInfo<DescriptorRangeOverflowError> {
public:
static char ID;
dxil::ResourceClass Type;
uint32_t Register;
uint32_t Space;

DescriptorRangeOverflowError(dxil::ResourceClass Type, uint32_t Register,
uint32_t Space)
: Type(Type), Register(Register), Space(Space) {}

void log(raw_ostream &OS) const override {
OS << "Overflow for descriptor range: " << getResourceClassName(Type)
<< "(register=" << Register << ", space=" << Space << ").";
}

std::error_code convertToErrorCode() const override {
return llvm::inconvertibleErrorCode();
}
};

class TableSamplerMixinError : public ErrorInfo<TableSamplerMixinError> {
public:
static char ID;
dxil::ResourceClass Type;
uint32_t Location;

TableSamplerMixinError(dxil::ResourceClass Type, uint32_t Location)
: Type(Type), Location(Location) {}

void log(raw_ostream &OS) const override {
OS << "Samplers cannot be mixed with other "
<< "resource types in a descriptor table, " << getResourceClassName(Type)
<< "(location=" << Location << ")";
}

std::error_code convertToErrorCode() const override {
return llvm::inconvertibleErrorCode();
}
};

class GenericRSMetadataError : public ErrorInfo<GenericRSMetadataError> {
public:
LLVM_ABI static char ID;
Expand Down
87 changes: 87 additions & 0 deletions llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ namespace rootsig {
char GenericRSMetadataError::ID;
char InvalidRSMetadataFormat::ID;
char InvalidRSMetadataValue::ID;
char TableSamplerMixinError::ID;
char ShaderRegisterOverflowError::ID;
char OffsetOverflowError::ID;
char DescriptorRangeOverflowError::ID;

template <typename T> char RootSignatureValidationError<T>::ID;

static std::optional<uint32_t> extractMdIntValue(MDNode *Node,
Expand Down Expand Up @@ -63,6 +68,14 @@ extractShaderVisibility(MDNode *Node, unsigned int OpId) {
return make_error<InvalidRSMetadataValue>("ShaderVisibility");
}

static uint64_t updateOngoingOffset(uint64_t CurOfset, uint64_t NumDescriptors,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
static uint64_t updateOngoingOffset(uint64_t CurOfset, uint64_t NumDescriptors,
static uint64_t updateOngoingOffset(uint64_t CurOffset, uint64_t NumDescriptors,

Is this function required? I think we could just use the OffsetBound below in the same way as the front-end? Or we can make the function shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this function to a common place and updated the frontend to use it. I wasn't able to get the correct behaviour by copying frontend's update function. The test rootsignature-validation-fail-appending-overflow.ll, was failing with it.
If you have something you would like me to try, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit concerned that the change to the frontend to use this function doesn't also include a test change - the frontend's original logic was simple saturation, and this behaviour is not the same as that. Are we missing test coverage in the frontend that would show this fixing a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the frontend has all tests covered. I spent sometime checking for equivalent errors for the tests I've added, here are the mappings I've found:

  • llvm/test/CodeGen/DirectX/rootsignature-validation-fail-appending-overflow.ll = RootSignature-resource-ranges-err.hlsl#append_to_unbound_signature
  • llvm/test/CodeGen/DirectX/rootsignature-validation-fail-offset-overflow.ll = RootSignature-resource-ranges-err.hlsl#direct_offset_overflow_signature
  • llvm/test/CodeGen/DirectX/rootsignature-validation-fail-register-overflow.ll = RootSignature-err.hlsl#basic_validation_0
  • llvm/test/CodeGen/DirectX/rootsignature-validation-fail-sampler-mix.ll =RootSignature-resource-ranges-err.hlsl#mixed_resource_table

@inbelic, let me know if you think otherwise.

Copy link
Contributor

@inbelic inbelic Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do it more like this: #153276 (comment).

To Justin's point though, I think we are missing a test-case for something like:

DescriptorTable(
  CBV(u0, offset = 2^32 - 3), numDescriptors = 4), // Overflows
  CBV(u1) // Appending to overflow
)

which would only report the first overflow and not the second because the offset will be truncated to 1 when converted to a uint32_t, when using updateOngoingOffset. It should report both when using the original frontend method.

uint64_t Offset) {
// Append to the current offset if DescriptorTableOffsetAppend is set,
// otherwise calculate the new Offset.
return Offset == DescriptorTableOffsetAppend ? CurOfset + NumDescriptors
: Offset + NumDescriptors;
}

namespace {

// We use the OverloadVisit with std::visit to ensure the compiler catches if a
Expand Down Expand Up @@ -515,6 +528,72 @@ Error MetadataParser::parseRootSignatureElement(mcdxbc::RootSignatureDesc &RSD,
llvm_unreachable("Unhandled RootSignatureElementKind enum.");
}

Error validateDescriptorTableSamplerMixin(mcdxbc::DescriptorTable Table,
uint32_t Location) {
bool HasSampler = false;
bool HasOtherRangeType = false;
dxil::ResourceClass OtherRangeType;

for (const mcdxbc::DescriptorRange &Range : Table.Ranges) {
dxil::ResourceClass RangeType =
static_cast<dxil::ResourceClass>(Range.RangeType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast does nothing - Range.RangeType is a dxil::ResourceClass.


if (RangeType == dxil::ResourceClass::Sampler) {
HasSampler = true;
} else {
HasOtherRangeType = true;
OtherRangeType = RangeType;
}
}

// Samplers cannot be mixed with other resources in a descriptor table.
if (HasSampler && HasOtherRangeType)
return make_error<TableSamplerMixinError>(OtherRangeType,
Location);
return Error::success();
}

Error validateDescriptorTableRegisterOverflow(mcdxbc::DescriptorTable Table,
uint32_t Location) {
uint64_t Offset = 0;

for (const mcdxbc::DescriptorRange &Range : Table.Ranges) {
// Validation of NumDescriptors should have happened by this point.
if (Range.NumDescriptors <= 0)
continue;
Comment on lines 566 to 568
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is being added here for 2 reasons: 1) The equivalent implementation of this function in the frontend makes this check, so I wanna make sure we have the same assumptions when running this logic; 2) There are tests that require Range.NumDescriptors to be 0, those test check other parts of the code, since this code is accumulating multiple errors, this check needs to be here to avoid breaking such tests.

I am open to review it, if you have a better approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The continue is probably fine here for the reasons you describe, but why are we checking <= 0? Since NumDescriptors is unsigned, wouldn't checking == 0 make more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, missed that. Thanks

const dxil::ResourceClass &RangeType =
static_cast<dxil::ResourceClass>(Range.RangeType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another no-op cast


if (Range.OffsetInDescriptorsFromTableStart != DescriptorTableOffsetAppend)
Offset = Range.OffsetInDescriptorsFromTableStart;

if (!verifyNoOverflowedOffset(Offset))
return make_error<OffsetOverflowError>(RangeType,
Range.BaseShaderRegister,
Range.RegisterSpace);

const uint64_t RangeBound = llvm::hlsl::rootsig::computeRangeBound(
Range.BaseShaderRegister, Range.NumDescriptors);

if (!verifyNoOverflowedOffset(RangeBound))
return make_error<ShaderRegisterOverflowError>(
RangeType, Range.BaseShaderRegister,
Range.RegisterSpace);

const uint64_t OffsetBound =
llvm::hlsl::rootsig::computeRangeBound(Offset, Range.NumDescriptors);

if (!verifyNoOverflowedOffset(OffsetBound))
return make_error<DescriptorRangeOverflowError>(
RangeType, Range.BaseShaderRegister, Range.RegisterSpace);

Offset = updateOngoingOffset(Offset, Range.NumDescriptors,
Range.OffsetInDescriptorsFromTableStart);
}

return Error::success();
}

Error MetadataParser::validateRootSignature(
const mcdxbc::RootSignatureDesc &RSD) {
Error DeferredErrs = Error::success();
Expand Down Expand Up @@ -588,6 +667,14 @@ Error MetadataParser::validateRootSignature(
joinErrors(std::move(DeferredErrs),
make_error<RootSignatureValidationError<uint32_t>>(
"DescriptorFlag", Range.Flags));

if (Error Err =
validateDescriptorTableSamplerMixin(Table, Info.Location))
DeferredErrs = joinErrors(std::move(DeferredErrs), std::move(Err));

if (Error Err =
validateDescriptorTableRegisterOverflow(Table, Info.Location))
DeferredErrs = joinErrors(std::move(DeferredErrs), std::move(Err));
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }

!dx.rootsignatures = !{!2} ; list of function/root signature pairs
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
!3 = !{ !5 } ; list of root signature elements
!5 = !{ !"DescriptorTable", i32 0, !6, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20 }
!3 = !{ !5, !21 } ; list of root signature elements
!5 = !{ !"DescriptorTable", i32 0, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20 }
!21 = !{ !"DescriptorTable", i32 0,!6, !8, !9 }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor is necessary, because this test was mixing samplers and non samplers in a single descriptor table, which is not allowed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!21 = !{ !"DescriptorTable", i32 0,!6, !8, !9 }
!21 = !{ !"DescriptorTable", i32 0, !6, !8, !9 }


; typedef enum D3D12_DESCRIPTOR_RANGE_FLAGS {
; NONE = 0,
Expand Down Expand Up @@ -53,37 +54,20 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!20 = !{ !"UAV", i32 5, i32 1, i32 15, i32 5, i32 65540 }

;DXC:- Name: RTS0
;DXC-NEXT: Size: 380
;DXC-NEXT: Size: 400
;DXC-NEXT: RootSignature:
;DXC-NEXT: Version: 2
;DXC-NEXT: NumRootParameters: 1
;DXC-NEXT: NumRootParameters: 2
;DXC-NEXT: RootParametersOffset: 24
;DXC-NEXT: NumStaticSamplers: 0
;DXC-NEXT: StaticSamplersOffset: 380
;DXC-NEXT: StaticSamplersOffset: 400
;DXC-NEXT: Parameters:
;DXC-NEXT: - ParameterType: 0
;DXC-NEXT: ShaderVisibility: 0
;DXC-NEXT: Table:
;DXC-NEXT: NumRanges: 14
;DXC-NEXT: RangesOffset: 44
;DXC-NEXT: NumRanges: 11
;DXC-NEXT: RangesOffset: 56
;DXC-NEXT: Ranges:
;DXC-NEXT: - RangeType: 3
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 1
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: - RangeType: 3
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 3
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
;DXC-NEXT: - RangeType: 3
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 4
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are all samplers, they are being moved to bellow

;DXC-NEXT: - RangeType: 0
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
Expand Down Expand Up @@ -155,3 +139,26 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
;DXC-NEXT: - ParameterType: 0
;DXC-NEXT: ShaderVisibility: 0
;DXC-NEXT: Table:
;DXC-NEXT: NumRanges: 3
;DXC-NEXT: RangesOffset: 328
;DXC-NEXT: Ranges:
;DXC-NEXT: - RangeType: 3
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 1
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: - RangeType: 3
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 3
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
;DXC-NEXT: - RangeType: 3
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 4
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,40 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }

!dx.rootsignatures = !{!2} ; list of function/root signature pairs
!2 = !{ ptr @main, !3, i32 1 } ; function, root signature
!3 = !{ !5 } ; list of root signature elements
!5 = !{ !"DescriptorTable", i32 0, !6, !7 }
!3 = !{ !5, !8 } ; list of root signature elements
!5 = !{ !"DescriptorTable", i32 0, !6 }
!6 = !{ !"Sampler", i32 1, i32 1, i32 0, i32 -1, i32 1 }
!8 = !{ !"DescriptorTable", i32 0, !7 }
!7 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 3 }


; DXC: - Name: RTS0
; DXC-NEXT: Size: 84
; DXC-NEXT: Size: 104
; DXC-NEXT: RootSignature:
; DXC-NEXT: Version: 1
; DXC-NEXT: NumRootParameters: 1
; DXC-NEXT: NumRootParameters: 2
; DXC-NEXT: RootParametersOffset: 24
; DXC-NEXT: NumStaticSamplers: 0
; DXC-NEXT: StaticSamplersOffset: 84
; DXC-NEXT: StaticSamplersOffset: 104
; DXC-NEXT: Parameters:
; DXC-NEXT: - ParameterType: 0
; DXC-NEXT: ShaderVisibility: 0
; DXC-NEXT: Table:
; DXC-NEXT: NumRanges: 2
; DXC-NEXT: RangesOffset: 44
; DXC-NEXT: NumRanges: 1
; DXC-NEXT: RangesOffset: 56
; DXC-NEXT: Ranges:
; DXC-NEXT: - RangeType: 3
; DXC-NEXT: NumDescriptors: 1
; DXC-NEXT: BaseShaderRegister: 1
; DXC-NEXT: RegisterSpace: 0
; DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
; DXC-NEXT: - RangeType: 1
; DXC-NEXT: - ParameterType: 0
; DXC-NEXT: ShaderVisibility: 0
; DXC-NEXT: Table:
; DXC-NEXT: NumRanges: 1
; DXC-NEXT: RangesOffset: 84
; DXC-NEXT: Ranges:
; DXC-NEXT: - RangeType: 1
; DXC-NEXT: NumDescriptors: 5
; DXC-NEXT: BaseShaderRegister: 1
; DXC-NEXT: RegisterSpace: 10
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; This test check if a resource is implicitly overflowing. That means, it is appending a resource after an unbounded range.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
; This test check if a resource is implicitly overflowing. That means, it is appending a resource after an unbounded range.
; This test checks if a resource is implicitly overflowing. That means, it is appending a resource after an unbounded range.


; CHECK: error: Cannot append range with implicit lower bound after an unbounded range UAV(register=0, space=0).

@TB.str = private unnamed_addr constant [3 x i8] c"TB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!3}
!3 = !{!"DescriptorTable", i32 0, !4, !5}
!4 = !{!"UAV", i32 -1, i32 1, i32 0, i32 2, i32 0}
!5 = !{!"UAV", i32 1, i32 0, i32 0, i32 -1, i32 0}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: error: Overflow for descriptor range: UAV(register=0, space=0)
@TB.str = private unnamed_addr constant [3 x i8] c"TB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!3}
!3 = !{!"DescriptorTable", i32 0, !4, !5}
!4 = !{!"UAV", i32 100, i32 0, i32 0, i32 4294967294, i32 0}
!5 = !{!"UAV", i32 1, i32 101, i32 0, i32 10, i32 0}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: error: Overflow for shader register range: UAV(register=4294967295, space=0)
@TB.str = private unnamed_addr constant [3 x i8] c"TB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!3}
!3 = !{!"DescriptorTable", i32 0, !4}
!4 = !{!"UAV", i32 100, i32 4294967295, i32 0, i32 -1, i32 0}
Loading
Loading