Commit Graph

13 Commits

Author SHA1 Message Date
8e50a770f8 Runtime: suspend conditional rendering around WriteBufferImmediate 2026-11-22 13:19:27 +03:00
9360ec9ec0 Runtime: predicate byte-granular CopyBufferRegion on the GPU
Build on the full 64-bit predicate snapshots from #856. Replay predicated buffer copies through a storage8 compute helper, retain descriptor batches through timeline completion, and reject missing capabilities or active statistics queries before submitting work.

Validate byte offsets, high predicate words, bounds, skipped destinations and pending descriptor lifetimes with CPU checks, 180 native WARP comparisons and 64 gated/reused GPU submissions. The existing OPTIONS19 host-capability mismatch also reproduces on base 4a36bb1; no tests are disabled.
2026-11-22 05:28:28 -04:00
29345889be Runtime: capture full 64-bit predication values on the GPU 2026-11-22 04:34:35 -04:00
033192d050 vk_command_replay_test: cover a subresource copied twice in one list
copy_layout has to order a transfer write that finds its range already in
the transfer layout, because a texture can stay in COPY_DEST and be copied
into again; D3D12 orders copies on the queue and needs no barrier from the
application. That ordering landed in 5ec780c without a test, and the BC7
copy case in d3d12_vulkan_device_test reaches it: on a tree without it the
case reports ten WRITE_AFTER_WRITE hazards under synchronization
validation.

Part G records two buffer-to-image copies into the same subresource with no
transition between them and reads the texture back, so the missing
dependency shows up as a validation error and as the wrong texels.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 23:26:54 -06:00
c7e450fc69 D3D-26: keep a null discard region apart from an explicit UINT_MAX count
A region with NumSubresources = UINT_MAX was recorded like a null region and
skipped the FirstSubresource check. DiscardResource now has a whole flag;
explicit ranges are checked in 64-bit at recording and replay. Tests at the
UINT_MAX boundary in command_list_test, part F and the COM device test.
Found by matheuskshn in review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:55:44 +00:00
e40bd6563e Merge main into D3D-26: predication and reserved resources on main
main added SetPredication (D3D-18) and reserved resources; both sides are
kept. The predication replay test took part E, so the D3D-26 test is now
part F. An atomic copy recorded under a predicate is counted with the
other copies that Vulkan's conditional rendering cannot skip, and
SetPredication, DiscardResource and the atomic copies are all refused in
a bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:29:19 +00:00
be91840c07 Runtime: SetPredication on VK_EXT_conditional_rendering (D3D-18)
- 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>
2026-11-22 10:59:11 +11:00
399b8ff839 Merge main into D3D-26: the replay test's new part D, the resolve-region section
main's vk_command_replay_test now has a part D (sync/access pairs), so the
D3D-26 test becomes part E. The device test's D3D-26 section signals fence
value 7, after main's resolve-region section took 5 and 6. The docs keep
both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:49:29 +00:00
19742b531a Runtime: DiscardResource, WriteBufferImmediate and atomic copies on Vulkan (D3D-26)
Three command-list IR commands, recorded through COM and replayed by
vulkan_replay.h:

- DiscardResource: an oldLayout = UNDEFINED barrier to the layout the
  tracker already has for each subresource. Buffers, rectangle discards,
  parts never used yet, untracked replays and one plane of a combined
  depth-stencil without separate layouts are no-ops.
- WriteBufferImmediate: a 4-byte vkCmdUpdateBuffer at the address,
  resolved at execution through ResourceBinding::va / buffer_offset and
  ReplayFunctions::buffer_at (the same fields and lookup as #291).
  MARKER_OUT waits for and sees every earlier write; MARKER_IN gets an
  execution-only ALL_COMMANDS dependency (Vulkan cannot say "started");
  DEFAULT is ordered by the application's barriers.
- AtomicCopyBufferUINT/UINT64: one vkCmdCopyBuffer region after a
  barrier that covers every earlier write, the dependent resources'
  included. Recording follows the debug layer's ATOMICCOPYBUFFER_* and
  WRITEBUFFERIMMEDIATE_* rules.

Tests: command_list_test (recording rules), vk_command_replay_test part D
(GPU readback of writes in all three modes, ordered atomic copies,
discards, and the lists that must be refused), and the COM path in
d3d12_vulkan_device_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:16:54 +00:00
44a94f35ca Runtime: widen enhanced-barrier stages so every access has a stage that can perform it
D3D12 lets an access be named with a sync scope whose Vulkan stages cannot perform it:
SYNC_ALL_SHADING with ACCESS_VERTEX_BUFFER is valid D3D12, but VERTEX_ATTRIBUTE_READ needs
VERTEX_ATTRIBUTE_INPUT. Vulkan rejects such barriers (docs/d3d12_vulkan.md listed it as a known gap).

vulkan_barrier_scope maps each side of a global, buffer or texture barrier and adds the narrowest
stage that supports any access left without one (the synchronization2 "supported access types"
table). The access is never dropped, so the dependency still covers everything the application
named. CLEAR only writes, and ALL_GRAPHICS holds no transfer stage, so transfer reads get ALL_TRANSFER.

vk_command_replay_test part D records all 360 D3D12 sync/access pairs as global, buffer and texture
barriers: 462 validation errors before, 0 after, on Intel(R) Graphics. d3d12_state_map_test checks
that stages only grow, accesses never change, and pairs Vulkan already accepts are left alone.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:42:05 +01:00
d27e4c5765 Runtime: ResolveSubresource and multisampled textures on Vulkan
There was no resolve, and a multisampled committed texture was refused.

- IR: ResolveSubresource (two different resources).
- Replay: ResolveSubresource is vkCmdResolveImage in the layouts copies
  use: a multisampled colour subresource into a single-sampled 2D one of
  the same size and format. Depth-stencil resolves and resolves between
  two formats of a typeless family stay unsupported. ResourceBinding gains
  samples: a multisampled texture copies only to its own sample count and
  has no footprint.
- Device: committed multisampled 2D textures (single-mip render targets or
  depth-stencils, when the GPU has the sample count for the format; the
  other shapes are E_INVALIDARG as in D3D12), and TEXTURE2DMS
  render-target and depth-stencil views.
- COM: ID3D12GraphicsCommandList::ResolveSubresource.

Tests: command_list_test (recording rules, and a copy with a z range);
vk_command_replay_test part C (a 4x resolve and the refused resolves and
multisampled copies; it also runs the volume copies that are already on
main at the Vulkan level, on Linux too: a 4x4x4 volume uploaded, copied as
a block and whole, read back, and the z ranges that must be refused);
d3d12_vulkan_device_test (a resolve through the Xbox-ABI proxy and the
refused shapes).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 16:34:22 -05:00
Ryx
6052bf0bd5 Runtime: rectangle clears, layout tracking, enhanced barriers, COM list/queue/fence
Closes the gaps left by the barrier/clear slice:

- Rectangle clears: ClearRenderTargetView/ClearDepthStencilView rects are
  recorded and replayed with vkCmdClearAttachments in a dynamic-rendering
  scope, clipped to the mip.
- LayoutTracker: the current Vulkan layout per image subresource, so barriers
  start from the real layout. This honours implicit promotion and decay
  (COMMON is GENERAL; simultaneous-access textures stay GENERAL) and, with
  separateDepthStencilLayouts, lets one depth/stencil plane be cleared or
  transitioned while the other stays in another state.
- Enhanced barriers (global, buffer, texture, split, discard) mapped to
  vkCmdPipelineBarrier2.
- vulkan_backend.h: VulkanContext, VulkanQueue (ExecuteCommandLists checks
  every list before writing any; Wait is attached to the next submission),
  VulkanFence on timeline semaphores.
- d3d12_com.cpp: ID3D12GraphicsCommandList7, ID3D12CommandQueue,
  ID3D12CommandAllocator and ID3D12Fence1. Unimplemented methods are stubs
  generated at build time from the SDK's d3d12.h (tools/gen_d3d12_stubs.py),
  so vtables follow the SDK order and nothing SDK-derived is checked in.

Tests: command_list_test and d3d12_state_map_test (every copied D3D12
constant checked against d3d12.h) in ctest; vk_command_replay_test and the new
d3d12_com_test on the GPU, clean under the Khronos validation layer.
2026-11-21 19:19:31 +01:00
Ryx
7f6e8f059d Runtime: D3D12 barriers and depth-stencil clears in the command-list IR
The IR (command_list.h, was clear_commands.h) now records transition, UAV and
aliasing barriers (split barriers record their end half) and full-view
ClearDepthStencilView next to ClearRenderTargetView.

vulkan_replay.h (was vulkan_clear.h) maps D3D12 resource states to Vulkan
layout/access/stage (section 4.3 table), decodes subresource indices including
depth/stencil planes, validates the whole list before emitting anything, and
wraps clears in a layout round trip so images stay in their D3D12 state. The
caller no longer manages layouts by hand.

Tests: command_list_test (recording rules), d3d12_state_map_test (state table,
subresource decoding, constants checked against d3d12.h; needs Vulkan headers
only) and vk_command_replay_test (GPU readback of colour, depth and stencil;
LEONIDA_VK_VALIDATION=1 runs it under the Khronos validation layer).
2026-11-21 18:58:48 +01:00