Commit Graph

4696 Commits

Author SHA1 Message Date
564eb48c8e fix(runtime): apply ResourceMinLODClamp to sampled 3D volume views
Texture3D SRVs already encode ResourceMinLODClamp into the T# descriptor, but image_descriptor() rejected non-zero clamps and bind_image() only applied VK_EXT_image_view_min_lod / empty-mip-set swizzle zeroing to 2D, 2D-array and cube colour views.

Allow non-zero ResourceMinLODClamp on sampled 3D colour views, forward the T# clamp to Vulkan in bind_image(), update docs/d3d12_vulkan.md, and add synthetic GPU sampling and negative-control checks in d3d12_descriptor_test.
2026-11-22 13:12:54 +01: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
e4f1093278 M2 test: sampler control (ps_m2_uoff, WRAP left / CLAMP right, CPU-predicted pixels)
With U in range, a POINT/CLAMP sampler, a POINT/WRAP one and the fallback sampler give the same pixels, so the
first pass cannot tell which sampler a draw used. The control adds 1 to U before image_sample and picks the sampler
per half through the sampler table: 4096 of 4096 pixels match the CPU prediction and 1536 differ from the plain pass.

Sampler control suggested and measured by @Vonsek in #1489.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:10:05 +01:00
72b5b7820d Merge main into test-184-image-ops
main is at 99f99890. One conflict, both sides kept:

- tests/test_shader_checks.py: main shortened the comment above TOTAL and
  counts a fourth vk_store_test shader (cs_sample_lz_int_d16: 3 -> 4) on the
  lines this branch's comment change touches. Main's comment with a clause
  for the "words" fixtures and the image_get_lod draws, main's count, and
  this branch's STORE_WORDS and GET_LOD_TESTS terms.

The automatic merges were read as well: check.py and run_gpu_tests.py run
cs_sample_lz_int_d16 through vk_store_test's "load-d16" mode next to the
"words" fixtures, and gfx10_descriptors.h still encodes the T# of the 16x4
image the same way.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 07:09:14 -05:00
4ffc2bc178 tests: d3d12_rgb96 and d3d12_stencil_copy skip under Wine (follow-up to #1343)
Under Wine with a Vulkan GPU both failed instead of skipping:
- d3d12_stencil_copy: its ctest entry sets LEONIDA_HOST_ADAPTER=warp, and
  copycmp::create_host exits 1 when that adapter isn't there, which under
  Wine it never is.
- d3d12_rgb96: Wine 11 has a WARP adapter (vkd3d), so the 'no WARP' skip
  doesn't fire and the test compares against vkd3d's footprints.

Both now return 77 when the host D3D12 is Wine's, as the other host
comparisons do since #1343. Windows is unchanged.

AI-assisted (Claude Code).
2026-11-22 13:09:10 +01:00
934bb0c78c Merge pull request #1541 from AlxcBTW
# Conflicts:
#	docs/design.md
2026-11-22 07:08:07 -05:00
948f5799c0 Merge pull request #1537 from adriaespii 2026-11-22 07:08:05 -05:00
cf7b7444b9 Merge pull request #1531 from Shadman PC 2026-11-22 07:08:04 -05:00
1c9a997e9d Merge pull request #1525 from romainveurrier 2026-11-22 07:08:02 -05:00
57490d226c Merge pull request #1524 from bobcatchris 2026-11-22 07:08:02 -05:00
a42b5abd79 Merge pull request #1522 from totonii 2026-11-22 07:08:02 -05:00
497597353c Merge pull request #1521 from Luiz Neves 2026-11-22 07:08:01 -05:00
0c56af2b88 Merge pull request #1519 from Hadagalberto Junior 2026-11-22 07:08:01 -05:00
81f26eefc8 Merge pull request #1517 from Dominik 2026-11-22 07:08:00 -05:00
66111c29d3 Merge pull request #1512 from Hamza
# Conflicts:
#	docs/design.md
#	docs/testing.md
2026-11-22 07:07:59 -05:00
48a8d23be0 Merge pull request #1511 from zneel 2026-11-22 07:07:58 -05:00
0acb7399b5 Merge pull request #1505 from DomasUrbonas 2026-11-22 07:07:56 -05:00
a4801cf9ed Merge pull request #1493 from Dominik 2026-11-22 07:07:54 -05:00
fdb0e84fb0 Merge pull request #1490 from Vonsek 2026-11-22 07:07:53 -05:00
bffad8677a Merge pull request #1478 from Vonsek 2026-11-22 07:07:49 -05:00
cbb770ff65 Merge pull request #1447 from Claude 2026-11-22 07:07:47 -05:00
9b60294e28 Merge pull request #1324 from lloyd 2026-11-22 07:07:45 -05:00
db6c5790dc Merge pull request #319 from Vonsek 2026-11-22 07:07:44 -05:00
ee7c52a102 Translator: swizzled buffer V#s and ADD_TID_ENABLE (SHADER-231)
MUBUF/MTBUF accesses follow the RDNA2 ISA's swizzled buffer addressing
(8.1.5, tables 33/35/37) with the V# fields of Mesa's gfx10-rsrc.json:
SWIZZLE_ENABLE word1 bit 31, INDEX_STRIDE word3 [22:21], ADD_TID_ENABLE
word3 bit 23, element size fixed at 4 bytes. ADD_TID adds the wave lane to
the index (swizzled or linear), dword k of a swizzled access is 4 * IS bytes
after dword k - 1, and OOB_SELECT 3 with swizzle and a stride checks like
mode 0. Literal V# words fold; run-time ones use IS = 2^(swz * (3 + n)), so
IS = 1 is the linear address. A literal swizzled V# used to be Unsupported
and a run-time one was translated unswizzled.

Tests: tests/semantic/test_buffer_swizzle.py (hand-worked addresses, literal
and run-time V#s) and the GPU fixture cs_buf_swizzle.asm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:06:51 +01:00
a9bab0cf30 Subgroup size: keep the required-size structs in the PSO recipe, judge ps_w64x_readlane only where 64 was required, register d3d12_subgroup
The graphics stage infos chain structs that variants built at draw time still read. d3d12_subgroup_test builds its V# with OOB_SELECT 3. check.py and run_gpu_tests.py skip the wave64 pixel fixture where the fragment stage could not be required 64-wide (vk_harness says so). d3d12_subgroup is registered with ctest and exits 77 without a Vulkan device.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:57 +01:00
910a789d0d Tests: enable shaderInt64 on the test Vulkan device
The translated shaders declare Capability Int64 for the physical-storage-buffer address arithmetic; the standalone device now enables shaderInt64, but the test device (vk_test_device.h) did not, so vkCreateShaderModule broke VUID-VkShaderModuleCreateInfo-pCode-08740 on every translated module under validation (found with d3d12_subgroup_test).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:57 +01:00
2e7d374cb4 M2: drop pre-#291 leftovers so the branch diff is only M1.5 + M2 on main
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:05:52 +01:00
6a2c59f075 Tests: a wave64 pixel shader through a graphics PSO, and the driver's subgroup size observed
d3d12_subgroup_test now draws ps_w64x_readlane.asm (a wave64 pixel shader with
v_readlane of lanes 40, 5, 33 and 63) over 64x64 pixels through a D3D12 graphics
PSO into a float target: every pixel must carry the derived words where the PSO
required 64 (4096 of 4096 on the Radeon 880M). Probe shaders (compute and
fragment) store gl_SubgroupSize, so the size the driver ran them with is
observed and must equal what the PSO required; a wave32 compute shader's control
run is asserted to differ on a device whose default is not 32, and the pixel
probe shows the wave32 request changing 64-wide to 32-wide on the 880M. The
wave64 pixel control is asserted to differ only where the default pixel
subgroup is not 64.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:42 +01:00
36998edb14 Runtime: a default subgroup size that is the wanted one is device_default, not unavailable
Where the size cannot be required (the stage is not in requiredSubgroupSizeStages,
or subgroupSizeControl is off) but the device default is the wanted size, the
shader works as it is. The decision now says device_default (not guaranteed
stable, but not inexact and not logged as such); only a different default stays
unavailable. The REQUIRE_FULL_SUBGROUPS citations are corrected: the feature rule
is VUID-VkPipelineShaderStageCreateInfo-flags-02785, the stage rule flags-08988
(flags-02784 is the ALLOW_VARYING feature rule).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:41 +01:00
3c6102543e Tests: subgroup size control through D3D12 PSOs (d3d12_subgroup_test)
Dispatches cs_w64x_readlane translated natively and with --wave64-emulate, and
the wave32 cs_wqm_w32, through compute PSOs of the Vulkan device and compares
the words they store. The PSO's request must match the decision function; the
native wave64 shader must be exact where the device can give 64 and is only
reported where it cannot, the emulated one must be exact everywhere. A control
run with nothing requested is printed. The shaders are translated at build time
with test/shaders/build.py when llvm-mc is available.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:17 +01:00
7b88178d11 Runtime: request the translated subgroup size in compute and graphics PSOs
Device creation enables subgroupSizeControl and computeFullSubgroups where the
GPU has them and keeps minSubgroupSize, maxSubgroupSize, the default
subgroupSize, maxComputeWorkgroupSubgroups and requiredSubgroupSizeStages in
VulkanDeviceInfo::subgroup (also printed at creation). CreateComputePipelineState
and CreateGraphicsPipelineState run decide_subgroup_size() per stage and chain
the result into the stage create-info; the "wave64 compute shader runs
32-wide" log line goes away. A size the device cannot give is logged once per
stage with the first shader's name, and tells the build to use
--wave64-emulate where that exists (compute, mesh).

pipeline_subgroup_requests() exposes what each stage of a PSO asked for.
vktest::Device fills the same properties and the compute and draw tests pass
them on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:10 +01:00
98aca391ca Runtime: decide the subgroup size a pipeline stage asks for
decide_subgroup_size() maps a shader index entry and the device's subgroup
size properties to what a stage should request: nothing for an emulated
shader, VkPipelineShaderStageRequiredSubgroupSizeCreateInfo with the size the
translation assumed (64 for wave64, 32 otherwise) where the feature is on, the
stage is in requiredSubgroupSizeStages, the size is a power of two within
[min, max] and the workgroup fits size * maxComputeWorkgroupSubgroups, and
REQUIRE_FULL_SUBGROUPS for compute when computeFullSubgroups is on and local X
is a multiple of the size. A device with one size that is the wanted one needs
nothing; otherwise the size is reported unavailable.

subgroup_size_test checks it against AMD-like, NVIDIA-like and old-RADV
properties, the limits, and the resulting create-info chain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:10 +01:00
7176d29679 Runtime: read subgroup_size and wave64_exchange from the shader index
ShaderEntry gains subgroup_size (0 when the entry says null or has none) and
wave64_exchange; emulated() is true for a shader translated with
--wave64-emulate, which is exact on any subgroup size. shader_library_test
checks an absent, a native and an emulated entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:09 +01:00
217249c8a3 Runtime: ExecuteIndirect with MaxCommandCount 0 is a no-op, not a failed list 2026-11-22 17:34:40 +05:30
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
2f54b2c171 xbox_present: skip the known sRGB swapchain STORAGE validation VUID
NVIDIA's validation layer checks the presenter's sRGB swapchain as if it requested STORAGE, then reports VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 and its max-layers/max-extent follow-ons. The presenter only requests TRANSFER_DST, plus TRANSFER_SRC for capture, so that is a layer false positive. Count this VUID separately and return the ctest skip code only when it is the sole validation error; any other error, or a mix, still fails.

The matcher is covered by synthetic first-message and follow-on checks in xbox_present_test. On an RX 7900 XTX with validation on, the test remains clean and passes.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 06:03:54 -06:00
ce305ec6b3 Translator: wave64 VS/PS/GS on 32-wide subgroups when the halves can't tell (SHADER-10)
tools/wave64_halves.py classifies each wave64 VS/PS/GS by partition
invariance: A exact as translated, B exact by construction (waterfall loops,
wave-aggregated atomics up to slot order, readfirstlane/readlane of values
that are the same in every lane), C not exact (lane counts/ranks/ids,
readlane of varying data, stale scalars behind votes, masks as data, ...).
index.json gets wave64_graphics, wave64_graphics_reasons and
wave64_graphics_idioms; --wave64-graphics warn|error|off (error refuses
tier C). One rewrite: readlane of a proven-uniform VGPR reads the own copy.
--census prints tier counts from an index.json. ps_w64_* fixtures,
w64_graphics.py (fragment subgroup size required 64 vs 32) and semantic
tests; vk_harness gets VKH_HEAP_DUMP and a subgroup-size report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:03:37 +01:00
95288af6df Tests: skip d3d12_present on-screen colour check on HDR displays (TEST-209)
On a Windows HDR desktop, DWM scales SDR content by the user's configured
SDR white level, causing GDI GetPixel reads to reflect the boosted and
potentially clipped values (e.g. 66,205,255 for a 51,153,230 clear).

Use IDXGIOutput6::GetDesc1 to check if the monitor displaying the test window
is running in HDR mode (DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020), and skip
the on-screen colour check with an informative message if so, avoiding false
test failures.

Tested on AMD Radeon RX 9070 (driver 26.10.1, Windows 11).
AI-assisted.
2026-11-22 13:03:17 +01:00
f94fc77ac2 Merge main into test/ssharp-mip-fields (#319)
Conflicts were list/registration hunks in runtime/CMakeLists.txt, check.py, run_gpu_tests.py and tests/test_shader_checks.py; kept main's side and re-added vk_sampler_test, ps_ssharp and the TOTAL count.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:02:26 +01:00
248ad95f6e Merge remote-tracking branch 'origin/main' into presentx-immediate-threshold
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 13:00:50 +01:00
109a79da19 Merge fork/m2-textured-draw into m3-synthetic-gate
# Conflicts:
#	scripts/run_gpu_tests.py
2026-11-22 13:00:49 +01:00
c03b573a16 PresentX tear: review fixes
- find_tear_mode rejects a mode whose surface caps lack the swapchain's image usage or extent.
- present_timing: a repeated or stale token is never late.
- percent_scanned is measured at commit, so it agrees with the display time.
- The "no effect" log distinguishes the kill switch from a missing extension or mode.
- LEONIDA_PRESENT_NO_TEAR is read with _dupenv_s: any non-empty value but "0" disables.
- xbox_present_test: the real-time comment is back where it belongs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:00:38 +01:00
2782aa7a6a perf(translator): defer descriptor index load to hit block in desc_probe
In `desc_probe` (`%desc_lookup_fn`), the bindless index word at `base + 9`
was loaded from the `%desc_map` storage buffer before the conditional branch
`OpBranchConditional %match %dl_hit %dl_next`.

On every non-matching slot probed as well as on 8-probe misses, this issued
an unnecessary global storage buffer load that was immediately discarded.
Moving the index load into `%dl_hit` eliminates up to 8 storage buffer reads
per miss and 1 read per non-matching collision slot, reducing memory traffic
and register pressure.

Mirrored the same deferred load structure in `runtime/test/vk_descriptor_bench.cpp`.
Added `test_desc_probe_defers_index_load_to_hit_block` to `tests/test_desc_cache.py`.
2026-11-22 18:00:09 +06:00
41e3bc0fd0 M3 (synthetic): d3d12_m3_frame_test, MRT + D24S8 + occlusion + barriers + SRV pass, three frames in flight
Six frames through a ring of three slots, each with its own fence. Pass 1 draws
three rectangles (translator-output vs_m3/ps_m3) into an RGBA8 and an R32F
target with depth LESS/write and stencil REPLACE/EQUAL, the far one inside an
OCCLUSION query; barriers move the targets to shader/copy-read states; pass 2
samples the first target through an SRV descriptor table. Every pixel and the
exact sample count match a CPU reference. No layer change was needed. Render
passes (D3D-27) stay open. The generic shader harness skips the fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:59:57 +01:00
99f99890c5 Register #291's M1 tests with ctest; awc_names and bink_names replace unencodable stdout
- d3d12_compute_test and d3d12_draw_test (built when glslangValidator is found) had no add_test, which
  test_ctest_registration catches; registered like their neighbours (exit 77 is a skip).
- awc_names.py (#1421) and bink_names.py (#1403) are new tools without #1428's stdout errors='replace' guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:59:37 -05:00
6d642f40f9 GPU test cs_w32_salu64: 64-bit scalar data ops and v_mad_u64_u32
s_brev_b64, s_bfe_u64/i64, s_bitset1_b64, s_flbit_i32_b64/i64, s_cmov_b32
(with s_sext_i32_i16) and v_mad_u64_u32 were added with semantic tests
only. cs_w32_salu64.asm has lane 0 of a wave32 group store one word of
each; check.py and run_gpu_tests.py expect the eight words (derived in
the .asm header), so CI runs it on llvmpipe.

tests/semantic/test_salu64_fixture.py runs the fixture on the CPU,
checks the words against values computed from the ISA definitions, and
that both GPU runners expect the same words.
2026-11-22 08:58:01 -03:00
f1918a31df Merge main into test/coverage-gaps (#1299)
Conflicts were all list/registration hunks in check.py, run_gpu_tests.py, regen_fixtures.py and test_value_semantics.py; kept main's side and re-added only this PR's entries.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:57:00 +01:00
d55fa3d4d1 Translator: image_bvh triangle nodes read their type's vertex slots and the barycentric remap byte
image_bvh(64)_intersect_ray followed RADV's software path on triangle nodes,
which always reads vertex slots 0, 1, 2 and returns (v, w): RADV builds one
triangle per node. The hardware format packs up to four triangles per node,
and the node type picks the slots: TRI0 (0,1,2), TRI1 (1,3,2), TRI2 (2,3,4),
TRI3 (2,4,0). The type's byte of the triangle-ID word at +60 picks which two
vertex weights come back (bits [1:0] and [3:2]; 0x09 is RADV's v, w). A BVH
with paired leaves therefore traversed TRI1 against the wrong triangle.

Both rules come from AMD GPURT (CalcTriangleCompressionVertexIndices,
SwizzleBarycentrics, TRIANGLE_ID_I/J_SRC_SHIFT), and the public XDXR software
path (Read3Verts, TestXboxBvh4Leaf) agrees with it.

- tests/semantic/test_image_bvh_tri.py: every node type on a hand-built node,
  every remap selector pair, the byte per type, selector 3, a zero word
- spirv_mini_interp: OpVectorExtractDynamic and GLSL.std.450 FSign, from the
  specifications
- vk_compute_test "bvh": its hand-built triangle nodes now carry the 0x09
  triangle ID a builder writes; expected words unchanged
- docs/design.md Ray tracing row, docs/bvh.md 7a, translator docstring

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:56:07 +01:00
e49a735134 fix(pe_loader): validate SizeOfHeaders covers NT/section headers and guard truncated relocation blocks 2026-11-22 08:55:31 -03:00
6728a00c2a PresentX: implement ImmediateThresholdPercent with VK_KHR/EXT_swapchain_maintenance1
A frame presented after the vblank it was due at is flipped at once (IMMEDIATE, else
FIFO_RELAXED) when the scan would be within the threshold percentage of the screen,
instead of waiting a whole interval. The decision is the pure
leonida::decide_present_sync(late_us, interval_us, threshold); FramePacer reports the
lateness against the vblank after the token's origin and records the tear in
GetFrameStatisticsX (PercentScanned) and immediate_presents().

VulkanPresenter creates a vsync swapchain with FIFO plus the tear mode when the surface
lists it as compatible (VkSurfacePresentModeCompatibilityKHR) and chains
VkSwapchainPresentModeInfoKHR on a tearing present. The device enables the KHR (else EXT)
extension, its feature and the matching instance extensions only where present; without
them the threshold is ignored and logged once, as before. LEONIDA_PRESENT_NO_TEAR=1 turns
it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:54:49 +01:00