Commit Graph

4696 Commits

Author SHA1 Message Date
fb31cc780e tests: rename the multisample levels in d3d12_descriptor_test
The multisample-quality check declared a local 'levels' that hid the footprint array 'levels[3]' still used later in the function, which MSVC /W4 reported as C4456. Rename the feature struct to quality_levels; no behavior change.
2026-11-21 20:30:57 -08:00
5517ed7ac0 Merge remote-tracking branch 'origin/main' into presentx-core-v2
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
2026-11-22 05:28:42 +01:00
daff874493 XboxPresentation: present null/stale/repeated tokens with a log, MSAA gives DXGI_ERROR_UNSUPPORTED, SuspendX never waits on a present; tests and docs
xbox_present_test presents with null, repeated and stale tokens (the present
happens) and refuses never-issued ones, and presents MSAA, integer and BC sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:34 +01:00
7677932bdf presenter: format-feature checks, srgb state set after recreate, abortable acquire
Blit support comes from vkGetPhysicalDeviceFormatProperties (BLIT_SRC source,
BLIT_DST swapchain, linear filter only with SAMPLED_IMAGE_FILTER_LINEAR), cached
per format. The swapchain encoding is recorded only once the new swapchain
exists, so a failed recreate is retried. The image acquire polls an abort
callback every 50 ms instead of waiting for ever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:34 +01:00
5241cf2cfe FramePacer: lenient tokens, SetFrameIntervalX keeps the origin armed, schedule keeps this period's origin
Only a token that was never handed out is refused; null, stale and repeated
tokens are reported through TokenIssue and presented. SetFrameIntervalX re-bases
the grid and leaves the origin event armed. ScheduleFrameEventX takes the origin
whose offset has not passed yet. ManualFrameClock calls its wake under the lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:21 +01:00
b7a0232523 runtime: XboxPresentation (PresentX 0/1/2 planes, frame events, Suspend/ResumeX) and xbox_present_test
Provisional struct layouts and constants of ours; real slots unmeasured (TODO
table in the header). The test reads the swapchain image back on a Vulkan
device and runs the frame events on a fake clock, then 30 frames in real time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:06 +01:00
4d62f48a5c presenter: source rectangle, blank present, sRGB swapchain format, frame capture
VulkanPresenter::present takes an optional source rectangle (stretched to the
window), present_blank clears the swapchain image, the swapchain format follows
the source (an sRGB source gets an sRGB swapchain, every other a UNORM one), and
enable_capture/read_back copy each presented frame to host memory for tests.
Integer, block-compressed and multisampled sources are refused. WindowPresenter
forwards all of it. Also renames the device-extension counters in
create_vulkan_device_standalone that the merge left shadowing each other (C4456).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:28:06 +01:00
bb6bb741fd Compile large Vulkan shader modules exclusively 2026-11-22 01:27:49 -03:00
70f184a636 feat(runtime): add D3D12 CBV/SRV/UAV buffer views and VkPipelineLayout root signatures 2026-11-22 01:27:04 -03:00
5ccbd36f39 runtime: FramePacer for the Xbox frame events (interval, origin event, latency, tokens, statistics, suspend/resume)
Header-only, injectable clock, tested on a fake clock (frame_pacer_test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:26:41 +01:00
69b1d114cc d3d12_translated_draw_test: rename the global size (it shadowed locals in vulkan_replay.h, C4459)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 05:26:10 +01:00
5aef74c8c6 Merge remote-tracking branch 'origin/main' into m15-translated-draw-v2
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 05:25:09 +01:00
9552f0d899 M1.5 review: structured V# out-of-range mode via gfx10::encode, stricter edge assert, softer 436 and V# docs
make_vsharp used OOB_SELECT raw with stride 32, which on hardware checks the byte offset
against num_records; the test only passed because the translator ignores OOB_SELECT. It now
encodes a gfx10::Buffer with OobSelect::structured. The 32 diagonal pixels must be the clear
colour (a right edge under the top-left rule). Docs: 436 is not in the tree (identical result
with its translator change applied); the V# failure follows from the upload buffer lying below
the arena, which is allocation order, so the rule stays: anything behind a V# is an arena range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:25:01 +01:00
ff84376255 Standalone Vulkan device: enable shaderDrawParameters when supported; log a missing shaderInt64
PR 436's translated vertex shaders read BaseVertex/BaseInstance, so the production device
must enable shaderDrawParameters before 436 lands (same lines as 436, so they merge). A GPU
without shaderInt64 cannot load any translated shader (all declare Int64): say so once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:24:55 +01: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
b962a709f6 Vulkan devices enable shaderInt64; the test device also shaderDrawParameters
Every translated shader declares Int64 (64-bit addresses) and lists shaderInt64 in
its index metadata, but neither the standalone device nor the test device enabled
it: vkCreateShaderModule was a validation error and the first translated draw
lost the queue. The test device also enables shaderDrawParameters, which the
translator's zero-based VS ids (PR 436) will need. Two names in the test device
no longer shadow each other after the merge with main. The standalone-device
change is PR 291's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:24:27 +01:00
46f5ce2f1d fix: sample linear and sRGB views of typeless RGBA8 volumes
A committed RGBA8 typeless image already permits mutable Vulkan views. Let explicit UNORM and sRGB Texture3D SRVs select their formats so shaders can read either interpretation of the same voxels.
2026-11-22 05:23:59 +01:00
53d2c6126b Report application-cache feedback for compiled Vulkan pipelines 2026-11-21 21:22:43 -07:00
8a58c59d71 Merge pull request #876 from sanuk369 2026-11-21 23:15:39 -05:00
12e53efa62 Merge pull request #875 from Cozma 2026-11-21 23:15:39 -05:00
7123be6c5e Merge pull request #869 from Ayoze Torres 2026-11-21 23:15:37 -05:00
e73037732f Merge pull request #868 from Størm 2026-11-21 23:15:37 -05:00
6b8b2e5f6e Merge pull request #865 from Felix Croasdale 2026-11-21 23:15:36 -05:00
f54d1f3f89 Merge pull request #864 from omardev29 2026-11-21 23:15:36 -05:00
524bb1fb7b Merge pull request #862 from sanuk369 2026-11-21 23:15:35 -05:00
5ff488901c Merge pull request #861 from adonizm 2026-11-21 23:15:35 -05:00
9b21cde473 Merge pull request #858 from traeb0n 2026-11-21 23:15:34 -05:00
91d938767f Merge pull request #855 from AlxcBTW 2026-11-21 23:15:34 -05:00
67bb661453 Merge pull request #850 from sanuk369 2026-11-21 23:15:33 -05:00
0e191881e2 Merge pull request #846 from Ayoze Torres 2026-11-21 23:15:32 -05:00
3dd8acf58c Merge pull request #834 from Vonsek 2026-11-21 23:15:31 -05:00
fa274f5709 Merge pull request #739 from Ayinaki
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-21 23:15:28 -05:00
a03a3db26b Merge pull request #737 from AlxcBTW 2026-11-21 23:15:27 -05:00
8d8c528aa1 Merge pull request #561 from Ayinaki 2026-11-21 23:15:23 -05:00
e28b1d63fb Merge pull request #423 from kotorvr 2026-11-21 23:15:23 -05:00
cce77b65ef Normalize binary occlusion results in Vulkan replay 2026-11-22 01:13:30 -03:00
enx
943e5f8048 Build the Windows runtime on Linux with clang-cl and xwin
runtime/cmake/clang-cl-xwin.cmake cross-compiles gta6rt, its shims and
tests with clang-cl and lld-link (LLVM 19+) against an MSVC CRT and
Windows SDK laid out by xwin, and makes ctest run them through Wine (or
Proton's wine). llvm-ml64 stands in for ml64, so the register-
preservation check in unimplemented_policy_test runs too.

Changes that let a cross build work without a Developer Prompt:
- gen_d3d12_stubs.py gets the d3d12.h CMake finds (--header) instead of
  relying on INCLUDE; without one the COM targets are skipped.
- d3d12_trace names the interpreter by path, so ctest doesn't prepend the
  emulator to Python, and check_d3d12_trace.py starts the fixture through
  the emulator (--runner).

docs/testing.md describes the build and the Wine and Proton runs.
2026-11-21 21:09:12 -07:00
9528e239e8 Tests: replay_cpu_bench, the layer's CPU cost per command
A benchmark of the D3D12 -> Vulkan replay's own CPU time: CommandList
recording, prepare and emit, with no-op Vulkan entry points that count
their calls and fake resource bindings, so no GPU, driver or game files
are involved. Bindings and image views are looked up the way
VulkanContext does (unordered_map, std::map view cache), and each
execution makes a new PreparedList, as VulkanQueue::execute does.

It reports, for every command kind on its own and for a frame mix
(barriers, whole-view and rectangle clears, buffer and texture copies,
a UAV clear, queries, predication), the median ns per command of each
phase, heap allocations per command and Vulkan calls per command, plus
the cost of just making and freeing the PreparedList entries.
--self-test (in ctest) checks that every kind and the frame record and
replay, and that the counts are the same on a second run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:07:56 -06:00
a6e3198607 Fuzzers: find vk_compute_test in a Visual Studio build
valu_fuzz.py and lds_fuzz.py ran <build>/vk_compute_test, so with the Visual
Studio generator (runtime/build/RelWithDebInfo) every program stopped with a
FileNotFoundError traceback. They now look in <build> and then its
RelWithDebInfo/Release folder, as run_gpu_tests.py does, and stop with one line
when it isn't built. crosslane_fuzz.py's default --exe gets the same fallback.
2026-11-22 09:37:03 +05:30
5097ea041a GameInput shim: keyboard pad (LEONIDA_KEYBOARD_PAD)
The title reads gamepads only, so keys reach it as one more pad: an SDL
virtual gamepad whose buttons are pressed from GetAsyncKeyState on each
poll. It goes through open_pad/read_pad like a real controller (device
object, player slot, readings, callbacks, UI navigation) and reports no
motors.

Arrows d-pad, Enter A, Backspace B, X X, Y Y, Q/E shoulders, Esc Menu,
Tab View. Off by default; =1 reads keys only while a window of this
process is in the foreground and releases everything on focus loss,
=always ignores focus (console tools). Sticks and triggers stay at rest.

gameinput_test drives it through set_keyboard_source with fake keys and
focus: 31 new checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:05:38 +02:00
16e6c330cd Runtime: trace debug markers by name; trace test uses a method still unsupported
SetMarker/BeginEvent/EndEvent on lists and queues are implemented now, so
they record a 'called' trace entry (the name only, never the label), and
the d3d12_trace check takes SetProtectedResourceSession as its example of
an unsupported call. The synthetic label still must not reach the trace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 04:05:36 +00:00
4fc1301a11 Merge remote-tracking branch 'origin/main' into claude/d3d-24-debug-markers-457bab
# Conflicts:
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/src/command_list.h
#	runtime/src/vulkan_replay.h
#	runtime/test/vk_test_device.h
2026-11-22 04:05:35 +00:00
059b9f325f Runtime: CreateHeap and CreatePlacedResource on the Vulkan layer 2026-11-22 05:04:53 +01:00
a03f0c5e13 d3d12_state_map_test: DiscardResource subresource ranges through prepare()
A CPU-only check of the loop renamed in the previous commit: two per-subresource
discards in one list each give their own ranges (mip and layer decoded), a
partial discard records none, and a range one past the last subresource is
refused. With the loop stopping one short, the test fails at first.size() == 3.
docs/d3d12_vulkan.md now lists this and the Resizable BAR detection the test
already had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:03:26 -06:00
eb2928a8b4 Merge remote-tracking branch 'origin/main' into claude/d3d-30-fences-timing-7ce86f
# Conflicts:
#	runtime/shims/d3d12_com.cpp
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 04:03:01 +00: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
80e5cacabe Runtime: refuse PSOs below 144 bytes of push constants; push-constant stages from the stage table
Review feedback from IAmNotSiob:
- Both PSO paths declared a 144-byte push-constant range without consulting #224's limit. On a device with
  maxPushConstantsSize 128 (the Vulkan minimum) that breaks VUID-VkPushConstantRange-size-00298 and returns a
  bare E_FAIL. Both paths now refuse with E_NOTIMPL and log the limit until the uniform-buffer tail exists.
  d3d12_compute_test checks this with a device that reports 128 bytes.
- The graphics range's stage flags are now the whole stage table create_graphics accepts, kept in
  GraphicsPipeline::push_stages, and the replay pushes with the same flags. A geometry or mesh stage added to
  the table is covered without another change.

docs/d3d12_vulkan.md section 5.2 now counts code-base readers per stage with the current translator: of the 662
shaders with s_getpc_b64, 53 VS, 92 PS, 246 MS and 263 CS read the code base. VS+PS pairs are only known at
PSO creation.
2026-11-22 05:01:36 +01:00
Ryx
1267591716 Runtime: only allocate from a memory heap that can hold the allocation (arena without Resizable BAR)
Without Resizable BAR the only DEVICE_LOCAL | HOST_VISIBLE memory type sits in a heap of 256 MiB or less
(214 MiB on an RTX 3090, driver 616.56). The 256 MiB default arena preferred that type, so vkAllocateMemory
was asked for more than the heap holds (VUID-vkAllocateMemory-pAllocateInfo-01713). The NVIDIA driver still
returned VK_SUCCESS, so the fallback to plain host-visible memory never ran, and d3d12_compute_test and
d3d12_draw_test failed under validation. Reported by CharlyRien.

memory_type_order (vulkan_backend.h) now leaves out every type whose heap is smaller than the allocation,
so the preference falls through to system memory there. DeviceState::allocate uses it for every allocation.
d3d12_state_map_test checks the order on that card's heap layout and with Resizable BAR on.
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