Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
5055432
startup: lower the FP32 box case of image_bvh_intersect_ray
lambirou Nov 26, 2026
2ec454f
startup: keep non-BVH resource manifests from reading a third field
lambirou Nov 26, 2026
34a2c5c
startup: lower binary16 box nodes in image_bvh_intersect_ray
lambirou Nov 26, 2026
c47f598
tests: compile the binary16 BVH helper with DXC
lambirou Nov 26, 2026
1fd5475
tests: dispatch the binary16 BVH helper on WARP
lambirou Nov 26, 2026
cfe00df
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
35a342d
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
94e9029
startup: keep unsorted BVH hits in child order
lambirou Nov 27, 2026
07a60ea
merge the sort-disabled BVH fix into the binary16 slice
lambirou Nov 27, 2026
6d2b778
merge main into the binary16 BVH slice
lambirou Nov 27, 2026
6459442
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
c7a23a1
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
1316703
Merge origin/main into startup/bvh-intersect-box16
lambirou Nov 27, 2026
b7117d4
docs: correct the binary16 node count in the BVH receipt
lambirou Nov 27, 2026
5640a90
startup: lower triangle nodes in image_bvh_intersect_ray
lambirou Nov 27, 2026
bf0e664
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
5098855
Merge branch 'startup/bvh-intersect-box16' into startup/bvh-intersect…
lambirou Nov 27, 2026
aa5c901
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
004fcd0
Merge branch 'startup/bvh-intersect-box16' into startup/bvh-intersect…
lambirou Nov 27, 2026
3ac44c2
startup: treat the BVH descriptor size as a count minus one
lambirou Nov 27, 2026
d70721a
Merge branch 'startup/bvh-intersect-box16' into startup/bvh-intersect…
lambirou Nov 27, 2026
070b12d
startup: use the decoded BVH extent for triangle nodes
lambirou Nov 27, 2026
2ce9f11
compile_dxil: invalidate a published manifest by sidecar content, not…
lambirou Nov 27, 2026
06c7380
runtime: keep the published disk pair after candidate PSO failure
lambirou Nov 27, 2026
d2eeb68
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
a68c9bd
Merge branch 'startup/bvh-intersect-box16' into startup/bvh-intersect…
lambirou Nov 27, 2026
e387d85
startup: identify a rotated rectangle corner by its diagonal (#3131)
lambirou Nov 27, 2026
263604f
startup: cover BVH triangle operands and box return mode
lambirou Nov 27, 2026
9360bca
runtime: bind from the recovered translation after PSO fallback
lambirou Nov 27, 2026
1600acc
runtime: add opt-in input trace for the virtual gamepad
lambirou Nov 27, 2026
ec324f7
tooling: add a startup UI regression matrix
lambirou Nov 27, 2026
83d36db
tooling: report the first scene-colour write from draw dumps
lambirou Nov 27, 2026
33bd9f1
tooling: report the startup exit code and last presented frame
lambirou Nov 27, 2026
8f7953f
runtime: count decoded Opus completions and desktop audio submissions
lambirou Nov 27, 2026
aff14cb
docs: point the scene-colour note at the switches section
lambirou Nov 27, 2026
8121d2e
merge PR #3032 (fork/startup/bvh-intersect-box16)
lambirou Nov 27, 2026
f92b08e
merge PR #3105 (fork/startup/bvh-intersect-triangle)
lambirou Nov 27, 2026
6c7c471
merge PR #3137 (native/stale-manifest-mtime)
lambirou Nov 27, 2026
ca49acd
merge PR #3139 (native/graphics-pso-fallback)
lambirou Nov 27, 2026
959fe60
merge PR #3142 (fork/startup/ui-gradient-gap)
lambirou Nov 27, 2026
1de4192
merge PR #3173 (fork/codex/ui-regression-matrix)
lambirou Nov 27, 2026
a63198b
merge PR #3175 (fork/codex/scene-color-trace)
lambirou Nov 27, 2026
fe9053b
merge PR #3176 (fork/codex/exit-code-trace)
lambirou Nov 27, 2026
bd78ee9
merge PR #3177 (fork/codex/input-movement-trace)
lambirou Nov 27, 2026
7584398
merge PR #3178 (fork/codex/opus-completion-count)
lambirou Nov 27, 2026
114aae1
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
35ee05e
shader: emit 1e-6 as an exact bit pattern in rect geometry
lambirou Nov 27, 2026
6b14ac1
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
46c6a7b
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
7d8f7dd
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
da6ab8e
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
55cfcb6
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
99e412e
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
1afd556
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
d944949
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
173294e
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
d805912
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
e1a0e1f
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
7eadaf4
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
5106972
merge origin/main into local/pr-stack
lambirou Nov 27, 2026
d25451f
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
918fd07
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
a285b49
runtime: store compute token UAV descriptions in the merged view union
lambirou Nov 28, 2026
1341fa5
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
87287c5
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
e1b6917
Refactor native compute tests and enhance output validation
lambirou Nov 28, 2026
73a3378
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
cf0b707
shader: keep packed state and request shape validation after main merge
lambirou Nov 28, 2026
b1ead1e
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
dc76ca1
runtime: read view-token compute inputs from non-aliased placed buffers
lambirou Nov 28, 2026
9443cb1
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
72f3c8e
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
2dff32d
runtime: pass input alignment after the title-snapshot flag
lambirou Nov 28, 2026
bb5ee4c
runtime: prefer a published graphics pair over native compilation
lambirou Nov 28, 2026
089d7c6
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
eedd386
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
3b5c7a8
startup: confirm command list slots from the 261000 table
lambirou Nov 28, 2026
a269879
runtime: decode the 261000 xmem attribute layout
lambirou Nov 28, 2026
225a6e4
Merge gdk/d3d12x-confirmed-slots into local/pr-stack
lambirou Nov 28, 2026
734a8dd
Merge gdk/xmem-attributes-261000 into local/pr-stack
lambirou Nov 28, 2026
250418b
startup: name the confirmed command list table
lambirou Nov 28, 2026
bb51a2e
Merge the updated gdk/d3d12x-confirmed-slots into local/pr-stack
lambirou Nov 28, 2026
1ebe509
Merge origin/main into local/pr-stack
lambirou Nov 28, 2026
676b2f9
docs: update the Era heap layout for the 261000 table
lambirou Nov 28, 2026
a8fe6a2
Merge the updated gdk/xmem-attributes-261000 into local/pr-stack
lambirou Nov 28, 2026
2a37836
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
7d3ae28
docs: align the query slot table with the confirmed slots
lambirou Nov 28, 2026
c871621
runtime: note the two-MiB xmem page in the resource path
lambirou Nov 28, 2026
bad336b
Merge the updated gdk/d3d12x-confirmed-slots into local/pr-stack
lambirou Nov 28, 2026
cbfed6b
Merge the updated gdk/xmem-attributes-261000 into local/pr-stack
lambirou Nov 28, 2026
6ed317e
docs: drop the allocator page-size note from the slot change
lambirou Nov 28, 2026
f250843
Merge the reviewed gdk/d3d12x-confirmed-slots into local/pr-stack
lambirou Nov 28, 2026
b03c70f
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
d77efc7
docs: distinguish the 261000 layout from the SlimEra baseline
lambirou Nov 28, 2026
2f67122
Merge the clarified gdk/xmem-attributes-261000 docs into local/pr-stack
lambirou Nov 28, 2026
15f8db3
tooling: parse GDK MSVC class layouts
lambirou Nov 28, 2026
79d3359
tooling: audit GDK export coverage
lambirou Nov 28, 2026
a7b111c
tooling: extract GDK MSBuild platform profiles
lambirou Nov 28, 2026
9a5bb20
tooling: report GDK knowledge coverage
lambirou Nov 28, 2026
89f5f2b
Merge the GDK gdk/runtime-oracle slice into local/pr-stack
lambirou Nov 28, 2026
2d7cc37
Merge the GDK gdk/layouts-abi slice into local/pr-stack
lambirou Nov 28, 2026
d2785f2
Merge the GDK gdk/export-coverage slice into local/pr-stack
lambirou Nov 28, 2026
6cb354c
Merge the GDK gdk/platform-profiles slice into local/pr-stack
lambirou Nov 28, 2026
b4ca6b1
Merge the GDK gdk/shader-corpus slice into local/pr-stack
lambirou Nov 28, 2026
8f3d0e3
Merge the GDK gdk/knowledge-report slice into local/pr-stack
lambirou Nov 28, 2026
789ee57
ci: retry the Windows smoke test
lambirou Nov 28, 2026
d8d4919
Merge the updated gdk/runtime-oracle into local/pr-stack
lambirou Nov 28, 2026
eb3fdfc
Merge the updated gdk/export-coverage into local/pr-stack
lambirou Nov 28, 2026
abae48d
Merge the updated gdk/knowledge-report into local/pr-stack
lambirou Nov 28, 2026
4b833b2
tooling: keep print-only ABI probes to size facts
lambirou Nov 28, 2026
eda3adc
Merge the reviewed gdk/layouts-abi into local/pr-stack
lambirou Nov 28, 2026
9f95512
Merge origin/main into local/pr-stack
lambirou Nov 28, 2026
f46e9ad
Merge origin/main into gdk/layouts-abi
lambirou Nov 28, 2026
0edc189
Merge origin/main into gdk/export-coverage
lambirou Nov 28, 2026
f74ee3f
Merge origin/main into gdk/platform-profiles
lambirou Nov 28, 2026
18f046d
Merge the refreshed gdk/runtime-oracle into local/pr-stack
lambirou Nov 28, 2026
b82591c
Merge the refreshed gdk/layouts-abi into local/pr-stack
lambirou Nov 28, 2026
fa07b40
Merge the refreshed gdk/export-coverage into local/pr-stack
lambirou Nov 28, 2026
bd4f3fa
Merge the refreshed gdk/platform-profiles into local/pr-stack
lambirou Nov 28, 2026
6fbcc19
Merge the refreshed gdk/shader-corpus into local/pr-stack
lambirou Nov 28, 2026
f5d1194
Merge the refreshed gdk/knowledge-report into local/pr-stack
lambirou Nov 28, 2026
e1822e8
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
354b32f
tooling: use the selected SDK for platform paths
lambirou Nov 28, 2026
7f97cb5
Merge the reviewed gdk/platform-profiles into local/pr-stack
lambirou Nov 28, 2026
c6c7688
runtime: restore bounded native scalar windows in integration
wish131400 Nov 28, 2026
3273b75
runtime: merge main 3926a289 into the integration stack
lambirou Nov 28, 2026
808bc79
tooling: allow the optional rectangle geometry shader in patch manifests
lambirou Nov 28, 2026
b3a74d3
Merge remote-tracking branch 'origin/main' into local/pr-stack
lambirou Nov 28, 2026
3cfe6f2
Merge branch 'main' of github.com:R0Y00/Xbox2Windows into local/pr-stack
lambirou Nov 28, 2026
6589adb
Merge local/pr-stack-latest into the main-synchronized stack
lambirou Nov 28, 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
1 change: 0 additions & 1 deletion docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17979,7 +17979,6 @@ Linux controls (including exhaustive verification against `fractions.Fraction` a

Independent Windows 11 (`26200.9974`, DXC `1.9.2602.17`, `debug_layer=unavailable`) measurements on `bd8f6f42` ([comment 1](https://github.com/R0Y00/Xbox2Windows/pull/2857#issuecomment-7196200555)) and `3100f363` ([comment 2](https://github.com/R0Y00/Xbox2Windows/pull/2857#issuecomment-7200844836)) passed `pixel_aot_f16_cvt_norm_hardware` (`AMD Radeon RX 9070 XT` `1002:7550`, driver `32.0.32029.2010`) and `pixel_aot_f16_cvt_norm_warp` with `max_absolute_error=0`, all 20 mutation draws mismatching, and DXIL disassembly confirming the `-Od` pass retains the `mul`/`lshr`/`shl` integer path. Scope limits: under `#839`'s static finite-proof contract (`half16_arith_source` / `half16_dpp_source`), operands are statically known per-lane uniform values, so device draw readbacks do not distinguish lane-routing changes on `dpp16`/`dpp8` (the permutation-to-intrinsic mapping is pinned statically in `check_f16_cvt_norm_controls`), mutation draws compile optimized rather than `-Od`, and the exhaustive 63,488-value check runs in Python rather than on-device.


## Native raw pixel buffer UAV binding

The native graphics cache and draw stand-in support a single raw pixel UAV from a tracked descriptor table for a direct non-indexed draw without SRVs. The manifest records the table parameter and byte offset; the runtime requires an aligned raw R32_TYPELESS buffer view with valid bounds, UAV resource flags and compatible state, retains the resource, and orders consecutive UAV uses. Typed/structured views, mixed views and other draw paths are outside this slice (#3212, #3215; separate from #3094/#2981).
Expand Down
71 changes: 71 additions & 0 deletions docs/experiments/native-scalar-window-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Native scalar input windows in the integration stack

The public integration stack in [#3248](https://github.com/R0Y00/Xbox2Windows/pull/3248),
at `7f97cb5ba467d16019dfd3ecdc86cf09c6dbcf09`, retains the native compiler's
`Slot::scalar_window` metadata but does not consume it when resolving compute inputs.
The bounded unplaced-window fallback exists in the public runtime branch of
[#3094](https://github.com/R0Y00/Xbox2Windows/pull/3094) at `97cde4d5`.

## Reproduction and change

The existing source-built
[native compute dispatch check](../../tests/startup_compute_dispatch_native_check.py)
loads its scalar descriptor from table 1 byte 64 and reads a scalar at buffer byte 36.
The descriptor has three records of stride 16 in readable CPU memory outside the
fixture's placed buffers. A valid decoy at table byte 0 contains a different value.

On the unmodified integration head, the first positive case is refused with
`an input is in title memory outside any placed buffer`. All 288 result words stay
at `0xc5c5c5c5` instead of becoming `0x400`; the 32 guard words remain untouched.
Native translation itself succeeds.

Restore the bounded fallback after normal GPU-backed range resolution. It applies
only to native scalar views, non-token descriptors, and that specific unplaced-range
refusal. The descriptor must cover the compiler's required bytes, contain whole
dwords, be at most 64 KiB, and be completely readable. The existing frame upload
copy retains the data for the recording. Successful normal resolution, invalid
tokens, partial placements and short windows do not enter this fallback. Existing
compute input source counters identify the fallback as a CPU snapshot.

This restores integration behavior; it does not enable the separate opt-in snapshot
of non-aliased placed buffers and does not change that policy.

## Validation

Windows 10 Pro build 19045, NVIDIA GeForce RTX 4070 Ti SUPER, driver
`32.0.15.7270`, Release `/O2`, MSVC `19.43.34810`, DXC `1.9.2609`,
Agility SDK 620, D3D12 debug layer enabled. The local WARP driver is
`10.0.19041.5794`.

```powershell
. .\tools\dev.ps1
cmake --build --preset runtime
# Use Windows' locale encoding for localized native error messages in this fixture.
$env:PYTHONUTF8 = '0'
ctest --preset release --no-tests=error -j 1 -V -R '^(native_fixed_mesh57_(varying|buffers)?_?hardware|startup_native_graphics_draw_hardware|startup_compute_dispatch_(native|input)_hardware|startup_slot67_indirect_dispatch_hardware)$'
ctest --preset release --no-tests=error -j 1 -V -R '^(startup_compute_dispatch_(native|input)|startup_slot67_indirect_dispatch)_warp$'
```

- Hardware: 7 selected, 7 passed, 0 failed, 0 skipped, 24.09 seconds.
- The scalar positives match all 288 result words for both `0x400` and `0x45678`,
with all 32 guards unchanged. The two-record (32-byte) control is refused and
leaves the complete output unchanged. The ordinary native, published fallback,
wrong table and shared read/write UAV cases also pass.
- Existing input rejection, opt-in snapshot, memory-view token, indirect dispatch
and fixed Mesh pixel checks pass without changing their assertions.
- WARP: 3 selected, 2 passed, 0 failed, 1 capability skip, 7.24 seconds. Native
compute skips because this WARP adapter has no 32-lane waves; its published
fallback and refusal controls run before the skip.

With Python 3.14's UTF-8 default, the graphics check separately fails decoding a
localized missing-DXC error. `PYTHONUTF8=0` permits its existing negative control
to run; no graphics or test source change was needed for that local encoding issue.

## Scope

This fixture uses only synthetic inputs. Its descriptor shape is relevant to
[#3310](https://github.com/R0Y00/Xbox2Windows/issues/3310), but it does not establish
the cause of that issue's 48 zero argument records. A matched integration capture
must still identify the actual SRV producer, demonstrate nonzero matching
post-write and pre-consume records at the same resource and offset, and show a real
Mesh submission changing scene color before composition.
3 changes: 2 additions & 1 deletion src/direct_compute_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ static const char *view_kind_name(ComputeViewKind kind) {
"heap_stride_srv", "raw_buffer_uav", "typed_buffer_uav", "half_buffer_uav", "root_buffer_srv",
"comparison_texture_srv", "half2_texture_uav", "half4_texture_uav", "cube_sample_srv", "cube_comparison_srv",
"indexed_atomic_uav", "d16_sample_srv", "byte_window_srv", "heap_buffer_srv", "heap_sampler",
"uint_texture_uav", "float_texture_uav", "float2_texture_uav", "float3_texture_uav"};
"uint_texture_uav", "float_texture_uav", "float2_texture_uav", "float3_texture_uav", "packed_d16_x_uav",
"indexed_raw_srv"};
const auto index = static_cast<size_t>(kind);
return index < std::size(names) ? names[index] : "unknown";
}
Expand Down
121 changes: 88 additions & 33 deletions src/startup_stubs/d3d12_draw.inl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ struct Translation {
enum UdKind { rect, base_vertex, start_instance, root_constant, stride, mrt_bits, d16_unorm16, desc_word3 };
struct Ud { int kind, a, b; };
int state = 0; // 1 ready, 2 unavailable
bool native_candidate = false; // shaders and manifest were prepared in-process; a published disk pair may also exist
u64 revision = 0; // bumped when a disk pair replaces the native shaders, invalidating created PSOs
std::string rtv_request; // the RTV variant text this translation was prepared for, else empty
#ifdef X2W_NATIVE_SHADERS
bool native_graphics_attempted = false;
#endif
Expand Down Expand Up @@ -447,7 +450,7 @@ bool native_shaders_only()
return enabled;
}

void load_translation(Translation& tr, const std::string& rtv_request = {}, std::string manifest = {})
void load_translation(Translation& tr, const std::string& rtv_request = {}, std::string manifest = {}, bool count = true)
{
tr.state = 2;
if (manifest.empty() && native_shaders_only()) {
Expand All @@ -458,7 +461,7 @@ void load_translation(Translation& tr, const std::string& rtv_request = {}, std:
const bool provided = !manifest.empty();
if (!cache_path(path, L"", tr.key, L".txt")) return;
if (!provided && !read_text(path, manifest)) {
if (!tr.manifest_retry.pending()) {
if (count && !tr.manifest_retry.pending()) {
InterlockedIncrement(&translation_missing);
static LONG missing;
if (rtv_request.empty() && first_calls(missing, 12))
Expand Down Expand Up @@ -580,8 +583,8 @@ void load_translation(Translation& tr, const std::string& rtv_request = {}, std:
}
tr.state = 1;
load_pso_recipes(tr);
if (previously_missing) InterlockedDecrement(&translation_missing);
InterlockedIncrement(&translation_ready);
if (count && previously_missing) InterlockedDecrement(&translation_missing);
if (count) InterlockedIncrement(&translation_ready);
log("x2w-draw pipeline %016llx translated: %zu entry values, %zu resources, %zu writable views, %zu static samplers, sampler_heap=%u",
tr.key, tr.uds.size(), tr.srvs.size(), tr.uavs.size(), tr.samplers.statics.size(), tr.samplers.heap ? 1u : 0u);
}
Expand Down Expand Up @@ -614,6 +617,7 @@ static bool try_native_graphics(Translation& tr, bool variant = false)
auto ps = stage(pair.pixel.dxil_ir, L"ps_6_6", ps_hit);
Translation candidate;
candidate.key = tr.key;
candidate.rtv_request = request.rtv_request;
candidate.manifest_retry = tr.manifest_retry;
candidate.native_graphics_attempted = true;
if (!pair.input_layout.empty()) {
Expand All @@ -631,6 +635,7 @@ static bool try_native_graphics(Translation& tr, bool variant = false)
}
candidate.vs = vs.Detach();
candidate.ps = ps.Detach();
candidate.native_candidate = true;
tr = std::move(candidate);
log("x2w-draw native graphics %016llx ready=%u cache(frontend,vs,ps)=%u,%u,%u",
tr.key, tr.state == 1, frontend_hit, vs_hit, ps_hit);
Expand Down Expand Up @@ -1258,6 +1263,7 @@ Translation* translation_for_targets(Translation* base, const Pass& pass)
if (!entry) {
entry = new Translation;
entry->key = key;
entry->rtv_request = request;
load_translation(*entry, request);
if (entry->state != 1) {
const bool published = publish_shader_request(key, L".rtv", request.data(), request.size());
Expand Down Expand Up @@ -1459,8 +1465,9 @@ ID3D12PipelineState* pipeline_for(BoundPipeline& bound, Translation& tr, const P
const DXGI_FORMAT dsv_format = pass_dsv_format(bound, pass);
// A state decoded from registers needs a depth view to act on; with none bound the pass keeps the desktop default.
const bool use_depth_stencil = bound.has_depth_stencil && (!bound.depth_from_registers || dsv_format != DXGI_FORMAT_UNKNOWN);
const u64 key = x2w_startup::pso_state_key(pass.target_count, pass.target_formats, dsv_format, use_depth_stencil,
bound.depth_stencil, bound.has_rasterizer, bound.rasterizer, indexed_rect);
u64 key = x2w_startup::pso_state_key(pass.target_count, pass.target_formats, dsv_format, use_depth_stencil,
bound.depth_stencil, bound.has_rasterizer, bound.rasterizer, indexed_rect);
if (tr.revision) key = fnv_bytes(&tr.revision, sizeof(tr.revision), key);
const auto found = bound.pipelines.find(key);
if (found != bound.pipelines.end()) return found->second;
D3D12_BLEND_DESC blend{};
Expand Down Expand Up @@ -1492,11 +1499,42 @@ ID3D12PipelineState* pipeline_for(BoundPipeline& bound, Translation& tr, const P
desc.SampleDesc.Count = 1;
ID3D12PipelineState* pipeline = nullptr;
X2W_ZONE("desktop pipeline creation");
const HRESULT hr = device_of(the_device)->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pipeline));
log("x2w-draw desktop pipeline for %016llx, %u targets (format %d) -> 0x%08lx (dsv %d, depth %d)", tr.key,
pass.target_count, pass.target_count ? pass.target_formats[0] : 0, static_cast<unsigned long>(hr),
static_cast<int>(dsv_format), desc.DepthStencilState.DepthEnable ? 1 : 0);
check_device("translated CreateGraphicsPipelineState", 0);
HRESULT hr = E_FAIL;
const bool injected = tr.native_candidate && x2w_local::env_on("X2W_TEST_NATIVE_GRAPHICS_PSO_FAILURE");
if (!injected) {
hr = device_of(the_device)->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pipeline));
log("x2w-draw desktop pipeline for %016llx, %u targets (format %d) -> 0x%08lx (dsv %d, depth %d)", tr.key,
pass.target_count, pass.target_count ? pass.target_formats[0] : 0, static_cast<unsigned long>(hr),
static_cast<int>(dsv_format), desc.DepthStencilState.DepthEnable ? 1 : 0);
check_device("translated CreateGraphicsPipelineState", 0);
}
if (FAILED(hr) && pipeline) {
pipeline->Release();
pipeline = nullptr;
}
if (FAILED(hr) && tr.native_candidate) {
// A native candidate whose shaders this device cannot turn into a PSO keeps the published pair usable.
log("x2w-draw native graphics %016llx candidate pipeline failed 0x%08lx%s", tr.key,
static_cast<unsigned long>(hr), injected ? " (injected)" : "");
if (!native_shaders_only()) {
Translation fallback;
fallback.key = tr.key;
fallback.rtv_request = tr.rtv_request;
load_translation(fallback, tr.rtv_request, {}, false);
if (fallback.state == 1) {
fallback.revision = tr.revision + 1;
tr = std::move(fallback);
log("x2w-draw native graphics %016llx published disk pair recovered", tr.key);
ID3D12PipelineState* recovered = pipeline_for(bound, tr, pass, indexed_rect);
if (!recovered)
log("x2w-draw native graphics %016llx published disk pair pipeline failed", tr.key);
return recovered;
}
log("x2w-draw native graphics %016llx no valid published disk pair", tr.key);
} else {
log("x2w-draw native graphics %016llx no published disk pair in native-only mode", tr.key);
}
}
bound.pipelines[key] = pipeline;
if (pipeline) {
wchar_t path[MAX_PATH];
Expand Down Expand Up @@ -2523,7 +2561,8 @@ IndirectBufferView indirect_table_buffer(Wrapper* self, const std::uint32_t* wor
const Wrapper* owner = nullptr;
bool own_memory = false;
if (why) *why = nullptr;
if (words[0] == view_token_magic) {
const bool view_token_input = words[0] == view_token_magic;
if (view_token_input) {
ViewRecord record{};
AcquireSRWLockShared(&note_lock);
if (words[1] < view_records().size()) record = view_records()[words[1]];
Expand Down Expand Up @@ -2607,7 +2646,9 @@ IndirectBufferView indirect_table_buffer(Wrapper* self, const std::uint32_t* wor
owner = placed.owner;
native = static_cast<ID3D12Resource*>(owner->own().real);
offset = address - reinterpret_cast<u64>(owner->own().title_memory);
if (!placed.alias) {
// A view token already names a desktop resource and its range. Reading it does not require the
// title-memory alias used for raw guest addresses; the later resource/device/range checks still apply.
if (!view_token_input && !placed.alias) {
if (native && list_copied_gpu_range(self, native, offset, bytes)) {
input_source = 1; // a GPU copy of this list filled the range: the GPU buffer is the truth
} else if (allow_title_snapshot && title_input_snapshot_enabled() && bytes <= (u64{16} << 20)) {
Expand Down Expand Up @@ -2890,20 +2931,47 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI
return true;
}
if (indirect && tr) indirect->shader_key = tr->key;
if (!tr || tr->state != 1) {
if (indirect) indirect->refusal_code = indirect_refusal_code::translation_not_ready;
ReleaseSRWLockExclusive(&draw_lock);
return false;
}
// pipeline_for may replace the native candidate with the published disk translation.
// Create the PSO first, then derive every binding from the translation it leaves in tr.
bool fixed_stream = !tr->fixed_stream.empty();
bool geometry_rect = indexed_rect || (rect && fixed_stream);
ID3D12PipelineState* pipeline = ensure_draw_heap(self->own().list_device) ? pipeline_for(*bound, *tr, pass, geometry_rect) : nullptr;
if (pipeline) {
const bool recovered_fixed_stream = !tr->fixed_stream.empty();
const bool recovered_geometry_rect = indexed_rect || (rect && recovered_fixed_stream);
if (recovered_geometry_rect != geometry_rect) {
pipeline = pipeline_for(*bound, *tr, pass, recovered_geometry_rect);
geometry_rect = recovered_geometry_rect;
}
fixed_stream = recovered_fixed_stream;
}
if (indirect && indexed_rect && !pipeline) {
indirect->set_refusal("translated indexed rectangle geometry unavailable",
indirect_refusal_code::indexed_rect_unavailable);
}
if (!pipeline || (tr->samplers.heap && !prepare_draw_sampler_heap(self, pass, list, tr->samplers.reserved_fallback))) {
if (indirect && !(indexed_rect && !pipeline))
indirect->refusal_code = !pipeline ? indirect_refusal_code::pipeline_unavailable
: indirect_refusal_code::sampler_heap_unavailable;
ReleaseSRWLockExclusive(&draw_lock);
return false;
}
std::uint32_t d16_unorm16[32] = {};
FormattedBufferDescriptor formatted_buffers[32] = {};
const bool translation_ok = tr && tr->state == 1;
const bool d16_ok = translation_ok && d16_srvs_ready(*tr, pass, d16_unorm16);
const bool d16_ok = d16_srvs_ready(*tr, pass, d16_unorm16);
const bool formatted_ok = d16_ok && formatted_buffers_ready(*tr, pass, formatted_buffers);
if (!formatted_ok) {
if (indirect && tr)
indirect->refusal_code = !translation_ok ? indirect_refusal_code::translation_not_ready
: !d16_ok ? indirect_refusal_code::d16_srv_not_ready
: indirect_refusal_code::formatted_buffer_not_ready;
if (indirect)
indirect->refusal_code = !d16_ok ? indirect_refusal_code::d16_srv_not_ready
: indirect_refusal_code::formatted_buffer_not_ready;
ReleaseSRWLockExclusive(&draw_lock);
return false;
}
const bool fixed_stream = !tr->fixed_stream.empty();
D3D12_VERTEX_BUFFER_VIEW fixed_view{};
ID3D12Resource* fixed_resource = nullptr;
if (fixed_stream && (indirect || !fixed_vertex_view(self, pass, *tr, indexed, start, count, fixed_view, fixed_resource))) {
Expand Down Expand Up @@ -2966,19 +3034,6 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI
return false;
}
}
const bool geometry_rect = indexed_rect || (rect && fixed_stream);
ID3D12PipelineState* pipeline = ensure_draw_heap(self->own().list_device) ? pipeline_for(*bound, *tr, pass, geometry_rect) : nullptr;
if (indirect && indexed_rect && !pipeline) {
indirect->set_refusal("translated indexed rectangle geometry unavailable",
indirect_refusal_code::indexed_rect_unavailable);
}
if (!pipeline || (tr->samplers.heap && !prepare_draw_sampler_heap(self, pass, list, tr->samplers.reserved_fallback))) {
if (indirect && !(indexed_rect && !pipeline))
indirect->refusal_code = !pipeline ? indirect_refusal_code::pipeline_unavailable
: indirect_refusal_code::sampler_heap_unavailable;
ReleaseSRWLockExclusive(&draw_lock);
return false;
}
const bool raw_uav = std::any_of(tr->uavs.begin(), tr->uavs.end(), [](const PixelUav& uav) { return uav.raw; });
// ponytail: prove direct draws with one writable buffer first. SRVs and indexed
// draws can alias it through guest addresses, so do not guess their independence.
Expand Down
Loading
Loading