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>
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.
Depth-stencil attachments can opt out of sampling while remaining valid resources. Leave a reused descriptor null before any view is encoded or registered.
#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>
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.
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>
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.
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.
- 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>
#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>
#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>
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.
- 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>
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.
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.
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.
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>
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>
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>
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
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.