Commit Graph

6 Commits

Author SHA1 Message Date
489258fda5 Resolve colour MSAA regions into destination offsets 2026-11-22 00:05:17 +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
55af930bcc runtime: add public ID3D12GraphicsCommandList8 to the D3D12 proxy
The command list implements the SDK's GCL8 chain (IID ee936ef9-599d-4d28-938e-23c4ad05ce51), so a GCL8 QueryInterface succeeds and slot 81 (byte offset 0x288) is OMSetFrontAndBackStencilRef(UINT, UINT). The method records both values on the list and Reset clears them. Nothing applies them yet: Vulkan's dynamic stencil reference is per face, but only a pipeline that consumes it can, and the layer has no pipeline or draw path. The call is reported once rather than silently dropped.

d3d12_gcl8_test creates only an allocator and a list (no Vulkan device), checks the interface pointer, the raw slot 81 call, both recorded values and the QueryInterface reference count. It runs under CTest.
2026-11-21 20:30:33 +00:00
Ryx
99336386d1 Runtime: D3D12 copies on Vulkan (buffers, textures, uploads, BC) and GetCopyableFootprints
- IR: CopyBufferRegion, CopyTextureRegion (subresource or placed footprint,
  optional box) and CopyResource, with D3D12's call rules (512-byte footprint
  offsets, 256-byte pitches, non-empty boxes).
- Replay: vkCmdCopyBuffer / CopyBufferToImage / CopyImageToBuffer / CopyImage.
  Footprint pitch becomes bufferRowLength; BC extents stop at the mip edge;
  every range and buffer bound is checked before anything is written. Copies
  run in TRANSFER_SRC/DST, or in place in GENERAL for a COMMON texture
  (implicit promotion). 2D only.
- Device: buffers expose their VkBuffer; BC1-7 formats; textureCompressionBC
  enabled when present; GetCopyableFootprints for buffers and 2D textures.
  Compared with the PC runtime over 13 descriptions, which showed planar
  depth-stencil rows are padded to 512 bytes.
- Each submission ends with a barrier to the host so readback buffers hold the
  GPU's writes after the fence wait. BC textures are not zero-filled on first
  use (Vulkan cannot clear them; the validation layer caught the first try).

Tests: d3d12_vulkan_device_test now reads results back through D3D12
(CopyTextureRegion into a readback heap, Map) and adds an upload list: a
pattern into a texture, CopyResource into a COMMON texture, a boxed copy, a BC1
round trip and CopyBufferRegion. command_list_test covers the copy rules. All
GPU tests are clean under the Khronos validation layer; 6/6 ctest.
2026-11-21 20:33:34 +01:00
Ryx
40f6399088 Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy
- d3d12_vulkan_device.cpp: an ID3D12Device11 (PC ABI) the device proxy
  forwards to. Creates queues, allocators, command lists (incl.
  CreateCommandList1), fences, descriptor heaps (32-byte slots; RTV/DSV hold
  TargetViews), render-target and depth-stencil views, committed buffers
  (upload/readback mapped and zeroed) and 2D textures in the common formats,
  and answers feature-level and architecture queries. Everything else is a
  generated stub that logs once.
- First use of a new texture zero-fills it and moves it to the layout the
  command expects (vulkan_replay.h initialize), as D3D12 committed resources
  start zeroed; no submission at creation. CREATE_NOT_ZEROED skips the fill.
- Children hold the proxy, so GetDevice returns the Xbox-ABI object; COM base
  classes moved to d3d12_com_object.h. D3D12 queues share one VkQueue behind a
  submit lock.
- D3D12XboxCreateDevice: LEONIDA_D3D12=vulkan creates the Vulkan device on its
  own instance and wraps it in the same proxy (gta6rt built with the Vulkan
  SDK and Python 3); the host PC device stays the default.

Tests: d3d12_vulkan_device_test calls everything through the proxy (heaps via
slot 14 with RAX start handles, a render target via slot 76 with the Xbox
layout word) and reads colour, depth, stencil and a never-written texture
back; it also runs the standalone device. Clean under the Khronos validation
layer with the other GPU tests; all 6 ctest tests pass.
2026-11-21 20:22:20 +01: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