Conflicts, both sides kept: predication (D3D-18) next to the UAV clear in
command_list.h, vulkan_backend.h and vulkan_replay.h; the D3D-28 tests next to
the UAV clear test; texture_create_info's attachment argument with main's
mutable host-transfer usage.
UAV clears under a predicate: a whole-view texture clear takes the attachment
path, as render-target clears do, so conditional rendering applies; buffer
clears and non-attachment texture clears are transfers and are counted in
unpredicated_copies with the copies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add DXGI-to-Vulkan mappings and block sizes for missing integer and typeless formats in the Vulkan D3D12 device (D3D-60):
- R32G32 (_TYPELESS, _UINT, _SINT)
- R16G16B16A16 (_UINT, _SINT)
- R10G10B10A2_UINT
- R16G16 (_TYPELESS, _UINT, _SINT)
- R8G8 (_TYPELESS, _UINT, _SINT)
Exclude these integer formats from color resolve matching in color_resolve_format_matches (integer resolves are disallowed in Vulkan and D3D12).
Add footprint and allocation tests comparing against host D3D12 WARP, as well as CheckFeatureSupport and committed resource creation checks.
Tested on AMD Radeon RX 9070 (driver 26.10.1, Windows 11) and host D3D12 WARP.
AI-assisted.
A UINT opaque-white border read back as 0 (Vonsek, on an RTX 5080). The S# has
no integer border types, since the hardware reads them by the image's format.
So bind_sampler gave Vulkan VK_BORDER_COLOR_FLOAT_*, which an integer image
reads as 0. The float and UINT samplers also shared one S# key and so one
VkSampler.
An integer border is now marked in the S#: BORDER_COLOR_PTR = 0x800
(gfx10::kIntegerBorderPtr), a field the hardware reads only for table colours.
That gives it its own key, and vulkan_sampler picks VK_BORDER_COLOR_INT_*.
d3d12_descriptor_test runs Vonsek's case: an R8G8B8A8_UINT texture sampled past
its edge through UINT black and white border samplers reads 0 and 1, and a
float white border reads 255. The case fails with the float enums on an RTX
4090. gfx10_descriptors_test and d3d12_sampler2_test check the mark.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateSampler2 wraps CreateSampler. The UINT border colour maps (0,0,0,0),
(0,0,0,1) and (1,1,1,1) to the S#'s border types, and anything else to the
table. Non-normalized coordinates set FORCE_UNNORMALIZED. A description the PC
runtime refuses (unknown flags; a non-normalized sampler with an unequal
min/mag filter, a linear mip filter, anisotropy, comparison, a U/V address mode
other than clamp/border, or a non-zero LOD or bias) leaves the slot as it was,
as the runtime does on an RTX 4090 and on WARP. The layer now answers
D3D12_OPTIONS17 with NonNormalizedCoordinateSamplersSupported, as both report.
d3d12_sampler2_test compares the S# bytes with CreateSampler's and the 22
edge cases with the host's PC runtime live.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateCommittedResource1/2/3, CreateCommandQueue1 and GetCopyableFootprints1
as thin wrappers over the existing methods. D3D12_RESOURCE_DESC1 drops to
D3D12_RESOURCE_DESC; the initial state or barrier layout is unused, because new
textures start UNDEFINED and move on first use. The newer arguments are answered
as the PC runtime answers them (measured on an RTX 4090, driver 621.14):
- a protected resource session: E_INVALIDARG (no session support reported);
- a sampler-feedback mip region: E_INVALIDARG on textures, ignored on buffers;
GetCopyableFootprints1 returns its failure answer for such a texture;
- a buffer's initial layout other than UNDEFINED: E_INVALIDARG;
- a castable count with a null list: no list;
- a castable list: E_INVALIDARG, since it needs RelaxedFormatCastingSupported,
which the layer does not report (D3D12_OPTIONS12 is unanswered);
- CreateCommandQueue1's creator ID: ignored.
d3d12_method_variants_test compares each variant with its base method, runs the
edge cases and, when the host has a D3D12 device, compares each answer with the
PC runtime live. Thanks to ezwinxdlmao for the probe notes in #156.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D3D12 stores blue in the low five bits of B5G6R5. Use the Vulkan packed format with the same ordering and check the two-byte words returned by full-image and rectangular clears.
Map the shared-exponent format through resource creation and buffer-image copies so shaders can resolve its existing GFX10 view. Check the sampled channels and compare the mip-array footprints with the host runtime.
Preserve reserved-resource coverage alongside multisample resolve support and comparison tests. Fix the Windows SDK ResolveSubresourceRegion rectangle mutability.
Both were generated stubs; WriteToSubresource is in the first-frame API set
(docs/d3d12_vulkan.md section 6.1). Textures in CPU-visible custom heaps map with a
null pointer, as on D3D12, and copy on the host with VK_EXT_host_image_copy while
they are in GENERAL (D3D12's COMMON). Every other case is a CopyTextureRegion
from or to a staging buffer, replayed on the device's queue and waited for, so the
layout tracker and first-use zero fill behave as for the application's copies.
The standalone and test devices enable the extension where the GPU has it.
d3d12_vulkan_device_test checks both paths: boxes and pitches, a mip, a volume,
BC1, rejected calls, a default-heap texture, and GPU copies in both directions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add DXGI->Vulkan mappings and footprint sizes for SNORM and SINT render-target formats, and extend render_target_clear_color to convert SINT clears numerically (NaN to zero, clamp to the signed range, truncate toward zero) instead of copying float bits. Rename d3d12_uint_clear_test to d3d12_clear_test and widen it to compare UNORM/SNORM/FLOAT/UINT/SINT render-target and depth/stencil clears against Windows WARP, full and rectangle. SRGB clears are left out of the byte-exact comparison: the linear->sRGB encoding rounds differently at the .5 boundary on WARP vs Vulkan (a 1-ulp driver difference).
Conflicts, both sides kept: command_list.h (clear_unordered_access next to
ExecuteBundle's execute_bundle), vulkan_backend.h (fill/update buffer next to
the sampler functions), CMakeLists.txt (the UAV clear test next to the new
descriptor test) and the known-gaps paragraph in docs/d3d12_vulkan.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- command_list.h: a Predication command (offset 8-byte aligned, EQUAL_ZERO or
NOT_EQUAL_ZERO; a null buffer turns it off), recorded by
GraphicsCommandList::SetPredication.
- vulkan_replay.h: begin/end conditional rendering (INVERTED for NOT_EQUAL_ZERO),
ended before a new predicate and at the end of the list. While predicated,
whole-view clears go through vkCmdClearAttachments, which conditional rendering
covers. New ReplayResult::invalid_predication; PreparedList::unpredicated_copies
counts copies Vulkan cannot predicate.
- Device: VK_EXT_conditional_rendering and its feature enabled when present, and
buffers created with VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT; without it a
predicated list is unsupported.
- Tests: command_list_test (recording rules), vk_command_replay_test part C (GPU).
- docs/d3d12_vulkan.md 4.7: what is done; copies and the 64-bit value are open.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateReservedResource (and 1 and 2) reserve the whole resource linearly, as
docs/d3d12_vulkan.md section 4.2 plans for the first boot: a committed
resource on a default heap underneath, so every tile is backed and starts
zeroed. D3D12's description rules are kept as measured on the PC runtime
(ROW_MAJOR buffers, 64KB swizzle layouts for textures, a format with a tile
shape; GetHeapProperties is E_INVALIDARG on a reserved resource). The Xbox
tiled layout word 0x101 is accepted as 64KB_UNDEFINED_SWIZZLE.
GetResourceTiling comes from src/resource_tiling.h: the standard 64 KiB tile
shapes, standard and packed mips, per-mip tile counts and the tile order. The
device test compares it with the host PC runtime for 18 buffer, 2D, array,
block-compressed and volume layouts; resource_tiling_test checks the same
arithmetic without a GPU. Packed-mip tile counts are the driver's choice and
are this layer's own rule (tight linear size in whole tiles).
UpdateTileMappings and CopyTileMappings log once and do nothing; what that
loses (aliasing, unmapped tiles keeping data) is written down in section 4.2.
Tested on an RTX 5070 (driver 621.01) under VK_LAYER_KHRONOS_validation.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MakeResident, Evict, SetResidencyPriority, EnqueueMakeResident, SetStablePowerState and
SetBackgroundProcessingMode. Vulkan memory stays resident until it is freed and paging is the
kernel driver's job, so there is nothing to do; each method still checks its arguments
(E_INVALIDARG) and EnqueueMakeResident signals its fence so a queue waiting on it does not hang.
SetBackgroundProcessingMode sets its completion event at once. d3d12_vulkan_device_test covers the
success paths, bad arguments, and the fence signal seen by a queue Wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: main moved texture create info into texture_create_info (the UAV
attachment usage now goes there, so placed-resource sizing agrees) and edited
the same docs paragraphs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CPU handle's slot is read while recording as the GFX10 T#/V# a shader
would load (docs section 3.4), so the clear works with whichever view
creation lands (#157, #328, #334) and with game-built descriptors.
- Buffers: vkCmdFillBuffer for elements up to 4 bytes, with the unaligned
ends copied from the filled middle; 8/16-byte elements are written with
vkCmdUpdateBuffer and doubled with copies. Rects are element ranges.
- Textures: vkCmdClearColorImage for whole views, vkCmdClearAttachments
for rects (UAV textures also get COLOR_ATTACHMENT usage when the format
supports it), in place in GENERAL; mip and layer range from the T#.
- Values follow D3D's Uint (raw low bits) and Float (converting) rules,
encoded in the view's format and cleared into the image as the value
that decodes those bytes in the image's own format (typeless resources).
- d3d12_uav_clear_test: hand-computed conversion checks, then raw,
structured and typed buffers and 2D, array and volume textures cleared
and read back through D3D12; refusals at record and replay.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two findings from the review of #328, on MSVC 19.44 and an RTX 5080.
- bind_image did not compile with MSVC (C2397): the view's aspect, picked
between two VkImageAspectFlagBits values, went into a VkImageAspectFlags
field in braces. MSVC's enums are ints, so that is a narrowing
conversion there; GCC and clang give the enum an unsigned type and accept
it. The value is cast now.
- d3d12_descriptor_test passed with the sampler index forced to 0, because
its point, clamping sampler and the fallback sampler read the same
texels. The test's sampler now wraps in U and the shader samples one
tile to the right: the right sampler gives the texture, the fallback its
right edge. With the index forced to 0 the test fails (texel 0 reads
224, 0, 135, 255 instead of 0, 0, 128, 255).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The device now keeps set 0 of the translated shaders and puts into it what
views and samplers name. No pipeline binds the set yet: that comes with
the compute path. Until then rt::d3d12::bindless_set / bindless_set_layout
hand it out.
- Device: CreateShaderResourceView and CreateUnorderedAccessView of
textures write a T# into the slot, CreateSampler an S#
(gfx10_descriptors.h); each makes sure set 0 has the view or sampler and
the hash table has the key. The key is the descriptor's bytes, so a
copied descriptor needs nothing more. A view that cannot be shown (a
volume, a multisampled texture, the stencil plane, a range past the
texture) leaves a null descriptor, which finds the fallback. A texture
is named by an address of its own above 4 GiB that nothing dereferences;
its keys are erased and its indices freed when it is destroyed.
- VulkanDeviceInfo::bindless says the Vulkan device has the features; the
standalone device and the test helper enable them where the GPU has
them, with samplerAnisotropy and samplerMirrorClampToEdge.
- Every ExecuteCommandLists flushes the set before its commands are
written (VulkanContext::set_bindless_prepare).
- Layouts: a bindless descriptor has one image layout, but D3D12 samples a
texture both in a shader-resource state and while promoted from COMMON
(GENERAL here). With the set, a texture's shader-resource states use
GENERAL too (ResourceBinding::sampled_in_general). This follows from the
Vulkan rule for descriptor layouts; no test can see it broken, since the
validation layer does not follow dynamic indices into runtime arrays.
Not done, and listed in docs/d3d12_vulkan.md: buffer and constant-buffer
views, 1D/3D/multisampled and stencil views, descriptors the game writes
itself, static samplers and shaders' literal S#s, and holding back a flush
that moves table entries while earlier command lists still run.
Test: d3d12_descriptor_test, through the Xbox-ABI proxy. It decodes what
the slots hold (a view of an uploaded 8x8 texture, a sampler, a BGRA cube
view with a component mapping, an unordered-access view, null
descriptors). Then a compute shader (test/glsl/cs_sample.comp, compiled
with glslangValidator where it is found) is handed a slot's T# and the
sampler's S#, looks them up in the hash table as a translated shader does
and samples; the test creates that pipeline in Vulkan and binds the
device's set. It reads the texture through the view's own slot and
through a copy of it, and gets the fallback from a slot of bytes no view
was made for and, once the texture is destroyed, from the view's own
bytes. Without the table insert, or without the removal at destruction,
the test fails. The test no longer compiles d3d12_xs_device.cpp itself:
the COM library has it.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
GetResourceAllocationInfo, GetResourceAllocationInfo1 and
GetResourceAllocationInfo2 were generated stubs. Buffers take their width
rounded up to 64 KiB. A texture's size is what its VkImage needs
(vkGetDeviceImageMemoryRequirements, or a throwaway image without it),
rounded up to its D3D12 alignment: 64 KiB, 4 MiB with MSAA, or the small
alignment the description asks for. A 4 KiB request that doesn't qualify
is invalid, as on the PC runtime; the MSAA 64 KiB one has no size limit
there. Texture creation and these queries share one VkImageCreateInfo.
d3d12_vulkan_device_test compares buffer sizes, alignments and invalid
descriptions with the host PC runtime, and checks the per-resource layout
of the Device4/Device8 variants.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A descriptor is the bytes of its heap slot (a TargetView in RTV and DSV
heaps, otherwise what the shader loads), so both are byte copies.
CopyDescriptors walks the destination and source range lists together,
one descriptor at a time; null size arrays mean one descriptor per range,
and whichever side runs out first ends the copy.
Test: d3d12_descriptor_test, through the Xbox-ABI proxy, checks the slots'
bytes for one run, range lists of different shapes on each side, null
size arrays, a destination longer than its source, and null arguments.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>