Commit Graph

73 Commits

Author SHA1 Message Date
b358f4788b Tests: heap properties, residency and typeless depth check the layer on its own (TEST-WINE-HOST-GUARDS)
With no host to compare with (no host device, or Wine's), d3d12_heap_properties and d3d12_residency only printed
the layer's record, so a wrong answer of the layer still passed, and d3d12_typeless_depth exited 77 without looking
at the layer at all. Each now checks the layer by itself, on every host, before any comparison:

- d3d12_heap_properties: for every committed or placed resource the layer created, GetHeapProperties succeeds
  with both outputs, with the properties alone and with the flags alone, Type is the heap type it was created
  with (for a custom heap the CPU page property and memory pool too), and a call asking for one output reports
  what the call asking for both does. For a reserved resource the call fails.
- d3d12_residency: no call raises an exception, the plainly valid calls succeed, the device is never removed, and
  after EnqueueMakeResident the fence holds the value asked for (or stays put for a lower one, or after a failure).
- d3d12_typeless_depth: the layer's readback has to hold the cleared depth and stencil at every texel. Under Wine
  that is now the whole check and the test passes instead of exiting 77; elsewhere it runs before the comparison
  with WARP.

With LEONIDA_D3D49_VERBOSE=1 the first two print the layer's record when there is no host. dxgi_swapchain says
why it compared nothing under Wine instead of "no host D3D12 device".

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 10:42:39 -06:00
ffce6b5c39 Tests: eight host-comparison tests skip Wine's host and still check the layer (TEST-WINE-HOST-GUARDS)
d3d12_noop_copy, d3d12_indirect_dispatch_count, d3d12_typeless_depth, d3d12_residency, d3d12_heap_properties,
dxgi_swapchain, dxgi_host_parity and dxgi_waitable_latency compared the layer with the host's D3D12/DXGI without
the host_wine.h guard the other host-comparison tests use. Under Wine that host is vkd3d and Wine's own DXGI, so
all eight failed on its answers, two of them in a page fault inside wined3d/dxgi, and three before the layer's own
checks ran.

Under Wine the host comparison is now skipped: the tests whose every case is a host comparison exit 77, and the
others go on to check the layer. d3d12_indirect_dispatch_count also names a D3DCompile failure of its reference
shader instead of exiting 1 without a word. On Windows the tests run as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 04:11:27 -06:00
3746bff239 dxgi: SetSourceSize checks the requested size after a failed ResizeBuffers; the comparison treats DXGI_STATUS_OCCLUDED as S_OK
Review by @KarolKurzyna in the original repository:
- The host answers DXGI_STATUS_OCCLUDED from Present for a window that isn't on screen, which depends on the
  desktop, so compare_failed_resize now counts it as S_OK. The failures stay strict.
- After a failed ResizeBuffers the host checks SetSourceSize against the size that was asked for (RTX 3060 Ti:
  after 16x16385, 100x10 is DXGI_ERROR_INVALID_CALL; after 16385x16 it is S_OK), so the layer does too. The
  comparison gains those two steps (17 now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:16:48 +03:00
a3090aab2d dxgi: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host
Measured against the host runtime (RTX 3060 Ti, NVIDIA 610.88, and WARP): once ResizeBuffers accepts its arguments
the old buffers are gone. If the new ones can't be made it fails, and the swap chain stays without buffers. GetDesc1
already reports the requested size and count, GetBuffer and Present are DXGI_ERROR_INVALID_CALL, and the next
successful ResizeBuffers restores everything. A side above 16384 is E_INVALIDARG on the hardware device. A call
refused for its arguments (a back buffer still held) changes nothing.

The layer answered E_FAIL and kept describing the old buffers. It now answers E_INVALIDARG for a side above 16384
before calling Vulkan (it used to pass the extent to vkCreateImage, past the device's limits) and E_OUTOFMEMORY when
Vulkan fails. It reports the requested description, refuses Present, and recovers on the next ResizeBuffers.

dxgi_swapchain_test compares 15 steps of that with the host's default adapter. dxgi_swapchain_count_test gets
failure injection on its fake Vulkan table: whether the offscreen ring or vkCreateSwapchainKHR fails (the latter
retires the old swapchain anyway), on the offscreen and on the direct path, the next resize builds a working
swapchain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:16:33 +03:00
dbadb08b15 dxgi: the adapter answers IDXGIAdapter4; GetRestrictToOutput, ResizeBuffers flags and null out-pointers answer as the host does
Measured against the host runtime's DXGI on an RTX 5070 Ti and on WARP (Windows 11), both agreeing:

- The adapter answers IDXGIAdapter4. GetDesc3 gives what GetDesc1 gives, plus the
  preemption granularities; a null description is E_INVALIDARG.
- GetRestrictToOutput on a swap chain created without an output is S_OK with a null
  output, not DXGI_ERROR_NOT_FOUND.
- ResizeBuffers refuses NONPREROTATED, FULLSCREEN_VIDEO and every bit from 0x4000 up
  with DXGI_ERROR_INVALID_CALL, and FOREGROUND_LAYER, YUV_VIDEO and 0x2000 on a chain
  created without them with E_INVALIDARG (a sweep of all 32 bits on the host).
- A null out-pointer on GetBuffer, GetHwnd, GetLastPresentCount and GetRestrictToOutput
  is DXGI_ERROR_INVALID_CALL, not E_POINTER or E_INVALIDARG.

dxgi_host_parity_test compares the layer with the host for each of these (PROBE_WARP=1
for WARP): 18 of 26 rows differ before, 0 after, on both. dxgi_device_test and
dxgi_swapchain_test now expect the host's answers.

AI-assisted: yes
2026-11-23 15:47:27 -06:00
55200be11e dxgi_device, dxgi_swapchain: skip what needs a desktop when the process has no interactive window station (#6301)
Squash-merged after review of PR #6301 - dxgi_device, dxgi_swapchain: skip what needs a desktop when the process has no interactive window station
2026-11-23 08:16:35 -06:00
e2ac2238fa Runtime test clashes: typeless clears accept WARP's nearest-even tie (#521), three close-parity copies now match WARP, the source-size checks start from 300x200 again after ResizeTarget, one test_attribute_trace in xmem_test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:41:22 -05:00
c250b58580 Merge pull request #4273 from Exopus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:13:01 -05:00
d61dfe2b6e Merge pull request #4260 from Exopus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:12:52 -05:00
8f31de661d Merge pull request #3283 from kapitche
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:07:08 -05:00
0fd05a431a Merge pull request #2976 from nightsale
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:32 -05:00
608707c625 Merge pull request #2808 from bobcatchris
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:10 -05:00
5b3eb785cb DXGI: RegisterStereoStatusWindow/Event return S_OK with a cookie
Both returned E_NOTIMPL, which Microsoft documents only for the Windows 7 Platform Update. They now return S_OK with a unique cookie for UnregisterStereoStatus; stereo is never enabled so nothing is notified. Test: dxgi_swapchain.
2026-11-22 19:42:00 -05:00
e27efbc11d dxgi: CheckInterfaceSupport reports the adapter's real UMD driver version
IDXGIAdapter::CheckInterfaceSupport(IDXGIDevice) reported a user-mode
driver version of 0. Host DXGI reports the adapter's, which titles read
as the driver version. The layer now reads it the way DXGI does,
D3DKMTOpenAdapterFromLuid + D3DKMTQueryAdapterInfo(
KMTQAITYPE_UMD_DRIVER_VERSION) on the adapter's Vulkan deviceLUID,
looked up from gdi32 at run time (0 kept when missing or failing, e.g.
under Wine); the host dxgi.dll isn't used. Measured equal to host DXGI
on an RTX 5060 Ti (0x0020000000100842, driver 621.14) and on WARP.

dxgi_swapchain_test compares it with the host adapter of the same LUID
(host dxgi.dll loaded at run time); fails on main with 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:28:55 +01:00
429edff313 dxgi: Set/GetMatrixTransform answer DXGI_ERROR_INVALID_CALL, as on the host
IDXGISwapChain2::SetMatrixTransform/GetMatrixTransform stored and
returned a matrix on every swapchain. A matrix transform belongs to
composition swapchains (CreateSwapChainForComposition, E_NOTIMPL in the
layer); host DXGI answers DXGI_ERROR_INVALID_CALL to both on an HWND
swapchain, with a matrix and with null (Windows 11, RTX 5060 Ti, driver
621.14). Both now give that answer, and the stored matrix goes.

dxgi_swapchain_test asserted the round-trip; it now checks the host's
answer for the four calls (fails on main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:24:19 +01:00
e17bea316f dxgi: SetSourceSize stores the source region and refuses one too large
SetSourceSize answered S_OK and ignored its arguments, and GetSourceSize always
reported the back-buffer size, so a game that scales its source region could not
read back what it set.

Host-measured on Windows 11 with the system DXGI (RX 7900 XTX): a fresh
swapchain reports the back-buffer extent; SetSourceSize(64,32) round-trips while
GetDesc1 keeps the buffer size; a region larger than either buffer dimension is
DXGI_ERROR_INVALID_CALL and keeps the stored value; zero is accepted and stored;
GetSourceSize needs both pointers; and ResizeBuffers resets the source size to
the new back-buffer extent.

Present still does not scale by the source region; that stays a documented
difference and is not part of this change.
2026-11-22 17:37:54 -06:00
1ae9cee10a dxgi: implement Adapter::EnumOutputs and IDXGIOutput6 (D3D-313)
- Upgrade dxgi_com.h to dxgi1_6.h for IDXGIOutput6 / DXGI_OUTPUT_DESC1.
- Enumerate Win32 monitors via EnumDisplayMonitors / EnumDisplaySettingsW with headless 1920x1080@60 fallback.
- Implement Output (IDXGIOutput..IDXGIOutput6) and wire Adapter::EnumOutputs and SwapChain::GetContainingOutput against host dxgi.dll behavior.
- Add D3D-313 unit and host-comparison coverage in dxgi_swapchain_test.cpp (synthetic, no game data).

AI-assisted.
2026-11-22 23:10:03 +01:00
50d4f46fcf Merge pull request #3597 from Kam471
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 17:02:56 -05:00
78183db304 Merge pull request #3531 from Ewann 2026-11-22 17:02:34 -05:00
3c0aa65071 Merge pull request #3280 from kapitche 2026-11-22 17:01:13 -05:00
dac96d2d65 DXGI: CreateSwapChainForHwnd checks MSAA, buffer count and format before the size, like the host
A description with width 16385 and MSAA 4, one buffer or a bad format is
DXGI_ERROR_INVALID_CALL on the host runtime's DXGI, not E_INVALIDARG
(found by Kam471 in the review of #3531). Five multi-fault cases added
to the side-by-side comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:37:10 +01:00
96830e58f2 dxgi: keep BufferCount at the app's request when Vulkan's native count differs (D3D-389)
Vulkan may return more images than minImageCount, and caps.minImageCount can exceed the requested count, but GetDesc/GetDesc1 must report the app's BufferCount and GetCurrentBackBufferIndex must stay inside it.

When the native count differs, expose a stable offscreen ring of exactly the requested size and blit the current slot into the acquired native image at present; direct native mapping is unchanged when the counts agree. Add a fake-Vulkan regression test (extra native images, min above request, request above min) and DXGI-level desc/index assertions.
2026-11-22 21:01:27 +00:00
e62744353b DXGI: CreateSwapChainForHwnd refuses what the host runtime's DXGI refuses
Measured on RTX 5070 / 621.14: bitblt effects, window-incompatible
scaling and alpha modes, flags outside 0x2/0x20/0x40/0x800/0x1000/0x2000,
shared/read-only/discard-on-present/UAV usage, a null or non-queue
device, null window/description/output are DXGI_ERROR_INVALID_CALL; a
side above 16384 is E_INVALIDARG. dxgi_swapchain_test compares 40
descriptions with the host. The CoreWindow path keeps its old checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:27:31 +01:00
e66a9c71c5 Merge pull request #3284 from kapitche 2026-11-22 15:16:40 -05:00
3ac9743ce8 Merge pull request #3268 from Ryderadzeee 2026-11-22 15:16:21 -05:00
237d590237 Merge pull request #3259 from Vyral1978 2026-11-22 15:16:16 -05:00
ec6847a7f7 Merge pull request #2974 from Ryderadzeee 2026-11-22 15:13:43 -05:00
cb32d2d942 Merge pull request #2876 from Ryderadzeee 2026-11-22 15:12:48 -05:00
9a507b063d Merge pull request #2822 from bobcatchris 2026-11-22 15:12:19 -05:00
64272954c2 Merge pull request #2791 from bobcatchris 2026-11-22 15:12:01 -05:00
1d2d67dc37 DXGI: keep IDXGIObject private data on the factory, adapter and swapchain
SetPrivateData, SetPrivateDataInterface and GetPrivateData accepted the data and discarded it, so GetPrivateData always returned DXGI_ERROR_NOT_FOUND. They now store a copy of the bytes, hold a reference for an interface until it is replaced or removed, and answer DXGI_ERROR_MORE_DATA for a buffer that is too small. Test: dxgi_swapchain.
2026-11-22 15:11:35 -05:00
b62a30c37c DXGI: RegisterVideoMemoryBudgetChangeNotificationEvent succeeds with a cookie
The method returned E_NOTIMPL and a zero cookie. It now returns S_OK with a unique cookie for UnregisterVideoMemoryBudgetChangeNotification; the budget is recomputed on every QueryVideoMemoryInfo, so the event is never signalled. Test: dxgi_swapchain.
2026-11-22 14:58:20 -05:00
bdf052a2d8 DXGI: match native waitable swapchain frame latency limits 2026-11-22 23:57:08 +04:00
afd0d4c622 dxgi: IDXGIFactory6 and IDXGIFactory7 on the Vulkan factory (D3D-2)
CreateDXGIFactory2(IID_IDXGIFactory7) and QueryInterface for
IDXGIFactory6/7 failed on the layer's factory, which stopped at
IDXGIFactory5.

- EnumAdapterByGpuPreference returns the one Vulkan adapter at index 0
  for every preference.
- RegisterAdaptersChangedEvent / UnregisterAdaptersChangedEvent keep a
  cookie registry. The adapter list never changes, so the event is
  never signalled.

Every return code follows the host dxgi.dll, measured on Windows 11
with an RTX 3070:
- a preference outside the enum is accepted;
- a null out is DXGI_ERROR_INVALID_CALL;
- past the end is DXGI_ERROR_NOT_FOUND with *out cleared;
- a non-adapter riid is E_NOINTERFACE;
- a null event or cookie, and an event registered twice, are
  DXGI_ERROR_INVALID_CALL;
- cookies start at 1 and are separate from the occlusion cookies;
- an unknown cookie is DXGI_ERROR_NOT_FOUND.

dxgi_swapchain_test checks each answer. With main's factory it fails
at QueryInterface(IDXGIFactory6/7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:55:41 +01:00
32fc04a14e dxgi: MakeWindowAssociation refuses unknown flag bits
The factory answered S_OK for every flags value, while the host rejects anything
outside DXGI_MWA_NO_WINDOW_CHANGES, DXGI_MWA_NO_ALT_ENTER and
DXGI_MWA_NO_PRINT_SCREEN with DXGI_ERROR_INVALID_CALL (measured on Windows 11
with the system DXGI), so an invalid call looked accepted. Reject unknown bits
before recording the window, and cover the accepted combinations and two unknown
bits in the swapchain test.
2026-11-22 13:40:33 -06:00
7b8eed6f21 dxgi: ResizeTarget resizes a windowed swapchain's client area
ResizeTarget answered S_OK and ignored its argument, so a windowed game that
switches resolution through the DXGI 1.0 path kept the old window: the host
moves the target's client area to the mode's Width x Height and leaves the back
buffers alone until ResizeBuffers (where 0 means the new client area).

Measured on Windows 11 with the system DXGI (RX 7900 XTX): ResizeTarget(nullptr)
is DXGI_ERROR_INVALID_CALL, ResizeTarget(0x0) is accepted and the window's
minimum tracking size decides the result, ResizeTarget(234x156) gives a 234x156
client area with the buffers at 128x128, and ResizeBuffers(0, 0, 0) then takes
234x156. The swapchain test now covers the same sequence on the shim.
2026-11-22 13:40:31 -06:00
ed8528885b Validate DXGI ResizeBuffers1 node masks and presentation queues 2026-11-22 22:59:57 +04:00
4f4cc860ad Match DXGI on an out-of-range GetBuffer index 2026-11-22 22:34:58 +04:00
900473fcce Merge pull request #2343 from edupode 2026-11-22 13:14:02 -05:00
fd9bc14131 dxgi: return DXGI_STATUS_OCCLUDED on CreateSwapChain fullscreen fallback and add test 2026-11-22 23:12:44 +05:30
342eef5eb5 dxgi: match native DXGI INVALID_CALL for CreateSwapChain params and E_NOINTERFACE on Factory::GetParent 2026-11-22 23:12:44 +05:30
7ec740b9be dxgi: implement Factory CreateSwapChain delegation, GetParent, and SwapChain GetCoreWindow/GetRestrictToOutput 2026-11-22 23:12:43 +05:30
bec58c9aac fix: return parent device from DXGI swapchain 2026-11-22 16:40:23 +00:00
cd63047345 Merge pull request #1940 from Ryderadzeee 2026-11-22 10:39:35 -05:00
28ef599619 Runtime: pick the Vulkan GPU by the harnesses' rank (native over Dozen)
The runtime's standalone device (d3d12_vulkan_device.cpp) still took
"the first usable device, replaced by every later discrete GPU". #915
fixed that rule in the test harnesses because Mesa's Dozen (Microsoft
vendor 0x1414, "Microsoft Direct3D12 (<gpu>)") reports a discrete GPU, so
on a PC with the OpenCL/OpenGL/Vulkan Compatibility Pack the runtime
could run on the Vulkan-on-D3D12 wrapper while the tests used the native
driver. Even without Dozen, on a two-dGPU PC the runtime took the last
GPU and vk_test_device.h the first.

- runtime/src/vulkan_device_filter.h: vulkan_device_rank() (native over
  Microsoft's layers, then discrete > integrated > virtual > CPU), with
  the device type as an int so the header stays Vulkan-free.
- d3d12_vulkan_device.cpp: the first usable device of the highest rank.
- vk_device_pick.h: device_rank forwards to it (static_assert on the
  VkPhysicalDeviceType values).
- d3d12_indirect_rt_test, dxgi_swapchain_test, vk_image_fuzz,
  vk_sampler_test had the old loop and ignored LEONIDA_VK_DEVICE: they
  now filter and rank like the rest, and an unmatched filter fails
  instead of skipping.
- vulkan_device_filter_test: the rank order; docs/testing.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:27:09 +00:00
09857dfa54 Validate DXGI flip-model swapchain sample descriptions 2026-11-22 19:08:35 +04:00
2d32cd2576 Merge pull request #1801 from Ryderadzeee 2026-11-22 09:48:19 -05:00
8d27bec8d6 Merge pull request #1780 from Ryderadzeee 2026-11-22 09:15:18 -05:00
a0af2deb87 Merge pull request #1766 from Ryderadzeee 2026-11-22 09:15:11 -05:00
4d6febbde3 Merge pull request #1761 from SHAURYASANYAL3 2026-11-22 09:15:08 -05:00