Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ bool SemaHLSL::handleRootSignatureElements(
ReportError(Loc, 1, 0xfffffffe);
}

if (!llvm::hlsl::rootsig::verifyDescriptorRangeFlag(Version, Clause->Type,
Clause->Flags))
if (!llvm::hlsl::rootsig::verifyDescriptorRangeFlag(
Version, Clause->Type, llvm::to_underlying(Clause->Flags)))
ReportFlagError(Loc);
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ LLVM_ABI bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal);
LLVM_ABI bool verifyRangeType(uint32_t Type);
LLVM_ABI bool verifyDescriptorRangeFlag(uint32_t Version,
dxil::ResourceClass Type,
dxbc::DescriptorRangeFlags FlagsVal);
uint32_t FlagsVal);
LLVM_ABI bool verifyStaticSamplerFlags(uint32_t Version, uint32_t FlagsNumber);
LLVM_ABI bool verifyNumDescriptors(uint32_t NumDescriptors);
LLVM_ABI bool verifyMipLODBias(float MipLODBias);
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,7 @@ Error MetadataParser::validateRootSignature(
"NumDescriptors", Range.NumDescriptors));

if (!hlsl::rootsig::verifyDescriptorRangeFlag(
RSD.Version, Range.RangeType,
dxbc::DescriptorRangeFlags(Range.Flags)))
RSD.Version, Range.RangeType, Range.Flags))
DeferredErrs =
joinErrors(std::move(DeferredErrs),
make_error<RootSignatureValidationError<uint32_t>>(
Expand Down
12 changes: 11 additions & 1 deletion llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ bool verifyRegisterSpace(uint32_t RegisterSpace) {

bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal) {
using FlagT = dxbc::RootDescriptorFlags;
uint32_t LargestValue =
llvm::to_underlying(FlagT::LLVM_BITMASK_LARGEST_ENUMERATOR);
if (FlagsVal >= NextPowerOf2(LargestValue))
return false;

FlagT Flags = FlagT(FlagsVal);
if (Version == 1)
return Flags == FlagT::DataVolatile;
Expand All @@ -54,9 +59,14 @@ bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal) {
}

bool verifyDescriptorRangeFlag(uint32_t Version, dxil::ResourceClass Type,
dxbc::DescriptorRangeFlags Flags) {
uint32_t FlagsVal) {
using FlagT = dxbc::DescriptorRangeFlags;
uint32_t LargestValue =
llvm::to_underlying(FlagT::LLVM_BITMASK_LARGEST_ENUMERATOR);
if (FlagsVal >= NextPowerOf2(LargestValue))
return false;

FlagT Flags = FlagT(FlagsVal);
const bool IsSampler = (Type == dxil::ResourceClass::Sampler);

if (Version == 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: not opt -passes='print<dxil-root-signature>' %s -S -o - 2>&1 | FileCheck %s

target triple = "dxil-unknown-shadermodel6.0-compute"

; CHECK: error: Invalid value for DescriptorFlag: 66666
; CHECK-NOT: Root Signature Definitions

define void @main() #0 {
entry:
ret void
}
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, !7 }
!6 = !{ !"SRV", i32 1, i32 1, i32 0, i32 -1, i32 66666 }
!7 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 2 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; RUN: not opt -passes='print<dxil-root-signature>' %s -S -o - 2>&1 | FileCheck %s

target triple = "dxil-unknown-shadermodel6.0-compute"


; CHECK: error: Invalid value for RootDescriptorFlag: 666
; CHECK-NOT: Root Signature Definitions
define void @main() #0 {
entry:
ret void
}
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 = !{ !"RootCBV", i32 0, i32 1, i32 2, i32 666 }