CreateCommittedResource refused every TEXTURE1D with ALLOW_RENDER_TARGET or
ALLOW_DEPTH_STENCIL ("1D texture cannot be an attachment"), although the PC
runtime creates them: on an RX 6750 XT the AMD adapter and WARP both accept
64 color formats as 1D render targets and 20 as 1D depth-stencils. The 1D
RTV/DSV code already on main was unreachable.
Accepting them also needs a valid attachment view: VulkanBackend::view made
every attachment view VK_IMAGE_VIEW_TYPE_2D_ARRAY, which a VK_IMAGE_TYPE_1D
image can't take (VUID-VkImageViewCreateInfo-subResourceRange-01021). That
already hit rectangle clears of 1D UAV textures on main, whose UAV images
get color-attachment usage. ResourceBinding now records a 1D image, and its
attachment views are 1D arrays. A driver without the 1D attachment image
still refuses through check_image_support.
d3d12_texture1d_target_test compares creation with the host adapter and
WARP, and reads back clears through 1D and 1D-array RTVs and DSVs (whole and
rectangles, mips, slice ranges) and a 1D UAV rectangle clear against WARP.
d3d12_typeless_families_test runs its draws on a 1D target too.
d3d12_vulkan_device_test expected the old refusal.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015z45kpgzff6KvVjAnLtc4h
subgroup_facts set a plain bool before it filled the data, so a second
thread that made its first CheckFeatureSupport(D3D12_OPTIONS1) call at
the same time could read WaveOps FALSE and lane counts of 0.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
rt::rootsig::pack_stage() lays a root signature out for one stage the
way the console compiler does: root order from the stage base, a table
one dword (its 32-bit VA), a root view two, constants one per value,
and the first parameter that does not fit refused (the spill array
behind s[0:1] is not modelled).
Compute (base s4) is measured: on the package's FidelityFX DLL, whose 29
compute containers carry their RTS0 next to the console-compiled program,
base plus span equals RSRC2 USER_SGPR in 29 of 29, and
root_sig_contract.py --model console finds all 20 translated programs
compatible (the s0 model contradicts 7). VS/PS/GS s8 and MS s16 stay a
census hypothesis.
The compute bind point now uses this layout; graphics keeps pack(),
since every stage reads one push-constant block and a mesh shader (s16)
and a pixel shader (s8) would collide. A signature carries both
layouts; binding it where its layout refused it invalidates the list.
Test fixtures follow: the compute GLSL shaders read the new places, and
the asm fixtures a D3D12 compute PSO runs are built with
LEONIDA_USER_DATA_SHIFT=4 (compute_fixture.py shifts every SGPR and the
RSRC2 user count), so the standalone harness keeps using them at s0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A typed B8G8R8A8 or B8G8R8X8 texture with a castable-format list took
an RTV in a format the list doesn't name (its own sRGB format, say) and
silently kept the image's format, where a typed R8G8B8A8 texture with a
list refuses it. CreateRenderTargetView now refuses it for these
textures too; without a list they keep the image's format, as before.
d3d12_clear_test's negative check covers a B8G8R8A8 texture listing
R8G8B8A8 and a B8G8R8X8 one listing B8G8R8A8 next to the R8G8B8A8 one:
each takes its own and its listed format and refuses 3 formats its list
doesn't name. Without the shim change it fails on the B8G8R8A8 texture's
unlisted B8G8R8A8_UNORM_SRGB.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only CPU-writable heaps expose a host pointer to replay, so DEFAULT and READBACK pointer lists are refused as unsupported instead of being read from possibly stale mapped bytes. Reuse completed staging buffers and write translated addresses directly. Adds a GPU-copy-produced placed-DEFAULT regression with a negative control.
AI-assisted (OpenCode)
GetCopyableFootprints sized a mip with desc->Height >> mip and
depth >> mip on 32-bit values, and desc->Width >> mip on 64 bits. D3D12
accepts any MipLevels, so a shift count of 32 (64 for the width) or more
is reachable, and C++ leaves it undefined. Measured on an RTX 5060 Ti,
the PC runtime's own shift wraps: a 16x16 texture with 40 mips reports
subresource 32 as 1x16 and 33 as 1x8, a 40-mip volume 16 slices at mip
32. The layer matched only because MSVC's x64 shift masks the count the
same way; the counts are now masked explicitly (& 31, & 63), which gives
the same answers by definition.
compare_footprints: a 40-mip 2D texture, a 70-mip 1D texture and a
40-mip volume, every subresource compared with the host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GPU builder grouped four consecutive Morton-sorted elements per node,
level by level. Those groups ignore where the Morton prefix changes, so
sibling boxes overlapped and a ray took about twice the traversal steps.
It now builds a binary radix tree over the same sorted keys (Karras 2012,
ties broken by sorted position) and keeps the inner nodes at an even depth
as the BOX32/BOX16 nodes, each taking its children's children (2 to 4),
numbered in sorted order by a scan (root = node 0). Boxes are filled by one
bottom-up pass: each element writes its slot box and merges it into its
parent's accumulator with atomics; the last child to arrive carries on.
The arrival counter's atomicAdd has acquire-release semantics instead of a
memoryBarrierBuffer, since the pass is divergent and SPIRV-Cross before
MSL 3.2 lowers memory barriers to threadgroup_barrier. Refit reuses the pass
through the parent table.
TRI1 pairing (#3315) pairs triangle children of one node; the build records
each element's tree pointer so a paired sibling finds its TRI1 slot. The
node count depends on the keys: the layout reserves (3N - 2) / 4 nodes, the
header counts the nodes written (plus the BOX16 spare unit after the last
one), so compaction gives the rest back. Refit copies a source by its
header size. check-build reports traversal steps per ray.
Steps per ray: 5,000 random triangles 42.0 -> 23.0, BOX16 43.9 -> 23.7,
paired 7,200-triangle grid 37.6 -> 19.5. Build 1M triangles: RTX 5090
5.50 -> 5.99 ms, Radeon gfx1036 iGPU 133 -> 180 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ID3D12Heap::GetDesc returned the creation description unchanged. The
host runtime reports the alignment the heap was placed with (64 KiB for
an Alignment of 0) and the one node for a node mask of 0, as the layer
already does for resources, descriptor heaps and queues: measured on an
RTX 5060 Ti, 19 of 20 heaps (default, default with 4 MiB alignment,
upload, readback, custom; each node-mask pair) read back differently.
d3d12_vulkan_device_test: compare_heap_descs creates each heap on the
layer's arena device and on the host and compares the whole GetDesc.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KHR TLAS builds hardcoded arrayOfPointers = VK_FALSE and passed the guest's console-VA pointer list straight to Vulkan. Carry DescsLayout into the recorded build, validate each pointer, stage a copy with heap_base added into a device-addressable buffer, and use it as the build input. The guest input is not modified and GPU-written pointer lists are refused. Adds ARRAY and ARRAY_OF_POINTERS RayQuery coverage plus a null-entry refusal check.
- GetRaytracingAccelerationStructurePrebuildInfo's KHR path passes
LOW_MEMORY for MINIMIZE_MEMORY, as the build now does (Vulkan sizes a build
with identical flags).
- check-build enforces a case's "box16" field (only BOX16 or only BOX32
inner nodes), so a BOX16 case that came out BOX32 cannot pass the bit
check vacuously; the vk and D3D12 BOX16 cases set it.
- Comments: half_round's inward overflow, the remap byte's positions, what
the half-rounding table test covers, and what an update that breaks
D3D12's flag or ALLOW_UPDATE rules would do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A bottom-level BuildRaytracingAccelerationStructure with MINIMIZE_MEMORY now
writes BOX16 inner nodes (64 bytes, half boxes) instead of BOX32 (128 bytes):
the same tree, about a fifth smaller. Prebuild info, the build and its refits
take the choice from the same flags (xdxr_box16), so the sizes stay exact.
Top-level builds keep BOX32 (world space: a half's step is 2 m at 2 km).
Each child box is rounded outward from the exact box kept in scratch, in
integer code (packHalf2x16's rounding is implementation-defined; AMD rounds
toward zero). Past the half range a bound goes to +-inf outward and +-65504
inward, so empty slots stay empty; below the smallest normal half it goes to
0 or +-2^-14, never a denormal a flushing decoder would shrink.
tools/xdxr_bvh.py half_round gets the same denormal rule, and check-build now
compares every BOX16 word bit for bit with encode_box16 of the exact box of
the triangles under it.
Tests: five blas_box16_* cases in vk_xdxr_build_test (radix and small sort,
an inactive triangle, values past 65504 and below 2^-14, a refit), and a
MINIMIZE_MEMORY BLAS plus its in-place update through the D3D12 API in
d3d12_xdxr_rt_test (prebuild and postbuild sizes).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A title holds the Xbox-ABI proxy, and create_window_presenter looked up the
layer's device on the pointer it was given, so with the proxy it returned null
and logged nothing. It now resolves the proxy first, as the helpers around it
do, and says on stderr when it is handed a device that is neither.
xbox_present_test creates a presenter from the proxy and presents a blank
frame.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After slot 67 (or 62) creates a pipeline, amd_fidelityfx_upscaler_xbox.dll calls the pipeline's slot 11, past the
public ID3D12PipelineState, and the slot-67 mapping dropped the dispatch state, so two programs with the same code and
different kind 0 could not be told apart there.
- d3d12_xs_device.cpp: with kind 0 present (the DLL always passes it), slot 67 builds one FSPX payload from the four
pointer and size pairs (leonida::fspx_payload_from_parts) and passes it as CS, so the device uses the code and
state keys. Every pair is checked before it is read; an inconsistent one refuses the call. Without kind 0 the
kind-6 bytes go on alone, as before.
- d3d12_vulkan_device.cpp: XboxPipelineStateStubs puts console slots 9, 10 and 11 into the pipeline's vtable ahead
of Object's virtual destructor (one slot under MSVC, two under GCC), so they are slots 9 to 11 on both. Slot 11
returns a blob holding 0; 9 and 10 return E_NOTIMPL.
- Why 0, measured on 1.0.2.1: the DLL zeroes the value before the call, keeps it at 0 when slot 11 fails or returns
no object, and with 0 skips the scratch buffer and list slot 141 at dispatch. None of the 29 programs sets
COMPUTE_PGM_RSRC2.SCRATCH_EN or has a scratch instruction, and kind-0 words 0 to 2 are the same in all 29, so no
per-program scratch size is there.
- Tests: shader_library_test (payload building, refused pairs, the #1911 review case through slot-67 parts) and
d3d12_fspx_compute_test (slot 67 with four pairs picks the right one of two programs sharing their code, bad pairs
refused, slot 11 and its object's slot 3 and 4, reference counts unchanged).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_vulkan_device_standalone never enabled fragmentStoresAndAtomics or
vertexPipelineStoresAndAtomics, so a pixel shader with a writable storage
image (an image atomic: 1,018 corpus pixel shaders) broke
VUID-RuntimeSpirv-NonWritable-06340 while CreateGraphicsPipelineState
answered S_OK.
The device enables both where the GPU has them. A graphics PSO whose stage
declares writable storage (src/spirv_stores.h reads the declarations) on a
device without the feature is refused with E_NOTIMPL and a log line.
spirv_stores_test checks the rule on hand-built SPIR-V; d3d12_stores_atomics_test
checks the refusal and the standalone device under the validation layer.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A castable-format list may name an R8G8B8A8 texture's B8G8R8A8 formats,
or the reverse, or cross B8G8R8X8 and B8G8R8A8. WARP and AMD's D3D12
driver store a clear or a draw through an RTV in a listed format in the
view's channel order and encoding: an R8G8B8A8 texture cleared to
(0.2, 0.4, 0.6, 0.25) through a B8G8R8A8 RTV holds 153, 102, 51, 64.
CreateRenderTargetView refused such an RTV on an R8G8B8A8 texture, so
the clear failed Close and draws were dropped, and a typed B8G8R8A8
texture's RTV kept the image's format whatever the view named, so its
clears came out in BGRA order and without the sRGB encoding.
An RGBA8 or BGRA8 UNORM/SRGB texture (B8G8R8X8 included) now gets an
RTV in another of these formats when its list, as the application gave
it, names that format, and color_view_format lets a castable image's
clear cross between the two channel orders. Draws already used the
PSO's format for the attachment view. A format the list doesn't name
stays refused; a typed B8G8R8A8 texture without a list keeps ignoring
the RTV's format, as before.
d3d12_clear_test compares 8 such textures with WARP in full and
rectangle clears (the X byte of an X8 view left out: WARP and AMD write
different values there) and checks that 3 unlisted formats get no RTV;
d3d12_draw_test draws through the same views; typeless_rtv_test checks
the replay's crossing and its refusals.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateRenderTargetView and CreateDepthStencilView stored ArraySize -1 of a
TEXTURE2DARRAY or TEXTURE2DMSARRAY view as the layer count, so the view was
nulled (typeless and castable RGBA8) or the list was refused at replay. The
host accepts it and clears the remaining slices. Resolve it at creation;
out-of-range views are refused as before. d3d12_view_slices_test compares
clears through such views with the host on the same adapter and WARP.
d3d12_typeless_rtv_test listed {first slice 1, ArraySize -1} on a four-slice
texture among the views the layer must reject; the host accepts that view, so
the entry now uses first slice 4, which the host refuses too.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On a GPU without a D24 attachment (AMD) the layer stores D24_UNORM_S8_UINT as
D32_SFLOAT_S8_UINT. Draws then broke two D3D rules: the integer DepthBias was
scaled by the primitive's exponent instead of D24 units, and fragment depth was
not quantised like the clears, so an EQUAL test at a cleared value failed.
Single-sampled graphics pipelines with depth enabled on such a target now have
their pixel stage write FragDepth = quantise(z + D3D bias), with the bias in D24
units and the quantisation of depth24_convert.comp; the rasterizer's own bias is
off for them. A pipeline without a pixel shader, with or without a geometry
shader, gets a built-in one. d3d12_depth24_draw_test covers the finding's cases,
stored depth with constant and slope-scaled bias, a shader that writes depth, and
a VS + GS pipeline without a pixel shader.
Co-authored-by: UlteriorMotive00 <132296248+UlteriorMotive00@users.noreply.github.com>
create_device_proxy returns the proxy's DXGI pointer when the title asks for
IDXGIDevice1. D3D12XboxCreateDevice passed that pointer to set_device_outer,
so the Vulkan device's outer identity was the DXGI pointer, and
set_device_adapter_provider, which knew only the primary vtable, set nothing:
GetAdapter then loaded the host's dxgi.dll and returned a host adapter.
set_device_outer resolves the proxy first (device_proxy_primary), and
set_device_adapter_provider takes either pointer, returns whether it set the
provider and says so on stderr when it did not.
dxgi_device_test creates the device as IDXGIDevice1 on WARP, a hardware
adapter and the Vulkan device. Found by @kacper-serewis in review.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
d3d12_heap_properties_test compares what ID3D12Resource::GetHeapProperties
returns on the Vulkan-backed device and on the host runtime: the properties
and heap flags of committed resources in every heap type (custom ones and
SHARED, ALLOW_DISPLAY, CREATE_NOT_ZEROED, CREATE_NOT_RESIDENT included), of
placed resources in heaps of each kind, and of reserved resources, with null
arguments too, and whether each call wrote its outputs: 561 values. On main 4
differed (RTX 3060, driver 610.88), all the same rule: a placed resource
reports its heap's flags as they are, so one in an ALLOW_ALL heap reads back
0, while the layer added the DENY bits of the resource classes it isn't (0xC0
for a buffer, 0x44 for a texture). Those bits are the runtime's choice only for
a committed resource's implicit heap, where the layer already matched.
Builds on #2864, which adds the placed_ flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said hull, domain and geometry stages, and more than one
sample, are refused. The code accepts both: a geometry shader is the
translator's Vulkan geometry stage (it needs the geometryShader feature and
a triangle topology type), and sample counts above one are accepted
(d3d12_geometry and d3d12_msaa_draw cover them).
Say what create_graphics refuses today, each checked against the code:
- hull, domain and stream output: E_NOTIMPL with a log;
- the centre multisample pattern (needs custom sample locations);
- two stages that both read their code base (still refused with
E_NOTIMPL, "two stages read their code base");
- state that needs a Vulkan feature the device lacks.
Comment only, no behaviour change. Claimed in #3381.
Written with AI assistance (Claude, via OpenBot).
Tested on an RTX 4070 (NVIDIA 621.01, Windows 11, MSVC 14.44): the runtime
builds (431 targets) and ctest d3d12_draw, d3d12_msaa_draw, d3d12_geometry,
d3d12_translated_draw, d3d12_compute, d3d12_m4_compute and
d3d12_set0_compute pass 7/7, as on the base f847748c.
Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>