Commit Graph

4163 Commits

Author SHA1 Message Date
f2cf303237 SHADER-177: model computed I/J barycentrics (v0/v1 overwritten before v_interp) 2026-11-22 04:22:04 -08:00
cb33e81b04 Runtime: invalid-argument HRESULTs as the host runtime (D3D-49)
CreateCommittedResource, CreateDescriptorHeap, CreateCommandQueue, CreateFence
and Map now return the host PC runtime's HRESULTs for invalid arguments.
compare_invalid_arguments in d3d12_vulkan_device_test checks the invalid
descriptions and their valid neighbours, plus ALLOW_RENDER_TARGET and
ALLOW_DEPTH_STENCIL on every format both devices create, against the host
device.

On main the new test found 25 mismatches in its first 55 cases (invalid
heap properties and flags, buffer layouts, upload/readback states, clear
values and texture flags accepted; two access violations, on a zero-width
buffer and a zero-size texture array), then the process died creating a
2049-layer texture. main also refused zero-descriptor heaps and answered
E_POINTER where the host treats a null output as a capability check.

CreateDescriptorHeap answers a null output before its flag, type and node
rules, as the host does; committed resources and fences check their
arguments first. A GPU_UPLOAD heap is refused, matching the layer's
OPTIONS16.GPUUploadHeapSupported FALSE; the test compares that case only on
a host without GPU upload heaps (Resizable BAR off).

CreateCommittedResource accepts a sample quality on a single-sampled texture
and the two standard MSAA patterns, as the host does.

The flag and format rules were measured on an RX 9070 XT, an integrated Radeon
GPU and WARP. Answers that differ between them, or that the layer can't follow,
are not compared and are listed in docs/d3d12_vulkan.md. Each new refusal is
logged once with its reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:19:56 +01:00
86f7e9f887 Runtime: build XDXR BVH4 acceleration structures on the GPU
The game's translated ray-tracing shaders read the console's BVH records
themselves (docs/d3d12_vulkan.md 4.8), so the layer has to write them. This
adds the GPU builder, checked against tools/xdxr_bvh.py:

- src/xdxr_build.comp: one pipeline, one dispatch per step. Triangle leaves
  (any of R32G32B32/R32G32 vertices, none/R16/R32 indices, a stride, an
  optional 3x4 transform) or 128-byte INSTANCE records with world-to-object
  inverses; Morton keys and a bitonic sort; BOX32 nodes four consecutive
  children at a time, level by level, with the parent table; the header.
  Buffer device addresses as uvec2: needs bufferDeviceAddress, not
  shaderInt64. NaN triangles, mask-0 instances, instances without a BLAS and
  singular transforms get empty boxes.
- src/xdxr_build.h: XdxrLayout (exact result and scratch sizes from the
  element count, for the prebuild info too) and XdxrBuilder (records the
  dispatches). A bias maps the application's 40-bit BLAS addresses to device
  addresses.
- test/vk_xdxr_build_test.cpp: nine synthetic cases built on the GPU and
  dumped; ctest `xdxr_build` + `xdxr_build_check`, which runs
  `tools/xdxr_bvh.py check-build`: validate, then trace 1000 rays per case
  against brute force.
- vk_test_device.h: opt-in bufferDeviceAddress (request_buffer_device_address,
  device_address()).
- tools/xdxr_bvh.py: check-build; trace takes the bias; instances without a
  BLAS and inactive triangles are valid.

Not wired to BuildRaytracingAccelerationStructure yet: that path builds a
VkAccelerationStructureKHR today (#743), and which one the layer uses is a
maintainer decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:19:18 +01:00
1a156425c7 Merge fork/m2-textured-draw into m3-synthetic-gate
# Conflicts:
#	scripts/run_gpu_tests.py
2026-11-22 13:18:51 +01:00
bf7014999a fix(runtime): enable VkSamplerReductionModeCreateInfo for MIN/MAX samplers
sampler_descriptor() already encodes D3D12_FILTER_REDUCTION_TYPE_MINIMUM and MAXIMUM into the S# filter_mode and gfx10_descriptors.h already provides vulkan_reduction_mode(), but bind_sampler() ignored it and logged that minimum/maximum samplers blend for now.

Enable Vulkan 1.2 samplerFilterMinmax in device creation and vk_test_device.h, chain VkSamplerReductionModeCreateInfo in bind_sampler() when supported and not combined with compareEnable (falling back to blend with a log otherwise), update docs/d3d12_vulkan.md, and add a synthetic 2x2 GPU sampling test in d3d12_descriptor_test comparing MINIMUM, MAXIMUM, and STANDARD (negative control) linear filters.
2026-11-22 13:18:40 +01:00
ec6645401d [TEST-200] Make M1 CTest skips accurate 2026-11-22 13:13:38 +01:00
84a0b02161 Test Vulkan swapchain retry after a surface query failure 2026-11-22 15:43:12 +03:30
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