Xbox Series shaders (10,584 shaders / 39.9% of the corpus) index directly-indexed sampler heaps at 16-byte stride (4-dword hardware S#). Previously the runtime hardcoded 32-byte stride for SAMPLER heaps, so every odd sampler slot (0x430, 0x4b0, etc.) read zeroed upper bytes and fell back to fallback_sampler_ (NEAREST + CLAMP_TO_EDGE -> 1D clamped road stripes and nearest-neighbor textures), while even slots read wrong sampler N/2.
Introduce sampler_descriptor_size = 16 and descriptor_increment(type) across GetDescriptorHandleIncrementSize, CreateSampler/CreateSampler2, DescriptorHeap, CopyDescriptors*, scan_title_table, materialize_table, console_heap_range_plausible, local_write_through/copy_title_slots/pull_title_descriptors/local_mirror_table, proxy_create_sampler_x, and d3d12_com.cpp; add packed 16-byte even/odd sampler regression tests.
- U1: preserve D3D12_DSV_FLAG_READ_ONLY_* on TargetView; remap read-only depth layouts to GENERAL when sampled_in_general; emit shader-read barrier visibility and gated VK_ATTACHMENT_STORE_OP_NONE
- U2: add VK_FORMAT_D16_UNORM_S8_UINT to gfx10::format_table so DXGI 119 SRVs succeed on AMD/RADV
- T1/T2: decode non-array GFX10 image_1d/image_2d/image_2d_msaa as layer_count=1 (ignoring linear pitch/depth in WORD4[12:0]); route image_1d_array to TEXTURE1D
- P0: keep capture_ptr_ alive across splash handoff when LEONIDA_PRESENT_DUMP is enabled
- Add capped tsharp-refuse and slot-57 fallback diagnostics + unit/VVL GPU tests
After the merge the tree held this branch's older states of files main maintains. Run against main's code,
tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have
been built from two generations of its sources. So that the merge cannot break what main builds and tests:
- runtime/ is main's, file for file (68 files only this branch had are not carried over);
- every file under tools/, tests/ and docs/ that both sides have is main's (80 files);
- ten translator tests only this branch has, which test rules main's translator does not have, and their
fixtures are left out.
What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1,
play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven
notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and
the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia.
Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the
line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own.
Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the
branch's), CI.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings the D3D12 runtime branch (d3d12/, its launcher scripts and notes, and the pull requests reviewed and applied
on it) together with mandy's main.
Conflicts (67 files, none under d3d12/): docs/, make_game.py, runtime/, scripts/build_runtime.ps1, tests/ and
tools/. Every one takes main's side: main is where that code is maintained, and this branch's copies were older
states of the same files or the same pull requests in another form. tests/test_fspx_unpack.py is main's too, as it
tests main's tools/fspx_unpack.py. Nothing under d3d12/ is changed by the merge.
Checked before pushing: python -m compileall over make_game.py, tools and tests; make_game.py --help;
scripts/check_no_game_data.py over the files this adds to main; tests/test_text_write_line_endings.py. The
translator suite, the C++ runtime build and CI have not run on the result.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On the console a texture access loads the T# and samples. Translated shaders hashed the eight T# words and probed up
to eight slots of the descriptor table for every access: 62 lookups and 19,714 RADV instructions in the tiled-lighting
pixel shader (3,080 in the native program).
The layer now writes the index into dword 6 of every T# in the heaps shaders read, as TAG 0xA [31:28] | storage kind
[27:23] | sampled kind [22:16] | index [15:0] (gfx10_descriptors.h, tsharp_index_word): the console resource heap
copies (fix_console_slot, again whenever the texture at the T#'s address comes, goes or is replaced) and its own
shader-visible heaps (write_image_descriptor, refreshed for bound tables by scan_title_table). The title's bytes and
the T#'s table key keep the title's dword 6.
The translator (tools/descriptor_sources.py, Gen.tsharp_index_sgpr) follows the SGPR dataflow and takes the index from
dword 6, with no lookup, for every T# whose dword 6 it traces to a heap slot (an s_load from a 32-bit descriptor-table
or heap pointer in user data); index 0 unless the word has the tag and dword 3 names an image. Other T#s are looked up
and prefer a tagged word. S#s keep the lookup (sampler heaps are read in place; 40% are literals).
Over the 1.0.2.1 corpus (tools/descriptor_source_census.py) 438,353 of 439,415 T# operands (99.76%) take the word and
17,432 of 17,540 modules keep no T# lookup; no scalar instruction reads dword 5-7 of a heap T#. RADV on an RX 7900 XTX,
lighting shader: instructions 19,714 -> 17,568, latency 73,690 -> 32,458, inverse throughput 16,453 -> 7,468.
Modules record "tsharp_index": "dword6"; the runtime writes the word when the library's modules read it, so packs
translated before keep working as they did. LEONIDA_CONSOLE_HEAP_GPU's pass copies T#s as written, so such a library's
console heaps are fixed on the CPU.
Tests: tests/semantic/test_tsharp_index_word.py (interpreter and dataflow), gfx10_descriptors_test, shader_library_test;
ps_texture_sample and ps_table_fetch now load their T# through a table pointer and vk_texture_test writes the word
(integrated GPU, RADV).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The start screen drew a 1-pixel white line from the bottom left to the top right and no batched text. The title's
console-compiled Scaleform batch shaders read their constant buffer's float4 rows with buffer_load_dwordx4 ... idxen
and the row number (rows 4b..4b+3: colour transform, then the position matrix), and MUBUF addressing is
base + index * STRIDE. CreateConstantBufferView wrote a raw V# (STRIDE 0), so every row read the first one: x and y
came from the same row, so every batched shape and glyph landed on clip-space y = x, coloured white.
A constant-buffer view is now STRIDE 16, NUM_RECORDS the size in rows, format 32_32_32_32_FLOAT, OOB_SELECT 1
(gfx10::constant_buffer_descriptor). s_buffer_load keeps its bound (NUM_RECORDS * STRIDE bytes) and offen loads reach
the whole buffer. With it the line is gone and the batched text (titles, button prompts) draws.
Tests: gfx10_descriptors_test checks the fields; d3d12_compute_test's CBV pass reads through them (its GLSL stand-in
now bounds a CBV read as s_buffer_load does).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted;
this commit is the resolution only. Build and test repairs follow in their own commits.
Rule of resolution: where both sides added different things, both stay; where both made the same change in two
forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two
changed the same code for different purposes, both purposes are kept.
Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, registry.cpp):
- d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device
routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device
slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the
console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and
list slot 139 (#396).
- Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's
completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is
attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider
pc_resource_desc, S_OK for queue slots past the PC table.
- Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its
undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base
list proxy, its null-view slot 70 and its refusing slot 133.
Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp):
- Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra
cases added; main's --env-slots-74 and #984's --env-slots-70.
- Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy,
the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases.
D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h,
frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp,
d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp,
vk_pipeline_check.cpp, vk_test_device.h):
- Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's
ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's
origin, so both pools run on disjoint sets of textures.
- frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter.
- main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4
stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980).
- shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it.
- Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count
refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it.
Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp,
runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp):
- ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on
ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file.
- gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries.
- Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped.
Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1,
make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py,
runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md,
runtime/README.md):
- Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake.
- rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's
restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped.
- shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags.
- shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants.
One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC
compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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>
vulkan_sampler() kept the S#'s address modes and filters when FORCE_UNNORMALIZED is set.
Vulkan requires unnormalizedCoordinates samplers to use CLAMP_TO_EDGE or CLAMP_TO_BORDER on U
and V (VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075) and equal min and mag filters
(-01072). WRAP is the S#'s default mode (word 0 = 0), so any S# with FORCE_UNNORMALIZED and
no explicit clamp produced an invalid VkSamplerCreateInfo.
U and V now clamp to the edge (a border mode stays the border); W is left as decoded; the
minification filter follows the magnification filter. gfx10_descriptors_test checks both cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Creating an SRV of a depth texture (D16_UNORM/R16_TYPELESS or D32_FLOAT/R32_TYPELESS) with a colour format (e.g. R16_FLOAT, R16_SNORM, R16_UINT, R16_SINT, R32_UINT, R32_SINT) previously produced a colour-format VkImageView with VK_IMAGE_ASPECT_DEPTH_BIT, violating VUID-VkImageViewCreateInfo-image-01762. Tighten vulkan_view_format(), image_descriptor() and bind_image() so depth/stencil textures only accept their own family's depth/stencil SRV formats and colour textures reject depth/stencil view formats. Adds exhaustive unit tests and GPU + Vulkan validation tests.
Both sides extended the same spots: the PR's castable-format flag and main's
R9G9B9E5-as-R32_UINT view emulation meet in bind_image (two extra defaulted
parameters), image_descriptor's view format (resource_format + castable list),
create_texture (TextureCreateInfo carries the VkImageFormatListCreateInfo the
castable list fills) and the device init (arena creation plus main's predication
configuration). Main's hardened CopyBuffer preparation and predicate capture
keep the PR's arena-buffer offsets; the PR's old emit-side offset math is
superseded by main's prepare-side buffer_offset handling.
Literal GFX10 samplers can encode bias from -32 to +31. A decoded +31 exceeded the Vulkan sampler limit on both tested devices at registration. Bound the native bias while retaining the original S# for shader lookup.
Keep-both resolutions per #313's conflict analysis: main's ExecuteIndirect /
acceleration-structure / debug-marker / depth24 / node-mask features alongside
the stack's arena, compute and draw paths. Main's indirect and AS offsets gain
the arena's buffer_offset / heap_base compensation; AS resources on default
heaps get their GENERIC structure over the arena range. Reset clears
stencil_ref_set_ next to reset_state, and OMSetStencilRef sets it. README takes
main's (the crypto-token lines stay deleted).
Keep the creation-time castable list on the resource, reject an SRV format
that is neither the resource format nor listed, and allow listed same-size
cross-family casts such as R8G8B8A8_UINT to R32_UINT.
The hardware depth function is zero for both a regular sampler and a NEVER comparison. Give layer-created NEVER comparisons a separate descriptor key so Vulkan binds a comparison-enabled sampler.
A UINT opaque-white border read back as 0 (Vonsek, on an RTX 5080). The S# has
no integer border types, since the hardware reads them by the image's format.
So bind_sampler gave Vulkan VK_BORDER_COLOR_FLOAT_*, which an integer image
reads as 0. The float and UINT samplers also shared one S# key and so one
VkSampler.
An integer border is now marked in the S#: BORDER_COLOR_PTR = 0x800
(gfx10::kIntegerBorderPtr), a field the hardware reads only for table colours.
That gives it its own key, and vulkan_sampler picks VK_BORDER_COLOR_INT_*.
d3d12_descriptor_test runs Vonsek's case: an R8G8B8A8_UINT texture sampled past
its edge through UINT black and white border samplers reads 0 and 1, and a
float white border reads 255. The case fails with the float enums on an RTX
4090. gfx10_descriptors_test and d3d12_sampler2_test check the mark.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/d3d12_vulkan.md section 5.3 asks for a C++ decoder of the structures the
shaders read from descriptor heaps, and section 3.4 for the layer to write them
in Create*View and CreateSampler. runtime/src/gfx10_descriptors.h is that
piece, as a header with no Windows dependency; nothing uses it yet.
- T# (image, 8 dwords), S# (sampler, 4) and V# (buffer, 4): encode from and
decode to plain structs. Field positions are Mesa's register database
(src/amd/registers/gfx10-rsrc.json, the gfx103 types), enum values its
gfx6.json, and what goes where follows ac_descriptors.c and radv. They agree
with what the translator reads: T# FORMAT at word 1 bits 28:20, the V# base,
stride, NUM_RECORDS, FORMAT and DST_SEL.
- Only what a Vulkan view or sampler needs is encoded; tiling, compression
metadata and tuning fields are written as zero and ignored when decoding.
- decode refuses dwords whose TYPE is not an image's (so a V# in a 32-byte heap
slot is told apart), a reserved DST_SEL, and ranges that end before they
start.
- Format table: GFX10_FORMAT code <-> VkFormat with each format's channel
order as a DST_SEL (BGRA8 is 8_8_8_8 read as Z, Y, X, W), the view format for
a T# on an image, DST_SEL -> VkComponentMapping, S# -> VkSamplerCreateInfo,
T# type -> VkImageViewType (a cube is a 2D array, as the translator samples
it).
Tests: gfx10_descriptors_test (ctest, Vulkan headers only): every field alone
at its bit position, round trips, refusals, the T#s cs_imgstore.asm builds,
the V# as the translator reads it, sampler words as radv writes them, the
format table and the mappings. tests/test_gfx10_descriptors.py reads the
table out of the header and checks each code's name against
tools/gfx10_formats.json and each Vulkan format's layout against that name.
Moving FORMAT by one bit, or giving a row another code, fails them.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>