internal/glfwwin, internal/graphicsdriver/directx: bug fix: HRESULT and Errno are imcompatible

This commit is contained in:
Hajime Hoshi 2022-06-03 00:41:04 +09:00
parent 7d95dddb1a
commit c29c423686
2 changed files with 38 additions and 38 deletions

View File

@ -1072,7 +1072,7 @@ func _DragQueryPoint(hDrop _HDROP) (_POINT, bool) {
func _DwmEnableBlurBehindWindow(hWnd windows.HWND, pBlurBehind *_DWM_BLURBEHIND) error { func _DwmEnableBlurBehindWindow(hWnd windows.HWND, pBlurBehind *_DWM_BLURBEHIND) error {
r, _, _ := procDwmEnableBlurBehindWindow.Call(uintptr(hWnd), uintptr(unsafe.Pointer(pBlurBehind))) r, _, _ := procDwmEnableBlurBehindWindow.Call(uintptr(hWnd), uintptr(unsafe.Pointer(pBlurBehind)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("glfwwin: DwmEnableBlurBehindWindow failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("glfwwin: DwmEnableBlurBehindWindow failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1082,7 +1082,7 @@ func _DwmGetColorizationColor() (uint32, bool, error) {
var opaqueBlend int32 var opaqueBlend int32
r, _, _ := procDwmGetColorizationColor.Call(uintptr(unsafe.Pointer(&colorization)), uintptr(unsafe.Pointer(&opaqueBlend))) r, _, _ := procDwmGetColorizationColor.Call(uintptr(unsafe.Pointer(&colorization)), uintptr(unsafe.Pointer(&opaqueBlend)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return 0, false, fmt.Errorf("glfwwin: DwmGetColorizationColor failed: %w", windows.Errno(uint32(r))) return 0, false, fmt.Errorf("glfwwin: DwmGetColorizationColor failed: HRESULT(%d)", uint32(r))
} }
return colorization, opaqueBlend != 0, nil return colorization, opaqueBlend != 0, nil
} }
@ -1090,7 +1090,7 @@ func _DwmGetColorizationColor() (uint32, bool, error) {
func _DwmFlush() error { func _DwmFlush() error {
r, _, _ := procDwmFlush.Call() r, _, _ := procDwmFlush.Call()
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("glfwwin: DwmFlush failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("glfwwin: DwmFlush failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1099,7 +1099,7 @@ func _DwmIsCompositionEnabled() (bool, error) {
var enabled int32 var enabled int32
r, _, _ := procDwmIsCompositionEnabled.Call(uintptr(unsafe.Pointer(&enabled))) r, _, _ := procDwmIsCompositionEnabled.Call(uintptr(unsafe.Pointer(&enabled)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return false, fmt.Errorf("glfwwin: DwmIsCompositionEnabled failed: %w", windows.Errno(uint32(r))) return false, fmt.Errorf("glfwwin: DwmIsCompositionEnabled failed: HRESULT(%d)", uint32(r))
} }
return enabled != 0, nil return enabled != 0, nil
} }

View File

@ -894,10 +894,10 @@ var (
func _D3D12CreateDevice(pAdapter unsafe.Pointer, minimumFeatureLevel _D3D_FEATURE_LEVEL, riid *windows.GUID, ppDevice *unsafe.Pointer) error { func _D3D12CreateDevice(pAdapter unsafe.Pointer, minimumFeatureLevel _D3D_FEATURE_LEVEL, riid *windows.GUID, ppDevice *unsafe.Pointer) error {
r, _, _ := procD3D12CreateDevice.Call(uintptr(pAdapter), uintptr(minimumFeatureLevel), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(ppDevice))) r, _, _ := procD3D12CreateDevice.Call(uintptr(pAdapter), uintptr(minimumFeatureLevel), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(ppDevice)))
if ppDevice == nil && uint32(r) != uint32(windows.S_FALSE) { if ppDevice == nil && uint32(r) != uint32(windows.S_FALSE) {
return fmt.Errorf("directx: D3D12CreateDevice failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: D3D12CreateDevice failed: HRESULT(%d)", uint32(r))
} }
if ppDevice != nil && uint32(r) != uint32(windows.S_OK) { if ppDevice != nil && uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: D3D12CreateDevice failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: D3D12CreateDevice failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -906,7 +906,7 @@ func _D3D12GetDebugInterface() (*_ID3D12Debug, error) {
var debug *_ID3D12Debug var debug *_ID3D12Debug
r, _, _ := procD3D12GetDebugInterface.Call(uintptr(unsafe.Pointer(&_IID_ID3D12Debug)), uintptr(unsafe.Pointer(&debug))) r, _, _ := procD3D12GetDebugInterface.Call(uintptr(unsafe.Pointer(&_IID_ID3D12Debug)), uintptr(unsafe.Pointer(&debug)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: D3D12GetDebugInterface failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: D3D12GetDebugInterface failed: HRESULT(%d)", uint32(r))
} }
return debug, nil return debug, nil
} }
@ -918,9 +918,9 @@ func _D3D12SerializeRootSignature(pRootSignature *_D3D12_ROOT_SIGNATURE_DESC, ve
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
if errorBlob != nil { if errorBlob != nil {
defer errorBlob.Release() defer errorBlob.Release()
return nil, fmt.Errorf("directx: D3D12SerializeRootSignature failed: %s: %w", errorBlob.String(), windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: D3D12SerializeRootSignature failed: %s: HRESULT(%d)", errorBlob.String(), uint32(r))
} }
return nil, fmt.Errorf("directx: D3D12SerializeRootSignature failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: D3D12SerializeRootSignature failed: HRESULT(%d)", uint32(r))
} }
return blob, nil return blob, nil
} }
@ -928,7 +928,7 @@ func _D3D12SerializeRootSignature(pRootSignature *_D3D12_ROOT_SIGNATURE_DESC, ve
func _D3D12XboxCreateDevice(pAdapter unsafe.Pointer, pParameters *_D3D12XBOX_CREATE_DEVICE_PARAMETERS, riid *windows.GUID, ppDevice *unsafe.Pointer) error { func _D3D12XboxCreateDevice(pAdapter unsafe.Pointer, pParameters *_D3D12XBOX_CREATE_DEVICE_PARAMETERS, riid *windows.GUID, ppDevice *unsafe.Pointer) error {
r, _, _ := procD3D12XboxCreateDevice.Call(uintptr(pAdapter), uintptr(unsafe.Pointer(pParameters)), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(ppDevice))) r, _, _ := procD3D12XboxCreateDevice.Call(uintptr(pAdapter), uintptr(unsafe.Pointer(pParameters)), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(ppDevice)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: D3D12XboxCreateDevice failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: D3D12XboxCreateDevice failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -958,9 +958,9 @@ func _D3DCompile(srcData []byte, sourceName string, pDefines []_D3D_SHADER_MACRO
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
if errorMsgs != nil { if errorMsgs != nil {
defer errorMsgs.Release() defer errorMsgs.Release()
return nil, fmt.Errorf("directx: D3DCompile failed: %s: %w", errorMsgs.String(), windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: D3DCompile failed: %s: HRESULT(%d)", errorMsgs.String(), uint32(r))
} }
return nil, fmt.Errorf("directx: D3DCompile failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: D3DCompile failed: HRESULT(%d)", uint32(r))
} }
return code, nil return code, nil
} }
@ -969,7 +969,7 @@ func _CreateDXGIFactory2(flags uint32) (*_IDXGIFactory4, error) {
var factory *_IDXGIFactory4 var factory *_IDXGIFactory4
r, _, _ := procCreateDXGIFactory2.Call(uintptr(flags), uintptr(unsafe.Pointer(&_IID_IDXGIFactory4)), uintptr(unsafe.Pointer(&factory))) r, _, _ := procCreateDXGIFactory2.Call(uintptr(flags), uintptr(unsafe.Pointer(&_IID_IDXGIFactory4)), uintptr(unsafe.Pointer(&factory)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: CreateDXGIFactory2 failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: CreateDXGIFactory2 failed: HRESULT(%d)", uint32(r))
} }
return factory, nil return factory, nil
} }
@ -1111,7 +1111,7 @@ func (i *_ID3D12CommandAllocator) Release() {
func (i *_ID3D12CommandAllocator) Reset() error { func (i *_ID3D12CommandAllocator) Reset() error {
r, _, _ := syscall.Syscall(i.vtbl.Reset, 1, uintptr(unsafe.Pointer(i)), 0, 0) r, _, _ := syscall.Syscall(i.vtbl.Reset, 1, uintptr(unsafe.Pointer(i)), 0, 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12CommandAllocator::Reset failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12CommandAllocator::Reset failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1154,7 +1154,7 @@ func (i *_ID3D12CommandQueue) Signal(signal *_ID3D12Fence, value uint64) error {
uintptr(unsafe.Pointer(signal)), uintptr(value)) uintptr(unsafe.Pointer(signal)), uintptr(value))
runtime.KeepAlive(signal) runtime.KeepAlive(signal)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12CommandQueue::Signal failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12CommandQueue::Signal failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1223,7 +1223,7 @@ type _ID3D12DebugCommandList_Vtbl struct {
func (i *_ID3D12DebugCommandList) SetFeatureMask(mask _D3D12_DEBUG_FEATURE) error { func (i *_ID3D12DebugCommandList) SetFeatureMask(mask _D3D12_DEBUG_FEATURE) error {
r, _, _ := syscall.Syscall(i.vtbl.SetFeatureMask, 2, uintptr(unsafe.Pointer(i)), uintptr(mask), 0) r, _, _ := syscall.Syscall(i.vtbl.SetFeatureMask, 2, uintptr(unsafe.Pointer(i)), uintptr(mask), 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12DebugCommandList::SetFeatureMask failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12DebugCommandList::SetFeatureMask failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1324,7 +1324,7 @@ func (i *_ID3D12Device) CreateCommandAllocator(typ _D3D12_COMMAND_LIST_TYPE) (*_
uintptr(typ), uintptr(unsafe.Pointer(&_IID_ID3D12CommandAllocator)), uintptr(unsafe.Pointer(&commandAllocator)), uintptr(typ), uintptr(unsafe.Pointer(&_IID_ID3D12CommandAllocator)), uintptr(unsafe.Pointer(&commandAllocator)),
0, 0) 0, 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateCommandAllocator failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateCommandAllocator failed: HRESULT(%d)", uint32(r))
} }
return commandAllocator, nil return commandAllocator, nil
} }
@ -1338,7 +1338,7 @@ func (i *_ID3D12Device) CreateCommandList(nodeMask uint32, typ _D3D12_COMMAND_LI
runtime.KeepAlive(pCommandAllocator) runtime.KeepAlive(pCommandAllocator)
runtime.KeepAlive(pInitialState) runtime.KeepAlive(pInitialState)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateCommandList failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateCommandList failed: HRESULT(%d)", uint32(r))
} }
return commandList, nil return commandList, nil
} }
@ -1353,7 +1353,7 @@ func (i *_ID3D12Device) CreateCommittedResource(pHeapProperties *_D3D12_HEAP_PRO
runtime.KeepAlive(pDesc) runtime.KeepAlive(pDesc)
runtime.KeepAlive(pOptimizedClearValue) runtime.KeepAlive(pOptimizedClearValue)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateCommittedResource failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateCommittedResource failed: HRESULT(%d)", uint32(r))
} }
return resource, nil return resource, nil
} }
@ -1365,7 +1365,7 @@ func (i *_ID3D12Device) CreateCommandQueue(desc *_D3D12_COMMAND_QUEUE_DESC) (*_I
0, 0) 0, 0)
runtime.KeepAlive(desc) runtime.KeepAlive(desc)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateCommandQueue failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateCommandQueue failed: HRESULT(%d)", uint32(r))
} }
return commandQueue, nil return commandQueue, nil
} }
@ -1383,7 +1383,7 @@ func (i *_ID3D12Device) CreateDescriptorHeap(desc *_D3D12_DESCRIPTOR_HEAP_DESC)
0, 0) 0, 0)
runtime.KeepAlive(desc) runtime.KeepAlive(desc)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateDescriptorHeap failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateDescriptorHeap failed: HRESULT(%d)", uint32(r))
} }
return descriptorHeap, nil return descriptorHeap, nil
} }
@ -1403,7 +1403,7 @@ func (i *_ID3D12Device) CreateFence(initialValue uint64, flags _D3D12_FENCE_FLAG
uintptr(initialValue), uintptr(flags), uintptr(unsafe.Pointer(&_IID_ID3D12Fence)), uintptr(unsafe.Pointer(&fence)), uintptr(initialValue), uintptr(flags), uintptr(unsafe.Pointer(&_IID_ID3D12Fence)), uintptr(unsafe.Pointer(&fence)),
0) 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateFence failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateFence failed: HRESULT(%d)", uint32(r))
} }
return fence, nil return fence, nil
} }
@ -1415,7 +1415,7 @@ func (i *_ID3D12Device) CreateGraphicsPipelineState(pDesc *_D3D12_GRAPHICS_PIPEL
0, 0) 0, 0)
runtime.KeepAlive(pDesc) runtime.KeepAlive(pDesc)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateGraphicsPipelineState failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateGraphicsPipelineState failed: HRESULT(%d)", uint32(r))
} }
return pipelineState, nil return pipelineState, nil
} }
@ -1434,7 +1434,7 @@ func (i *_ID3D12Device) CreateRootSignature(nodeMask uint32, pBlobWithRootSignat
uintptr(nodeMask), pBlobWithRootSignature, blobLengthInBytes, uintptr(nodeMask), pBlobWithRootSignature, blobLengthInBytes,
uintptr(unsafe.Pointer(&_IID_ID3D12RootSignature)), uintptr(unsafe.Pointer(&signature))) uintptr(unsafe.Pointer(&_IID_ID3D12RootSignature)), uintptr(unsafe.Pointer(&signature)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Device::CreateRootSignature failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Device::CreateRootSignature failed: HRESULT(%d)", uint32(r))
} }
return signature, nil return signature, nil
} }
@ -1471,7 +1471,7 @@ func (i *_ID3D12Device) GetDescriptorHandleIncrementSize(descriptorHeapType _D3D
func (i *_ID3D12Device) GetDeviceRemovedReason() error { func (i *_ID3D12Device) GetDeviceRemovedReason() error {
r, _, _ := syscall.Syscall(i.vtbl.GetDeviceRemovedReason, 1, uintptr(unsafe.Pointer(i)), 0, 0) r, _, _ := syscall.Syscall(i.vtbl.GetDeviceRemovedReason, 1, uintptr(unsafe.Pointer(i)), 0, 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12Device::GetDeviceRemovedReason failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12Device::GetDeviceRemovedReason failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1510,7 +1510,7 @@ func (i *_ID3D12Fence) SetEventOnCompletion(value uint64, hEvent windows.Handle)
r, _, _ := syscall.Syscall(i.vtbl.SetEventOnCompletion, 3, uintptr(unsafe.Pointer(i)), r, _, _ := syscall.Syscall(i.vtbl.SetEventOnCompletion, 3, uintptr(unsafe.Pointer(i)),
uintptr(value), uintptr(hEvent)) uintptr(value), uintptr(hEvent))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12Fence::SetEventOnCompletion failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12Fence::SetEventOnCompletion failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1601,7 +1601,7 @@ func (i *_ID3D12GraphicsCommandList) ClearRenderTargetView(pRenderTargetView _D3
func (i *_ID3D12GraphicsCommandList) Close() error { func (i *_ID3D12GraphicsCommandList) Close() error {
r, _, _ := syscall.Syscall(i.vtbl.Close, 1, uintptr(unsafe.Pointer(i)), 0, 0) r, _, _ := syscall.Syscall(i.vtbl.Close, 1, uintptr(unsafe.Pointer(i)), 0, 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12GraphicsCommandList::Close failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12GraphicsCommandList::Close failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1666,7 +1666,7 @@ func (i *_ID3D12GraphicsCommandList) QueryInterface(riid *windows.GUID, ppvObjec
uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(ppvObject))) uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(ppvObject)))
runtime.KeepAlive(riid) runtime.KeepAlive(riid)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12GraphicsCommandList::QueryInterface failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12GraphicsCommandList::QueryInterface failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1681,7 +1681,7 @@ func (i *_ID3D12GraphicsCommandList) Reset(pAllocator *_ID3D12CommandAllocator,
runtime.KeepAlive(pAllocator) runtime.KeepAlive(pAllocator)
runtime.KeepAlive(pInitialState) runtime.KeepAlive(pInitialState)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: ID3D12GraphicsCommandList::Reset failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: ID3D12GraphicsCommandList::Reset failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -1787,7 +1787,7 @@ func (i *_ID3D12Resource) Map(subresource uint32, pReadRange *_D3D12_RANGE) (uns
0, 0) 0, 0)
runtime.KeepAlive(pReadRange) runtime.KeepAlive(pReadRange)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: ID3D12Resource::Map failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: ID3D12Resource::Map failed: HRESULT(%d)", uint32(r))
} }
return data, nil return data, nil
} }
@ -1866,7 +1866,7 @@ func (i *_IDXGIAdapter1) GetDesc1() (*_DXGI_ADAPTER_DESC1, error) {
var desc _DXGI_ADAPTER_DESC1 var desc _DXGI_ADAPTER_DESC1
r, _, _ := syscall.Syscall(i.vtbl.GetDesc1, 2, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&desc)), 0) r, _, _ := syscall.Syscall(i.vtbl.GetDesc1, 2, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&desc)), 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: IDXGIAdapter1::GetDesc1 failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: IDXGIAdapter1::GetDesc1 failed: HRESULT(%d)", uint32(r))
} }
return &desc, nil return &desc, nil
} }
@ -1915,7 +1915,7 @@ func (i *_IDXGIFactory4) CreateSwapChainForComposition(pDevice unsafe.Pointer, p
runtime.KeepAlive(pDesc) runtime.KeepAlive(pDesc)
runtime.KeepAlive(pRestrictToOutput) runtime.KeepAlive(pRestrictToOutput)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: IDXGIFactory4::CreateSwapChainForComposition failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: IDXGIFactory4::CreateSwapChainForComposition failed: HRESULT(%d)", uint32(r))
} }
return swapChain, nil return swapChain, nil
} }
@ -1930,7 +1930,7 @@ func (i *_IDXGIFactory4) CreateSwapChainForHwnd(pDevice unsafe.Pointer, hWnd win
runtime.KeepAlive(pFullscreenDesc) runtime.KeepAlive(pFullscreenDesc)
runtime.KeepAlive(pRestrictToOutput) runtime.KeepAlive(pRestrictToOutput)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: IDXGIFactory4::CreateSwapChainForHwnd failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: IDXGIFactory4::CreateSwapChainForHwnd failed: HRESULT(%d)", uint32(r))
} }
return swapChain, nil return swapChain, nil
} }
@ -1939,7 +1939,7 @@ func (i *_IDXGIFactory4) EnumAdapters1(adapter uint32) (*_IDXGIAdapter1, error)
var ptr *_IDXGIAdapter1 var ptr *_IDXGIAdapter1
r, _, _ := syscall.Syscall(i.vtbl.EnumAdapters1, 3, uintptr(unsafe.Pointer(i)), uintptr(adapter), uintptr(unsafe.Pointer(&ptr))) r, _, _ := syscall.Syscall(i.vtbl.EnumAdapters1, 3, uintptr(unsafe.Pointer(i)), uintptr(adapter), uintptr(unsafe.Pointer(&ptr)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: IDXGIFactory4::EnumAdapters1 failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: IDXGIFactory4::EnumAdapters1 failed: HRESULT(%d)", uint32(r))
} }
return ptr, nil return ptr, nil
} }
@ -1948,7 +1948,7 @@ func (i *_IDXGIFactory4) EnumWarpAdapter() (*_IDXGIAdapter1, error) {
var ptr *_IDXGIAdapter1 var ptr *_IDXGIAdapter1
r, _, _ := syscall.Syscall(i.vtbl.EnumWarpAdapter, 3, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&_IID_IDXGIAdapter1)), uintptr(unsafe.Pointer(&ptr))) r, _, _ := syscall.Syscall(i.vtbl.EnumWarpAdapter, 3, uintptr(unsafe.Pointer(i)), uintptr(unsafe.Pointer(&_IID_IDXGIAdapter1)), uintptr(unsafe.Pointer(&ptr)))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: IDXGIFactory4::EnumWarpAdapter failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: IDXGIFactory4::EnumWarpAdapter failed: HRESULT(%d)", uint32(r))
} }
return ptr, nil return ptr, nil
} }
@ -2101,7 +2101,7 @@ func (i *_IDXGISwapChain4) GetBuffer(buffer uint32) (*_ID3D12Resource, error) {
uintptr(buffer), uintptr(unsafe.Pointer(&_IID_ID3D12Resource)), uintptr(unsafe.Pointer(&resource)), uintptr(buffer), uintptr(unsafe.Pointer(&_IID_ID3D12Resource)), uintptr(unsafe.Pointer(&resource)),
0, 0) 0, 0)
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return nil, fmt.Errorf("directx: IDXGISwapChain4::GetBuffer failed: %w", windows.Errno(uint32(r))) return nil, fmt.Errorf("directx: IDXGISwapChain4::GetBuffer failed: HRESULT(%d)", uint32(r))
} }
return resource, nil return resource, nil
} }
@ -2114,7 +2114,7 @@ func (i *_IDXGISwapChain4) GetCurrentBackBufferIndex() uint32 {
func (i *_IDXGISwapChain4) Present(syncInterval uint32, flags uint32) error { func (i *_IDXGISwapChain4) Present(syncInterval uint32, flags uint32) error {
r, _, _ := syscall.Syscall(i.vtbl.Present, 3, uintptr(unsafe.Pointer(i)), uintptr(syncInterval), uintptr(flags)) r, _, _ := syscall.Syscall(i.vtbl.Present, 3, uintptr(unsafe.Pointer(i)), uintptr(syncInterval), uintptr(flags))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: IDXGISwapChain4::Present failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: IDXGISwapChain4::Present failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }
@ -2124,7 +2124,7 @@ func (i *_IDXGISwapChain4) ResizeBuffers(bufferCount uint32, width uint32, heigh
uintptr(unsafe.Pointer(i)), uintptr(bufferCount), uintptr(width), uintptr(unsafe.Pointer(i)), uintptr(bufferCount), uintptr(width),
uintptr(height), uintptr(newFormat), uintptr(swapChainFlags)) uintptr(height), uintptr(newFormat), uintptr(swapChainFlags))
if uint32(r) != uint32(windows.S_OK) { if uint32(r) != uint32(windows.S_OK) {
return fmt.Errorf("directx: IDXGISwapChain4::ResizeBuffers failed: %w", windows.Errno(uint32(r))) return fmt.Errorf("directx: IDXGISwapChain4::ResizeBuffers failed: HRESULT(%d)", uint32(r))
} }
return nil return nil
} }