Repository navigation
Conversation
Apple's D3DMetal (macOS under CrossOver) has no GPU timestamps: a queue's
GetTimestampFrequency gives 60 and every D3D12_QUERY_TYPE_TIMESTAMP
resolves to 0 (measured with a D3D12 program without XCL: three queries,
fence reached, all three 0). A title's Write64BitValue{Top,Bottom}OfPipeX
timestamp therefore stayed 0 for ever:
timestamps_outside_unified_memory_land_after_the_queue fails there with
"never landed (top=0, bottom=0)", and the test title's "no GPU timestamp".
A title queue is asked its timestamp frequency when it is created; below
1000 ticks a second that is no GPU clock, and XCL's timestamps become the
CPU's clock (QueryPerformanceCounter). A timestamp query that resolved to
0 on a queue that got there turns it on as well. From then on a timestamp
is the clock's value when it was recorded, written through the path every
other Write64BitValue takes (so it lands in the GPU's order), and the
queue's GetTimestampFrequency / GetClockCalibration answer with the same
clock. A host with GPU timestamps is asked one frequency per queue and
nothing else changes.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ufoptg
pushed a commit
that referenced
this pull request
Nov 24, 2026
…ites `pc_resource_desc` takes ALLOW_UNORDERED_ACCESS from a depth buffer the console also lets shaders write (the PC refuses ALLOW_DEPTH_STENCIL with ALLOW_UNORDERED_ACCESS). Only CreatePlacedResourceX (#44) moved such a resource's initial state off UNORDERED_ACCESS as well (to DEPTH_WRITE). The other paths that create a resource of the converted description only masked the state with PC_RESOURCE_STATES: the committed fallback of CreateCommittedResource (#27 / #76 / #127, reached without unified memory or when its coherent window is full), the PC-way retry and the committed fallback of CreatePlacedResource (#29), and its memory-of-its- own path for textures larger on the PC. A console texture with flags DEPTH_STENCIL | UNORDERED_ACCESS created in UNORDERED_ACCESS was then asked for in a state D3D12 refuses for a resource without the UAV flag (E_INVALIDARG; the #29 own-memory path fell back to COMMON). `device_x::pc_initial_state` does both steps; #44 uses it with no change in behaviour, and the four other sites use it with the console flags (or the PC description's, which keep ALLOW_DEPTH_STENCIL). Tests: a unit test of the helper; a GPU test placing a 256x256 D16 depth+UAV texture in UNORDERED_ACCESS as XCL now does (not run here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Upstream PR xcl-dev#996 was closed or merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apple's D3DMetal (macOS under CrossOver) has no GPU timestamps: a queue's
GetTimestampFrequencygives 60 and everyD3D12_QUERY_TYPE_TIMESTAMPresolves to 0. A title'sWrite64BitValueBottomOfPipeX/Write64BitValueTopOfPipeXtimestamp therefore stays 0 for ever:timestamps_outside_unified_memory_land_after_the_queuefails there ("never landed (top=0, bottom=0)"), and so does the test title's "no GPU timestamp" check. Part of #258.On such a host XCL's timestamps become the CPU's clock (
QueryPerformanceCounter). A host with GPU timestamps is asked oneGetTimestampFrequencyper title queue and nothing else changes for it.Related: #317 (draft) touches the same functions for a different thing, the console's OS-clock timestamp flags. This PR does not change which flags mean what.
What is in it (one commit, +100 / -5)
hle/d3d12x/cpu_writes.rs:cpu_clock()and what turns it on: a title queue whose timestamp frequency is below 1000 ticks a second (note_host_timestamp_frequency), or a timestamp query that resolved to 0 on a queue that reached its fence (that write gets the clock's value too). Unit testa_60_hz_timestamp_frequency_is_no_gpu_clock.hle/d3d12x/device_x.rs:create_command_queue_xasks a direct / compute queue its timestamp frequency.hle/d3d12x/list_x.rs: withcpu_clock(),timestampwrites the clock's value throughwrite, as any otherWrite64BitValue*. A target in unified memory gets it from the GPU, in the list's order (WriteBufferImmediate, marker in for top of pipe, marker out for bottom). A target outside unified memory gets it from thecpu_writesworker after the queue's fence, as every other value written there does.hle/d3d12x/real.rs: withcpu_clock(), queueGetTimestampFrequencyanswers the clock's frequency andGetClockCalibrationits value for both.What it is not: the value is the clock when the timestamp was recorded, not when the GPU got there, so GPU times measured between two timestamps come out too short (top and bottom of one submission differ only by the CPU time between the two calls). It also changes the value, not the ordering: outside unified memory the write still comes from the
cpu_writesworker, so the gap @Lucasyudi described in #258 (a title's ownSignaland wait can overtake the worker's write) is as open as before, for timestamps as for any other value. An earlier version wrote every clock value from that worker; the test title, whose timestamp is in unified memory, read 0 right after its own fence, which is why those go through the list.Tested
x86_64-pc-windows-msvcwith clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, Rust 1.100.0, debug. Test binaries run under Wine.mainis9aec53d, the head isf242ea8.EndQuery+ResolveQueryDataof three timestamps into a readback buffer, fence reached):GetTimestampFrequencyS_OK, 60; all three slots 0.xcl-<hash>.exe cpu_writes:: timestamps_outside_unified_memory --test-threads=1, 3 runs each:main2 passed, 1 failed (timestamps_outside_unified_memory_land_after_the_queue) every run; head 4 passed, 0 failed every run (the log shows "no GPU timestamps on this host (a timestamp query resolved to 0)").hle:: --skip ::gpu_ --test-threads=1, skipping the 3 tests that crash this host onmaintoo (create_list_reset_and_clear_state_track_initial_pso_on_d3d12,placed_title_textures_share_vram_and_preserve_pixels,d32s8_targets_take_their_own_size_of_video_memory):main288 passed, 4 failed, 2 ignored; head 290 passed, 3 failed, 2 ignored. The only test that changed is the timestamp one; the other 3 failures are the same on both (write_buffer_immediate_on_open_existing_heap_visible_to_cpu,mapped_frame_dump_distinguishes_dark_bright_and_undecoded_content,xma2_source_voice_decodes_and_manages_lifetime, the last one is XAudio2: GetState names the oldest queued buffer when the host gives none xcl-dev/xcl#890).tests/e2e.rs):maindies on this host before its timestamp check (the fallback PSO, D3D12.X: a stage the PC cannot run goes to the fallback without the driver xcl-dev/xcl#750). On a local stack ofmac-on-main-wip(db065d8) + D3D12.X: a stage the PC cannot run goes to the fallback without the driver xcl-dev/xcl#750's diff + this change (ported by hand, the branch'scpu_writes.rsdiffers): "D3D12.X: console command list memory methods (writes, timestamp, fill, copy, KickoffX, Wait32/64)" passes in 3 of 3 runs, 47 PASS, and the log shows "no GPU timestamps on this host (the queue's timestamp frequency is 60)". Without this change that stack fails the check with "no GPU timestamp" (D3D12.X: a stage the PC cannot run goes to the fallback without the driver xcl-dev/xcl#750's description has the same).Tested by others
cargo test --workspace -- --test-threads=4with this patch onmain02bfd1d: 728 passed, 0 failed, 41 ignored (baseline 727). D3D12.X: timestamps are the CPU's clock on a host without GPU timestamps xcl-dev/xcl#996 (comment)f242ea8: 725 passed, 0 failed, 41 ignored; "no GPU timestamps on this host" appears 0 times in the tests' and the test title's logs. D3D12.X: timestamps are the CPU's clock on a host without GPU timestamps xcl-dev/xcl#996 (comment)gnullvmrelease build: the timestamp test fails on02bfd1dand passes onf242ea8; the trigger there is the resolved-to-0 one. D3D12.X: timestamps are the CPU's clock on a host without GPU timestamps xcl-dev/xcl#996 (comment)Regression run
xcl-smokepair is needed before this leaves draft.Not tested
cpu_writesordering above):timestamps_outside_unified_memory_land_after_the_queuepolls until the value is there, so it cannot see that.EndQuery/ResolveQueryDatatimestamp queries on the PC queue is not intercepted and still reads 0 on such a host (noted by @mikebuckets171).cargo test --workspacedoes not finish on this host, see [upstream #1898] Direct DXIL: truncate s instead of returning native on special values in round_exact #258).GetTimestampFrequency/GetClockCalibrationcalls (the test title makes neither).AI use
🤖 Generated with Claude Code
Mirror of xcl-dev#996 (auto-synced, do not edit).