internal/graphicsdriver/directx: check DirectX availability earlier for Wine

Closes #2114
This commit is contained in:
Hajime Hoshi 2022-07-20 01:22:43 +09:00
parent e861080145
commit 7025f195a7

View File

@ -286,6 +286,14 @@ func (g *Graphics) initializeDesktop(useWARP bool, useDebugLayer bool) (ferr err
return err return err
} }
// GetOpyableFootprints might return an invalid value with Wine (#2114).
// To check this early, call NewImage here.
i, err := g.NewImage(1, 1)
if err != nil {
return err
}
i.Dispose()
return nil return nil
} }
@ -1047,7 +1055,7 @@ func (g *Graphics) NewImage(width, height int) (graphicsdriver.Image, error) {
} }
layouts, _, _, totalBytes := g.device.GetCopyableFootprints(&desc, 0, 1, 0) layouts, _, _, totalBytes := g.device.GetCopyableFootprints(&desc, 0, 1, 0)
if totalBytes == 1<<64-1 { if totalBytes == ^uint64(0) {
return nil, fmt.Errorf("directx: GetCopyableFootprints returned an invalid total bytes") return nil, fmt.Errorf("directx: GetCopyableFootprints returned an invalid total bytes")
} }