Skip to content

Commit fd9721e

Browse files
author
Greg Roth
authored
[lit] support dxil version check in lit test (#6343)
dxil-1-* will be added as available_features for lit config. There're 3 ways to use it. 1. Whole file limit use required dxil-1-8 2. Single RUN line with %if dxil-1-8 %{ %} 3. Whole folder with check dxil-1-8 to set config.unsupported in lit.local.cfg
2 parents 2c530ce + 71b84cc commit fd9721e

4 files changed

Lines changed: 50 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config.unsupported = 'dxil-1-8' not in config.available_features

tools/clang/test/CodeGenDXIL/hlsl/objects/NodeObjects/node-objects-metdata.hlsl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
// RUN: %dxc -T lib_6_8 %s | FileCheck %s --check-prefixes=MD
2-
// RUN: %dxc -T lib_6_8 -Od %s | FileCheck %s --check-prefixes=MD
3-
// RUN: %dxc -T lib_6_8 -Zi %s | FileCheck %s --check-prefixes=MD
4-
5-
// RUN: %dxc -T lib_6_8 -fcgl %s | FileCheck %s --check-prefix=FCGLMD
1+
// RUN: %if dxil-1-8 \
2+
// RUN: %{ \
3+
// RUN: %dxc -T lib_6_8 %s | FileCheck %s --check-prefixes=MD \
4+
// RUN: %}
5+
6+
// RUN: %if dxil-1-8 \
7+
// RUN: %{ \
8+
// RUN: %dxc -T lib_6_8 -Od %s | FileCheck %s --check-prefixes=MD \
9+
// RUN: %}
10+
11+
// RUN: %if dxil-1-8 \
12+
// RUN: %{ \
13+
// RUN: %dxc -T lib_6_8 -Zi %s | FileCheck %s --check-prefixes=MD \
14+
// RUN: %}
15+
16+
// RUN: %if dxil-1-8 \
17+
// RUN: %{ \
18+
// RUN: %dxc -T lib_6_8 -fcgl %s | FileCheck %s --check-prefix=FCGLMD \
19+
// RUN: %}
620

721
// Verify correct metadata annotations for different node shader input and outputs.
822

tools/clang/test/LitDXILValidation/illegalDXILOp.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ define void @main() {
3939

4040
%6 = call %dx.types.Handle @dx.op.annotateHandle2(i32 216, %dx.types.Handle %2, %dx.types.ResourceProperties { i32 32782, i32 0 }) ; AnnotateHandle(res,props) resource: SamplerComparisonState
4141

42-
; CHECK: error: DXILOpCode must be [0..258]. 1999981 specified.
42+
; CHECK: error: DXILOpCode must be [0..{{[0-9]+}}]. 1999981 specified.
4343
; CHECK: note: at '%7 = call float @dx.op.calculateLOD.f32(i32 1999981, %dx.types.Handle %5, %dx.types.Handle %6, float %3, float %4, float undef, i1 true)' in block '#0' of function 'main'.
4444

4545
%7 = call float @dx.op.calculateLOD.f32(i32 1999981, %dx.types.Handle %5, %dx.types.Handle %6, float %3, float %4, float undef, i1 true) ; CalculateLOD(handle,sampler,coord0,coord1,coord2,clamped)

tools/clang/test/lit.cfg

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,35 @@ if config.enable_backtrace == "1":
503503
if config.spirv:
504504
config.available_features.add("spirv")
505505

506+
# Check supported dxil version
507+
def get_dxil_version():
508+
result = subprocess.run([lit.util.which('dxc', llvm_tools_dir), "--version"], stdout=subprocess.PIPE)
509+
output = result.stdout.decode("utf-8")
510+
dxcPat = re.compile(r"(dxcompiler.dll|libdxcompiler.so|libdxcompiler.dylib): (?P<dxcMajor>[0-9]+)\.(?P<dxcMinor>[0-9]+).")
511+
m = dxcPat.search(output)
512+
dxcMajor = int(m.group("dxcMajor"))
513+
dxcMinor = int(m.group("dxcMinor"))
514+
515+
dxilPat = re.compile(r"; (dxil.dll|libdxil.so): (?P<dxilMajor>[0-9]+)\.(?P<dxilMinor>[0-9]+)")
516+
m = dxilPat.search(output)
517+
if None == m:
518+
return dxcMajor, dxcMinor
519+
dxilMajor = int(m.group("dxilMajor"))
520+
dxilMinor = int(m.group("dxilMinor"))
521+
if dxcMajor < dxilMajor:
522+
return dxcMajor, dxcMinor
523+
if dxcMajor > dxilMajor:
524+
return dxilMajor, dxilMinor
525+
if dxcMinor < dxilMinor:
526+
return dxcMajor, dxcMinor
527+
return dxilMajor, dxilMinor
528+
529+
dxilMajor, dxilMinor = get_dxil_version()
530+
if dxilMajor == 1:
531+
for i in range(0, dxilMinor + 1):
532+
config.available_features.add(f"dxil-1-{i}")
533+
534+
506535
# Check if we should run long running tests.
507536
if lit_config.params.get("run_long_tests", None) == "true":
508537
config.available_features.add("long_tests")

0 commit comments

Comments
 (0)