Commit Graph

5744 Commits

Author SHA1 Message Date
dc3fe5fb43 Merge pull request #749 from Kam471 2026-11-21 21:37:58 -05:00
dcb2e8ecf1 Merge pull request #748 from Vonsek 2026-11-21 21:37:58 -05:00
e69c573c79 Merge pull request #746 from fearkov 2026-11-21 21:37:57 -05:00
cfea5a679b Merge pull request #738 from kotorvr 2026-11-21 21:37:55 -05:00
35b0026581 Merge pull request #734 from omardev29 2026-11-21 21:37:54 -05:00
d844da0f87 Merge pull request #727 from ismailchaka1 2026-11-21 21:37:53 -05:00
3d4249ffda Merge pull request #716 from Kam471 2026-11-21 21:37:51 -05:00
fcd51e74ba Merge pull request #708 from Spaghetih 2026-11-21 21:37:50 -05:00
ce8c10a572 Merge pull request #704 from Ayinaki 2026-11-21 21:37:49 -05:00
51a5c3ee3b Merge pull request #701 from mohamedsaad.lahlou 2026-11-21 21:37:48 -05:00
6cb0facab2 Merge pull request #696 from SuarezPM 2026-11-21 21:37:48 -05:00
28e2991a8c Merge pull request #672 from Vonsek 2026-11-21 21:37:46 -05:00
adbc4f42b7 Merge pull request #624 from Luiz Neves 2026-11-21 21:37:46 -05:00
4e0cfc3637 Merge pull request #617 from VictorJulianiR 2026-11-21 21:37:46 -05:00
7c86f68fa6 Merge pull request #576 from Tim Elery 2026-11-21 21:37:45 -05:00
fcea57d5d9 Merge pull request #455 from fearkov 2026-11-21 21:37:44 -05:00
48f2164427 Merge pull request #399 from fearkov 2026-11-21 21:37:44 -05:00
e4d72347d7 Answer 5.1 to a shader model request that asks for it
D3D12's baseline is 5.1, and both WARP and the RTX 5070 runtime answer a 5.1 request with S_OK and 5.1; the layer
refused everything below 6.0, so a caller asking for the minimum got E_INVALIDARG. The host comparison now covers
5.1, the test pins it, and the docs record both measurements.
2026-11-22 02:36:35 +00:00
178a4b47ff SHADER-86 follow-up: correctly rounded UNORM/SNORM decode with integer ops; add 8_SNORM, 16_SNORM, 8_8_SNORM
OpFDiv is allowed 2.5 ULP, and on an RX 6700 (AMD Windows 26.11.2) and an
RTX 5090 it returns the reciprocal-multiply bits, so #599's decode was only
correctly rounded in the CPU model (8_UNORM 130/256 exact on the RX 6700).

x/(2^n-1) in binary is x's n bits repeated, so a 64-bit multiply by the repeat
pattern, FindUMsb and the round bit give the correctly rounded f32 with integer
ops only; the tail never ends, so there are no ties. SNORM uses the same on the
magnitude with n-1 bits; the most negative code is -1.0.

Formats 2 (8_SNORM), 8 (16_SNORM) and 15 (8_8_SNORM) were missing from
FORMATS and decoded to 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:36:22 +01:00
55d42a90f2 psin_index: decode LSCH (type schema) and LENM (enums) (ASSET-50)
LSCH holds 32-byte struct headers followed by 16-byte members; LENM
holds 24-byte enum headers followed by 16-byte values. Neither stores
the header count; it is the one count that fills the payload. Names
are case-sensitive joaat. Counts and layouts only, no game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:35:20 +00:00
88dc8beac1 Runtime: bind multisampled 2D and array shader-resource views 2026-11-22 02:34:09 +00:00
a78d53cf8b ASSET-51: decode the 63 30 00 00 pages as vertex blocks and meshlet groups
The 45 shared_minigame000 streams that docs/story.md listed as undecoded float
records are mesh pages: 16-byte-aligned vertex blocks (a 0x60-byte header of
tagged slot offsets, then position/colour/normal/float2 streams) and meshlet
groups (<=128 vertices and triangles per meshlet, 7-bit packed triangles,
u16 vertex references). tools/meshlet_page.py walks them with layout checks
and writes counts only; tests build every page by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:31:58 +00:00
276a9e9d37 runtime: render-target views of a multisample texture array's slice range
CreateRenderTargetView refused D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY, so after the DSV change in
#683 a multisample array could be a depth target but not a colour target (found by @Derpbeat on
#683). The view is {resource, mip 0, FirstArraySlice, ArraySize}, as for the DSV; the replay
already checks the range and clears through a view of those layers.

d3d12_vulkan_device_test: a 4-layer 4x RGBA8 target is cleared red through a whole-array view and
green through a view of slices 1-2; every slice is resolved and read back, so slices 0 and 3 must
stay red and 1-2 green. A view of slices 3-4 is refused at execute (invalid_subresource). Without
the change the test fails at the captured-range check.

docs/d3d12_vulkan.md: the RTV/DSV bullet lists TEXTURE2DMSARRAY for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:31:00 -03:00
e6eaecd05a Runtime: the descriptor table lives in device-local memory (D3D-76)
AI-assisted. Set 0 binding 2 is the table every T#/S# lookup probes.
BindlessSet allocated it HOST_VISIBLE | HOST_COHERENT and flush() memcpy'd into
the mapping, so a divergent lookup read it over PCIe: 19.5x slower for T#+S#
pairs and 46.2x for a divergent miss at 100k entries on an RTX 2060 SUPER
(vk_descriptor_bench, #639; 58-796x on the 5080).

The table now lives in DEVICE_LOCAL (HOST_VISIBLE kept as a fallback for a device
without it). flush() takes the command buffer that will use the set and uploads
only what changed: the whole table from a mapped staging buffer when the buffers
were just created (first use or growth), and the changed slots with
vkCmdUpdateBuffer otherwise, which copies the data into the command buffer while
recording so no staging bytes are read at execution. A TRANSFER_WRITE ->
SHADER_READ barrier follows, before the draws. DescriptorTable tracks the slots
that insert, replace, erase, clear and grow touched, including both slots of a
relocation, so a flush no longer rebuilds an 80 MiB table for one descriptor.

A command buffer whose vkQueueSubmit is rejected never runs the upload, so the
set keeps the obligation: VulkanQueue::execute reports the submit result through
a commit callback, and the set rebuilds the table on the next flush, which also
reports flush_needs_idle() and makes the device wait before it. The same wait now
honours the pre-existing contract for replaced/erased entries and for growth
(the device ignored flush_needs_idle() before), and frees the retired buffers
once the queue is idle instead of at teardown.

Verified on an NVIDIA RTX 2060 SUPER, Linux 620.73.04, Vulkan 1.4.357:
- ctest 10/10, including descriptor_table cases for the change list, relocation
  marking and consume-once reads.
- vk_bindless_test with LEONIDA_VK_VALIDATION=1: 14 draws (probe depth, erase,
  relocation, growth 64 -> 512 slots, rebind, failed-submit retry, other view,
  removal) read back exact, table in device-local memory in both
  descriptor-indexing configurations. With the retry disabled the test is red.
- GPU suite 64/91 with the same 27 64-wide skips as main, 0 failures; 91/91 with
  LEONIDA_W64_EMULATE=1.

No game data; synthetic fixtures only.
2026-11-21 23:30:46 -03:00
d0f0a510f3 rtti_scan: keep the old report when a write fails; mark mad denormals as not modelled
Follow-ups to review points on three merged PRs.

#658 (@VictorJulianiR): rtti_scan.py opened the report in place, so a write
that failed after the open (full disk, locked range) left a 0-byte file and
the previous report was gone. The report is now written to a temp file next to
it and swapped in with os.replace; on failure the temp file is removed.

#627 (@Caasares): three subnormal cases pinned the translator's result as if
it were RDNA2's. v_mad_f32, v_mac_f32 and v_mad_legacy_f32 flush f32
denormals on RDNA2 (LLVM SIISelLowering.cpp, isFMADLegal). They move to
DenormalDivergenceTests, which pins the translator result and records the RDNA2
one; docs/design.md lists the flush as not modelled. No translator change.

#645 (@esteban-dcp): crosslane_fuzz.py still called permlane FI=0
unmeasured; comments now point at the measurement and at #580.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:30:20 +00:00
050ea3dcfa Docs: re-count the model-bearing archives at rpf9-explorer 917e9b9 (ASSET-49)
Fresh scan/recover at the new pin, no cache, across every model-bearing archive. The new pin recovers 350,248 models (159,483 drawable-dictionary children) against 190,792 at c3708fb.

Per archive: levels.rpf 314,000 (130,225 children), story000 7,460 (4,156), packs 24,034 (23,720), data 2,581 (268), shared_minigame000 1,288 (317), core_restofworld 885 (797). The standalone total is 190,765, 27 below the c3708fb recovery (duplicates merged). levels.rpf is the sum of ten parallel recovery shards over 206,981 candidates; the last shard rejects 1,009 incomplete/duplicate tail pages. Triangle totals and the C# TTPF texture counts were not re-run.
2026-11-22 02:30:07 +00:00
89bf640040 fix(runtime): check image capabilities before texture creation
Single-sampled attachments and storage images could bypass the device's format limits. Use the same query for allocation info and committed creation so unsupported requests get the same answer before Vulkan allocates an image.
2026-11-22 03:29:48 +01:00
14668c62d8 Runtime: RTS0 descriptor ranges read Flags before the table offset
parse_rts0 read 1.1/1.2 descriptor-range records with Flags and
OffsetInDescriptorsFromTableStart swapped (offset at +16, flags at +20).
The PC serializer writes D3D12_DESCRIPTOR_RANGE1 order: type, count, base
register, space, Flags, then the offset. Both values were discarded, so
nothing broke yet, but the descriptor-table layout would have read flags as
offsets.

DescriptorRange now keeps all six fields; the canonical codec stores them
(codec version 2; nothing persists version 1 blobs). The hand-built 1.1
fixture in root_signature_test had the same swap and is corrected; a 1.0
fixture is added, and root_signature_oracle_test checks every range field
against the host serializer for 1.0, 1.1 and 1.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:29:35 +10:00
247f30e238 Merge remote-tracking branch 'origin/main' into valu-cvt-flr-rpi
# Conflicts:
#	docs/design.md
#	tools/rdna2spirv.py
2026-11-21 23:29:23 -03:00
be283d10fc Merge main and preserve stencil and depth views alongside A8 sampled textures 2026-11-21 23:29:03 -03:00
5e55015def Merge main and verify B5G5R5A1 packed sampling and native footprints 2026-11-21 23:28:57 -03:00
03d1e118a6 bcpack: add BC6H and BC7 decoders with external runtime history loader (ASSET-5) 2026-11-21 18:27:01 -08:00
c9ef98d7ae Gamedata: identify the MHIU 0x28 field as the default height (ASSET-48)
Byte 0x28 is a u8 default height: 23 in both MHIU payloads, the value the
empty rows hold, and the value the encoder crops each row by (0 of 6,902
span ends are 23 although 23 is 82% of cells). The decoder now reads the
default from the header, reports the three following bytes as pad_29 and
counts span ends on the default. A scan of all 12 archives finds 2 MHIU
payloads, both in common.rpf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:26:40 +00:00
a48b953d9d docs: native-path workgroup barriers are not proven uniform (SHADER-91)
Records the corpus count, the GPU results on three NVIDIA setups and the fix to use if a hang shows up, as suggested in #634.

AI-assisted.
2026-11-22 03:26:34 +01:00
24c6e9af45 Drop a wrong item ID from the D24 comments and docs (D3D-47 is the resolve comparison)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:26:24 +01:00
23e0f544ad Docs: a row for the v_interp_p2_f16 clamp 2026-11-21 22:25:49 -04:00
2748b0f6bb D24 clears quantised on the native path too; host ties logged as a quirk
- A depth clear of any D24 texture, native D24 or stored as D32, now clears with
  depth24_to_float(depth24_quantize(v)), an exact 24-bit value, so no driver's
  tie rounding is left and NVIDIA's native D24 matches WARP and AMD.
- d3d12_depth24_compare.h checks the layer's clears against the reference
  (depth24_quantize, stencil value) and fails on a difference; the host is
  compared byte for byte only when it agrees with the reference, otherwise
  the difference is logged as a host quirk (NVIDIA's D3D12 rounds some ties
  the other way: 478 of 5215 values).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:25:35 +01:00
13cae9c949 chore: merge upstream descriptor plane coverage
Preserve the new plane views and packed-format tests alongside volume sampling so they run in the same descriptor fixture.
2026-11-22 03:24:54 +01:00
e3794131b6 docs/runtime: XDXR BATCHED_DESC2 and XDXR_STREAM_DESC layouts from XboxBvhBuilder.dll (open question 8)
Recovered from the package DLL's own reads (field accesses, element strides,
the standard-build and prebuild wrappers that construct a BATCHED_DESC2):
BATCHED_DESC2 is the public build desc, the postbuild count and pointer and
a 16-byte XDXR_STREAM_DESC (0x50 bytes); the stream desc is a size and a
pointer to 16-byte typed records, whose offsets, value types, defaults and
lookup rule are measured. The DLL rejects the offline-statistics postbuild
type for every build, so that layout is not in the package.

docs/xdxr.md has the evidence per field (RVAs only, nothing quoted from the
DLL). runtime/src/xdxr_descs.h defines the structs with static_asserts and
the DLL's stream lookup and flag defaults; xdxr_descs_test checks them and,
with a DXR d3d12.h, the public part against the SDK.
2026-11-22 03:23:37 +01:00
398f5b06bd Merge current main into the D3D12 trace branch 2026-11-22 03:22:44 +01:00
30035b9439 Allow the Windows Vulkan tools to build without the runtime SDK 2026-11-21 23:22:22 -03:00
b5d15862fc docs: valu_fuzz --family f16 needs llvm-mc 21+; 18 runs the rest
docs/testing.md asks for LLVM 21+, but says a distribution's llvm-mc is
enough on Linux, and the fuzzer does not say what it needs. Measured with
Ubuntu 24.04's llvm-18 (18.1.3): valu_fuzz --family mem and lds_fuzz
assemble and run, but every --family f16 program fails, because 18
rejects op_sel on the 16-bit integer VOP3 forms; 23.1.6 assembles them.
Both places now say so.
2026-11-22 02:22:21 +00:00
40bb5e76ce Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	runtime/src/vulkan_replay.h
2026-11-22 03:20:16 +01:00
6910e1cfef Merge origin/main into d3d-47-d24-emulation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:17:17 +01:00
d605067cb8 Docs: record the Home Sweet Home mission-music search
The credited song is the Home Sweet Home mission song, not a radio track. The mission and its localized objective/fail strings are in data.rpf; the song audio is absent from every searched container.

Records the measured coverage (story000 streamed/plain/Bink, movies.rpf Bink, audio.rpf short and all banks, loop banks, packs/data/script/common inflated, raw levels.rpf ADAT/KB2), the 19,807-file / 653-hour Chromaprint sweep with its tempo range, the positive controls, the 12 joaat(burn) data hashes that are not audio, and the remaining levels.rpf/RSC8 uncertainty. No game audio or localized strings are included.
2026-11-22 02:16:53 +00:00
00fef11ad2 fix(runtime): report unaligned BC texture support
The Vulkan path can sample a top-level mip with partial edge blocks, but callers querying OPTIONS8 receive E_INVALIDARG. Report the logical device's enabled BC feature so callers can select the matching upload path.
2026-11-22 03:16:34 +01:00
0e63a76da0 D24 conversion: predication, large copies, tests, spec note (review)
- A dispatch honours conditional rendering and the layer's copies do not, so a
  SetPredication that skips copies also skipped the D24 conversion while the
  copy ran. Conditional rendering is ended around the dispatch and begun
  again; a test runs an upload and readback under a skipping predicate and
  compares with the host's unpredicated run (it fails without the fix).
- A copy larger than maxStorageBufferRange (queried; 128 MiB assumed if not)
  is split into dispatches by slices, or by rows of one slice; the descriptors
  bind 256-byte-aligned windows of both buffers. depth24_convert_test splits
  the 4096x4096 copy with a 1 MiB range and a pitched one with a 1 KiB range.
- make_pipeline destroys the layouts it made when a later step fails.
- depth24_convert_test is in the CI tool list; the docs say which GPU each test
  exercises.
- R24G8_TYPELESS with a typed D24 DSV is compared with the host. SRVs of
  R24_UNORM_X8_TYPELESS and X24_TYPELESS_G8_UINT are an empty slot in the
  layer (no format mapping; stencil-plane views refused): reported by the
  test and documented as a known gap.
- depth24.h: the D3D11.3 spec's FLOAT -> UNORM wording (3.2.3.6, 3.2.2) next to
  what WARP and AMD were measured to do; "159" is 5215.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:15:13 +01:00
2d47ebc473 Docs: f16_out docstring and the Known approximations pkrtz sentence mention MODE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:14:42 +01:00
e157fddad9 Translator: MODE f16/f64 rounding (s_setreg FP_ROUND[3:2]) (SHADER-35)
The game sets MODE.FP_ROUND[3:2] (f16/f64 rounding) inside its shaders: 9,417 writes in 6,333 of 26,503
shaders, 6,694 toward zero (3) and 2,723 back to nearest even (0); no other MODE field, no s_denorm_mode or
s_round_mode. The translator ignored it.

- The field is kept in a per-invocation Function variable (%mode_r16) when the program writes it.
- Every VALU f16 result (f16_out, v_pk_*_f16 via f16_pack2, v_cvt_f16_f32, v_sin/cos_f16, v_interp_p2_f16,
  v_fma_mix{lo,hi}_f16) goes through f16_res: main's integer f16_bits, or f16_bits(rtz=True) while the mode
  is toward zero. Integer ops only either way (SHADER-56).
- f16 add/sub and v_pk_add_f16 step the f32 sum one ulp toward zero when its exact TwoSum error shows it
  rounded away from zero (2 - 2^-24 is an f32 tie that rounds to 2.0; toward zero it is 0x3FFF). f16 FMAs
  need nothing extra: fma_f16_odd's round-to-odd f32 value (SHADER-55) narrows exactly in either direction.
- v_add_f64 steps one ulp toward zero the same way (finite overflow -> +-DBL_MAX), on the raw sum, before
  clamp/omod.
- Other MODE writes (other bits, partial field, +inf/-inf, register values), s_denorm_mode and s_round_mode
  raise Unsupported; none occur in the corpus.
- Shaders that never write MODE emit the same code.

tests/test_mode_round.py; tests/spirv_interp.py gains binary64 arithmetic, double <-> v2uint bitcasts and
vector Fma/FMin/FMax/FClamp. docs/design.md: Known approximations and the f16 rounding row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:11:57 +01:00
21126810d6 Answer shader model and root signature feature queries
CheckFeatureSupport fell through to E_INVALIDARG for
D3D12_FEATURE_SHADER_MODEL and D3D12_FEATURE_ROOT_SIGNATURE, so a game
asking either got an error where the PC runtime answers. Report DXIL 1.0
and root signature 1.1, the versions this layer can honour rather than
the driver's maximum, clamp higher requests down, and refuse an undefined
value, a wrong DataSize and a null buffer, as the host runtime does.
2026-11-22 02:11:18 +00:00