Skip to content
Merged
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
5 changes: 5 additions & 0 deletions docs/buffer_bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ API-created CBVs mirror the observed inline console descriptor (mode 0, 16-byte

- **RDNA2 follows Mesa's GFX11 column**, not the GFX10 one: of 732 cases, 729 match GFX11 and 696 match GFX10.
Every GFX10 miss is an access that only partly fits, for example a raw buffer with `N = 3` read at offset 0.
- **The offset is not cut to 32 bits.** `index * stride` is a full product and `soffset` is added in 64 bits, so
index 0xFFFFFFFF with a 20-byte stride lands tens of GiB past the base and the access has no effect; in 32 bits it
would be the 20 bytes below the base, which modes 2 and 3 do not refuse. The translator treats an offset above
0xFFFFFFFF as out of range in every mode. Observed on hardware by five-star-recomp (commit `b9b57e2`), not measured
here; `tests/semantic/test_buffer_offset_wrap.py`.
- **In raw mode `soffset` is part of the checked offset.** The 3 cases that match neither column are raw reads at
offset 8 with `soffset` 8 and `N = 18`: 8 + 8 + 4 > 18, out of range on hardware.
- Loads and stores agree in every case.
Expand Down
174 changes: 165 additions & 9 deletions docs/d3d12_vulkan.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions docs/design.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/gameinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ The title reads gamepads only, so keyboard input has to arrive as a gamepad. Wit
shim attaches one SDL virtual gamepad named `Keyboard pad (Leonida)` and presses its buttons from the keyboard on
every poll. It then goes through the same path as a real pad: a device object, the next free player slot, readings,
reading and device callbacks, and UI navigation derived from its buttons. It reports no rumble motors. It is off by
default.
default. If SDL fails to attach or open the keyboard pad, the shim retries after one second while the pad is
enabled. Only the first failure in a continuous series is logged; turning the pad off and back on retries immediately.

| key | button |
|---|---|
Expand Down
21 changes: 17 additions & 4 deletions docs/shader_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ them and the state key is the record's state blob. The step is redone as a whole
`llvm-mc`, the wave64 mode or the flags change (`library_build.json`, written last), and a clash of both keys between
different modules fails it, as for the FSPX step. Graphics pipelines are not translated by the build.

### Resuming a compute-only batch on Linux
### Resuming a compute-only batch on Linux or native Windows

Run `tools/shader_library.py` with `--stages cs --disasm --jobs 2` and the carved containers, or select the
kind-6 hashes with `--compute-hashes`. For an unpacked library with its input `index.json`, use the compute batch.
Expand All @@ -187,14 +187,27 @@ kind-6 hashes with `--compute-hashes`. For an unpacked library with its input `i
python3 -I scripts/translate_pipeline_compute.py /path/to/unpacked --out /path/to/spirv/library --wave64-emulate
```

Use a dedicated output folder. The two workers run at nice 19. Each has a 768 MiB address-space limit and uses one
SPIRV-Tools process at a time (four processes total). `--jobs 1` uses a single worker and `--memory-mib` changes
the per-process limit. A rerun checks each module against its checksum and the listing, source container, FSPX
Use a dedicated output folder and a stable, trusted SPIRV-Tools installation on PATH. On Linux the two workers
run at nice 19. Each has a 768 MiB address-space limit and uses one SPIRV-Tools process at a time (four processes
total). On native Windows CPython, a BelowNormal coordinator and up to two gated workers run with a 768 MiB
**committed memory** cap per process (not total virtual address space). Each worker's kill-on-close Job permits
only itself and one tool process. The parent verifies job membership before sending work; the child rechecks the
effective limits. A no-share file open keeps the pack exclusive through worker exit. An incompatible outer Job
or a failed limit/lock check stops the build; there is no unbounded Windows mode. A hard stop can leave temporary
scratch files, but cannot partially replace the index. `--jobs 1` uses a single translating worker and
`--memory-mib` changes the per-process limit. A rerun checks each module against its checksum and the listing, source container, FSPX
sidecars, toolchain and wave mode. It retries failures. Only validated modules enter the runtime index. Its
atomic replacement follows both workers, so an interrupted run leaves the previous index readable. A partial
run exits nonzero and writes the reasons to `failures.json`, keyed by kind-6 and kind-0 SHA-256. Old modules
can still be used by a runtime that already opened the preceding index.

The coordinator and each shard explicitly apply `--wave64-emulate`, `--loop-limit`, `--descriptor-hash` and
`--compact-spirv`; requesting compaction requires both translator support and `spirv-opt`. The cache key includes
those settings, compiler sources, builder and tool hashes. `.compute-cache/worker-receipt.json` records the exact
options and input-name digest for each shard; compare its `index_sha256` with the actual published index before
using it. This is an audit file, not a completion marker. A pre-upgrade cache key is not reused as evidence for
a new builder.

Among 2,680 compute programs, 46 start with two 12-byte literal-bearing VOP3 NOP hash carriers. Their body
starts at byte 24. The three-record form starts at byte 36. The no-op measurements are in `docs/fspx.md`.
A hash literal can resemble an instruction. `shader_library.py` excludes both complete carrier records before
Expand Down
79 changes: 74 additions & 5 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,17 @@ if(BUILD_TESTING)
add_executable(pipeline_cache_store_test test/pipeline_cache_store_test.cpp)
add_test(NAME pipeline_cache_store COMMAND pipeline_cache_store_test)

# The per-pipeline journal files compute pipelines are kept in: naming, header check, atomic replacement.
add_executable(pipeline_cache_journal_test test/pipeline_cache_journal_test.cpp)
add_test(NAME pipeline_cache_journal COMMAND pipeline_cache_journal_test)

# The compile helper's request files and building markers (shims/d3d12_compile_helper.h): Win32 file calls only.
if(WIN32)
add_executable(compile_helper_test test/compile_helper_test.cpp)
target_compile_definitions(compile_helper_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
add_test(NAME compile_helper COMMAND compile_helper_test)
endif()

add_executable(xdxr_build_output_test test/xdxr_build_output_test.cpp)
add_test(NAME xdxr_build_output COMMAND xdxr_build_output_test)

Expand Down Expand Up @@ -1710,6 +1721,12 @@ if(BUILD_TESTING)
target_compile_options(active_input_test PRIVATE /W4 /permissive- /utf-8)
endif()
add_test(NAME active_input COMMAND active_input_test)
# The same keyboard connection lifecycle as the shim, with a fake clock and virtual-device backend only.
add_executable(keyboard_pad_retry_test test/keyboard_pad_retry_test.cpp)
if(MSVC)
target_compile_options(keyboard_pad_retry_test PRIVATE /W4 /permissive- /utf-8)
endif()
add_test(NAME keyboard_pad_retry COMMAND keyboard_pad_retry_test)
if(WIN32 AND TARGET gameinput_no_sdl_test)
add_test(NAME gameinput_no_sdl COMMAND gameinput_no_sdl_test)
# LEONIDA_INPUT_SCRIPT without SDL3: the scripted pad, its device callbacks and its readings on a fake clock.
Expand Down Expand Up @@ -1878,10 +1895,21 @@ if(TARGET Vulkan::Headers)
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)
# The submit lock's owner tracking, waiter count, submit handoff and compile gate (SubmitMutex), on the CPU.
if(WIN32)
add_executable(submit_mutex_test test/submit_mutex_test.cpp)
target_link_libraries(submit_mutex_test PRIVATE Vulkan::Headers)
target_compile_definitions(submit_mutex_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
if(MSVC)
target_compile_options(submit_mutex_test PRIVATE /W4 /permissive- /utf-8)
endif()
add_test(NAME submit_mutex COMMAND submit_mutex_test)
set_tests_properties(submit_mutex PROPERTIES TIMEOUT 60)
endif()

foreach(tool vk_harness vk_ps_sweep vk_texture_test vk_sampler_test vk_compute_test vk_store_test vk_pipeline_check vk_command_replay_test
vk_bindless_test vk_image_fuzz vk_descriptor_bench depth24_convert_test vk_predicate_capture_test vk_predicated_copy_test
vk_xdxr_build_test vk_queue_test vk_sandbox)
vk_xdxr_build_test vk_queue_test vk_sandbox vk_console_heap_gpu_test)
add_executable(${tool} test/${tool}.cpp)
target_link_libraries(${tool} PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS})
if(WIN32)
Expand Down Expand Up @@ -1969,7 +1997,7 @@ if(TARGET Vulkan::Headers)
# Self-checking Vulkan tests with no shaders or game data; each exits 77 without a Vulkan device (TEST-514).
# indirect_clamp is registered next to its own add_executable above, where tests/test_ctest_registration.py
# can see it.
foreach(test vk_command_replay vk_predicated_copy vk_predicate_capture vk_queue)
foreach(test vk_command_replay vk_predicated_copy vk_predicate_capture vk_queue vk_console_heap_gpu)
add_test(NAME ${test} COMMAND ${test}_test)
set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77)
endforeach()
Expand Down Expand Up @@ -2002,6 +2030,23 @@ if(TARGET Vulkan::Headers)
add_test(NAME vk_queue_query_sync COMMAND vk_queue_query_sync_test)
set_tests_properties(vk_queue_query_sync PROPERTIES SKIP_RETURN_CODE 77)
endif()
# Fence and queue teardown with submissions pending: a fence released after an unheld Signal, the bindless upload
# queue destroyed before another queue submits, the device-fault submit ring forgetting destroyed semaphores.
add_executable(vk_semaphore_lifetime_test test/vk_semaphore_lifetime_test.cpp)
target_link_libraries(vk_semaphore_lifetime_test PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS})
if(WIN32)
target_compile_definitions(vk_semaphore_lifetime_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
else()
find_package(Threads REQUIRED)
target_link_libraries(vk_semaphore_lifetime_test PRIVATE Threads::Threads)
endif()
if(MSVC)
target_compile_options(vk_semaphore_lifetime_test PRIVATE /W4 /permissive- /utf-8)
endif()
if(BUILD_TESTING)
add_test(NAME vk_semaphore_lifetime COMMAND vk_semaphore_lifetime_test)
set_tests_properties(vk_semaphore_lifetime PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 60)
endif()
# With LEONIDA_VK_VALIDATION=1: synchronization validation reports a missing barrier (and not a present one), so
# the other GPU tests' "0 validation errors" was checked by an active layer. 77 without validation or a device.
add_executable(vk_sync_validation_selftest test/vk_sync_validation_selftest.cpp)
Expand Down Expand Up @@ -2226,13 +2271,14 @@ if(TARGET Vulkan::Headers)
ENVIRONMENT "LEONIDA_VK_VALIDATION=1;VK_VALIDATE_SYNC=1")
# VulkanPresenter tracker lock / failed-submit rollback and capture-buffer WAW synchronization.
add_executable(vk_presenter_sync_test test/vk_presenter_sync_test.cpp)
target_link_libraries(vk_presenter_sync_test PRIVATE Vulkan::Headers user32)
target_link_libraries(vk_presenter_sync_test PRIVATE Vulkan::Headers user32 advapi32)
target_compile_definitions(vk_presenter_sync_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
if(MSVC)
target_compile_options(vk_presenter_sync_test PRIVATE /W4 /permissive- /utf-8)
endif()
add_test(NAME vk_presenter_sync COMMAND vk_presenter_sync_test)
set_tests_properties(vk_presenter_sync PROPERTIES SKIP_RETURN_CODE 77)
add_test(NAME vk_presenter_sparse_capture COMMAND vk_presenter_sync_test --sparse-capture)
set_tests_properties(vk_presenter_sync vk_presenter_sparse_capture PROPERTIES SKIP_RETURN_CODE 77)
set(conformance_src ${CMAKE_CURRENT_SOURCE_DIR}/../tools/conformance/native/src)
add_executable(vk_present_dump_test test/vk_present_dump_test.cpp
${conformance_src}/png_io.cpp ${conformance_src}/diagnostics.cpp)
Expand Down Expand Up @@ -2725,6 +2771,9 @@ if(TARGET Vulkan::Headers)
add_test(NAME d3d12_host_prefix COMMAND d3d12_existing_heap_test --host-prefix-only)
set_tests_properties(d3d12_host_prefix PROPERTIES SKIP_RETURN_CODE 77)
set_tests_properties(d3d12_existing_heap PROPERTIES SKIP_RETURN_CODE 77)
# LEONIDA_TEXTURE_REFRESH_ASYNC=1 (set by the test itself): a mapped plane's first submission reads its bytes.
add_test(NAME d3d12_mapped_plane_async COMMAND d3d12_existing_heap_test --mapped-plane-async)
set_tests_properties(d3d12_mapped_plane_async PROPERTIES SKIP_RETURN_CODE 77)
# The same with write watching off: the guarded cases only, the concurrent writers among them.
add_test(NAME d3d12_existing_heap_no_write_watch COMMAND d3d12_existing_heap_test)
set_tests_properties(d3d12_existing_heap_no_write_watch PROPERTIES SKIP_RETURN_CODE 77
Expand Down Expand Up @@ -2901,6 +2950,26 @@ if(TARGET Vulkan::Headers)
set_tests_properties(d3d12_indirect_group_budget PROPERTIES SKIP_RETURN_CODE 77
ENVIRONMENT "LEONIDA_INDIRECT_GROUP_BUDGET=2")
set_tests_properties(d3d12_indirect_dispatch_count PROPERTIES SKIP_RETURN_CODE 77)

# A single ordinary compute PSO and direct dispatch for cold/warm production journal comparisons;
# only the authored two-counter shader is shared with the indirect test.
set(_journal_second_spv ${CMAKE_CURRENT_BINARY_DIR}/generated/cs_compute_journal_v2.spv)
add_custom_command(OUTPUT ${_journal_second_spv}
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env vulkan1.2 -DTEST_COUNTER_TERM=2u
-o ${_journal_second_spv} ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/cs_indirect_dispatch_count.comp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/cs_indirect_dispatch_count.comp
COMMENT "Compiling the second authored compute journal control" VERBATIM)
# The first shader comes from gta6rt_indirect_count_shader: naming its output here too would give Make a second
# rule for the same file, and the two glslangValidator runs raced ("Failed to open file").
add_custom_target(gta6rt_compute_journal_shader DEPENDS ${_journal_second_spv})
add_executable(d3d12_compute_journal_test test/d3d12_compute_journal_test.cpp)
add_dependencies(d3d12_compute_journal_test gta6rt_indirect_count_shader gta6rt_compute_journal_shader)
target_link_libraries(d3d12_compute_journal_test PRIVATE gta6rt_d3d12_com)
target_compile_definitions(d3d12_compute_journal_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX
LEONIDA_TEST_COUNTER_SPV="${_indirect_count_spv}" LEONIDA_TEST_COUNTER_V2_SPV="${_journal_second_spv}")
target_compile_options(d3d12_compute_journal_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_compute_journal COMMAND d3d12_compute_journal_test)
set_tests_properties(d3d12_compute_journal PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 60)
endif()

# The cache vk_pipeline_check saves has to hit on the runtime's device (docs/pipeline_check.md): the test
Expand Down Expand Up @@ -3567,7 +3636,7 @@ if(TARGET Vulkan::Headers)
target_compile_definitions(d3d12_unmapped_vsharp_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX LEONIDA_VULKAN_DEVICE)
target_compile_options(d3d12_unmapped_vsharp_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_unmapped_vsharp COMMAND d3d12_unmapped_vsharp_test)
set_tests_properties(d3d12_unmapped_vsharp PROPERTIES SKIP_RETURN_CODE 77)
set_tests_properties(d3d12_unmapped_vsharp PROPERTIES SKIP_RETURN_CODE 77 ENVIRONMENT "LEONIDA_CONSOLE_FIX_US=0")
add_executable(d3d12_indirect_zero_test test/d3d12_indirect_zero_test.cpp)
target_link_libraries(d3d12_indirect_zero_test PRIVATE gta6rt_d3d12_com d3d12 dxgi)
target_compile_definitions(d3d12_indirect_zero_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
Expand Down
Loading
Loading