Skip to content

Commit 1550b90

Browse files
Add back compat lit test suite, and download older dxil.dll's (microsoft#7705)
This PR adds new lit test suites, that build by downloading and unzipping 5 release packages. The release packages are a selection of historical packages that will be useful in later testing for validation back-compatibility. However, this data can also be used for other testing, and doesn't necessarily need to be restricted to older packages. For now, 5 releases have been included, including the latest 3 releases at the time of this writing. This PR then executes these test suites with an environment variable that points to the dxil.dll that was just downloaded, so that in the future, DxcDllExtValLoader can grab the dxil.dll path and initialize appropriately. This PR effectively sets up a test suite and an environment so that back compat work is possible. Adds some final touches on @damyanp's work. Fixes microsoft#7707 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 1d400c3 commit 1550b90

9 files changed

Lines changed: 108 additions & 12 deletions

File tree

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ stages:
1313
- stage: Build
1414
jobs:
1515
- job: Windows
16-
timeoutInMinutes: 120
16+
timeoutInMinutes: 165
1717

1818
pool:
1919
vmImage: windows-2022
@@ -48,7 +48,7 @@ stages:
4848
displayName: 'DXIL Execution Tests (Nuget WARP)'
4949
5050
- job: Nix
51-
timeoutInMinutes: 120
51+
timeoutInMinutes: 165
5252

5353
variables:
5454
macOS: macOS-latest

include/dxc/Test/DxcTestUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "dxc/Support/WinIncludes.h"
1515

16+
#include "dxc/Support/dxcapi.extval.h"
1617
#include "dxc/Support/dxcapi.use.h"
1718
#include "dxc/dxcapi.h"
1819
#include "llvm/ADT/ArrayRef.h"
@@ -175,7 +176,7 @@ class FileRunTestResult {
175176
PluginToolsPaths *pPluginToolsPaths = nullptr,
176177
LPCWSTR dumpName = nullptr);
177178
static FileRunTestResult
178-
RunFromFileCommands(LPCWSTR fileName, dxc::DxCompilerDllLoader &dllSupport,
179+
RunFromFileCommands(LPCWSTR fileName, dxc::SpecificDllLoader &dllSupport,
179180
PluginToolsPaths *pPluginToolsPaths = nullptr,
180181
LPCWSTR dumpName = nullptr);
181182
};

projects/dxilconv/unittests/DxilConvTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class DxilConvTest {
6767
END_TEST_METHOD()
6868

6969
private:
70-
dxc::DxCompilerDllLoader m_dllSupport;
70+
// this loader only loads dxilconv.dll
71+
dxc::SpecificDllLoader m_dllSupport;
7172
PluginToolsPaths m_TestToolPaths;
7273

7374
void DxilConvTestCheckFile(LPCWSTR path) {

tools/clang/test/CMakeLists.txt

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,95 @@ set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")
108108

109109
# HLSL Change Begin - Generate lit targets for test subdirectories.
110110

111+
# -------------------------------------------------------------------------
112+
# DXIL Backward Compatibility Section
113+
# -------------------------------------------------------------------------
114+
115+
# Define DXC releases as (NAME VERSION) pairs
116+
set(DXC_RELEASES
117+
dxc_2025_02_20 v1.8.2502
118+
dxc_2023_08_14 v1.7.2308
119+
dxc_2021_12_08 v1.6.2112
120+
)
121+
122+
# Download a DXC release
123+
function(add_released_dxc name version)
124+
ExternalProject_Add(${name}
125+
URL https://github.com/microsoft/DirectXShaderCompiler/releases/download/${version}/${name}.zip
126+
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/tools/clang/test/dxc_releases
127+
SOURCE_DIR ${CMAKE_BINARY_DIR}/tools/clang/test/dxc_releases/${version}/${name}
128+
CONFIGURE_COMMAND ""
129+
BUILD_COMMAND ""
130+
INSTALL_COMMAND ""
131+
)
132+
endfunction()
133+
134+
# Iterate over releases
135+
list(LENGTH DXC_RELEASES DXC_RELEASES_LENGTH)
136+
math(EXPR num_pairs "${DXC_RELEASES_LENGTH} / 2")
137+
math(EXPR loop_end "${num_pairs} - 1")
138+
foreach(i RANGE 0 ${loop_end})
139+
math(EXPR idx_name "${i}*2")
140+
math(EXPR idx_version "${i}*2 + 1")
141+
142+
list(GET DXC_RELEASES ${idx_name} name)
143+
list(GET DXC_RELEASES ${idx_version} version)
144+
145+
add_released_dxc(${name} ${version})
146+
147+
if(WIN32)
148+
# Determine target architecture for DXC binaries
149+
if(CMAKE_GENERATOR MATCHES "Visual Studio")
150+
# Multi-config generators (VS/Xcode)
151+
if(NOT DEFINED CMAKE_GENERATOR_PLATFORM)
152+
message(FATAL_ERROR "CMAKE_GENERATOR_PLATFORM not set for multi-config generator")
153+
endif()
154+
set(TARGET_ARCH ${CMAKE_GENERATOR_PLATFORM})
155+
else()
156+
# Single-config generators (Ninja, Makefiles)
157+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_PROCESSOR_LOWER)
158+
159+
if(SYSTEM_PROCESSOR_LOWER MATCHES "^(x86|i[3-6]86)$")
160+
set(TARGET_ARCH x86)
161+
elseif(SYSTEM_PROCESSOR_LOWER MATCHES "^(x64|amd64|x86_64)$")
162+
set(TARGET_ARCH x64)
163+
elseif(SYSTEM_PROCESSOR_LOWER MATCHES "^(arm64|aarch64)$")
164+
set(TARGET_ARCH arm64)
165+
elseif(SYSTEM_PROCESSOR_LOWER MATCHES "^arm")
166+
set(TARGET_ARCH arm)
167+
else()
168+
message(FATAL_ERROR "Unknown architecture: ${CMAKE_SYSTEM_PROCESSOR}")
169+
endif()
170+
endif()
171+
172+
# Path to dxil.dll for this release
173+
set(DXC_PATH ${CMAKE_BINARY_DIR}/tools/clang/test/dxc_releases/${version}/${name}/bin/${TARGET_ARCH}/dxil.dll)
174+
175+
# Create a lit target for this release
176+
add_lit_target("check-clang-${name}" "Running clang regression tests with ${name}\n"
177+
${CMAKE_CURRENT_SOURCE_DIR}
178+
PARAMS ${CLANG_TEST_PARAMS} DXC_DXIL_DLL_PATH=${DXC_PATH}
179+
skip_taef_exec=True
180+
DEPENDS ${CLANG_TEST_DEPS} ${name}
181+
ARGS ${CLANG_TEST_EXTRA_ARGS}
182+
)
183+
184+
# Ensure there is a top-level check-clang target
185+
if(NOT TARGET check-clang)
186+
add_custom_target(check-clang)
187+
endif()
188+
189+
# Make check-clang depend on this particular release's tests
190+
add_dependencies(check-clang "check-clang-${name}")
191+
192+
# Hook into check-all
193+
if (WIN32 AND TARGET check-all)
194+
add_dependencies(check-all "check-clang-${name}")
195+
endif()
196+
endif()
197+
endforeach()
198+
# -------------------------------------------------------------------------
199+
111200
set(CLANG_TEST_PARAMS
112201
${CLANG_TEST_PARAMS}
113202
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
@@ -122,8 +211,6 @@ add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
122211
FOLDER "Clang tests/Suites"
123212
)
124213

125-
# Manually generate targets that we need to expose in visual studio builds.
126-
127214
# The code below here _ONLY_ executes when building with Visual Studio or Xcode.
128215
if (NOT CMAKE_CONFIGURATION_TYPES)
129216
return()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# REQUIRES: dxc_dxil_dll_path
2+
# RUN: python -c "import os; print(os.environ['DXC_DXIL_DLL_PATH'])" | FileCheck %s
3+
# CHECK: dxil.dll

tools/clang/test/lit.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ for name in possibly_dangerous_env_vars:
9494
if name in config.environment:
9595
del config.environment[name]
9696

97+
dxc_dll_path = lit_config.params.get('DXC_DXIL_DLL_PATH', None)
98+
if dxc_dll_path and os.path.exists(dxc_dll_path):
99+
lit_config.note("Setting DXC_DXIL_DLL_PATH environment variable")
100+
config.environment.update({'DXC_DXIL_DLL_PATH' : dxc_dll_path})
101+
config.available_features.add("dxc_dxil_dll_path")
102+
97103
# Tweak the PATH to include the tools dir and the scripts dir.
98104
if clang_obj_root is not None:
99105
clang_tools_dir = getattr(config, 'clang_tools_dir', None)

tools/clang/unittests/HLSL/ValidationTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "dxc/Support/Global.h"
3535

3636
#include "dxc/DXIL/DxilShaderModel.h"
37-
#include "dxc/Support/dxcapi.extval.h"
3837
#include "dxc/Test/DxcTestUtils.h"
3938
#include "dxc/Test/HlslTestUtils.h"
4039

tools/clang/unittests/HLSLExec/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ find_package(D3D12 REQUIRED) # Used for ExecutionTest.cpp.
55

66
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
77

8-
set(DXCSUPPORT_DIR "${CMAKE_SOURCE_DIR}/lib/DxcSupport")
9-
108
add_clang_library(ExecHLSLTests SHARED
119
ExecutionTest.cpp
1210
ShaderOpTest.cpp

tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ FileRunCommandPart::RunFromPath(const std::string &toolPath,
12581258
#endif //_WIN32
12591259

12601260
class FileRunTestResultImpl : public FileRunTestResult {
1261-
dxc::DxCompilerDllLoader &m_support;
1261+
dxc::SpecificDllLoader &m_support;
1262+
dxc::DxcDllExtValidationLoader m_extval_support;
12621263
PluginToolsPaths *m_pPluginToolsPaths;
12631264
LPCWSTR m_dumpName = nullptr;
12641265
// keep track of virtual files for duration of this test (for all RUN lines)
@@ -1332,7 +1333,7 @@ class FileRunTestResultImpl : public FileRunTestResult {
13321333
}
13331334

13341335
public:
1335-
FileRunTestResultImpl(dxc::DxCompilerDllLoader &support,
1336+
FileRunTestResultImpl(dxc::SpecificDllLoader &support,
13361337
PluginToolsPaths *pPluginToolsPaths = nullptr,
13371338
LPCWSTR dumpName = nullptr)
13381339
: m_support(support), m_pPluginToolsPaths(pPluginToolsPaths),
@@ -1389,7 +1390,7 @@ FileRunTestResult FileRunTestResult::RunFromFileCommands(
13891390
}
13901391

13911392
FileRunTestResult FileRunTestResult::RunFromFileCommands(
1392-
LPCWSTR fileName, dxc::DxCompilerDllLoader &dllSupport,
1393+
LPCWSTR fileName, dxc::SpecificDllLoader &dllSupport,
13931394
PluginToolsPaths *pPluginToolsPaths /*=nullptr*/,
13941395
LPCWSTR dumpName /*=nullptr*/) {
13951396
FileRunTestResultImpl result(dllSupport, pPluginToolsPaths, dumpName);

0 commit comments

Comments
 (0)