Remove unnecessary "#if def"s and type conversion in windows compilation.
Remove unnecessary "#if def"s. Forward declare IUnknown in Surface.h. Change Surface.GetCoreWindow's return type to IUnknown*. Remove unnecessary type conversion in SwapChainD3D12.cpp. Bug: dawn:766 Change-Id: Id9f4ae20a5ed52fe8338d4e1673588c828c4c5df Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50080 Commit-Queue: 陈俊嘉 <cjj19970505@live.cn> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
26f4383c6a
commit
e7a5fabf48
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -245,7 +245,6 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
ComPtr<IDXGISwapChain1> 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<IUnknown*>(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:
|
||||
|
|
Loading…
Reference in New Issue