Commit graph

605 commits

Author SHA1 Message Date
Giovanni Mascellani
aeb9776f4c dxgi: Split D3D12/Vulkan resource creation and destruction.
This is to eventually hand frontend and backend resource management
to different code pieces.
2023-07-04 15:37:16 +02:00
Giovanni Mascellani
b4741fd259 dxgi: Pass a VkImage to d3d12_swapchain_queue_present().
This is to eventually allow d3d12_swapchain_queue_present() to
operate on a certain VkImage even if current_buffer_index has
already been modified since the corresponding Present() call.
2023-07-04 15:37:15 +02:00
Giovanni Mascellani
89cd45bb1f dxgi: Free the frontend images memory only once. 2023-07-04 15:37:15 +02:00
Giovanni Mascellani
e5c232eb4c dxgi: Consider vk_format a frontend field.
This is an oversight in eec9c3a2f6:
vk_format specifies the format used for the frontend resources. The backend
images could use a different format, depending on what the swapchain
supports.

Also, introduce the terms "frontend" and "backend" for the two sides
of the swapchain, which are probably easier to understand.
2023-07-04 15:37:12 +02:00
Giovanni Mascellani
e1cdc48786 dxgi/tests: Test that the present count is updated when Present() is called. 2023-07-04 15:37:12 +02:00
Giovanni Mascellani
1a0c2d6b41 dxgi/tests: Test that the back buffer index is updated when Present() is called. 2023-07-04 15:37:12 +02:00
Zebediah Figura
ebaa0a9426 wined3d: Recreate swapchain textures in wined3d_swapchain_resize_buffers().
Instead of using wined3d_texture_update_desc(). This is safe, because:

* ddraw never exposes wined3d textures directly, and always retrieves them
  directly from wined3d when rendering.

* d3d8 and d3d9 (non-extended) will only resize buffers during a reset, and
  resetting is forbidden if the application holds any references to the
  backbuffers. RTVs are also replaced during a reset, so there is no concern
  about retrieving the old RTVs from the device state.

* d3d9ex allows resetting while holding references to the backbuffers, but tests
  (fixed by this patch) show that the backbuffers should in fact be recreated.

* dxgi forbids holding references to back buffers during ResizeBuffers(),
  including indirect references via command lists or device contexts.
2023-06-29 12:04:35 +02:00
Zebediah Figura
0dc7de15e0 dxgi: Do not create a d3d11 swapchain object for the implicit swapchain.
This swapchain is never actually exposed, and effectively only exists due to
implementation constraints. When it was introduced, it was necessary or simplest
to create a dxgi swapchain object, but currently that's no longer necessary, and
avoiding that allows some code to be simplified.
2023-06-29 12:04:33 +02:00
Giovanni Mascellani
e0ce5e331a dxgi: Rename and split d3d12_swapchain_destroy_buffers(). 2023-06-21 18:15:43 +02:00
Giovanni Mascellani
2e556c3245 dxgi: Only create D3D12 resources when necessary. 2023-06-21 18:15:43 +02:00
Giovanni Mascellani
c10e272152 dxgi: Do not destroy D3D12 resources unless requested.
This is probably a leftover of when Vulkan swapchain images were
used directly.
2023-06-21 18:15:43 +02:00
Giovanni Mascellani
bc3edfd188 dxgi: Remove now-useless function d3d12_swapchain_create_buffers(). 2023-06-21 18:15:43 +02:00
Giovanni Mascellani
0521f57027 dxgi: Do not uselessly pass queue_family_index around. 2023-06-21 18:15:43 +02:00
Giovanni Mascellani
4e88f44270 dxgi: Move Vulkan-specific code to d3d12_swapchain_create_vulkan_swapchain(). 2023-06-02 22:25:02 +02:00
Giovanni Mascellani
a7ff40a324 dxgi: Move non-Vulkan-specific code out of d3d12_swapchain_create_vulkan_swapchain(). 2023-06-02 22:25:02 +02:00
Giovanni Mascellani
6cb23836e7 dxgi: Factor out d3d12_swapchain_create_image_resources(). 2023-06-02 22:25:02 +02:00
Giovanni Mascellani
237062d01f dxgi: Store Vulkan formats in the swapchain object. 2023-06-02 22:25:02 +02:00
Giovanni Mascellani
565917d5d2 dxgi: Rename d3d12_swapchain_prepare_command_buffers(). 2023-06-02 22:25:02 +02:00
Giovanni Mascellani
eec9c3a2f6 dxgi: Document some struct d3d12_swapchain fields. 2023-06-02 22:25:02 +02:00
Zebediah Figura
7b7d26a731 dxgi: Create d3d11 swapchain textures directly from d3d11_swapchain_init().
Using the IWineDXGIDeviceParent::swapchain_texture_created() callback.
2023-04-26 22:49:17 +02:00
Zebediah Figura
4413e94908 dxgi: Introduce IWineDXGIDeviceParent::register_swapchain_texture() and use it in IDXGIDevice::CreateSurface().
Instead of having d3d11 create the wined3d texture, create it in dxgi instead,
and let d3d11 create a d3d_texture2d object to wrap it.

This is a step towards getting rid of the create_swapchain_texture() callback,
which is mildly difficult to work with and conceptually complex.
2023-04-26 22:49:17 +02:00
Andrey Gusev
af6d82613a dxgi: Update TRACE in dxgi_device_create_resource(). 2023-04-19 20:26:15 +02:00
Giovanni Mascellani
9015565ac0 dxgi/tests: Test the frame latency waitable more thoroughly. 2023-04-05 11:36:14 +02:00
Giovanni Mascellani
3cb350b228 dxgi/tests: Rename the waitable object from "event" to "semaphore".
From the tests it behaves more like a semaphore than like an event.

I'm not testing explicitly because I'm not sure it's relevant, but
another indication is that calling ReleaseSemaphore() returns
ERROR_ACCESS_DENIED, while calling SetEvent() returns
ERROR_INVALID_HANDLE.
2023-04-05 11:36:13 +02:00
Giovanni Mascellani
54bf9a9363 dxgi: Return a duplicate frame latency event. 2023-04-05 11:36:13 +02:00
Giovanni Mascellani
c6c065818c dxgi: Return correct present count with DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT. 2023-04-05 11:36:13 +02:00
Giovanni Mascellani
ecc480c8dc dxgi/tests: Test GetLastPresentCount() with DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT. 2023-04-05 11:36:11 +02:00
Stefan Dösinger
617831054f dxgi/tests: Test nested SetFullscreenState from the same thread.
I am still deliberately not testing after which message the swapchain
state changes from the old state to the new until we find a game that
depends on this.

ddraw, d3d8 and d3d9 do not catch recursive SetDisplayMode or Reset()
calls. They will recurse for about 16 times and then return library
specific weird return values like 0xd0000510 (NTSTATUS, but
nonexistent facility) or 0x88760868 (non-existent HRESULT facility). I
suspect it aborts when the kernel-side message processing stack is
exhausted. As such, an application depending on nested calls in those
libraries would have to deliberately do it, but limit the amount of
nesting to a non-zero amount.
2023-03-10 09:49:32 +01:00
Stefan Dösinger
92544264fd dxgi/tests: Test nested fullscreen application from different thread. 2023-03-10 09:49:32 +01:00
Stefan Dösinger
33170e2720 dxgi: Catch nested SetFullscreenState invocations. 2023-03-10 09:49:32 +01:00
Stefan Dösinger
75f7bd0eea dxgi: Unlock the wined3d mutex after storing the new target.
Otherwise a second thread might set it to something else between the
unlock and assignment.
2023-03-10 09:49:32 +01:00
Stefan Dösinger
52bdd0dbcd dxgi/tests: Run test_swapchain_window_messages on d3d12. 2023-03-10 09:49:32 +01:00
Zebediah Figura
6956746a0a dxgi: Call wined3d_swapchain_state_set_fullscreen in d3d12_swapchain_init.
Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
2023-03-10 09:49:32 +01:00
Stefan Dösinger
99cc854a03 dxgi/tests: Run test_resize_target_wndproc on d3d12 too. 2023-03-10 09:49:32 +01:00
Stefan Dösinger
2654f9c456 dxgi/tests: Fix UnregisterClass call in test_resize_target_wndproc. 2023-03-10 09:49:13 +01:00
Giovanni Mascellani
ac265bf3fb dxgi: Reset the back buffer index to zero on ResizeBuffers(). 2023-03-09 17:31:26 +01:00
Giovanni Mascellani
dc2a2eaf3d dxgi/tests: Test that ResizeBuffers() resets the back buffer index to zero. 2023-03-09 17:31:26 +01:00
Giovanni Mascellani
8af43e1cb3 dxgi: Always assume that a D3D12 swapchain always uses user images. 2023-03-09 17:31:26 +01:00
Giovanni Mascellani
e946f610b2 dxgi: Immediately error out when creating a D3D12 swapchain on a non-immediate queue. 2023-03-09 17:31:26 +01:00
David Gow
fe9a1403fa dxgi: Don't warn on DXGI_ALPHA_MODE_UNSPECIFIED with wined3d. 2023-02-21 11:19:28 +01:00
Zebediah Figura
555cee6449 dxgi: Implement IDXGIResource::GetUsage(). 2023-02-14 20:57:09 +01:00
Francois Gouget
6ec99a0e91 dxgi/tests: Mark the test_swapchain_window_messages() tests failing randomly on Windows as flaky.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=53229
2022-10-11 11:43:59 +02:00
Francois Gouget
5b10cb08a5 dxgi/tests: Mark the test_swapchain_window_styles() tests failing randomly on Windows as flaky.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=53228
2022-10-11 11:43:57 +02:00
Zebediah Figura
a601930a91 dxgi: Build the device list only once in dxgi_output_get_display_mode_list(). 2022-08-02 21:49:54 +02:00
Zebediah Figura
0ee74e9f81 d3d9: Cache the output mode list.
Garou: Mark of the Wolves calls IDirect3D9::GetAdapterModeCount() on every
frame. This results in calling EnumDisplaySettingsExW() once per available mode,
which is a very slow operation, both on Windows and Wine.

Manual testing shows that Windows caches the mode list (as well as the adapter
list, which is already cached in Wine) in Direct3D 9 and lower. Calls to
GetAdapterModeCount() and EnumAdapterDisplayModes() are fast, and they also do
not change if monitors are added or removed.

DXGI behaves differently, however. The list of outputs attached to an adapter is
cached—that is, calls to IDXGIAdapter::EnumOutputs() are fast, and return stale
data. However, at least some other calls are slow and do not seem to be cached,
including IDXGIOutput::GetDisplayModeList() and IDXGIOutput::GetDesc().

ddraw is also slow and uncached. Since all testing was done on Windows 10 (for
lack of available older hardware to test with) it is not unlikely that ddraw was
reimplemented over dxgi on newer Windows, and that older Windows versions would
be fast and cached, but this is speculation. In any case I have not included
patches to cache ddraw modes.

Tests were done on Windows 10 21H2, both on real hardware with NVidia drivers
and on software drivers via qemu/KVM. In the latter case only speed could be
tested, but this was consistent with the results from the NVidia machine.
2022-08-02 21:49:54 +02:00
Nikolay Sivov
184ff3bfbb dxgi: Create DXGI resource object, optionally supporting surface interfaces.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2022-06-15 21:44:47 +02:00
Nikolay Sivov
9a78bd87c4 dxgi/tests: Add a IDXGIResource support test for CreateSurface().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2022-06-15 21:44:46 +02:00
Zhiyi Zhang
fd6e137dfe dxgi: Implement adapter video memory budget change notification.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51665
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-23 20:50:01 +02:00
Zhiyi Zhang
14237e321b dxgi/tests: Test adapter video memory budget notification.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-20 10:23:08 +02:00
Zhiyi Zhang
0f7c7cd7a0 dxgi: Implement dxgi_adapter_QueryVideoMemoryInfo() with D3DKMTQueryVideoMemoryInfo().
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-20 10:22:59 +02:00