mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
internal/graphicsdriver/directx: bug fix: D3D12CreateDevice could be called without creating a device
This commit is contained in:
parent
0f9ec45709
commit
f8acd5e7ee
@ -1048,9 +1048,13 @@ var (
|
||||
procCreateDXGIFactory2 = dxgi.NewProc("CreateDXGIFactory2")
|
||||
)
|
||||
|
||||
func _D3D12CreateDevice(pAdapter unsafe.Pointer, minimumFeatureLevel _D3D_FEATURE_LEVEL, riid *windows.GUID) (unsafe.Pointer, error) {
|
||||
func _D3D12CreateDevice(pAdapter unsafe.Pointer, minimumFeatureLevel _D3D_FEATURE_LEVEL, riid *windows.GUID, createDevice bool) (unsafe.Pointer, error) {
|
||||
var v unsafe.Pointer
|
||||
r, _, _ := procD3D12CreateDevice.Call(uintptr(pAdapter), uintptr(minimumFeatureLevel), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(&v)))
|
||||
var pv *unsafe.Pointer
|
||||
if createDevice {
|
||||
pv = &v
|
||||
}
|
||||
r, _, _ := procD3D12CreateDevice.Call(uintptr(pAdapter), uintptr(minimumFeatureLevel), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(pv)))
|
||||
if v == nil && uint32(r) != uint32(windows.S_FALSE) {
|
||||
return nil, fmt.Errorf("directx: D3D12CreateDevice failed: HRESULT(%d)", uint32(r))
|
||||
}
|
||||
|
@ -255,7 +255,8 @@ func (g *Graphics) initializeDesktop(useWARP bool, useDebugLayer bool) (ferr err
|
||||
if desc.Flags&_DXGI_ADAPTER_FLAG_SOFTWARE != 0 {
|
||||
continue
|
||||
}
|
||||
if _, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_11_0, &_IID_ID3D12Device); err != nil {
|
||||
// Test D3D12CreateDevice without creating an actual device.
|
||||
if _, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_11_0, &_IID_ID3D12Device, false); err != nil {
|
||||
continue
|
||||
}
|
||||
break
|
||||
@ -266,7 +267,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)
|
||||
d, err := _D3D12CreateDevice(unsafe.Pointer(adapter), _D3D_FEATURE_LEVEL_11_0, &_IID_ID3D12Device, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user