mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicsdriver/directx: bug fix: ID3D12Resource::Map sometimes retrying
Updates #2113 Closes #2116
This commit is contained in:
parent
8e4e3d67c4
commit
3e1b313221
@ -1780,14 +1780,24 @@ func (i *_ID3D12Resource) GetGPUVirtualAddress() _D3D12_GPU_VIRTUAL_ADDRESS {
|
||||
return _D3D12_GPU_VIRTUAL_ADDRESS(r)
|
||||
}
|
||||
|
||||
func (i *_ID3D12Resource) Map(subresource uint32, pReadRange *_D3D12_RANGE) (unsafe.Pointer, error) {
|
||||
var data unsafe.Pointer
|
||||
func (i *_ID3D12Resource) Map(subresource uint32, pReadRange *_D3D12_RANGE) (uintptr, error) {
|
||||
var retryCount int
|
||||
retry:
|
||||
var data uintptr
|
||||
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 uint32(r) != uint32(windows.S_OK) {
|
||||
return nil, fmt.Errorf("directx: ID3D12Resource::Map failed: HRESULT(%d)", uint32(r))
|
||||
return 0, fmt.Errorf("directx: ID3D12Resource::Map failed: HRESULT(%d)", uint32(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 data, nil
|
||||
}
|
||||
|
@ -1573,19 +1573,19 @@ func (i *Image) ensureDepthStencilView(device *_ID3D12Device) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func copyFloat32s(dst unsafe.Pointer, src []float32) {
|
||||
func copyFloat32s(dst uintptr, src []float32) {
|
||||
var dsts []float32
|
||||
h := (*reflect.SliceHeader)(unsafe.Pointer(&dsts))
|
||||
h.Data = uintptr(dst)
|
||||
h.Data = dst
|
||||
h.Len = len(src)
|
||||
h.Cap = len(src)
|
||||
copy(dsts, src)
|
||||
}
|
||||
|
||||
func copyUint16s(dst unsafe.Pointer, src []uint16) {
|
||||
func copyUint16s(dst uintptr, src []uint16) {
|
||||
var dsts []uint16
|
||||
h := (*reflect.SliceHeader)(unsafe.Pointer(&dsts))
|
||||
h.Data = uintptr(dst)
|
||||
h.Data = dst
|
||||
h.Len = len(src)
|
||||
h.Cap = len(src)
|
||||
copy(dsts, src)
|
||||
|
Loading…
Reference in New Issue
Block a user