@@ -2469,7 +2469,7 @@ Error RenderingDeviceDriverD3D12::swap_chain_resize(CommandQueueID p_cmd_queue,
2469
2469
DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {};
2470
2470
if (swap_chain->d3d_swap_chain != nullptr ) {
2471
2471
_swap_chain_release_buffers (swap_chain);
2472
- res = swap_chain->d3d_swap_chain ->ResizeBuffers (p_desired_framebuffer_count, 0 , 0 , DXGI_FORMAT_UNKNOWN, creation_flags);
2472
+ res = swap_chain->d3d_swap_chain ->ResizeBuffers (p_desired_framebuffer_count, surface-> width , surface-> height , DXGI_FORMAT_UNKNOWN, creation_flags);
2473
2473
ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_UNAVAILABLE);
2474
2474
} else {
2475
2475
swap_chain_desc.BufferCount = p_desired_framebuffer_count;
@@ -2478,22 +2478,19 @@ Error RenderingDeviceDriverD3D12::swap_chain_resize(CommandQueueID p_cmd_queue,
2478
2478
swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
2479
2479
swap_chain_desc.SampleDesc .Count = 1 ;
2480
2480
swap_chain_desc.Flags = creation_flags;
2481
- swap_chain_desc.Scaling = DXGI_SCALING_NONE ;
2481
+ swap_chain_desc.Scaling = DXGI_SCALING_STRETCH ;
2482
2482
if (OS::get_singleton ()->is_layered_allowed ()) {
2483
2483
swap_chain_desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED;
2484
2484
has_comp_alpha[(uint64_t )p_cmd_queue.id ] = true ;
2485
2485
} else {
2486
2486
swap_chain_desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
2487
2487
has_comp_alpha[(uint64_t )p_cmd_queue.id ] = false ;
2488
2488
}
2489
+ swap_chain_desc.Width = surface->width ;
2490
+ swap_chain_desc.Height = surface->height ;
2489
2491
2490
2492
ComPtr<IDXGISwapChain1> swap_chain_1;
2491
- res = context_driver->dxgi_factory_get ()->CreateSwapChainForHwnd (command_queue->d3d_queue .Get (), surface->hwnd , &swap_chain_desc, nullptr , nullptr , swap_chain_1.GetAddressOf ());
2492
- if (!SUCCEEDED (res) && swap_chain_desc.AlphaMode != DXGI_ALPHA_MODE_IGNORE) {
2493
- swap_chain_desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
2494
- has_comp_alpha[(uint64_t )p_cmd_queue.id ] = false ;
2495
- res = context_driver->dxgi_factory_get ()->CreateSwapChainForHwnd (command_queue->d3d_queue .Get (), surface->hwnd , &swap_chain_desc, nullptr , nullptr , swap_chain_1.GetAddressOf ());
2496
- }
2493
+ res = context_driver->dxgi_factory_get ()->CreateSwapChainForComposition (command_queue->d3d_queue .Get (), &swap_chain_desc, nullptr , swap_chain_1.GetAddressOf ());
2497
2494
ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2498
2495
2499
2496
swap_chain_1.As (&swap_chain->d3d_swap_chain );
@@ -2503,6 +2500,36 @@ Error RenderingDeviceDriverD3D12::swap_chain_resize(CommandQueueID p_cmd_queue,
2503
2500
ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2504
2501
}
2505
2502
2503
+ if (surface->composition_device .Get () == nullptr ) {
2504
+ using PFN_DCompositionCreateDevice = HRESULT (WINAPI *)(IDXGIDevice *, REFIID, void **);
2505
+ PFN_DCompositionCreateDevice pfn_DCompositionCreateDevice = (PFN_DCompositionCreateDevice)(void *)GetProcAddress (context_driver->lib_dcomp , " DCompositionCreateDevice" );
2506
+ ERR_FAIL_NULL_V (pfn_DCompositionCreateDevice, ERR_CANT_CREATE);
2507
+
2508
+ res = pfn_DCompositionCreateDevice (nullptr , IID_PPV_ARGS (surface->composition_device .GetAddressOf ()));
2509
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2510
+
2511
+ res = surface->composition_device ->CreateTargetForHwnd (surface->hwnd , TRUE , surface->composition_target .GetAddressOf ());
2512
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2513
+
2514
+ res = surface->composition_device ->CreateVisual (surface->composition_visual .GetAddressOf ());
2515
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2516
+
2517
+ res = surface->composition_visual ->SetContent (swap_chain->d3d_swap_chain .Get ());
2518
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2519
+
2520
+ res = surface->composition_target ->SetRoot (surface->composition_visual .Get ());
2521
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2522
+
2523
+ res = surface->composition_device ->Commit ();
2524
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2525
+ } else {
2526
+ res = surface->composition_visual ->SetContent (swap_chain->d3d_swap_chain .Get ());
2527
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2528
+
2529
+ res = surface->composition_device ->Commit ();
2530
+ ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2531
+ }
2532
+
2506
2533
res = swap_chain->d3d_swap_chain ->GetDesc1 (&swap_chain_desc);
2507
2534
ERR_FAIL_COND_V (!SUCCEEDED (res), ERR_CANT_CREATE);
2508
2535
ERR_FAIL_COND_V (swap_chain_desc.BufferCount == 0 , ERR_CANT_CREATE);
0 commit comments