Tracking & Static Audit: 50 New Source-Level Bugs + 150 Prioritized Backlog Items [Part 2/3] #1489

Open
opened 2026-11-26 04:55:23 +00:00 by github-bot · 5 comments
Owner

@⁠hyperland956-lgtm on GitHub · 2026-11-24 16:51 UTC · original

Multi-Part Series (2/3): Part 1/3: https://github.com/ivall/xcl/issues/1488 | Part 2/3 (this issue) | Part 3/3: https://github.com/ivall/xcl/issues/1490

23. XCL-BT-023 — dev_create_pipeline_state Bypasses device_x::create_graphics_pso_tracked, Breaking RSSetDepthBiasX and CreateDerivedPipelineStateX for All Stream-Created Graphics PSOs (P1)

  • Location: crates/xcl/src/hle/d3d12x/real.rs lines 4660-4670

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'create_graphics_pso_tracked', 'dev_create_pipeline_state', 'dynamic_depth_bias': PR #927 covers Intel Arc dynamic depth bias fallback and PR #170/#303/#743 cover mesh/untranslated streams; zero issues or PRs mention dev_create_pipeline_state bypassing create_graphics_pso_tracked.

  • Root Cause: When dev_create_pipeline_state (real.rs:4660-4670) unpacks a graphics pipeline state stream via stream_pipeline, it calls graphics_pso(this, &d, riid, out) directly instead of routing through device_x::create_graphics_pso_tracked. As a result, stream-created graphics PSOs (1) never get D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS added on supported GPUs, and (2) are never registered with device_x::note_base. Any subsequent RSSetDepthBiasX or CreateDerivedPipelineStateX targeting a stream-created graphics PSO silently fails or drops the depth bias (causing severe shadow-map acne / z-fighting on decals and shadows).

  • Edge-Case / Verification Note: Verified dev_create_graphics_pso calls device_x::create_graphics_pso_tracked (which injects D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS and calls note_base), whereas dev_create_pipeline_state at real.rs:4665-4666 calls graphics_pso directly, completely skipping both.

  • Synthetic Reproducer: Create a graphics PSO using ID3D12Device2::CreatePipelineState (pipeline stream API), bind it, and call RSSetDepthBiasX (e.g. for shadow maps or decals) or CreateDerivedPipelineStateX. Because note_base was never called, device_x::base_depth_bias_info returns None, RSSetDepthBiasX cannot use native dynamic depth bias or patched-PSO fallback, and CreateDerivedPipelineStateX fails.

  • Proposed Fix & Risk: - Fix: Route the unpacked graphics D3D12_GRAPHICS_PIPELINE_STATE_DESC in dev_create_pipeline_state through device_x::create_graphics_pso_tracked (passing graphics_pso as the creation callback), matching dev_create_graphics_pso.

  • Regression Risk: Low; reuses the exact same tracked graphics PSO creation path already proven for CreateGraphicsPipelineState. (Estimated size: S)

24. XCL-BT-024 — draw_indexed_x Never Re-Syncs Mirrored Non-UMA Inline Index Buffers After Initial Bind, Rendering Stale Indices (P1)

  • Location: crates/xcl/src/hle/d3d12x/list_x.rs lines 3155-3219, 3341-3360

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'draw_indexed_x', 'sync_title_buffers', 'mirrored': PR #195 introduced mirroring, PR #222 fixed a test address collision, and PR #693 fixed skipping VirtualQuery on already-mirrored binds; zero issues or PRs report draw_indexed_x failing to re-sync updated CPU index data for mirrored inline index buffers.

  • Root Cause: draw_indexed_x (list_x.rs:3341-3360) receives an inline index buffer VA va directly as a draw parameter (rather than via IASetIndexBuffer). It calls sync_title_buffers(this, None, 0, 0, 2) (which only syncs bound vertex_titles, ignoring va because indexed is None) and then resolves the GPU VA via gpu_va(this, va, len, "DrawIndexedX indices", false). When va lies outside unified memory, gpu_va creates a mirror in MIRRORS and copies the initial bytes on the first draw; on every subsequent draw where the title updates the CPU index buffer at va, gpu_va hits the existing mirror in MIRRORS and returns it without copying the new index bytes, so the GPU permanently renders stale indices from the first draw.

  • Edge-Case / Verification Note: Checked gpu_va and mirror (list_x.rs:3120-3151): mirror copies bytes only when creating a new mirror entry; subsequent lookups return Some(m + (va - s)) directly without copying. Regular DrawIndexedInstanced relies on sync_title_buffers(this, Some((first, count, base)), ...) to refresh b.index_title's mirror, whereas draw_indexed_x passes indexed = None and never refreshes the mirror of its inline va.

  • Synthetic Reproducer: Allocate a dynamic index buffer outside unified memory (e.g., heap/stack memory), call DrawIndexedX(va, DXGI_FORMAT_R16_UINT, 6, 0) with triangle A's indices, overwrite va on the CPU with triangle B's indices, and call DrawIndexedX(va, DXGI_FORMAT_R16_UINT, 6, 0) again. The second draw still renders triangle A's indices.

  • Proposed Fix & Risk: - Fix: In draw_indexed_x, after resolving gpu_va (or before set_index_buffer), check if let Some(m) = mirrored(va, len) and copy the len bytes from va to m when readable (and optionally pass Some((0, count, 0)) with the inline index range to sync_title_buffers for tighter vertex sync).

  • Regression Risk: Very low; only copies when MIRROR_BYTES > 0 and the inline index buffer va is in MIRRORS. (Estimated size: S)

25. XCL-BT-025 — fmt_comp fills missing MUBUF typed buffer channels with (0,0,0,1) instead of c mod n and quiets 16_FLOAT sNaN payloads via f16tof32 (P1)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 5282-5284

  • Prior-Work Check: Searched all 4,430 XCL records for fmt_comp and f16tof32 NaN / c mod n (PR #875 only fixed tbuffer DST_SEL; 0 hits for MUBUF c mod n channel repetition or 16_FLOAT sNaN payload preservation).

  • Root Cause: Measured on RDNA2 gfx1036 (ProjectLeonidaL/leonida docs/buffer_formats.md:50-52, docs/shader_validation.md:1671-1711 f16_widen_probe.py), fmt_comp in emit.rs:5282-5284 has two hardware divergences: (1) for MUBUF typed buffer loads where channel index c >= n (the format's channel count), RDNA2 hardware repeats c % n (whereas TBUFFER returns 0), while XCL returns (0, 0, 0, 1) (c == 3 ? 1.0 : 0.0); (2) for 16_FLOAT NaNs, hardware widens without quieting signaling NaNs (sign | 0x7F800000 | (payload << 13)), whereas XCL calls HLSL f16tof32, which quiets bit 22 and canonicalizes NaN payloads.

  • Edge-Case / Verification Note: Alternative hypothesis: DST_SEL usually maps missing channels explicitly to SEL_0 or SEL_1. Falsification: when a V# descriptor leaves DST_SEL = XYZW on a 1-, 2-, or 3-channel format (common for R32_FLOAT or R16G16_FLOAT buffers), c >= n reaches fmt_comp directly and exposes (0,0,0,1) vs c % n.

  • Synthetic Reproducer: (1) buffer_load_format_xyzw of a 32_FLOAT buffer containing 5.0f with DST_SEL = XYZW -> hardware returns (5.0, 5.0, 5.0, 5.0), XCL returns (5.0, 0.0, 0.0, 1.0). (2) buffer_load_format_x of 16_FLOAT 0x7C01 (sNaN) -> hardware returns 0x7F802000, XCL returns quieted 0x7FC02000.

  • Proposed Fix & Risk: - Fix: Pass a is_tbuffer flag into fmt_comp so MUBUF indexes c % n and TBUFFER returns 0 for c >= n (before DST_SEL), and widen f16 NaNs via bit-exact ((h & 0x8000u) << 16) | 0x7F800000u | ((h & 0x03FFu) << 13) when (h & 0x7FFF) > 0x7C00.

  • Regression Risk: Low; localized to fmt_comp HLSL helper. (Estimated size: S)

26. XCL-BT-026 — fmt_encode typed buffer stores violate four measured RDNA2 hardware contracts (INT saturation, SCALED, float16/11/10 RTZ+max-finite, UNORM/SNORM rounding) (P1)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 5344-5358

  • Prior-Work Check: Searched all 4,430 XCL records for fmt_encode, USCALED, SSCALED, and buffer_store_format rounding/saturation (0 hits).

  • Root Cause: Measured across 1.55M elements on RDNA2 gfx1036 and RDNA3.5 gfx1150 (ProjectLeonidaL/leonida docs/buffer_formats.md:54-68,162-168), fmt_encode in emit.rs:5344-5358 violates four distinct typed-store rules: (1) UINT/SINT (ty == 4u || 5u) returns raw x and put_bits truncates instead of saturating to [0, (1<<w)-1] / [-(1<<(w-1)), (1<<(w-1))-1]; (2) USCALED/SSCALED (ty == 2u / 3u) casts (uint)f/(int)f instead of converting as UNORM/SNORM (confirmed on RDNA2: SCALED stores use normalized conversion, not raw int cast); (3) 16/11/10-bit FLOAT uses f32tof16 (RNE + overflows finite > 65504 to +inf) instead of RTZ + saturating finite overflow to max finite (0x7BFF for f16, 0x7BF for f11, 0x3DF for f10); (4) UNORM/SNORM double-rounds via f32 multiplication (0.3 * 65535 -> 19660 vs hardware 19661) and 2-bit SNORM rounds halves to even instead of away from zero.

  • Edge-Case / Verification Note: Alternative hypothesis: 1-ULP UNORM rounding differences might be invisible. Falsification: integer truncation on 16_UINT/8_UINT/10_10_10_2_UINT wraps 65536 to 0 (catastrophic index/ID corruption), finite f16 overflow creates Inf/NaN fireflies in HDR render buffers, and USCALED/SSCALED off-by-scale factors corrupt vertex/buffer writes completely.

  • Synthetic Reproducer: (1) buffer_store_format_x 16_UINT of 70000 -> hardware stores 65535, XCL stores 4464. (2) 16_FLOAT store of 65520.0 -> hardware stores 0x7BFF, XCL stores 0x7C00 (+inf). (3) 16_UNORM store of 0.3f -> hardware stores 19661, XCL stores 19660.

  • Proposed Fix & Risk: - Fix: Clamp UINT/SINT to bit-width bounds before put_bits; route USCALED/SSCALED through UNORM/SNORM store logic; implement bit-exact RTZ + max-finite saturation for f16/f11/f10; use double (or exact integer) scaling for 16-bit UNORM/SNORM and round-half-away-from-zero for 2-bit SNORM.

  • Regression Risk: Low; self-contained within fmt_encode HLSL helper. (Estimated size: M)

27. XCL-BT-027 — gameinput.rs: IGameInput::RegisterDeviceCallback completely ignores statusFilter (_filter) (P1)

  • Location: crates/xcl/src/hle/gameinput.rs lines 815-842

  • Prior-Work Check: Verified 0 overlap across ivall_xcl corpus (1 hit in #106 was unrelated loader/TLS issue).

  • Root Cause: In register_device_callback (gameinput.rs:815-842), the statusFilter parameter is named _filter: u32 and never stored or checked during initial enumeration or hotplug delivery.

  • Edge-Case / Verification Note: Titles passing GameInputDeviceAnyStatus (0xFFFFFFFF) or GameInputDeviceConnected (0x1) do not notice the missing filter, but titles registering separate callbacks for distinct status bits (e.g., audio-only or specific connect/disconnect masks) get duplicate/wrong invocations.

  • Synthetic Reproducer: Call IGameInput::RegisterDeviceCallback with statusFilter = 0 (or GameInputDeviceAudioCapture) and GameInputBlockingEnumeration; callback fires for the connected gamepad despite non-matching filter.

  • Proposed Fix & Risk: - Fix: Store status_filter: u32 in the registered callback entry and only invoke the callback when (current_status & status_filter) != 0 (for initial enumeration) or ((previous_status ^ current_status) & status_filter) != 0 (for transitions).

  • Regression Risk: Low; directly enforces Microsoft GameInput callback filtering semantics. (Estimated size: S)

28. XCL-BT-028 — image_load / image_load_mip with D16=1 truncates 32-bit UINT/SINT texels and zeroes vdst[31:16] on odd-channel loads (P1)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 2217-2223, 2455-2459

  • Prior-Work Check: Searched all 4,430 XCL records for image_load d16 saturation / high half (0 hits).

  • Root Cause: Measured on RDNA2 gfx1036 across 1D/2D/2D-array/3D textures (ProjectLeonidaL/leonida docs/shader_validation.md:1767-1778, image_d16_probe.py), image_load / image_load_mip with D16=1 saturates 32-bit UINT/SINT texels to [0, 65535] / [-32768, 32767] and preserves vdst[31:16] on odd-channel dmask counts (1 or 3 enabled channels). emit.rs:2217-2223, 2455-2459 truncates integer texels with & 0xFFFFu and overwrites the entire 32-bit vdst with high 16 bits zeroed on odd channel counts.

  • Edge-Case / Verification Note: Alternative hypothesis: games might only use image_load d16 on 16-bit or 8-bit formats where truncation equals saturation. Falsification: R32_UINT/R32_SINT visibility/ID/histogram buffers loaded via d16 wrap on values > 65535 or < -32768, and odd-channel dmask:0x1 clobbers packed high-half VGPR registers.

  • Synthetic Reproducer: Pre-load v0 = 0xCAFE_0000, execute image_load v0, v[1:2], s[0:7] dmask:0x1 d16 on an R32_UINT texel containing 100000. Hardware produces v0 = 0xCAFE_FFFF; XCL produces 0x0000_86A0.

  • Proposed Fix & Risk: - Fix: Saturate UINT/SINT texels to 16-bit bounds when d16 is set, and merge the final odd channel into (vdst & 0xFFFF0000u) | (lo & 0xFFFFu).

  • Regression Risk: Low; localized to mimg d16 output packing. (Estimated size: S)

29. XCL-BT-029 — kernelx.rs: FreeTitlePhysicalPages removes away mappings without calling lazy::unmark(at), leaving stale VEH entries in LAZY (P1)

  • Location: crates/xcl/src/hle/kernelx.rs, crates/xcl/src/hle/kernelx/lazy.rs lines kernelx.rs:1169-1176; lazy.rs:47-59

  • Prior-Work Check: Verified 0 hits across ivall_xcl corpus for lazy::unmark.

  • Root Cause: In FreeTitlePhysicalPages (kernelx.rs:1169-1176), removing an away mapping deletes it from away.page and away.at, but never calls lazy::unmark(at). Consequently, the 64 KiB VA remains in the global LAZY BTreeSet (lazy.rs:29) indefinitely.

  • Edge-Case / Verification Note: Titles that always call MapTitlePhysicalPages(va, n, ..., NULL) before FreeTitlePhysicalPages go through unmap_away which calls lazy::unmark; titles that free physical pages directly while still mapped away hit this leak.

  • Synthetic Reproducer: Allocate a physical page, map it lazily into a reserved VA (marked in LAZY), call FreeTitlePhysicalPages without unmapping, VirtualFree(MEM_RELEASE) the VA, re-reserve the same VA with PAGE_NOACCESS, and read it: lazy::handler commits it PAGE_READWRITE instead of raising an access violation.

  • Proposed Fix & Risk: - Fix: Call lazy::unmark(at); inside the if let Some(at) = away.page.remove(&*arr.add(i)) block at kernelx.rs:1171-1174.

  • Regression Risk: Low; one-line cleanup matching unmap_away. (Estimated size: S)

30. XCL-BT-030 — kernelx.rs: VirtualAllocEx(GetCurrentProcess(), ...) bypasses placeholders::alloc, UMA, sparse VRAM, and GRAPHICS_RESERVATIONS (P1)

  • Location: crates/xcl/src/hle/kernelx.rs lines 453-467

  • Prior-Work Check: Verified 0 hits across ivall_xcl corpus for virtualallocex.

  • Root Cause: VirtualFreeEx (kernelx.rs:453-463) checks proc_ == GetCurrentProcess() and forwards UMA/sparse/graphics addresses to VirtualFree, whereas VirtualAllocEx (lines 465-467) unconditionally calls mem::VirtualAllocEx(proc_, addr, size, sanitize_alloc_type(t), sanitize_protect(p)), stripping Xbox flags and bypassing VirtualAlloc (including placeholders::alloc, UMA, sparse VRAM, and GRAPHICS_RESERVATIONS).

  • Edge-Case / Verification Note: Titles that only use VirtualAlloc / VirtualAlloc2 / XMemVirtualAlloc are unaffected, but Win32/GDK allocators that route current-process allocations through VirtualAllocEx(GetCurrentProcess(), ...) silently lose GPU visibility and placeholder tracking.

  • Synthetic Reproducer: Call kernelx::VirtualAllocEx(GetCurrentProcess(), null, 0x10000, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS); host VirtualAllocEx fails with ERROR_INVALID_PARAMETER instead of allocating a sparse placeholder via placeholders::alloc.

  • Proposed Fix & Risk: - Fix: In VirtualAllocEx, if proc_ == thr::GetCurrentProcess(), delegate directly to VirtualAlloc(addr, size, t, p).

  • Regression Risk: Low; mirrors VirtualFreeEx's current-process delegation. (Estimated size: S)

31. XCL-BT-031 — resolve_subresource_x and resolve_subresource_region_x Omit title_textures::note_gpu_write(dst) and Console DXGI Format Translation (P1)

  • Location: crates/xcl/src/hle/d3d12x/list_x.rs lines 3738-3753

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'resolve_subresource_x' and 'resolve_subresource_region_x': 0 matching records across all issues, PRs, and comments.

  • Root Cause: Unlike copy_texture_region_x (list_x.rs:3612) and copy_resource_x (list_x.rs:3759), neither resolve_subresource_x (list_x.rs:3738-3742) nor resolve_subresource_region_x (list_x.rs:3747-3753) calls super::title_textures::note_gpu_write(dst). If a title resolves an MSAA render target into a placed texture tracked by title_textures, title_textures never marks dst as GPU-written and subsequently overwrites the resolved GPU image with stale CPU bytes on the next submit. Additionally, both functions forward the raw format: i32 directly to PC ResolveSubresource/ResolveSubresourceRegion without translating console-only DXGI formats via real::pc_target_format/real::pc_view_format (e.g., R9G9B9E5_SHAREDEXP promoted targets or console depth/color formats).

  • Edge-Case / Verification Note: Verified copy_texture_region_x and copy_resource_x both unconditionally call super::title_textures::note_gpu_write(dst) right next to super::present::note_use(dst, USE_COPY). resolve_subresource_x and resolve_subresource_region_x call present::note_use(dst, USE_COPY) but omit both title_textures::note_gpu_write(dst) and format translation.

  • Synthetic Reproducer: Create a placed single-sample destination texture tracked by title_textures (or with a promoted/console format) and execute ResolveSubresource or ResolveSubresourceRegion from an MSAA target into it. Either the resolve fails format validation on PC or title_textures::upload_all overwrites the resolved pixels with stale CPU memory.

  • Proposed Fix & Risk: - Fix: Call super::title_textures::note_gpu_write(dst); and translate format with real::pc_target_format(DXGI_FORMAT(format)).0 (or pc_view_format for depth) in both resolve_subresource_x and resolve_subresource_region_x.

  • Regression Risk: Very low; aligns MSAA resolve paths with copy_texture_region_x and copy_resource_x. (Estimated size: XS)

32. XCL-BT-032 — resource_barrier_x Records BEGIN_ONLY Split Transition Barriers as Completed StateAfter in title_textures::note_transitions (P1)

  • Location: crates/xcl/src/hle/d3d12x/list_x.rs lines 3486-3517

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'note_transitions', 'begin_only', 'resource_barrier_x': PR #135 introduced note_transitions and PR #1025/#1027 cover enhanced barriers and depth-UAV counting; zero issues or PRs mention BEGIN_ONLY split barriers corrupting title_textures state tracking.

  • Root Cause: In resource_barrier_x (list_x.rs:3513-3517), every transition barrier (b[0] == 0) in out is forwarded to title_textures::note_transitions(this, &t) with b[6] (StateAfter), regardless of b[1] (D3D12_RESOURCE_BARRIER_FLAGS). For a split barrier with D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY (b[1] == 1), the resource has not yet transitioned to StateAfter—it remains in a mid-transition split state until a matching END_ONLY (b[1] == 2) barrier executes (often in a later command list). Recording StateAfter on BEGIN_ONLY causes title_textures::upload_all to emit an invalid StateAfter -> COPY_DEST barrier if an upload runs before END_ONLY, triggering D3D12 debug-layer state mismatch errors or GPU hazards.

  • Edge-Case / Verification Note: Confirmed b[1] holds D3D12_RESOURCE_BARRIER_FLAGS (0 = NONE, 1 = BEGIN_ONLY, 2 = END_ONLY) and list_x.rs:3515 filters only on b[0] == 0 without checking b[1] != 1 (D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY).

  • Synthetic Reproducer: On command list A, emit a BEGIN_ONLY transition on a tracked placed texture from PIXEL_SHADER_RESOURCE to RENDER_TARGET; close and submit list A, then trigger a title_textures upload before submitting list B's END_ONLY. title_textures transitions from RENDER_TARGET (never reached) instead of waiting/tracking the actual completed state.

  • Proposed Fix & Risk: - Fix: Exclude BEGIN_ONLY barriers (b[1] != 1) when collecting transitions for title_textures::note_transitions in resource_barrier_x (only NONE and END_ONLY complete a state transition).

  • Regression Risk: Very low; single predicate addition (&& b[1] != 1) in resource_barrier_x. (Estimated size: XS)

33. XCL-BT-033 — sparse::sync_sent_range Hashes Entire 64-Byte Chunks After Sub-64-Byte GPU Readbacks, Silently Dropping Un-Uploaded CPU Writes in Same Cacheline (P1)

  • Location: crates/xcl/src/hle/d3d12x/sparse.rs lines 970-997, 1021-1038

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'sync_sent_range', 'readback_ranges', 'readback_after_execute': PR #433 addresses CPU-wait deadlock in readback_after_execute, PR #99 fixed sub-tile reclaim, and Issue #262 covers simultaneous-access; zero issues or PRs mention sync_sent_range clobbering sibling bytes in a 64-byte hash chunk.

  • Root Cause: After a GPU Write32BitValueX or Write64BitValueX (4 or 8 bytes) is read back into the CPU view by readback_after_execute (sparse.rs:1021-1038), sync_sent_range(dst, len) (sparse.rs:970-997) recomputes chunk_hash over the entire 64-byte chunk(s) covering [dst, dst + len) and writes those hashes into entry.sent[k]. Because before_execute skips uploading any 64-byte chunk whose current CPU hash matches entry.sent[k], any pending CPU writes that occurred in the other 56–60 bytes of that same 64-byte cacheline (before the readback or concurrently on another CPU thread) are hashed into entry.sent[k] as if already present in VRAM and are silently never uploaded to the GPU.

  • Edge-Case / Verification Note: Confirmed CHUNK = 64 in sparse.rs and that sync_sent_range unconditionally hashes all 64 bytes of each touched chunk from live CPU memory rather than only when len covers the full 64-byte chunk or preserving dirty status for partial chunks. Because titles pack fence/counter words adjacent to CPU-written command/constant fields in the same 64-byte cacheline, this causes real data loss.

  • Synthetic Reproducer: Place a CPU-written struct field at base + 0x00 and a GPU Write64BitValueBottomOfPipeX target at base + 0x08 (same 64-byte chunk). Have the GPU write base + 0x08 while the CPU writes base + 0x00 before readback_after_execute completes; sync_sent_range(base + 0x08, 8) hashes the full 64 bytes including base + 0x00 into entry.sent[0], causing the next before_execute to skip uploading base + 0x00 to VRAM.

  • Proposed Fix & Risk: - Fix: Only update entry.sent[k] in sync_sent_range for chunks fully covered by [dst, dst + len) (chunk_start >= dst && chunk_end <= dst + len), or invalidate (entry.sent[k] = 0) partial chunks so any modified sibling bytes are safely re-uploaded (or use sub-chunk dirty tracking).

  • Regression Risk: Low; at most triggers one 64-byte re-upload on the next submit for partially written readback cachelines (which is safe because CPU memory already holds the readback bytes too). (Estimated size: S)

34. XCL-BT-034 — stream_pipeline Unconditionally Defaults DepthEnable=TRUE Even When DEPTH_STENCIL Subobject Is Omitted and DSVFormat Is UNKNOWN (P1)

  • Location: crates/xcl/src/hle/d3d12x/real.rs lines 4549-4577

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'stream_pipeline', 'depthenable', 'dev_create_pipeline_state': PR #170 (mesh streams), PR #199 (rect list GS), PR #303 (console shader guard), and PR #743 (MS stand-in) do not mention DepthEnable defaulting in stream_pipeline.

  • Root Cause: When unpacking a D3D12_PIPELINE_STATE_STREAM_DESC into a D3D12_GRAPHICS_PIPELINE_STATE_DESC, stream_pipeline (real.rs:4549-4577) initializes d.DepthStencilState.DepthEnable = TRUE and DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL unconditionally before parsing subobjects. Per the D3D12 CreatePipelineState specification, if a pipeline stream omits D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL (or DEPTH_STENCIL1/2) AND DSVFormat == DXGI_FORMAT_UNKNOWN, DepthEnable defaults to FALSE. Leaving DepthEnable = TRUE when no DSV is bound causes D3D12 validation errors or incorrect depth-test rejection on drivers that enforce strict stream defaults.

  • Edge-Case / Verification Note: Verified stream_pipeline lines 4549-4640: there is no post-parse check clearing DepthEnable when !has_ds && d.DSVFormat == DXGI_FORMAT_UNKNOWN. In contrast, Microsoft's D3D12 CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL and runtime stream parser explicitly default DepthEnable to FALSE whenever DSVFormat == DXGI_FORMAT_UNKNOWN and no depth-stencil subobject was supplied.

  • Synthetic Reproducer: Call ID3D12Device2::CreatePipelineState with a graphics pipeline stream containing VS, PS, RTVFormats, and no DEPTH_STENCIL or DEPTH_STENCIL_FORMAT subobject (a standard fullscreen/UI/post-process stream). stream_pipeline constructs a desc with DepthEnable = TRUE, DSVFormat = UNKNOWN.

  • Proposed Fix & Risk: - Fix: Track let mut has_ds = false; while parsing stream subobjects in stream_pipeline, and after the loop set if !has_ds && d.DSVFormat == DXGI_FORMAT_UNKNOWN { d.DepthStencilState.DepthEnable = FALSE; }.

  • Regression Risk: Very low; strictly conforms to the D3D12 pipeline state stream default specification. (Estimated size: XS)

35. XCL-BT-035 — title_textures::recheck_gpu_view_sources Increments PENDING for Shadowed Textures, Permanently Leaking PENDING Counter and Breaking Fast-Path Skip (P1)

  • Location: crates/xcl/src/hle/d3d12x/title_textures.rs lines 260-266, 426-451

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'recheck_gpu_view_sources', 'recheck_source', 'shadowed': PR #288 introduced shadowed textures, PR #539/#1075/#1086/#1102 touch upload/GPU views; zero issues or PRs report PENDING counter corruption from shadowed textures in recheck_gpu_view_sources.

  • Root Cause: In title_textures.rs, the global PENDING AtomicUsize strictly counts entries in t.by_res that have pending == true (when an entry is moved to t.shadowed, PENDING is decremented; when an entry is removed from t.shadowed, PENDING is not decremented; when uncovered back to t.by_res, PENDING is incremented). However, recheck_gpu_view_sources (title_textures.rs:426-451) calls recheck_source on both t.by_res.values_mut() and t.shadowed.values_mut(). Inside recheck_source, when a shadowed texture's source address changes and !e.pending, it sets e.pending = true and executes PENDING.fetch_add(1, Ordering::Relaxed). Because upload_all only drains t.by_res (never t.shadowed), that PENDING increment is never decremented while shadowed—and if the shadowed texture is later uncovered or destroyed, PENDING leaks permanently (>= 1 forever), disabling the PENDING == 0 fast-path skip on every ExecuteCommandLists and causing double-counting if uncovered.

  • Edge-Case / Verification Note: Traced all PENDING.fetch_add and PENDING.fetch_sub call sites in title_textures.rs: shadowed entries are deliberately excluded from PENDING everywhere else (unmap_superseded decrements PENDING when moving to shadowed; Table::remove does not decrement PENDING for shadowed removals). Only recheck_gpu_view_sources violates this invariant by calling recheck_source (which increments PENDING) on t.shadowed.values_mut().

  • Synthetic Reproducer: Create two overlapping placed textures so texture A is moved to t.shadowed with pending == false. Trigger CopyPageMappingsBatchX -> recheck_gpu_view_sources() that updates texture A's gpu_view_src. Observe PENDING incremented by 1 even though t.by_res has 0 pending textures; destroy texture A and observe PENDING stays permanently non-zero.

  • Proposed Fix & Risk: - Fix: Pass a count_pending: bool parameter to recheck_source (true for t.by_res, false for t.shadowed), or only increment PENDING when recheck_source mutates an entry in t.by_res.

  • Regression Risk: Very low; 2-line invariant fix with zero behavioral side effects. (Estimated size: XS)

36. XCL-BT-036 — translated_gs_pso Copies Raw Console RTV/DSV DXGI Formats Into StreamOut Pipeline Stream Without pc_target_format / pc_view_format Translation (P1)

  • Location: crates/xcl/src/hle/d3d12x/real.rs lines 4347-4414

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'translated_gs_pso', 'pc_target_format', 'rtvformats', 'dsvformat': PR #303 guards untranslated shaders, PR #541/#605/#242/#651 cover MS-in-AS and R9G9B9E5 formats in other paths, and PR #977 adds tests; zero issues or PRs report missing pc_target_format/pc_view_format translation in translated_gs_pso.

  • Root Cause: Unlike translated_mesh_stream (real.rs:4330-4338) and pc_graphics_desc, translated_gs_pso (real.rs:4347-4414) copies d.RTVFormats and d.DSVFormat verbatim from the console D3D12_GRAPHICS_PIPELINE_STATE_DESC into the D3D12_PIPELINE_STATE_STREAM_DESC (StreamOut / mesh-emulated GS stream) without calling pc_target_format on each RTV format or pc_view_format on DSVFormat. Any geometry-shader pipeline targeting console-only formats (such as Xbox D16S8 116..=120, DXGI_FORMAT_B4G4R4A4_UNORM 115, DXGI_FORMAT_B5G5R5A1_UNORM 86, or R9G9B9E5_SHAREDEXP promoted to R11G11B10_FLOAT) fails CreatePipelineState with E_INVALIDARG.

  • Edge-Case / Verification Note: Compared translated_gs_pso (real.rs:4375-4395) directly against translated_mesh_stream (real.rs:4330-4338): translated_mesh_stream explicitly maps every RTVFormats[i] through pc_target_format and DSVFormat through pc_view_format, whereas translated_gs_pso passes d.RTVFormats and d.DSVFormat raw.

  • Synthetic Reproducer: Create a console graphics PSO containing a geometry shader (routed to translated_gs_pso) with DSVFormat = 118 (Xbox D16_UNORM_S8_UINT) or RTVFormats[0] = DXGI_FORMAT_R9G9B9E5_SHAREDEXP. CreatePipelineState fails with E_INVALIDARG instead of compiling the translated pipeline.

  • Proposed Fix & Risk: - Fix: Translate rtv_formats.RTFormats[i] = pc_target_format(d.RTVFormats[i]) for i in 0..d.NumRenderTargets.min(8) and dsv_format = pc_view_format(d.DSVFormat) inside translated_gs_pso, matching translated_mesh_stream.

  • Regression Risk: Very low; 4-line fix aligning translated_gs_pso with translated_mesh_stream. (Estimated size: XS)

37. XCL-BT-037 — upper_lanes::step() misses S_MOVRELSD_2_B32 when invalidating SGPR abstract state (P1)

  • Location: crates/xcl/src/gpu/recomp/upper_lanes.rs lines 549-555

  • Prior-Work Check: Searched all 4,430 XCL records for S_MOVRELSD_2_B32 and upper_lanes (PR #94 fixed x64_masks.rs, NOT upper_lanes.rs:549-555; 0 hits for upper_lanes.rs).

  • Root Cause: upper_lanes.rs:549-555 checks if name.starts_with("S_MOVRELD") to conservatively invalidate all SGPR abstract values (st.s.fill(SVal::Unknown)) because s_movreld_b32 writes to an M0-indexed SGPR s[dst + m0]. However, S_MOVRELSD_2_B32 (s[dst + (m0 >> 16)] = s[src + (m0 & 0xFFFF)]) does NOT start with "S_MOVRELD", so upper_lanes::step() fails to invalidate st.s. Subsequent Wave64-on-Wave32 upper-lane analysis uses stale SGPR abstract state (e.g. stale EXEC/VCC/mask values) across s_movrelsd_2_b32.

  • Edge-Case / Verification Note: Alternative hypothesis: s_movrelsd_2_b32 might rarely appear in Wave64 shaders that run through upper_lanes. Falsification: PR #94 already hit S_MOVRELSD_2_B32 in real shaders inside x64_masks.rs, proving it occurs in practice and was simply missed in upper_lanes.rs.

  • Synthetic Reproducer: Wave64 shader setting an SGPR mask in s4, overwriting s4 indirectly via s_movrelsd_2_b32 s0, s8 with m0 = 4 << 16, then using s4 in a mask operation analyzed by upper_lanes. upper_lanes retains the pre-write SVal for s4.

  • Proposed Fix & Risk: - Fix: Change the condition at upper_lanes.rs:549 to if name.starts_with("S_MOVRELD") || name.starts_with("S_MOVRELSD").

  • Regression Risk: Very low; conservative invalidation identical to S_MOVRELD. (Estimated size: XS)

38. XCL-BT-038 — v_pack_b32_f16 silently drops VOP3 abs and neg source modifiers (P1)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 3304-3308

  • Prior-Work Check: Searched all 4,430 XCL records (1,035 issues/PRs + 3,395 issue comments) for v_pack_b32_f16 (only #159 opcode census mentions it; 0 hits for abs/neg bug).

  • Root Cause: Verified on RDNA2 silicon (ProjectLeonidaL/leonida docs/design.md:306,309), v_pack_b32_f16 supports VOP3 abs (clearing bit 15) and neg (flipping bit 15) on both 16-bit sources in addition to op_sel. emit.rs:3304-3308 extracts the half via m.opsel ((a >> (m.opsel & 1) * 16) & 0xFFFF) and packs them without ever applying m.abs[0..2] (& 0x7FFF) or m.neg[0..2] (^ 0x8000).

  • Edge-Case / Verification Note: Alternative hypothesis: DXC might fold abs/neg into earlier f16 ALU ops instead of v_pack_b32_f16. Falsification: DXC routinely packs negated or absolute-value f16 scalars (e.g., flipped normal/UV components or half2 construction) directly in v_pack_b32_f16_e64 v0, -v1, |v2|.

  • Synthetic Reproducer: Assemble v_pack_b32_f16 v0, -v1, |v2| with v1 = 0x3C00 (+1.0h), v2 = 0xBC00 (-1.0h). Hardware produces v0 = 0x3C00_BC00; XCL produces 0xBC00_3C00.

  • Proposed Fix & Risk: - Fix: Apply if m.abs[i] { h &= 0x7FFF } and if m.neg[i] { h ^= 0x8000 } to both extracted 16-bit operands in emit.rs:3304-3308.

  • Regression Risk: Very low; two bitwise ops gated on m.abs / m.neg. (Estimated size: XS)

39. XCL-BT-039 — valu16 and valu64 apply VOP3 omod (mul:2/mul:4/div:2) to f16/f64 despite RDNA2 gating omod off under MODE.denorm_mode_16_64 = 3 (P1)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 2960-2965, 3186-3191

  • Prior-Work Check: Searched all 4,430 XCL records for denorm_mode_16_64 and omod on valu16/valu64 (0 hits).

  • Root Cause: Measured on RDNA2 gfx1036 (ProjectLeonidaL/leonida docs/shader_validation.md:1503-1509 f64_omod_probe.py, 1964-1971 SHADER-135), when MODE.denorm_mode_16_64 == 3 (preserve denorms on both input and output, which is the default console mode for f16 and f64), RDNA2 hardware silently ignores omod (mul:2, mul:4, div:2) on all f16 and f64 VOP3 instructions (while still honoring clamp). emit.rs:2960-2965 (valu16) and emit.rs:3186-3191 (valu64) unconditionally multiply the result by 2.0/4.0/0.5 whenever m.omod != 0.

  • Edge-Case / Verification Note: Alternative hypothesis: shaders compiled for denorm_mode_16_64 = 3 might never encode non-zero omod on f16/f64 ops. Falsification: hardware probes (f64_omod_probe.py, SHADER-135) explicitly document that non-zero omod bits in f16/f64 VOP3 encodings are ignored by silicon under denorm_mode_16_64 = 3 (and shaders that toggle s_setreg mode or carry leftover omod bits diverge by 2x/4x).

  • Synthetic Reproducer: Under default MODE.denorm_mode_16_64 = 3, execute v_add_f16_e64 v0, v1, v2 mul:2 (v1 = 1.0h, v2 = 1.0h) or v_add_f64 v[0:1], v[2:3], v[4:5] mul:2. Hardware returns 2.0 (omod ignored); XCL returns 4.0.

  • Proposed Fix & Risk: - Fix: Gate omod application in valu16 and valu64 on the shader's denorm_mode_16_64 (disable omod when denorm_mode_16_64 == 3, the default, while preserving clamp).

  • Regression Risk: Very low; gated strictly on f16/f64 omod under default denorm preservation. (Estimated size: XS)

40. XCL-BT-040 — xgameruntime/api.rs: query_interface on all XGameRuntime COM objects refuses IID_IUnknown with E_NOINTERFACE (P1)

  • Location: crates/xcl/src/hle/xgameruntime/api.rs lines 366-379

  • Prior-Work Check: Verified 0 hits across ivall_xcl corpus for query_interface E_NOINTERFACE / IID_IUnknown in xgameruntime.

  • Root Cause: At xgameruntime/api.rs:371, query_interface only accepts *iid == f.clsid, f.iids.contains(&*iid), or own(&f.clsid, &*iid). It never checks for IID_IUnknown (00000000-0000-0000-C000-000000000046), refusing it with E_NOINTERFACE.

  • Edge-Case / Verification Note: Direct GDK C thunks call QueryApiImpl with the specific provider IID and do not QI for IID_IUnknown, but generic COM helpers and debug wrappers require IID_IUnknown to succeed on every COM object.

  • Synthetic Reproducer: Call slot 0 (QueryInterface) on any object returned by QueryApiImpl with IID_IUnknown; returns E_NOINTERFACE and sets *out = null.

  • Proposed Fix & Risk: - Fix: Add *iid == IID_IUNKNOWN to the accepted condition at api.rs:371 (returning S_OK and *out = this as *mut c_void).

  • Regression Risk: Low; fundamental COM rule. (Estimated size: S)

41. XCL-BT-041 — xgameruntime/mod.rs: association_call ignores canceled flag and XUserUnregisterForDeviceAssociationChanged ignores wait, causing UAF on caller context (P1)

  • Location: crates/xcl/src/hle/xgameruntime/mod.rs lines 867-871, 891-910

  • Prior-Work Check: Verified 0 hits across ivall_xcl corpus for association_call / XUserUnregisterForDeviceAssociationChanged.

  • Root Cause: 1) association_call (mod.rs:867-871) ignores _canceled: bool and invokes r.cb(r.ctx, &r.change) even when the XTaskQueue was terminated (canceled == true). 2) XUserUnregisterForDeviceAssociationChanged (lines 907-910) removes the token from ASSOCIATION_CALLBACKS and ignores _wait, never cancelling or waiting for in-flight/queued association_call callbacks submitted on line 900 or 921.

  • Edge-Case / Verification Note: Because association callbacks are typically only queued once at sign-in, titles that keep their input manager alive until process exit may not hit the race, but titles that tear down and recreate UI/input subsystems or terminate task queues during shutdown hit a deterministic UAF.

  • Synthetic Reproducer: After XUserAddResult, call XUserRegisterForDeviceAssociationChanged on a manual-dispatch queue, immediately call XUserUnregisterForDeviceAssociationChanged(token, true), free ctx, then dispatch or terminate the queue; association_call dereferences freed ctx.

  • Proposed Fix & Risk: - Fix: Check if canceled { return; } in association_call, tag each queued AssociationCall with a shared Arc<AtomicBool> / Condvar active flag (matching gameinput.rs's CallbackEntry pattern), skip invocation if unregistered, and block when wait == true until any in-flight invocation finishes.

  • Regression Risk: Low; standard callback-unregistration synchronization. (Estimated size: M)

42. XCL-BT-042 — Float compare-and-swap atomics use bitwise InterlockedCompareExchange instead of IEEE float equality (-0.0 == +0.0, NaN != NaN) (P2)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 5008-5011, 5059

  • Prior-Work Check: Searched all 4,430 XCL records for fcmpswap, ds_cmpst_f32, and InterlockedCompareExchange float equality (0 hits).

  • Root Cause: Documented in RDNA2 ISA and verified in hardware shader contracts (Kajcsi/G6Recomp docs/shaders.md:927-932, ProjectLeonidaL/leonida docs/design.md:404), float CAS atomics (ds_cmpst_f32, buffer_atomic_fcmpswap, global_atomic_fcmpswap, image_atomic_fcmpswap, and _x2 64-bit variants) compare using IEEE-754 float equality where -0.0 == +0.0 succeeds and NaN == NaN fails. emit.rs:5008-5011 and 5059 lower all float CAS ops to raw bitwise InterlockedCompareExchange, which fails on -0.0 vs +0.0 and spuriously succeeds on identical NaN bit patterns.

  • Edge-Case / Verification Note: Alternative hypothesis: CAS retry loops for float atomic add/min/max use the exact bit pattern returned by the previous load, so -0.0 vs +0.0 only diverges on initial expected values. Falsification: direct ds_cmpst_f32 / *_fcmpswap with an expected 0.0f against stored -0.0f (or sentinel NaN) immediately diverges from hardware.

  • Synthetic Reproducer: Store -0.0f (0x80000000) in LDS/buffer, execute ds_cmpst_f32 / buffer_atomic_fcmpswap comparing against +0.0f (0x00000000) and swapping to 1.0f. Hardware succeeds and stores 1.0f; XCL fails bitwise CAS and leaves -0.0f.

  • Proposed Fix & Risk: - Fix: Wrap float CAS ops in a short CAS loop that loads cur, checks asfloat(cur) == asfloat(cmp) (handles -0.0 == +0.0 and NaN != NaN), and executes bitwise InterlockedCompareExchange(addr, cur, new_val, orig) until orig == cur or float equality is false.

  • Regression Risk: Low; only affects explicit *_fcmpswap / ds_cmpst_f32 instructions. (Estimated size: S)

43. XCL-BT-043 — acphal.rs: XApuEnqueueCommand and XApuGetResultCount report current queue length instead of cumulative enqueued/dequeued totals (P2)

  • Location: crates/xcl/src/hle/acphal.rs lines 955-962, 985-994

  • Prior-Work Check: Verified 0 hits across ivall_xcl corpus for XApuGetResultCount.

  • Root Cause: In acphal.rs:955-962, XApuEnqueueCommand writes q.len() as u32 into *count instead of a cumulative count of enqueued commands, and in acphal.rs:985-994, XApuGetResultCount writes q.len() as u32 (the same value as its return value) into *total instead of the cumulative count of dequeued results (compare VIctory apu.rs:302-307, 367, 379-383).

  • Edge-Case / Verification Note: Callers passing NULL for the optional total out-parameter or only inspecting the return value of XApuGetResultCount are unaffected.

  • Synthetic Reproducer: Enqueue 2 commands, dequeue 2 results, and call XApuGetResultCount(h, &mut total); returns 0 and sets total = 0 instead of total = 2.

  • Proposed Fix & Risk: - Fix: Add enqueued_total: u32 and dequeued_total: u32 counters (wrapping_add(1)) to XApu state and write them to the respective optional out-parameters.

  • Regression Risk: Low; aligns XApu counter semantics with Xbox XApu ABI. (Estimated size: S)

44. XCL-BT-044 — kernelx.rs: XMemVirtualQuery writes only a 32-bit CPU-only flag at +48, leaving +52..+64 uninitialized and clearing GPU visibility (P2)

  • Location: crates/xcl/src/hle/kernelx.rs lines 648-667

  • Prior-Work Check: Verified 0 overlap with ivall_xcl #650/#656 (test buffer alignment) and #1005 (coherent UMA VirtualQuery fast-path).

  • Root Cause: At kernelx.rs:665, XMemVirtualQuery writes only a 4-byte u32 (cpu as u32, bit 0 only) at offset +48 and explicitly assumes 'The caller zeroes the rest' (line 647). It neither zeroes bytes +52..+64 nor sets the GPU-accessible bit for addresses inside UMA / sparse VRAM.

  • Edge-Case / Verification Note: XboxBvhBuilder.dll zeroes the buffer and checks bit 0, so that specific caller works, but other GDK/middleware callers inspecting full 64-bit flags or GPU accessibility get stale stack bytes or wrong flags.

  • Synthetic Reproducer: Fill a 64-byte aligned buffer with 0xCC and call XMemVirtualQuery on a committed UMA buffer; bytes 52..64 remain 0xCC and bit 1 (GPU) is 0.

  • Proposed Fix & Risk: - Fix: Zero bytes +48..+64 before writing the flags field, and set the GPU-accessible bit when the queried address falls within UMA / sparse VRAM.

  • Regression Risk: Low; eliminates uninitialized output bytes. (Estimated size: S)

45. XCL-BT-045 — present::note_rtv Retains ID3D12Resource COM References Indefinitely in RTVS Without Cleanup on Descriptor Heap Destruction (COM & VRAM Leak) (P2)

  • Location: crates/xcl/src/hle/d3d12x/present.rs lines 158-171

  • Prior-Work Check: Verified 0% overlap across 4,430 ivall_xcl records. Searched 'note_rtv', 'rtvs': only PR #555 (area-filter window shrink) and unrelated format comments (#150, #242, #605) matched; zero issues or PRs report the permanent COM resource leak in present::RTVS.

  • Root Cause: present::note_rtv (present.rs:158-171) inserts (rtv_cpu_handle, res.clone()) into the global RTVS: Mutex<Option<HashMap<usize, ID3D12Resource>>> map on every CreateRenderTargetView call, incrementing the COM reference count of every render target texture. Entries are only overwritten if the exact same CPU descriptor handle address is later reused by another CreateRenderTargetView call—there is no cleanup hook when an ID3D12DescriptorHeap (RTV heap) is released or when a render target is destroyed. Titles that recreate RTV descriptor heaps (e.g., on resolution change, level load, or per-scene transient render target pools) permanently leak ID3D12Resource COM objects and their underlying VRAM allocations.

  • Edge-Case / Verification Note: Searched the entire present.rs file for RTVS: entries are inserted in note_rtv and read on OMSetRenderTargets/Present, and never removed on descriptor heap destruction or resource release. Even a single transient RTV heap with 1080p/4K render targets leaks tens to hundreds of megabytes of VRAM for the rest of the process lifetime.

  • Synthetic Reproducer: Create an RTV descriptor heap, create an ID3D12Resource render target and RTV in that heap, then call rt->Release() and rtv_heap->Release(). Observe rt's COM refcount never reaches 0 because present::RTVS still holds an ID3D12Resource clone keyed by the freed heap's CPU descriptor handle.

  • Proposed Fix & Risk: - Fix: Track RTV heap address ranges (heap_start_handle..heap_end_handle) and purge matching keys from RTVS when an RTV ID3D12DescriptorHeap is released (or store raw/weak resource pointers cleaned up on res_release instead of strong ID3D12Resource clones).

  • Regression Risk: Low; prevents unbounded VRAM retention on 6 GB GPUs during level transitions and resize events. (Estimated size: S)

46. XCL-BT-046 — v_cmp_class_f32 applies abs/neg via float arithmetic (flushing denormals & quieting sNaNs) (P2)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 2564-2573, 3633-3638, 5851

  • Prior-Work Check: PR #107 fixed v_cmp_class_f16 bitwise (& 0x7FFF / ^ 0x8000), leaving v_cmp_class_f32 still using Self::fsrc.

  • Root Cause: v_cmp_class_f32 routes src0 through Self::fsrc (abs(asfloat(...)) / -asfloat(...)) before fpclass_f32. Under HLSL/DXIL float semantics, float abs/neg can flush denormals to zero and quiet sNaNs before classification, whereas f64v (3075) and v_cmp_class_f16 (3607) manipulate the sign bit bitwise.

  • Edge-Case / Verification Note: Alternative hypothesis: DXC/driver might lower abs(asfloat(x)) to a bitwise AND on some GPUs. Falsification: HLSL does not guarantee preserving sNaN/denorm bit patterns across float abs/neg; bitwise & 0x7FFF_FFFFu / ^ 0x8000_0000u is guaranteed across all drivers.

  • Synthetic Reproducer: Synthetic GPU test: v_cmp_class_f32 vcc, |v0|, 0x001 (sNaN bit) with v0 = 0x7F800001 and |v0| with v0 = 0x00000001 (denorm).

  • Proposed Fix & Risk: - Fix: Apply abs (& 0x7FFF_FFFFu) and neg (^ 0x8000_0000u) bitwise on the raw uint bits of src0, matching v_cmp_class_f16.

  • Regression Risk: Very low. (Estimated size: XS)

47. XCL-BT-047 — v_div_scale_f32 / v_div_fmas_f32 / v_div_fixup_f32 drops pre/post-scaling and mishandles NaN q, sign, and underflow cutoff (P2)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 3471-3472, 3547-3555, 5624

  • Prior-Work Check: Searched all 4,430 XCL records; PR #823 covers f64 division ops only; f32 v_div_scale/v_div_fmas/v_div_fixup remain broken.

  • Root Cause: v_div_scale_f32 never pre-scales (2^32/2^-32) and always sets sdst = false; v_div_fmas_f32 ignores VCC; and div_fixup(q, d, n) (5624) returns q unchanged when d and n are finite non-zero even if q is NaN (hardware returns ±inf with sign(d)^sign(n)), omits the exp(n) - exp(d) <= -151 underflow cutoff, and fails to enforce sign(d) ^ sign(n).

  • Edge-Case / Verification Note: Alternative hypothesis: normal mid-range divisions do not hit exponent scaling. Falsification: shaders dividing tiny/huge world/lighting values (1e35 / 1e-10) produce NaN instead of ±inf.

  • Synthetic Reproducer: Synthetic GPU test: div_fixup(NaN, 1.0f, 2.0f) -> expected +inf, observed NaN; 1e35f / 1e-10f via full v_div_scale/rcp/fmas/fixup sequence -> expected +inf, observed NaN.

  • Proposed Fix & Risk: - Fix: Implement AMD ISA scaling predicates in v_div_scale_f32, conditional ldexp(..., ±32) in v_div_fmas_f32, and full NaN/cutoff/sign rules in div_fixup.

  • Regression Risk: Low; isolated to explicit division helper sequence. (Estimated size: M)

48. XCL-BT-048 — v_interp_p2_f16 double-rounds through binary32 instead of single-rounding to binary16 (P2)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 2025-2031

  • Prior-Work Check: Searched all 4,430 XCL records for v_interp_p2_f16 (0 hits).

  • Root Cause: v_interp_p2_f16 computes the interpolation FMA in binary32 and then narrows via to_f16_expr(...). Native RDNA2 (gfx1036) hardware measurements (Leonida/tools/interp_hw_probe.py, 30/30 ties) confirm hardware rounds fma(h20, J, p1ll) once, directly to binary16.

  • Edge-Case / Verification Note: Alternative hypothesis: 1 f16 ULP interpolation difference is rarely visible. Falsification: exact tie inputs from interp_hw_probe.py diverge bit-for-bit on all 30/30 ties.

  • Synthetic Reproducer: Synthetic shader executing v_interp_p1ll_f16 + v_interp_p2_f16 on binary16 midpoint tie inputs.

  • Proposed Fix & Risk: - Fix: Apply round-to-odd in binary32 (exact fma + error sticky bit) before calling to_f16_expr.

  • Regression Risk: Very low. (Estimated size: S)

49. XCL-BT-049 — v_min_f32 / v_max_f32 / v_min3_f32 / v_max3_f32 violate RDNA2 -0.0 < +0.0 signed-zero ordering on NVIDIA/WARP (P2)

  • Location: crates/xcl/src/gpu/recomp/emit.rs lines 2987-2992, 3362-3375

  • Prior-Work Check: PR #719 and PR #739 are test-only PRs checking NaN propagation; neither fixes nor raw-bit-tests -0.0 vs +0.0 sign ordering.

  • Root Cause: XCL emits plain HLSL min(a, b) / max(a, b). In HLSL/DXIL, the sign of min(-0.0, +0.0) and max(-0.0, +0.0) is unspecified and driver-dependent (NVIDIA/WARP differ by operand order), whereas RDNA2 strictly orders -0.0 < +0.0.

  • Edge-Case / Verification Note: Alternative hypothesis: most shaders treat -0.0 == +0.0. Falsification: shaders that inspect sign bits (asuint, copysign, oct-normal encoding) diverge when min(-0.0, +0.0) returns +0.0.

  • Synthetic Reproducer: Synthetic GPU test comparing raw asuint of v_min_f32(+0.0, -0.0) (expected 0x80000000) and v_max_f32(-0.0, +0.0) (expected 0x00000000) on NVIDIA/WARP.

  • Proposed Fix & Risk: - Fix: Wrap min/max in fmin_rdna/fmax_rdna helpers that resolve two-zero inputs via asuint(a) | asuint(b) (min) and asuint(a) & asuint(b) (max).

  • Regression Risk: Very low. (Estimated size: S)

50. XCL-BT-050 — xgameruntime/networking.rs: check_thumbprints for XNetworkingThumbprintType::Issuer only inspects chain_sha1s.get(1), failing on 4+ cert chains (P2)

  • Location: crates/xcl/src/hle/xgameruntime/networking.rs lines 421-442

  • Prior-Work Check: Verified 0 hits across ivall_xcl corpus for chain_sha1s; PR #77 only hardened malformed pin metadata and did not fix multi-intermediate issuer matching.

  • Root Cause: At networking.rs:433, check_thumbprints handles thumbprint_type == 1 (XNetworkingThumbprintType::Issuer) with chain_sha1s.get(1).is_some_and(|c| c.as_slice() == expected). In chains with 2+ intermediate certificates (length >= 4), intermediate issuers at indices 2..chain_sha1s.len()-1 are never checked.

  • Edge-Case / Verification Note: Standard 3-cert chains (Leaf -> Intermediate -> Root) only have index 1 as an intermediate and pass, so the bug only affects deeper PKI hierarchies (common in enterprise/cross-signed chains).

  • Synthetic Reproducer: Call check_thumbprints with a 4-cert chain [leaf, sub1, sub2, root] and an Issuer (type 1) pin matching sub2; returns PinCheck::Mismatch instead of PinCheck::Matched.

  • Proposed Fix & Risk: - Fix: For tp.thumbprint_type == 1, check all intermediate certificates: chain_sha1s.len() >= 3 && chain_sha1s[1..chain_sha1s.len() - 1].iter().any(|c| c.as_slice() == expected) (or chain_sha1s.get(1..).is_some_and(...) if root-as-issuer in 2-cert chains should also match).

  • Regression Risk: Low; strictly expands valid intermediate CA pin matching without weakening leaf/root checks. (Estimated size: S)


Continue Series: Part 1/3: https://github.com/ivall/xcl/issues/1488 | Part 2/3 (this issue) | Part 3/3: https://github.com/ivall/xcl/issues/1490

**@⁠hyperland956-lgtm** on GitHub · 2026-11-24 16:51 UTC · [original](https://github.com/xcl-dev/xcl/issues/1489) > **Multi-Part Series (2/3):** Part 1/3: `https://github.com/ivall/xcl/issues/1488` | **Part 2/3 (this issue)** | Part 3/3: `https://github.com/ivall/xcl/issues/1490` #### 23. `XCL-BT-023` — dev_create_pipeline_state Bypasses device_x::create_graphics_pso_tracked, Breaking RSSetDepthBiasX and CreateDerivedPipelineStateX for All Stream-Created Graphics PSOs (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/real.rs` lines `4660-4670` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'create_graphics_pso_tracked', 'dev_create_pipeline_state', 'dynamic_depth_bias': PR #927 covers Intel Arc dynamic depth bias fallback and PR #170/#303/#743 cover mesh/untranslated streams; zero issues or PRs mention dev_create_pipeline_state bypassing create_graphics_pso_tracked. * **Root Cause:** When `dev_create_pipeline_state` (`real.rs:4660-4670`) unpacks a graphics pipeline state stream via `stream_pipeline`, it calls `graphics_pso(this, &d, riid, out)` directly instead of routing through `device_x::create_graphics_pso_tracked`. As a result, stream-created graphics PSOs (1) never get `D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS` added on supported GPUs, and (2) are never registered with `device_x::note_base`. Any subsequent `RSSetDepthBiasX` or `CreateDerivedPipelineStateX` targeting a stream-created graphics PSO silently fails or drops the depth bias (causing severe shadow-map acne / z-fighting on decals and shadows). * **Edge-Case / Verification Note:** Verified `dev_create_graphics_pso` calls `device_x::create_graphics_pso_tracked` (which injects `D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS` and calls `note_base`), whereas `dev_create_pipeline_state` at `real.rs:4665-4666` calls `graphics_pso` directly, completely skipping both. * **Synthetic Reproducer:** Create a graphics PSO using `ID3D12Device2::CreatePipelineState` (pipeline stream API), bind it, and call `RSSetDepthBiasX` (e.g. for shadow maps or decals) or `CreateDerivedPipelineStateX`. Because `note_base` was never called, `device_x::base_depth_bias_info` returns `None`, `RSSetDepthBiasX` cannot use native dynamic depth bias or patched-PSO fallback, and `CreateDerivedPipelineStateX` fails. * **Proposed Fix & Risk:** - **Fix:** Route the unpacked graphics `D3D12_GRAPHICS_PIPELINE_STATE_DESC` in `dev_create_pipeline_state` through `device_x::create_graphics_pso_tracked` (passing `graphics_pso` as the creation callback), matching `dev_create_graphics_pso`. * **Regression Risk:** Low; reuses the exact same tracked graphics PSO creation path already proven for `CreateGraphicsPipelineState`. (Estimated size: `S`) #### 24. `XCL-BT-024` — draw_indexed_x Never Re-Syncs Mirrored Non-UMA Inline Index Buffers After Initial Bind, Rendering Stale Indices (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/list_x.rs` lines `3155-3219, 3341-3360` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'draw_indexed_x', 'sync_title_buffers', 'mirrored': PR #195 introduced mirroring, PR #222 fixed a test address collision, and PR #693 fixed skipping VirtualQuery on already-mirrored binds; zero issues or PRs report draw_indexed_x failing to re-sync updated CPU index data for mirrored inline index buffers. * **Root Cause:** `draw_indexed_x` (`list_x.rs:3341-3360`) receives an inline index buffer VA `va` directly as a draw parameter (rather than via `IASetIndexBuffer`). It calls `sync_title_buffers(this, None, 0, 0, 2)` (which only syncs bound `vertex_titles`, ignoring `va` because `indexed` is `None`) and then resolves the GPU VA via `gpu_va(this, va, len, "DrawIndexedX indices", false)`. When `va` lies outside unified memory, `gpu_va` creates a mirror in `MIRRORS` and copies the initial bytes on the first draw; on every subsequent draw where the title updates the CPU index buffer at `va`, `gpu_va` hits the existing mirror in `MIRRORS` and returns it without copying the new index bytes, so the GPU permanently renders stale indices from the first draw. * **Edge-Case / Verification Note:** Checked `gpu_va` and `mirror` (`list_x.rs:3120-3151`): `mirror` copies bytes only when creating a new mirror entry; subsequent lookups return `Some(m + (va - s))` directly without copying. Regular `DrawIndexedInstanced` relies on `sync_title_buffers(this, Some((first, count, base)), ...)` to refresh `b.index_title`'s mirror, whereas `draw_indexed_x` passes `indexed = None` and never refreshes the mirror of its inline `va`. * **Synthetic Reproducer:** Allocate a dynamic index buffer outside unified memory (e.g., heap/stack memory), call `DrawIndexedX(va, DXGI_FORMAT_R16_UINT, 6, 0)` with triangle A's indices, overwrite `va` on the CPU with triangle B's indices, and call `DrawIndexedX(va, DXGI_FORMAT_R16_UINT, 6, 0)` again. The second draw still renders triangle A's indices. * **Proposed Fix & Risk:** - **Fix:** In `draw_indexed_x`, after resolving `gpu_va` (or before `set_index_buffer`), check `if let Some(m) = mirrored(va, len)` and copy the `len` bytes from `va` to `m` when readable (and optionally pass `Some((0, count, 0))` with the inline index range to `sync_title_buffers` for tighter vertex sync). * **Regression Risk:** Very low; only copies when `MIRROR_BYTES > 0` and the inline index buffer `va` is in `MIRRORS`. (Estimated size: `S`) #### 25. `XCL-BT-025` — fmt_comp fills missing MUBUF typed buffer channels with (0,0,0,1) instead of c mod n and quiets 16_FLOAT sNaN payloads via f16tof32 (`P1`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `5282-5284` * **Prior-Work Check:** Searched all 4,430 XCL records for `fmt_comp` and `f16tof32` NaN / `c mod n` (PR #875 only fixed `tbuffer` `DST_SEL`; 0 hits for MUBUF `c mod n` channel repetition or `16_FLOAT` sNaN payload preservation). * **Root Cause:** Measured on RDNA2 `gfx1036` (`ProjectLeonidaL/leonida` `docs/buffer_formats.md:50-52`, `docs/shader_validation.md:1671-1711` `f16_widen_probe.py`), `fmt_comp` in `emit.rs:5282-5284` has two hardware divergences: (1) for MUBUF typed buffer loads where channel index `c >= n` (the format's channel count), RDNA2 hardware repeats `c % n` (whereas TBUFFER returns `0`), while XCL returns `(0, 0, 0, 1)` (`c == 3 ? 1.0 : 0.0`); (2) for `16_FLOAT` NaNs, hardware widens without quieting signaling NaNs (`sign | 0x7F800000 | (payload << 13)`), whereas XCL calls HLSL `f16tof32`, which quiets bit 22 and canonicalizes NaN payloads. * **Edge-Case / Verification Note:** Alternative hypothesis: `DST_SEL` usually maps missing channels explicitly to `SEL_0` or `SEL_1`. Falsification: when a V# descriptor leaves `DST_SEL = XYZW` on a 1-, 2-, or 3-channel format (common for `R32_FLOAT` or `R16G16_FLOAT` buffers), `c >= n` reaches `fmt_comp` directly and exposes `(0,0,0,1)` vs `c % n`. * **Synthetic Reproducer:** (1) `buffer_load_format_xyzw` of a `32_FLOAT` buffer containing `5.0f` with `DST_SEL = XYZW` -> hardware returns `(5.0, 5.0, 5.0, 5.0)`, XCL returns `(5.0, 0.0, 0.0, 1.0)`. (2) `buffer_load_format_x` of `16_FLOAT` `0x7C01` (sNaN) -> hardware returns `0x7F802000`, XCL returns quieted `0x7FC02000`. * **Proposed Fix & Risk:** - **Fix:** Pass a `is_tbuffer` flag into `fmt_comp` so MUBUF indexes `c % n` and TBUFFER returns `0` for `c >= n` (before `DST_SEL`), and widen f16 NaNs via bit-exact `((h & 0x8000u) << 16) | 0x7F800000u | ((h & 0x03FFu) << 13)` when `(h & 0x7FFF) > 0x7C00`. * **Regression Risk:** Low; localized to `fmt_comp` HLSL helper. (Estimated size: `S`) #### 26. `XCL-BT-026` — fmt_encode typed buffer stores violate four measured RDNA2 hardware contracts (INT saturation, SCALED, float16/11/10 RTZ+max-finite, UNORM/SNORM rounding) (`P1`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `5344-5358` * **Prior-Work Check:** Searched all 4,430 XCL records for `fmt_encode`, `USCALED`, `SSCALED`, and `buffer_store_format` rounding/saturation (0 hits). * **Root Cause:** Measured across 1.55M elements on RDNA2 `gfx1036` and RDNA3.5 `gfx1150` (`ProjectLeonidaL/leonida` `docs/buffer_formats.md:54-68,162-168`), `fmt_encode` in `emit.rs:5344-5358` violates four distinct typed-store rules: (1) `UINT`/`SINT` (`ty == 4u || 5u`) returns raw `x` and `put_bits` truncates instead of saturating to `[0, (1<<w)-1]` / `[-(1<<(w-1)), (1<<(w-1))-1]`; (2) `USCALED`/`SSCALED` (`ty == 2u / 3u`) casts `(uint)f`/`(int)f` instead of converting as `UNORM`/`SNORM` (confirmed on RDNA2: `SCALED` stores use normalized conversion, not raw int cast); (3) 16/11/10-bit `FLOAT` uses `f32tof16` (RNE + overflows finite `> 65504` to `+inf`) instead of RTZ + saturating finite overflow to max finite (`0x7BFF` for f16, `0x7BF` for f11, `0x3DF` for f10); (4) `UNORM`/`SNORM` double-rounds via `f32` multiplication (`0.3 * 65535 -> 19660` vs hardware `19661`) and 2-bit `SNORM` rounds halves to even instead of away from zero. * **Edge-Case / Verification Note:** Alternative hypothesis: 1-ULP UNORM rounding differences might be invisible. Falsification: integer truncation on `16_UINT`/`8_UINT`/`10_10_10_2_UINT` wraps `65536` to `0` (catastrophic index/ID corruption), finite f16 overflow creates `Inf`/`NaN` fireflies in HDR render buffers, and `USCALED`/`SSCALED` off-by-scale factors corrupt vertex/buffer writes completely. * **Synthetic Reproducer:** (1) `buffer_store_format_x` `16_UINT` of `70000` -> hardware stores `65535`, XCL stores `4464`. (2) `16_FLOAT` store of `65520.0` -> hardware stores `0x7BFF`, XCL stores `0x7C00` (`+inf`). (3) `16_UNORM` store of `0.3f` -> hardware stores `19661`, XCL stores `19660`. * **Proposed Fix & Risk:** - **Fix:** Clamp `UINT`/`SINT` to bit-width bounds before `put_bits`; route `USCALED`/`SSCALED` through `UNORM`/`SNORM` store logic; implement bit-exact RTZ + max-finite saturation for f16/f11/f10; use `double` (or exact integer) scaling for 16-bit `UNORM`/`SNORM` and round-half-away-from-zero for 2-bit `SNORM`. * **Regression Risk:** Low; self-contained within `fmt_encode` HLSL helper. (Estimated size: `M`) #### 27. `XCL-BT-027` — gameinput.rs: IGameInput::RegisterDeviceCallback completely ignores statusFilter (\_filter) (`P1`) * **Location:** `crates/xcl/src/hle/gameinput.rs` lines `815-842` * **Prior-Work Check:** Verified 0 overlap across ivall_xcl corpus (1 hit in #106 was unrelated loader/TLS issue). * **Root Cause:** In register_device_callback (gameinput.rs:815-842), the `statusFilter` parameter is named `_filter: u32` and never stored or checked during initial enumeration or hotplug delivery. * **Edge-Case / Verification Note:** Titles passing `GameInputDeviceAnyStatus` (0xFFFFFFFF) or `GameInputDeviceConnected` (0x1) do not notice the missing filter, but titles registering separate callbacks for distinct status bits (e.g., audio-only or specific connect/disconnect masks) get duplicate/wrong invocations. * **Synthetic Reproducer:** Call IGameInput::RegisterDeviceCallback with statusFilter = 0 (or GameInputDeviceAudioCapture) and GameInputBlockingEnumeration; callback fires for the connected gamepad despite non-matching filter. * **Proposed Fix & Risk:** - **Fix:** Store `status_filter: u32` in the registered callback entry and only invoke the callback when `(current_status & status_filter) != 0` (for initial enumeration) or `((previous_status ^ current_status) & status_filter) != 0` (for transitions). * **Regression Risk:** Low; directly enforces Microsoft GameInput callback filtering semantics. (Estimated size: `S`) #### 28. `XCL-BT-028` — image_load / image_load_mip with D16=1 truncates 32-bit UINT/SINT texels and zeroes vdst\[31:16\] on odd-channel loads (`P1`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `2217-2223, 2455-2459` * **Prior-Work Check:** Searched all 4,430 XCL records for `image_load` `d16` saturation / high half (0 hits). * **Root Cause:** Measured on RDNA2 `gfx1036` across 1D/2D/2D-array/3D textures (`ProjectLeonidaL/leonida` `docs/shader_validation.md:1767-1778`, `image_d16_probe.py`), `image_load` / `image_load_mip` with `D16=1` saturates 32-bit `UINT`/`SINT` texels to `[0, 65535]` / `[-32768, 32767]` and preserves `vdst[31:16]` on odd-channel `dmask` counts (1 or 3 enabled channels). `emit.rs:2217-2223, 2455-2459` truncates integer texels with `& 0xFFFFu` and overwrites the entire 32-bit `vdst` with high 16 bits zeroed on odd channel counts. * **Edge-Case / Verification Note:** Alternative hypothesis: games might only use `image_load d16` on 16-bit or 8-bit formats where truncation equals saturation. Falsification: `R32_UINT`/`R32_SINT` visibility/ID/histogram buffers loaded via `d16` wrap on values `> 65535` or `< -32768`, and odd-channel `dmask:0x1` clobbers packed high-half VGPR registers. * **Synthetic Reproducer:** Pre-load `v0 = 0xCAFE_0000`, execute `image_load v0, v[1:2], s[0:7] dmask:0x1 d16` on an `R32_UINT` texel containing `100000`. Hardware produces `v0 = 0xCAFE_FFFF`; XCL produces `0x0000_86A0`. * **Proposed Fix & Risk:** - **Fix:** Saturate `UINT`/`SINT` texels to 16-bit bounds when `d16` is set, and merge the final odd channel into `(vdst & 0xFFFF0000u) | (lo & 0xFFFFu)`. * **Regression Risk:** Low; localized to `mimg` `d16` output packing. (Estimated size: `S`) #### 29. `XCL-BT-029` — kernelx.rs: FreeTitlePhysicalPages removes away mappings without calling lazy::unmark(at), leaving stale VEH entries in LAZY (`P1`) * **Location:** `crates/xcl/src/hle/kernelx.rs, crates/xcl/src/hle/kernelx/lazy.rs` lines `kernelx.rs:1169-1176; lazy.rs:47-59` * **Prior-Work Check:** Verified 0 hits across ivall_xcl corpus for lazy::unmark. * **Root Cause:** In FreeTitlePhysicalPages (kernelx.rs:1169-1176), removing an away mapping deletes it from `away.page` and `away.at`, but never calls `lazy::unmark(at)`. Consequently, the 64 KiB VA remains in the global `LAZY` BTreeSet (`lazy.rs:29`) indefinitely. * **Edge-Case / Verification Note:** Titles that always call MapTitlePhysicalPages(va, n, ..., NULL) before FreeTitlePhysicalPages go through unmap_away which calls lazy::unmark; titles that free physical pages directly while still mapped away hit this leak. * **Synthetic Reproducer:** Allocate a physical page, map it lazily into a reserved VA (marked in LAZY), call FreeTitlePhysicalPages without unmapping, VirtualFree(MEM_RELEASE) the VA, re-reserve the same VA with PAGE_NOACCESS, and read it: lazy::handler commits it PAGE_READWRITE instead of raising an access violation. * **Proposed Fix & Risk:** - **Fix:** Call `lazy::unmark(at);` inside the `if let Some(at) = away.page.remove(&*arr.add(i))` block at kernelx.rs:1171-1174. * **Regression Risk:** Low; one-line cleanup matching unmap_away. (Estimated size: `S`) #### 30. `XCL-BT-030` — kernelx.rs: VirtualAllocEx(GetCurrentProcess(), ...) bypasses placeholders::alloc, UMA, sparse VRAM, and GRAPHICS_RESERVATIONS (`P1`) * **Location:** `crates/xcl/src/hle/kernelx.rs` lines `453-467` * **Prior-Work Check:** Verified 0 hits across ivall_xcl corpus for virtualallocex. * **Root Cause:** VirtualFreeEx (kernelx.rs:453-463) checks `proc_ == GetCurrentProcess()` and forwards UMA/sparse/graphics addresses to `VirtualFree`, whereas VirtualAllocEx (lines 465-467) unconditionally calls `mem::VirtualAllocEx(proc_, addr, size, sanitize_alloc_type(t), sanitize_protect(p))`, stripping Xbox flags and bypassing `VirtualAlloc` (including `placeholders::alloc`, UMA, sparse VRAM, and `GRAPHICS_RESERVATIONS`). * **Edge-Case / Verification Note:** Titles that only use VirtualAlloc / VirtualAlloc2 / XMemVirtualAlloc are unaffected, but Win32/GDK allocators that route current-process allocations through VirtualAllocEx(GetCurrentProcess(), ...) silently lose GPU visibility and placeholder tracking. * **Synthetic Reproducer:** Call kernelx::VirtualAllocEx(GetCurrentProcess(), null, 0x10000, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS); host VirtualAllocEx fails with ERROR_INVALID_PARAMETER instead of allocating a sparse placeholder via placeholders::alloc. * **Proposed Fix & Risk:** - **Fix:** In VirtualAllocEx, if `proc_ == thr::GetCurrentProcess()`, delegate directly to `VirtualAlloc(addr, size, t, p)`. * **Regression Risk:** Low; mirrors VirtualFreeEx's current-process delegation. (Estimated size: `S`) #### 31. `XCL-BT-031` — resolve_subresource_x and resolve_subresource_region_x Omit title_textures::note_gpu_write(dst) and Console DXGI Format Translation (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/list_x.rs` lines `3738-3753` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'resolve_subresource_x' and 'resolve_subresource_region_x': 0 matching records across all issues, PRs, and comments. * **Root Cause:** Unlike `copy_texture_region_x` (`list_x.rs:3612`) and `copy_resource_x` (`list_x.rs:3759`), neither `resolve_subresource_x` (`list_x.rs:3738-3742`) nor `resolve_subresource_region_x` (`list_x.rs:3747-3753`) calls `super::title_textures::note_gpu_write(dst)`. If a title resolves an MSAA render target into a placed texture tracked by `title_textures`, `title_textures` never marks `dst` as GPU-written and subsequently overwrites the resolved GPU image with stale CPU bytes on the next submit. Additionally, both functions forward the raw `format: i32` directly to PC `ResolveSubresource`/`ResolveSubresourceRegion` without translating console-only DXGI formats via `real::pc_target_format`/`real::pc_view_format` (e.g., `R9G9B9E5_SHAREDEXP` promoted targets or console depth/color formats). * **Edge-Case / Verification Note:** Verified `copy_texture_region_x` and `copy_resource_x` both unconditionally call `super::title_textures::note_gpu_write(dst)` right next to `super::present::note_use(dst, USE_COPY)`. `resolve_subresource_x` and `resolve_subresource_region_x` call `present::note_use(dst, USE_COPY)` but omit both `title_textures::note_gpu_write(dst)` and format translation. * **Synthetic Reproducer:** Create a placed single-sample destination texture tracked by `title_textures` (or with a promoted/console format) and execute `ResolveSubresource` or `ResolveSubresourceRegion` from an MSAA target into it. Either the resolve fails format validation on PC or `title_textures::upload_all` overwrites the resolved pixels with stale CPU memory. * **Proposed Fix & Risk:** - **Fix:** Call `super::title_textures::note_gpu_write(dst);` and translate `format` with `real::pc_target_format(DXGI_FORMAT(format)).0` (or `pc_view_format` for depth) in both `resolve_subresource_x` and `resolve_subresource_region_x`. * **Regression Risk:** Very low; aligns MSAA resolve paths with `copy_texture_region_x` and `copy_resource_x`. (Estimated size: `XS`) #### 32. `XCL-BT-032` — resource_barrier_x Records BEGIN_ONLY Split Transition Barriers as Completed StateAfter in title_textures::note_transitions (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/list_x.rs` lines `3486-3517` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'note_transitions', 'begin_only', 'resource_barrier_x': PR #135 introduced note_transitions and PR #1025/#1027 cover enhanced barriers and depth-UAV counting; zero issues or PRs mention BEGIN_ONLY split barriers corrupting title_textures state tracking. * **Root Cause:** In `resource_barrier_x` (`list_x.rs:3513-3517`), every transition barrier (`b[0] == 0`) in `out` is forwarded to `title_textures::note_transitions(this, &t)` with `b[6]` (`StateAfter`), regardless of `b[1]` (`D3D12_RESOURCE_BARRIER_FLAGS`). For a split barrier with `D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY` (`b[1] == 1`), the resource has **not** yet transitioned to `StateAfter`—it remains in a mid-transition split state until a matching `END_ONLY` (`b[1] == 2`) barrier executes (often in a later command list). Recording `StateAfter` on `BEGIN_ONLY` causes `title_textures::upload_all` to emit an invalid `StateAfter -> COPY_DEST` barrier if an upload runs before `END_ONLY`, triggering D3D12 debug-layer state mismatch errors or GPU hazards. * **Edge-Case / Verification Note:** Confirmed `b[1]` holds `D3D12_RESOURCE_BARRIER_FLAGS` (`0 = NONE`, `1 = BEGIN_ONLY`, `2 = END_ONLY`) and `list_x.rs:3515` filters only on `b[0] == 0` without checking `b[1] != 1` (`D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY`). * **Synthetic Reproducer:** On command list A, emit a `BEGIN_ONLY` transition on a tracked placed texture from `PIXEL_SHADER_RESOURCE` to `RENDER_TARGET`; close and submit list A, then trigger a `title_textures` upload before submitting list B's `END_ONLY`. `title_textures` transitions from `RENDER_TARGET` (never reached) instead of waiting/tracking the actual completed state. * **Proposed Fix & Risk:** - **Fix:** Exclude `BEGIN_ONLY` barriers (`b[1] != 1`) when collecting transitions for `title_textures::note_transitions` in `resource_barrier_x` (only `NONE` and `END_ONLY` complete a state transition). * **Regression Risk:** Very low; single predicate addition (`&& b[1] != 1`) in `resource_barrier_x`. (Estimated size: `XS`) #### 33. `XCL-BT-033` — sparse::sync_sent_range Hashes Entire 64-Byte Chunks After Sub-64-Byte GPU Readbacks, Silently Dropping Un-Uploaded CPU Writes in Same Cacheline (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/sparse.rs` lines `970-997, 1021-1038` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'sync_sent_range', 'readback_ranges', 'readback_after_execute': PR #433 addresses CPU-wait deadlock in readback_after_execute, PR #99 fixed sub-tile reclaim, and Issue #262 covers simultaneous-access; zero issues or PRs mention sync_sent_range clobbering sibling bytes in a 64-byte hash chunk. * **Root Cause:** After a GPU `Write32BitValueX` or `Write64BitValueX` (4 or 8 bytes) is read back into the CPU view by `readback_after_execute` (`sparse.rs:1021-1038`), `sync_sent_range(dst, len)` (`sparse.rs:970-997`) recomputes `chunk_hash` over the **entire** 64-byte chunk(s) covering `[dst, dst + len)` and writes those hashes into `entry.sent[k]`. Because `before_execute` skips uploading any 64-byte chunk whose current CPU hash matches `entry.sent[k]`, any pending CPU writes that occurred in the other 56–60 bytes of that same 64-byte cacheline (before the readback or concurrently on another CPU thread) are hashed into `entry.sent[k]` as if already present in VRAM and are silently never uploaded to the GPU. * **Edge-Case / Verification Note:** Confirmed `CHUNK = 64` in `sparse.rs` and that `sync_sent_range` unconditionally hashes all 64 bytes of each touched chunk from live CPU memory rather than only when `len` covers the full 64-byte chunk or preserving dirty status for partial chunks. Because titles pack fence/counter words adjacent to CPU-written command/constant fields in the same 64-byte cacheline, this causes real data loss. * **Synthetic Reproducer:** Place a CPU-written struct field at `base + 0x00` and a GPU `Write64BitValueBottomOfPipeX` target at `base + 0x08` (same 64-byte chunk). Have the GPU write `base + 0x08` while the CPU writes `base + 0x00` before `readback_after_execute` completes; `sync_sent_range(base + 0x08, 8)` hashes the full 64 bytes including `base + 0x00` into `entry.sent[0]`, causing the next `before_execute` to skip uploading `base + 0x00` to VRAM. * **Proposed Fix & Risk:** - **Fix:** Only update `entry.sent[k]` in `sync_sent_range` for chunks fully covered by `[dst, dst + len)` (`chunk_start >= dst && chunk_end <= dst + len`), or invalidate (`entry.sent[k] = 0`) partial chunks so any modified sibling bytes are safely re-uploaded (or use sub-chunk dirty tracking). * **Regression Risk:** Low; at most triggers one 64-byte re-upload on the next submit for partially written readback cachelines (which is safe because CPU memory already holds the readback bytes too). (Estimated size: `S`) #### 34. `XCL-BT-034` — stream_pipeline Unconditionally Defaults DepthEnable=TRUE Even When DEPTH_STENCIL Subobject Is Omitted and DSVFormat Is UNKNOWN (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/real.rs` lines `4549-4577` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'stream_pipeline', 'depthenable', 'dev_create_pipeline_state': PR #170 (mesh streams), PR #199 (rect list GS), PR #303 (console shader guard), and PR #743 (MS stand-in) do not mention DepthEnable defaulting in stream_pipeline. * **Root Cause:** When unpacking a `D3D12_PIPELINE_STATE_STREAM_DESC` into a `D3D12_GRAPHICS_PIPELINE_STATE_DESC`, `stream_pipeline` (`real.rs:4549-4577`) initializes `d.DepthStencilState.DepthEnable = TRUE` and `DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL` unconditionally before parsing subobjects. Per the D3D12 `CreatePipelineState` specification, if a pipeline stream omits `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL` (or `DEPTH_STENCIL1`/`2`) AND `DSVFormat == DXGI_FORMAT_UNKNOWN`, `DepthEnable` defaults to `FALSE`. Leaving `DepthEnable = TRUE` when no DSV is bound causes D3D12 validation errors or incorrect depth-test rejection on drivers that enforce strict stream defaults. * **Edge-Case / Verification Note:** Verified `stream_pipeline` lines 4549-4640: there is no post-parse check clearing `DepthEnable` when `!has_ds && d.DSVFormat == DXGI_FORMAT_UNKNOWN`. In contrast, Microsoft's D3D12 `CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL` and runtime stream parser explicitly default `DepthEnable` to `FALSE` whenever `DSVFormat == DXGI_FORMAT_UNKNOWN` and no depth-stencil subobject was supplied. * **Synthetic Reproducer:** Call `ID3D12Device2::CreatePipelineState` with a graphics pipeline stream containing VS, PS, RTVFormats, and no `DEPTH_STENCIL` or `DEPTH_STENCIL_FORMAT` subobject (a standard fullscreen/UI/post-process stream). `stream_pipeline` constructs a desc with `DepthEnable = TRUE, DSVFormat = UNKNOWN`. * **Proposed Fix & Risk:** - **Fix:** Track `let mut has_ds = false;` while parsing stream subobjects in `stream_pipeline`, and after the loop set `if !has_ds && d.DSVFormat == DXGI_FORMAT_UNKNOWN { d.DepthStencilState.DepthEnable = FALSE; }`. * **Regression Risk:** Very low; strictly conforms to the D3D12 pipeline state stream default specification. (Estimated size: `XS`) #### 35. `XCL-BT-035` — title_textures::recheck_gpu_view_sources Increments PENDING for Shadowed Textures, Permanently Leaking PENDING Counter and Breaking Fast-Path Skip (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/title_textures.rs` lines `260-266, 426-451` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'recheck_gpu_view_sources', 'recheck_source', 'shadowed': PR #288 introduced shadowed textures, PR #539/#1075/#1086/#1102 touch upload/GPU views; zero issues or PRs report PENDING counter corruption from shadowed textures in recheck_gpu_view_sources. * **Root Cause:** In `title_textures.rs`, the global `PENDING` `AtomicUsize` strictly counts entries in `t.by_res` that have `pending == true` (when an entry is moved to `t.shadowed`, `PENDING` is decremented; when an entry is removed from `t.shadowed`, `PENDING` is not decremented; when uncovered back to `t.by_res`, `PENDING` is incremented). However, `recheck_gpu_view_sources` (`title_textures.rs:426-451`) calls `recheck_source` on **both** `t.by_res.values_mut()` and `t.shadowed.values_mut()`. Inside `recheck_source`, when a shadowed texture's source address changes and `!e.pending`, it sets `e.pending = true` and executes `PENDING.fetch_add(1, Ordering::Relaxed)`. Because `upload_all` only drains `t.by_res` (never `t.shadowed`), that `PENDING` increment is never decremented while shadowed—and if the shadowed texture is later uncovered or destroyed, `PENDING` leaks permanently (`>= 1` forever), disabling the `PENDING == 0` fast-path skip on every `ExecuteCommandLists` and causing double-counting if uncovered. * **Edge-Case / Verification Note:** Traced all `PENDING.fetch_add` and `PENDING.fetch_sub` call sites in `title_textures.rs`: `shadowed` entries are deliberately excluded from `PENDING` everywhere else (`unmap_superseded` decrements `PENDING` when moving to `shadowed`; `Table::remove` does not decrement `PENDING` for `shadowed` removals). Only `recheck_gpu_view_sources` violates this invariant by calling `recheck_source` (which increments `PENDING`) on `t.shadowed.values_mut()`. * **Synthetic Reproducer:** Create two overlapping placed textures so texture A is moved to `t.shadowed` with `pending == false`. Trigger `CopyPageMappingsBatchX` -> `recheck_gpu_view_sources()` that updates texture A's `gpu_view_src`. Observe `PENDING` incremented by 1 even though `t.by_res` has 0 pending textures; destroy texture A and observe `PENDING` stays permanently non-zero. * **Proposed Fix & Risk:** - **Fix:** Pass a `count_pending: bool` parameter to `recheck_source` (true for `t.by_res`, false for `t.shadowed`), or only increment `PENDING` when `recheck_source` mutates an entry in `t.by_res`. * **Regression Risk:** Very low; 2-line invariant fix with zero behavioral side effects. (Estimated size: `XS`) #### 36. `XCL-BT-036` — translated_gs_pso Copies Raw Console RTV/DSV DXGI Formats Into StreamOut Pipeline Stream Without pc_target_format / pc_view_format Translation (`P1`) * **Location:** `crates/xcl/src/hle/d3d12x/real.rs` lines `4347-4414` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'translated_gs_pso', 'pc_target_format', 'rtvformats', 'dsvformat': PR #303 guards untranslated shaders, PR #541/#605/#242/#651 cover MS-in-AS and R9G9B9E5 formats in other paths, and PR #977 adds tests; zero issues or PRs report missing pc_target_format/pc_view_format translation in translated_gs_pso. * **Root Cause:** Unlike `translated_mesh_stream` (`real.rs:4330-4338`) and `pc_graphics_desc`, `translated_gs_pso` (`real.rs:4347-4414`) copies `d.RTVFormats` and `d.DSVFormat` verbatim from the console `D3D12_GRAPHICS_PIPELINE_STATE_DESC` into the `D3D12_PIPELINE_STATE_STREAM_DESC` (`StreamOut` / mesh-emulated GS stream) without calling `pc_target_format` on each RTV format or `pc_view_format` on `DSVFormat`. Any geometry-shader pipeline targeting console-only formats (such as Xbox D16S8 `116..=120`, `DXGI_FORMAT_B4G4R4A4_UNORM` `115`, `DXGI_FORMAT_B5G5R5A1_UNORM` `86`, or `R9G9B9E5_SHAREDEXP` promoted to `R11G11B10_FLOAT`) fails `CreatePipelineState` with `E_INVALIDARG`. * **Edge-Case / Verification Note:** Compared `translated_gs_pso` (`real.rs:4375-4395`) directly against `translated_mesh_stream` (`real.rs:4330-4338`): `translated_mesh_stream` explicitly maps every `RTVFormats[i]` through `pc_target_format` and `DSVFormat` through `pc_view_format`, whereas `translated_gs_pso` passes `d.RTVFormats` and `d.DSVFormat` raw. * **Synthetic Reproducer:** Create a console graphics PSO containing a geometry shader (routed to `translated_gs_pso`) with `DSVFormat = 118` (Xbox `D16_UNORM_S8_UINT`) or `RTVFormats[0] = DXGI_FORMAT_R9G9B9E5_SHAREDEXP`. `CreatePipelineState` fails with `E_INVALIDARG` instead of compiling the translated pipeline. * **Proposed Fix & Risk:** - **Fix:** Translate `rtv_formats.RTFormats[i] = pc_target_format(d.RTVFormats[i])` for `i in 0..d.NumRenderTargets.min(8)` and `dsv_format = pc_view_format(d.DSVFormat)` inside `translated_gs_pso`, matching `translated_mesh_stream`. * **Regression Risk:** Very low; 4-line fix aligning `translated_gs_pso` with `translated_mesh_stream`. (Estimated size: `XS`) #### 37. `XCL-BT-037` — upper_lanes::step() misses S_MOVRELSD_2_B32 when invalidating SGPR abstract state (`P1`) * **Location:** `crates/xcl/src/gpu/recomp/upper_lanes.rs` lines `549-555` * **Prior-Work Check:** Searched all 4,430 XCL records for `S_MOVRELSD_2_B32` and `upper_lanes` (PR #94 fixed `x64_masks.rs`, NOT `upper_lanes.rs:549-555`; 0 hits for `upper_lanes.rs`). * **Root Cause:** `upper_lanes.rs:549-555` checks `if name.starts_with("S_MOVRELD")` to conservatively invalidate all SGPR abstract values (`st.s.fill(SVal::Unknown)`) because `s_movreld_b32` writes to an `M0`-indexed SGPR `s[dst + m0]`. However, `S_MOVRELSD_2_B32` (`s[dst + (m0 >> 16)] = s[src + (m0 & 0xFFFF)]`) does NOT start with `"S_MOVRELD"`, so `upper_lanes::step()` fails to invalidate `st.s`. Subsequent Wave64-on-Wave32 upper-lane analysis uses stale SGPR abstract state (e.g. stale `EXEC`/`VCC`/mask values) across `s_movrelsd_2_b32`. * **Edge-Case / Verification Note:** Alternative hypothesis: `s_movrelsd_2_b32` might rarely appear in Wave64 shaders that run through `upper_lanes`. Falsification: PR #94 already hit `S_MOVRELSD_2_B32` in real shaders inside `x64_masks.rs`, proving it occurs in practice and was simply missed in `upper_lanes.rs`. * **Synthetic Reproducer:** Wave64 shader setting an SGPR mask in `s4`, overwriting `s4` indirectly via `s_movrelsd_2_b32 s0, s8` with `m0 = 4 << 16`, then using `s4` in a mask operation analyzed by `upper_lanes`. `upper_lanes` retains the pre-write `SVal` for `s4`. * **Proposed Fix & Risk:** - **Fix:** Change the condition at `upper_lanes.rs:549` to `if name.starts_with("S_MOVRELD") || name.starts_with("S_MOVRELSD")`. * **Regression Risk:** Very low; conservative invalidation identical to `S_MOVRELD`. (Estimated size: `XS`) #### 38. `XCL-BT-038` — v_pack_b32_f16 silently drops VOP3 abs and neg source modifiers (`P1`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `3304-3308` * **Prior-Work Check:** Searched all 4,430 XCL records (1,035 issues/PRs + 3,395 issue comments) for `v_pack_b32_f16` (only #159 opcode census mentions it; 0 hits for `abs`/`neg` bug). * **Root Cause:** Verified on RDNA2 silicon (`ProjectLeonidaL/leonida` `docs/design.md:306,309`), `v_pack_b32_f16` supports VOP3 `abs` (clearing bit 15) and `neg` (flipping bit 15) on both 16-bit sources in addition to `op_sel`. `emit.rs:3304-3308` extracts the half via `m.opsel` (`(a >> (m.opsel & 1) * 16) & 0xFFFF`) and packs them without ever applying `m.abs[0..2]` (`& 0x7FFF`) or `m.neg[0..2]` (`^ 0x8000`). * **Edge-Case / Verification Note:** Alternative hypothesis: DXC might fold `abs`/`neg` into earlier f16 ALU ops instead of `v_pack_b32_f16`. Falsification: DXC routinely packs negated or absolute-value f16 scalars (e.g., flipped normal/UV components or half2 construction) directly in `v_pack_b32_f16_e64 v0, -v1, |v2|`. * **Synthetic Reproducer:** Assemble `v_pack_b32_f16 v0, -v1, |v2|` with `v1 = 0x3C00` (`+1.0h`), `v2 = 0xBC00` (`-1.0h`). Hardware produces `v0 = 0x3C00_BC00`; XCL produces `0xBC00_3C00`. * **Proposed Fix & Risk:** - **Fix:** Apply `if m.abs[i] { h &= 0x7FFF }` and `if m.neg[i] { h ^= 0x8000 }` to both extracted 16-bit operands in `emit.rs:3304-3308`. * **Regression Risk:** Very low; two bitwise ops gated on `m.abs` / `m.neg`. (Estimated size: `XS`) #### 39. `XCL-BT-039` — valu16 and valu64 apply VOP3 omod (mul:2/mul:4/div:2) to f16/f64 despite RDNA2 gating omod off under MODE.denorm_mode_16_64 = 3 (`P1`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `2960-2965, 3186-3191` * **Prior-Work Check:** Searched all 4,430 XCL records for `denorm_mode_16_64` and `omod` on `valu16`/`valu64` (0 hits). * **Root Cause:** Measured on RDNA2 `gfx1036` (`ProjectLeonidaL/leonida` `docs/shader_validation.md:1503-1509` `f64_omod_probe.py`, `1964-1971` SHADER-135), when `MODE.denorm_mode_16_64 == 3` (preserve denorms on both input and output, which is the default console mode for f16 and f64), RDNA2 hardware silently ignores `omod` (`mul:2`, `mul:4`, `div:2`) on all f16 and f64 VOP3 instructions (while still honoring `clamp`). `emit.rs:2960-2965` (`valu16`) and `emit.rs:3186-3191` (`valu64`) unconditionally multiply the result by `2.0`/`4.0`/`0.5` whenever `m.omod != 0`. * **Edge-Case / Verification Note:** Alternative hypothesis: shaders compiled for `denorm_mode_16_64 = 3` might never encode non-zero `omod` on f16/f64 ops. Falsification: hardware probes (`f64_omod_probe.py`, SHADER-135) explicitly document that non-zero `omod` bits in f16/f64 VOP3 encodings are ignored by silicon under `denorm_mode_16_64 = 3` (and shaders that toggle `s_setreg` mode or carry leftover `omod` bits diverge by 2x/4x). * **Synthetic Reproducer:** Under default `MODE.denorm_mode_16_64 = 3`, execute `v_add_f16_e64 v0, v1, v2 mul:2` (`v1 = 1.0h, v2 = 1.0h`) or `v_add_f64 v[0:1], v[2:3], v[4:5] mul:2`. Hardware returns `2.0` (`omod` ignored); XCL returns `4.0`. * **Proposed Fix & Risk:** - **Fix:** Gate `omod` application in `valu16` and `valu64` on the shader's `denorm_mode_16_64` (disable `omod` when `denorm_mode_16_64 == 3`, the default, while preserving `clamp`). * **Regression Risk:** Very low; gated strictly on f16/f64 `omod` under default denorm preservation. (Estimated size: `XS`) #### 40. `XCL-BT-040` — xgameruntime/api.rs: query_interface on all XGameRuntime COM objects refuses IID_IUnknown with E_NOINTERFACE (`P1`) * **Location:** `crates/xcl/src/hle/xgameruntime/api.rs` lines `366-379` * **Prior-Work Check:** Verified 0 hits across ivall_xcl corpus for query_interface E_NOINTERFACE / IID_IUnknown in xgameruntime. * **Root Cause:** At xgameruntime/api.rs:371, `query_interface` only accepts `*iid == f.clsid`, `f.iids.contains(&*iid)`, or `own(&f.clsid, &*iid)`. It never checks for `IID_IUnknown` (`00000000-0000-0000-C000-000000000046`), refusing it with `E_NOINTERFACE`. * **Edge-Case / Verification Note:** Direct GDK C thunks call QueryApiImpl with the specific provider IID and do not QI for IID_IUnknown, but generic COM helpers and debug wrappers require IID_IUnknown to succeed on every COM object. * **Synthetic Reproducer:** Call slot 0 (QueryInterface) on any object returned by QueryApiImpl with IID_IUnknown; returns E_NOINTERFACE and sets \*out = null. * **Proposed Fix & Risk:** - **Fix:** Add `*iid == IID_IUNKNOWN` to the accepted condition at api.rs:371 (returning S_OK and `*out = this as *mut c_void`). * **Regression Risk:** Low; fundamental COM rule. (Estimated size: `S`) #### 41. `XCL-BT-041` — xgameruntime/mod.rs: association_call ignores canceled flag and XUserUnregisterForDeviceAssociationChanged ignores wait, causing UAF on caller context (`P1`) * **Location:** `crates/xcl/src/hle/xgameruntime/mod.rs` lines `867-871, 891-910` * **Prior-Work Check:** Verified 0 hits across ivall_xcl corpus for association_call / XUserUnregisterForDeviceAssociationChanged. * **Root Cause:** 1) `association_call` (mod.rs:867-871) ignores `_canceled: bool` and invokes `r.cb(r.ctx, &r.change)` even when the XTaskQueue was terminated (`canceled == true`). 2) `XUserUnregisterForDeviceAssociationChanged` (lines 907-910) removes the token from `ASSOCIATION_CALLBACKS` and ignores `_wait`, never cancelling or waiting for in-flight/queued `association_call` callbacks submitted on line 900 or 921. * **Edge-Case / Verification Note:** Because association callbacks are typically only queued once at sign-in, titles that keep their input manager alive until process exit may not hit the race, but titles that tear down and recreate UI/input subsystems or terminate task queues during shutdown hit a deterministic UAF. * **Synthetic Reproducer:** After XUserAddResult, call XUserRegisterForDeviceAssociationChanged on a manual-dispatch queue, immediately call XUserUnregisterForDeviceAssociationChanged(token, true), free ctx, then dispatch or terminate the queue; association_call dereferences freed ctx. * **Proposed Fix & Risk:** - **Fix:** Check `if canceled { return; }` in `association_call`, tag each queued `AssociationCall` with a shared `Arc<AtomicBool>` / `Condvar` active flag (matching gameinput.rs's CallbackEntry pattern), skip invocation if unregistered, and block when `wait == true` until any in-flight invocation finishes. * **Regression Risk:** Low; standard callback-unregistration synchronization. (Estimated size: `M`) #### 42. `XCL-BT-042` — Float compare-and-swap atomics use bitwise InterlockedCompareExchange instead of IEEE float equality (-0.0 == +0.0, NaN != NaN) (`P2`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `5008-5011, 5059` * **Prior-Work Check:** Searched all 4,430 XCL records for `fcmpswap`, `ds_cmpst_f32`, and `InterlockedCompareExchange` float equality (0 hits). * **Root Cause:** Documented in RDNA2 ISA and verified in hardware shader contracts (`Kajcsi/G6Recomp` `docs/shaders.md:927-932`, `ProjectLeonidaL/leonida` `docs/design.md:404`), float CAS atomics (`ds_cmpst_f32`, `buffer_atomic_fcmpswap`, `global_atomic_fcmpswap`, `image_atomic_fcmpswap`, and `_x2` 64-bit variants) compare using IEEE-754 float equality where `-0.0 == +0.0` succeeds and `NaN == NaN` fails. `emit.rs:5008-5011` and `5059` lower all float CAS ops to raw bitwise `InterlockedCompareExchange`, which fails on `-0.0` vs `+0.0` and spuriously succeeds on identical `NaN` bit patterns. * **Edge-Case / Verification Note:** Alternative hypothesis: CAS retry loops for float atomic add/min/max use the exact bit pattern returned by the previous load, so `-0.0` vs `+0.0` only diverges on initial expected values. Falsification: direct `ds_cmpst_f32` / `*_fcmpswap` with an expected `0.0f` against stored `-0.0f` (or sentinel `NaN`) immediately diverges from hardware. * **Synthetic Reproducer:** Store `-0.0f` (`0x80000000`) in LDS/buffer, execute `ds_cmpst_f32` / `buffer_atomic_fcmpswap` comparing against `+0.0f` (`0x00000000`) and swapping to `1.0f`. Hardware succeeds and stores `1.0f`; XCL fails bitwise CAS and leaves `-0.0f`. * **Proposed Fix & Risk:** - **Fix:** Wrap float CAS ops in a short CAS loop that loads `cur`, checks `asfloat(cur) == asfloat(cmp)` (handles `-0.0 == +0.0` and `NaN != NaN`), and executes bitwise `InterlockedCompareExchange(addr, cur, new_val, orig)` until `orig == cur` or float equality is false. * **Regression Risk:** Low; only affects explicit `*_fcmpswap` / `ds_cmpst_f32` instructions. (Estimated size: `S`) #### 43. `XCL-BT-043` — acphal.rs: XApuEnqueueCommand and XApuGetResultCount report current queue length instead of cumulative enqueued/dequeued totals (`P2`) * **Location:** `crates/xcl/src/hle/acphal.rs` lines `955-962, 985-994` * **Prior-Work Check:** Verified 0 hits across ivall_xcl corpus for XApuGetResultCount. * **Root Cause:** In acphal.rs:955-962, XApuEnqueueCommand writes `q.len() as u32` into `*count` instead of a cumulative count of enqueued commands, and in acphal.rs:985-994, XApuGetResultCount writes `q.len() as u32` (the same value as its return value) into `*total` instead of the cumulative count of dequeued results (compare VIctory apu.rs:302-307, 367, 379-383). * **Edge-Case / Verification Note:** Callers passing NULL for the optional `total` out-parameter or only inspecting the return value of XApuGetResultCount are unaffected. * **Synthetic Reproducer:** Enqueue 2 commands, dequeue 2 results, and call XApuGetResultCount(h, &mut total); returns 0 and sets total = 0 instead of total = 2. * **Proposed Fix & Risk:** - **Fix:** Add `enqueued_total: u32` and `dequeued_total: u32` counters (wrapping_add(1)) to `XApu` state and write them to the respective optional out-parameters. * **Regression Risk:** Low; aligns XApu counter semantics with Xbox XApu ABI. (Estimated size: `S`) #### 44. `XCL-BT-044` — kernelx.rs: XMemVirtualQuery writes only a 32-bit CPU-only flag at +48, leaving +52..+64 uninitialized and clearing GPU visibility (`P2`) * **Location:** `crates/xcl/src/hle/kernelx.rs` lines `648-667` * **Prior-Work Check:** Verified 0 overlap with ivall_xcl #650/#656 (test buffer alignment) and #1005 (coherent UMA VirtualQuery fast-path). * **Root Cause:** At kernelx.rs:665, XMemVirtualQuery writes only a 4-byte u32 (`cpu as u32`, bit 0 only) at offset +48 and explicitly assumes 'The caller zeroes the rest' (line 647). It neither zeroes bytes +52..+64 nor sets the GPU-accessible bit for addresses inside UMA / sparse VRAM. * **Edge-Case / Verification Note:** XboxBvhBuilder.dll zeroes the buffer and checks bit 0, so that specific caller works, but other GDK/middleware callers inspecting full 64-bit flags or GPU accessibility get stale stack bytes or wrong flags. * **Synthetic Reproducer:** Fill a 64-byte aligned buffer with 0xCC and call XMemVirtualQuery on a committed UMA buffer; bytes 52..64 remain 0xCC and bit 1 (GPU) is 0. * **Proposed Fix & Risk:** - **Fix:** Zero bytes +48..+64 before writing the flags field, and set the GPU-accessible bit when the queried address falls within UMA / sparse VRAM. * **Regression Risk:** Low; eliminates uninitialized output bytes. (Estimated size: `S`) #### 45. `XCL-BT-045` — present::note_rtv Retains ID3D12Resource COM References Indefinitely in RTVS Without Cleanup on Descriptor Heap Destruction (COM & VRAM Leak) (`P2`) * **Location:** `crates/xcl/src/hle/d3d12x/present.rs` lines `158-171` * **Prior-Work Check:** Verified 0% overlap across 4,430 ivall_xcl records. Searched 'note_rtv', 'rtvs': only PR #555 (area-filter window shrink) and unrelated format comments (#150, #242, #605) matched; zero issues or PRs report the permanent COM resource leak in present::RTVS. * **Root Cause:** `present::note_rtv` (`present.rs:158-171`) inserts `(rtv_cpu_handle, res.clone())` into the global `RTVS: Mutex<Option<HashMap<usize, ID3D12Resource>>>` map on every `CreateRenderTargetView` call, incrementing the COM reference count of every render target texture. Entries are only overwritten if the exact same CPU descriptor handle address is later reused by another `CreateRenderTargetView` call—there is no cleanup hook when an `ID3D12DescriptorHeap` (RTV heap) is released or when a render target is destroyed. Titles that recreate RTV descriptor heaps (e.g., on resolution change, level load, or per-scene transient render target pools) permanently leak `ID3D12Resource` COM objects and their underlying VRAM allocations. * **Edge-Case / Verification Note:** Searched the entire `present.rs` file for `RTVS`: entries are inserted in `note_rtv` and read on `OMSetRenderTargets`/`Present`, and never removed on descriptor heap destruction or resource release. Even a single transient RTV heap with 1080p/4K render targets leaks tens to hundreds of megabytes of VRAM for the rest of the process lifetime. * **Synthetic Reproducer:** Create an RTV descriptor heap, create an `ID3D12Resource` render target and RTV in that heap, then call `rt->Release()` and `rtv_heap->Release()`. Observe `rt`'s COM refcount never reaches 0 because `present::RTVS` still holds an `ID3D12Resource` clone keyed by the freed heap's CPU descriptor handle. * **Proposed Fix & Risk:** - **Fix:** Track RTV heap address ranges `(heap_start_handle..heap_end_handle)` and purge matching keys from `RTVS` when an RTV `ID3D12DescriptorHeap` is released (or store raw/weak resource pointers cleaned up on `res_release` instead of strong `ID3D12Resource` clones). * **Regression Risk:** Low; prevents unbounded VRAM retention on 6 GB GPUs during level transitions and resize events. (Estimated size: `S`) #### 46. `XCL-BT-046` — v_cmp_class_f32 applies abs/neg via float arithmetic (flushing denormals & quieting sNaNs) (`P2`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `2564-2573, 3633-3638, 5851` * **Prior-Work Check:** PR #107 fixed `v_cmp_class_f16` bitwise (`& 0x7FFF` / `^ 0x8000`), leaving `v_cmp_class_f32` still using `Self::fsrc`. * **Root Cause:** `v_cmp_class_f32` routes `src0` through `Self::fsrc` (`abs(asfloat(...))` / `-asfloat(...)`) before `fpclass_f32`. Under HLSL/DXIL float semantics, float `abs`/`neg` can flush denormals to zero and quiet sNaNs before classification, whereas `f64v` (`3075`) and `v_cmp_class_f16` (`3607`) manipulate the sign bit bitwise. * **Edge-Case / Verification Note:** Alternative hypothesis: DXC/driver might lower `abs(asfloat(x))` to a bitwise AND on some GPUs. Falsification: HLSL does not guarantee preserving sNaN/denorm bit patterns across float `abs`/`neg`; bitwise `& 0x7FFF_FFFFu` / `^ 0x8000_0000u` is guaranteed across all drivers. * **Synthetic Reproducer:** Synthetic GPU test: `v_cmp_class_f32 vcc, |v0|, 0x001` (sNaN bit) with `v0 = 0x7F800001` and `|v0|` with `v0 = 0x00000001` (denorm). * **Proposed Fix & Risk:** - **Fix:** Apply `abs` (`& 0x7FFF_FFFFu`) and `neg` (`^ 0x8000_0000u`) bitwise on the raw `uint` bits of `src0`, matching `v_cmp_class_f16`. * **Regression Risk:** Very low. (Estimated size: `XS`) #### 47. `XCL-BT-047` — v_div_scale_f32 / v_div_fmas_f32 / v_div_fixup_f32 drops pre/post-scaling and mishandles NaN q, sign, and underflow cutoff (`P2`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `3471-3472, 3547-3555, 5624` * **Prior-Work Check:** Searched all 4,430 XCL records; PR #823 covers `f64` division ops only; `f32` `v_div_scale`/`v_div_fmas`/`v_div_fixup` remain broken. * **Root Cause:** `v_div_scale_f32` never pre-scales (`2^32`/`2^-32`) and always sets `sdst = false`; `v_div_fmas_f32` ignores VCC; and `div_fixup(q, d, n)` (`5624`) returns `q` unchanged when `d` and `n` are finite non-zero even if `q` is `NaN` (hardware returns `±inf` with `sign(d)^sign(n)`), omits the `exp(n) - exp(d) <= -151` underflow cutoff, and fails to enforce `sign(d) ^ sign(n)`. * **Edge-Case / Verification Note:** Alternative hypothesis: normal mid-range divisions do not hit exponent scaling. Falsification: shaders dividing tiny/huge world/lighting values (`1e35 / 1e-10`) produce `NaN` instead of `±inf`. * **Synthetic Reproducer:** Synthetic GPU test: `div_fixup(NaN, 1.0f, 2.0f)` -> expected `+inf`, observed `NaN`; `1e35f / 1e-10f` via full `v_div_scale`/`rcp`/`fmas`/`fixup` sequence -> expected `+inf`, observed `NaN`. * **Proposed Fix & Risk:** - **Fix:** Implement AMD ISA scaling predicates in `v_div_scale_f32`, conditional `ldexp(..., ±32)` in `v_div_fmas_f32`, and full NaN/cutoff/sign rules in `div_fixup`. * **Regression Risk:** Low; isolated to explicit division helper sequence. (Estimated size: `M`) #### 48. `XCL-BT-048` — v_interp_p2_f16 double-rounds through binary32 instead of single-rounding to binary16 (`P2`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `2025-2031` * **Prior-Work Check:** Searched all 4,430 XCL records for `v_interp_p2_f16` (0 hits). * **Root Cause:** `v_interp_p2_f16` computes the interpolation FMA in binary32 and then narrows via `to_f16_expr(...)`. Native RDNA2 (`gfx1036`) hardware measurements (`Leonida/tools/interp_hw_probe.py`, 30/30 ties) confirm hardware rounds `fma(h20, J, p1ll)` **once**, directly to binary16. * **Edge-Case / Verification Note:** Alternative hypothesis: 1 f16 ULP interpolation difference is rarely visible. Falsification: exact tie inputs from `interp_hw_probe.py` diverge bit-for-bit on all 30/30 ties. * **Synthetic Reproducer:** Synthetic shader executing `v_interp_p1ll_f16` + `v_interp_p2_f16` on binary16 midpoint tie inputs. * **Proposed Fix & Risk:** - **Fix:** Apply round-to-odd in binary32 (exact `fma` + error sticky bit) before calling `to_f16_expr`. * **Regression Risk:** Very low. (Estimated size: `S`) #### 49. `XCL-BT-049` — v_min_f32 / v_max_f32 / v_min3_f32 / v_max3_f32 violate RDNA2 -0.0 < +0.0 signed-zero ordering on NVIDIA/WARP (`P2`) * **Location:** `crates/xcl/src/gpu/recomp/emit.rs` lines `2987-2992, 3362-3375` * **Prior-Work Check:** PR #719 and PR #739 are test-only PRs checking NaN propagation; neither fixes nor raw-bit-tests `-0.0` vs `+0.0` sign ordering. * **Root Cause:** XCL emits plain HLSL `min(a, b)` / `max(a, b)`. In HLSL/DXIL, the sign of `min(-0.0, +0.0)` and `max(-0.0, +0.0)` is unspecified and driver-dependent (NVIDIA/WARP differ by operand order), whereas RDNA2 strictly orders `-0.0 < +0.0`. * **Edge-Case / Verification Note:** Alternative hypothesis: most shaders treat `-0.0 == +0.0`. Falsification: shaders that inspect sign bits (`asuint`, `copysign`, oct-normal encoding) diverge when `min(-0.0, +0.0)` returns `+0.0`. * **Synthetic Reproducer:** Synthetic GPU test comparing raw `asuint` of `v_min_f32(+0.0, -0.0)` (expected `0x80000000`) and `v_max_f32(-0.0, +0.0)` (expected `0x00000000`) on NVIDIA/WARP. * **Proposed Fix & Risk:** - **Fix:** Wrap `min`/`max` in `fmin_rdna`/`fmax_rdna` helpers that resolve two-zero inputs via `asuint(a) | asuint(b)` (min) and `asuint(a) & asuint(b)` (max). * **Regression Risk:** Very low. (Estimated size: `S`) #### 50. `XCL-BT-050` — xgameruntime/networking.rs: check_thumbprints for XNetworkingThumbprintType::Issuer only inspects chain_sha1s.get(1), failing on 4+ cert chains (`P2`) * **Location:** `crates/xcl/src/hle/xgameruntime/networking.rs` lines `421-442` * **Prior-Work Check:** Verified 0 hits across ivall_xcl corpus for chain_sha1s; PR #77 only hardened malformed pin metadata and did not fix multi-intermediate issuer matching. * **Root Cause:** At networking.rs:433, `check_thumbprints` handles thumbprint_type == 1 (XNetworkingThumbprintType::Issuer) with `chain_sha1s.get(1).is_some_and(|c| c.as_slice() == expected)`. In chains with 2+ intermediate certificates (length >= 4), intermediate issuers at indices `2..chain_sha1s.len()-1` are never checked. * **Edge-Case / Verification Note:** Standard 3-cert chains (Leaf -> Intermediate -> Root) only have index 1 as an intermediate and pass, so the bug only affects deeper PKI hierarchies (common in enterprise/cross-signed chains). * **Synthetic Reproducer:** Call check_thumbprints with a 4-cert chain \[leaf, sub1, sub2, root\] and an Issuer (type 1) pin matching sub2; returns PinCheck::Mismatch instead of PinCheck::Matched. * **Proposed Fix & Risk:** - **Fix:** For `tp.thumbprint_type == 1`, check all intermediate certificates: `chain_sha1s.len() >= 3 && chain_sha1s[1..chain_sha1s.len() - 1].iter().any(|c| c.as_slice() == expected)` (or `chain_sha1s.get(1..).is_some_and(...)` if root-as-issuer in 2-cert chains should also match). * **Regression Risk:** Low; strictly expands valid intermediate CA pin matching without weakening leaf/root checks. (Estimated size: `S`) --- > **Continue Series:** Part 1/3: `https://github.com/ivall/xcl/issues/1488` | **Part 2/3 (this issue)** | Part 3/3: `https://github.com/ivall/xcl/issues/1490`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:23 +00:00
Author
Owner

@⁠coenflict on GitHub · 2026-11-24 18:10 UTC · original

XCL-BT-033

I reproduced the partial sparse readback issue on 9e3831e1f570d3646e53ab753b19ec07eb8f1485. In the existing D3D12 readback fixture, I changed CPU byte 0, copied 8 GPU bytes back at offset 8, and scanned the page. The scan returned no upload ranges. With the local fix it returns the 64-byte chunk.

The fix hashes a complete copy-back from the GPU staging bytes and updates a clean partial chunk from its pre-copy snapshot. A partial chunk with a pending CPU write stays marked for upload, even if a later CPU write happens to restore the old chunk hash. A separate fixture exercises dirty partial, fully overwritten, and clean partial chunks in one request.

Tested

  • Windows 11 build 26340, Ryzen 7 9800X3D, RTX 5090 driver 32.0.16.2140, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug.
  • cargo test -p xcl --lib hle::d3d12x::sparse::tests -- --nocapture: 15 passed, 0 failed, 1 ignored, 0 skips with the local patch.
  • scripts/test.ps1 --nocapture on the uncommitted patch at the base above: 777 reported passed, 0 failed, 41 ignored. The pass count includes three GPU skips (two no wave64, one no heap windows). XCL_SAMPLE_* inputs were unset.

Not tested

  • Retail-title regression, readback throughput under retail load, and GPU-only writes outside the copied-back range in the same chunk.

AI use

  • Codex (gpt-6.2-sol) wrote the local patch and tests, ran them, and drafted this report.
**@⁠coenflict** on GitHub · 2026-11-24 18:10 UTC · [original](https://github.com/xcl-dev/xcl/issues/1489#issuecomment-7140268047) **XCL-BT-033** I reproduced the partial sparse readback issue on `9e3831e1f570d3646e53ab753b19ec07eb8f1485`. In the existing D3D12 readback fixture, I changed CPU byte 0, copied 8 GPU bytes back at offset 8, and scanned the page. The scan returned no upload ranges. With the local fix it returns the 64-byte chunk. The fix hashes a complete copy-back from the GPU staging bytes and updates a clean partial chunk from its pre-copy snapshot. A partial chunk with a pending CPU write stays marked for upload, even if a later CPU write happens to restore the old chunk hash. A separate fixture exercises dirty partial, fully overwritten, and clean partial chunks in one request. **Tested** - Windows 11 build 26340, Ryzen 7 9800X3D, RTX 5090 driver `32.0.16.2140`, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug. - `cargo test -p xcl --lib hle::d3d12x::sparse::tests -- --nocapture`: 15 passed, 0 failed, 1 ignored, 0 skips with the local patch. - `scripts/test.ps1 --nocapture` on the uncommitted patch at the base above: 777 reported passed, 0 failed, 41 ignored. The pass count includes three GPU skips (two no wave64, one no heap windows). `XCL_SAMPLE_*` inputs were unset. **Not tested** - Retail-title regression, readback throughput under retail load, and GPU-only writes outside the copied-back range in the same chunk. **AI use** - Codex (`gpt-6.2-sol`) wrote the local patch and tests, ran them, and drafted this report.
Author
Owner

@⁠coenflict on GitHub · 2026-11-24 18:17 UTC · original

XCL-BT-027

I reproduced the GameInput v0 status-filter bug on 9e3831e1f570d3646e53ab753b19ec07eb8f1485. A blocking registration filtered for audio capture still got the synthetic gamepad callback. The local fix checks for an overlapping bit before either initial enumeration path. In the fixture, the audio-only and zero masks yield no callback, and a combined audio-capture/connected mask yields one callback with the full current status. Microsoft GameInput v0 documentation

Tested

  • Windows 11 build 26340, Ryzen 7 9800X3D, RTX 5090 driver 32.0.16.2140, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug.
  • The new status-filter test failed before the fix. cargo test -p xcl --lib hle::gameinput::tests -- --nocapture with the patch: 10 passed, 0 failed, 0 ignored, 0 skips.
  • scripts/test.ps1 --nocapture with the uncommitted patch at the base above: 777 reported passed, 0 failed, 41 ignored. The pass count includes three GPU skips (two no wave64, one no heap windows). XCL_SAMPLE_* inputs were unset.

Not tested

  • Retail-title regression and physical device changes.

AI use

  • Codex (gpt-6.2-sol) wrote the local fix and regression test, ran the tests, and drafted this report.
**@⁠coenflict** on GitHub · 2026-11-24 18:17 UTC · [original](https://github.com/xcl-dev/xcl/issues/1489#issuecomment-7140428993) **XCL-BT-027** I reproduced the GameInput v0 status-filter bug on `9e3831e1f570d3646e53ab753b19ec07eb8f1485`. A blocking registration filtered for audio capture still got the synthetic gamepad callback. The local fix checks for an overlapping bit before either initial enumeration path. In the fixture, the audio-only and zero masks yield no callback, and a combined audio-capture/connected mask yields one callback with the full current status. [Microsoft GameInput v0 documentation](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback?view=gdk-2604) **Tested** - Windows 11 build 26340, Ryzen 7 9800X3D, RTX 5090 driver `32.0.16.2140`, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug. - The new status-filter test failed before the fix. `cargo test -p xcl --lib hle::gameinput::tests -- --nocapture` with the patch: 10 passed, 0 failed, 0 ignored, 0 skips. - `scripts/test.ps1 --nocapture` with the uncommitted patch at the base above: 777 reported passed, 0 failed, 41 ignored. The pass count includes three GPU skips (two no wave64, one no heap windows). `XCL_SAMPLE_*` inputs were unset. **Not tested** - Retail-title regression and physical device changes. **AI use** - Codex (`gpt-6.2-sol`) wrote the local fix and regression test, ran the tests, and drafted this report.
Author
Owner

@⁠AC-Storm-YT on GitHub · 2026-11-24 19:45 UTC · original

Hardware measurements for three recompiler items of this audit: XCL-BT-039, -042 and -047. The instructions ran natively on RDNA2 silicon and were compared with XCL main c160d86.

Setup

  • RDNA2: the Ryzen 7 9800X3D's integrated GPU (gfx1036), AMD driver 32.0.21045.29003, Windows 11 Pro 26200. These are OpenCL C kernels with inline RDNA assembly, so the GPU runs the exact instruction, built by the driver's OpenCL (3679.0, PAL, LC). MODE is set with s_setreg around each instruction.
  • XCL: a temporary local test, not committed, runs the same inputs through translate and runner::run on an RX 9070 XT (driver 32.0.32029.2010), wave32.
  • This is desktop RDNA2, not the console GPU. The measurements are my own: no Leonida code, data or documents were used.

XCL-BT-042: float compare-and-swap: confirmed

RDNA2 compares the floats, not the bits. In each case below the new value is 1.0, and the instructions are ds_cmpst_rtn_f32, global_atomic_fcmpswap and global_atomic_fcmpswap_x2. The integer ds_cmpst_rtn_b32 and global_atomic_cmpswap behave as XCL does, as a control.

stored compare hardware (all three float forms) XCL (InterlockedCompareExchange)
-0.0 +0.0 swaps keeps
+0.0 -0.0 swaps keeps
qNaN 0x7fc00000 the same bits keeps swaps
sNaN 0x7f800001 the same bits keeps swaps
denormal 0x00000001 +0.0, f32 denormals flushed (MODE.FP_DENORM f32 = 0) swaps keeps
denormal 0x00000001 +0.0, f32 denormals kept (= 3) keeps keeps

In f64, ±0 and NaN behave the same way. With f32 denormals flushed, ±denormals also compare equal to ±0.

XCL-BT-047: f32 division: confirmed, for quotients near the ends of the range

This is the standard sequence v_div_scale ×2, v_rcp, 5 × v_fma, v_div_fmas, v_div_fixup, over 65,491 (n, d) pairs: edge values, random words and random normal floats.

  • Hardware: all 65,491 results equal the correctly rounded n / d, including all 8,051 quotients that overflow. Those come out ±inf.
  • XCL: 12,097 differ.
    • 7,986: ±inf on the hardware, NaN in XCL. Example: 3.4e38 / 1.18e-38.
    • 2,841: a denormal quotient that XCL makes 0. Example: 1 / 3.4e38 gives 0x00200000 on the hardware.
    • 311: a normal quotient that XCL makes 0. Example: 1.4e-45 / 1e-10.
    • 77: a normal quotient that XCL makes inf. Example: 1 / 1.18e-38 gives 0x7e800001.
    • 851: off by 1 ulp.
    • 23: a zero that loses its sign. Example: -0 / 1 gives +0.
    • 8: a normal quotient or a zero that XCL makes NaN. Example: 1.4e-45 / 1.4e-45 gives 1.0 on the hardware.
  • Scope: when the exponents of n and d are both within ±60, all 14,703 pairs match exactly. So these results go wrong only near the ends of the f32 range.
  • v_div_fixup_f32 alone: 521 of 1,728 special (q, d, n) triples differ. For finite d and n, the hardware returns ±inf for a NaN q, ±0 for n = ±0, and |q| with the sign sign(d) ^ sign(n). XCL's div_fixup returns q unchanged.

XCL-BT-025: 16_FLOAT signaling NaN: confirmed, for buffer_load_format_d16_x

For all 1,022 f16 signaling NaNs (0x7C01..), the hardware returns the payload bit for bit, and XCL returns it quieted (0x7E01..). I only measured the d16 form. The setup and the other d16 results are in my comment on #1488.

XCL-BT-039: omod on f16 / f64: true, but the rule is broader than the audit says

v_add / v_mul / v_fma in f16, f32 and f64 with mul:2, mul:4 and div:2, under every IEEE and FP_DENORM setting:

  • omod is applied only when MODE.IEEE = 0 and output denormals are off for that type (FP_DENORM 0 or 1).
  • With IEEE = 1, or with FP_DENORM 2 or 3 for the type, omod is ignored. This holds for f32 too, not only f16 / f64.

XCL always applies omod and doesn't track MODE (s_denorm_mode is a no-op). In practice it matters only if a console compiler emits omod in a mode where the hardware ignores it. LLVM's AMDGPU backend folds omod only when IEEE is off and denormals are flushed, so this may not happen in real code. I haven't checked any console shaders. Note that gpu_clamp_and_omod_per_instruction expects omod to apply on f64.

Not tested

  • Wave64. The RDNA2 runs used 32-lane waves.
  • buffer_atomic_fcmpswap, image_atomic_fcmpswap and the LDS _x2 form. I measured only the global and LDS f32 forms and the global f64 form.
  • The console GPU itself, and any retail shader.
  • I haven't written a fix. All three would change crates/xcl/src, which needs a smoke run on a title I don't have.

AI use

  • Claude Code (Claude Opus 5.5) wrote the measuring scripts and the temporary XCL test, ran them on my machine, and drafted this comment.
**@⁠AC-Storm-YT** on GitHub · 2026-11-24 19:45 UTC · [original](https://github.com/xcl-dev/xcl/issues/1489#issuecomment-7142546620) Hardware measurements for three recompiler items of this audit: **XCL-BT-039, -042 and -047**. The instructions ran natively on RDNA2 silicon and were compared with XCL `main` `c160d86`. **Setup** - **RDNA2:** the Ryzen 7 9800X3D's integrated GPU (`gfx1036`), AMD driver 32.0.21045.29003, Windows 11 Pro 26200. These are OpenCL C kernels with inline RDNA assembly, so the GPU runs the exact instruction, built by the driver's OpenCL (3679.0, PAL, LC). MODE is set with `s_setreg` around each instruction. - **XCL:** a temporary local test, not committed, runs the same inputs through `translate` and `runner::run` on an RX 9070 XT (driver 32.0.32029.2010), wave32. - This is desktop RDNA2, not the console GPU. The measurements are my own: no Leonida code, data or documents were used. ### XCL-BT-042: float compare-and-swap: **confirmed** RDNA2 compares the floats, not the bits. In each case below the new value is 1.0, and the instructions are `ds_cmpst_rtn_f32`, `global_atomic_fcmpswap` and `global_atomic_fcmpswap_x2`. The integer `ds_cmpst_rtn_b32` and `global_atomic_cmpswap` behave as XCL does, as a control. | stored | compare | hardware (all three float forms) | XCL (`InterlockedCompareExchange`) | |---|---|---|---| | `-0.0` | `+0.0` | swaps | keeps | | `+0.0` | `-0.0` | swaps | keeps | | qNaN `0x7fc00000` | the same bits | keeps | swaps | | sNaN `0x7f800001` | the same bits | keeps | swaps | | denormal `0x00000001` | `+0.0`, f32 denormals **flushed** (MODE.FP_DENORM f32 = 0) | swaps | keeps | | denormal `0x00000001` | `+0.0`, f32 denormals kept (= 3) | keeps | keeps | In f64, `±0` and NaN behave the same way. With f32 denormals flushed, ±denormals also compare equal to ±0. ### XCL-BT-047: f32 division: **confirmed, for quotients near the ends of the range** This is the standard sequence `v_div_scale` ×2, `v_rcp`, 5 × `v_fma`, `v_div_fmas`, `v_div_fixup`, over 65,491 (n, d) pairs: edge values, random words and random normal floats. - **Hardware:** all 65,491 results equal the correctly rounded `n / d`, including all 8,051 quotients that overflow. Those come out ±inf. - **XCL:** **12,097 differ.** - 7,986: ±inf on the hardware, NaN in XCL. Example: `3.4e38 / 1.18e-38`. - 2,841: a denormal quotient that XCL makes 0. Example: `1 / 3.4e38` gives `0x00200000` on the hardware. - 311: a normal quotient that XCL makes 0. Example: `1.4e-45 / 1e-10`. - 77: a normal quotient that XCL makes inf. Example: `1 / 1.18e-38` gives `0x7e800001`. - 851: off by 1 ulp. - 23: a zero that loses its sign. Example: `-0 / 1` gives `+0`. - 8: a normal quotient or a zero that XCL makes NaN. Example: `1.4e-45 / 1.4e-45` gives 1.0 on the hardware. - **Scope:** when the exponents of n and d are both within ±60, all 14,703 pairs match exactly. So these results go wrong only near the ends of the f32 range. - **`v_div_fixup_f32` alone:** 521 of 1,728 special (q, d, n) triples differ. For finite d and n, the hardware returns ±inf for a NaN q, ±0 for n = ±0, and `|q|` with the sign `sign(d) ^ sign(n)`. XCL's `div_fixup` returns q unchanged. ### XCL-BT-025: 16_FLOAT signaling NaN: **confirmed, for `buffer_load_format_d16_x`** For all 1,022 f16 signaling NaNs (`0x7C01`..), the hardware returns the payload bit for bit, and XCL returns it quieted (`0x7E01`..). I only measured the d16 form. The setup and the other d16 results are in my comment on #1488. ### XCL-BT-039: omod on f16 / f64: **true, but the rule is broader than the audit says** `v_add` / `v_mul` / `v_fma` in f16, f32 and f64 with `mul:2`, `mul:4` and `div:2`, under every IEEE and FP_DENORM setting: - omod is applied **only when MODE.IEEE = 0 and output denormals are off for that type** (FP_DENORM 0 or 1). - With IEEE = 1, or with FP_DENORM 2 or 3 for the type, omod is ignored. **This holds for f32 too**, not only f16 / f64. XCL always applies omod and doesn't track MODE (`s_denorm_mode` is a no-op). In practice it matters only if a console compiler emits omod in a mode where the hardware ignores it. LLVM's AMDGPU backend folds omod only when IEEE is off and denormals are flushed, so this may not happen in real code. I haven't checked any console shaders. Note that `gpu_clamp_and_omod_per_instruction` expects omod to apply on f64. **Not tested** - Wave64. The RDNA2 runs used 32-lane waves. - `buffer_atomic_fcmpswap`, `image_atomic_fcmpswap` and the LDS `_x2` form. I measured only the global and LDS f32 forms and the global f64 form. - The console GPU itself, and any retail shader. - I haven't written a fix. All three would change `crates/xcl/src`, which needs a smoke run on a title I don't have. **AI use** - Claude Code (Claude Opus 5.5) wrote the measuring scripts and the temporary XCL test, ran them on my machine, and drafted this comment.
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 00:02 UTC · original

Taking XCL-BT-042 (float compare-and-swap atomics IEEE-754 equality across emit.rs, dxil/lower_mem.rs, and dxil/lower_image.rs):

  • Replace raw bitwise compare-exchange in fcmpswap / cmpst_f32 (32-bit and 64-bit) with bounded CAS loops using bitwise IEEE-754 ordered equality so -0.0 == +0.0 swaps and NaN == NaN does not swap (without touching PRELUDE_MEM or requiring DoubleExtensions), verified with HLSL + Direct DXIL GPU regression tests on RTX 4060.

AI use: Google Antigravity (Gemini 4 Neon).

**@⁠Decodere** on GitHub · 2026-11-25 00:02 UTC · [original](https://github.com/xcl-dev/xcl/issues/1489#issuecomment-7148077396) Taking **`XCL-BT-042`** (float compare-and-swap atomics IEEE-754 equality across `emit.rs`, `dxil/lower_mem.rs`, and `dxil/lower_image.rs`): - Replace raw bitwise compare-exchange in `fcmpswap` / `cmpst_f32` (32-bit and 64-bit) with bounded CAS loops using bitwise IEEE-754 ordered equality so `-0.0 == +0.0` swaps and `NaN == NaN` does not swap (without touching `PRELUDE_MEM` or requiring `DoubleExtensions`), verified with HLSL + Direct DXIL GPU regression tests on RTX 4060. AI use: Google Antigravity (Gemini 4 Neon).
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 01:02 UTC · original

Taking XCL-BT-043 (XApuEnqueueCommand / XApuGetResultCount cumulative counters in crates/xcl/src/hle/acphal.rs):

  • Track cumulative enqueued and dequeued counters alongside the result queue under XApu.results so *count reports total enqueued commands and *total reports total dequeued results while XApuGetResultCount keeps returning current pending length, with regression unit tests.

AI use: Google Antigravity (Gemini 4 Neon).

**@⁠Decodere** on GitHub · 2026-11-25 01:02 UTC · [original](https://github.com/xcl-dev/xcl/issues/1489#issuecomment-7149136863) Taking **`XCL-BT-043`** (`XApuEnqueueCommand` / `XApuGetResultCount` cumulative counters in `crates/xcl/src/hle/acphal.rs`): - Track cumulative `enqueued` and `dequeued` counters alongside the result queue under `XApu.results` so `*count` reports total enqueued commands and `*total` reports total dequeued results while `XApuGetResultCount` keeps returning current pending length, with regression unit tests. AI use: Google Antigravity (Gemini 4 Neon).
This discussion has been locked. Commenting is limited to contributors.
No description provided.