Commit Graph

45 Commits

Author SHA1 Message Date
e914437279 Merge pull request #3347 from whattheflop 2026-11-22 17:01:33 -05:00
5bed65414b Merge pull request #2965 from Vonsek 2026-11-22 17:00:15 -05:00
01763ffeeb Merge main into image-sample-c (#2965)
tools/rdna2spirv.py

AI-assisted.
2026-11-22 21:53:14 +01:00
04c956b18f Merge pull request #2894 from whattheflop 2026-11-22 15:12:56 -05:00
bf05936467 tests: preserve DrawParameters when enabling Vulkan maintenance8 2026-11-23 06:11:17 +10:00
e620b92644 vk_texture_test: device selection spelled as in #2225
The same pick_device block as #2225, so whichever merges first leaves the other
a trivial merge there.

AI-assisted.
2026-11-22 19:59:18 +01:00
23b458b5f8 rdna2spirv: image_sample_c and image_sample_c_b, depth compares with implicit LOD (EGEN-MIMG-SAMPLE-C)
image_sample_c / image_sample_c_b (and their _o forms) were Unsupported. In a
pixel shader they are OpImageSampleDrefImplicitLod (Bias for _c_b); LOD 0 for
_c elsewhere. The _c_b address order is bias then z-compare (the parser read
the compare first). vk_texture_test now honours LEONIDA_VK_DEVICE. GPU tests
ps_sample_c and ps_sample_c_b, semantic tests, design.md row.

AI-assisted.
2026-11-22 19:57:23 +01:00
e67b252dc0 TEST: synchronize texture readback with host reads 2026-11-23 04:37:32 +10:00
d30267d4ed Merge pull request #2313 from Vonsek
# Conflicts:
#	docs/design.md
2026-11-22 13:13:48 -05:00
407a53923e Merge pull request #2048 from whoalin1
# Conflicts:
#	docs/testing.md
2026-11-22 13:12:54 -05:00
0ec464b0e1 GPU tests: bind the --pc-tail-ubo block, so 128-byte push-constant devices run the tests
With LEONIDA_PC_TAIL_UBO=1, build.py and run_gpu_tests.py translate with --pc-tail-ubo, and the test
programs (vk_compute_test, vk_store_test, vk_harness, vk_texture_test, vk_sampler_test, vk_bindless_test)
declare and push 128 bytes and, when a stage declares set 1, bind the tail block there
(runtime/test/vk_pc_tail.h: a host-visible buffer with one slot per dispatch or draw, bound as a dynamic
uniform buffer). vk_harness refuses --mesh-compute with the flag (exit 77): mesh_compute_vs.py's vertex
shader still reads its address from push constants. Without the variable nothing changes.

Step 2 of the uniform-buffer tail claimed in #1902.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:48:05 +02:00
9b9c634b31 rdna2spirv: image_get_resinfo returns what RDNA2 returns (2D depth 0, minified layers, 0 past the last level)
Measured on gfx1036 in #2204 (tools/image_query_probe.py): a 2D image's
depth word is 0, a 2D array's layer count is minified to
max(1, layers >> (BASE_LEVEL + level)), and past the last level width,
height and depth are 0. The translator wrote 1, the full layer count, and
queried OpImageQuerySizeLod past the view's levels (undefined).

Gen.resinfo_words now emits the hardware rule: the level is compared
unsigned with the level count, the size query uses level 0 when it is out of
range, and BASE_LEVEL comes from T# word 3 [15:12]. vk_texture_test's
stand-in T# gets BASE_LEVEL 0 to match its level-0 views. cs_resinfo expects
depth 0 and gains level 5 of five.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:39:10 +01:00
1f32be4f4b Merge remote-tracking branch 'origin/main' into shader-33-vs-inputs
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-22 15:04:48 +01:00
1955e1b958 Merge remote-tracking branch 'origin/main' into r436
# Conflicts:
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
#	tools/rdna2spirv.py
2026-11-22 14:16:49 +01:00
1676a01a80 Merge pull request #1641 from Vonsek 2026-11-22 08:08:22 -05:00
36d8e84967 Merge pull request #1610 from bobcatchris 2026-11-22 08:08:09 -05:00
0a1b235854 Merge remote-tracking branch 'upstream/main' into codex/implicit-typed-mips
# Conflicts:
#	scripts/run_gpu_tests.py
2026-11-22 14:05:00 +01:00
e5f9661dac fix(translator): preserve implicit mip selection for typed 2D samples
Sampling an integer image through a float view makes D16 convert the wrong numeric values. Compute the quad derivatives before branching to the matching view so implicit minification still chooses the correct level.
2026-11-22 13:47:51 +01:00
ac1529efee vk_texture_test: skip when the Vulkan environment is unavailable
The texture test only returned 77 when --two-mip was set; a normal run returned 1 for a missing physical device or graphics queue, and a missing loader or ICD also failed instead of skipping. Treat those unavailable-environment cases as the existing ctest skip (77) in every mode, while real shader or result failures still return 1.

Verified on Windows 11 with an RX 7900 XTX: the normal texture test passes after building the generated SPIR-V, and a forced no-ICD run returns 77. No game files.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 06:37:03 -06:00
678c5c0b1e fix(test): synchronize texture framebuffer readback
Make the render pass expose its attachment writes and final layout transition to the copy that reads the frame. Matching pixels alone leave this hazard invisible on two drivers.
2026-11-22 13:30:08 +01:00
286f5e1bbe Merge pull request #1364 from AlxcBTW 2026-11-22 06:08:02 -05:00
07bd05fa95 Translator: zero-based VS v0/v3 (VertexIndex - BaseVertex, InstanceIndex - BaseInstance); VS is legacy, not NGG (SHADER-33)
Corpus (scripts/vs_input_survey.py, all 2,236 VS): no exp prim, no s_sendmsg, no v_mbcnt, every
VS exports pos0/param, so the console runs them as legacy hardware VS. Their input VGPRs are
Mesa's GFX10 legacy layout (radv_shader_args.c, declare_vs_input_vgprs, not is_ngg): v0 vertex
id, v1 unused, v2 primitive id, v3 instance id; no VS reads v1/v2 on entry, 788 start with the
fetch call and read attributes from v4.

Those ids are zero-based on the hardware (ac_nir_lower_intrinsics_to_args.c: vertex_id is
load_vertex_id_zero_base, instance_id is load_instance_id; the bases come in SGPRs), while
Vulkan's VertexIndex/InstanceIndex include firstVertex|vertexOffset/firstInstance. The
translator now seeds v0 = VertexIndex - BaseVertex and v3 = InstanceIndex - BaseInstance
(DrawParameters; feature shaderDrawParameters in every VS's metadata).

GPU test vs_base_ids.asm, drawn with VKH_DRAW=16,7 (new vk_harness option): 0x101 on every
pixel, where before it was 0x7111. Run by check.py and run_gpu_tests.py. vk_harness,
vk_pipeline_check, vk_bindless_test, vk_texture_test and the runtime's Vulkan device enable
shaderDrawParameters. design.md's "Inputs and outputs" row replaces the "unverified" note.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:59:04 +01:00
db7538e8f0 test(vulkan): encode the sampled view format in the synthetic T#
The arbitrary texture key named an unsigned format for an RGBA8_UNORM view, sending explicit gathers down the wrong branch. Derive the T# format from the same Vulkan format used to create the view.
2026-11-22 11:40:48 +01:00
e256a2547c Translator: --fma khr emits OpFmaKHR for fused multiply-adds
GLSL.std.450 Fma may be split into two roundings by a driver (Vulkan
environment: inherited from OpFMul followed by OpFAdd); RDNA2 v_fma_* round
once. --fma khr (default stays glsl) emits OpFmaKHR with capability FMAKHR and
SPV_KHR_fma and lists shaderFmaFloat32 in the index. Runtime device creation
and the vk_* test programs enable VK_KHR_shader_fma when present; cs_fma_fused
tests single rounding; the mini interpreter learns OpFmaKHR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:25:37 +01:00
07402f3828 Merge pull request #973 from Vonsek 2026-11-22 00:33:21 -05:00
5826a60187 fix: apply sampler LOD bounds to emulated gathers
Explicit-LOD gathers use four texel fetches that bypass the Vulkan sampler. Decode its 4.8 LOD bounds before selecting the mip so clamped gathers agree with a sampler-backed draw.
2026-11-22 06:25:26 +01:00
9806be2999 Tests: prefer the native Vulkan ICD over Mesa's Dozen on Windows
With the Compatibility Pack installed, Windows enumerates Mesa's D3D12
translation layer next to the real GPU, and Dozen reports DISCRETE_GPU. Every
harness used "the last discrete device wins", so it selected the wrapper and
the resulting failures looked like translator bugs (#915). One shared rank now
treats Microsoft's vendor as a translation layer, then prefers discrete over
integrated over virtual over CPU, keeping the first device on a tie. A CPU-only
test covers the reported enumeration without needing the Compatibility Pack.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 22:58:59 -06:00
524bb1fb7b Merge pull request #862 from sanuk369 2026-11-21 23:15:35 -05:00
0c84bff89a GPU tests: a device with too few push constant bytes skips the texture tests
vk_texture_test returned 1 instead of the unsupported code 77 when
maxPushConstantsSize is below the 144 bytes it needs (only --two-mip got 77),
and run_gpu_tests.py treated any non-zero exit of the bindless texture tests and
ps_gather_wrap as a failure. On a 128-byte device that reported 8 FAILs instead
of SKIPs. Both now skip with the device's own reason; check.py already mapped 77
to a skip.
2026-11-22 09:25:03 +05:30
11df1519bf Tests: propagate Vulkan texture readback write failures 2026-11-22 00:41:02 -03:00
b707035ca0 Tests: vk_texture_test enables shaderResourceMinLod for a MinLod clamp
A shader that declares MinLod (image_sample_d_cl) needs the feature, and without it the validation layer reports VUID-VkShaderModuleCreateInfo-pCode-08740. A device without it is now a skip (exit 77), as in the other texture tests.
2026-11-21 22:11:02 -04:00
bd880b85cc Tests: a16 bias, d_cl and depth compare samples on a GPU 2026-11-21 22:10:52 -04:00
8de6eb2875 Tests: vk_texture_test dref checks depth compare samples on a GPU 2026-11-21 22:10:21 -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
add0b5cfce GPU test for texel offsets (image_sample*_o, image_gather4_lz_o)
SHADER-14. runtime/test/shaders/ps_texoff.asm samples vk_texture_test's 8x8
texture (every texel different, point sampler, clamp to edge) through the
translated shader and exports the texel coordinates it read as integers:

- image_sample_lz_o with an offset computed per pixel: all 64 pairs of x, y
  in -4..3 from the centre of texel (4, 4), each a different texel, none
  clamped;
- image_sample_l_o with (-3, +2) and image_sample_lz_o with (+16, -32), the
  offset dword loaded from an immediate. The second one tells 4-bit, 5-bit
  and 6-bit fields apart; it is outside Vulkan's guaranteed -8..7 and is
  judged only where the device's texel offset limits cover it;
- image_gather4_lz_o of red and of green with the per-pixel offset, at a
  texel corner (shaderImageGatherExtended, not maintenance8).

Expected words are derived by hand from the docs/design.md rule (signed
6-bit fields, x [5:0], y [13:8]) and the texture contents, before any run;
the derivation is in the .asm header and check.py's texoff_words().

Harness: vk_texture_test enables VK_KHR_maintenance8 and
shaderImageGatherExtended when the device has them, prints the texel offset
limits, and with VKT_NEED_MAINTENANCE8=1 exits 77 without the extension
(SKIP in check.py and scripts/run_gpu_tests.py).

vk_harness.cpp is unchanged: its maintenance8 guard (#if defined() on the
structure-type enumerator, never true) was already fixed upstream, which now
uses #ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME.

tests/conftest.py: the sample validator retries with
--allow-offset-texture-operand (what rdna2spirv.py validates with) when
spirv-val rejects a non-gather Offset, and skips on a spirv-val that does not
know the flag.

Tested on an AMD Radeon RX 6800, Windows, driver 26.11.2 (texel offset limits
-64..63, gather -32..31, maintenance8 enabled):
  run_gpu_tests.py: 49/50 passed, 1 skipped (was 48/49, 1 skipped)
    PASS  ps_texoff  4096/4096 pixels exact (offsets +16/-32 judged)
  check.py: 45 of 45 pass, 0 skipped (was 44 of 44)
No translator bug found: tools/rdna2spirv.py is unchanged.

Negative controls (translator sabotaged, test run, reverted). FAIL: sample
offset dropped, x/y swapped, y field at bit 6, 4-bit fields, 5-bit fields;
gather offset dropped, x/y swapped, y field at bit 6; three corrupted
expectations. PASS, so not detected on this GPU:
- fields read unsigned (sample and gather): Offset 60..63 sampled as -4..-1
  and +32 as -32, so the sign extension cannot be seen through Vulkan here;
- 4-bit and 5-bit gather fields: the gather offsets stay in -4..3.
Both are pinned by the new structural test tests/test_texel_offsets.py
instead (signed, bit 8k, 6 bits; it fails with OpBitFieldUExtract).

The test shows that the translated SPIR-V implements the documented rule on
Vulkan; it does not measure the field layout on the hardware. Still not
GPU-tested: sign extension, gather field width, image_sample_o, _b_o,
_c_lz_o, image_gather4_l_o, the z field (3D), 1D/2D-array/cube targets, wrap
or mirror addressing, linear filtering, mips other than 0, other vendors'
drivers, devices without maintenance8.

unittest tests/semantic: 388 OK before and after.
pytest tests (LLVM_MC set): 1467 passed, 6 skipped, 1 xfailed before;
1478 passed, 6 skipped, 1 xfailed after.

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 16:55:18 -07:00
7fefe7f425 Merge upstream cube sampling with the two-mip Vulkan fixture
Keep the cube array at its original extent and allocate a separate upload range for the two-dimensional mip chain. Both shader registrations now run through the updated upstream runner.
2026-11-21 23:51:27 +01:00
aa0d8a8ba7 fix: report unsupported two-mip Vulkan devices
Return the established skip code for unavailable graphics capabilities so unsupported hardware yields a distinct test result. Preserve failures for Vulkan allocation and enumeration errors.
2026-11-21 23:38:08 +01:00
d798c76853 test: distinguish explicit mip zero from implicit minification on Vulkan
A single-level view produces the same image for both sampling operations. Exercise both against the same minified view so the readback detects a wrong LOD or swapped texture coordinates.
2026-11-21 23:31:25 +01:00
b9552cd924 Translator: convert cube sample coordinates for the 2D-array view
The hardware takes a cube sample's s and t in [1, 2] and its third
coordinate as 8 * slice + face (Mesa ac_nir_lower_tex_coords.c, LLPC
ImageBuilder.cpp). Samples and gathers passed them unchanged to the
6-layer 2D-array view; they now use s - 1, t - 1 and layer
6 * slice + face.

ps_cube_sample checks every pixel on a GPU (vk_texture_test cube), and
test_cube_sample checks the coordinates without one.
2026-11-22 04:15:43 +05:45
9eb04373fa Runtime: add DescriptorTable::erase() and autonomous vk_texture_test with synthetic shader 2026-11-21 22:26:49 +01:00
82a1e229c9 Runtime: implement FNV-1a descriptor hash table for shader contract (set 0, binding 2) 2026-11-21 21:37:24 +01:00
4b251d1cb6 Merge pull request #15 from Mulkku
# Conflicts:
#	runtime/test/vk_store_test.cpp
#	runtime/test/vk_texture_test.cpp
#	runtime/test/vulkan_loader.h
#	tools/rdna2spirv.py
2026-11-21 11:47:52 -05:00
987e8471ee Fix RDNA2 wave masks and flat inputs
Preserve whole-wave mask operations, saved EXEC values and flat
pixel inputs when generating SPIR-V. Keep a dispatch-loop fallback
alongside structured control flow and share the descriptor probe.

Add reproducible GPU fixtures for these cases and exercise the
control-flow and mask analyses in CI.
2026-11-21 16:56:54 +02:00
4146672f58 Vulkan tools: fix builds on Linux 2026-11-21 02:35:54 -03:00
db0dc8bd5e Initial commit: Leonida, build-it-yourself PC port groundwork
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:22:16 -05:00