Skip to content

Commit 4c4a588

Browse files
authored
[lit] Add dxil version to available_features for lit (microsoft#6310)
This will allow lit test check dxil version to avoid running on unsupported dxil.dll.
1 parent 823125b commit 4c4a588

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

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/lit.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,33 @@ 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+
pat = re.compile(r"(dxcompiler.dll|libdxcompiler.so|libdxcompiler.dylib): (?P<dxcMajor>[0-9]+)\.(?P<dxcMinor>[0-9]+).*(; (dxil.dll|libdxil.so): (?P<dxilMajor>[0-9]+)\.(?P<dxilMinor>[0-9]+))?")
511+
m = pat.search(output)
512+
dxcMajor = int(m.group("dxcMajor"))
513+
dxcMinor = int(m.group("dxcMinor"))
514+
515+
if None == m.group("dxilMajor"):
516+
return dxcMajor, dxcMinor
517+
dxilMajor = int(m.group("dxilMajor"))
518+
dxilMinor = int(m.group("dxilMinor"))
519+
if dxcMajor < dxilMajor:
520+
return dxcMajor, dxcMinor
521+
if dxcMajor > dxilMajor:
522+
return dxilMajor, dxilMinor
523+
if dxcMinor < dxilMinor:
524+
return dxcMajor, dxcMinor
525+
return dxilMajor, dxilMinor
526+
527+
dxilMajor, dxilMinor = get_dxil_version()
528+
if dxilMajor == 1:
529+
for i in range(0, dxilMinor + 1):
530+
config.available_features.add(f"dxil-1-{i}")
531+
532+
506533
# Check if we should run long running tests.
507534
if lit_config.params.get("run_long_tests", None) == "true":
508535
config.available_features.add("long_tests")

0 commit comments

Comments
 (0)