diff --git a/src/dawn_native/Surface.cpp b/src/dawn_native/Surface.cpp index 3a68832c28..d78f3f3cf3 100644 --- a/src/dawn_native/Surface.cpp +++ b/src/dawn_native/Surface.cpp @@ -124,11 +124,9 @@ namespace dawn_native { mType = Type::MetalLayer; mMetalLayer = metalDesc->layer; } else if (hwndDesc) { -#if defined(DAWN_PLATFORM_WIN32) mType = Type::WindowsHWND; mHInstance = hwndDesc->hinstance; mHWND = hwndDesc->hwnd; -#endif // defined(DAWN_PLATFORM_WIN32) } else if (coreWindowDesc) { #if defined(DAWN_PLATFORM_WINDOWS) mType = Type::WindowsCoreWindow; @@ -180,7 +178,7 @@ namespace dawn_native { return mHWND; } - void* Surface::GetCoreWindow() const { + IUnknown* Surface::GetCoreWindow() const { ASSERT(mType == Type::WindowsCoreWindow); #if defined(DAWN_PLATFORM_WINDOWS) return mCoreWindow.Get(); diff --git a/src/dawn_native/Surface.h b/src/dawn_native/Surface.h index 2871bbb1ab..bdab2b45bc 100644 --- a/src/dawn_native/Surface.h +++ b/src/dawn_native/Surface.h @@ -27,6 +27,11 @@ # include "dawn_native/d3d12/d3d12_platform.h" #endif // defined(DAWN_PLATFORM_WINDOWS) +// Forward declare IUnknown +// GetCoreWindow needs to return an IUnknown pointer +// non-windows platforms don't have this type +struct IUnknown; + namespace dawn_native { MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance, @@ -57,7 +62,7 @@ namespace dawn_native { void* GetHWND() const; // Valid to call if the type is WindowsCoreWindow - void* GetCoreWindow() const; + IUnknown* GetCoreWindow() const; // Valid to call if the type is WindowsXlib void* GetXDisplay() const; diff --git a/src/dawn_native/d3d12/SwapChainD3D12.cpp b/src/dawn_native/d3d12/SwapChainD3D12.cpp index 166551338c..9002cc4c2d 100644 --- a/src/dawn_native/d3d12/SwapChainD3D12.cpp +++ b/src/dawn_native/d3d12/SwapChainD3D12.cpp @@ -245,7 +245,6 @@ namespace dawn_native { namespace d3d12 { ComPtr swapChain1; switch (GetSurface()->GetType()) { -#if defined(DAWN_PLATFORM_WIN32) case Surface::Type::WindowsHWND: { DAWN_TRY(CheckHRESULT( factory2->CreateSwapChainForHwnd(device->GetCommandQueue().Get(), @@ -254,13 +253,12 @@ namespace dawn_native { namespace d3d12 { "Creating the IDXGISwapChain1")); break; } -#endif // defined(DAWN_PLATFORM_WIN32) case Surface::Type::WindowsCoreWindow: { - DAWN_TRY(CheckHRESULT(factory2->CreateSwapChainForCoreWindow( - device->GetCommandQueue().Get(), - static_cast(GetSurface()->GetCoreWindow()), - &swapChainDesc, nullptr, &swapChain1), - "Creating the IDXGISwapChain1")); + DAWN_TRY(CheckHRESULT( + factory2->CreateSwapChainForCoreWindow(device->GetCommandQueue().Get(), + GetSurface()->GetCoreWindow(), + &swapChainDesc, nullptr, &swapChain1), + "Creating the IDXGISwapChain1")); break; } default: