internal/graphicsdriver/directx: refactoring: reduce indentations

This commit is contained in:
Hajime Hoshi 2023-03-26 22:56:15 +09:00
parent fe5c3354fc
commit 549e6120b5

View File

@ -173,11 +173,20 @@ func (g *graphics12) initializeDesktop(useWARP bool, useDebugLayer bool, feature
}() }()
var adapter *_IDXGIAdapter1 var adapter *_IDXGIAdapter1
if len(adapters) > 0 {
if useWARP { if useWARP {
if len(adapters) > 0 {
adapter = adapters[0] adapter = adapters[0]
}
} else { } else {
for _, a := range adapters { for _, a := range adapters {
desc, err := a.GetDesc1()
if err != nil {
continue
}
if desc.Flags&_DXGI_ADAPTER_FLAG_SOFTWARE != 0 {
continue
}
// Test D3D12CreateDevice without creating an actual device. // Test D3D12CreateDevice without creating an actual device.
if _, err := _D3D12CreateDevice(unsafe.Pointer(a), featureLevel, &_IID_ID3D12Device, false); err != nil { if _, err := _D3D12CreateDevice(unsafe.Pointer(a), featureLevel, &_IID_ID3D12Device, false); err != nil {
continue continue
@ -186,7 +195,6 @@ func (g *graphics12) initializeDesktop(useWARP bool, useDebugLayer bool, feature
break break
} }
} }
}
if adapter == nil { if adapter == nil {
return errors.New("directx: DirectX 12 is not supported") return errors.New("directx: DirectX 12 is not supported")