Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ec7318d
native: translate GPU-selected heap textures through view tokens in c…
JB2WIN Nov 30, 2026
f58b05f
native: translate GPU-selected heap raw buffers through view tokens i…
JB2WIN Nov 30, 2026
32b9f26
native: judge the heap raw buffer address shape in the analysis
JB2WIN Nov 30, 2026
4a03faf
native: drop heap buffer candidates the lowering would refuse (loop, …
JB2WIN Nov 30, 2026
8353a6f
native: signal the heap token word budget by exception type, tidy com…
JB2WIN Nov 30, 2026
a1c1487
native: rejoin a wrapped comment on the heap token budget retry
JB2WIN Nov 30, 2026
9917aa9
native: address review of heap token textures (EXEC miss count, nativ…
JB2WIN Nov 30, 2026
cf0f40b
Merge upstream/main into native/heap-token-textures
JB2WIN Nov 30, 2026
b919436
Merge native/heap-token-textures into native/heap-token-buffers
JB2WIN Nov 30, 2026
f4cc6a0
docs: keep the revision 2 note next to revision 3 for heap token loads
JB2WIN Nov 30, 2026
d2805e7
native compute: one null word per dimension for heap token programs
JB2WIN Nov 30, 2026
a9438e2
d3d12 runtime: gate heap token programs behind X2W_D3D12_HEAP_TOKENS
JB2WIN Nov 30, 2026
35278e5
d3d12 runtime: heap token kinds and pending-id queue (no descriptors …
JB2WIN Nov 30, 2026
0730d80
d3d12 runtime: heap token queue survives failed reassignment and allo…
JB2WIN Nov 30, 2026
0f61075
d3d12 runtime: heap token region, view heap alias and root flag (no d…
JB2WIN Dec 1, 2026
eb9b1bf
d3d12 runtime: heap token review fixes (alias lifetime, opt-in-only r…
JB2WIN Dec 1, 2026
716139b
d3d12 runtime: heap token review fixes 2 (stride-derived test expecta…
JB2WIN Dec 1, 2026
b0cdcdc
d3d12 runtime: bind heap view tokens for translated compute (opt-in)
JB2WIN Dec 1, 2026
2d917cc
d3d12 runtime: heap token binding review fixes
JB2WIN Dec 1, 2026
7921950
Merge remote-tracking branch 'upstream/main' into native/heap-token-r…
JB2WIN Dec 1, 2026
eb79f7f
d3d12 runtime: heap token mirror review fixes (dead wrapper, comments)
JB2WIN Dec 1, 2026
0e9771f
Merge remote-tracking branch 'upstream/main' into native/heap-token-r…
JB2WIN Dec 1, 2026
4bc3d4a
ci: build native_heap_token_texture in the pr preset
JB2WIN Dec 1, 2026
20d33c5
Merge remote-tracking branch 'upstream/main' into native/heap-token-t…
JB2WIN Dec 1, 2026
e6c0227
Merge branch 'native/heap-token-textures' into native/heap-token-buffers
JB2WIN Dec 1, 2026
2c89fca
Merge branch 'native/heap-token-buffers' into native/heap-token-runtime
JB2WIN Dec 1, 2026
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
117 changes: 114 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ target_compile_options(x2w_build_rev PRIVATE /Zl)

# Desktop d3d12_xs.dll for the package DLLs' two named d3d12_xs root-signature imports.
add_library(d3d12_xs_shim SHARED src/d3d12_xs_shim.cpp src/d3d12x_device_slots.cpp
src/d3d12_xs_iids.cpp src/d3d12_xs_shim.def src/startup_stubs/d3d12_xs_device.cpp)
src/d3d12_xs_iids.cpp src/d3d12_xs_shim.def src/startup_stubs/d3d12_xs_device.cpp src/era_gpu_alias.cpp)
set_target_properties(d3d12_xs_shim PROPERTIES OUTPUT_NAME d3d12_xs)
target_include_directories(d3d12_xs_shim PRIVATE src)
target_compile_features(d3d12_xs_shim PRIVATE cxx_std_17)
Expand Down Expand Up @@ -2442,6 +2442,9 @@ add_test(NAME startup_translated_sampler_bindings COMMAND startup_translated_sam
add_test(NAME startup_translated_sampler_bindings_shared_axis_control
COMMAND startup_translated_sampler_bindings_check --mutate shared-axis)
set_tests_properties(startup_translated_sampler_bindings_shared_axis_control PROPERTIES WILL_FAIL TRUE)
add_test(NAME startup_translated_sampler_bindings_resource_text_control
COMMAND startup_translated_sampler_bindings_check --mutate resource-text)
set_tests_properties(startup_translated_sampler_bindings_resource_text_control PROPERTIES WILL_FAIL TRUE)
# Real-draw decision for title root signatures that index descriptor heaps directly
# (src/startup_stubs/heap_indexed_root.h), without a device. The mutated runs are the negative controls.
# Limits of the slot 70 refusal and "token" null census (src/startup_stubs/memory_srv_census.h), without a device.
Expand Down Expand Up @@ -2469,6 +2472,100 @@ endforeach()
add_executable(startup_heap_indexed_root_check tests/startup_heap_indexed_root_check.cpp)
target_include_directories(startup_heap_indexed_root_check PRIVATE src)
target_compile_features(startup_heap_indexed_root_check PRIVATE cxx_std_17)
# Heap token kinds table codes and the mirror's pending-id queue (src/startup_stubs/heap_token_kinds.h and
# heap_token_pending.h), without a device. Each mutated run must fail.
add_executable(heap_token_kinds_check tests/heap_token_kinds_check.cpp)
target_include_directories(heap_token_kinds_check PRIVATE src)
target_compile_features(heap_token_kinds_check PRIVATE cxx_std_17)
add_test(NAME heap_token_kinds COMMAND heap_token_kinds_check)
target_compile_definitions(heap_token_kinds_check PRIVATE X2W_HEAP_TOKEN_PENDING_TEST_HOOKS)
# A control passes only when the check ran to the end and printed "mutation <name>: caught" (a mutation that made it
# fail with FAIL lines); a crash, an unknown mutation name or a mutation that is not caught prints no such line.
foreach(mutation IN ITEMS kind-offset typed-any-format backfill-skipped generation-kept generation-kept-on-alloc-failure)
add_test(NAME heap_token_kinds_${mutation}_control COMMAND heap_token_kinds_check --mutate ${mutation})
set_tests_properties(heap_token_kinds_${mutation}_control PROPERTIES
PASS_REGULAR_EXPRESSION "mutation ${mutation}: caught")
endforeach()
# The draw heap's heap token region and ring, the typed nulls, the raw view over a title view heap and its stride rule, the
# root flags and the refusal text (src/startup_stubs/heap_token_binding.h), without a device.
add_executable(heap_token_binding_check tests/heap_token_binding_check.cpp)
target_include_directories(heap_token_binding_check PRIVATE src)
target_compile_features(heap_token_binding_check PRIVATE cxx_std_17)
add_test(NAME heap_token_binding COMMAND heap_token_binding_check)
# Mutation controls: the same check, built against a copy of heap_token_binding.h with one real edit of the production code
# (the anchor is replaced; configure fails when the header no longer holds it). The check must print the FAIL line named for the mutant (the last argument), not just any.
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS src/startup_stubs/heap_token_binding.h)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/startup_stubs/heap_token_binding.h" heap_token_binding_text)
function(heap_token_binding_mutant name anchor replacement caught)
string(FIND "${heap_token_binding_text}" "${anchor}" position)
if(position LESS 0)
message(FATAL_ERROR "heap_token_binding.h lost the anchor of heap_token_binding_${name}_control: ${anchor}")
endif()
string(REPLACE "${anchor}" "${replacement}" mutated "${heap_token_binding_text}")
if(mutated STREQUAL heap_token_binding_text)
message(FATAL_ERROR "heap_token_binding_${name}_control does not change the header")
endif()
set(directory "${CMAKE_CURRENT_BINARY_DIR}/heap_token_binding_mutants/${name}")
file(WRITE "${directory}/startup_stubs/heap_token_binding.h" "${mutated}")
add_executable(heap_token_binding_${name}_check tests/heap_token_binding_check.cpp)
target_include_directories(heap_token_binding_${name}_check PRIVATE "${directory}" src)
target_compile_features(heap_token_binding_${name}_check PRIVATE cxx_std_17)
add_test(NAME heap_token_binding_${name}_control COMMAND heap_token_binding_${name}_check)
set_tests_properties(heap_token_binding_${name}_control PROPERTIES PASS_REGULAR_EXPRESSION "${caught}")
endfunction()
heap_token_binding_mutant(ring-full-heap
"return opt_in ? heap_token_ring_size(heap_slots) : heap_slots;" "return heap_slots;"
"FAIL: the ring with the opt-in is not 196,603 slots")
heap_token_binding_mutant(ring-always-reduced
"return opt_in ? heap_token_ring_size(heap_slots) : heap_slots;" "return heap_token_ring_size(heap_slots);"
"FAIL: the ring without the opt-in is not the whole 262,144-slot heap")
heap_token_binding_mutant(region-overlap
"return heap_token_ring_size(heap_slots) + id; }" "return heap_token_ring_size(heap_slots) + id - 1; }"
"FAIL: the mirror does not start where the ring ends")
heap_token_binding_mutant(ring-wrap-dropped
"if (first + n > ring_size) first = 0;" "if (false) first = 0;"
"FAIL: a reservation of 5 slots 3 below the end of the ring does not start at 0")
heap_token_binding_mutant(ring-oversize-taken
"if (n > ring_size || n > 0x7fffffffu) return heap_token_ring_refused;" ""
"FAIL: a reservation larger than the ring is not refused")
heap_token_binding_mutant(null-2da-as-2d
"desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;" "desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;"
"FAIL: the 2D array null is not a 2D array texture view")
heap_token_binding_mutant(alias-unchecked
"entries * heap_token_record_bytes <= bytes;" "true;"
"FAIL: a heap one byte short is taken")
heap_token_binding_mutant(alias-stride-unchecked
"return title_stride == heap_token_record_bytes;" "return title_stride != 0;"
"FAIL: a 64-byte stride is taken")
heap_token_binding_mutant(root-flag-dropped
"(heap_tokens_bound ? D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED : D3D12_ROOT_SIGNATURE_FLAG_NONE)"
"D3D12_ROOT_SIGNATURE_FLAG_NONE"
"FAIL: a heap token program's root lacks the view heap flag")
heap_token_binding_mutant(gate-capability-ignored
"if (lacks_resource_heap) return \"heap tokens need a directly indexed resource heap\";" ""
"FAIL gate adapter lacks the resource heap:")
heap_token_binding_mutant(ring-cursor-runs-on
"const UINT next = first + n == ring_size ? 0 : first + n;" "const UINT next = static_cast<UINT>(seen) + n;"
"FAIL: the cursor left the ring")
heap_token_binding_mutant(miss-delta-underflows
"const std::uint32_t delta = total >= logged ? total - logged : 0;" "const std::uint32_t delta = total - logged;"
"FAIL: an older readback does not give a delta of 0")
heap_token_binding_mutant(miss-mark-moves-back
"if (total > logged) logged = total;" "logged = total;"
"FAIL: an older readback moved the logged mark back")
heap_token_binding_mutant(null-2d-word-wrong
"case 5: return heap_token_null_slot(heap_slots, null_2d);" "case 5: return heap_token_null_slot(heap_slots, null_1d);"
"FAIL: null2d is not the 2D null slot")
heap_token_binding_mutant(null-2da-word-wrong
"case 6: return heap_token_null_slot(heap_slots, null_2da);" "case 6: return heap_token_null_slot(heap_slots, null_2d);"
"FAIL: null2da is not the 2D array null slot")
heap_token_binding_mutant(count-unbounded
"const UINT bounded = records < heap_token_mirror_capacity ? records : heap_token_mirror_capacity;"
"const UINT bounded = records;"
"FAIL: count is not bounded by the mirror capacity")
heap_token_binding_mutant(kind-unchanged-dirty
"if (kinds_[id] != kind) {" "if (true) {"
"FAIL: storing the same kind again is dirty")
add_test(NAME startup_heap_indexed_root COMMAND startup_heap_indexed_root_check)
foreach(mutation IN ITEMS sampler-alone bind-unrestorable)
add_test(NAME startup_heap_indexed_root_${mutation}_control COMMAND startup_heap_indexed_root_check --mutate ${mutation})
Expand Down Expand Up @@ -5112,9 +5209,18 @@ if(EXISTS "${INTAKE_PYTHON}")
add_test(NAME startup_compute_dispatch_heap_word_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_dispatch_heap_word_check.py" "$<TARGET_FILE:startup_stream_consumer>"
"${DXC_EXECUTABLE}" ${adapter})
if(adapter STREQUAL "warp")
# Heap view token runtime, skeleton: x2w_d3d12_create_srv records and queues slot-18 views (WARP only for now).
add_test(NAME startup_compute_heap_token_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_heap_token_check.py" "$<TARGET_FILE:d3d12_xs_shim>")
set_tests_properties(startup_compute_heap_token_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endif()
add_test(NAME startup_compute_dispatch_input_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_dispatch_input_check.py" "$<TARGET_FILE:startup_stream_consumer>"
"${DXC_EXECUTABLE}" ${adapter})
add_test(NAME startup_compute_dispatch_ring_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_dispatch_ring_check.py" "$<TARGET_FILE:startup_stream_consumer>"
"${DXC_EXECUTABLE}" ${adapter})
add_test(NAME startup_compute_live_retry_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_live_retry_check.py" "$<TARGET_FILE:startup_stream_consumer>"
"${DXC_EXECUTABLE}" ${adapter})
Expand All @@ -5128,6 +5234,7 @@ if(EXISTS "${INTAKE_PYTHON}")
startup_compute_dispatch_heap_${adapter} startup_compute_dispatch_heap_word_${adapter}
startup_compute_live_retry_${adapter} startup_compute_dispatch_entry_${adapter}
startup_compute_dispatch_input_${adapter} startup_compute_dispatch_two_mips_${adapter}
startup_compute_dispatch_ring_${adapter}
PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endforeach()
add_test(NAME startup_stream_adapter_filter COMMAND "${INTAKE_PYTHON}" -B
Expand Down Expand Up @@ -5182,8 +5289,12 @@ if(EXISTS "${INTAKE_PYTHON}")
add_test(NAME startup_draw_depth_target_debug_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}"
"${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_draw_depth_target_check.py"
"$<TARGET_FILE:startup_draw_depth_target>" "${backend}" debug)
add_test(NAME startup_draw_depth_target_ring_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}"
"${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_draw_depth_target_check.py"
"$<TARGET_FILE:startup_draw_depth_target>" "${backend}" ring)
set_tests_properties(startup_draw_depth_target_${backend} startup_draw_depth_target_drop_control_${backend}
startup_draw_depth_target_debug_${backend} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
startup_draw_depth_target_debug_${backend} startup_draw_depth_target_ring_${backend}
PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
foreach(compiler IN ITEMS fxc dxc)
add_test(NAME startup_joined_table_pointer_${compiler}_${backend} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_joined_table_pointer_check.py"
Expand Down Expand Up @@ -9622,7 +9733,7 @@ if(EXISTS "${INTAKE_PYTHON}")
DEPENDS cpu_shim_startup tests/cpu/translate_shim_startup.py tools/cpu_switch_aot.py
tools/cpu_call_aot.py tools/cpu_leaf_aot.py tools/cpu_ranges.py VERBATIM)
add_library(cpu_placed_dxr_provider SHARED tests/cpu/placed_dxr_provider.cpp tests/dxr_check.cpp
tests/desktop_gpu.cpp src/era_title_va.cpp
tests/desktop_gpu.cpp src/era_title_va.cpp src/era_gpu_alias.cpp
"${ray_header}" "${ray_table_header}" "${ray_pipeline_header}" "${candidates_header}" "${candidates_pipeline_header}")
if(TARGET d3d12_xs_device_obj)
target_sources(cpu_placed_dxr_provider PRIVATE $<TARGET_OBJECTS:d3d12_xs_device_obj>)
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check",
"xmem_page_runs_device_check", "linear_buffer_backing_check",
"bcpack_formats_check", "startup_stub_consumer", "startup_inline_retire", "startup_resource_retire_title", "startup_table_lock",
"native_compute_ir_dump", "native_pixel_ir_dump", "native_store_replay", "native_raw_buffer_view_check"
"native_compute_ir_dump", "native_pixel_ir_dump", "native_store_replay", "native_raw_buffer_view_check",
"native_heap_token_texture"
]
},
{ "name": "release", "configurePreset": "release" },
Expand Down
2 changes: 2 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -18356,3 +18356,5 @@ ctest --preset dev --no-tests=error -j1 -R '^native_pixel_atomic_(warp|hardware)
```

Repeat with the release preset. The source-built fixture verifies 13 actual draws and four refusal controls per adapter/configuration, including contention, guard words, active out-of-view, odd raster edges and real WQM quad-neighbor reads with and without GLC. WQM+GLC records returned old values through a second exact atomic in a private lane slot and checks a valid serialization of the varying addends. Local RX 7900 XT/WARP Debug/Release integration over main 4b0350e passed 52 draws, 3328 DWORD and 1664 pixel comparisons, and 16 refusal controls. The debug layer was unavailable; actual title rendering is not established.

See [GPU-selected heap textures through view tokens in native compute](experiments/native-heap-token-textures.md) (#3023 stage 3) for the `heaptok` manifest lines (refused without `X2W_D3D12_HEAP_TOKENS=1`, bound by the runtime with it). The same page covers GPU-selected raw buffers read through view tokens (`baseraw` and `nullraw` words).
Loading
Loading