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;
|
mType = Type::MetalLayer;
|
||||||
mMetalLayer = metalDesc->layer;
|
mMetalLayer = metalDesc->layer;
|
||||||
} else if (hwndDesc) {
|
} else if (hwndDesc) {
|
||||||
#if defined(DAWN_PLATFORM_WIN32)
|
|
||||||
mType = Type::WindowsHWND;
|
mType = Type::WindowsHWND;
|
||||||
mHInstance = hwndDesc->hinstance;
|
mHInstance = hwndDesc->hinstance;
|
||||||
mHWND = hwndDesc->hwnd;
|
mHWND = hwndDesc->hwnd;
|
||||||
#endif // defined(DAWN_PLATFORM_WIN32)
|
|
||||||
} else if (coreWindowDesc) {
|
} else if (coreWindowDesc) {
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||||
mType = Type::WindowsCoreWindow;
|
mType = Type::WindowsCoreWindow;
|
||||||
|
@ -180,7 +178,7 @@ namespace dawn_native {
|
||||||
return mHWND;
|
return mHWND;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Surface::GetCoreWindow() const {
|
IUnknown* Surface::GetCoreWindow() const {
|
||||||
ASSERT(mType == Type::WindowsCoreWindow);
|
ASSERT(mType == Type::WindowsCoreWindow);
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||||
return mCoreWindow.Get();
|
return mCoreWindow.Get();
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
# include "dawn_native/d3d12/d3d12_platform.h"
|
# include "dawn_native/d3d12/d3d12_platform.h"
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#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 {
|
namespace dawn_native {
|
||||||
|
|
||||||
MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance,
|
MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance,
|
||||||
|
@ -57,7 +62,7 @@ namespace dawn_native {
|
||||||
void* GetHWND() const;
|
void* GetHWND() const;
|
||||||
|
|
||||||
// Valid to call if the type is WindowsCoreWindow
|
// Valid to call if the type is WindowsCoreWindow
|
||||||
void* GetCoreWindow() const;
|
IUnknown* GetCoreWindow() const;
|
||||||
|
|
||||||
// Valid to call if the type is WindowsXlib
|
// Valid to call if the type is WindowsXlib
|
||||||
void* GetXDisplay() const;
|
void* GetXDisplay() const;
|
||||||
|
|
|
@ -245,7 +245,6 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
ComPtr<IDXGISwapChain1> swapChain1;
|
ComPtr<IDXGISwapChain1> swapChain1;
|
||||||
switch (GetSurface()->GetType()) {
|
switch (GetSurface()->GetType()) {
|
||||||
#if defined(DAWN_PLATFORM_WIN32)
|
|
||||||
case Surface::Type::WindowsHWND: {
|
case Surface::Type::WindowsHWND: {
|
||||||
DAWN_TRY(CheckHRESULT(
|
DAWN_TRY(CheckHRESULT(
|
||||||
factory2->CreateSwapChainForHwnd(device->GetCommandQueue().Get(),
|
factory2->CreateSwapChainForHwnd(device->GetCommandQueue().Get(),
|
||||||
|
@ -254,11 +253,10 @@ namespace dawn_native { namespace d3d12 {
|
||||||
"Creating the IDXGISwapChain1"));
|
"Creating the IDXGISwapChain1"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_WIN32)
|
|
||||||
case Surface::Type::WindowsCoreWindow: {
|
case Surface::Type::WindowsCoreWindow: {
|
||||||
DAWN_TRY(CheckHRESULT(factory2->CreateSwapChainForCoreWindow(
|
DAWN_TRY(CheckHRESULT(
|
||||||
device->GetCommandQueue().Get(),
|
factory2->CreateSwapChainForCoreWindow(device->GetCommandQueue().Get(),
|
||||||
static_cast<IUnknown*>(GetSurface()->GetCoreWindow()),
|
GetSurface()->GetCoreWindow(),
|
||||||
&swapChainDesc, nullptr, &swapChain1),
|
&swapChainDesc, nullptr, &swapChain1),
|
||||||
"Creating the IDXGISwapChain1"));
|
"Creating the IDXGISwapChain1"));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue