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)