Commit Graph

93 Commits

Author SHA1 Message Date
a09d690ca9 Merge pull request #3252 from Douglas Sposito 2026-11-22 15:16:12 -05:00
09039457de Merge pull request #2948 from kapitche 2026-11-22 15:13:29 -05:00
dd86750fde Runtime: views across B8G8R8X8 and B8G8R8A8 through a castable-format list (BUILD-768)
A castable-format list may name the other family of a B8G8R8X8 or
B8G8R8A8 texture (relaxed casting). WARP and AMD's D3D12 driver accept
such lists both ways, typed and TYPELESS, and an SRV in a listed format
reads by its own format: alpha 1 for B8G8R8X8, the stored byte for
B8G8R8A8, and red and blue swapped when the list crosses channel orders
(an R8G8B8A8 texture read as B8G8R8A8 or B8G8R8X8). The layer kept the
list only as Vulkan formats, where both families are BGRA8, so it refused
a view across them, and its T# took the channel order from the image's
format, so a B8G8R8A8 view of an R8G8B8A8 texture read unswapped.

The resource now also keeps the list as the application gave it,
image_descriptor lets a view cross the families when the list names its
format, the alpha swizzle follows the view's format, and a colour view in
the other channel order takes its swizzle from that order (both orders
share one T# format code).

d3d12_descriptor_test adds a B8G8R8A8_UNORM texture listing
B8G8R8X8_UNORM, a B8G8R8X8_UNORM one listing B8G8R8A8_UNORM, and two
R8G8B8A8_UNORM ones listing B8G8R8X8_UNORM and B8G8R8A8_UNORM, each viewed
through the listed format: T# formats and swizzles, an unlisted format
refused, and the same bytes sampled through the bindless set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:53:06 -03:00
4896856544 tests: d3d12_descriptor accepts a floored fractional image-view minimum LOD, which Vulkan permits 2026-11-22 13:51:04 -05:00
c9fe0bd788 Merge pull request #2500 from Codex 2026-11-22 13:15:45 -05:00
0cb7657dff Find packaged shader fixtures in relocated GPU test artifacts 2026-11-22 18:15:36 +01:00
3fd09d4ecd Merge pull request #2232 from Jolymmiles 2026-11-22 11:43:11 -05:00
95ac207b7b Merge pull request #2099 from Luis Baker 2026-11-22 11:41:47 -05:00
4f574add4b d3d12_descriptor_test: the bindless capacity check follows the set's room
On MoltenVK (1.4.2, 1.4.3) the check sampled zeros: vkGetDescriptorSetLayoutSupport there accepts only layouts
of fewer than maxPerSetDescriptors (1212) descriptors, so size_bindings keeps the default 4096 2D images and
1024 samplers, and the test's 5001st view and 2100th sampler were refused as the arrays filled. MoltenVK does
create and sample a 65536-image, 4096-sampler set correctly (a native reproduction, and the whole test passes
under Wine with growth forced), so that is MoltenVK's to fix; the runtime keeps following the driver's answer.

The test now asks the set how much room it has (rt::d3d12::bindless_room, from BindlessSet::free_images and
free_samplers). Where the set holds the full counts nothing changes. Where it holds fewer, the test fills each
short array to its last index, checks the last view through the last sampler gives the texture, and that one
more view and sampler are refused and read as the fallbacks. The device logs at startup when its set holds
fewer samplers than a full shader-visible sampler heap. bindless_sizing_test gets MoltenVK's limits;
vk_bindless_test checks the free counts.
2026-11-22 20:01:37 +04:00
90927ab35b Runtime: reject non-depth colour SRV formats on depth textures
Creating an SRV of a depth texture (D16_UNORM/R16_TYPELESS or D32_FLOAT/R32_TYPELESS) with a colour format (e.g. R16_FLOAT, R16_SNORM, R16_UINT, R16_SINT, R32_UINT, R32_SINT) previously produced a colour-format VkImageView with VK_IMAGE_ASPECT_DEPTH_BIT, violating VUID-VkImageViewCreateInfo-image-01762. Tighten vulkan_view_format(), image_descriptor() and bind_image() so depth/stencil textures only accept their own family's depth/stencil SRV formats and colour textures reject depth/stencil view formats. Adds exhaustive unit tests and GPU + Vulkan validation tests.
2026-11-22 16:56:36 +01:00
8dc359b892 Merge pull request #1914 from zneel 2026-11-22 10:39:25 -05:00
1e48c3f463 Merge pull request #760 from 0xTehuti 2026-11-22 10:38:41 -05:00
ea32ba2f8e d3d12: review fixes for the new formats
- UAV clears of A4B4G4R4: an R4G4B4A4_PACK16 layout row (red in bits
  12-15, alpha in 0-3), unit-checked in conversion_checks and cleared end
  to end where the layer reports a typed UAV (the driver's call: WARP has
  one, AMD's D3D12 driver doesn't).
- FORMAT_SUPPORT reports IA_VERTEX_BUFFER only for formats input layouts
  accept (vertex_format), not every format Vulkan can fetch: R8/R16
  SNORM/SINT (and R8G8 SNORM/SINT) have no input-layout mapping yet.
- new_format_round_trips: each render-target format is cleared to
  (-3, -0.4, 0.25, 7) on the layer and on the host and the bytes compared,
  which catches a mapping of the right size but the wrong numeric type
  (R16_SNORM as UNORM, R8_SINT as UINT); no value is an exact half step.
  The host is the Vulkan device's own adapter, as in
  compare_format_support, not the default one.
- A4B4G4R4 is skipped where the Vulkan driver can't sample
  R4G4B4A4_UNORM_PACK16 (Vulkan doesn't require it), by the driver's
  format properties rather than the layer's answers; B4G4R4A4 and
  B5G5R5A1 are never skipped.
- d3d12_copy_xfmt: D16_UNORM <-> R16_UINT and R16_SNORM copies, the new
  members of depth_colour_pair, against the host and WARP.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:23:58 +01:00
3e3d94f65c d3d12: custom sampler border colours on VK_EXT_custom_border_color (D3D-73)
- Implements custom float and UINT sampler border colours on VK_EXT_custom_border_color in runtime/shims/d3d12_vulkan_device.cpp.
- Maintains a device-wide border colour table of up to 4000 entries.
- Assigns table indices into S# BORDER_COLOR_PTR [11:0] (with BORDER_COLOR_TYPE = table), ensuring distinct custom colours produce distinct keys in the bindless descriptor hash table while identical colours reuse existing indices.
- Chains VkSamplerCustomBorderColorCreateInfoEXT with VK_BORDER_COLOR_FLOAT_CUSTOM_EXT / VK_BORDER_COLOR_INT_CUSTOM_EXT and format = VK_FORMAT_UNDEFINED when customBorderColorWithoutFormat is enabled. Falls back to transparent black with a diagnostic warning when the extension is absent.
- Enables VK_EXT_custom_border_color in standalone device creation and vk_test_device.h.
- Updates d3d12_sampler2_test to verify table index assignment, index reuse, S# distinction between float and UINT representations, and Vulkan sampler creation.
- Documents the architecture in docs/d3d12_vulkan.md.

Tested on Windows 11, MSVC 2022 x64 (Ninja, RelWithDebInfo), NVIDIA GeForce RTX 2070 SUPER, Driver 595.79.
Clean-room verification suite (python compileall, make_game.py CLI, 27/27 CTest, d3d12_vulkan_device_test, d3d12_sampler2_test, d3d12_descriptor_test) passed with exit code 0.

Item: D3D-73 (#634)
Co-Authored-By: Antigravity <antigravity@google.com>
2026-11-22 16:14:56 +01:00
667dbc76c9 Merge pull request #1851 from Alex Arenas 2026-11-22 09:48:45 -05:00
57f57a825f runtime: allow explicit Texture1D SRVs on 1D texture arrays to select slice 0 2026-11-22 15:33:25 +01:00
629bcb2d99 d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates
vulkan_format() had no entry for R16_UINT, R16_SINT, R16_SNORM, R8_UINT,
R8_SINT, R8_SNORM, R8_TYPELESS, R16G16_UNORM, R16G16_SNORM,
R16G16B16A16_SNORM or A4B4G4R4_UNORM, so CreateCommittedResource refused
them with E_INVALIDARG and FORMAT_SUPPORT answered DXGI_ERROR_UNSUPPORTED
where native D3D12 creates them (item 1 of the FORMAT_SUPPORT finding in
#1380).

A4B4G4R4_UNORM keeps alpha in bits 0-3 and red in 12-15 (cleared and
read back on native D3D12, RX 9070 XT and WARP), which is Vulkan's
R4G4B4A4_UNORM_PACK16; its T# row reads that as W, Z, Y, X.

Copies get the formats' texel sizes, D16 copies pair with R16 SNORM/UINT/
SINT like the other R16_TYPELESS members, and the colour-resolve check
refuses every integer format by numeric class instead of a list that
missed R8/R16 and the SINT forms of R8G8B8A8, R32 and R32G32B32A32.

Tests: d3d12_vulkan_device creates each format (as the host does), copies
a 4x4 upload in and back out bit for bit, and clears an A4B4G4R4 render
target to R, G, B and A; d3d12_descriptor_test samples A4B4G4R4 through
a T# alongside B4G4R4A4 and B5G5R5A1.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:26:19 +01:00
24abd3dde4 Merge pull request #1749 from Alex Arenas 2026-11-22 09:15:03 -05:00
41ceb016c2 runtime: remove duplicate bind_image call in write_image_descriptor 2026-11-22 14:50:41 +01:00
aee81b80ef Merge pull request #759 from Douglas Sposito 2026-11-22 08:37:59 -05:00
b8f9d6f906 Merge pull request #1569 from Vonsek 2026-11-22 08:08:07 -05:00
c26caf2f08 Merge pull request #1554 from Vonsek 2026-11-22 08:08:04 -05:00
b576c75ad2 Runtime: B8G8R8X8 textures as BGRA8 images, views read alpha 1 (D3D-87)
Map B8G8R8X8_UNORM, _UNORM_SRGB and _TYPELESS to the B8G8R8A8 Vulkan formats, so
creation, copies, footprints and clears work as for BGRA8. Shader views of the family
read alpha as 1 (the T# selects one for the alpha channel), and views between the
B8G8R8X8 and B8G8R8A8 typeless families are refused, although both land on the same
VkFormat.

Compared with the host D3D12 runtime on an RX 9060 XT: it reports no typed UAV for the
family and refuses typed B8G8R8X8 textures that allow unordered access (the typeless
format is accepted). The BGRA8 image would have advertised storage, so
CheckFeatureSupport now leaves the typed UAV bits out, texture creation refuses typed
B8G8R8X8 with ALLOW_UNORDERED_ACCESS, CreateUnorderedAccessView gives a null descriptor
for the family, and its images get no storage usage. WARP writes the clear's alpha into
the X byte, as Vulkan does, so clears need no change.

Tests: d3d12_clear_test clears B8G8R8A8_UNORM and B8G8R8X8_UNORM against WARP;
d3d12_vulkan_device_test compares B8G8R8X8 footprints, the typed UAV bits and UAV/RTV
resource creation with the host runtime; d3d12_descriptor_test samples a B8G8R8X8 and a
B8G8R8A8 texture with the same bytes through the bindless set (alpha 1 against the
stored byte) and checks the refused views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:03:51 -03:00
d88129e39a docs,test(runtime): check per-format SAMPLED_IMAGE_FILTER_MINMAX_BIT in descriptor test 2026-11-22 13:42:46 +01:00
65ef3d2d89 Merge remote-tracking branch 'upstream/main' into ag/d3d12-sampler-minmax 2026-11-22 13:40:53 +01:00
08986b18c8 Merge remote-tracking branch 'upstream/main' into ag/d3d12-volume-min-lod
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/d3d12_descriptor_test.cpp
2026-11-22 13:39:39 +01:00
0dd6bb051c Merge pull request #1569 from Vonsek 2026-11-22 07:38:16 -05: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
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
017d260438 fix(runtime): bind single-layer Texture1D shader-resource views
The device can allocate 1D textures and set 0 has a sampled 1D binding, but default and explicit views previously sampled the fallback. Use the texture dimension and the requested mip range when registering the view.
2026-11-22 12:38:59 +01:00
90c8688124 Merge pull request #1323 from Flyander 2026-11-22 05:37:41 -05:00
983862e2a8 Runtime: 96-bit R32G32B32 textures on the Vulkan layer (D3D-62)
R32G32B32_FLOAT/UINT/SINT/TYPELESS textures were refused ("texture format not
supported yet"). They are now R32G32B32A32 images on every GPU: most have no
optimal-tiling RGB32 image, and one that has would not avoid the repack, since
D3D12 places subresources at multiples of 512 bytes and Vulkan wants a copy's
buffer offset to be a multiple of the texel size
(VUID-vkCmdCopyBufferToImage-dstImage-07975).

- Footprints keep D3D12's 12-byte texels (compared with WARP).
- CopyTextureRegion between a texture and a buffer is repacked by the D24
  compute pass (depth24_convert.comp modes 2 and 3, Depth24Job::rgb96): the
  same scratch, parts and lifetime, texels of three words in the footprint and
  four in the scratch, copied uninterpreted. depth24_convert.inc is
  regenerated with the documented glslc command; the same glslc reproduces the
  previous blob byte for byte from the previous source.
- WriteToSubresource/ReadFromSubresource take the staged copy, as D24-as-D32.
- A view's T# names GFX10_FORMAT_32_32_32_*, so alpha reads as one.
- Refused: unordered access and depth (as WARP), render targets (WARP has
  them; not done, and FORMAT_SUPPORT and GetResourceAllocationInfo agree),
  copies between a 96-bit and a four-channel texture, views of another
  format family.

Tested on an RX 9070 XT (AMD 26.11.2), Windows 11: d3d12_rgb96_test matches
WARP and the expected texels bit for bit for 4 formats as 2D arrays with mips
and as volumes; d3d12_descriptor_test samples FLOAT, UINT and TYPELESS views.
Clean under the validation layer with sync validation; depth24_convert_test
and ctest (62) pass.

AI-assisted (Claude Code).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:26:48 +01:00
3974555c19 [TEST-189] Fix descriptor test compilation with clang-cl 2026-11-22 11:09:12 +01:00
d8455a7ae8 Merge pull request #1235 from Vonsek 2026-11-22 04:07:48 -05:00
cdc9ab3735 fix(runtime): respect the device limit for sampler LOD bias
Literal GFX10 samplers can encode bias from -32 to +31. A decoded +31 exceeded the Vulkan sampler limit on both tested devices at registration. Bound the native bias while retaining the original S# for shader lookup.
2026-11-22 09:43:56 +01:00
8dbf3a686c Merge pull request #1211 from Vonsek 2026-11-22 03:37:51 -05:00
a57ae52048 fix(runtime): apply the resource mip clamp to sampled cube views
Cube descriptors carry a minimum resource LOD but were excluded when building the sampled Vulkan view. Include them alongside array views so a point sample from a restricted cube cannot select an earlier mip.
2026-11-22 09:21:30 +01:00
209f5e1f2a Merge pull request #1199 from quackottu 2026-11-22 03:14:28 -05:00
ea512f284c Runtime: size the bindless set's arrays from the device's descriptor limits
Set 0's 2D, sampler and storage arrays were constexpr (4096 2D images, 1024
samplers, 256 per storage array): one full D3D12 sampler heap (2048) did
not fit and bind_image/bind_sampler fell back. They are now sized once, when
the device creates the set, from the update-after-bind or plain limits:
today's sizes as the floor, then samplers up to min(4096,
maxSamplerAllocationCount - 64), 2D images up to 65536, storage up to 4096.
Sizing at creation keeps the set layout fixed for the pipelines built on it.
2026-11-22 13:41:58 +05:30
fd94dba66a d3d12: register shaders' literal S#s without a heap slot (rt::d3d12::register_samplers)
Shaders that build an S# from immediates look it up through the descriptor
hash probe like any other S#, but nothing registered those keys, so they
sampled through the fallback nearest-clamp sampler. register_samplers runs
CreateSampler's path (decode, VkSampler, key in set 0) for each S# without
a heap slot; the call at pipeline creation comes with #291's shader index.
2026-11-22 13:21:06 +05:30
326e8490bb test(runtime): distinguish integer and fractional array LOD clamps
An integer image-view minimum is permitted by Vulkan and was observed on Intel. Check an effective integer minimum separately and report both view groups before returning a mismatch.
2026-11-22 07:10:00 +01:00
a69977e76f fix(runtime): honor minimum LOD on sampled 2D array views
A Texture2DArray SRV encodes the clamp in its image descriptor. Forward it to Vulkan so sampling keeps the requested mip and array layer.
2026-11-22 06:47:50 +01:00
817a5e9f5e Tests: run the eight unregistered D3D12 GPU tests under ctest
d3d12_clear, d3d12_com, d3d12_descriptor, d3d12_method_variants,
d3d12_resource_desc, d3d12_sampler2, d3d12_typeless_rtv and d3d12_uav_clear were
built but never added with add_test, so ctest and CI never ran them. Each now
exits 77 when there is no Vulkan GPU (DeviceStatus::unavailable), as
d3d12_vulkan_device_test does, and is registered with SKIP_RETURN_CODE 77.

(cherry picked from commit 2af37e5da368dd130ba23db385e812635cb1a768)
2026-11-22 00:33:45 -05:00
6845ddab45 Merge pull request #909 from Dea7hsmiles 2026-11-22 00:33:08 -05:00
ac93feef4e Merge pull request #897 from Vonsek
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 00:33:04 -05:00
482aa3c33f test: isolate typeless volume descriptors from multisample views
The pending multisample fixture already owns the next slots on the common heap. Give the two typeless views their own CPU descriptors so both sampling regressions can run in the same command list.
2026-11-22 05:33:07 +01:00
fb31cc780e tests: rename the multisample levels in d3d12_descriptor_test
The multisample-quality check declared a local 'levels' that hid the footprint array 'levels[3]' still used later in the function, which MSVC /W4 reported as C4456. Rename the feature struct to quality_levels; no behavior change.
2026-11-21 20:30:57 -08:00
46f5ce2f1d fix: sample linear and sRGB views of typeless RGBA8 volumes
A committed RGBA8 typeless image already permits mutable Vulkan views. Let explicit UNORM and sRGB Texture3D SRVs select their formats so shaders can read either interpretation of the same voxels.
2026-11-22 05:23:59 +01:00
8c36677b41 chore: merge upstream query and descriptor updates 2026-11-22 04:45:39 +01:00
0b5a342f3e Merge pull request #779 from Vonsek 2026-11-21 22:37:42 -05:00