Commit Graph

85 Commits

Author SHA1 Message Date
c6341775fb Merge pull request #3321 from HAMADA 2026-11-22 15:16:57 -05:00
94ff85fdf7 Merge pull request #2784 from SuarezPM 2026-11-22 15:11:58 -05:00
00f9ebd672 Merge pull request #2070 from jaybeebabageyus 2026-11-22 15:10:09 -05:00
38df0fb43f d3d12: measure 96-bit resource tiling 2026-11-22 20:04:08 +00:00
50e9dd32fa Merge remote-tracking branch 'upstream/main' into 2070-lifecycle-fix
# Conflicts:
#	runtime/src/pe_loader.cpp
#	runtime/src/pe_loader.h
#	runtime/test/loader_tls_test.cpp
2026-11-22 20:57:07 +01:00
1188e6406e runtime: scope the TLS clone purge to ownerless files, clean clones before ExitProcess, per-slot thread-event errors
The startup purge deleted every leonida_tls_host_*.dll in the temp directory, so it could remove the
clone of a concurrent process that had copied its helper but not reached LoadLibraryExW yet. Clones
are now copied to a staging name and renamed into place while the copy step's guard handle is open, so
a final-name clone never exists without a handle, and the purge skips files that fail an exclusive
open or whose owner process (from the file name) is still alive.

std::atexit cleanup never ran on the --run path because main ends with ExitProcess; the loader now
exposes cleanup_tls_clones() and main calls it before ExitProcess (atexit still covers normal exits).

on_host_thread_event wrapped the whole slot loop in one try/catch, so one throwing slot killed the
events for every other module. The catch is now per slot, and the detach path releases the slot even
when the callbacks threw, instead of leaking the block to the OS loader.

README and the initialize_tls comment no longer claim only one mapped TLS module can be live; the
loader_tls_test gained purge-ownership and explicit-cleanup checks.
2026-11-22 20:54:47 +01:00
f495169092 boot: the first-boot runbook and the two-trace summary
tools/boot_trace.py reads the `--trace` JSONL and the `[d3d12-trace]`
stderr lines and prints the units a first boot needs: modules, unimplemented
imports with their callers, DllMain/TLS results, exceptions with their
stack, the exit, and the D3D12 calls by outcome and first call per method.
It counts debug strings instead of printing them, so a real trace stays on
the player's machine; the tests use synthetic fixtures only.

docs/boot.md is the runbook around it: the Windows and Wine commands, the
LEONIDA_UNIMPLEMENTED and validation switches, the first-failure triage
order, and the Q1-Q22 table mapping each open question to the event to look
for. docs/README.md and runtime/README.md point at both.
2026-11-22 15:16:15 -03:00
a3b1719c61 gameinput: report and drive force-feedback and haptic motors through SDL3 haptics (RT-160)
IGameInputDevice answered the force-feedback and haptic half of the API with
nothing: no motors in GameInputDeviceInfo, E_INVALIDARG from
CreateForceFeedbackEffect, false from IsForceFeedbackMotorPoweredOn, a no-op
SetForceFeedbackMotorGain and E_INVALIDARG from SetHapticMotorState. A pad SDL
opens as a haptic device now reports one force-feedback motor with the effect
kinds SDL lists, and a pad with trigger motors reports two haptic motors.

Force feedback goes to SDL_CreateHapticEffect/RunHapticEffect on the poll
thread, so title calls still never touch SDL; the eleven GameInput effect kinds
are SDL's eleven force-feedback effects. The trigger haptic motors play their
one waveform as an intensity on the existing trigger output. A pad with neither
keeps the old answers, and LEONIDA_RUMBLE=0 silences both. gameinput_test drives
all of it through a fake haptic backend, because SDL's virtual joysticks report
no haptics.

AI-assisted.
2026-11-22 18:26:28 +01:00
96dcddb6fb Merge pull request #1911 from Jan Trencansky 2026-11-22 10:39:21 -05:00
98e9acfb91 Merge pull request #1908 from Jolymmiles 2026-11-22 10:39:19 -05:00
d6443b1524 Startup trace: never replace an existing file; write UTF-8 only
Review on #1756 (Vonsek):
- The trace is opened before the loader reads the image, so `wb` could
  truncate an input named by mistake (the image itself). open() now
  uses "x" mode and fails with EEXIST on an existing path; gta6rt says
  so and exits with 2.
- OutputDebugStringA text is in the ANSI code page. It is converted
  to UTF-8 before quoting, so a byte such as 0xE9 no longer breaks the
  JSON lines. Host module names now come from GetModuleFileNameW,
  converted to UTF-8, for the same reason.

startup_trace_test: an existing file is refused with EEXIST and its
bytes survive, the trace stays off; an ANSI debug string with 0xE9
appears as its UTF-8 form and the whole file is valid UTF-8.
2026-11-22 12:06:49 -03:00
2dca597bd9 Runtime: opt-in startup trace (gta6rt --trace FILE)
Writes one JSON object per line, flushed per event: module maps, TLS
callbacks, DllMain results, the first call of each unimplemented import
with its caller as module+RVA, OutputDebugString text, exceptions with
module+RVA and a short unwind, and the exit code. A vectored handler
records and returns EXCEPTION_CONTINUE_SEARCH, so behaviour is unchanged.
Off by default.

startup_trace_test builds a synthetic DLL image (no game data) and
checks each event kind.
2026-11-22 12:03:22 -03:00
17a27f23cc d3d12_present_test: check the presented images through the capture, GDI screen read only where it works
Under Wine's macOS driver the test failed at its last step, the GDI read of the screen: GetPixel on the screen DC
returns CLR_INVALID there for every pixel, even one GDI painted itself (BitBlt from the screen DC fails too), and
the window's own DC holds Wine's GDI surface (white), not the image presented through the Metal layer. The
presenter itself was fine: all the injected-failure checks passed, MoltenVK made 320x240 and 400x300 swapchains
at contents scale 1.0, and the driver reported no out-of-date presents. The "present failed" lines in that log
(VkResult -1000001004 twice, then -1 = VK_ERROR_OUT_OF_HOST_MEMORY) are the test's own injections; markers around
them showed each line inside its injection.

The test now enables the presenter's capture and checks the whole presented image for the clear colour at the
swapchain's size after the first 60 frames, after the resize and at the end, on every platform. The screen check
stays where GDI can read the screen; a CLR_INVALID there is reported and skipped instead of failing. The test also
says on stderr that the next three "present failed" lines are expected, since they were read as faults twice.
Checked under CrossOver's Wine 11 with MoltenVK 1.4.3 on an Apple M3 Max: the test passes, and with the clear
colour changed the capture check fails at the first 60 frames.
2026-11-22 18:59:21 +04:00
7886972a6b Merge upstream main
# Conflicts:
#	docs/d3d12_command_objects.md
2026-11-22 09:48:41 -05:00
c7801ac6fb Merge upstream main
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/README.md
2026-11-22 09:35:55 -05:00
088447e117 FSPX programs: translated by the shaders stage, found at run time by their kind-6 bytes (RT-99)
The FidelityFX DLL creates its compute pipelines from FSPX programs (docs/fspx.md): through slot 67 with the bare
kind-6 program, then through slot 62 with the DXBC container whose ACCC part holds the payload. Both ended in
E_INVALIDARG: the layer took only FSSM bytecode, the build never translated the DLL and the index had no key for it.

- make_game.py: the shaders stage unpacks the package's DLL with tools/fspx_unpack.py --disasm into
  <work>/shaders/fspx and translates it into <work>/shaders/spirv/fspx, with the same wave64 mode and fallback
  flags. The step is redone as a whole when the DLL, its tools, llvm-mc or the flags change (fspx_build.json,
  written last) and never makes the game's shaders run again.
- tools/shader_meta.py: an entry of a program without an FSSM blob gets fspx_code_sha256, the SHA-256 of
  fspx/<name>.code.
- runtime/src/shader_library.h: the library also loads <dir>/fspx/index.json and finds entries by
  fspx_code_sha256. compute_program() takes an FSSM program as before, the kind-6 bytes of an ACCC container or of a
  bare FSPX payload, and a bare kind-6 program recognized by its prologue; the directory is parsed with the DLL
  reader's rules and bounds-checked, so a malformed one is refused.
- create_compute: looks the program up by the key of its kind and uses those bytes as the code base.
- Tests: shader_library_test (parsing, malformed directories, lookup, the fspx folder), d3d12_fspx_compute_test
  (PSOs from both forms, a dispatch each, refused inputs) and tests/test_fspx_shaders_stage.py.
- Docs: the lookup in docs/fspx.md; slots 62 and 67 in d3d12_command_objects.md and d3d12_vulkan.md. The size the
  slot-67 description carries at +0x30 is kind 6's own size, read from the DLL's code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:22:54 -05:00
a3263e79e6 Merge pull request #1757 from Vonsek 2026-11-22 09:15:07 -05:00
22888d4e65 Runtime: test the shader lookup against a translated corpus
shader_library_corpus_test runs src/shader_library.h over the work folder
make_game.py builds from the player's copy (LEONIDA_SHADERS=<work>/shaders/spirv,
containers from <work>/shaders/dxbc or LEONIDA_SHADER_DXBC), as the D3D12
layer does with a PSO's bytecode: inflate the FSSM program, hash it and look
it up under the stage the DXIL program header names. Every container must
find its own index.json entry and a readable .spv, every entry must be
reached, and in containers with more than one 0x0D payload no earlier
payload may be the indexed program.

Without LEONIDA_SHADERS it prints SKIP and exits 77 (SKIP_RETURN_CODE).
On the 1.0.2.1 corpus: 26,503 containers, all resolve, 195 with more than
one program. With fssm_program switched to the first payload it fails
(391 failures, 26,308 of 26,503 entries reached).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:54:56 +01:00
705a40bda9 Tests: a compute dispatch that samples through set 0 (d3d12_set0_compute_test)
Since #1489 the layer binds the device's bindless set at every dispatch as well as at every draw, but only the
draw has a test (d3d12_m2_textured_test): d3d12_compute_test takes the binding-free index entry on purpose, and
d3d12_descriptor_test samples through set 0 with a Vulkan pipeline of its own.

This test covers the compute bind point through D3D12 alone: a compute PSO whose index entry lists set-0
bindings, two SRVs, bytes no view was made for, and a wrapping and a clamping sampler. Four dispatches of
test/glsl/cs_set0_sample.comp (GLSL written to the translator's contract) load the T# and the S# from the
descriptor tables, find them in the hash table and sample: the two textures texel for texel, the fallback image
for the unknown bytes, and the right edge with the clamping sampler. A device without the bindless set refuses
the PSO. Registered with ctest like its neighbours (exit 77 is a skip).

With the vkCmdBindDescriptorSets call of the compute bind point removed from replay, this test fails
(VUID-vkCmdDispatch-None-08600, on llvmpipe).

Checked with a mingw-w64 build under Wine on llvmpipe, an RDNA2 integrated GPU and an RX 7900 XTX (RADV), with
the validation layer: exact, no validation errors. Not built with MSVC.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 08:19:04 -05:00
a0acd33d77 Docs: one Other languages line, and runtime/README links docs/runtime_imports.md
Two i18n PRs merged as "both" left docs/README.md with two quickstart lines (test_i18n_index); #1551's link in
runtime/README.md pointed at runtime/runtime_imports.md instead of docs/ (test_docs_links).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:02:25 -05:00
41557027b6 Merge pull request #1551 from HQasper 2026-11-22 07:38:08 -05:00
a98f9925b0 gta6rt: map GAME: console paths, and send writes to an overlay (RT-97)
A mapped title names its files on the console's drives, but nothing mapped them: the file calls went
straight to the host and --game-dir was only used to find modules, so the first file a title opens at boot
would fail. New shims for CreateFile*, FindFirstFile*/FindNextFile*/FindClose, GetFileAttributes*/
GetFileAttributesEx* and DeleteFile* (kernel32, kernelbase and the api-ms-win-core-file sets) map a GAME:
path under --game-dir, and send every open that can write and every delete to --overlay (default
<game-dir>\overlay), which reads and listings prefer. A write-open copies the package file into the overlay
first, so OPEN_EXISTING keeps its bytes, and a delete of a package file leaves a marker instead of removing
it, so the package is never modified. A path that climbs above GAME: with ".." or names another drive is
refused with ERROR_INVALID_NAME. A path without the prefix is still a host path.

The prefixes and the overlay come from ivall/xcl (GPL-2.0-only), as facts only, no code.

file_system ctest: 43 checks over folders in %TEMP%, covering mapping and case, copy-up and read
preference, a new file in folders the package lacks, delete and re-create, the merged listing, host-path
passthrough, the escape refusal and the narrow variants.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 13:11:57 +01:00
5529697596 Merge origin/main (landed #291) into m2-textured-draw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:04:28 +01:00
650ea999a6 Merge pull request #1083 from abilliontokens 2026-11-22 06:37:53 -05:00
b23531386a docs: thread events stop running TLS callbacks once ~Loader starts the process detach
~Loader (#1172) clears initialised before delivering DLL_PROCESS_DETACH; with
the thread events that write goes through the TLS lock, so a thread that ends
during or after the detach no longer runs the module's callbacks.
2026-11-22 12:29:52 +01:00
f3d302dded docs: per-thread TLS and C++ exceptions in mapped images
runtime/README.md: the RtlPcToFileHeader redirect, and the thread events in
place of "the loader does not deliver thread attach/detach events"; mapped
DLLs' DllMain still gets no thread events. design.md: the CPU-code row.
2026-11-22 12:29:52 +01:00
7f97fb7b8f Merge fork/m15-translated-draw-v2 (M1.5, #907) into pr291-on-main 2026-11-22 12:19:59 +01:00
69b21a9427 Merge origin/main (c2967a5e) into d3d90-castable-placed
Second merge round: main added rgb96 views, the device filter, the
present source-rect path and its own ctest registration of
d3d12_present_test. bind_image keeps both defaulted parameters and the
rgb96 view fallback; image_descriptor runs main's 96-bit family check
before the castable-list check; Resource keeps main's rgb96_ member;
register_samplers and the presentation plumbing follow main's positions,
and the duplicated d3d12_present_test block and stale 'surfaces' local
are dropped in favour of main's.
2026-11-22 03:15:32 -08:00
6e2db3d273 Merge main (c2967a5) into runtime/compute-path
main gained 117 commits since f85582e, among them #119 itself (through #908,
which is built on its head and adds PresentX on top), so both sides now
carry the presentation path: this branch as #119's own commits merged with
main at 426023a, main as #908's integration of them. Eleven hunks in six
files conflicted.

runtime/src/vulkan_present.h (2 hunks):
- present's blit: main's structure (a blank present, the source rectangle)
  with both locks of the branch. record() reads and updates the context's
  layout tracker, which ExecuteCommandLists guards with tracker_mutex_ (it
  copies the tracker, emits, and commits the copy after the submit); under
  the resource lock alone a present between that copy and that commit would
  lose its update. Order as in the context: resource -> tracker -> submit.
- presentable(): identical code, main's comment.

runtime/shims/d3d12_vulkan_device.cpp (3 hunks):
- includes: shader_library.h stays (pipelines read the translator's index);
- Resource's fields: the branch's arena fields and main's rgb96_ (D3D-62);
- standalone device: info.presentation is set once, where the swapchain
  extension is pushed (the branch's order); main set the same value later.

runtime/shims/d3d12_com.h (2 hunks): the union of the includes; the
branch's VulkanDeviceInfo::features and shader_dir stay.

runtime/CMakeLists.txt: main now builds and registers d3d12_present_test
next to xbox_present_test, so the branch's copy of that block goes; the
compute and draw tests keep theirs. d3d12_present_test keeps returning 77
without a Vulkan device, which main's registration (c2967a5) relies on but
main's test does not do yet.

README.md, docs/d3d12_vulkan.md (3 hunks): the branch's text. main's side
is what the branch had already merged at f85582e, unchanged since.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 06:03:39 -05:00
d7e1857c5d Merge origin/main into d3d90-castable-placed (resolve #1083 conflicts)
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.
2026-11-22 03:00:14 -08:00
4cfde416f8 Merge main (f85582e) into runtime/compute-path
On top of the merge candidate 70178d3 (Ryx69/Leonida#6, which merged main at
426023a): the 219 commits main gained since. Three hunks conflicted, in two
files; both follow the notes on #291 (ItsNotRexed 08:27 UTC, Vonsek 09:58 UTC
on 2026-11-22).

runtime/shims/d3d12_vulkan_device.cpp, device setup after the VulkanContext:
- the branch's GPU address arena is created first, as before;
- main's block that configures predication and the predicated byte copy
  (#1277) follows it;
- one load_host_image_copy call and main's lazy D24 converter (enabled only
  where D24_UNORM_S8_UINT is not usable) replace the branch's unconditional
  enable_depth24, which was the same code before main changed it.

runtime/src/vulkan_replay.h:
- CopyBuffer: main's version. It already adds ResourceBinding::buffer_offset
  to both offsets, as the branch did, and adds the overflow and overlap
  checks and the predicated copy. With the arena, source and destination are
  often the same VkBuffer; the overlap check compares the adjusted ranges.
- Predication: main's version. prepare() passes buffer_offset + the command's
  offset to prepare_predicate, so a default-heap buffer inside the arena is
  read at its own range; emit() captures the word and tests the capture's
  scratch slot, not the application's buffer.

Everything else merged without conflicts. Nothing in main's 219 commits adds
a caller that takes a buffer's Vulkan device address for its GPU VA.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 05:45:58 -05:00
d01d1df494 Merge pull request #1306 from zneel 2026-11-22 05:37:40 -05:00
983862e2a8 Runtime: 96-bit R32G32B32 textures on the Vulkan layer (D3D-62)
R32G32B32_FLOAT/UINT/SINT/TYPELESS textures were refused ("texture format not
supported yet"). They are now R32G32B32A32 images on every GPU: most have no
optimal-tiling RGB32 image, and one that has would not avoid the repack, since
D3D12 places subresources at multiples of 512 bytes and Vulkan wants a copy's
buffer offset to be a multiple of the texel size
(VUID-vkCmdCopyBufferToImage-dstImage-07975).

- Footprints keep D3D12's 12-byte texels (compared with WARP).
- CopyTextureRegion between a texture and a buffer is repacked by the D24
  compute pass (depth24_convert.comp modes 2 and 3, Depth24Job::rgb96): the
  same scratch, parts and lifetime, texels of three words in the footprint and
  four in the scratch, copied uninterpreted. depth24_convert.inc is
  regenerated with the documented glslc command; the same glslc reproduces the
  previous blob byte for byte from the previous source.
- WriteToSubresource/ReadFromSubresource take the staged copy, as D24-as-D32.
- A view's T# names GFX10_FORMAT_32_32_32_*, so alpha reads as one.
- Refused: unordered access and depth (as WARP), render targets (WARP has
  them; not done, and FORMAT_SUPPORT and GetResourceAllocationInfo agree),
  copies between a 96-bit and a four-channel texture, views of another
  format family.

Tested on an RX 9070 XT (AMD 26.11.2), Windows 11: d3d12_rgb96_test matches
WARP and the expected texels bit for bit for 4 formats as 2D arrays with mips
and as volumes; d3d12_descriptor_test samples FLOAT, UINT and TYPELESS views.
Clean under the validation layer with sync validation; depth24_convert_test
and ctest (62) pass.

AI-assisted (Claude Code).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:26:48 +01:00
1ea8ac875d Merge remote-tracking branch 'origin/main' into presentx-core-v2-local
# Conflicts:
#	README.md
#	docs/d3d12_vulkan.md
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/vk_test_device.h
2026-11-22 11:15:14 +01:00
22d26c949d Merge origin/main into m15-translated-draw-v2
Conflicts (both sides kept): runtime/CMakeLists.txt (stub list), d3d12_com.h, d3d12_vulkan_device.cpp (arena buffers
with main's ray-tracing buffers and deferred destruction, calibrated timestamps, instance extensions, sampler
registration next to the window presenter), command_list.h, vulkan_backend.h, vulkan_replay.h, vk_test_device.h,
d3d12_state_map_test.cpp, docs and README. vulkan_present.h takes main's resource and tracker locks.

CI (linux-gpu-tests): ps_m15 and vs_m15 belong to d3d12_translated_draw_test. run_gpu_tests.py still assembles and
translates them but reports them as skipped (OTHER_HARNESS) instead of "no checker defined".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:08:08 +01:00
759087b51b Merge origin/main into d3d90-castable-placed (resolve #1083 conflicts)
- register_samplers (main) and create_window_presenter (stack) both kept.
- Resource dtor: stack arena release + main deferred destroys.
- AS binding: main size/host_readable + stack console va.
- VulkanContext: main's lock split kept; stack arena/pipeline accessors
  moved to resource_mutex_ (execute copies replay_ under its shared lock),
  presenter lookups take it shared.
- README takes main wholesale; D3D-90 code and tests untouched.
2026-11-22 00:51:55 -08:00
68a4073154 Merge main (0d61c35) into runtime/compute-path
Resolved along the lines in #291 (comment by ItsNotRexed, 2026-11-22 08:27):

- Default-heap buffers stay in the GPU address arena: a VA is an arena offset,
  and every buffer's device address is heap_base + VA (upload and readback
  buffers: device address minus heap_base, as before).
- Acceleration structures: a buffer created in RAYTRACING_ACCELERATION_STRUCTURE
  state on a ray-tracing device stays out of the arena and keeps main's model,
  its VA being the VkAccelerationStructureKHR's device address, so BLAS
  addresses in TLAS instance descriptions are what Vulkan reads. It is
  registered by that VA. BuildRaytracingAccelerationStructure turns build
  inputs and scratch into heap_base + VA, and the arena gets the build-input
  usage on ray-tracing devices. Resource keeps one va_ (gpu_va_/buffer_va_
  removed).
- buffer_at keeps the size& signature; main's only caller (WriteBufferImmediate)
  is the branch's version, and ExecuteIndirect resolves its buffers by id.
- ~Resource keeps arena_release and main's defer_destroy.
- Main's split context locks: pipeline registration and heap_base/zero page
  take resource_mutex_ (prepare looks pipelines up under its shared lock);
  VulkanPresenter takes resource_mutex_ shared, plus tracker_mutex_ while it
  records the back buffer's transition.
- Standalone device: main's single instance-extension list and DXGI swapchain
  enable; info.presentation follows the same swapchain/surface condition, so
  create_window_presenter keeps working. Main's DeferredDeletionQueue,
  calibrated timestamps and ray-tracing extensions are kept next to the
  branch's presentation and feature enables.
- Command IR: Dispatch and Draw follow main's DebugMarker, ExecuteIndirect and
  BuildAccelerationStructure in the variant.
2026-11-22 05:50:20 -03:00
29345889be Runtime: capture full 64-bit predication values on the GPU 2026-11-22 04:34:35 -04:00
eda43133f8 Merge pull request #1172 from farhat 2026-11-22 03:14:21 -05:00
cc76514229 fix(runtime): detach initialised PE modules before unmapping them
Deliver TLS and DllMain process-detach notifications in reverse dependency order while every mapped image and TLS block is still live. This lets mapped DLLs unregister FLS callbacks before their code is freed. Cover failed attach, map-only loads, partial initialisation, teardown ordering and malformed TLS tables with synthetic PE tests.
2026-11-22 14:56:50 +07:00
73dd6d7dce Runtime: depth and stencil resolves in ResolveSubresourceRegion
MIN and MAX of either plane, and AVERAGE of the depth plane when Format is
the plane's own format, as the PC runtime accepts them (RTX 5070 and WARP).
Each resolve is a vkCmdBeginRendering scope with no draws: the MSAA plane
is the depth or stencil attachment and the destination plane its resolve
target, checked at record time against D3D12's rules and the device's
supported resolve modes. Colour resolves are unchanged.
2026-11-22 13:14:43 +05:30
36d073f79d Merge remote-tracking branch 'origin/main' into pr1083-merge-main
# Conflicts:
#	runtime/src/vulkan_backend.h
#	runtime/src/vulkan_replay.h
2026-11-21 23:26:25 -08:00
2933767eac Merge origin/main into d3d90-castable-placed (resolve #1083 conflicts)
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).
2026-11-21 23:23:18 -08:00
fa39a573c2 Merge pull request #1044 from SombraSoft 2026-11-22 01:38:01 -05:00
a97ac608db Runtime: deduplicate root_sig CTest and add opt-in Vulkan-Headers fetch 2026-11-22 03:10:01 -03:00
08b8dc793f gta6rt: refuse more than one of --dry-run, --init and --run (#886)
--dry-run --run set both flags, so the dry run initialised the modules
and called the entry point. gta6rt now takes exactly one mode and prints
the usage (exit 2) otherwise. Three ctest cases run the stand-in game
with two modes and fail if it is mapped or run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:01:31 -06:00
082fdd048e M1.5 (D3D-53): a draw whose VS and PS are translator output
vs_m15.asm and ps_m15.asm are hand-written RDNA2 (gfx1013), built by
test/shaders/build.py through llvm-mc and tools/rdna2spirv.py. build.py now also
writes the synthetic FSSM program a shader's header asks for (fssm-at, fssm-data)
to fssm/, so the translator records its fssm_sha256 in index.json.
d3d12_translated_draw_test creates a graphics PSO from containers carrying those
programs; the layer finds both stages by hash in the translator's own index. It
covers a descriptor-table root argument and root constants (s0..s5), vertex fetch
through a V# the application wrote into a descriptor slot (s_load, then
buffer_load_dwordx4 idxen), the PS reading constants through the code base
(s_getpc_b64), and compares a float render target bit for bit. All draws use
StartVertexLocation 0, so the result is the same with and without PR 436's
zero-based ids; verified both ways. docs/d3d12_vulkan.md records the milestone and
the measurement that a V# cannot point at an upload buffer (48-bit base, negative
console VA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:24:46 +01:00
Ryx
2aed144550 Runtime: second round of review fixes, and predication on arena buffers after the rebase onto main
From the reviews and test runs on #291:
- A pipeline without vertex bindings (a full-screen pass from SV_VertexID) no longer declares the vertex-stride
  dynamic state, which nothing would set (VUID-vkCmdDraw-pStrides-04913; aslan2142, AlxcBTW, ezwinxdlmao).
- Logic ops are applied from RenderTarget[0] instead of being logged and ignored (Vonsek's XOR case), and
  DepthClipEnable = FALSE is depth clamping (AlxcBTW). Both need their feature (logicOp, depthClamp), or the
  PSO is refused.
- The standalone device also enables shaderInt64, shaderFloat64, shaderInt16, shaderClipDistance and
  shaderCullDistance where the GPU has them (AlxcBTW, whattheflop: VUID-...-pCode-08740), plus logicOp and
  depthClamp.
- Among index entries for one program, a PSO takes the first that fits and declares no set-0 bindings, as
  pipelines do not bind set 0 yet. This covers the compute group in poke900310's corpus count, where an entry
  with 10 bindings shadowed a binding-free one.
- The command list holds a reference to every root signature and pipeline state it is given until Reset or
  its release, so releasing them right after Set* (as D3D12 allows) no longer leaves dangling layouts or drops
  the submission (AlxcBTW).

After the rebase onto main: main's SetPredication reads the predicate through the resource's VkBuffer, so a
default-heap buffer (a range of the GPU address arena) adds its offset in the arena, and the arena gets the
conditional-rendering usage when the extension is on (lahlousaad4's integration note).

Tests: d3d12_draw_test has a second pass with a full-screen triangle first in its submission and an XOR quad,
and a depth-clamp refusal. d3d12_compute_test releases its root signature and PSO right after setting them,
sets the signature again after the arguments, and has a bound entry ahead of the binding-free one in its
index. Each new fix, undone on its own, fails a test: pStrides-04913, wrong XOR pixels, a heap-corruption
crash without the hold, a refused PSO without the binding-free choice.

Documented as known gaps, not fixed here: wave64 subgroup size (AlxcBTW's follow-up in #313), cross-queue
waits on one VkQueue and CPU fence signals below a pending GPU signal (woreksami), and the linear buffer_at.
2026-11-22 05:01:36 +01:00
Ryx
8b711cc6b4 Runtime: fixes from CharlyRien's review of the compute and draw paths
Shader library
- fssm_program takes the last XDAT 0x0D payload, as tools/fssm_unpack.py does by default (195 of 26,503
  containers have two different ones, and fssm_sha256 is computed from the last).
- The JSON reader parses numbers with from_chars and \u escapes as exactly four hex digits, so a malformed
  index is refused instead of throwing into the shim. Integer fields outside 0..2^32-1 read as 0.
- Index entries that share a program are all kept; CreateGraphicsPipelineState takes the VS whose input
  signature the input layout feeds.

Command list
- Setting the root signature that is already bound keeps the root arguments, as D3D12 does.
- A draw with no viewport (never set, or RSSetViewports(0, ...)) or an empty one is not recorded: D3D12
  rasterizes nothing and Vulkan forbids a 0x0 viewport.
- More than eight render targets is an invalid call, in OMSetRenderTargets and in a PSO.

Device
- Buffers of 0 bytes, or with a size that wraps when aligned, are E_INVALIDARG. The arena refuses zero-size
  ranges, and its fit test cannot wrap.
- A shader-visible descriptor heap the arena cannot hold is E_OUTOFMEMORY instead of a host heap with GPU
  handle 0.
- A failed arena releases its buffer and memory, so other buffers do not get raw device addresses as VAs.
- Graphics PSOs that need independentBlend, fillModeNonSolid, depthBiasClamp or dualSrcBlend are refused
  unless VulkanDeviceInfo::features has them. The standalone device enables those the GPU supports.
- A draw that leaves a slot unbound where the PSO names a format uses a pipeline variant with that format
  undefined (built on first use, kept with the PSO), instead of breaking
  dynamicRenderingUnusedAttachments-08912.
- Instance step rate 0 reads element 0 for every instance (stride 0 at draw time).
- The Vulkan 1.0 graphics entry points are required; the 1.3 ones are checked before a graphics PSO is made.

Replay
- An unbound vertex slot, or an indexed draw with no index buffer, reads the arena's reserved first 64 KiB,
  which is kept zero, as D3D12 reads zeros. A view that runs past its buffer is cut at the buffer's end
  instead of failing the whole ExecuteCommandLists.
- The rendering layer count is the smallest layer count of the bound views.

Tests: shader_library_test covers two payloads, malformed JSON and duplicate programs. d3d12_draw_test
covers an unbound RT and DSV, a rebound root signature, step rate 0, an unbound vertex slot, a draw with no
viewport, the feature and count refusals, and bad buffer and heap sizes. Each of the rebind, step-rate and
variant fixes, undone on its own, makes the test fail.

Still open, documented: instance step rates above 1, read-only DSV layouts, and the index buffer's view size.
2026-11-22 05:01:36 +01:00
Ryx
1e7f5152ae Runtime: graphics pipelines and draws on Vulkan (milestone M1, D3D-4)
- CreateGraphicsPipelineState (PC slot 10): VS and PS found by the SHA-256
  of their FSSM programs in the translator's index. Input-layout elements are
  matched to the VS input signature by semantic name and index; location =
  the element's register (the translator's vertex-fetch rule); a layout that
  leaves an input unfed is refused, as D3D12 does. Rasterizer, blend and
  depth-stencil state map one to one; viewport, scissor, topology, vertex
  strides, stencil references and blend factor are dynamic; dynamic
  rendering takes the RTV/DSV formats. Hull/domain/geometry, stream output,
  MSAA, set-0 bindings and two code-base stages (question 14) are refused
  with a log.
- Command list: IASetPrimitiveTopology / VertexBuffers / IndexBuffer,
  RSSetViewports / ScissorRects (first of each), OMSetRenderTargets (views
  read at the call, single-range handles too), OMSetBlendFactor,
  OMSetStencilRef and CommandList8's front/back references (now applied),
  DrawInstanced / DrawIndexedInstanced recording a copy of that state.
  CreateCommandList's initial pipeline state is applied. Reset and
  ClearState share one state reset.
- Replay: vertex/index views resolve to buffers by VA (arena or upload),
  attachments move to attachment layouts through the tracker (first use
  zero-fills), the draw runs in a dynamic-rendering scope with a flipped
  viewport (translated VS write D3D clip coordinates), stencil references
  per face, then vkCmdDraw / vkCmdDrawIndexed. Render-target views take the
  pipeline's formats (the view cache keys on format).
- shader_library.h reads the index's input_signature and PS outputs.

Test: d3d12_draw_test (through the proxy) builds a VS+PS PSO whose input
layout order differs from the VS registers, uploads a vertex buffer into the
arena, reads indices from an upload heap, and draws two indexed quads with
different root constants and root CBVs plus a back-facing triangle: all 4096
read-back pixels match (which also checks the viewport flip and winding).
Shaders are GLSL written to the translator's contract. d3d12_com_test now
uses SetMarker as its unimplemented-method example, since DrawInstanced is
implemented. 13/13 ctest; all six GPU tests clean under the Khronos
validation layer.
2026-11-22 05:01:36 +01:00