mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 02:15:43 +00:00
Add UWP support
Add necessary cflags and cflags_cc for winrt compilation. Add 'dawn_is_winuwp'. Set 'dawn_enable_vulkan' and 'dawn_supports_glfw_for_windowing' when compiling for UWP. Link d3d12, d3d11 and dxgi stub libs when compiling for UWP. Use LoadPackagedLibrary instead of LoadLibraryA in DynamicLib when compiling for UWP. Swapchain related changes will be in another commit. Bug: dawn:766 Change-Id: I1210798a21cc175bab77281403d262d4bfb02d99 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/48480 Commit-Queue: 陈俊嘉 <cjj19970505@live.cn> Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
This commit is contained in:
committed by
Commit Bot service account
parent
e6a12d5efa
commit
02336e6f99
@@ -129,6 +129,16 @@ config("dawn_internal") {
|
||||
# Dawn extends wgpu enums with internal enums.
|
||||
# MSVC considers these invalid switch values. crbug.com/dawn/397.
|
||||
cflags += [ "/wd4063" ]
|
||||
if (dawn_is_winuwp) {
|
||||
# /ZW makes sure we don't add calls that are forbidden in UWP.
|
||||
# and /EHsc is required to be used in combination with it,
|
||||
# even if it is already added by the windows GN defaults,
|
||||
# we still add it to make every /ZW paired with a /EHsc
|
||||
cflags_cc = [
|
||||
"/ZW:nostdlib",
|
||||
"/EHsc",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
#if DAWN_PLATFORM_WINDOWS
|
||||
# include "common/windows_with_undefs.h"
|
||||
# if DAWN_PLATFORM_WINUWP
|
||||
# include "common/WindowsUtils.h"
|
||||
# endif
|
||||
#elif DAWN_PLATFORM_POSIX
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
@@ -43,8 +46,11 @@ bool DynamicLib::Valid() const {
|
||||
|
||||
bool DynamicLib::Open(const std::string& filename, std::string* error) {
|
||||
#if DAWN_PLATFORM_WINDOWS
|
||||
# if DAWN_PLATFORM_WINUWP
|
||||
mHandle = LoadPackagedLibrary(UTF8ToWStr(filename.c_str()).c_str(), 0);
|
||||
# else
|
||||
mHandle = LoadLibraryA(filename.c_str());
|
||||
|
||||
# endif
|
||||
if (mHandle == nullptr && error != nullptr) {
|
||||
*error = "Windows Error: " + std::to_string(GetLastError());
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ class PlacementAllocated {
|
||||
void operator delete(void* ptr) {
|
||||
// Object is placement-allocated. Don't free the memory.
|
||||
}
|
||||
|
||||
void operator delete(void*, void*) {
|
||||
// This is added to match new(size_t size, void* ptr)
|
||||
// Otherwise it triggers C4291 warning in MSVC
|
||||
}
|
||||
};
|
||||
|
||||
#endif // COMMON_PLACEMENTALLOCATED_H_
|
||||
|
||||
@@ -16,7 +16,15 @@
|
||||
#define COMMON_PLATFORM_H_
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# include <winapifamily.h>
|
||||
# define DAWN_PLATFORM_WINDOWS 1
|
||||
# if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
|
||||
# define DAWN_PLATFORM_WIN32 1
|
||||
# elif WINAPI_FAMILY == WINAPI_FAMILY_PC_APP
|
||||
# define DAWN_PLATFORM_WINUWP 1
|
||||
# else
|
||||
# error "Unsupported Windows platform."
|
||||
# endif
|
||||
|
||||
#elif defined(__linux__)
|
||||
# define DAWN_PLATFORM_LINUX 1
|
||||
|
||||
Reference in New Issue
Block a user