Skip to content

Commit

Permalink
internal/graphicsdriver/directx: specify DX level 12
Browse files Browse the repository at this point in the history
Updates #2447
  • Loading branch information
hajimehoshi committed Nov 11, 2022
1 parent c72fd7f commit b8073f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/graphicsdriver/directx/api_windows.go
Expand Up @@ -73,7 +73,7 @@ const (
type _D3D_FEATURE_LEVEL int32

const (
_D3D_FEATURE_LEVEL_11_0 _D3D_FEATURE_LEVEL = 0xb000
_D3D_FEATURE_LEVEL_12_0 _D3D_FEATURE_LEVEL = 0xc000
)

type _D3D_PRIMITIVE_TOPOLOGY int32
Expand Down
7 changes: 5 additions & 2 deletions internal/graphicsdriver/directx/graphics_windows.go
Expand Up @@ -185,6 +185,7 @@ func (g *Graphics) initialize() (ferr error) {
return err
}
}

return nil
}

Expand Down Expand Up @@ -256,7 +257,9 @@ func (g *Graphics) initializeDesktop(useWARP bool, useDebugLayer bool) (ferr err
continue
}
// Test D3D12CreateDevice without creating an actual device.
if _, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_11_0, &_IID_ID3D12Device, false); err != nil {
// Ebitengine itself doesn't require the features level 12 and 11 should be enough,
// but some old cards don't work well (#2447). Specify the level 12 here.
if _, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_12_0, &_IID_ID3D12Device, false); err != nil {
continue
}
break
Expand All @@ -267,7 +270,7 @@ func (g *Graphics) initializeDesktop(useWARP bool, useDebugLayer bool) (ferr err
return errors.New("directx: DirectX 12 is not supported")
}

d, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_11_0, &_IID_ID3D12Device, true)
d, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_12_0, &_IID_ID3D12Device, true)
if err != nil {
return err
}
Expand Down

0 comments on commit b8073f5

Please sign in to comment.