Commit Graph

1118 Commits

Author SHA1 Message Date
aa5ff92859 Merge pull request #1696 from SHAURYASANYAL3 2026-11-22 08:38:31 -05:00
e2af5b7df7 Merge pull request #1674 from Serrambi 2026-11-22 08:38:19 -05: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
aee81b80ef Merge pull request #759 from Douglas Sposito 2026-11-22 08:37:59 -05:00
83160a8114 d3d12: handle 4x MSAA and invalid MSAA in tiled allocation queries (D3D-191) 2026-11-22 14:36:05 +01:00
1f71839aa3 runtime: fallback and clamp swapchain extent when surface reports undefined extent (D3D-165) 2026-11-22 18:59:51 +05:30
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
1b1d090e3c Merge pull request #1667 from romainveurrier 2026-11-22 08:08:38 -05:00
0c7dd3bd66 Merge pull request #1650 from Vonsek 2026-11-22 08:08:28 -05:00
6c655f92b7 Merge pull request #1614 from Vonsek 2026-11-22 08:08:10 -05:00
c26caf2f08 Merge pull request #1554 from Vonsek 2026-11-22 08:08:04 -05:00
a0c07b7c48 d3d12: support tiled placed textures (D3D-191) 2026-11-22 14:07:43 +01:00
1c58d6cfbc D3D12: BuildRaytracingAccelerationStructure writes XDXR BVH4 records
The game's translated RT shaders read the console's XDXR records, which a
VkAccelerationStructureKHR is not (docs/d3d12_vulkan.md 4.8). The standalone
Vulkan device now builds them with src/xdxr_build.h, unless LEONIDA_RT_AS=khr
keeps #743's KHR builds (the proposal in the maintainer decisions of #1548).

- VulkanDeviceInfo::xdxr_acceleration_structures; the standalone device sets
  it with bufferDeviceAddress and then leaves the KHR extensions off, so
  acceleration-structure buffers keep their console VAs.
- VulkanContext owns an XdxrBuilder; replay checks the inputs while the list
  is prepared (R32G32B32/R32G32 vertices, none/R16/R32 indices, addresses,
  counts) and records the build with heap_base added to every VA and as the
  bias for instance BLAS addresses.
- GetRaytracingAccelerationStructurePrebuildInfo answers from XdxrLayout,
  exactly; an update rebuilds, so it needs the same scratch.
- The geometry's vertex format is mapped per DXGI format (an unknown one is
  refused instead of read as R32G32B32), and its D3D12 flags reach the build.
- test/d3d12_xdxr_rt_test.cpp: a two-geometry BLAS (a soup; an R16-indexed
  grid with stride 16 and a transform) and a TLAS of three instances through
  the D3D12 API; ctest d3d12_xdxr_rt + d3d12_xdxr_rt_check.
- tools/xdxr_bvh.py: check-build compares TLAS hits by (geometry, primitive),
  and skips (77) when the build step wrote no cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:04:34 +01:00
b576c75ad2 Runtime: B8G8R8X8 textures as BGRA8 images, views read alpha 1 (D3D-87)
Map B8G8R8X8_UNORM, _UNORM_SRGB and _TYPELESS to the B8G8R8A8 Vulkan formats, so
creation, copies, footprints and clears work as for BGRA8. Shader views of the family
read alpha as 1 (the T# selects one for the alpha channel), and views between the
B8G8R8X8 and B8G8R8A8 typeless families are refused, although both land on the same
VkFormat.

Compared with the host D3D12 runtime on an RX 9060 XT: it reports no typed UAV for the
family and refuses typed B8G8R8X8 textures that allow unordered access (the typeless
format is accepted). The BGRA8 image would have advertised storage, so
CheckFeatureSupport now leaves the typed UAV bits out, texture creation refuses typed
B8G8R8X8 with ALLOW_UNORDERED_ACCESS, CreateUnorderedAccessView gives a null descriptor
for the family, and its images get no storage usage. WARP writes the clear's alpha into
the X byte, as Vulkan does, so clears need no change.

Tests: d3d12_clear_test clears B8G8R8A8_UNORM and B8G8R8X8_UNORM against WARP;
d3d12_vulkan_device_test compares B8G8R8X8 footprints, the typed UAV bits and UAV/RTV
resource creation with the host runtime; d3d12_descriptor_test samples a B8G8R8X8 and a
B8G8R8A8 texture with the same bytes through the bindless set (alpha 1 against the
stored byte) and checks the refused views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:03:51 -03: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
6eb5bce392 runtime: accept a Vulkan 1.2 device with the dynamic rendering and synchronization2 extensions
The D3D12 layer and its GPU tests took only Vulkan 1.3 devices, for dynamicRendering and synchronization2.
CrossOver's MoltenVK on macOS (1.2.10, the driver its Wine uses) is Vulkan 1.2 with VK_KHR_dynamic_rendering
and VK_KHR_synchronization2, the same features under their extension names, so every Vulkan-backed test
skipped there. src/vulkan13_features.h picks the core features on 1.3 and the two extensions on 1.2, and
device_proc_or_khr falls back to the ...KHR entry points (vkCmdPipelineBarrier2KHR, vkCmdBeginRenderingKHR),
which a 1.2 device serves instead of the core names. The translated shaders are SPIR-V 1.5 validated for
Vulkan 1.2 already. On a 1.3 device the feature chain is the one it was.

Tested in a CrossOver Preview arm64 bottle (FEX) on an Apple M2 Max, cross-built with clang-cl 22.1.8 and
xwin: against main at the same commit, no test that passed fails, and d3d12_com, d3d12_multithread,
d3d12_method_variants, d3d12_uav_clear, d3d12_debug_markers, d3d12_fence_timing, d3d12_sampler2,
d3d12_typeless_rtv, d3d12_predicated_copy and depth24_convert now run and pass. Ten more now run and
fail: comparisons with Wine's host D3D12, and MoltenVK 1.2.10 limits (vk_binary_occlusion and
vk_overlapping_occlusion fail the same way natively on that driver and pass on MoltenVK 1.4.2). The
1.3 path of create_vulkan_device_standalone was not run on a 1.3 device here.

AI-assisted. No game files.
2026-11-22 12:54:04 +00:00
08986b18c8 Merge remote-tracking branch 'upstream/main' into ag/d3d12-volume-min-lod
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/d3d12_descriptor_test.cpp
2026-11-22 13:39:39 +01:00
c3975165ac fix(runtime): allow native RGB9E5 multisample resolves 2026-11-22 13:38:38 +01:00
8c35079690 Merge pull request #1583 from Vonsek 2026-11-22 07:38:22 -05:00
0dd6bb051c Merge pull request #1569 from Vonsek 2026-11-22 07:38:16 -05:00
f3e6d5a9b4 Merge pull request #1523 from AlxcBTW 2026-11-22 07:38:02 -05:00
11380bbbd6 Merge pull request #1511 from zneel 2026-11-22 07:38:00 -05:00
12eab0b570 Merge pull request #1489 from AlxcBTW 2026-11-22 07:38:00 -05:00
814e506179 Merge pull request #558 from omar-akermi 2026-11-22 07:37:53 -05:00
d63d9c9a05 Merge origin/main into pso-subgroup-size-v2
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:34:03 +01: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
7ec6e3ecfe d3d12 FORMAT_SUPPORT: depth formats are not UAVs
NVIDIA gives VK_FORMAT_D32_SFLOAT and D16_UNORM STORAGE_IMAGE, so the
layer reported typed UAVs (and now typed loads) for D32_FLOAT and
D16_UNORM on an RTX 3070 where native D3D12 reports none (found by
@Parakeet-Wheat, review by @Flyander). The depth cleanup clears the
typed-UAV bit and every Support2 bit, and the host comparison's depth
check now covers TYPED_UNORDERED_ACCESS_VIEW and Support2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:24:48 +01:00
17d0861c34 d3d12 FORMAT_SUPPORT: review fixes; the test catches over-claims
From two reviews of #1511:
- Depth formats drop TEXTURE1D: the layer refuses 1D depth-stencil
  resources (native D3D12 allows them).
- The depth MULTISAMPLE_RENDERTARGET query uses the same usages as
  MULTISAMPLE_QUALITY_LEVELS and resource creation.
- R9G9B9E5's emulated UAV reports typed load with store, like the rest.
- Comments and docs say what works today: typed UAV texture reads go
  through the sampled binding; typed buffer UAVs share the store side's
  gaps (no buffer UAV views, rdna2spirv FORMATS); R32_UINT atomics work
  on 2D UAVs only.
- compare_format_support only runs against a host on the same adapter,
  lists the formats the layer answers with no uses instead of skipping
  them silently, needs at least 40 compared formats, and checks
  over-claims: MIP and atomics the host lacks, atomics outside
  R32_UINT/R32_SINT, sampling integer formats, and multisample render
  targets that disagree with MULTISAMPLE_QUALITY_LEVELS. A layer with
  injected atomics, multisample and integer-sampling over-claims fails
  it with 128 mismatches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:23:02 +01:00
cb33e81b04 Runtime: invalid-argument HRESULTs as the host runtime (D3D-49)
CreateCommittedResource, CreateDescriptorHeap, CreateCommandQueue, CreateFence
and Map now return the host PC runtime's HRESULTs for invalid arguments.
compare_invalid_arguments in d3d12_vulkan_device_test checks the invalid
descriptions and their valid neighbours, plus ALLOW_RENDER_TARGET and
ALLOW_DEPTH_STENCIL on every format both devices create, against the host
device.

On main the new test found 25 mismatches in its first 55 cases (invalid
heap properties and flags, buffer layouts, upload/readback states, clear
values and texture flags accepted; two access violations, on a zero-width
buffer and a zero-size texture array), then the process died creating a
2049-layer texture. main also refused zero-descriptor heaps and answered
E_POINTER where the host treats a null output as a capability check.

CreateDescriptorHeap answers a null output before its flag, type and node
rules, as the host does; committed resources and fences check their
arguments first. A GPU_UPLOAD heap is refused, matching the layer's
OPTIONS16.GPUUploadHeapSupported FALSE; the test compares that case only on
a host without GPU upload heaps (Resizable BAR off).

CreateCommittedResource accepts a sample quality on a single-sampled texture
and the two standard MSAA patterns, as the host does.

The flag and format rules were measured on an RX 9070 XT, an integrated Radeon
GPU and WARP. Answers that differ between them, or that the layer can't follow,
are not compared and are listed in docs/d3d12_vulkan.md. Each new refusal is
logged once with its reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:19:56 +01:00
bf7014999a fix(runtime): enable VkSamplerReductionModeCreateInfo for MIN/MAX samplers
sampler_descriptor() already encodes D3D12_FILTER_REDUCTION_TYPE_MINIMUM and MAXIMUM into the S# filter_mode and gfx10_descriptors.h already provides vulkan_reduction_mode(), but bind_sampler() ignored it and logged that minimum/maximum samplers blend for now.

Enable Vulkan 1.2 samplerFilterMinmax in device creation and vk_test_device.h, chain VkSamplerReductionModeCreateInfo in bind_sampler() when supported and not combined with compareEnable (falling back to blend with a log otherwise), update docs/d3d12_vulkan.md, and add a synthetic 2x2 GPU sampling test in d3d12_descriptor_test comparing MINIMUM, MAXIMUM, and STANDARD (negative control) linear filters.
2026-11-22 13:18:40 +01:00
564eb48c8e fix(runtime): apply ResourceMinLODClamp to sampled 3D volume views
Texture3D SRVs already encode ResourceMinLODClamp into the T# descriptor, but image_descriptor() rejected non-zero clamps and bind_image() only applied VK_EXT_image_view_min_lod / empty-mip-set swizzle zeroing to 2D, 2D-array and cube colour views.

Allow non-zero ResourceMinLODClamp on sampled 3D colour views, forward the T# clamp to Vulkan in bind_image(), update docs/d3d12_vulkan.md, and add synthetic GPU sampling and negative-control checks in d3d12_descriptor_test.
2026-11-22 13:12:54 +01:00
48a8d23be0 Merge pull request #1511 from zneel 2026-11-22 07:07:58 -05:00
a4801cf9ed Merge pull request #1493 from Dominik 2026-11-22 07:07:54 -05:00
bffad8677a Merge pull request #1478 from Vonsek 2026-11-22 07:07:49 -05:00
9b60294e28 Merge pull request #1324 from lloyd 2026-11-22 07:07:45 -05:00
a9bab0cf30 Subgroup size: keep the required-size structs in the PSO recipe, judge ps_w64x_readlane only where 64 was required, register d3d12_subgroup
The graphics stage infos chain structs that variants built at draw time still read. d3d12_subgroup_test builds its V# with OOB_SELECT 3. check.py and run_gpu_tests.py skip the wave64 pixel fixture where the fragment stage could not be required 64-wide (vk_harness says so). d3d12_subgroup is registered with ctest and exits 77 without a Vulkan device.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:05:57 +01:00
2e7d374cb4 M2: drop pre-#291 leftovers so the branch diff is only M1.5 + M2 on main
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:05:52 +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
5529697596 Merge origin/main (landed #291) into m2-textured-draw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:04:28 +01:00
248ad95f6e Merge remote-tracking branch 'origin/main' into presentx-immediate-threshold
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-22 13:00:50 +01:00
c03b573a16 PresentX tear: review fixes
- find_tear_mode rejects a mode whose surface caps lack the swapchain's image usage or extent.
- present_timing: a repeated or stale token is never late.
- percent_scanned is measured at commit, so it agrees with the display time.
- The "no effect" log distinguishes the kill switch from a missing extension or mode.
- LEONIDA_PRESENT_NO_TEAR is read with _dupenv_s: any non-empty value but "0" disables.
- xbox_present_test: the real-time comment is back where it belongs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:00:38 +01:00
6728a00c2a PresentX: implement ImmediateThresholdPercent with VK_KHR/EXT_swapchain_maintenance1
A frame presented after the vblank it was due at is flipped at once (IMMEDIATE, else
FIFO_RELAXED) when the scan would be within the threshold percentage of the screen,
instead of waiting a whole interval. The decision is the pure
leonida::decide_present_sync(late_us, interval_us, threshold); FramePacer reports the
lateness against the vblank after the token's origin and records the tear in
GetFrameStatisticsX (PercentScanned) and immediate_presents().

VulkanPresenter creates a vsync swapchain with FIFO plus the tear mode when the surface
lists it as compatible (VkSurfacePresentModeCompatibilityKHR) and chains
VkSwapchainPresentModeInfoKHR on a tearing present. The device enables the KHR (else EXT)
extension, its feature and the matching instance extensions only where present; without
them the threshold is ignored and logged once, as before. LEONIDA_PRESENT_NO_TEAR=1 turns
it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:54:49 +01:00
00d9634ac7 d3d12 FORMAT_SUPPORT test: integer resolves only; guard the depth MSAA query
Which float formats resolve is up to the GPU (the RX 9070 XT's driver
reports no R9G9B9E5 resolve, WARP does), so the host comparison only
checks the rule the layer implements: no resolve of UINT/SINT formats.
The depth-stencil multisample query checks image_format_properties like
the other calls do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:46:48 +01:00
196d200242 d3d12: D24 format support and MSAA levels describe the D32 image creation makes
On a GPU without Vulkan D24_UNORM_S8_UINT (AMD), a D24 texture is a D32_SFLOAT_S8_UINT image (#737), but
CheckFeatureSupport answered from the D24 format itself: FORMAT_SUPPORT gave Support1 = 0 for
D24_UNORM_S8_UINT and R24G8_TYPELESS, and MULTISAMPLE_QUALITY_LEVELS gave 0 levels for R24G8_TYPELESS at
every count, while CreateCommittedResource(ALLOW_DEPTH_STENCIL) succeeded (found by @zneel, #1380 item 2).

- FORMAT_SUPPORT queries D32_SFLOAT_S8_UINT when the format resolves to D24 and the device can't use D24.
- MULTISAMPLE_QUALITY_LEVELS takes the creation path for typeless formats that are only valid as depth.
- d3d12_d24_support_test checks the layer against itself on any GPU: DEPTH_STENCIL is reported exactly when
  a 1x depth-stencil texture is created, and a quality level exactly when a 2x/4x/8x one is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:43:54 +00:00
810acc75fe Merge origin/main into m2-textured-draw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:42:47 +01:00
9a08a6d706 d3d12: FORMAT_SUPPORT follows D3D12's per-format rules
The layer turned Vulkan feature bits straight into D3D12 support bits. On an
RX 9070 XT that disagreed with native D3D12 on the same adapter in 169
reported-but-absent bits and 761 absent-but-native ones. This change only
reports what the layer provides:

- UAV_TYPED_LOAD with every typed UAV (reads use the sampled binding), not
  from STORAGE_IMAGE_ATOMIC; the UAV atomic bits other than exchange for
  R32_UINT, the format with the r32ui storage view
- MIP where the image can have mips; SHADER_GATHER with SHADER_SAMPLE;
  MULTISAMPLE_RENDERTARGET for depth formats
- no integer MULTISAMPLE_RESOLVE, no 1D block-compressed, no 3D or shader
  reads of depth formats, and TYPELESS formats report only texture
  dimensions and MIP

d3d12_vulkan_device_test compares these format-defined bits with native
D3D12 on the same adapter: 0 mismatches over 78 formats with this change,
249 on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:42:00 +01:00