From cae4b2f4f96153ad4e0aef936f17aa18b289dc56 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 31 Jan 2024 01:33:43 +1100 Subject: [PATCH] [host] windows: fix compilation under gcc --- host/platform/Windows/CMakeLists.txt | 2 +- .../Windows/capture/D12/CMakeLists.txt | 3 +-- host/platform/Windows/capture/D12/d12.c | 19 ++++++++++++++++--- .../Windows/capture/DXGI/CMakeLists.txt | 1 + .../platform/Windows/capture/DXGI/src/d3d12.c | 8 +++++++- host/platform/Windows/include/com_ref.h | 5 +++++ 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/host/platform/Windows/CMakeLists.txt b/host/platform/Windows/CMakeLists.txt index 30989a00..0b59af56 100644 --- a/host/platform/Windows/CMakeLists.txt +++ b/host/platform/Windows/CMakeLists.txt @@ -16,7 +16,7 @@ add_library(platform_Windows STATIC # allow use of functions for Windows 7 or later add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601) -add_definitions("-DCOBJMACROS -DINITGUID -DWIDL_C_INLINE_WRAPPERS") +add_definitions("-DCOBJMACROS -DINITGUID") add_subdirectory("capture") diff --git a/host/platform/Windows/capture/D12/CMakeLists.txt b/host/platform/Windows/capture/D12/CMakeLists.txt index 7af46736..5e3d0572 100644 --- a/host/platform/Windows/capture/D12/CMakeLists.txt +++ b/host/platform/Windows/capture/D12/CMakeLists.txt @@ -6,10 +6,9 @@ add_library(capture_D12 STATIC backend/dd.c ) -add_definitions("-DCOBJMACROS -DINITGUID -DWIDL_C_INLINE_WRAPPERS") - target_link_libraries(capture_D12 lg_common + platform_Windows d3d11 dxgi dwmapi diff --git a/host/platform/Windows/capture/D12/d12.c b/host/platform/Windows/capture/D12/d12.c index 0a91bbff..6dc68173 100644 --- a/host/platform/Windows/capture/D12/d12.c +++ b/host/platform/Windows/capture/D12/d12.c @@ -111,6 +111,19 @@ static ID3D12Resource * d12_frameBufferToResource( FrameBuffer * frameBuffer, unsigned size); +// workarounds + +static D3D12_HEAP_DESC _ID3D12Heap_GetDesc(ID3D12Heap* This) +{ + D3D12_HEAP_DESC __ret; + return *This->lpVtbl->GetDesc(This, &__ret); +} + +static D3D12_RESOURCE_DESC _ID3D12Resource_GetDesc(ID3D12Resource* This) { + D3D12_RESOURCE_DESC __ret; + return *This->lpVtbl->GetDesc(This,&__ret); +} + // implementation static const char * d12_getName(void) @@ -262,7 +275,7 @@ retryCreateCommandQueue: } // Adjust the alignSize based on the required heap alignment - D3D12_HEAP_DESC heapDesc = ID3D12Heap_GetDesc(*ivshmemHeap); + D3D12_HEAP_DESC heapDesc = _ID3D12Heap_GetDesc(*ivshmemHeap); *alignSize = heapDesc.Alignment; // initialize the backend @@ -329,7 +342,7 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex, goto exit; } - D3D12_RESOURCE_DESC desc = ID3D12Resource_GetDesc(*src); + D3D12_RESOURCE_DESC desc = _ID3D12Resource_GetDesc(*src); if (desc.Width != this->lastFormat.Width || desc.Height != this->lastFormat.Height || desc.Format != this->lastFormat.Format) @@ -384,7 +397,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex, goto exit; // copy into the framebuffer resource - D3D12_RESOURCE_DESC desc = ID3D12Resource_GetDesc(*src); + D3D12_RESOURCE_DESC desc = _ID3D12Resource_GetDesc(*src); D3D12_TEXTURE_COPY_LOCATION srcLoc = { .pResource = *src, diff --git a/host/platform/Windows/capture/DXGI/CMakeLists.txt b/host/platform/Windows/capture/DXGI/CMakeLists.txt index b9f048ab..4e4a34f6 100644 --- a/host/platform/Windows/capture/DXGI/CMakeLists.txt +++ b/host/platform/Windows/capture/DXGI/CMakeLists.txt @@ -15,6 +15,7 @@ add_library(capture_DXGI STATIC target_link_libraries(capture_DXGI lg_common + platform_Windows d3d11 dxgi dwmapi diff --git a/host/platform/Windows/capture/DXGI/src/d3d12.c b/host/platform/Windows/capture/DXGI/src/d3d12.c index 3e1479fa..0433eb5f 100644 --- a/host/platform/Windows/capture/DXGI/src/d3d12.c +++ b/host/platform/Windows/capture/DXGI/src/d3d12.c @@ -95,6 +95,12 @@ typedef HRESULT (*D3D12GetDebugInterface_t)( void **ppvDebug ); +static D3D12_HEAP_DESC _ID3D12Heap_GetDesc(ID3D12Heap* This) +{ + D3D12_HEAP_DESC __ret; + return *This->lpVtbl->GetDesc(This, &__ret); +} + static void d3d12_free(void); static bool d3d12_create( @@ -189,7 +195,7 @@ static bool d3d12_create( return false; } - D3D12_HEAP_DESC heapDesc = ID3D12Heap_GetDesc(*heap); + D3D12_HEAP_DESC heapDesc = _ID3D12Heap_GetDesc(*heap); DEBUG_INFO("ID3D12Heap : Size:%I64u Alignment:%I64u", heapDesc.SizeInBytes, heapDesc.Alignment); *alignSize = heapDesc.Alignment; diff --git a/host/platform/Windows/include/com_ref.h b/host/platform/Windows/include/com_ref.h index 8b92ab26..5e22c9f4 100644 --- a/host/platform/Windows/include/com_ref.h +++ b/host/platform/Windows/include/com_ref.h @@ -18,6 +18,9 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _H_COMREF_ +#define _H_COMREF_ + #include #include #include @@ -96,3 +99,5 @@ inline static ULONG comRef_release(IUnknown ** ref) } #define comRef_release(ref) comRef_release((IUnknown **)(ref)) + +#endif