From b3ddeb6456b6eadddf61a9a48ea7247131983122 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 4 Jun 2022 01:12:35 +0900 Subject: [PATCH] Revert "internal/graphicsdriver/directx: bug fix: ID3D12Resource::Map sometimes needs retrying" This reverts commit a9afacc8c65768e37a4792298c043744045d9de3. Reason: The true culprit was #2117. #2116 was not a bug. Updates #2116 Updates #2117 --- internal/graphicsdriver/directx/api_windows.go | 16 +++------------- .../graphicsdriver/directx/graphics_windows.go | 8 ++++---- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/internal/graphicsdriver/directx/api_windows.go b/internal/graphicsdriver/directx/api_windows.go index c69b921a9..5f32e7029 100644 --- a/internal/graphicsdriver/directx/api_windows.go +++ b/internal/graphicsdriver/directx/api_windows.go @@ -1727,24 +1727,14 @@ func (i *iD3D12Resource1) GetGPUVirtualAddress() _D3D12_GPU_VIRTUAL_ADDRESS { return _D3D12_GPU_VIRTUAL_ADDRESS(r) } -func (i *iD3D12Resource1) Map(subresource uint32, pReadRange *_D3D12_RANGE) (uintptr, error) { - var retryCount int -retry: - var data uintptr +func (i *iD3D12Resource1) Map(subresource uint32, pReadRange *_D3D12_RANGE) (unsafe.Pointer, error) { + var data unsafe.Pointer r, _, _ := syscall.Syscall6(i.vtbl.Map, 4, uintptr(unsafe.Pointer(i)), uintptr(subresource), uintptr(unsafe.Pointer(pReadRange)), uintptr(unsafe.Pointer(&data)), 0, 0) runtime.KeepAlive(pReadRange) if windows.Handle(r) != windows.S_OK { - return 0, fmt.Errorf("directx: ID3D12Resource1::Map failed: %w", windows.Errno(r)) - } - if data == 0 { - // This is very mysterious, but sometimes Map fails especially on tests with Warp and/or Proton (Steam Deck) (#2113). - if retryCount >= 5 { - return 0, fmt.Errorf("directx: ID3D12Resource::Map failed: nothing is mapped") - } - retryCount++ - goto retry + return nil, fmt.Errorf("directx: ID3D12Resource1::Map failed: %w", windows.Errno(r)) } return data, nil } diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index 7acc68412..121be4a10 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -1531,19 +1531,19 @@ func (i *Image) ensureDepthStencilView(device *iD3D12Device) error { return nil } -func copyFloat32s(dst uintptr, src []float32) { +func copyFloat32s(dst unsafe.Pointer, src []float32) { var dsts []float32 h := (*reflect.SliceHeader)(unsafe.Pointer(&dsts)) - h.Data = dst + h.Data = uintptr(dst) h.Len = len(src) h.Cap = len(src) copy(dsts, src) } -func copyUint16s(dst uintptr, src []uint16) { +func copyUint16s(dst unsafe.Pointer, src []uint16) { var dsts []uint16 h := (*reflect.SliceHeader)(unsafe.Pointer(&dsts)) - h.Data = dst + h.Data = uintptr(dst) h.Len = len(src) h.Cap = len(src) copy(dsts, src)