Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HansKristian-Work/vkd3d-proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ashton <joshua@froggi.es>2020-07-07 00:27:02 +0300
committerJoshua Ashton <joshua@froggi.es>2020-07-07 01:57:54 +0300
commit1c82616717eefb010de3b213df3ea96b05a94b53 (patch)
tree6c9c95caefea7d7fefc5d0a843f355c4a2fc906e
parentcb1da02af9b967e86d451fe8f2281a8518c277a8 (diff)
vkd3d: Correctly handle output + fix NULL old targets for fullscreenswapchain-fix
The output here is actually for secure presentation and restricting a swapchain to a certain output. Correctly handle NULL (desktop) targets that we used to have. Fixes crashes with titles that use fullscreen via an initial fullscreen desc. Signed-off-by: Joshua Ashton <joshua@froggi.es>
-rw-r--r--libs/vkd3d/swapchain.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/libs/vkd3d/swapchain.c b/libs/vkd3d/swapchain.c
index 4e1297dc..dd5549b0 100644
--- a/libs/vkd3d/swapchain.c
+++ b/libs/vkd3d/swapchain.c
@@ -384,7 +384,7 @@ static HRESULT d3d12_swapchain_set_display_mode(struct d3d12_swapchain *swapchai
return hr;
}
- if (output != swapchain->target)
+ if (output != swapchain->target && swapchain->target)
{
if (FAILED(hr = d3d12_output_set_display_mode(swapchain->target, &swapchain->state.original_mode)))
{
@@ -2244,7 +2244,7 @@ static CONST_VTBL struct IDXGISwapChain3Vtbl d3d12_swapchain_vtbl =
static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IDXGIFactory *factory,
struct d3d12_command_queue *queue, HWND window,
const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc,
- IDXGIOutput *output)
+ IDXGIOutput *restrict_output_to_target)
{
const struct vkd3d_vk_device_procs *vk_procs = &queue->device->vk_procs;
VkWin32SurfaceCreateInfoKHR surface_desc;
@@ -2254,7 +2254,7 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IDXGIFact
VkSurfaceKHR vk_surface;
VkInstance vk_instance;
IDXGIAdapter *adapter;
- IDXGIOutput *target = NULL;
+ IDXGIOutput *target;
VkBool32 supported;
VkDevice vk_device;
VkFence vk_fence;
@@ -2290,23 +2290,18 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IDXGIFact
if (FAILED(hr = IUnknown_QueryInterface(queue->device->parent, &IID_IDXGIAdapter, (void **)&adapter)))
return hr;
- if (!output)
+ if (FAILED(hr = d3d12_get_output_from_window((IDXGIFactory*)factory, window, &target)))
{
- if (FAILED(hr = d3d12_get_output_from_window((IDXGIFactory*)factory, window, &target)))
- {
- WARN("Failed to get output from window %p, hr %#x.\n", window, hr);
+ WARN("Failed to get output from window %p, hr %#x.\n", window, hr);
- if (FAILED(hr = IDXGIAdapter_EnumOutputs(adapter, 0, &target)))
- {
- IDXGIAdapter_Release(adapter);
- return hr;
- }
-
- FIXME("Using the primary output for the device window that is on a non-primary output.\n");
+ if (FAILED(hr = IDXGIAdapter_EnumOutputs(adapter, 0, &target)))
+ {
+ IDXGIAdapter_Release(adapter);
+ return hr;
}
+
+ FIXME("Using the primary output for the device window that is on a non-primary output.\n");
}
- else
- target = output;
if (FAILED(hr = d3d12_output_get_display_mode(target, &swapchain->state.original_mode)))
{
@@ -2421,23 +2416,25 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IDXGIFact
}
}
- IDXGIFactory_AddRef(swapchain->factory = factory);
-
if (FAILED(hr = d3d12_swapchain_set_fullscreen(swapchain, target, TRUE)))
{
- WARN("Failed to go fullscreen.\n");
+ ERR("Failed to enter fullscreen.");
return hr;
}
- if (!output && target)
+ if (!swapchain->fullscreen_desc.Windowed)
+ swapchain->target = target;
+ else
IDXGIOutput_Release(target);
+ IDXGIFactory_AddRef(swapchain->factory = factory);
+
return S_OK;
}
static HRESULT d3d12_swapchain_create(IDXGIFactory *factory, struct d3d12_command_queue *queue, HWND window,
const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc,
- IDXGIOutput *output, IDXGISwapChain1 **swapchain)
+ IDXGIOutput *restrict_to_output, IDXGISwapChain1 **swapchain)
{
DXGI_SWAP_CHAIN_FULLSCREEN_DESC default_fullscreen_desc;
struct d3d12_swapchain *object;
@@ -2456,7 +2453,7 @@ static HRESULT d3d12_swapchain_create(IDXGIFactory *factory, struct d3d12_comman
if (!(object = vkd3d_calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
- hr = d3d12_swapchain_init(object, factory, queue, window, swapchain_desc, fullscreen_desc, output);
+ hr = d3d12_swapchain_init(object, factory, queue, window, swapchain_desc, fullscreen_desc, restrict_to_output);
if (FAILED(hr))
{