Commit Graph

10 Commits

Author SHA1 Message Date
fc99d468a8 Merge pull request #1417 from whoalin1/vk-image-fuzz-drawparams
vk_image_fuzz: enable shaderDrawParameters for the translated vertex shader
2026-11-29 16:41:49 +01:00
9f98dcc617 Improve post-load GPU memory and pipeline handling (RT-POST-LOAD-GPU-MEMORY)
Fall back to a dedicated buffer allocation when the shared arena fills.
Update console descriptors and resource backing, preserve pipeline cache
entries, and replay mesh records using bounded indirect arguments. Keep
scripted input available until read and cover the runtime and translator
paths with synthetic tests.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 14:30:51 -06:00
285801f0ac vk_image_fuzz: enable shaderDrawParameters for the translated vertex shader
Every translated VS declares the SPIR-V DrawParameters capability (BaseVertex /
BaseInstance for the zero-based v0 / v3), but the harness never enabled
VkPhysicalDeviceVulkan11Features::shaderDrawParameters. Under
LEONIDA_VK_VALIDATION=1, vkCreateShaderModule fails with
VUID-VkShaderModuleCreateInfo-pCode-08740 on every case, on both AMD and
NVIDIA, silently zeroing an image_fuzz campaign; drivers tolerate it without
validation.

Query Vulkan11 features on their own vkGetPhysicalDeviceFeatures2 call and
chain enable11 under the Vulkan12 features at device creation, as
vk_sampler_test and vk_bindless_test already do for their queries.

Verified: image_fuzz seed 1 (60 programs) and seed 2 (30 programs) match on
AMD Radeon Graphics and NVIDIA RTX 4070 SUPER with LEONIDA_VK_VALIDATION=1,
0 validation errors; before the fix the first case of each GPU failed with
the VUID. vk_bindless_test and vk_sampler_test run clean under validation on
both GPUs, so their chained Vulkan11-under-Vulkan12 queries needed no change.

Co-Authored-By: Devin <noreply@cognition.ai>
2026-11-25 22:07:34 +02:00
861df84bfd image_fuzz: support --pc-tail-ubo / LEONIDA_PC_TAIL_UBO=1 on 128-byte devices
Honour LEONIDA_PC_TAIL_UBO=1 in runtime/test/vk_image_fuzz.cpp by sizing the
push-constant range and vkCmdPushConstants to 128 bytes (s0..s31; the fuzz
shaders read neither heap base nor code base, so they declare no set-1 block).

Add --pc-tail-ubo (and LEONIDA_PC_TAIL_UBO=1 env detection) to
tools/image_fuzz.py so it forwards --pc-tail-ubo to rdna2spirv.py and sets
LEONIDA_PC_TAIL_UBO=1 for vk_image_fuzz, enabling 128-byte push-constant GPUs
to run the image fuzzer instead of skipping every case.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-22 19:32:05 +02:00
28ef599619 Runtime: pick the Vulkan GPU by the harnesses' rank (native over Dozen)
The runtime's standalone device (d3d12_vulkan_device.cpp) still took
"the first usable device, replaced by every later discrete GPU". #915
fixed that rule in the test harnesses because Mesa's Dozen (Microsoft
vendor 0x1414, "Microsoft Direct3D12 (<gpu>)") reports a discrete GPU, so
on a PC with the OpenCL/OpenGL/Vulkan Compatibility Pack the runtime
could run on the Vulkan-on-D3D12 wrapper while the tests used the native
driver. Even without Dozen, on a two-dGPU PC the runtime took the last
GPU and vk_test_device.h the first.

- runtime/src/vulkan_device_filter.h: vulkan_device_rank() (native over
  Microsoft's layers, then discrete > integrated > virtual > CPU), with
  the device type as an int so the header stays Vulkan-free.
- d3d12_vulkan_device.cpp: the first usable device of the highest rank.
- vk_device_pick.h: device_rank forwards to it (static_assert on the
  VkPhysicalDeviceType values).
- d3d12_indirect_rt_test, dxgi_swapchain_test, vk_image_fuzz,
  vk_sampler_test had the old loop and ignored LEONIDA_VK_DEVICE: they
  now filter and rank like the rest, and an unmatched filter fails
  instead of skipping.
- vulkan_device_filter_test: the rank order; docs/testing.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:27:09 +00:00
fd17f11a5c Translator: typed image_load fetches UINT/SINT formats from the sampled arrays (SHADER-151)
UINT/SINT image_load read the uint/sint storage arrays with OpImageRead, so
every typed load declared StorageImageReadWithoutFormat (missing on Intel
Xe-LP, #619), and read-only integer textures, which the runtime binds only in
the sampled arrays, read the fallback or past the 256-entry storage arrays.
They now fetch through uint/sint aliases of the dimension's sampled array;
a lookup miss takes the float path.

vk_store_test load fills the images before the dispatch, runs without
shaderStorageImageReadWithoutFormat and fails a module that declares it.
vk_image_fuzz no longer requires the without-format features, and binds
its UINT/SINT cases (#1087) as sampled images, as the runtime binds a
read-only texture, instead of storage-only images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:37:47 +00:00
71eea4a73e GPU tests: vk_bindless_test and vk_image_fuzz skip below 144 push constant bytes (TEST-149)
Both harnesses create a pipeline layout with the 144-byte translated
user-data block and never checked maxPushConstantsSize, so on a
128-byte device (Intel Arc, some AMD drivers) they failed validation
instead of skipping, although every pixel was exact. Each now prints
"unsupported: need 144 push constant bytes, device has N" and exits
77 before creating anything, as vk_texture_test does since 0c84bff;
the range uses the same constant.

run_gpu_tests.py already reported ps_tex's 77 as SKIP; image_fuzz.py
skipped it with a fixed message and now quotes the harness's
unsupported line. CPU tests cover both runners' 77 path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:52:32 -06:00
dd380ef2fb Tests: fuzz integer image loads 2026-11-22 03:46:54 -03:00
dbc428d83c vk_image_fuzz: name the missing device feature, one per line
The skip message said 'lacks ... or the without-format reads/writes', which cost kapitche a vulkaninfo round trip on an Intel UHD 770. It now prints the exact features that are missing, plus the reason when the without-format ones are involved: the translated image_load declares those capabilities for every shader, because its uint/sint path is chosen from the T# FORMAT at run time.
2026-11-22 01:56:25 -03:00
e6c767bdd3 Tools: image_load differential fuzzer with a GPU harness
AI-assisted. docs/shader_validation.md said "Not covered yet: images", and
FUZZ-1..13 touch VALU, memory, LDS, crosslane and control flow but not a single
image instruction. This is the first slice of that gap:

- runtime/test/vk_image_fuzz.cpp: headless harness that binds one 2D sampled
  image from a key=value spec (format, size, texels, T# key) through the
  bindless set and the descriptor table, draws a 64x64 full-screen triangle with
  a caller-supplied VS/PS, and dumps RGBA32F. It enables the without-format
  storage-image reads/writes and fragment atomics the translated image path
  declares, and fails on validation errors with LEONIDA_VK_VALIDATION=1.
- tools/image_fuzz.py: assembles a pixel shader that reads one texel with
  image_load (dmask 0xf, T# in s[8:15]), translates it with rdna2spirv.py, runs
  the harness, and compares every pixel with an independent CPU oracle for the
  T# format. A fetch is a memory read, so the oracle is exact.
- tests/test_image_fuzz.py: the oracle, the texel mapping, the T# word and the
  generated shader, without a GPU.

Covered: R8G8B8A8_UNORM, R16G16B16A16_SFLOAT, R32G32B32A32_SFLOAT and
R32_SFLOAT, at 8/16/32/64 square sizes that divide the draw; a fifth of the
values are NaN, +-inf, +-0 or denormals.
Not covered yet: dmask variants, UINT/SINT formats (they read through the
storage views), mips, 1D/2D-array/3D/cube, image_sample/gather with filters and
borders, and texel offsets with VK_KHR_maintenance8.

Verified on an NVIDIA RTX 2060 SUPER (Linux, 620.73.04, Vulkan 1.4.357):
40/40 programs match under LEONIDA_VK_VALIDATION=1; ctest 11/11; the GPU suite
is unchanged with a clean build. Synthetic fixtures only, no game data.
2026-11-22 01:56:25 -03:00