Skip to content

Commit

Permalink
[NFC] Add a %dxc_target substitution (#37)
Browse files Browse the repository at this point in the history
This replaces the `dxc` tool invocation with `%dxc_target` which includes the target-specific options (i.e. `-spirv`) so that we can simplify our RUN lines.

We still need special handling for Metal to convert dxil to metal libraries... for now.
  • Loading branch information
llvm-beanz authored Mar 3, 2025
1 parent fe131bd commit e47f542
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 92 deletions.
12 changes: 5 additions & 7 deletions test/Basic/DescriptorSets.test
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/DescriptorSets.hlsl %}
# RUN: %if DirectX %{ %offloader %t/DescriptorSets.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -Fo %t.spv %t/DescriptorSets.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/DescriptorSets.yaml %t.spv | FileCheck %s %}

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/DescriptorSets.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/DescriptorSets.yaml %t.metallib | FileCheck %s %}
# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/DescriptorSets.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/DescriptorSets.yaml %t.o | FileCheck %s

# CHECK: Data:
# CHECK-LABEL: Name: Out1
Expand Down
11 changes: 4 additions & 7 deletions test/Basic/Mandelbrot.test
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ DescriptorSets:
# REQUIRES: goldenimage
# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil -r Tex -o %t/output.png %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv -r Tex -o %t/output.png %}
# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib -r Tex -o %t/output.png %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o -r Tex -o %t/output.png
# RUN: imgdiff %t/output.png %goldenimage_dir/hlsl/Basic/Mandelbrot.png -rules %t/rules.yaml
12 changes: 4 additions & 8 deletions test/Basic/StructuredBuffer-SRV.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ DescriptorSets:
#--- end

# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# CHECK: Name: In
# CHECK: Data: [
Expand Down
13 changes: 5 additions & 8 deletions test/Basic/StructuredBuffer-packed.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# RUN: %if !Vulkan %{ %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl %}
# RUN: %if Vulkan %{ %dxc_target -T cs_6_0 -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.o %t/source.hlsl %}
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s


# CHECK: Data: [ 0, 1, 2, 3, 4, 0, 1, 2, 3, 6, 4, 0 ]
12 changes: 4 additions & 8 deletions test/Basic/StructuredBuffer.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,12 @@ DescriptorSets:
#--- end

# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s
# XFAIL: DXC-Vulkan

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}

# CHECK: Name: In
# CHECK: Data: [
# CHECK: 0x0,
Expand Down
11 changes: 4 additions & 7 deletions test/Basic/TestFloat32Pipeline.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# CHECK: Name: In
# CHECK: Format: Float32
Expand Down
11 changes: 4 additions & 7 deletions test/Basic/TestPipeline.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -E CSMain -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -E CSMain -spirv -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
# RUN: %if Metal %{ dxc -T cs_6_0 -E CSMain -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -E CSMain -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# CHECK: Name: In
# CHECK: Format: Int32
Expand Down
11 changes: 4 additions & 7 deletions test/Basic/cbuffer.test
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# CHECK: Name: In
# CHECK: Format: Int32
Expand Down
11 changes: 4 additions & 7 deletions test/Basic/idiv-edges.test
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# Divide by-zero behavior seems to be erradic enough to call it undefined...

Expand Down
12 changes: 4 additions & 8 deletions test/Basic/simple.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ DescriptorSets:
#--- end

# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/simple.hlsl %}
# RUN: %if DirectX %{ %offloader %t/simple.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -Fo %t.spv %t/simple.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/simple.yaml %t.spv | FileCheck %s %}

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/simple.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/simple.yaml %t.metallib | FileCheck %s %}
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/simple.hlsl
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/simple.yaml %t.o | FileCheck %s

# CHECK: Data:
# CHECK: Data: [ 4, 16, 36, 64 ]
12 changes: 5 additions & 7 deletions test/WaveOps/WaveActiveMax.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck --check-prefixes=CHECK,DX %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.1 -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s --check-prefixes=CHECK,VULKAN %}
# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s --check-prefixes=CHECK,METAL %}
# RUN: %if !Vulkan %{ %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl %}
# RUN: %if Vulkan %{ %dxc_target -T cs_6_0 -fspv-target-env=vulkan1.1 -Fo %t.o %t/source.hlsl %}
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# The behavior of this operation is consistent on Metal, so the test verifies that behavior.

Expand Down
14 changes: 6 additions & 8 deletions test/WaveOps/WaveActiveSum.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ DescriptorSets:

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.1 -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
# XFAIL: Vulkan-NV
# RUN: %if !Vulkan %{ %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl %}
# RUN: %if Vulkan %{ %dxc_target -T cs_6_0 -fspv-target-env=vulkan1.1 -Fo %t.o %t/source.hlsl %}
# RUN: %if Metal %{ mv %t.o %t.dxil %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.o %}
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
# XFAIL: Vulkan-NV

# CHECK: Data: [ 42, 42, 40, 40 ]
11 changes: 8 additions & 3 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,20 @@
else:
tools.append(ToolSubst("%offloader", FindTool("offloader")))

ExtraCompilerArgs = []
if config.offloadtest_enable_vulkan:
ExtraCompilerArgs = ['-spirv']

HLSLCompiler = ''
if config.offloadtest_test_clang:
if os.path.exists(config.offloadtest_dxc_dir):
tools.append(ToolSubst("dxc", FindTool("clang-dxc"), extra_args=["--dxv-path=%s" % config.offloadtest_dxc_dir]))
ExtraCompilerArgs.append("--dxv-path=%s" % config.offloadtest_dxc_dir)
tools.append(ToolSubst("%dxc_target", FindTool("clang-dxc"), extra_args=ExtraCompilerArgs))
else:
tools.append(ToolSubst("dxc", FindTool("clang-dxc")))
tools.append(ToolSubst("%dxc_target", FindTool("clang-dxc"), extra_args=ExtraCompilerArgs))
HLSLCompiler = 'Clang'
else:
tools.append(ToolSubst("dxc", config.offloadtest_dxc))
tools.append(ToolSubst("%dxc_target", config.offloadtest_dxc, extra_args=ExtraCompilerArgs))
HLSLCompiler = 'DXC'

config.available_features.add(HLSLCompiler)
Expand Down

0 comments on commit e47f542

Please sign in to comment.