Commit Graph

26 Commits

Author SHA1 Message Date
fc2ee62c98 Merge pull request #1683 from requiemsnkrp 2026-11-22 11:40:37 -05:00
9cc95bff0d Runtime: GetCachedBlob and CachedPSO checks like the host runtime
ID3D12PipelineState::GetCachedBlob returns a blob with the adapter, driver, pipelineCacheUUID and a SHA-256 of the description (without Flags; shaders keyed by their DXBC checksum), sealed by a checksum. Create{Compute,Graphics}PipelineState check a supplied CachedPSO before creating the PSO and answer as the PC runtime does, measured on an RTX 3060 and WARP. Rebased onto main (one commit). AI-assisted.
2026-11-22 17:09:44 +01:00
54176d2a21 Merge pull request #1995 from unknown 2026-11-22 10:40:14 -05:00
8b310b2092 Merge pull request #1977 from Douglas Sposito 2026-11-22 10:40:03 -05:00
352b9af158 d3d12: map the six narrow signed IA vertex formats
vertex_format() mapped the unsigned and float variants of R16, R8G8 and R8 but not R16_SNORM, R16_SINT, R8G8_SNORM, R8G8_SINT, R8_SNORM or R8_SINT, so a PSO whose input layout used one was refused with E_INVALIDARG. Add the six rows and cover them in d3d12_draw_test: the SNORM formats use the float VS, the SINT formats an integer-input VS declared ivec4. The test fails on the old table at line 157 (format 58) and passes with the rows, with no validation messages on an RTX 3070.
2026-11-22 07:27:16 -08:00
ed25f93b8b Tests: wait for the bundle blend draws in d3d12_draw (fence 31, not 21) 2026-11-22 16:21:39 +01:00
569bd01d7e Runtime: blends into B8G8R8X8 targets read destination alpha 1 (D3D-240)
B8G8R8X8 has no alpha, and WARP and AMD's D3D12 driver blend into it with
destination alpha 1. Its Vulkan image is BGRA8, so the blend factors that
read destination alpha read the X byte instead. For B8G8R8X8 render
targets the PSO now turns DST_ALPHA into ONE, ONE_MINUS_DST_ALPHA into
ZERO and the colour SRC_ALPHA_SATURATE into ZERO, in the colour and alpha
factors alike.

d3d12_draw_test blends a full-screen pass into B8G8R8X8 and B8G8R8A8
targets cleared with alpha 0.25 through the five factors that read
destination alpha, and compares red, green and blue. The X byte is left
out: WARP writes 0 there after a draw and AMD the blended alpha, and no
view reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:20:23 -03:00
8ba7c8d552 Merge pull request #1793 from WHOISJARDAS 2026-11-22 09:15:23 -05:00
01a6176456 Tests: wait for the bundle blend draws in d3d12_draw (fence 21, not 4)
#1583's strip-cut passes leave the fence at 20, and #1660's bundle blend
block then signalled 4. SetEventOnCompletion(4) returns at once when the
fence has already passed 4, on native D3D12 too, so the check read the
readback buffer before the draws had run. It saw the last strip-cut
pass's red quad: "bundle blend pixel (0, 0): got 255,0,0,255, expected
red 64", on every GPU.

Signal 21 instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:11:01 +00:00
bdac6330ee Merge pull request #1591 from Vonsek 2026-11-22 08:38:07 -05:00
bb0ecfc089 Merge pull request #906 from AlxcBTW 2026-11-22 08:37:59 -05:00
79cd04d231 Merge upstream/main and enforce SampleDesc.Count > 0 and per-format MSAA limits
Addresses review feedback on #1591:
- Reject SampleDesc.Count == 0 (and > D3D12_MAX_MULTISAMPLE_SAMPLE_COUNT) with E_INVALIDARG instead of defaulting 0 to 1x.
- Intersect per-format sampleCounts via vkGetPhysicalDeviceImageFormatProperties for each configured color and depth/stencil attachment format, returning E_INVALIDARG when unsupported.
- Add negative PSO creation tests for SampleDesc {0,0}, {3,0}, {64,0}, {4,1}, {1,1}, and unsupported {32,0}.

AI Assisted.
2026-11-22 14:25:43 +01:00
44288b3033 Merge remote-tracking branch 'origin/main' into w-pso4
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/shaders/check.py
#	runtime/test/vk_test_device.h
#	scripts/run_gpu_tests.py
2026-11-22 14:19:31 +01:00
f5d31f02ae Merge pull request #1660 from Vonsek 2026-11-22 08:08:34 -05:00
0c7dd3bd66 Merge pull request #1650 from Vonsek 2026-11-22 08:08:28 -05:00
5f7caad4d5 fix(runtime): carry bundle blend factors back to parent draws 2026-11-22 14:00:44 +01:00
87295ddcd5 fix(runtime): align appended vertex inputs by format size 2026-11-22 13:56:05 +01:00
74d9a9073a fix(runtime): reject non-zero SampleDesc.Quality in graphics PSOs
The layer reports NumQualityLevels = 1 for every supported sample count, so only quality 0 is valid. Reject desc.SampleDesc.Quality != 0 with E_INVALIDARG and add regression checks for {4, 1} and {1, 1} in d3d12_draw_test.

AI Assisted.
2026-11-22 13:55:54 +01:00
8c35079690 Merge pull request #1583 from Vonsek 2026-11-22 07:38:22 -05:00
445f796eae fix(runtime): enable multisampled graphics pipelines (SampleDesc.Count > 1)
CreateGraphicsPipelineState previously rejected SampleDesc.Count > 1 with E_NOTIMPL and hardcoded rasterizationSamples = VK_SAMPLE_COUNT_1_BIT, even though multisampled render targets, RTVs and ResolveSubresource already work.

Validate power-of-two sample counts against the physical device's framebufferColorSampleCounts / framebufferDepthSampleCounts / framebufferStencilSampleCounts / framebufferNoAttachmentsSampleCounts limits, set VkPipelineMultisampleStateCreateInfo::rasterizationSamples from desc.SampleDesc.Count, and add a synthetic 4x MSAA draw + ResolveSubresource test in d3d12_draw_test with SampleMask = 0xFFFFFFFF and SampleMask = 0x5 (half-mask control).
2026-11-22 13:30:06 +01:00
432d9ab1eb fix(runtime): support IBStripCutValue via dynamic primitive restart
CreateGraphicsPipelineState previously logged that index-buffer strip cuts (primitive restart) were not modelled and left primitiveRestartEnable disabled.

Load Vulkan 1.3 vkCmdSetPrimitiveRestartEnable in vulkan_backend.h, declare VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE on graphics pipelines, record IBStripCutValue on GraphicsPipeline, and enable primitive restart during replay only for indexed strip topologies whose index format matches the PSO strip-cut value (0xFFFF with UINT16, 0xFFFFFFFF with UINT32). Add synthetic 16-bit/32-bit triangle-strip cut and no-cut negative-control GPU draw tests in d3d12_draw_test.
2026-11-22 13:25:06 +01:00
ec6645401d [TEST-200] Make M1 CTest skips accurate 2026-11-22 13:13:38 +01:00
7b88178d11 Runtime: request the translated subgroup size in compute and graphics PSOs
Device creation enables subgroupSizeControl and computeFullSubgroups where the
GPU has them and keeps minSubgroupSize, maxSubgroupSize, the default
subgroupSize, maxComputeWorkgroupSubgroups and requiredSubgroupSizeStages in
VulkanDeviceInfo::subgroup (also printed at creation). CreateComputePipelineState
and CreateGraphicsPipelineState run decide_subgroup_size() per stage and chain
the result into the stage create-info; the "wave64 compute shader runs
32-wide" log line goes away. A size the device cannot give is logged once per
stage with the first shader's name, and tells the build to use
--wave64-emulate where that exists (compute, mesh).

pipeline_subgroup_requests() exposes what each stage of a PSO asked for.
vktest::Device fills the same properties and the compute and draw tests pass
them on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:10 +01:00
Ryx
2aed144550 Runtime: second round of review fixes, and predication on arena buffers after the rebase onto main
From the reviews and test runs on #291:
- A pipeline without vertex bindings (a full-screen pass from SV_VertexID) no longer declares the vertex-stride
  dynamic state, which nothing would set (VUID-vkCmdDraw-pStrides-04913; aslan2142, AlxcBTW, ezwinxdlmao).
- Logic ops are applied from RenderTarget[0] instead of being logged and ignored (Vonsek's XOR case), and
  DepthClipEnable = FALSE is depth clamping (AlxcBTW). Both need their feature (logicOp, depthClamp), or the
  PSO is refused.
- The standalone device also enables shaderInt64, shaderFloat64, shaderInt16, shaderClipDistance and
  shaderCullDistance where the GPU has them (AlxcBTW, whattheflop: VUID-...-pCode-08740), plus logicOp and
  depthClamp.
- Among index entries for one program, a PSO takes the first that fits and declares no set-0 bindings, as
  pipelines do not bind set 0 yet. This covers the compute group in poke900310's corpus count, where an entry
  with 10 bindings shadowed a binding-free one.
- The command list holds a reference to every root signature and pipeline state it is given until Reset or
  its release, so releasing them right after Set* (as D3D12 allows) no longer leaves dangling layouts or drops
  the submission (AlxcBTW).

After the rebase onto main: main's SetPredication reads the predicate through the resource's VkBuffer, so a
default-heap buffer (a range of the GPU address arena) adds its offset in the arena, and the arena gets the
conditional-rendering usage when the extension is on (lahlousaad4's integration note).

Tests: d3d12_draw_test has a second pass with a full-screen triangle first in its submission and an XOR quad,
and a depth-clamp refusal. d3d12_compute_test releases its root signature and PSO right after setting them,
sets the signature again after the arguments, and has a bound entry ahead of the binding-free one in its
index. Each new fix, undone on its own, fails a test: pStrides-04913, wrong XOR pixels, a heap-corruption
crash without the hold, a refused PSO without the binding-free choice.

Documented as known gaps, not fixed here: wave64 subgroup size (AlxcBTW's follow-up in #313), cross-queue
waits on one VkQueue and CPU fence signals below a pending GPU signal (woreksami), and the linear buffer_at.
2026-11-22 05:01:36 +01:00
Ryx
8b711cc6b4 Runtime: fixes from CharlyRien's review of the compute and draw paths
Shader library
- fssm_program takes the last XDAT 0x0D payload, as tools/fssm_unpack.py does by default (195 of 26,503
  containers have two different ones, and fssm_sha256 is computed from the last).
- The JSON reader parses numbers with from_chars and \u escapes as exactly four hex digits, so a malformed
  index is refused instead of throwing into the shim. Integer fields outside 0..2^32-1 read as 0.
- Index entries that share a program are all kept; CreateGraphicsPipelineState takes the VS whose input
  signature the input layout feeds.

Command list
- Setting the root signature that is already bound keeps the root arguments, as D3D12 does.
- A draw with no viewport (never set, or RSSetViewports(0, ...)) or an empty one is not recorded: D3D12
  rasterizes nothing and Vulkan forbids a 0x0 viewport.
- More than eight render targets is an invalid call, in OMSetRenderTargets and in a PSO.

Device
- Buffers of 0 bytes, or with a size that wraps when aligned, are E_INVALIDARG. The arena refuses zero-size
  ranges, and its fit test cannot wrap.
- A shader-visible descriptor heap the arena cannot hold is E_OUTOFMEMORY instead of a host heap with GPU
  handle 0.
- A failed arena releases its buffer and memory, so other buffers do not get raw device addresses as VAs.
- Graphics PSOs that need independentBlend, fillModeNonSolid, depthBiasClamp or dualSrcBlend are refused
  unless VulkanDeviceInfo::features has them. The standalone device enables those the GPU supports.
- A draw that leaves a slot unbound where the PSO names a format uses a pipeline variant with that format
  undefined (built on first use, kept with the PSO), instead of breaking
  dynamicRenderingUnusedAttachments-08912.
- Instance step rate 0 reads element 0 for every instance (stride 0 at draw time).
- The Vulkan 1.0 graphics entry points are required; the 1.3 ones are checked before a graphics PSO is made.

Replay
- An unbound vertex slot, or an indexed draw with no index buffer, reads the arena's reserved first 64 KiB,
  which is kept zero, as D3D12 reads zeros. A view that runs past its buffer is cut at the buffer's end
  instead of failing the whole ExecuteCommandLists.
- The rendering layer count is the smallest layer count of the bound views.

Tests: shader_library_test covers two payloads, malformed JSON and duplicate programs. d3d12_draw_test
covers an unbound RT and DSV, a rebound root signature, step rate 0, an unbound vertex slot, a draw with no
viewport, the feature and count refusals, and bad buffer and heap sizes. Each of the rebind, step-rate and
variant fixes, undone on its own, makes the test fail.

Still open, documented: instance step rates above 1, read-only DSV layouts, and the index buffer's view size.
2026-11-22 05:01:36 +01:00
Ryx
1e7f5152ae Runtime: graphics pipelines and draws on Vulkan (milestone M1, D3D-4)
- CreateGraphicsPipelineState (PC slot 10): VS and PS found by the SHA-256
  of their FSSM programs in the translator's index. Input-layout elements are
  matched to the VS input signature by semantic name and index; location =
  the element's register (the translator's vertex-fetch rule); a layout that
  leaves an input unfed is refused, as D3D12 does. Rasterizer, blend and
  depth-stencil state map one to one; viewport, scissor, topology, vertex
  strides, stencil references and blend factor are dynamic; dynamic
  rendering takes the RTV/DSV formats. Hull/domain/geometry, stream output,
  MSAA, set-0 bindings and two code-base stages (question 14) are refused
  with a log.
- Command list: IASetPrimitiveTopology / VertexBuffers / IndexBuffer,
  RSSetViewports / ScissorRects (first of each), OMSetRenderTargets (views
  read at the call, single-range handles too), OMSetBlendFactor,
  OMSetStencilRef and CommandList8's front/back references (now applied),
  DrawInstanced / DrawIndexedInstanced recording a copy of that state.
  CreateCommandList's initial pipeline state is applied. Reset and
  ClearState share one state reset.
- Replay: vertex/index views resolve to buffers by VA (arena or upload),
  attachments move to attachment layouts through the tracker (first use
  zero-fills), the draw runs in a dynamic-rendering scope with a flipped
  viewport (translated VS write D3D clip coordinates), stencil references
  per face, then vkCmdDraw / vkCmdDrawIndexed. Render-target views take the
  pipeline's formats (the view cache keys on format).
- shader_library.h reads the index's input_signature and PS outputs.

Test: d3d12_draw_test (through the proxy) builds a VS+PS PSO whose input
layout order differs from the VS registers, uploads a vertex buffer into the
arena, reads indices from an upload heap, and draws two indexed quads with
different root constants and root CBVs plus a back-facing triangle: all 4096
read-back pixels match (which also checks the viewport flip and winding).
Shaders are GLSL written to the translator's contract. d3d12_com_test now
uses SetMarker as its unimplemented-method example, since DrawInstanced is
implemented. 13/13 ctest; all six GPU tests clean under the Khronos
validation layer.
2026-11-22 05:01:36 +01:00