internal/graphicsdriver/directx: bug fix: ID3D12Resource::Unmap does not return an value

Updates #2113
This commit is contained in:
Hajime Hoshi 2022-06-02 12:52:54 +09:00
parent 4a684c4195
commit fb03a1e351
3 changed files with 7 additions and 21 deletions

View File

@ -1796,14 +1796,10 @@ func (i *_ID3D12Resource) Release() {
syscall.Syscall(i.vtbl.Release, 1, uintptr(unsafe.Pointer(i)), 0, 0) syscall.Syscall(i.vtbl.Release, 1, uintptr(unsafe.Pointer(i)), 0, 0)
} }
func (i *_ID3D12Resource) Unmap(subresource uint32, pWrittenRange *_D3D12_RANGE) error { func (i *_ID3D12Resource) Unmap(subresource uint32, pWrittenRange *_D3D12_RANGE) {
r, _, _ := syscall.Syscall(i.vtbl.Unmap, 3, uintptr(unsafe.Pointer(i)), syscall.Syscall(i.vtbl.Unmap, 3, uintptr(unsafe.Pointer(i)),
uintptr(subresource), uintptr(unsafe.Pointer(pWrittenRange))) uintptr(subresource), uintptr(unsafe.Pointer(pWrittenRange)))
runtime.KeepAlive(pWrittenRange) runtime.KeepAlive(pWrittenRange)
if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12Resource::Unmap failed: %w", windows.Errno(r))
}
return nil
} }
type _ID3DBlob struct { type _ID3DBlob struct {

View File

@ -829,18 +829,14 @@ func (g *Graphics) SetVertices(vertices []float32, indices []uint16) (ferr error
return err return err
} }
copyFloat32s(m, vertices) copyFloat32s(m, vertices)
if err := g.vertices[g.frameIndex][vidx].Unmap(0, nil); err != nil { g.vertices[g.frameIndex][vidx].Unmap(0, nil)
return err
}
m, err = g.indices[g.frameIndex][iidx].Map(0, &_D3D12_RANGE{0, 0}) m, err = g.indices[g.frameIndex][iidx].Map(0, &_D3D12_RANGE{0, 0})
if err != nil { if err != nil {
return err return err
} }
copyUint16s(m, indices) copyUint16s(m, indices)
if err := g.indices[g.frameIndex][iidx].Unmap(0, nil); err != nil { g.indices[g.frameIndex][iidx].Unmap(0, nil)
return err
}
return nil return nil
} }
@ -1372,9 +1368,7 @@ func (i *Image) ReadPixels(buf []byte) error {
copy(buf[j*i.width*4:(j+1)*i.width*4], dstBytes[j*int(i.layouts.Footprint.RowPitch):]) copy(buf[j*i.width*4:(j+1)*i.width*4], dstBytes[j*int(i.layouts.Footprint.RowPitch):])
} }
if err := i.readingStagingBuffer.Unmap(0, nil); err != nil { i.readingStagingBuffer.Unmap(0, nil)
return err
}
return nil return nil
} }
@ -1430,9 +1424,7 @@ func (i *Image) ReplacePixels(args []*graphicsdriver.ReplacePixelsArgs) error {
}) })
} }
if err := i.uploadingStagingBuffer.Unmap(0, nil); err != nil { i.uploadingStagingBuffer.Unmap(0, nil)
return err
}
return nil return nil
} }

View File

@ -420,9 +420,7 @@ func (p *pipelineStates) useGraphicsPipelineState(device *_ID3D12Device, command
} }
copyFloat32s(m, uniforms) copyFloat32s(m, uniforms)
if err := cb.Unmap(0, nil); err != nil { cb.Unmap(0, nil)
return err
}
commandList.SetPipelineState(pipelineState) commandList.SetPipelineState(pipelineState)