Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/gpu_test_results.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This page keeps a local record of GPU test runs. The project's public tracker is
[#166](https://github.com/ItsNotRexed/Leonida/issues/166) (one comment per GPU and driver);
post counts and pass/fail lines there, never game shaders, logs or private paths.

Name the Vulkan headers a run was built against: configure with `-DLEONIDA_VULKAN_HEADERS_FETCH=ON`, which uses the
repository's pinned Khronos Vulkan-Headers whatever else is installed, and quote the configure's `-- Vulkan headers:`
line in the entry. Other headers can change the counts ([testing.md](testing.md#build-the-test-programs)). Until
`CMAKE-VULKAN-HEADERS-PIN` the flag lost to any Vulkan headers already on the machine, so an older entry whose setup
names it may have been built against those instead.

| GPU | Driver, OS | Commit | build.py | check.py | run_gpu_tests.py | Failed | Entry |
|---|---|---|---|---|---|---|---|
| NVIDIA GeForce RTX 3080 Ti (Ampere), subgroup 32..32 | NVIDIA 616.92, Windows 11 26300.9974 | `d478a92` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 81/97 passed, 16 skipped (native); 97/97 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val | none in the subset | [local note](../gpu-test-results/RTX3080Ti-61692.txt) |
Expand Down
15 changes: 15 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ cmake --build runtime/build/linux --parallel

On macOS, add `-DVulkan_INCLUDE_DIR=/opt/homebrew/include` to the first command.

For a result you will post, add `-DLEONIDA_VULKAN_HEADERS_FETCH=ON` to the first command. It builds against the
repository's pinned Khronos Vulkan-Headers (downloaded once at configure time and hash-checked;
`-DFETCHCONTENT_SOURCE_DIR_VULKANHEADERS=<path>` uses a local copy instead), even when `VULKAN_SDK`,
`Vulkan_INCLUDE_DIR` or installed headers name others, so two records of the same GPU compare. When something else
would supply other headers in place of the pin (a dependency provider, or a stale download kept by
`FETCHCONTENT_FULLY_DISCONNECTED`), the configure fails instead. The headers decide what the test programs can ask the
driver for: built against conda-forge's Vulkan 1.3 headers instead of the pin, a Radeon 780M skipped `ps_texoff`,
`ps_texoff_forms` and `ps_texoff_implicit` (225/248 passed instead of 228/248,
[#14](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122653687)). Every configure names the
headers it uses in one line; quote it in the record:

```text
-- Vulkan headers: <build>/_deps/vulkanheaders-src/include (VK_HEADER_VERSION 363), the pin: Khronos Vulkan-Headers 6802bb4733b63ed5efd3adb308a6c885ef180ea1, hash-checked
```

The test programs and `scripts/run_gpu_tests.py` should come from the same commit. Some checks tolerate an older
binary (`unpinned_subgroup_skip`), but mixing them can report false failures in the compute tests: 28 `cs_*`
failures on both an RTX 5070 Ti Laptop and a Radeon 610M with the `426023a` script and `48ad23f` binaries, where
Expand Down
64 changes: 49 additions & 15 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1744,11 +1744,54 @@ if(BUILD_TESTING)
endif()

# GPU test and pipeline tools load Vulkan at run time, so only the Vulkan headers are needed at build time.
# Nothing is downloaded unless asked: set VULKAN_SDK, install the Vulkan headers, pass
# -DLEONIDA_VULKAN_HEADERS_FETCH=ON to download the pinned Khronos Vulkan-Headers release once at configure time
# (hash-checked), or pass -DFETCHCONTENT_SOURCE_DIR_VULKANHEADERS=<path> to use a local copy without downloading.
option(LEONIDA_VULKAN_HEADERS_FETCH "Download the pinned Khronos Vulkan-Headers release if no Vulkan headers are found" OFF)
# Nothing is downloaded unless asked. -DLEONIDA_VULKAN_HEADERS_FETCH=ON downloads the pinned Khronos Vulkan-Headers
# release once at configure time (hash-checked), and -DFETCHCONTENT_SOURCE_DIR_VULKANHEADERS=<path> uses a local
# copy of it without downloading. Either one wins over any other Vulkan headers on the machine (VULKAN_SDK,
# Vulkan_INCLUDE_DIR, conda-forge's vulkan-headers, /usr/include), so GPU test results built with it compare across
# machines. Without them the headers come from VULKAN_SDK, Vulkan_INCLUDE_DIR or an install. The configure names the
# headers it uses in a "Vulkan headers:" line (cmake/vulkan_headers_report.cmake).
option(LEONIDA_VULKAN_HEADERS_FETCH "Build against the pinned Khronos Vulkan-Headers release (downloaded once), even when other Vulkan headers are installed" OFF)
option(LEONIDA_REQUIRE_VULKAN "Fail the configure instead of warning when no Vulkan headers are found" OFF)
# The pinned Khronos Vulkan-Headers commit, which the "Vulkan headers:" line names, and its VK_HEADER_VERSION.
set(LEONIDA_VULKAN_HEADERS_PIN 6802bb4733b63ed5efd3adb308a6c885ef180ea1)
set(LEONIDA_VULKAN_HEADERS_PIN_VERSION 363)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/vulkan_headers_report.cmake")
set(leonida_vulkan_headers_origin FOUND)
if(LEONIDA_VULKAN_HEADERS_FETCH OR FETCHCONTENT_SOURCE_DIR_VULKANHEADERS)
# Before find_package(Vulkan): it would define Vulkan::Headers from whatever headers it finds first, and the pin
# would never be used. FindVulkan leaves an existing Vulkan::Headers alone.
include(FetchContent)
# OVERRIDE_FIND_PACKAGE: FetchContent_MakeAvailable never tries find_package(VulkanHeaders) in place of the pin, even
# with -DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS, and a later find_package(VulkanHeaders) gets the pin.
FetchContent_Declare(VulkanHeaders
# vulkan-sdk-1.4.363.0 (same commit pinned in .github/workflows/runtime.yml)
URL https://github.com/KhronosGroup/Vulkan-Headers/archive/${LEONIDA_VULKAN_HEADERS_PIN}.tar.gz
URL_HASH SHA256=9044fbb356160e43201dc2094acb44c8a906722a63a35f48fc0f051579db9bb6
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
set(VULKAN_HEADERS_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
set(VULKAN_HEADERS_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
set(VULKAN_HEADERS_ENABLE_MODULE OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(VulkanHeaders)
FetchContent_GetProperties(VulkanHeaders)
if(FETCHCONTENT_SOURCE_DIR_VULKANHEADERS)
set(leonida_vulkan_headers_origin SOURCE_DIR)
elseif(FETCHCONTENT_FULLY_DISCONNECTED)
# FetchContent reuses what is already in FETCHCONTENT_BASE_DIR and checks no archive.
set(leonida_vulkan_headers_origin PIN_CACHED)
else()
set(leonida_vulkan_headers_origin PIN)
endif()
# A dependency provider or an earlier FetchContent_Declare(VulkanHeaders) can still answer FetchContent_MakeAvailable
# with other headers; fail rather than build against them and call them the pin.
set(leonida_vk_include_dirs "")
if(TARGET Vulkan::Headers)
get_target_property(leonida_vk_include_dirs Vulkan::Headers INTERFACE_INCLUDE_DIRECTORIES)
endif()
leonida_vulkan_headers_check("${leonida_vk_include_dirs}" "${vulkanheaders_SOURCE_DIR}"
${leonida_vulkan_headers_origin})
endif()
# Also finds glslangValidator (Vulkan_GLSLANG_VALIDATOR_EXECUTABLE), which the shader-building tests below use.
find_package(Vulkan QUIET)
if(NOT TARGET Vulkan::Headers)
find_path(Vulkan_INCLUDE_DIR
Expand All @@ -1760,20 +1803,11 @@ if(NOT TARGET Vulkan::Headers)
set_target_properties(Vulkan::Headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIR}"
)
elseif(LEONIDA_VULKAN_HEADERS_FETCH OR FETCHCONTENT_SOURCE_DIR_VULKANHEADERS)
include(FetchContent)
FetchContent_Declare(VulkanHeaders
# vulkan-sdk-1.4.363.0 (same commit pinned in .github/workflows/runtime.yml)
URL https://github.com/KhronosGroup/Vulkan-Headers/archive/6802bb4733b63ed5efd3adb308a6c885ef180ea1.tar.gz
URL_HASH SHA256=9044fbb356160e43201dc2094acb44c8a906722a63a35f48fc0f051579db9bb6
DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
set(VULKAN_HEADERS_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
set(VULKAN_HEADERS_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
set(VULKAN_HEADERS_ENABLE_MODULE OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(VulkanHeaders)
endif()
endif()
if(TARGET Vulkan::Headers)
get_target_property(leonida_vk_include_dirs Vulkan::Headers INTERFACE_INCLUDE_DIRECTORIES)
leonida_vulkan_headers_report("${leonida_vk_include_dirs}" ${leonida_vulkan_headers_origin})
add_executable(vulkan_device_fault_test test/vulkan_device_fault_test.cpp)
target_link_libraries(vulkan_device_fault_test PRIVATE Vulkan::Headers)
add_test(NAME vulkan_device_fault COMMAND vulkan_device_fault_test)
Expand Down
3 changes: 2 additions & 1 deletion runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure
On Windows the build configures the CPU tests that do not need a GPU or game files, including the
root-signature forwarding test (`root_sig_test`) and the clear-command test. The Vulkan tools and
D3D12-over-Vulkan COM targets are built when Vulkan headers are found (via `VULKAN_SDK`, an installed
SDK, or `-DLEONIDA_VULKAN_HEADERS_FETCH=ON` to download the pinned Khronos Vulkan-Headers release):
SDK, or `-DLEONIDA_VULKAN_HEADERS_FETCH=ON` to download the pinned Khronos Vulkan-Headers release, which then wins
over any installed headers; the configure's `-- Vulkan headers:` line names the ones in use):

- `vk_harness` — hand-written RDNA2 shader programs on a real Vulkan device.
- `vk_texture_test`, `vk_compute_test`, `vk_store_test` — texture, LDS/compute, and buffer-store paths.
Expand Down
104 changes: 104 additions & 0 deletions runtime/cmake/vulkan_headers_report.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Names the Vulkan headers a configure builds against, in one STATUS line a GPU test record can quote:
# -- Vulkan headers: <include dir> (VK_HEADER_VERSION <n>), <where they come from>
# The headers decide what the GPU test tools can ask the driver for, so two records of the same GPU and driver differ
# when their headers do: rebuilt against conda-forge's Vulkan 1.3 headers instead of the pin, run_gpu_tests.py on a
# Radeon 780M skipped ps_texoff, ps_texoff_forms and ps_texoff_implicit (225/248 passed instead of 228/248).
# Kept in its own file so tests/test_cmake_vulkan_headers_pin.py can run it with `cmake -P`.

# Sets dir_var to the first of include_dirs (the INTERFACE_INCLUDE_DIRECTORIES of Vulkan::Headers) that holds
# vulkan/vulkan_core.h or vulkan/vulkan.h, or to "" when none does, and version_var to its VK_HEADER_VERSION, or to
# "unknown". Generator expressions such as $<BUILD_INTERFACE:...> (FetchContent's target) are unwrapped.
function(leonida_vulkan_headers_find include_dirs dir_var version_var)
set(dir "")
set(header "")
foreach(d IN LISTS include_dirs)
string(REGEX REPLACE "^\\$<BUILD_INTERFACE:(.*)>$" "\\1" d "${d}")
if(NOT d OR d MATCHES "^\\$<")
continue()
endif()
foreach(name vulkan_core.h vulkan.h)
if(EXISTS "${d}/vulkan/${name}")
set(dir "${d}")
set(header "${d}/vulkan/${name}")
break()
endif()
endforeach()
if(dir)
break()
endif()
endforeach()
set(version "unknown")
if(header)
file(STRINGS "${header}" line REGEX "^#define VK_HEADER_VERSION [0-9]+" LIMIT_COUNT 1)
if(line MATCHES "VK_HEADER_VERSION ([0-9]+)")
set(version "${CMAKE_MATCH_1}")
endif()
endif()
set(${dir_var} "${dir}" PARENT_SCOPE)
set(${version_var} "${version}" PARENT_SCOPE)
endfunction()

# include_dirs: the INTERFACE_INCLUDE_DIRECTORIES of Vulkan::Headers. origin: PIN (the hash-checked download of
# LEONIDA_VULKAN_HEADERS_PIN), PIN_CACHED (a copy already in FETCHCONTENT_BASE_DIR, which
# FETCHCONTENT_FULLY_DISCONNECTED=ON uses without downloading or checking an archive; leonida_vulkan_headers_check
# has confirmed only its version), SOURCE_DIR (FETCHCONTENT_SOURCE_DIR_VULKANHEADERS) or FOUND (anything else).
function(leonida_vulkan_headers_report include_dirs origin)
leonida_vulkan_headers_find("${include_dirs}" dir version)
if(NOT dir)
set(dir "${include_dirs}")
endif()
# string(CONCAT) on quoted pieces keeps a ";" in the text, which a list would split on.
if(origin STREQUAL "PIN")
set(what "the pin: Khronos Vulkan-Headers ${LEONIDA_VULKAN_HEADERS_PIN}, hash-checked")
elseif(origin STREQUAL "PIN_CACHED")
string(CONCAT what "the pinned version, cached source: Khronos Vulkan-Headers ${LEONIDA_VULKAN_HEADERS_PIN}; "
"archive not checked in this configure (FETCHCONTENT_FULLY_DISCONNECTED=ON)")
elseif(origin STREQUAL "SOURCE_DIR")
string(CONCAT what "from FETCHCONTENT_SOURCE_DIR_VULKANHEADERS: a local copy used in place of the pin, not "
"checked against it")
else()
string(CONCAT what "found on this machine, not the pin (-DLEONIDA_VULKAN_HEADERS_FETCH=ON builds against the "
"pinned Khronos Vulkan-Headers)")
endif()
message(STATUS "Vulkan headers: ${dir} (VK_HEADER_VERSION ${version}), ${what}")
endfunction()

# Fails the configure unless Vulkan::Headers (include_dirs) is the Vulkan-Headers copy FetchContent populated in
# source_dir (empty when it populated none). FetchContent_MakeAvailable(VulkanHeaders) can return other headers
# without populating anything: a dependency provider can answer it, and so can find_package() when an earlier
# FetchContent_Declare(VulkanHeaders) asked for that or when FETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS applies (an
# installed VulkanHeadersConfig.cmake with VK_HEADER_VERSION 111 was named as the pin that way). origin PIN or
# PIN_CACHED also needs the pinned version, LEONIDA_VULKAN_HEADERS_PIN_VERSION, which a build folder populated before
# the pin changed and configured with FETCHCONTENT_FULLY_DISCONNECTED=ON does not have.
function(leonida_vulkan_headers_check include_dirs source_dir origin)
leonida_vulkan_headers_find("${include_dirs}" dir version)
set(same FALSE)
if(dir AND source_dir)
file(REAL_PATH "${dir}" used)
file(REAL_PATH "${source_dir}/include" wanted)
if(used STREQUAL wanted)
set(same TRUE)
endif()
endif()
if(NOT same)
if(source_dir)
set(wanted "${source_dir}/include")
else()
set(wanted "a folder FetchContent populated (it populated none)")
endif()
message(FATAL_ERROR
"-DLEONIDA_VULKAN_HEADERS_FETCH=ON or FETCHCONTENT_SOURCE_DIR_VULKANHEADERS asks for the Vulkan headers in "
"${wanted}, but Vulkan::Headers includes \"${include_dirs}\". Something other than that download answered "
"FetchContent_MakeAvailable(VulkanHeaders): a dependency provider (CMAKE_PROJECT_TOP_LEVEL_INCLUDES) or an "
"earlier FetchContent_Declare(VulkanHeaders). Remove it, or configure without either of the two to build "
"against the installed headers.")
endif()
if((origin STREQUAL "PIN" OR origin STREQUAL "PIN_CACHED") AND
NOT version STREQUAL "${LEONIDA_VULKAN_HEADERS_PIN_VERSION}")
message(FATAL_ERROR
"${dir} has VK_HEADER_VERSION ${version}, but the pinned Khronos Vulkan-Headers ${LEONIDA_VULKAN_HEADERS_PIN} "
"are version ${LEONIDA_VULKAN_HEADERS_PIN_VERSION}, so ${source_dir} is not the pin. A dependency provider may "
"have populated it, or the build folder was populated before the pin changed and FETCHCONTENT_FULLY_DISCONNECTED "
"is ON, which keeps the old copy: configure once with -DFETCHCONTENT_FULLY_DISCONNECTED=OFF to download the pin.")
endif()
endfunction()
Loading
Loading