Commit Graph

1118 Commits

Author SHA1 Message Date
4fa0fb7dee Runtime: ID3D12Resource::GetDesc fills in a defaulted Alignment, as the host does
A resource created with Alignment 0 read back Alignment 0 from the Vulkan-backed
device. The PC runtime and WARP report the placement alignment instead: 64 KiB,
or 4 MiB for a multisampled texture, and keep one the description asked for.

d3d12_resource_desc_test compares every GetDesc field of 26 committed and
reserved descriptions with the default adapter and WARP.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 21:56:53 -05:00
deae7cc736 Merge remote-tracking branch 'origin/main' into claude/d3d-24-debug-markers-457bab
# Conflicts:
#	runtime/shims/d3d12_com.cpp
#	runtime/src/command_list.h
2026-11-22 02:56:52 +00:00
123ace7c11 Runtime: stencil-plane SRVs only on their own depth-stencil family
The stencil side of #767. image_descriptor accepted X24_TYPELESS_G8_UINT
and X32_TYPELESS_G8X24_UINT plane-1 views on either family, so an
R32G8X24_TYPELESS texture with an X24_TYPELESS_G8_UINT view (or the
other way round) got a live 8_UINT T# where D3D12 refuses the view.
Each stencil view format is now accepted on its own DXGI family only:
X24_TYPELESS_G8_UINT on R24G8_TYPELESS / D24_UNORM_S8_UINT,
X32_TYPELESS_G8X24_UINT on R32G8X24_TYPELESS / D32_FLOAT_S8X24_UINT. The
family is the DXGI format, not the Vulkan one behind it.

d3d12_descriptor_test checks that the other family's stencil view
format leaves the slot null on both textures; on main that check fails.
2026-11-22 02:56:29 +00:00
0c46a83525 Merge remote-tracking branch 'origin/main' into claude/d3d-30-fences-timing-7ce86f
# Conflicts:
#	runtime/shims/d3d12_com.cpp
2026-11-22 02:55:57 +00:00
74c71672c0 fix: reject shader views on textures that deny shader access
Depth-stencil attachments can opt out of sampling while remaining valid resources. Leave a reused descriptor null before any view is encoded or registered.
2026-11-22 03:54:16 +01:00
ff354a556b Report and exercise A8 texture mip support 2026-11-21 23:51:24 -03:00
9f755a30fa Runtime: depth-plane SRVs only on their own depth family (#678 follow-up)
#678 (D3D-84) took R24_UNORM_X8_TYPELESS and R32_FLOAT_X8X24_TYPELESS on any
texture with a depth aspect, so the other family's view (an X8X24 view of an
R24G8 texture, or the reverse) got a live descriptor of the texture's own
depth format. D3D12 refuses both. Each depth view format now belongs to its
own DXGI family only (R24G8_TYPELESS / D24_UNORM_S8_UINT, R32G8X24_TYPELESS /
D32_FLOAT_S8X24_UINT), checked on the resource's DXGI format, so a D24
texture backed by D32_SFLOAT_S8_UINT still takes the R24 view. The other
family's view falls through to the existing "view format not supported"
path and leaves the slot null.

d3d12_descriptor_test checks both cross pairs give a null descriptor, and
takes the expected depth T# from the texture's backing: a GPU without a
usable D24 (the layer's depth_usable rule) backs R24G8 with
D32_SFLOAT_S8_UINT, where the old expectation of 8_24_UNORM failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:42:28 -06:00
69ed76dad0 Merge pull request #754 from Rafael 2026-11-21 21:37:59 -05:00
dcb2e8ecf1 Merge pull request #748 from Vonsek 2026-11-21 21:37:58 -05:00
1242d7b861 Merge pull request #741 from totonii 2026-11-21 21:37:56 -05:00
ce8c10a572 Merge pull request #704 from Ayinaki 2026-11-21 21:37:49 -05:00
51a5c3ee3b Merge pull request #701 from mohamedsaad.lahlou 2026-11-21 21:37:48 -05:00
6cb0facab2 Merge pull request #696 from SuarezPM 2026-11-21 21:37:48 -05:00
e4d72347d7 Answer 5.1 to a shader model request that asks for it
D3D12's baseline is 5.1, and both WARP and the RTX 5070 runtime answer a 5.1 request with S_OK and 5.1; the layer
refused everything below 6.0, so a caller asking for the minimum got E_INVALIDARG. The host comparison now covers
5.1, the test pins it, and the docs record both measurements.
2026-11-22 02:36:35 +00:00
88dc8beac1 Runtime: bind multisampled 2D and array shader-resource views 2026-11-22 02:34:09 +00:00
276a9e9d37 runtime: render-target views of a multisample texture array's slice range
CreateRenderTargetView refused D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY, so after the DSV change in
#683 a multisample array could be a depth target but not a colour target (found by @Derpbeat on
#683). The view is {resource, mip 0, FirstArraySlice, ArraySize}, as for the DSV; the replay
already checks the range and clears through a view of those layers.

d3d12_vulkan_device_test: a 4-layer 4x RGBA8 target is cleared red through a whole-array view and
green through a view of slices 1-2; every slice is resolved and read back, so slices 0 and 3 must
stay red and 1-2 green. A view of slices 3-4 is refused at execute (invalid_subresource). Without
the change the test fails at the captured-range check.

docs/d3d12_vulkan.md: the RTV/DSV bullet lists TEXTURE2DMSARRAY for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:31:00 -03:00
e6eaecd05a Runtime: the descriptor table lives in device-local memory (D3D-76)
AI-assisted. Set 0 binding 2 is the table every T#/S# lookup probes.
BindlessSet allocated it HOST_VISIBLE | HOST_COHERENT and flush() memcpy'd into
the mapping, so a divergent lookup read it over PCIe: 19.5x slower for T#+S#
pairs and 46.2x for a divergent miss at 100k entries on an RTX 2060 SUPER
(vk_descriptor_bench, #639; 58-796x on the 5080).

The table now lives in DEVICE_LOCAL (HOST_VISIBLE kept as a fallback for a device
without it). flush() takes the command buffer that will use the set and uploads
only what changed: the whole table from a mapped staging buffer when the buffers
were just created (first use or growth), and the changed slots with
vkCmdUpdateBuffer otherwise, which copies the data into the command buffer while
recording so no staging bytes are read at execution. A TRANSFER_WRITE ->
SHADER_READ barrier follows, before the draws. DescriptorTable tracks the slots
that insert, replace, erase, clear and grow touched, including both slots of a
relocation, so a flush no longer rebuilds an 80 MiB table for one descriptor.

A command buffer whose vkQueueSubmit is rejected never runs the upload, so the
set keeps the obligation: VulkanQueue::execute reports the submit result through
a commit callback, and the set rebuilds the table on the next flush, which also
reports flush_needs_idle() and makes the device wait before it. The same wait now
honours the pre-existing contract for replaced/erased entries and for growth
(the device ignored flush_needs_idle() before), and frees the retired buffers
once the queue is idle instead of at teardown.

Verified on an NVIDIA RTX 2060 SUPER, Linux 620.73.04, Vulkan 1.4.357:
- ctest 10/10, including descriptor_table cases for the change list, relocation
  marking and consume-once reads.
- vk_bindless_test with LEONIDA_VK_VALIDATION=1: 14 draws (probe depth, erase,
  relocation, growth 64 -> 512 slots, rebind, failed-submit retry, other view,
  removal) read back exact, table in device-local memory in both
  descriptor-indexing configurations. With the retry disabled the test is red.
- GPU suite 64/91 with the same 27 64-wide skips as main, 0 failures; 91/91 with
  LEONIDA_W64_EMULATE=1.

No game data; synthetic fixtures only.
2026-11-21 23:30:46 -03:00
89bf640040 fix(runtime): check image capabilities before texture creation
Single-sampled attachments and storage images could bypass the device's format limits. Use the same query for allocation info and committed creation so unsupported requests get the same answer before Vulkan allocates an image.
2026-11-22 03:29:48 +01:00
be283d10fc Merge main and preserve stencil and depth views alongside A8 sampled textures 2026-11-21 23:29:03 -03:00
2748b0f6bb D24 clears quantised on the native path too; host ties logged as a quirk
- A depth clear of any D24 texture, native D24 or stored as D32, now clears with
  depth24_to_float(depth24_quantize(v)), an exact 24-bit value, so no driver's
  tie rounding is left and NVIDIA's native D24 matches WARP and AMD.
- d3d12_depth24_compare.h checks the layer's clears against the reference
  (depth24_quantize, stencil value) and fails on a difference; the host is
  compared byte for byte only when it agrees with the reference, otherwise
  the difference is logged as a host quirk (NVIDIA's D3D12 rounds some ties
  the other way: 478 of 5215 values).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:25:35 +01:00
13cae9c949 chore: merge upstream descriptor plane coverage
Preserve the new plane views and packed-format tests alongside volume sampling so they run in the same descriptor fixture.
2026-11-22 03:24:54 +01:00
398f5b06bd Merge current main into the D3D12 trace branch 2026-11-22 03:22:44 +01:00
f415ca5c43 Keep the B5G6R5 texture format main has (the dedupe of two merges removed it here)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:21:37 +01:00
40bb5e76ce Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	runtime/src/vulkan_replay.h
2026-11-22 03:20:16 +01:00
cc46b5b97f Merge branch 'd3d-46-copy-compare' of https://github.com/AlxcBTW/Leonida into HEAD
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 03:19:49 +01:00
67204bf8c0 Drop format cases two merges both added
#617 and #694 each added the B5G6R5 and R9G9B9E5 cases to the DXGI format map and the copy block table, so the
switch statements had duplicate labels and the Vulkan device tests no longer compiled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:19:42 -05:00
bfd0627c9c Merge origin/main into d3d-46-copy-compare; drop the format cases main now has
#562/#587 landed the same R9G9B9E5_SHAREDEXP and B5G6R5_UNORM mappings this
branch adds. The textual merge was clean but left duplicate case labels
(MSVC C2196) in texture_format and the block-size table; keep one of each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:19:21 +01:00
eaeb73f466 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-22 03:17:42 +01:00
6910e1cfef Merge origin/main into d3d-47-d24-emulation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:17:17 +01:00
00fef11ad2 fix(runtime): report unaligned BC texture support
The Vulkan path can sample a top-level mip with partial edge blocks, but callers querying OPTIONS8 receive E_INVALIDARG. Report the logical device's enabled BC feature so callers can select the matching upload path.
2026-11-22 03:16:34 +01:00
0e63a76da0 D24 conversion: predication, large copies, tests, spec note (review)
- A dispatch honours conditional rendering and the layer's copies do not, so a
  SetPredication that skips copies also skipped the D24 conversion while the
  copy ran. Conditional rendering is ended around the dispatch and begun
  again; a test runs an upload and readback under a skipping predicate and
  compares with the host's unpredicated run (it fails without the fix).
- A copy larger than maxStorageBufferRange (queried; 128 MiB assumed if not)
  is split into dispatches by slices, or by rows of one slice; the descriptors
  bind 256-byte-aligned windows of both buffers. depth24_convert_test splits
  the 4096x4096 copy with a 1 MiB range and a pitched one with a 1 KiB range.
- make_pipeline destroys the layouts it made when a later step fails.
- depth24_convert_test is in the CI tool list; the docs say which GPU each test
  exercises.
- R24G8_TYPELESS with a typed D24 DSV is compared with the host. SRVs of
  R24_UNORM_X8_TYPELESS and X24_TYPELESS_G8_UINT are an empty slot in the
  layer (no format mapping; stencil-plane views refused): reported by the
  test and documented as a known gap.
- depth24.h: the D3D11.3 spec's FLOAT -> UNORM wording (3.2.3.6, 3.2.2) next to
  what WARP and AMD were measured to do; "159" is 5215.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:15:13 +01:00
21126810d6 Answer shader model and root signature feature queries
CheckFeatureSupport fell through to E_INVALIDARG for
D3D12_FEATURE_SHADER_MODEL and D3D12_FEATURE_ROOT_SIGNATURE, so a game
asking either got an error where the PC runtime answers. Report DXIL 1.0
and root signature 1.1, the versions this layer can honour rather than
the driver's maximum, clamp higher requests down, and refuse an undefined
value, a wrong DataSize and a null buffer, as the host runtime does.
2026-11-22 02:11:18 +00:00
3dde44ecb2 Merge current main and isolate the A8 and R8 view descriptors 2026-11-21 23:09:05 -03:00
86a1bfeac7 Merge pull request #694 from ismailchaka1 2026-11-21 21:08:42 -05:00
69cb90ca32 Merge pull request #683 from Rafael 2026-11-21 21:08:40 -05:00
0f2cee0fdf Merge pull request #682 from Rafael 2026-11-21 21:08:40 -05:00
816a4e5c20 Merge pull request #678 from ismailchaka1 2026-11-21 21:08:40 -05:00
1abfc432ad Merge pull request #668 from ismailchaka1 2026-11-21 21:08:37 -05:00
36da56b1d9 Merge pull request #610 from AlxcBTW 2026-11-21 21:08:32 -05:00
89f19af545 chore: merge upstream 3D target and RGB9E5 coverage
Keep both packed and volume textures in the bindless readback test. Place the volume upload beyond the UINT texture so the RGB9E5 upload cannot overwrite its first depth slice.
2026-11-22 03:08:17 +01:00
4e1de429fd Runtime: add opt-in D3D12 call tracing 2026-11-22 03:07:36 +01:00
527e41c2d3 Runtime: report DXGI format plane counts through CheckFeatureSupport 2026-11-22 02:06:26 +00:00
e80485e24e Merge main into d3d-61-b4g4r4a4
The only conflict: block_format's two-byte list, where main added
R5G6B5_UNORM_PACK16 (#587) next to this PR's A4R4G4B4_UNORM_PACK16. Both kept.
2026-11-22 02:05:52 +00:00
9b70afedb8 Runtime: B4G4R4A4_UNORM textures (D3D-61)
CreateCommittedResource refused DXGI_FORMAT_B4G4R4A4_UNORM. It now maps
to VK_FORMAT_A4R4G4B4_UNORM_PACK16: DXGI names channels from the low bits
up and Vulkan from the high bits down, so both have B in bits 0-3 and A
in 12-15. Vulkan 1.3 requires sampling it. Copies use two-byte texels,
and the shader-resource view is a 4_4_4_4_UNORM T#, which the GFX10
table already had.

d3d12_descriptor_test uploads an 8x8 texture with a different nibble in
every channel of every texel, checks the footprint (two-byte rows), and
samples it through set 0: all 64 texels match, each nibble n read as
n * 17.
2026-11-22 02:00:15 +00:00
33059d6b63 D24_UNORM_S8_UINT byte-exact on GPUs without D24
The layer stores D24 as D32_SFLOAT_S8_UINT where the GPU has no D24 (the
Radeon 880M, AMD generally). Footprint copies of the depth plane now convert
through a compute pass: an upload turns the 24-bit words into the nearest
floats of d / 16777215, a readback quantises floats back (float multiply by
16777215, round to nearest even, as WARP and AMD's D3D12 driver do) and writes
0 in the unspecified top byte. Clears store the float of the quantised value,
so a texture reads back as D3D's quantisation of the clear value.

- src/depth24.h, vulkan_depth24.h, depth24_convert.comp (+ compiled SPIR-V):
  reference conversion, the converter (pipeline, scratch, descriptors freed
  once the submission completes) and the shader.
- vulkan_replay.h: depth24_as_float binding flag, convert jobs prepared with the
  list and run around the copy, depth clear value.
- depth24_convert_test: all 16777216 words to float and back, 16777216 float
  patterns against the reference, a pitched copy; d3d12_depth24_compare.h:
  5215 clear values (whole-view and rectangle) against the host.
- d3d12_copy_compare.h: the D24 case now compares upload and readback with the
  host instead of only the bit-preserving copies.

Depends on #610.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:53:51 +01:00
12f1dc5a48 runtime: depth-stencil views of a multisample texture array's slice range (D3D-79 part 1)
CreateDepthStencilView refused D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY, so the descriptor held an
empty TargetView and any clear through it failed when the list was recorded. Multisample textures
have one mip, so the view is {resource, mip 0, FirstArraySlice, ArraySize}; the replay already
checks the range against the image and clears through a view of those layers.

d3d12_vulkan_device_test: a 4-layer 4x multisampled D32 texture, a view of slices 1-2 captures
that range and its clear replays; a view of slices 3-4 is refused at execute
(invalid_subresource). D3D12 can't copy a multisampled texture to a buffer, so the cleared
values are not read back. Without the change the test fails at the captured-range check.

docs/d3d12_vulkan.md: drop the duplicated RTV/DSV bullet and list the new dimension. The 1D and
1D-array DSVs need 1D textures first (D3D-63, #561).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:51:42 -03:00
b74ebc5b6c runtime: compare the Xbox tiled layout word as an integer so clang-cl builds
create_reserved() declared `constexpr auto xbox_tiled = static_cast<D3D12_TEXTURE_LAYOUT>(0x101)`.
0x101 is outside D3D12_TEXTURE_LAYOUT's enumerators (the enum has no fixed underlying type), so the
cast is undefined in a constant expression. MSVC accepts it; clang-cl rejects it:

  error: constexpr variable 'xbox_tiled' must be initialized by a constant expression
  note: integer value 257 is outside the valid range of values [0, 3] for the enumeration type

Keep the word as a UINT and compare desc->Layout through a cast. Same behaviour; with this one
change the whole runtime builds with clang-cl 23 + lld-link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:51:10 -03:00
69e3be8bc5 Runtime: depth-plane shader-resource views of depth-stencil textures
R24_UNORM_X8_TYPELESS (D24S8) and R32_FLOAT_X8X24_TYPELESS (D32S8) views
were refused ("view format not supported for this texture: 46") and wrote
a null descriptor, so shadow maps and depth reads of these textures found
nothing. They now write a T# of the texture's own depth format
(8_24_UNORM, X24_8_32_FLOAT) with the depth in R, which set 0 views
through the depth aspect.

d3d12_descriptor_test checks both formats next to their stencil views:
same address, the depth format's code, R from X.

Depends on: #668
2026-11-22 01:49:06 +00:00
df9039e64d feat(runtime): bind single-sampled 3D texture SRVs
Volume depth belongs in the T# depth field, while its Vulkan view has a single array layer. Route matching descriptors through the existing 3D binding so a shader can select W slices and use a view-relative mip.
2026-11-22 02:45:57 +01:00
ed7e1ead05 D3D-61: keep alpha-only texture sampling distinct from R8 2026-11-21 22:44:35 -03:00