@@ -15,8 +15,6 @@ use windows::Win32::Graphics::Direct3D12::{
15
15
D3D12_COMMAND_LIST_TYPE_DIRECT , D3D12_COMMAND_QUEUE_DESC , D3D12_COMMAND_QUEUE_FLAG_NONE ,
16
16
D3D12_FENCE_FLAG_NONE , D3D12_RESOURCE_STATE_PRESENT ,
17
17
} ;
18
- #[ cfg( feature = "d3d_debug" ) ]
19
- use windows:: Win32 :: Graphics :: Direct3D12 :: { D3D12GetDebugInterface , ID3D12Debug } ;
20
18
use windows:: Win32 :: Graphics :: DirectComposition :: {
21
19
DCompositionCreateDevice2 , IDCompositionDevice , IDCompositionTarget , IDCompositionVisual ,
22
20
} ;
@@ -25,10 +23,15 @@ use windows::Win32::Graphics::Dxgi::Common::{
25
23
DXGI_SAMPLE_DESC ,
26
24
} ;
27
25
use windows:: Win32 :: Graphics :: Dxgi :: {
28
- CreateDXGIFactory2 , IDXGIAdapter1 , IDXGIFactory4 , IDXGISwapChain1 , IDXGISwapChain3 ,
29
- DXGI_ADAPTER_FLAG , DXGI_ADAPTER_FLAG_SOFTWARE , DXGI_CREATE_FACTORY_DEBUG , DXGI_SCALING_STRETCH ,
30
- DXGI_SWAP_CHAIN_DESC1 , DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT ,
31
- DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL , DXGI_USAGE_RENDER_TARGET_OUTPUT ,
26
+ CreateDXGIFactory1 , IDXGIAdapter1 , IDXGIFactory2 , IDXGISwapChain1 , IDXGISwapChain3 ,
27
+ DXGI_ADAPTER_FLAG , DXGI_ADAPTER_FLAG_SOFTWARE , DXGI_SCALING_STRETCH , DXGI_SWAP_CHAIN_DESC1 ,
28
+ DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT , DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL ,
29
+ DXGI_USAGE_RENDER_TARGET_OUTPUT ,
30
+ } ;
31
+ #[ cfg( feature = "d3d_debug" ) ]
32
+ use windows:: Win32 :: Graphics :: {
33
+ Direct3D12 :: { D3D12GetDebugInterface , ID3D12Debug } ,
34
+ Dxgi :: { CreateDXGIFactory2 , DXGI_CREATE_FACTORY_DEBUG } ,
32
35
} ;
33
36
use windows:: Win32 :: System :: Threading :: { CreateEventW , WaitForSingleObjectEx , INFINITE } ;
34
37
use winit:: {
@@ -42,7 +45,7 @@ use super::{vsync::VSyncWinSwapChain, RendererSettings, SkiaRenderer, VSync};
42
45
use crate :: profiling:: { d3d:: create_d3d_gpu_context, GpuCtx } ;
43
46
use crate :: { profiling:: tracy_gpu_zone, settings:: SETTINGS , window:: UserEvent } ;
44
47
45
- fn get_hardware_adapter ( factory : & IDXGIFactory4 ) -> Result < IDXGIAdapter1 > {
48
+ fn get_hardware_adapter ( factory : & IDXGIFactory2 ) -> Result < IDXGIAdapter1 > {
46
49
for i in 0 .. {
47
50
let adapter = unsafe { factory. EnumAdapters1 ( i) ? } ;
48
51
let mut desc = Default :: default ( ) ;
@@ -98,20 +101,22 @@ pub struct D3DSkiaRenderer {
98
101
impl D3DSkiaRenderer {
99
102
pub fn new ( window : Window ) -> Self {
100
103
#[ cfg( feature = "d3d_debug" ) ]
101
- unsafe {
104
+ let dxgi_factory : IDXGIFactory2 = unsafe {
102
105
let mut debug_controller: Option < ID3D12Debug > = None ;
103
106
D3D12GetDebugInterface ( & mut debug_controller)
104
107
. expect ( "Failed to create Direct3D debug controller" ) ;
105
108
106
109
debug_controller
107
110
. expect ( "Failed to enable debug layer" )
108
111
. EnableDebugLayer ( ) ;
109
- }
110
112
111
- let dxgi_factory: IDXGIFactory4 = unsafe {
112
113
CreateDXGIFactory2 ( DXGI_CREATE_FACTORY_DEBUG ) . expect ( "Failed to create DXGI factory" )
113
114
} ;
114
115
116
+ #[ cfg( not( feature = "d3d_debug" ) ) ]
117
+ let dxgi_factory: IDXGIFactory2 =
118
+ unsafe { CreateDXGIFactory1 ( ) . expect ( "Failed to create DXGI factory" ) } ;
119
+
115
120
let adapter = get_hardware_adapter ( & dxgi_factory)
116
121
. expect ( "Failed to find any suitable Direct3D 12 adapters" ) ;
117
122
0 commit comments