@@ -15,8 +15,6 @@ use windows::Win32::Graphics::Direct3D12::{
1515 D3D12_COMMAND_LIST_TYPE_DIRECT , D3D12_COMMAND_QUEUE_DESC , D3D12_COMMAND_QUEUE_FLAG_NONE ,
1616 D3D12_FENCE_FLAG_NONE , D3D12_RESOURCE_STATE_PRESENT ,
1717} ;
18- #[ cfg( feature = "d3d_debug" ) ]
19- use windows:: Win32 :: Graphics :: Direct3D12 :: { D3D12GetDebugInterface , ID3D12Debug } ;
2018use windows:: Win32 :: Graphics :: DirectComposition :: {
2119 DCompositionCreateDevice2 , IDCompositionDevice , IDCompositionTarget , IDCompositionVisual ,
2220} ;
@@ -25,10 +23,15 @@ use windows::Win32::Graphics::Dxgi::Common::{
2523 DXGI_SAMPLE_DESC ,
2624} ;
2725use 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 } ,
3235} ;
3336use windows:: Win32 :: System :: Threading :: { CreateEventW , WaitForSingleObjectEx , INFINITE } ;
3437use winit:: {
@@ -42,7 +45,7 @@ use super::{vsync::VSyncWinSwapChain, RendererSettings, SkiaRenderer, VSync};
4245use crate :: profiling:: { d3d:: create_d3d_gpu_context, GpuCtx } ;
4346use crate :: { profiling:: tracy_gpu_zone, settings:: SETTINGS , window:: UserEvent } ;
4447
45- fn get_hardware_adapter ( factory : & IDXGIFactory4 ) -> Result < IDXGIAdapter1 > {
48+ fn get_hardware_adapter ( factory : & IDXGIFactory2 ) -> Result < IDXGIAdapter1 > {
4649 for i in 0 .. {
4750 let adapter = unsafe { factory. EnumAdapters1 ( i) ? } ;
4851 let mut desc = Default :: default ( ) ;
@@ -98,20 +101,22 @@ pub struct D3DSkiaRenderer {
98101impl D3DSkiaRenderer {
99102 pub fn new ( window : Window ) -> Self {
100103 #[ cfg( feature = "d3d_debug" ) ]
101- unsafe {
104+ let dxgi_factory : IDXGIFactory2 = unsafe {
102105 let mut debug_controller: Option < ID3D12Debug > = None ;
103106 D3D12GetDebugInterface ( & mut debug_controller)
104107 . expect ( "Failed to create Direct3D debug controller" ) ;
105108
106109 debug_controller
107110 . expect ( "Failed to enable debug layer" )
108111 . EnableDebugLayer ( ) ;
109- }
110112
111- let dxgi_factory: IDXGIFactory4 = unsafe {
112113 CreateDXGIFactory2 ( DXGI_CREATE_FACTORY_DEBUG ) . expect ( "Failed to create DXGI factory" )
113114 } ;
114115
116+ #[ cfg( not( feature = "d3d_debug" ) ) ]
117+ let dxgi_factory: IDXGIFactory2 =
118+ unsafe { CreateDXGIFactory1 ( ) . expect ( "Failed to create DXGI factory" ) } ;
119+
115120 let adapter = get_hardware_adapter ( & dxgi_factory)
116121 . expect ( "Failed to find any suitable Direct3D 12 adapters" ) ;
117122
0 commit comments