Commit Graph

90 Commits

Author SHA1 Message Date
b699078893 d3d12, xmem: the page mirror: the title's GPU-readable pages at heap_base + their title address (RT-PAGE-MIRROR)
A V# or 64-bit pointer the title writes into its own memory names a title address, and the translated shaders read
heap_base + sext48(address). Nothing was there: run 63 lost the device on such a V# into the stream pool's GPU-only
window, which read zeros before step 2. The mirror puts the title's bytes there.

- src/title_mirror_space.h: xmem places every XMemVirtualAlloc reservation the title lets it place (address null) in
  [16 TiB, 48 TiB), handed out in order at reservation time, so no title pointer ever holds an old address. RADV makes
  sparse buffers at a chosen address only in its top 64 TiB, where heap_base (the sparse arena) is; heap_base + an
  address there stays inside it. A reservation the range cannot take is placed by the host, as before.
- src/title_mirror.h (TitleMirror, Vulkan through hooks): 2 GiB sparse chunks at heap_base + title address
  (bufferDeviceAddressCaptureReplay), one home per physical page (64 KiB of a 32 MiB host-visible unit), every page
  that shows a physical page bound to its one home (aliases share bytes and GPU writes; a remap is a rebind), the binds
  of a submission in one batch (the last bind of a page wins), homes freed after the retire ticket.
- src/title_frames.h Feed/Attach, xmem: every change of what a page of the range shows (host views in note_mapping,
  table pages in note_table_page), in order, with the physical page's scratch bytes; attaching feeds the pages mapped
  now under g_phys_mutex.
- src/title_mirror_tracking.h: the dirty set behind a small interface (watch, unwatch, collect: re-armed before the
  caller copies), with GuardTracking (a geometry-watch cell guard per page) until a measured policy replaces it.
- DeviceState::create_page_mirror / refresh_page_mirror (first in the before-execute hook): chunks for new
  reservations, the feed bound, written pages filled again once, the batch on the arena's bind queue signalling a
  timeline value; VulkanContext::note_mirror_bind makes every queue's next submission wait for it (the ordering rule).
  Off, with one line saying why, without capture-replay addresses, aliased strict sparse buffers, the bind queue, a
  sparse arena, signed V# offsets, xmem or the write-fault handler (llvmpipe), or with LEONIDA_PAGE_MIRROR=0.
  page_mirror_covers / page_mirror_address for the readers that move onto it. A log line every 10 s.

Tests: vk_title_mirror_test (native and under Wine, Raphael iGPU and RX 7900 XTX): a title-written V# read from a buffer
and dereferenced as the translated shaders do reaches its page, an alias the same, an unbound page reads zero; a remap,
a write (one upload for two aliases) and an unmap reach the next dispatch that waits for the batch; a home is freed only
after its ticket. d3d12_page_mirror_test (Wine, the game's device over xmem's pages): after slot-31 copies the GPU-only
page, its twin and the title's view hold the bytes at heap_base + address; a title write through its view reaches them
with one upload; a remap is a rebind with no host remap; an unmapped page reads zero. xmem_test: reservations land in
the range, the pair still pairs, the feed reports attach, host maps, table copies and unmaps in order, nothing after
detaching. Linux ctest (llvmpipe) 121/121.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 04:55:14 -05:00
293fbeacad d3d12: LEONIDA_GPU_PROFILE=1 measures the GPU time of each pipeline from timestamps
A diagnostic, off by default. Each submission on a queue whose family has
timestamp bits gets a query pool, reset once at the start of its command
buffer, and bottom-of-pipe timestamps: after the opening barrier and
bindless upload, before each run of consecutive draws or dispatches of one
pipeline, after a run that another command follows, and at the end. The
difference between two consecutive timestamps is what lies between them
added to the queue's work: a run's GPU time, or "other" when no draw or
dispatch lies between. The results are read on the fence callback once the
submission is done, never waited for, and summed by pipeline under its
stages' ShaderLibrary names (as the pass trace prints them), else its id.

Every 10 s, [rt] gpu profile lines give per frame the compute, graphics
and mesh totals, other work, per queue kind the busy time (measured as
LEONIDA_GPU_LATENCY does) against the timestamped span and the share in
draws and dispatches, and the 20 pipelines with the most GPU time (ms per
frame, share, kind, calls per frame, ms per call).

PSOs register their names with the context when the profile is on, as
they already do for the device-fault report; the device passes the
families' timestamp bits to the context. Off: one test per submission and
per command. On: about 1 us per timestamp on the Raphael iGPU, submit to
idle (vk_gpu_profile_test).

vk_gpu_profile_test runs known dispatches of two pipelines and a draw
through VulkanQueue and checks each pipeline's name, calls, runs, a time
that grows with its loop count, and that the intervals add up to the span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:50:22 -05:00
fb1260d91d Local test merge: sparse arena with signed V# offsets (9d46dd647)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:34:49 -05:00
9d46dd6475 d3d12: V# bases as signed offsets when every module sign-extends them; a sparse arena only then (RT-MEMORY-MODEL)
RADV puts sparse buffers 64 TiB above ordinary ones, so with the sparse arena of the previous commit every geometry
copy and title-window block lay below heap_base and TitleBufferWindows::allocate refused it (it accepted only a
positive offset below 2^47). Shaders translated since 2026-11-24 sign-extend a V#'s 48-bit base and say so in their
index entry (vsharp_base_sign_extended), and RADV hands out every address from one 2^47 half of the 48-bit space, so
any block is within reach of heap_base as a signed offset.

- shader_library.h: VsharpBaseCensus counts the marker over every loaded module; signed only when all have it.
- The device reads V# bases signed when the census says so (or with LEONIDA_IMPORT_BELOW_ARENA=1, as before). The
  import refusal still follows that setting alone. One line logs the census.
- create_arena: the arena is sparse only with signed offsets; otherwise one allocation, and one line says why.
- TitleBufferWindows::shader_reachable replaces the positive-only check. The first failure of each Vulkan call while
  making a block, and the first block refused for its address, are logged.
- rebase_title_vsharp sign-extends a base it already rewrote below heap_base.
- device_arena_memory (for tests); cs_user_data.comp reads V# bases sign-extended, as translated shaders do.

Tests: d3d12_title_va_game_device and d3d12_geometry_views_game_device (d3d12_title_va_test --game-device: the
device the game makes, with the arena's bind queue); geometry_views_test (shader_reachable at the measured RADV
addresses and the range edges); shader_library_test (the census). Wine suite on the iGPU: 429 pass / 23 fail against
425 / 23 on main 8bc59a74c, nothing pass to fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:03:39 -05:00
55e2bd9e9e Merge pull request #2230 from Tyrannys/rt-indirect-dispatch-group-limit
indirect clamp: bound dispatch records by the device's maxComputeWorkGroupCount, not 65,535 (RT-INDIRECT-DISPATCH-GROUP-LIMIT)
2026-11-26 22:43:12 +01:00
7d5d820779 bindless: size every sampled dimension alike and name a full array as its own refusal (RT-BINDLESS-DIMENSION-LIMITS)
World runs fill one bindless image array a few minutes in: `a bindless image array is full; dimension 3: 4096
indices, 4092 T#s of 4090 textures`. Dimension 3 is 1D (ImageDimension: 2D, 2D array, 3D, 1D). From then on every
new 1D T# reads the fallback's zeros, and the console heaps count it as "no view for the T#'s format or range",
which went from 2-28 a window to over 4000.

Nothing leaks: the 4096 indices are the fallback, 4092 entries of image_entries and 3 replaced views, every one
held by a texture the runtime still has registered, and a texture's indices go back when it goes (forget_image,
the deferred bindless_slot release, remove_image). The cause is the size: size_bindings grew 2D images to 65536
but 3D and 1D only to 4096 and 2D arrays to 16384, constants that guessed how many textures of each dimension a
title keeps, whatever the device holds (RADV allows 8388606 sampled images, llvmpipe 1015808).

- vulkan_bindless.h: one maximum (max_images, 65536) for the sampled array of every single-sample dimension, in
  place of max_2d_images, max_2d_array_images, max_3d_images and max_1d_images. The 2D-array, 3D and 1D arrays
  grow together after 2D and the storage arrays, so on a device whose limits stop growth earlier none of them is
  favoured. The bound is memory (each generation's pool holds every element): 325729 descriptors on an RTX 5070,
  10-20 MiB at 32-64 bytes a descriptor. The shaders declare runtime arrays, so no shader changes; the set layout
  changes, so compute pipelines get new journal names (hash_bindless_layout) and the pipeline cache is rebuilt.
- BindlessSet::image_refusal says why add_image returned 0: no array for the dimension, the array is full, or only
  its shorter storage range is.
- d3d12_vulkan_device.cpp: bind_image_locked and bind_image_views_locked report that reason; bind_title_image
  counts it ("the bindless array of the T#'s dimension is full", or "the bindless storage arrays of the T#'s
  dimension are full") instead of "no view for the T#'s format or range". The once-per-dimension line names the
  dimension, the storage range and how many of the textures holding indices are still registered at their address.
- docs/d3d12_vulkan.md: the sizes, and the new reason.

Tests: bindless_sizing_test checks RADV's and llvmpipe's limits (every sampled dimension at 65536; on main 1D and 3D
stop at 4096) and that the three dimensions share a short budget alike. vk_bindless_dimensions_test (new, GLSL
shader) sizes a set from the device, gives 5000 live 1D, 2D-array and 3D images an index each and reads every one
through its index, then fills the rest of the array: the next is refused as full, and removed indices come back at
once or, after an erased key, at the next flush. On main it fails at "1D: 4096 indices in the set".
vk_bindless_test's index-space case filled 1D expecting the first index to be 1, which held only while the 1D
array was as short as its storage arrays; it now checks every index once and that indices above the storage arrays
go first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 14:48:57 -05:00
7a761696dc indirect clamp: bound dispatch records by the device's maxComputeWorkGroupCount
The ExecuteIndirect argument clamp (indirect_clamp.comp) cut every dispatch
record at a fixed 65,535 groups per dimension, Vulkan's guaranteed minimum.
Devices report far more in x (NVIDIA: 2^31 - 1), so a one-dimensional
indirect dispatch of more than 65,535 groups ran only its first 65,535
groups; the rest never wrote their output.

The clamp now takes the device's maxComputeWorkGroupCount per axis in its
push constants (88 bytes, was 72) and bounds dispatch records by that. The
2^20 groups-per-dispatch cap, the list budget and LEONIDA_INDIRECT_GROUP_BUDGET
are unchanged; the product check now divides instead of multiplying, since x
alone may exceed 65,535. Mesh dispatches keep 65,535 in x.

indirect_clamp_test runs real indirect dispatches through the clamped
scratch with a marker shader (one atomic per group): 70,000 x 1 x 1 ran
65,535 groups and left 4,465 unrun on main, and runs all 70,000 exactly once
now; 65,535 x 1 x 1 and 1 x 65,535 x 1 (at the old limit) run exactly once
on both. A size past the device's own limit is skipped.

Idea from codec-d/cool_fox docs/findings.md ("Blocky patches: indirect
dispatches cut at 65,535 groups"); idea only, no code taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 02:27:26 -06:00
9f98dcc617 Improve post-load GPU memory and pipeline handling (RT-POST-LOAD-GPU-MEMORY)
Fall back to a dedicated buffer allocation when the shared arena fills.
Update console descriptors and resource backing, preserve pipeline cache
entries, and replay mesh records using bounded indirect arguments. Keep
scripted input available until read and cover the runtime and translator
paths with synthetic tests.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 14:30:51 -06:00
29c356b0bc runtime test: cs_user_data's descriptor-word mode gets its own sentinel
d3d12_rebound_tables, d3d12_rebound_second_device and
d3d12_api_descriptor_copy went from pass (main) to fail at line 896 of
d3d12_title_va_test: 0/64 GPU words matched on both submissions,
although the mirrored CBV in the layer heap was right (checked by
printing the slot after the submission). They had been hidden behind
line 502 in the same executable.

main was right. Its rebound-table check selects the test shader's
indexed CBV mode with s5 = 0xFFFFFFFB. #1723 added a mode that returns
a descriptor's words instead, also on 0xFFFFFFFB, ahead of main's
branch, so the rebound tables read the words at s8 (unset, address 0)
instead of the CBV's data. #1723's mode now uses 0xFFFFFFFA, which
nothing else uses, and its one caller (the out[3] dispatch in
check_title_va) passes that. Both checks run as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:00:46 -05:00
ba626820ec Integrate post-story-load memory, queue and Vulkan runtime changes
Preserve physical window aliases across remaps, order console list values,
and replay bounded indirect graphics with captured draw state. Coordinate
pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU
and GPU coverage for the integrated paths.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 03:44:43 -06:00
b8563e949e Merge main into D3D-448-GRAPHICS (#974)
main already lays graphics root arguments out in the console layout (from s8, one dword per table: #939's
graphics-root-layout patch in #984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console,
graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds
beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two
refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not
carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did.

Conflicts:
- runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the
  Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel.
- runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by
  default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console
  dropped.
- runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack
  and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no
  conflict) stays.
- runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the
  PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays,
  reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0.
- runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window).
- runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the
  PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the
  PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped
  (main's switch is read once per process).
- runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone.
- runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and
  runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query,
  vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated.
- runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept.
- docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row.
- docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 21:44:23 -05:00
154e4ec034 Merge the #984 result (main + RT-PROTON-STORY-LOAD) into #939
The base is 8a242efeb, the merge of main and #984. 68 files conflicted; they were resolved in seven groups by
one rule: the same change in two forms keeps the base's form, everything only #939 has is kept, and where the
two solve one problem in two ways the base's is the frame and #939's plugs into it.

A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with #939's additions
ported in. Device slot 57 asks #939's NativeGraphicsFactory first and falls back to the base's
proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from #939: the providers (texture lease,
raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages),
the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: #939's
duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in.

A2 (xs_proxy_mock_test.cpp): the base's test with #939's slot 70 raw-buffer case; presentation cases follow
#939's rule that a device which ever had a handler has no queue fallback.

B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h,
pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; #939's pending_base_compile
and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps
the base's signature; #939's deferred backing is folded into the base's placed-memory binder. #939's quad
lists as triangle indices.

B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list,
shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where
both carry the same case, #939's cases added (rebound tables, linear texture map, large vertex batch,
executable shaders, default A8 views).

C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h,
rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp,
replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its #1055 release rule and its
rectangle generator; #939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the
label fence on the base's submit.

D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test,
main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with
#939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's
answering first; --first-run-ui kept without host speech in its profile.

E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py,
scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's
v_dot4 decode, #281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the
base's executable-shader step with #939's cache fix; 366 registered tests.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:26:00 -05:00
273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.

Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.

Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.

Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.

No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 11:42:12 -06:00
5fdd6abbc0 D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window
The graphics bind point laid root arguments out with pack() (from s0, two
dwords per table), while the console starts them at s8 for VS/PS/GS with
one dword per table (the corpus census, and the retail frame loop reading
its tables at s8..s10). Compute already took the console layout (D3D-448);
graphics waited because a mesh shader (s16) and a pixel shader (s8) share
one push-constant block.

- translator: user_data_dword() - a mesh shader loads s16..s31 from push
  dwords 8..23, s8..s15 as 0, s0..s7 unchanged, so root dword k is push
  dword 8 + k for every graphics stage; index.json records the window as
  "root_window" on mesh shaders. VS/PS/GS/CS are unchanged.
- runtime: CreateRootSignature lays graphics out with
  pack_stage(Stage::Vertex) and checks Stage::Mesh (mesh_ok); a table is
  one dword at both bind points; DispatchMesh with a signature past the
  16-dword mesh window invalidates the list; a mesh PSO whose mesh shader
  has no root_window (translated before) is refused with a log line.
- fixtures: the GLSL stand-ins read the root arguments at push dword 8 + k;
  the M1.5/M2/M3 asm read their tables as one dword from s8.
- tests: tests/semantic/test_ms_root_window.py (MeshEXT and --mesh-compute
  on the CPU interpreter), graphics-window cases in root_signature_test,
  the two refusals in d3d12_mesh_test.
- docs: d3d12_vulkan.md 3.5, design.md user-data row.
2026-11-24 16:50:49 +01:00
db19bbd345 runtime: connect native pipelines and title resources to the offline first-run UI
Build on the public frame-loop integration in #321. Carry the texture-view and depth work from #213 and #261, the layout provider from #461, the responsive window from #526, and the rectangle generator from #682. Integrate the Xbox constant-buffer row addressing measured in #513 and the draw-time rectangle selection in #722. Keep all fixtures synthetic.

The Windows GPU path resolves title-owned shader objects, retires geometry uploads per submission, materializes texture views on use, maps linear surfaces, and delivers completed GPU label writes. A first-run UI launch selects the tested settings for these paths.
2026-11-24 21:19:30 +08:00
f9896e0fe5 local: merge #9137 (slot 133 kept as on ladder-frame) 2026-11-23 15:21:22 -06:00
e997a1f28f test: cs_user_data's root-view-to-table mode names its pointer target, not the GLSL keyword out
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:59:03 +01:00
65668002e9 d3d12: buffer addresses in the title's own memory reach a shader through an arena window
A root view or buffer V# may name the title's own memory outside any
slot-133 buffer (a per-frame constant ring, #8862 section 3.5). The
layer now makes a 64 KiB-aligned window of those pages in the GPU
address arena, copies it before every submission like a slot-133
shadow, and names that copy instead: for root views when set, for V#s
the layer writes, and for buffer V#s the title writes into a bound
CBV/SRV/UAV table itself, rewritten in place before each submission.
Counters per kind, LEONIDA_TITLE_WINDOWS_MB caps the windows (64 MiB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:47:45 +01:00
ab1fbff95d d3d12: shaders reach a title-placed buffer through the root views and buffer V#s the layer writes
Xbox device slot 133 places a buffer at the title's own VA, about 1.5 TiB on
Windows, while a translated shader computes heap_base + console VA with
heap_base the arena's device address. A root view or V# naming that VA
missed the buffer. The layer now translates an address inside a
title-placed buffer where it writes it (root CBV/SRV/UAV, CBV and buffer
SRV/UAV V#s): to the arena offset of the slot-133 shadow, which now lives
in the GPU address arena when it fits, or to an import's device address
minus heap_base. New tests: title_va_alias_test, d3d12_title_va_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:38:42 +01:00
7e1571a96f test: root UAV s4:s5 in the counted indirect dispatch shader (#6566)
Squash-merged after diff review of PR #6566
2026-11-23 12:42:57 -06:00
56e607ac85 Runtime: pipeline-statistics queries around mesh draws (D3D-291) (#2359)
Squash-merged after diff review of PR #2359
2026-11-23 09:34:02 -06:00
f19c45e427 Merge pull request #4631 from tedin7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:16:38 -05:00
f54c6395ed Merge pull request #4312 from Victor Garcia
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:13:27 -05:00
b0ea417152 Merge pull request #4290 from 73N1X
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:13:10 -05:00
42f4ed6b22 Merge pull request #4288 from Vonsek
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:13:08 -05:00
b102d827d2 Merge pull request #4065 from mohamedsaad.lahlou
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:10:58 -05:00
7309a3439c Merge pull request #3871 from traeb0n
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:05 -05:00
0177e62dab Merge pull request #3780 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:08:25 -05:00
6af4ba333d Merge pull request #3451 from Jonathan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:07:31 -05:00
9a4fb379b1 Merge remote-tracking branch 'origin/main' into test-1007
# Conflicts:
#	runtime/test/d3d12_draw_test.cpp
2026-11-23 04:48:00 +01:00
4a16dc1669 test: run the d3d12_draw logic-op pass on a UINT render target (TEST-1007)
D3D12 allows logic ops on UINT targets only; Intel Arc returns the source on UNORM. The XOR draw now runs on its own R8G8B8A8_UINT target with a uint pixel shader, and the expected pixels are the integer XOR.
2026-11-23 04:31:55 +01:00
7c2252609d D3D-448: console root-argument layout, measured for compute and used there
rt::rootsig::pack_stage() lays a root signature out for one stage the
way the console compiler does: root order from the stage base, a table
one dword (its 32-bit VA), a root view two, constants one per value,
and the first parameter that does not fit refused (the spill array
behind s[0:1] is not modelled).

Compute (base s4) is measured: on the package's FidelityFX DLL, whose 29
compute containers carry their RTS0 next to the console-compiled program,
base plus span equals RSRC2 USER_SGPR in 29 of 29, and
root_sig_contract.py --model console finds all 20 translated programs
compatible (the s0 model contradicts 7). VS/PS/GS s8 and MS s16 stay a
census hypothesis.

The compute bind point now uses this layout; graphics keeps pack(),
since every stage reads one push-constant block and a mesh shader (s16)
and a pixel shader (s8) would collide. A signature carries both
layouts; binding it where its layout refused it invalidates the list.

Test fixtures follow: the compute GLSL shaders read the new places, and
the asm fixtures a D3D12 compute PSO runs are built with
LEONIDA_USER_DATA_SHIFT=4 (compute_fixture.py shifts every SGPR and the
RSRC2 user count), so the standalone harness keeps using them at s0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:44:40 +01:00
45a4d888e8 d3d12_state_sweep_test: blend, depth and stencil state against the host D3D12 device
482 full-screen draws (every colour and alpha blend factor pair, blend
operations, write masks, sRGB, float, 10-bit, 16-bit and SNORM targets,
the depth comparison functions with and without writes, stencil
functions, pass, fail and depth-fail operations, read and write masks, and
the back face's own state) run on the layer and on the host device on the
same adapter, and the colour and stencil bytes are compared.

AI-assisted.
2026-11-23 01:33:20 +01:00
a55ba1febb Runtime: prototype explicit InnerCoverage library contract and GPU comparison 2026-11-22 20:27:48 -04:00
15f9dc6eb8 D3D12: report A8_UNORM shader gather support 2026-11-23 00:12:36 +01:00
afd5304c61 Tests: depth resolves of D32S8, and of samples that differ (TEST-847, TEST-848)
d3d12_depth_resolve_test now takes D32_FLOAT_S8X24_UINT through the same cases
as D24S8: either plane by the depth-stencil format, the depth plane by
R32_FLOAT_X8X24_TYPELESS (MIN, MAX, AVERAGE) and the stencil plane by
X32_TYPELESS_G8X24_UINT, an R32G8X24_TYPELESS resource, and the refusals
(AVERAGE by the D32S8 format or of stencil). The readback tells a 24-bit UNORM
depth plane from a float one by format, not by "has stencil".

Every case also runs as an edge case: a triangle drawn over the cleared 4x
source with a depth-only PSO (depth 0.5, stencil 0x44 REPLACE, test ALWAYS)
leaves the pixels its diagonal edge crosses with samples that differ, so
MIN, MAX and AVERAGE reduce over different values. There is no CPU model of
the coverage: the layer must match the PC runtime byte for byte, and MIN and
MAX of each edge case must differ somewhere. The layer's VS is a GLSL stand-in
(test/glsl/vs_depth_edge.vert) behind a synthetic FSSM container; the host's
is HLSL compiled by d3dcompiler_47. Without glslangValidator the edge cases are
skipped and the summary says so.

RTX 5070 (621.01), Windows 11, validation on: 97 of 97 cases match the PC
runtime on the default adapter, 71 of 71 on WARP, 20 edge MIN/MAX pairs differ.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:15:34 -06:00
3af6d905e4 Merge current main into Tier 2 conservative rasterization
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-22 18:06:08 -04:00
a36506022f d3d12: the runtime's own Vulkan device enables fragmentStoresAndAtomics; a PSO that needs it elsewhere is refused
create_vulkan_device_standalone never enabled fragmentStoresAndAtomics or
vertexPipelineStoresAndAtomics, so a pixel shader with a writable storage
image (an image atomic: 1,018 corpus pixel shaders) broke
VUID-RuntimeSpirv-NonWritable-06340 while CreateGraphicsPipelineState
answered S_OK.

The device enables both where the GPU has them. A graphics PSO whose stage
declares writable storage (src/spirv_stores.h reads the declarations) on a
device without the feature is refused with E_NOTIMPL and a log line.

spirv_stores_test checks the rule on hand-built SPIR-V; d3d12_stores_atomics_test
checks the refusal and the standalone device under the validation layer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:04:06 +00:00
0a9b3ff37f Merge pull request #3797 from JustDown 2026-11-22 17:03:51 -05:00
a8e0a3c756 Merge pull request #3461 from ChatGPT (AI-assisted) 2026-11-22 17:02:08 -05:00
efa9dc1c5c Merge pull request #2886 from Jolymmiles
# Conflicts:
#	docs/testing.md
2026-11-22 17:00:01 -05:00
654e666416 d3d12: D24 depth stored as D32 gets D24 depth bias and 24-bit depth in draws (D3D-309)
On a GPU without a D24 attachment (AMD) the layer stores D24_UNORM_S8_UINT as
D32_SFLOAT_S8_UINT. Draws then broke two D3D rules: the integer DepthBias was
scaled by the primitive's exponent instead of D24 units, and fragment depth was
not quantised like the clears, so an EQUAL test at a cleared value failed.

Single-sampled graphics pipelines with depth enabled on such a target now have
their pixel stage write FragDepth = quantise(z + D3D bias), with the bias in D24
units and the quantisation of depth24_convert.comp; the rasterizer's own bias is
off for them. A pipeline without a pixel shader, with or without a geometry
shader, gets a built-in one. d3d12_depth24_draw_test covers the finding's cases,
stored depth with constant and slope-scaled bias, a shader that writes depth, and
a VS + GS pipeline without a pixel shader.

Co-authored-by: UlteriorMotive00 <132296248+UlteriorMotive00@users.noreply.github.com>
2026-11-22 22:39:37 +01:00
c262fb7b3c Runtime: gate counted indirect compute dispatches on GPU 2026-11-22 15:34:34 -05:00
b5e9ca4ccc Runtime: expose conservative rasterization Tier 2 with capability gates 2026-11-22 16:20:44 -04:00
23c3ccebd9 Merge pull request #3274 from 73N1X 2026-11-22 15:16:24 -05:00
f40556ecac Merge pull request #2934 from kapitche 2026-11-22 15:13:20 -05:00
7fded18980 Merge pull request #1773 from Vonsek 2026-11-22 15:09:47 -05:00
777d218770 vk_compute_test: run 32-lane tests where the size is fixed but not requirable (MoltenVK)
MoltenVK reports subgroups 4..32 and requiredSubgroupSizeStages 0, so VKC_SUBGROUP_SIZE=32 printed "not available"
and the 32-lane compute tests skipped. The translator emits SPIR-V 1.5, where varying subgroup sizes are not allowed,
so Vulkan fixes SubgroupSize at the device's subgroupSize (32 there). vk_compute_test now runs a probe shader
(cs_wave_probe.comp, embedded) with the test's local size and flags first, checks every invocation's lane, subgroup
number and ballot width, and runs the test if they match. If they don't, the test fails (exit 1) instead of being
skipped. Full subgroups are requested where local size X is a multiple of maxSubgroupSize. Devices whose default
isn't the requested size keep printing "not available".
2026-11-23 00:04:20 +04:00
b9cc5f9a32 Runtime: support conservative rasterization Tier 1 2026-11-22 16:02:50 -04:00
15b4154142 Runtime: support conservative rasterization Tier 1 2026-11-22 15:57:00 -04:00