Commit Graph

4696 Commits

Author SHA1 Message Date
b3e71d7a4d runtime: UINT border colours use VK_BORDER_COLOR_INT_* (#538 review)
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>
2026-11-22 01:03:36 +00:00
ffb5e34b9c runtime: CreateSampler2 on the Vulkan device (D3D-28, part 2)
CreateSampler2 wraps CreateSampler. The UINT border colour maps (0,0,0,0),
(0,0,0,1) and (1,1,1,1) to the S#'s border types, and anything else to the
table. Non-normalized coordinates set FORCE_UNNORMALIZED. A description the PC
runtime refuses (unknown flags; a non-normalized sampler with an unequal
min/mag filter, a linear mip filter, anisotropy, comparison, a U/V address mode
other than clamp/border, or a non-zero LOD or bias) leaves the slot as it was,
as the runtime does on an RTX 4090 and on WARP. The layer now answers
D3D12_OPTIONS17 with NonNormalizedCoordinateSamplersSupported, as both report.

d3d12_sampler2_test compares the S# bytes with CreateSampler's and the 22
edge cases with the host's PC runtime live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:03:36 +00:00
382daba42f runtime: the 1/2/3 method variants on the Vulkan device (D3D-28, part 1)
CreateCommittedResource1/2/3, CreateCommandQueue1 and GetCopyableFootprints1
as thin wrappers over the existing methods. D3D12_RESOURCE_DESC1 drops to
D3D12_RESOURCE_DESC; the initial state or barrier layout is unused, because new
textures start UNDEFINED and move on first use. The newer arguments are answered
as the PC runtime answers them (measured on an RTX 4090, driver 621.14):

- a protected resource session: E_INVALIDARG (no session support reported);
- a sampler-feedback mip region: E_INVALIDARG on textures, ignored on buffers;
  GetCopyableFootprints1 returns its failure answer for such a texture;
- a buffer's initial layout other than UNDEFINED: E_INVALIDARG;
- a castable count with a null list: no list;
- a castable list: E_INVALIDARG, since it needs RelaxedFormatCastingSupported,
  which the layer does not report (D3D12_OPTIONS12 is unanswered);
- CreateCommandQueue1's creator ID: ignored.

d3d12_method_variants_test compares each variant with its base method, runs the
edge cases and, when the host has a D3D12 device, compares each answer with the
PC runtime live. Thanks to ezwinxdlmao for the probe notes in #156.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:03:35 +00:00
cfc314d233 Docs and CMake: the runtime needs the Windows SDK 10.0.26100 or newer
The runtime uses version 1.2 root signatures (D3D12_ROOT_SIGNATURE_DESC2),
which older SDKs such as 10.0.22621 don't declare, so the build failed
halfway through with a compiler error. The prerequisites now name the SDK,
docs/testing.md has a Known problems row for the error, and CMake checks
for it at configure time and stops with the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:03:14 -05:00
6e0d2066ee Merge remote-tracking branch 'upstream/main' into codex/bgr565-readback
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 02:02:13 +01:00
b3edaf3ed4 Merge remote-tracking branch 'upstream/main' into codex/rgb9e5-texture
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 02:02:12 +01:00
bd7e53f43a Runtime: serialize root signature 1.2 as 1.1 on runtimes that stop at 1.1 (WIN10-ROOTSIG)
The in-box d3d12.dll of Windows 10 (and Windows 11 23H2, #361) serializes
root signatures only up to 1.1: on Windows 10 it rejects even an empty 1.2
description with E_INVALIDARG (#528). #361 made the tests skip there, but the
d3d12_xs serializer still forwarded 1.2 descriptions unchanged, so every 1.2
root signature from the package DLLs or the game failed on those hosts.

- d3d12_xs_rootsig: downgrade_root_signature_1_2_to_1_1 rewrites a 1.2
  description whose static samplers all have Flags == 0 as the same root
  signature in 1.1 (1.2 differs only in D3D12_STATIC_SAMPLER_DESC1::Flags).
- d3d12_xs: probe the host once with an empty 1.2 description; where it
  stops at 1.1, serialize 1.2 as 1.1, or refuse one with sampler flags
  with a log line.
- root_sig_test: the registered shim's 1.2 checks run on every runtime again;
  new checks cover the rewrite field by field, through the registered shim
  and back through the host deserializer, and the refusal.
- root_signature_oracle_test: its 1.2 cases use sampler flags, which have no
  1.1 form, so they print SKIP where the host can't serialize 1.2.
- docs/d3d12_vulkan.md: the measurement and the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 17:01:11 -08:00
7cfa4354fe runtime: unimplemented-import stub review fixes and ABI tests
- make_common_stub checks RtlAddFunctionTable and reports a failure once;
  the stub keeps working, only stack walks through it stop.
- rt_unimplemented keys per-import state by the thunk's `what` pointer, so a
  repeat call does one map lookup and builds no strings.
- A test hook (set_unimplemented_test_hook) lets unimplemented_policy_test
  check, from inside the call, that rsp is aligned and that
  RtlLookupFunctionEntry/RtlVirtualUnwind walk through rt_unimplemented and
  the stub back to the caller.
- abi_probe.asm (MASM) calls a thunk with rbx/rbp/rdi/rsi/r12-r15 and
  xmm6-xmm15 set to patterns and compares them afterwards, with a control
  callee that clobbers rbx and xmm6.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 01:58:29 +01:00
037c373a24 feat(runtime): support B5G6R5 render targets and copies
D3D12 stores blue in the low five bits of B5G6R5. Use the Vulkan packed format with the same ordering and check the two-byte words returned by full-image and rectangular clears.
2026-11-22 01:56:04 +01:00
2c01fc8091 Validate sample descriptions on buffers and allocation queries 2026-11-22 01:55:55 +01:00
a4996c7ab4 Merge origin/main into f64-output-modifiers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:55:11 +01:00
0cdf534413 Use the resource depth-format fallback for MSAA quality queries 2026-11-22 01:54:23 +01:00
66a5fc90f8 Query multisample quality for depth-stencil formats 2026-11-22 01:53:53 +01:00
b3c2623554 Merge pull request #541 from SirAmong 2026-11-21 19:53:11 -05:00
6b34635a67 Merge pull request #531 from Capital 2026-11-21 19:53:09 -05:00
1ce79642f6 Merge pull request #525 from Luis Baker
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-21 19:53:08 -05:00
d29971a89b Merge pull request #518 from isaactouzani34100 2026-11-21 19:53:07 -05:00
302b4f2770 Merge pull request #516 from ezwinxdlmao 2026-11-21 19:53:07 -05:00
824f07e9af Merge latest main and align Vulkan MSAA with D3D12 sample limits
Expose only D3D12-valid Vulkan sample counts (2..32), allow 32x allocations, and reject zero, oversized, and unsupported-quality resource descriptions. Extend resolve/allocation coverage to 32x MSAA and add boundary tests.
2026-11-22 01:51:30 +01:00
3973ce8c20 feat(runtime): support sampled RGB9E5 textures
Map the shared-exponent format through resource creation and buffer-image copies so shaders can resolve its existing GFX10 view. Check the sampled channels and compare the mip-array footprints with the host runtime.
2026-11-22 01:47:40 +01:00
c0dbd14b96 Runtime: compare copies with the host runtime (D3D-46)
CopyResource, CopyTextureRegion (texture to texture, footprint to texture and back, boxes, offsets, array slices,
mips, 3D) and CopyBufferRegion run on the layer and on a host D3D12 device (LEONIDA_HOST_ADAPTER picks it) and the
bytes read back are compared, for 39 format/shape cases including BC1-7 and depth-stencil.

Layer fixes it found: texture formats R8G8_SNORM, R16_UNORM, R32G32_UINT, R9G9B9E5, B5G6R5 and B5G5R5A1 were
refused; a block-compressed texture-to-texture box reaching the padded mip edge was refused as invalid_copy.
Known differences (TEXTURE1D, D24 on GPUs without it, D24 X8 byte) are documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:47:27 +01:00
bcb9f6d5f2 runtime: LEONIDA_UNIMPLEMENTED=log|fail|stop policy for imports with no binding
An unimplemented import used to return 0 silently, which is S_OK for an
HRESULT function with its out parameters never written. The thunk now passes
the caller's return address and rcx/rdx/r8/r9 to a shared stub, and
LEONIDA_UNIMPLEMENTED picks the behaviour:

- log (default): exactly as before.
- fail: E_NOTIMPL for imports known to return HRESULT (D3D12Create*/Serialize*,
  CreateDXGIFactory*, XGameRuntimeInitialize, and the GDK XAsync/XTaskQueue/
  XUser/XStore/XGameSave/XPackage/XGameUi families minus their documented
  void/bool/int functions), 0 otherwise.
- stop: print the import, the caller as module+RVA and the four argument
  registers, then break under a debugger or exit with code 3.

--dry-run now counts unimplemented imports by return class. The stub zeroes
xmm0 and has unwind info, so float callers and debuggers are unaffected.
unimplemented_policy_test builds a synthetic image and checks all three modes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 01:46:33 +01:00
bfc6b6ed22 Merge pull request #493 from Andrea 2026-11-21 19:43:43 -05:00
0288f1a723 Merge pull request #439 from SombraSoft 2026-11-21 19:43:38 -05:00
45cf469013 Merge pull request #388 from 73N1X 2026-11-21 19:43:25 -05:00
8e02b90c29 Merge pull request #350 from nicolas
# Conflicts:
#	docs/design.md
2026-11-21 19:43:25 -05:00
c03c2bfdb9 Merge pull request #296 from Vonsek 2026-11-21 19:43:21 -05:00
b28c8ac0af Merge pull request #288 from Parakeet-Wheat 2026-11-21 19:43:17 -05:00
bcd38863f5 Merge pull request #268 from shelbykb2 2026-11-21 19:43:16 -05:00
8b5d88dec9 Merge upstream main into D3D-47 resolve comparison
Preserve reserved-resource coverage alongside multisample resolve support and comparison tests. Fix the Windows SDK ResolveSubresourceRegion rectangle mutability.
2026-11-22 01:42:26 +01:00
737735aecb Translator: v_movrelsd_2_b32 with separate M0 source/destination fields
VGPR[D + M0[25:16]] = VGPR[S0 + M0[9:0]] (RDNA2 ISA VOP1 opcode 72; same
fields in the RDNA3 ISA). It raised Unsupported before (noted in #496).

- tools/rdna2spirv.py: masks M0 per side on the existing movrel path.
- tests/semantic/test_alu_movrelsd_2.py: 7 hand-computed cases through the
  translator and the interpreter, including ignored M0 bits set, the _e32
  spelling and a check that it differs from v_movrelsd_b32.
- runtime/test/shaders/cs_movrelsd_2.asm: GPU test (wave32 dump) with the
  ISA's own example; registered in check.py and run_gpu_tests.py.
- docs/design.md: contract row for the v_movrel* forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 19:34:25 -05:00
e27749fcaf Preserve the last complete Vulkan pipeline cache checkpoint 2026-11-21 17:29:54 -07:00
879e1a798d Merge upstream texture and generated shader tests into the a16 fix
Use the canonical shader source for clip dependencies and preserve texel-offset checks next to explicit gradients.
2026-11-22 01:28:49 +01:00
0b29a78949 Keep barrier state tests compatible with newer Windows SDKs
Windows SDK 10.0.28000.0 omits the legacy video queue layout
enumerator. Compare against the enum when the SDK exposes it and
check the established numeric value on newer SDKs.
2026-11-22 01:28:06 +01:00
8f3fc8bd3b CI: build Windows Vulkan/COM targets via Vulkan-Headers and add sccache 2026-11-21 21:27:42 -03:00
58019e85ec Merge main and preserve predicated typeless clear handling 2026-11-21 20:26:41 -04:00
3164a4107a Merge upstream texel-offset coverage with the two-mip fixture
Preserve maintenance8 and the existing texture checks when building the optional two-level view.
2026-11-22 01:25:34 +01:00
1565e63418 Merge commit '91b36cf86cb92a95836eed8af73abc0671a61e31' into codex/med3-result-modifiers
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
2026-11-21 17:25:32 -07:00
adc1549376 Runtime: WriteToSubresource and ReadFromSubresource on the Vulkan device
Both were generated stubs; WriteToSubresource is in the first-frame API set
(docs/d3d12_vulkan.md section 6.1). Textures in CPU-visible custom heaps map with a
null pointer, as on D3D12, and copy on the host with VK_EXT_host_image_copy while
they are in GENERAL (D3D12's COMMON). Every other case is a CopyTextureRegion
from or to a staging buffer, replayed on the device's queue and waited for, so the
layout tracker and first-use zero fill behave as for the application's copies.
The standalone and test devices enable the extension where the GPU has it.

d3d12_vulkan_device_test checks both paths: boxes and pitches, a mip, a volume,
BC1, rejected calls, a default-heap texture, and GPU copies in both directions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:24:38 +11:00
e816f20b29 Runtime: SNORM/SINT render targets and clear conversion (D3D-45)
Add DXGI->Vulkan mappings and footprint sizes for SNORM and SINT render-target formats, and extend render_target_clear_color to convert SINT clears numerically (NaN to zero, clamp to the signed range, truncate toward zero) instead of copying float bits. Rename d3d12_uint_clear_test to d3d12_clear_test and widen it to compare UNORM/SNORM/FLOAT/UINT/SINT render-target and depth/stencil clears against Windows WARP, full and rectangle. SRGB clears are left out of the byte-exact comparison: the linear->sRGB encoding rounds differently at the .5 boundary on WARP vs Vulkan (a 1-ulp driver difference).
2026-11-22 01:21:20 +01:00
d999bb9709 Merge pull request #421 from shelbykb2
# Conflicts:
#	tests/semantic/README.md
#	tests/test_shader_checks.py
2026-11-21 19:19:04 -05:00
0b7233e567 Tests: the D3D-14 push-constant check accepts GPUs with 128 bytes
d3d12_vulkan_device_test asserted that the real test device never needs
the push-constant fallback. On a GPU whose maxPushConstantsSize is 128 (the
Vulkan minimum), the device is right to flag it, so the test stopped there.
That happens on Intel Arc, and on a Radeon 680M on the Windows driver
22.40.84.06. The check now asserts that the flag matches
maxPushConstantsSize < 144, which holds on either kind of GPU. The
simulated 128-byte device below it still covers the flagged path.

docs/d3d12_vulkan.md: the 680M joins Intel Arc as a measured 128-byte GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:18:39 +02:00
3a83c29eae GPU tests for f16 op_sel and partial writes, hardware-measured; f16 inline constants fixed (SHADER-13)
Covers the "16-bit results" contract row, which ended with "not yet GPU-verified".

Hardware evidence: AMD RX 6800 (gfx1030), the instructions run as a raw compute kernel in wave32 and
wave64, IEEE off, DX10 clamp on, denormals kept, round to nearest. The bytes assemble identically for
gfx1013 and gfx1030 (llvm-mc 21; the kernels themselves were assembled by the driver's comgr).
- v_med3_f16: all 16 op_sel patterns, neg/abs on a selected high half, clamp, destination also a source.
- v_add/sub/mul/max/min_f16 (_e32, _e64 with neg/abs/clamp), v_fmac_f16 (_e32, _e64), f16 unary
  (rndne/floor/ceil/trunc/fract/sqrt/rcp/rsq, _e32 and _e64), v_cvt_f16_f32: low halves in, low half out,
  high half of the destination kept; the v_fmac_f16 accumulator is the low half of the destination.
  336 words per wave size, all as the rule says and as the translator computes.
- Not expressible: op_sel on the VOP2/VOP1 ops in VOP3 encoding (v_add/sub/mul/max/min_f16_e64,
  v_fmac_f16_e64, unary _e64). llvm-mc rejects the modifier and its disassembler drops the bits, so
  nothing was measured there and nothing was hand-encoded.

Translator fix (tools/rdna2spirv.py, new src_h): an inline float constant in an f16 operand is the f16
value in the low half over a zero high half. The translator unpacked the f32 pattern, whose low half is
zero, so v_add_f16 d, 1.0, v added 0.0 and v_cvt_f32_f16 d, 0.5 gave 0. Measured for v_add/mul/max_f16,
v_sub_f16_e64, v_fma_f16, v_fmac_f16, v_rcp_f16, v_med3_f16, v_cmp_lt_f16, v_cvt_f32_f16, v_cos_f16,
v_pk_add/mul_f16 and v_pack_b32_f16 (0.15915494 is 0x3118); the high half op_sel selects from a constant
reads +0.0. v_fma_mix* operands were not
measured and are unchanged.

Tests:
- runtime/test/shaders/ps_f16_{med3_opsel,med3_mods,vop2,vop2b,vop1,vop1b,const,const2,pack}.asm, wired into
  check.py and scripts/run_gpu_tests.py. Their expected words are the ones the hardware gave for the same
  instructions. Vulkan, AMD Radeon RX 6800, Windows, driver 26.11.2: 9/9 pass; with one expected word
  flipped per test 0/9 pass; without the translator fix ps_f16_const, ps_f16_const2 and ps_f16_pack fail.
- tests/test_f16_hw_words.py: header, check.py and run_gpu_tests.py hold the hardware words; a
  plain-Python reference of the rule and the translator (tests/spirv_interp.py) both give them. 12 of its
  tests fail without the fix.
- tests/semantic: ps_f16_vop2 fixture and value test; the v_sin_f16 mutation anchor follows the edit.
- tests/spirv_interp.py: Floor/Ceil/Trunc/RoundEven keep the sign of a zero result (trunc(-0.75) is
  0x8000 on the hardware and on Vulkan), Sin/Cos, component-wise vector arithmetic.
- python -m unittest discover -s tests/semantic: 388 -> 389, OK. pytest tests: 1467 -> 1514 passed.
  scripts/run_gpu_tests.py (test tools rebuilt): 48/49 -> 57/58 passed, 1 skipped.

docs/design.md: the "16-bit results" row says what was verified and what is not expressible; new row
"f16 inline constants".

AI-assisted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 17:17:58 -07:00
2fd9504e92 Merge pull request #488 from LuanFreitas 2026-11-21 19:14:13 -05:00
291d0f604a Merge pull request #478 from slopgobblercobbler 2026-11-21 19:14:12 -05:00
edb8bb8643 Merge pull request #477 from tunczzzz
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
2026-11-21 19:14:12 -05:00
a6e5cc7927 Merge pull request #437 from Dea7hsmiles 2026-11-21 19:14:03 -05:00
a3e8a7f9e0 Merge pull request #420 from kotorvr 2026-11-21 19:14:02 -05:00
fad3f9ee9e Merge pull request #416 from VictorJulianiR 2026-11-21 19:14:01 -05:00
d407987c33 Merge pull request #411 from Gen800 2026-11-21 19:14:01 -05:00