Skip to content

Commit 6d1f9e5

Browse files
committed
Add options to configure warp-only and to select a warp version
This doesn't seem to quite be working, but it doesn't break anything...
1 parent f5c9fd3 commit 6d1f9e5

File tree

5 files changed

+67
-12
lines changed

5 files changed

+67
-12
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ else()
2323
endif()
2424
option(HLSLTEST_TEST_CLANG "Enable testing clang as the HLSL Compiler" ${default_HLSLTEST_TEST_CLANG})
2525

26+
option(HLSLTEST_WARP_ONLY "Only generate Warp configurations (useful for testing in VMs, Windows-only)." OFF)
27+
if (HLSLTEST_WARP_ONLY AND NOT WIN32)
28+
message(FATAL_ERROR "HLSLTEST_WARP_ONLY is only suppoted on Windows hosts!")
29+
endif()
30+
2631
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
2732
${CMAKE_CURRENT_BINARY_DIR}/include)
2833

@@ -81,6 +86,9 @@ if (WIN32)
8186
set(SKIP_INSTALL_EXPORT On)
8287
endif ()
8388
add_subdirectory(third-party/libpng)
89+
90+
include(Warp)
91+
8492
add_subdirectory(lib)
8593
add_subdirectory(tools)
8694

cmake/modules/Warp.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function(guess_nuget_arch output_var)
2+
if ((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))
3+
set(${output_var} "x64" PARENT_SCOPE)
4+
elseif ((CMAKE_GENERATOR_PLATFORM STREQUAL "x86") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x86"))
5+
set(${output_var} "x86" PARENT_SCOPE)
6+
elseif ((CMAKE_GENERATOR_PLATFORM MATCHES "ARM64.*") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARM64.*"))
7+
set(${output_var} "arm64" PARENT_SCOPE)
8+
elseif ((CMAKE_GENERATOR_PLATFORM MATCHES "ARM.*") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARM.*"))
9+
set(${output_var} "arm" PARENT_SCOPE)
10+
else()
11+
message(FATAL_ERROR "Failed to guess NuGet arch! (${CMAKE_GENERATOR_PLATFORM}, ${CMAKE_C_COMPILER_ARCHITECTURE_ID})")
12+
endif()
13+
endfunction()
14+
15+
function(setup_warp version)
16+
if (NOT WIN32)
17+
return()
18+
endif()
19+
20+
if (version STREQUAL "System")
21+
return()
22+
endif()
23+
24+
message(STATUS "Fetching WARP ${version}...")
25+
26+
set(WARP_ARCHIVE "${CMAKE_CURRENT_BINARY_DIR}/Microsoft.Direct3D.WARP.${version}.zip")
27+
file(DOWNLOAD "https://www.nuget.org/api/v2/package/Microsoft.Direct3D.WARP/${version}/" ${WARP_ARCHIVE})
28+
29+
guess_nuget_arch(NUGET_ARCH)
30+
31+
file(ARCHIVE_EXTRACT INPUT ${WARP_ARCHIVE} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/warp" PATTERNS *${NUGET_ARCH}*dll *${NUGET_ARCH}*pdb)
32+
33+
file(GLOB_RECURSE LIBS "${CMAKE_CURRENT_BINARY_DIR}/warp/*.dll" $<IF:$<CONFIG:DEBUG>,"${CMAKE_CURRENT_BINARY_DIR}/warp/*.pdb">)
34+
35+
foreach(FILE ${LIBS})
36+
get_filename_component(FILENAME ${FILE} NAME)
37+
file(COPY_FILE ${FILE} "${LLVM_RUNTIME_OUTPUT_INTDIR}/${FILENAME}")
38+
endforeach()
39+
40+
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/warp")
41+
endfunction()
42+
43+
set(WARP_VERSION "System" CACHE STRING "")
44+
setup_warp(${WARP_VERSION})

test/CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,21 @@ function(add_hlsltest_lit_suite suite)
131131
endfunction()
132132

133133
umbrella_lit_testsuite_begin(check-hlsl)
134-
foreach(platform ${platforms_to_test})
135-
set(TEST_${platform} True)
136-
add_hlsltest_lit_suite(${platform})
137134

138-
if (HLSLTEST_TEST_CLANG)
139-
set(FORCE_CLANG True)
140-
add_hlsltest_lit_suite(clang-${platform})
141-
set(FORCE_CLANG False)
142-
endif()
135+
if (NOT HLSLTEST_WARP_ONLY)
136+
foreach(platform ${platforms_to_test})
137+
set(TEST_${platform} True)
138+
add_hlsltest_lit_suite(${platform})
143139

144-
set(TEST_${platform} False)
145-
endforeach()
140+
if (HLSLTEST_TEST_CLANG)
141+
set(FORCE_CLANG True)
142+
add_hlsltest_lit_suite(clang-${platform})
143+
set(FORCE_CLANG False)
144+
endif()
145+
146+
set(TEST_${platform} False)
147+
endforeach()
148+
endif()
146149

147150
if (HLSLTEST_ENABLE_D3D12)
148151
set(TEST_d3d12 True)

tools/api-query/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
add_hlsl_tool(api-query
22
api-query.cpp)
33

4-
target_link_libraries(api-query PRIVATE LLVMSupport HLSLTestAPI)
4+
target_link_libraries(api-query PRIVATE LLVMSupport HLSLTestAPI)

tools/gpu-exec/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ add_hlsl_tool(gpu-exec
44

55
target_include_directories(gpu-exec PRIVATE SYSTEM BEFORE "${HLSLTEST_BINARY_DIR}/third-party/libpng/")
66

7-
target_link_libraries(gpu-exec PRIVATE LLVMSupport HLSLTestAPI png_static)
7+
target_link_libraries(gpu-exec PRIVATE LLVMSupport HLSLTestAPI png_static)

0 commit comments

Comments
 (0)