From 7025f195a72d5dc7b853d014abc7120e49ed0372 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 20 Jul 2022 01:22:43 +0900 Subject: [PATCH] internal/graphicsdriver/directx: check DirectX availability earlier for Wine Closes #2114 --- internal/graphicsdriver/directx/graphics_windows.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index f62578c90..4c98356df 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -286,6 +286,14 @@ func (g *Graphics) initializeDesktop(useWARP bool, useDebugLayer bool) (ferr 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 } @@ -1047,7 +1055,7 @@ func (g *Graphics) NewImage(width, height int) (graphicsdriver.Image, error) { } 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") }