Skip to content

Commit 7b9f3f1

Browse files
authored
Fix handling of device features for DX (#223)
Previously this code was creating a merged feature set for WARP and the available device. This instead only configures the features for the native device when not using WARP, and only configures WARPs features when you are using WARP.
1 parent bab36f9 commit 7b9f3f1

File tree

2 files changed

+54
-35
lines changed

2 files changed

+54
-35
lines changed

test/Feature/CBuffer/arrays-64bit.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ DescriptorSets:
6666
# https://github.com/llvm/llvm-project/issues/110722
6767
# XFAIL: Clang
6868

69+
# REQUIRES: Double, Int64
6970
# RUN: split-file %s %t
7071
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
7172
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

test/lit.cfg.py

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,44 @@
4545
ToolSubst("imgdiff", FindTool("imgdiff"))
4646
]
4747

48+
def setDeviceFeatures(config, device, compiler):
49+
API = device['API']
50+
config.available_features.add(API)
51+
if "Microsoft Basic Render Driver" in device['Description']:
52+
config.available_features.add("%s-WARP" % API)
53+
if "Intel" in device['Description']:
54+
config.available_features.add("%s-Intel" % API)
55+
if "NVIDIA" in device['Description']:
56+
config.available_features.add("%s-NV" % API)
57+
if "AMD" in device['Description']:
58+
config.available_features.add("%s-AMD" % API)
59+
60+
config.available_features.add("%s-%s" % (compiler, API))
61+
62+
if device['API'] == "DirectX":
63+
if device['Features'].get('Native16BitShaderOpsSupported', False):
64+
config.available_features.add("Int16")
65+
config.available_features.add("Half")
66+
if device['Features'].get('DoublePrecisionFloatShaderOps', False):
67+
config.available_features.add("Double")
68+
if device['Features'].get('Int64ShaderOps', False):
69+
config.available_features.add("Int64")
70+
71+
if device['API'] == "Metal":
72+
config.available_features.add("Int16")
73+
config.available_features.add("Half")
74+
75+
if device['API'] == "Vulkan":
76+
if device['Features'].get('shaderInt16', False):
77+
config.available_features.add("Int16")
78+
if device['Features'].get('shaderFloat16', False):
79+
config.available_features.add("Half")
80+
if device['Features'].get('shaderFloat64', False):
81+
config.available_features.add("Double")
82+
if device['Features'].get('shaderInt64', False):
83+
config.available_features.add("Int64")
84+
4885
if config.offloadtest_test_warp:
49-
config.available_features.add("DirectX-WARP")
5086
tools.append(ToolSubst("%offloader", command=FindTool("offloader"), extra_args=["-warp"]))
5187
else:
5288
tools.append(ToolSubst("%offloader", FindTool("offloader")))
@@ -76,45 +112,27 @@
76112
api_query = os.path.join(config.llvm_tools_dir, "api-query")
77113
query_string = subprocess.check_output(api_query)
78114
devices = yaml.safe_load(query_string)
115+
target_device = None
79116

117+
# Find the right device to configure against
80118
for device in devices['Devices']:
119+
is_warp = "Microsoft Basic Render Driver" in device['Description']
81120
if device['API'] == "DirectX" and config.offloadtest_enable_d3d12:
82-
config.available_features.add("DirectX")
83-
config.available_features.add(HLSLCompiler + "-DirectX")
84-
if "Intel" in device['Description']:
85-
config.available_features.add("DirectX-Intel")
86-
87-
if device['Features'].get('Native16BitShaderOpsSupported', False):
88-
config.available_features.add("Int16")
89-
config.available_features.add("Half")
90-
if device['Features'].get('DoublePrecisionFloatShaderOps', False):
91-
config.available_features.add("Double")
92-
if device['Features'].get('Int64ShaderOps', False):
93-
config.available_features.add("Int64")
94-
121+
if is_warp and config.offloadtest_test_warp:
122+
target_device = device
123+
elif not is_warp and not config.offloadtest_test_warp:
124+
target_device = device
95125
if device['API'] == "Metal" and config.offloadtest_enable_metal:
96-
config.available_features.add("Metal")
97-
config.available_features.add(HLSLCompiler + "-Metal")
98-
99-
config.available_features.add("Int16")
100-
config.available_features.add("Half")
101-
126+
target_device = device
102127
if device['API'] == "Vulkan" and config.offloadtest_enable_vulkan:
103-
config.available_features.add("Vulkan")
104-
config.available_features.add(HLSLCompiler + "-Vulkan")
105-
if "NVIDIA" in device['Description']:
106-
config.available_features.add("Vulkan-NV")
107-
if "Intel" in device['Description']:
108-
config.available_features.add("Vulkan-Intel")
109-
110-
if device['Features'].get('shaderInt16', False):
111-
config.available_features.add("Int16")
112-
if device['Features'].get('shaderFloat16', False):
113-
config.available_features.add("Half")
114-
if device['Features'].get('shaderFloat64', False):
115-
config.available_features.add("Double")
116-
if device['Features'].get('shaderInt64', False):
117-
config.available_features.add("Int64")
128+
target_device = device
129+
# Bail from th eloop if we found a device that matches what we're looking for.
130+
if target_device:
131+
break
132+
133+
if not target_device:
134+
config.fatal('No target device found!')
135+
setDeviceFeatures(config, target_device, HLSLCompiler)
118136

119137
if os.path.exists(config.goldenimage_dir):
120138
config.substitutions.append(("%goldenimage_dir", config.goldenimage_dir))

0 commit comments

Comments
 (0)