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
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,19 @@ foreach(backend IN ITEMS warp hardware)
endforeach()
set_tests_properties(startup_indirect_dispatch_hardware startup_indirect_root_constants_hardware PROPERTIES SKIP_RETURN_CODE 77)

# Occlusion queries recorded through command-list slots 28 to 30 reach the readback buffer (#870).
add_executable(startup_list_queries tests/startup_list_queries.cpp tests/desktop_gpu.cpp)
target_compile_features(startup_list_queries PRIVATE cxx_std_17)
target_link_libraries(startup_list_queries PRIVATE d3d12_xs_shim d3d12 dxgi d3dcompiler)
foreach(backend IN ITEMS warp hardware)
add_test(NAME startup_list_queries_${backend} COMMAND startup_list_queries ${backend})
set_tests_properties(startup_list_queries_${backend} PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77)
# Negative control: without X2W_D3D12_QUERY_SLOTS=1 the slots stay no-ops and the buffer keeps its sentinel.
add_test(NAME startup_list_queries_default_${backend}_control COMMAND startup_list_queries ${backend} default)
set_tests_properties(startup_list_queries_default_${backend}_control PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77
PASS_REGULAR_EXPRESSION "word 0: got 0xa5a5a5a5a5a5a5a5")
endforeach()

add_executable(startup_indirect_draw_indexed tests/startup_indirect_draw_indexed.cpp tests/desktop_gpu.cpp)
target_compile_features(startup_indirect_draw_indexed PRIVATE cxx_std_17)
target_link_libraries(startup_indirect_draw_indexed PRIVATE d3d12_xs_shim d3d12 dxgi d3dcompiler)
Expand Down
33 changes: 33 additions & 0 deletions docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ records. The control expects the first blend patch to win and must fail.

Command-list slot 24 (`OMSetStencilRef`, the desktop slot) passes its reference to the desktop list, as slots 21 to 23 do for viewports, scissors and the blend factor, so a translated draw whose pipeline enables the stencil test compares against it. A closed list ignores the call. The slot number is the desktop one and has not been seen in a title log; `startup_stream_depth_{warp,hardware}` checks the references 0x5A, 0x5B, 0 and 0xFF against a stencil cleared to the matching value.

## Occlusion queries

Which console methods sit at command-list slots 28 to 30 is not established by any fixture here. The repository
shows only that four console methods sit in 26 to 31 (32 is `SetDescriptorHeaps`, desktop 28 plus four) and that
the plus-four run has ended by 61 (`ExecuteIndirect`, desktop 59 plus two). As a hypothesis, slots 28 to 30 are
implemented as `BeginQuery(heap, type, index)`, `EndQuery(heap, type, index)` and
`ResolveQueryData(heap, type, start, count, buffer, offset)`. Because that is a hypothesis, the bindings are a
diagnostic opt-in: only with `X2W_D3D12_QUERY_SLOTS=1` (in render mode) are the three slots bound. Unset, they stay
no-ops as before. The fixture below calls those slots directly, so it checks the forwarding, the refusals and the
end at Close, not the numbering.

The query heap comes from device slot 39 with the desktop desc, which the stand-in keeps. Only occlusion and
binary-occlusion queries on an occlusion heap, recorded on a DIRECT list, are forwarded to the desktop list. A
resolve is forwarded only when every index in its range was ended, with the same query type, on the current
recording; a new `BeginQuery` on an index clears its completion, and Close clears all of them. These calls are
refused and logged (`x2w-render ... refused`, the first 16 of each method): another command-list type, an index
outside the heap, an `EndQuery` without a `BeginQuery` on the same list, a resolve over an index not so ended, and
a resolve to anything but a committed readback buffer without title memory, or past that buffer's end. A query
still open at Close is ended there, since the desktop Close would otherwise fail and drop the list. The readback
buffer stays in `COPY_DEST` and is not moved through the list's state tracking.

Known limit: a resolve recorded on a later list than the `EndQuery` calls it covers is refused. Whether a caller
resolves on the recording that ended its queries has not been observed.

`startup_list_queries_{warp,hardware}` sets `X2W_D3D12_QUERY_SLOTS=1`. It resolves a query around a draw over an
8x8 target (64 samples) and an empty one (0) into a readback buffer filled with a sentinel, and reads it through
the console `Map`. It then checks that the refused calls, among them resolves over a never-begun index, a range
with a hole and an index ended with the other occlusion type, leave the sentinel untouched with no debug-layer
error, and it leaves one query open at Close. `startup_list_queries_default_{warp,hardware}_control` runs it
without the switch: the slots stay no-ops and it must report the untouched sentinel in the first word.
`command_list_slot_names.h` still names 56 to 58 as the query methods by the plus-four rule.

## Default viewport and scissor

A desktop command list that never sets a viewport or scissor rectangle draws no pixel. A translated
Expand Down Expand Up @@ -762,6 +794,7 @@ ctest --preset dev --no-tests=error -R '^startup_trap_header(_prefix_control|_pr
| `X2W_D3D12_PERMISSIVE=1` | wraps the device: recording command lists, console present, view tracking |
| `X2W_D3D12_RENDER=1` | draws through translated pipelines from `X2W_SHADER_CACHE` and forwards [single-record indirect Dispatch](experiments.md#gpu-written-indirect-dispatch-arguments), [DrawIndexed](experiments.md#gpu-written-indirect-indexed-draw-arguments), [Draw](experiments.md#gpu-written-indirect-draw-arguments), and [DispatchMesh](experiments.md#gpu-written-indirect-mesh-dispatch-arguments) for supported desktop pipelines and tracked placed buffers |
| `X2W_SHADER_CACHE=<dir>` | translation cache: the runtime writes source requests `req_<key>.{a,b,root}` and, when needed, RTV variants `req_<key>.rtv`. Run `tools/startup/gfx2hlsl.py --pending <dir>` while the process is running, or start the run with `run.ps1 -Translate` (see [Translating shaders during a run](#translating-shaders-during-a-run)). Active draws poll for an absent manifest at most once per second per pipeline and use the published translation on a subsequent draw. The translator compiles `.vs.cso` and `.ps.cso` with `fxc.exe`: `X2W_FXC`, else the Windows SDK 10.0.26100.0 copy, else the newest `Windows Kits\10\bin\<version>\x64`, else `PATH`. When none exists it writes `<key>.fail` naming `X2W_FXC` without publishing a new manifest. `X2W_FXC=` (empty) publishes the manifest alone. Rerun `--pending` with compilation enabled to fill in missing bytecode for an existing manifest. |
| `X2W_D3D12_QUERY_SLOTS=1` | diagnostic, in render mode: binds command-list slots 28 to 30 to the hypothesised occlusion query methods (see [Occlusion queries](#occlusion-queries)). Unset, the three slots stay no-ops |
| `X2W_DRAW_NULL_IDENTITY=1` | null descriptors read as identity values instead of zero |
| `X2W_PRESENT_SIGNATURE_EVERY=<n>` | in render mode, samples a coarse signature of the presented picture every `n` presents from the start, without a script request (`0` off). Unset, sampling starts, every 4 presents, only once a script with a `wait` asks for it: see [Waiting for the presented picture](#waiting-for-the-presented-picture) |
| `X2W_D3D12_DUMP_SURFACE=<bmp>` | writes the last presented surface |
Expand Down
14 changes: 9 additions & 5 deletions src/startup_stubs/command_list_slot_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
// the slots between them (0 to 6, 8, 14 to 19, 24) take the desktop names.
// - Slots 10 and 11 are not named. The desktop order puts Reset and ClearState there, but this
// console list resets through slot 139, so the desktop order is not known to hold at 10 and 11.
// - Slots 26 to 31 are not named. The slots that follow are the desktop ones moved up by four
// (32 is SetDescriptorHeaps, desktop 28), so four console methods sit somewhere in 26 to 31 and
// which desktop slot is which is not known.
// - Slots 32 to 59 are the desktop slots 28 to 55 plus four. Implemented and checked against the
// desktop order: 32, 34, 36, 40, 42, 44, 47, 48, 50 and 52.
// - Slots 26 to 31 are not named here. The slots that follow are the desktop ones moved up by four
// (32 is SetDescriptorHeaps, desktop 28), so four console methods sit somewhere in 26 to 31.
// As a hypothesis, d3d12_xs_device.cpp binds 28, 29 and 30 as BeginQuery, EndQuery and
// ResolveQueryData, only with the diagnostic X2W_D3D12_QUERY_SLOTS=1. No fixture here establishes
// which console methods sit there.
// - Slots 32 to 59 are named as the desktop slots 28 to 55 plus four. Implemented and checked
// against the desktop order: 32, 34, 36, 40, 42, 44, 47, 48, 50 and 52. Past 52 the rule is not
// checked: ExecuteIndirect (desktop 59) is at 61, desktop plus two, so the run of four has ended
// by then. The 56 to 58 names below are kept as the rule gives them.
// - Slots 61 (ExecuteIndirect) and 139 (Reset) are implemented in d3d12_xs_device.cpp.
// - Other slots have no confirmed meaning.
#pragma once
Expand Down
Loading
Loading