mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Add support for UWP CoreWindow in SwapChain and Surface
Add SurfaceDescriptorFromWindowsCoreWindow structure in codegen. Add WindowsCoreWindow surface type. Add support for WindowsCoreWindow surface in SwapChain. Bug: dawn:766 Change-Id: If89258dc68896b9ba22c677d37ca3ba68c6fceb7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/48762 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: 陈俊嘉 <cjj19970505@live.cn>
This commit is contained in:
committed by
Commit Bot service account
parent
12c6305674
commit
74326fe2c8
@@ -20,8 +20,8 @@
|
||||
#include "dawn_native/SwapChain.h"
|
||||
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
# include "common/windows_with_undefs.h"
|
||||
#endif // DAWN_PLATFORM_WINDOWS
|
||||
# include <windows.ui.core.h>
|
||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
||||
|
||||
#if defined(DAWN_USE_X11)
|
||||
# include "common/xlib_with_undefs.h"
|
||||
@@ -40,9 +40,10 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateSingleSType(descriptor->nextInChain,
|
||||
wgpu::SType::SurfaceDescriptorFromMetalLayer,
|
||||
wgpu::SType::SurfaceDescriptorFromWindowsHWND,
|
||||
wgpu::SType::SurfaceDescriptorFromXlib));
|
||||
wgpu::SType::SurfaceDescriptorFromMetalLayer,
|
||||
wgpu::SType::SurfaceDescriptorFromWindowsHWND,
|
||||
wgpu::SType::SurfaceDescriptorFromWindowsCoreWindow,
|
||||
wgpu::SType::SurfaceDescriptorFromXlib));
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||
const SurfaceDescriptorFromMetalLayer* metalDesc = nullptr;
|
||||
@@ -56,17 +57,31 @@ namespace dawn_native {
|
||||
}
|
||||
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
||||
|
||||
#if defined(DAWN_PLATFORM_WIN32)
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
# if defined(DAWN_PLATFORM_WIN32)
|
||||
const SurfaceDescriptorFromWindowsHWND* hwndDesc = nullptr;
|
||||
FindInChain(descriptor->nextInChain, &hwndDesc);
|
||||
if (!hwndDesc) {
|
||||
return DAWN_VALIDATION_ERROR("Unsupported sType");
|
||||
if (hwndDesc) {
|
||||
if (IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0) {
|
||||
return DAWN_VALIDATION_ERROR("Invalid HWND");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
// Validate the hwnd using the windows.h IsWindow function.
|
||||
if (IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0) {
|
||||
return DAWN_VALIDATION_ERROR("Invalid HWND");
|
||||
# endif // defined(DAWN_PLATFORM_WIN32)
|
||||
const SurfaceDescriptorFromWindowsCoreWindow* coreWindowDesc = nullptr;
|
||||
FindInChain(descriptor->nextInChain, &coreWindowDesc);
|
||||
if (coreWindowDesc) {
|
||||
// Validate the coreWindow by query for ICoreWindow interface
|
||||
ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow;
|
||||
if (coreWindowDesc->coreWindow == nullptr ||
|
||||
FAILED(static_cast<IUnknown*>(coreWindowDesc->coreWindow)
|
||||
->QueryInterface(IID_PPV_ARGS(&coreWindow)))) {
|
||||
return DAWN_VALIDATION_ERROR("Invalid CoreWindow");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
#endif // defined(DAWN_PLATFORM_WIN32)
|
||||
return DAWN_VALIDATION_ERROR("Unsupported sType");
|
||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
||||
|
||||
#if defined(DAWN_USE_X11)
|
||||
const SurfaceDescriptorFromXlib* xDesc = nullptr;
|
||||
@@ -98,22 +113,33 @@ namespace dawn_native {
|
||||
ASSERT(descriptor->nextInChain != nullptr);
|
||||
const SurfaceDescriptorFromMetalLayer* metalDesc = nullptr;
|
||||
const SurfaceDescriptorFromWindowsHWND* hwndDesc = nullptr;
|
||||
const SurfaceDescriptorFromWindowsCoreWindow* coreWindowDesc = nullptr;
|
||||
const SurfaceDescriptorFromXlib* xDesc = nullptr;
|
||||
FindInChain(descriptor->nextInChain, &metalDesc);
|
||||
FindInChain(descriptor->nextInChain, &hwndDesc);
|
||||
FindInChain(descriptor->nextInChain, &coreWindowDesc);
|
||||
FindInChain(descriptor->nextInChain, &xDesc);
|
||||
ASSERT(metalDesc || hwndDesc || xDesc);
|
||||
if (metalDesc) {
|
||||
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;
|
||||
mCoreWindow = static_cast<IUnknown*>(coreWindowDesc->coreWindow);
|
||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
||||
} else if (xDesc) {
|
||||
mType = Type::Xlib;
|
||||
mXDisplay = xDesc->display;
|
||||
mXWindow = xDesc->window;
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +180,15 @@ namespace dawn_native {
|
||||
return mHWND;
|
||||
}
|
||||
|
||||
void* Surface::GetCoreWindow() const {
|
||||
ASSERT(mType == Type::WindowsCoreWindow);
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
return mCoreWindow.Get();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void* Surface::GetXDisplay() const {
|
||||
ASSERT(mType == Type::Xlib);
|
||||
return mXDisplay;
|
||||
|
||||
Reference in New Issue
Block a user