DAWN_PLATFORM and DAWN_COMPILER macro improvements
Change #if DAWN_PLATFORM_XXX to #if DAWN_PLATFORM_IS(XXX) To prevent #ifdef usage and reference without including dawn/common/Platform.h Also change #if DAWN_COMPILER_XXX to # if DAWN_COMPILER_IS(XXX) Bug: dawn:1447 Change-Id: If6c9dab15fd2676f9a087507f5efcceeff468d33 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92625 Commit-Queue: Shrek Shao <shrekshao@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
736e97c5e0
commit
7e74c21873
|
@ -69,7 +69,7 @@ struct ExternalImageExportInfoVk : ExternalImageExportInfo {
|
||||||
using ExternalImageExportInfo::ExternalImageExportInfo;
|
using ExternalImageExportInfo::ExternalImageExportInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Can't use DAWN_PLATFORM_LINUX since header included in both Dawn and Chrome
|
// Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
// Common properties of external images represented by FDs. On successful import the file
|
// Common properties of external images represented by FDs. On successful import the file
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
// MSVC triggers a warning in /W4 for do {} while(0). SDL worked around this by using (0,0) and
|
// MSVC triggers a warning in /W4 for do {} while(0). SDL worked around this by using (0,0) and
|
||||||
// points out that it looks like an owl face.
|
// points out that it looks like an owl face.
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
#define DAWN_ASSERT_LOOP_CONDITION (0, 0)
|
#define DAWN_ASSERT_LOOP_CONDITION (0, 0)
|
||||||
#else
|
#else
|
||||||
#define DAWN_ASSERT_LOOP_CONDITION (0)
|
#define DAWN_ASSERT_LOOP_CONDITION (0)
|
||||||
|
@ -48,9 +48,9 @@
|
||||||
} \
|
} \
|
||||||
} while (DAWN_ASSERT_LOOP_CONDITION)
|
} while (DAWN_ASSERT_LOOP_CONDITION)
|
||||||
#else
|
#else
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
|
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
|
||||||
#elif defined(DAWN_COMPILER_CLANG) && defined(__builtin_assume)
|
#elif DAWN_COMPILER_IS(CLANG) && defined(__builtin_assume)
|
||||||
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
|
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
|
||||||
#else
|
#else
|
||||||
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define SRC_DAWN_COMMON_COMPILER_H_
|
#define SRC_DAWN_COMMON_COMPILER_H_
|
||||||
|
|
||||||
// Defines macros for compiler-specific functionality
|
// Defines macros for compiler-specific functionality
|
||||||
// - DAWN_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
|
// - DAWN_COMPILER_IS(CLANG|GCC|MSVC): Compiler detection
|
||||||
// - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
|
// - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
|
||||||
// - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
|
// - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
|
||||||
// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
|
// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
|
||||||
|
@ -30,9 +30,9 @@
|
||||||
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
|
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#define DAWN_COMPILER_CLANG
|
#define DAWN_COMPILER_IS_CLANG 1
|
||||||
#else
|
#else
|
||||||
#define DAWN_COMPILER_GCC
|
#define DAWN_COMPILER_IS_GCC 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
// MSVC
|
// MSVC
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define DAWN_COMPILER_MSVC
|
#define DAWN_COMPILER_IS_MSVC 1
|
||||||
|
|
||||||
extern void __cdecl __debugbreak(void);
|
extern void __cdecl __debugbreak(void);
|
||||||
#define DAWN_BREAKPOINT() __debugbreak()
|
#define DAWN_BREAKPOINT() __debugbreak()
|
||||||
|
@ -75,6 +75,23 @@ extern void __cdecl __debugbreak(void);
|
||||||
#error "Unsupported compiler"
|
#error "Unsupported compiler"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This section defines other compiler macros to 0 to avoid undefined macro usage error.
|
||||||
|
#if !defined(DAWN_COMPILER_IS_CLANG)
|
||||||
|
#define DAWN_COMPILER_IS_CLANG 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_COMPILER_IS_GCC)
|
||||||
|
#define DAWN_COMPILER_IS_GCC 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_COMPILER_IS_MSVC)
|
||||||
|
#define DAWN_COMPILER_IS_MSVC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Use #if DAWN_COMPILER_IS(XXX) for compiler specific code.
|
||||||
|
// Do not use #ifdef or the naked macro DAWN_COMPILER_IS_XXX.
|
||||||
|
// This can help avoid common mistakes like not including "Compiler.h" and falling into unwanted
|
||||||
|
// code block as usage of undefined macro "function" will be blocked by the compiler.
|
||||||
|
#define DAWN_COMPILER_IS(X) (1 == DAWN_COMPILER_IS_##X)
|
||||||
|
|
||||||
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
|
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
|
||||||
#define DAWN_UNUSED(EXPR) (void)EXPR
|
#define DAWN_UNUSED(EXPR) (void)EXPR
|
||||||
// Likewise using static asserting on sizeof(&FUNC) seems to make it tagged as used
|
// Likewise using static asserting on sizeof(&FUNC) seems to make it tagged as used
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if DAWN_PLATFORM_WINDOWS
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include "dawn/common/windows_with_undefs.h"
|
#include "dawn/common/windows_with_undefs.h"
|
||||||
#if DAWN_PLATFORM_WINUWP
|
#if DAWN_PLATFORM_IS(WINUWP)
|
||||||
#include "dawn/common/WindowsUtils.h"
|
#include "dawn/common/WindowsUtils.h"
|
||||||
#endif
|
#endif
|
||||||
#elif DAWN_PLATFORM_POSIX
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#else
|
#else
|
||||||
#error "Unsupported platform for DynamicLib"
|
#error "Unsupported platform for DynamicLib"
|
||||||
|
@ -47,8 +47,8 @@ bool DynamicLib::Valid() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicLib::Open(const std::string& filename, std::string* error) {
|
bool DynamicLib::Open(const std::string& filename, std::string* error) {
|
||||||
#if DAWN_PLATFORM_WINDOWS
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#if DAWN_PLATFORM_WINUWP
|
#if DAWN_PLATFORM_IS(WINUWP)
|
||||||
mHandle = LoadPackagedLibrary(UTF8ToWStr(filename.c_str()).c_str(), 0);
|
mHandle = LoadPackagedLibrary(UTF8ToWStr(filename.c_str()).c_str(), 0);
|
||||||
#else
|
#else
|
||||||
mHandle = LoadLibraryA(filename.c_str());
|
mHandle = LoadLibraryA(filename.c_str());
|
||||||
|
@ -56,7 +56,7 @@ bool DynamicLib::Open(const std::string& filename, std::string* error) {
|
||||||
if (mHandle == nullptr && error != nullptr) {
|
if (mHandle == nullptr && error != nullptr) {
|
||||||
*error = "Windows Error: " + std::to_string(GetLastError());
|
*error = "Windows Error: " + std::to_string(GetLastError());
|
||||||
}
|
}
|
||||||
#elif DAWN_PLATFORM_POSIX
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
mHandle = dlopen(filename.c_str(), RTLD_NOW);
|
mHandle = dlopen(filename.c_str(), RTLD_NOW);
|
||||||
|
|
||||||
if (mHandle == nullptr && error != nullptr) {
|
if (mHandle == nullptr && error != nullptr) {
|
||||||
|
@ -74,9 +74,9 @@ void DynamicLib::Close() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DAWN_PLATFORM_WINDOWS
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
FreeLibrary(static_cast<HMODULE>(mHandle));
|
FreeLibrary(static_cast<HMODULE>(mHandle));
|
||||||
#elif DAWN_PLATFORM_POSIX
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
dlclose(mHandle);
|
dlclose(mHandle);
|
||||||
#else
|
#else
|
||||||
#error "Unsupported platform for DynamicLib"
|
#error "Unsupported platform for DynamicLib"
|
||||||
|
@ -88,13 +88,13 @@ void DynamicLib::Close() {
|
||||||
void* DynamicLib::GetProc(const std::string& procName, std::string* error) const {
|
void* DynamicLib::GetProc(const std::string& procName, std::string* error) const {
|
||||||
void* proc = nullptr;
|
void* proc = nullptr;
|
||||||
|
|
||||||
#if DAWN_PLATFORM_WINDOWS
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
proc = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(mHandle), procName.c_str()));
|
proc = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(mHandle), procName.c_str()));
|
||||||
|
|
||||||
if (proc == nullptr && error != nullptr) {
|
if (proc == nullptr && error != nullptr) {
|
||||||
*error = "Windows Error: " + std::to_string(GetLastError());
|
*error = "Windows Error: " + std::to_string(GetLastError());
|
||||||
}
|
}
|
||||||
#elif DAWN_PLATFORM_POSIX
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
proc = reinterpret_cast<void*>(dlsym(mHandle, procName.c_str()));
|
proc = reinterpret_cast<void*>(dlsym(mHandle, procName.c_str()));
|
||||||
|
|
||||||
if (proc == nullptr && error != nullptr) {
|
if (proc == nullptr && error != nullptr) {
|
||||||
|
|
|
@ -45,9 +45,9 @@ size_t Hash(const TypedInteger<Tag, T>& value) {
|
||||||
// return hash;
|
// return hash;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void HashCombine(size_t* hash, const T& value) {
|
void HashCombine(size_t* hash, const T& value) {
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
#if DAWN_PLATFORM_IS(64_BIT)
|
||||||
const size_t offset = 0x9e3779b97f4a7c16;
|
const size_t offset = 0x9e3779b97f4a7c16;
|
||||||
#elif defined(DAWN_PLATFORM_32_BIT)
|
#elif DAWN_PLATFORM_IS(32_BIT)
|
||||||
const size_t offset = 0x9e3779b9;
|
const size_t offset = 0x9e3779b9;
|
||||||
#else
|
#else
|
||||||
#error "Unsupported platform"
|
#error "Unsupported platform"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "dawn/common/Assert.h"
|
#include "dawn/common/Assert.h"
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ const char* SeverityName(LogSeverity severity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
android_LogPriority AndroidLogPriority(LogSeverity severity) {
|
android_LogPriority AndroidLogPriority(LogSeverity severity) {
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case LogSeverity::Debug:
|
case LogSeverity::Debug:
|
||||||
|
@ -60,7 +60,7 @@ android_LogPriority AndroidLogPriority(LogSeverity severity) {
|
||||||
return ANDROID_LOG_ERROR;
|
return ANDROID_LOG_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
@ -85,10 +85,10 @@ LogMessage::~LogMessage() {
|
||||||
|
|
||||||
const char* severityName = SeverityName(mSeverity);
|
const char* severityName = SeverityName(mSeverity);
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
android_LogPriority androidPriority = AndroidLogPriority(mSeverity);
|
android_LogPriority androidPriority = AndroidLogPriority(mSeverity);
|
||||||
__android_log_print(androidPriority, "Dawn", "%s: %s\n", severityName, fullMessage.c_str());
|
__android_log_print(androidPriority, "Dawn", "%s: %s\n", severityName, fullMessage.c_str());
|
||||||
#else // defined(DAWN_PLATFORM_ANDROID)
|
#else // DAWN_PLATFORM_IS(ANDROID)
|
||||||
FILE* outputStream = stdout;
|
FILE* outputStream = stdout;
|
||||||
if (mSeverity == LogSeverity::Warning || mSeverity == LogSeverity::Error) {
|
if (mSeverity == LogSeverity::Warning || mSeverity == LogSeverity::Error) {
|
||||||
outputStream = stderr;
|
outputStream = stderr;
|
||||||
|
@ -97,7 +97,7 @@ LogMessage::~LogMessage() {
|
||||||
// Note: we use fprintf because <iostream> includes static initializers.
|
// Note: we use fprintf because <iostream> includes static initializers.
|
||||||
fprintf(outputStream, "%s: %s\n", severityName, fullMessage.c_str());
|
fprintf(outputStream, "%s: %s\n", severityName, fullMessage.c_str());
|
||||||
fflush(outputStream);
|
fflush(outputStream);
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage DebugLog() {
|
LogMessage DebugLog() {
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
#include "dawn/common/Assert.h"
|
#include "dawn/common/Assert.h"
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t ScanForward(uint32_t bits) {
|
uint32_t ScanForward(uint32_t bits) {
|
||||||
ASSERT(bits != 0);
|
ASSERT(bits != 0);
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
// NOLINTNEXTLINE(runtime/int)
|
// NOLINTNEXTLINE(runtime/int)
|
||||||
unsigned long firstBitIndex = 0ul;
|
unsigned long firstBitIndex = 0ul;
|
||||||
unsigned char ret = _BitScanForward(&firstBitIndex, bits);
|
unsigned char ret = _BitScanForward(&firstBitIndex, bits);
|
||||||
|
@ -40,7 +40,7 @@ uint32_t ScanForward(uint32_t bits) {
|
||||||
|
|
||||||
uint32_t Log2(uint32_t value) {
|
uint32_t Log2(uint32_t value) {
|
||||||
ASSERT(value != 0);
|
ASSERT(value != 0);
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
// NOLINTNEXTLINE(runtime/int)
|
// NOLINTNEXTLINE(runtime/int)
|
||||||
unsigned long firstBitIndex = 0ul;
|
unsigned long firstBitIndex = 0ul;
|
||||||
unsigned char ret = _BitScanReverse(&firstBitIndex, value);
|
unsigned char ret = _BitScanReverse(&firstBitIndex, value);
|
||||||
|
@ -53,14 +53,14 @@ uint32_t Log2(uint32_t value) {
|
||||||
|
|
||||||
uint32_t Log2(uint64_t value) {
|
uint32_t Log2(uint64_t value) {
|
||||||
ASSERT(value != 0);
|
ASSERT(value != 0);
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
#if DAWN_PLATFORM_IS(64_BIT)
|
||||||
// NOLINTNEXTLINE(runtime/int)
|
// NOLINTNEXTLINE(runtime/int)
|
||||||
unsigned long firstBitIndex = 0ul;
|
unsigned long firstBitIndex = 0ul;
|
||||||
unsigned char ret = _BitScanReverse64(&firstBitIndex, value);
|
unsigned char ret = _BitScanReverse64(&firstBitIndex, value);
|
||||||
ASSERT(ret != 0);
|
ASSERT(ret != 0);
|
||||||
return firstBitIndex;
|
return firstBitIndex;
|
||||||
#else // defined(DAWN_PLATFORM_64_BIT)
|
#else // DAWN_PLATFORM_IS(64_BIT)
|
||||||
// NOLINTNEXTLINE(runtime/int)
|
// NOLINTNEXTLINE(runtime/int)
|
||||||
unsigned long firstBitIndex = 0ul;
|
unsigned long firstBitIndex = 0ul;
|
||||||
if (_BitScanReverse(&firstBitIndex, value >> 32)) {
|
if (_BitScanReverse(&firstBitIndex, value >> 32)) {
|
||||||
|
@ -69,10 +69,10 @@ uint32_t Log2(uint64_t value) {
|
||||||
unsigned char ret = _BitScanReverse(&firstBitIndex, value & 0xFFFFFFFF);
|
unsigned char ret = _BitScanReverse(&firstBitIndex, value & 0xFFFFFFFF);
|
||||||
ASSERT(ret != 0);
|
ASSERT(ret != 0);
|
||||||
return firstBitIndex;
|
return firstBitIndex;
|
||||||
#endif // defined(DAWN_PLATFORM_64_BIT)
|
#endif // DAWN_PLATFORM_IS(64_BIT)
|
||||||
#else // defined(DAWN_COMPILER_MSVC)
|
#else // DAWN_COMPILER_IS(MSVC)
|
||||||
return 63 - static_cast<uint32_t>(__builtin_clzll(value));
|
return 63 - static_cast<uint32_t>(__builtin_clzll(value));
|
||||||
#endif // defined(DAWN_COMPILER_MSVC)
|
#endif // DAWN_COMPILER_IS(MSVC)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t NextPowerOfTwo(uint64_t n) {
|
uint64_t NextPowerOfTwo(uint64_t n) {
|
||||||
|
|
|
@ -17,41 +17,41 @@
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#include <winapifamily.h>
|
#include <winapifamily.h>
|
||||||
#define DAWN_PLATFORM_WINDOWS 1
|
#define DAWN_PLATFORM_IS_WINDOWS 1
|
||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
|
#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
|
||||||
#define DAWN_PLATFORM_WIN32 1
|
#define DAWN_PLATFORM_IS_WIN32 1
|
||||||
#elif WINAPI_FAMILY == WINAPI_FAMILY_PC_APP
|
#elif WINAPI_FAMILY == WINAPI_FAMILY_PC_APP
|
||||||
#define DAWN_PLATFORM_WINUWP 1
|
#define DAWN_PLATFORM_IS_WINUWP 1
|
||||||
#else
|
#else
|
||||||
#error "Unsupported Windows platform."
|
#error "Unsupported Windows platform."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#define DAWN_PLATFORM_LINUX 1
|
#define DAWN_PLATFORM_IS_LINUX 1
|
||||||
#define DAWN_PLATFORM_POSIX 1
|
#define DAWN_PLATFORM_IS_POSIX 1
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#define DAWN_PLATFORM_ANDROID 1
|
#define DAWN_PLATFORM_IS_ANDROID 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define DAWN_PLATFORM_APPLE 1
|
#define DAWN_PLATFORM_IS_APPLE 1
|
||||||
#define DAWN_PLATFORM_POSIX 1
|
#define DAWN_PLATFORM_IS_POSIX 1
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
#define DAWN_PLATFORM_IOS
|
#define DAWN_PLATFORM_IS_IOS 1
|
||||||
#elif TARGET_OS_MAC
|
#elif TARGET_OS_MAC
|
||||||
#define DAWN_PLATFORM_MACOS
|
#define DAWN_PLATFORM_IS_MACOS 1
|
||||||
#else
|
#else
|
||||||
#error "Unsupported Apple platform."
|
#error "Unsupported Apple platform."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__Fuchsia__)
|
#elif defined(__Fuchsia__)
|
||||||
#define DAWN_PLATFORM_FUCHSIA 1
|
#define DAWN_PLATFORM_IS_FUCHSIA 1
|
||||||
#define DAWN_PLATFORM_POSIX 1
|
#define DAWN_PLATFORM_IS_POSIX 1
|
||||||
|
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
#define DAWN_PLATFORM_EMSCRIPTEN 1
|
#define DAWN_PLATFORM_IS_EMSCRIPTEN 1
|
||||||
#define DAWN_PLATFORM_POSIX 1
|
#define DAWN_PLATFORM_IS_POSIX 1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Unsupported platform."
|
#error "Unsupported platform."
|
||||||
|
@ -69,14 +69,66 @@
|
||||||
|
|
||||||
#if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__) || defined(__mips64__) || \
|
#if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__) || defined(__mips64__) || \
|
||||||
defined(__s390x__) || defined(__PPC64__)
|
defined(__s390x__) || defined(__PPC64__)
|
||||||
#define DAWN_PLATFORM_64_BIT 1
|
#define DAWN_PLATFORM_IS_64_BIT 1
|
||||||
static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
|
static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
|
||||||
#elif defined(_WIN32) || defined(__arm__) || defined(__i386__) || defined(__mips32__) || \
|
#elif defined(_WIN32) || defined(__arm__) || defined(__i386__) || defined(__mips32__) || \
|
||||||
defined(__s390__) || defined(__EMSCRIPTEN__)
|
defined(__s390__) || defined(__EMSCRIPTEN__)
|
||||||
#define DAWN_PLATFORM_32_BIT 1
|
#define DAWN_PLATFORM_IS_32_BIT 1
|
||||||
static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
|
static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
|
||||||
#else
|
#else
|
||||||
#error "Unsupported platform"
|
#error "Unsupported platform"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This section define other platform macros to 0 to avoid undefined macro usage error.
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_WINDOWS)
|
||||||
|
#define DAWN_PLATFORM_IS_WINDOWS 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_WIN32)
|
||||||
|
#define DAWN_PLATFORM_IS_WIN32 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_WINUWP)
|
||||||
|
#define DAWN_PLATFORM_IS_WINUWP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_POSIX)
|
||||||
|
#define DAWN_PLATFORM_IS_POSIX 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_LINUX)
|
||||||
|
#define DAWN_PLATFORM_IS_LINUX 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_ANDROID)
|
||||||
|
#define DAWN_PLATFORM_IS_ANDROID 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_APPLE)
|
||||||
|
#define DAWN_PLATFORM_IS_APPLE 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_IOS)
|
||||||
|
#define DAWN_PLATFORM_IS_IOS 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_MACOS)
|
||||||
|
#define DAWN_PLATFORM_IS_MACOS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_FUCHSIA)
|
||||||
|
#define DAWN_PLATFORM_IS_FUCHSIA 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_EMSCRIPTEN)
|
||||||
|
#define DAWN_PLATFORM_IS_EMSCRIPTEN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_64_BIT)
|
||||||
|
#define DAWN_PLATFORM_IS_64_BIT 0
|
||||||
|
#endif
|
||||||
|
#if !defined(DAWN_PLATFORM_IS_32_BIT)
|
||||||
|
#define DAWN_PLATFORM_IS_32_BIT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Use #if DAWN_PLATFORM_IS(XXX) for platform specific code.
|
||||||
|
// Do not use #ifdef or the naked macro DAWN_PLATFORM_IS_XXX.
|
||||||
|
// This can help avoid common mistakes like not including "Platform.h" and falling into unwanted
|
||||||
|
// code block as usage of undefined macro "function" will be blocked by the compiler.
|
||||||
|
#define DAWN_PLATFORM_IS(X) (1 == DAWN_PLATFORM_IS_##X)
|
||||||
|
|
||||||
#endif // SRC_DAWN_COMMON_PLATFORM_H_
|
#endif // SRC_DAWN_COMMON_PLATFORM_H_
|
||||||
|
|
|
@ -51,7 +51,7 @@ class StackAllocator : public std::allocator<T> {
|
||||||
// constructors and destructors to be automatically called. Define a POD
|
// constructors and destructors to be automatically called. Define a POD
|
||||||
// buffer of the right size instead.
|
// buffer of the right size instead.
|
||||||
alignas(T) char stack_buffer_[sizeof(T[stack_capacity])];
|
alignas(T) char stack_buffer_[sizeof(T[stack_capacity])];
|
||||||
#if defined(DAWN_COMPILER_GCC) && !defined(__x86_64__) && !defined(__i386__)
|
#if DAWN_COMPILER_IS(GCC) && !defined(__x86_64__) && !defined(__i386__)
|
||||||
static_assert(alignof(T) <= 16, "http://crbug.com/115612");
|
static_assert(alignof(T) <= 16, "http://crbug.com/115612");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
#include "dawn/common/Assert.h"
|
#include "dawn/common/Assert.h"
|
||||||
#include "dawn/common/Log.h"
|
#include "dawn/common/Log.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#elif defined(DAWN_PLATFORM_LINUX)
|
#elif DAWN_PLATFORM_IS(LINUX)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#elif defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
|
#elif DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
const char* GetPathSeparator() {
|
const char* GetPathSeparator() {
|
||||||
return "\\";
|
return "\\";
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ std::pair<std::string, bool> GetEnvironmentVar(const char* variableName) {
|
||||||
bool SetEnvironmentVar(const char* variableName, const char* value) {
|
bool SetEnvironmentVar(const char* variableName, const char* value) {
|
||||||
return SetEnvironmentVariableA(variableName, value) == TRUE;
|
return SetEnvironmentVariableA(variableName, value) == TRUE;
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_POSIX)
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
const char* GetPathSeparator() {
|
const char* GetPathSeparator() {
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ bool SetEnvironmentVar(const char* variableName, const char* value) {
|
||||||
#error "Implement Get/SetEnvironmentVar for your platform."
|
#error "Implement Get/SetEnvironmentVar for your platform."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
std::optional<std::string> GetHModulePath(HMODULE module) {
|
std::optional<std::string> GetHModulePath(HMODULE module) {
|
||||||
std::array<char, MAX_PATH> executableFileBuf;
|
std::array<char, MAX_PATH> executableFileBuf;
|
||||||
DWORD executablePathLen = GetModuleFileNameA(nullptr, executableFileBuf.data(),
|
DWORD executablePathLen = GetModuleFileNameA(nullptr, executableFileBuf.data(),
|
||||||
|
@ -100,7 +100,7 @@ std::optional<std::string> GetHModulePath(HMODULE module) {
|
||||||
std::optional<std::string> GetExecutablePath() {
|
std::optional<std::string> GetExecutablePath() {
|
||||||
return GetHModulePath(nullptr);
|
return GetHModulePath(nullptr);
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_LINUX)
|
#elif DAWN_PLATFORM_IS(LINUX)
|
||||||
std::optional<std::string> GetExecutablePath() {
|
std::optional<std::string> GetExecutablePath() {
|
||||||
std::array<char, PATH_MAX> path;
|
std::array<char, PATH_MAX> path;
|
||||||
ssize_t result = readlink("/proc/self/exe", path.data(), PATH_MAX - 1);
|
ssize_t result = readlink("/proc/self/exe", path.data(), PATH_MAX - 1);
|
||||||
|
@ -111,7 +111,7 @@ std::optional<std::string> GetExecutablePath() {
|
||||||
path[result] = '\0';
|
path[result] = '\0';
|
||||||
return path.data();
|
return path.data();
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
|
#elif DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
|
||||||
std::optional<std::string> GetExecutablePath() {
|
std::optional<std::string> GetExecutablePath() {
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
_NSGetExecutablePath(nullptr, &size);
|
_NSGetExecutablePath(nullptr, &size);
|
||||||
|
@ -124,12 +124,12 @@ std::optional<std::string> GetExecutablePath() {
|
||||||
buffer[size] = '\0';
|
buffer[size] = '\0';
|
||||||
return buffer.data();
|
return buffer.data();
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_FUCHSIA)
|
#elif DAWN_PLATFORM_IS(FUCHSIA)
|
||||||
std::optional<std::string> GetExecutablePath() {
|
std::optional<std::string> GetExecutablePath() {
|
||||||
// UNIMPLEMENTED
|
// UNIMPLEMENTED
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_EMSCRIPTEN)
|
#elif DAWN_PLATFORM_IS(EMSCRIPTEN)
|
||||||
std::optional<std::string> GetExecutablePath() {
|
std::optional<std::string> GetExecutablePath() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ std::optional<std::string> GetExecutableDirectory() {
|
||||||
return exePath->substr(0, lastPathSepLoc + 1);
|
return exePath->substr(0, lastPathSepLoc + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_LINUX) || defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
|
#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
|
||||||
std::optional<std::string> GetModulePath() {
|
std::optional<std::string> GetModulePath() {
|
||||||
static int placeholderSymbol = 0;
|
static int placeholderSymbol = 0;
|
||||||
Dl_info dlInfo;
|
Dl_info dlInfo;
|
||||||
|
@ -163,7 +163,7 @@ std::optional<std::string> GetModulePath() {
|
||||||
}
|
}
|
||||||
return absolutePath.data();
|
return absolutePath.data();
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_WINDOWS)
|
#elif DAWN_PLATFORM_IS(WINDOWS)
|
||||||
std::optional<std::string> GetModulePath() {
|
std::optional<std::string> GetModulePath() {
|
||||||
static int placeholderSymbol = 0;
|
static int placeholderSymbol = 0;
|
||||||
HMODULE module = nullptr;
|
HMODULE module = nullptr;
|
||||||
|
@ -179,11 +179,11 @@ std::optional<std::string> GetModulePath() {
|
||||||
#endif
|
#endif
|
||||||
return GetHModulePath(module);
|
return GetHModulePath(module);
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_FUCHSIA)
|
#elif DAWN_PLATFORM_IS(FUCHSIA)
|
||||||
std::optional<std::string> GetModulePath() {
|
std::optional<std::string> GetModulePath() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_EMSCRIPTEN)
|
#elif DAWN_PLATFORM_IS(EMSCRIPTEN)
|
||||||
std::optional<std::string> GetModulePath() {
|
std::optional<std::string> GetModulePath() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ bool SetEnvironmentVar(const char* variableName, const char* value);
|
||||||
std::optional<std::string> GetExecutableDirectory();
|
std::optional<std::string> GetExecutableDirectory();
|
||||||
std::optional<std::string> GetModuleDirectory();
|
std::optional<std::string> GetModuleDirectory();
|
||||||
|
|
||||||
#ifdef DAWN_PLATFORM_MACOS
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
void GetMacOSVersion(int32_t* majorVersion, int32_t* minorVersion = nullptr);
|
void GetMacOSVersion(int32_t* majorVersion, int32_t* minorVersion = nullptr);
|
||||||
bool IsMacOSVersionAtLeast(uint32_t majorVersion, uint32_t minorVersion = 0);
|
bool IsMacOSVersionAtLeast(uint32_t majorVersion, uint32_t minorVersion = 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define SRC_DAWN_COMMON_ITYP_BITSET_H_
|
#define SRC_DAWN_COMMON_ITYP_BITSET_H_
|
||||||
|
|
||||||
#include "dawn/common/BitSetIterator.h"
|
#include "dawn/common/BitSetIterator.h"
|
||||||
|
#include "dawn/common/Platform.h"
|
||||||
#include "dawn/common/TypedInteger.h"
|
#include "dawn/common/TypedInteger.h"
|
||||||
#include "dawn/common/UnderlyingType.h"
|
#include "dawn/common/UnderlyingType.h"
|
||||||
|
|
||||||
|
@ -124,9 +125,9 @@ class bitset : private std::bitset<N> {
|
||||||
template <typename Index, size_t N>
|
template <typename Index, size_t N>
|
||||||
Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
||||||
using I = UnderlyingType<Index>;
|
using I = UnderlyingType<Index>;
|
||||||
#if defined(DAWN_COMPILER_MSVC)
|
#if DAWN_COMPILER_IS(MSVC)
|
||||||
if constexpr (N > 32) {
|
if constexpr (N > 32) {
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
#if DAWN_PLATFORM_IS(64_BIT)
|
||||||
// NOLINTNEXTLINE(runtime/int)
|
// NOLINTNEXTLINE(runtime/int)
|
||||||
unsigned long firstBitIndex = 0ul;
|
unsigned long firstBitIndex = 0ul;
|
||||||
unsigned char ret = _BitScanReverse64(&firstBitIndex, bitset.to_ullong());
|
unsigned char ret = _BitScanReverse64(&firstBitIndex, bitset.to_ullong());
|
||||||
|
@ -134,7 +135,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
||||||
return Index(static_cast<I>(0));
|
return Index(static_cast<I>(0));
|
||||||
}
|
}
|
||||||
return Index(static_cast<I>(firstBitIndex + 1));
|
return Index(static_cast<I>(firstBitIndex + 1));
|
||||||
#else // defined(DAWN_PLATFORM_64_BIT)
|
#else // DAWN_PLATFORM_IS(64_BIT)
|
||||||
if (bitset.none()) {
|
if (bitset.none()) {
|
||||||
return Index(static_cast<I>(0));
|
return Index(static_cast<I>(0));
|
||||||
}
|
}
|
||||||
|
@ -144,7 +145,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
#endif // defined(DAWN_PLATFORM_64_BIT)
|
#endif // DAWN_PLATFORM_IS(64_BIT)
|
||||||
} else {
|
} else {
|
||||||
// NOLINTNEXTLINE(runtime/int)
|
// NOLINTNEXTLINE(runtime/int)
|
||||||
unsigned long firstBitIndex = 0ul;
|
unsigned long firstBitIndex = 0ul;
|
||||||
|
@ -154,7 +155,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
||||||
}
|
}
|
||||||
return Index(static_cast<I>(firstBitIndex + 1));
|
return Index(static_cast<I>(firstBitIndex + 1));
|
||||||
}
|
}
|
||||||
#else // defined(DAWN_COMPILER_MSVC)
|
#else // DAWN_COMPILER_IS(MSVC)
|
||||||
if (bitset.none()) {
|
if (bitset.none()) {
|
||||||
return Index(static_cast<I>(0));
|
return Index(static_cast<I>(0));
|
||||||
}
|
}
|
||||||
|
@ -164,7 +165,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
||||||
} else {
|
} else {
|
||||||
return Index(static_cast<I>(32 - static_cast<uint32_t>(__builtin_clz(bitset.to_ulong()))));
|
return Index(static_cast<I>(32 - static_cast<uint32_t>(__builtin_clz(bitset.to_ulong()))));
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_COMPILER_MSVC)
|
#endif // DAWN_COMPILER_IS(MSVC)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SRC_DAWN_COMMON_ITYP_BITSET_H_
|
#endif // SRC_DAWN_COMMON_ITYP_BITSET_H_
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
// redefined to be nullptr). This keeps the type-safety of having the handles be different types
|
// redefined to be nullptr). This keeps the type-safety of having the handles be different types
|
||||||
// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
|
// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
#if DAWN_PLATFORM_IS(64_BIT)
|
||||||
#define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = struct object##_T*;
|
#define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = struct object##_T*;
|
||||||
// This function is needed because MSVC doesn't accept reinterpret_cast from uint64_t from uint64_t
|
// This function is needed because MSVC doesn't accept reinterpret_cast from uint64_t from uint64_t
|
||||||
// TODO(cwallez@chromium.org): Remove this once we rework vulkan_platform.h
|
// TODO(cwallez@chromium.org): Remove this once we rework vulkan_platform.h
|
||||||
|
@ -43,7 +43,7 @@ template <typename T>
|
||||||
T NativeNonDispatachableHandleFromU64(uint64_t u64) {
|
T NativeNonDispatachableHandleFromU64(uint64_t u64) {
|
||||||
return reinterpret_cast<T>(u64);
|
return reinterpret_cast<T>(u64);
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_32_BIT)
|
#elif DAWN_PLATFORM_IS(32_BIT)
|
||||||
#define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = uint64_t;
|
#define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = uint64_t;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T NativeNonDispatachableHandleFromU64(uint64_t u64) {
|
T NativeNonDispatachableHandleFromU64(uint64_t u64) {
|
||||||
|
@ -138,12 +138,12 @@ HandleType* AsVkArray(detail::VkHandle<Tag, HandleType>* handle) {
|
||||||
// headers that vulkan.h includes that we have "undefs" for. Note that some of the VK_USE_PLATFORM_*
|
// headers that vulkan.h includes that we have "undefs" for. Note that some of the VK_USE_PLATFORM_*
|
||||||
// defines are defined already in the Vulkan-Header BUILD.gn, but are needed when building with
|
// defines are defined already in the Vulkan-Header BUILD.gn, but are needed when building with
|
||||||
// CMake, hence they cannot be removed at the moment.
|
// CMake, hence they cannot be removed at the moment.
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#ifndef VK_USE_PLATFORM_WIN32_KHR
|
#ifndef VK_USE_PLATFORM_WIN32_KHR
|
||||||
#define VK_USE_PLATFORM_WIN32_KHR
|
#define VK_USE_PLATFORM_WIN32_KHR
|
||||||
#endif
|
#endif
|
||||||
#include "dawn/common/windows_with_undefs.h"
|
#include "dawn/common/windows_with_undefs.h"
|
||||||
#endif // DAWN_PLATFORM_WINDOWS
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
#define VK_USE_PLATFORM_XLIB_KHR
|
#define VK_USE_PLATFORM_XLIB_KHR
|
||||||
|
@ -165,17 +165,17 @@ HandleType* AsVkArray(detail::VkHandle<Tag, HandleType>* handle) {
|
||||||
#endif
|
#endif
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
||||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||||
#endif
|
#endif
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_FUCHSIA)
|
#if DAWN_PLATFORM_IS(FUCHSIA)
|
||||||
#ifndef VK_USE_PLATFORM_FUCHSIA
|
#ifndef VK_USE_PLATFORM_FUCHSIA
|
||||||
#define VK_USE_PLATFORM_FUCHSIA
|
#define VK_USE_PLATFORM_FUCHSIA
|
||||||
#endif
|
#endif
|
||||||
#endif // defined(DAWN_PLATFORM_FUCHSIA)
|
#endif // DAWN_PLATFORM_IS(FUCHSIA)
|
||||||
|
|
||||||
// The actual inclusion of vulkan.h!
|
// The actual inclusion of vulkan.h!
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if !defined(DAWN_PLATFORM_WINDOWS)
|
#if !DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#error "windows_with_undefs.h included on non-Windows"
|
#error "windows_with_undefs.h included on non-Windows"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if !defined(DAWN_PLATFORM_LINUX)
|
#if !DAWN_PLATFORM_IS(LINUX)
|
||||||
#error "xlib_with_undefs.h included on non-Linux"
|
#error "xlib_with_undefs.h included on non-Linux"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
#include "dawn/native/Instance.h"
|
#include "dawn/native/Instance.h"
|
||||||
#include "dawn/native/SwapChain.h"
|
#include "dawn/native/SwapChain.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include <windows.ui.core.h>
|
#include <windows.ui.core.h>
|
||||||
#include <windows.ui.xaml.controls.h>
|
#include <windows.ui.xaml.controls.h>
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
#include "dawn/common/xlib_with_undefs.h"
|
#include "dawn/common/xlib_with_undefs.h"
|
||||||
|
@ -87,7 +87,7 @@ MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance,
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
const SurfaceDescriptorFromAndroidNativeWindow* androidDesc = nullptr;
|
const SurfaceDescriptorFromAndroidNativeWindow* androidDesc = nullptr;
|
||||||
FindInChain(descriptor->nextInChain, &androidDesc);
|
FindInChain(descriptor->nextInChain, &androidDesc);
|
||||||
// Currently the best validation we can do since it's not possible to check if the pointer
|
// Currently the best validation we can do since it's not possible to check if the pointer
|
||||||
|
@ -96,17 +96,17 @@ MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance,
|
||||||
DAWN_INVALID_IF(androidDesc->window == nullptr, "Android window is not set.");
|
DAWN_INVALID_IF(androidDesc->window == nullptr, "Android window is not set.");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#if defined(DAWN_PLATFORM_WIN32)
|
#if DAWN_PLATFORM_IS(WIN32)
|
||||||
const SurfaceDescriptorFromWindowsHWND* hwndDesc = nullptr;
|
const SurfaceDescriptorFromWindowsHWND* hwndDesc = nullptr;
|
||||||
FindInChain(descriptor->nextInChain, &hwndDesc);
|
FindInChain(descriptor->nextInChain, &hwndDesc);
|
||||||
if (hwndDesc) {
|
if (hwndDesc) {
|
||||||
DAWN_INVALID_IF(IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0, "Invalid HWND");
|
DAWN_INVALID_IF(IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0, "Invalid HWND");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_WIN32)
|
#endif // DAWN_PLATFORM_IS(WIN32)
|
||||||
const SurfaceDescriptorFromWindowsCoreWindow* coreWindowDesc = nullptr;
|
const SurfaceDescriptorFromWindowsCoreWindow* coreWindowDesc = nullptr;
|
||||||
FindInChain(descriptor->nextInChain, &coreWindowDesc);
|
FindInChain(descriptor->nextInChain, &coreWindowDesc);
|
||||||
if (coreWindowDesc) {
|
if (coreWindowDesc) {
|
||||||
|
@ -129,7 +129,7 @@ MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance,
|
||||||
"Invalid SwapChainPanel");
|
"Invalid SwapChainPanel");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_USE_WAYLAND)
|
#if defined(DAWN_USE_WAYLAND)
|
||||||
const SurfaceDescriptorFromWaylandSurface* waylandDesc = nullptr;
|
const SurfaceDescriptorFromWaylandSurface* waylandDesc = nullptr;
|
||||||
|
@ -203,15 +203,15 @@ Surface::Surface(InstanceBase* instance, const SurfaceDescriptor* descriptor)
|
||||||
mHInstance = hwndDesc->hinstance;
|
mHInstance = hwndDesc->hinstance;
|
||||||
mHWND = hwndDesc->hwnd;
|
mHWND = hwndDesc->hwnd;
|
||||||
} else if (coreWindowDesc) {
|
} else if (coreWindowDesc) {
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
mType = Type::WindowsCoreWindow;
|
mType = Type::WindowsCoreWindow;
|
||||||
mCoreWindow = static_cast<IUnknown*>(coreWindowDesc->coreWindow);
|
mCoreWindow = static_cast<IUnknown*>(coreWindowDesc->coreWindow);
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
} else if (swapChainPanelDesc) {
|
} else if (swapChainPanelDesc) {
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
mType = Type::WindowsSwapChainPanel;
|
mType = Type::WindowsSwapChainPanel;
|
||||||
mSwapChainPanel = static_cast<IUnknown*>(swapChainPanelDesc->swapChainPanel);
|
mSwapChainPanel = static_cast<IUnknown*>(swapChainPanelDesc->swapChainPanel);
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
} else if (xDesc) {
|
} else if (xDesc) {
|
||||||
mType = Type::XlibWindow;
|
mType = Type::XlibWindow;
|
||||||
mXDisplay = xDesc->display;
|
mXDisplay = xDesc->display;
|
||||||
|
@ -283,7 +283,7 @@ void* Surface::GetHWND() const {
|
||||||
IUnknown* Surface::GetCoreWindow() const {
|
IUnknown* Surface::GetCoreWindow() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
ASSERT(mType == Type::WindowsCoreWindow);
|
ASSERT(mType == Type::WindowsCoreWindow);
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
return mCoreWindow.Get();
|
return mCoreWindow.Get();
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -293,7 +293,7 @@ IUnknown* Surface::GetCoreWindow() const {
|
||||||
IUnknown* Surface::GetSwapChainPanel() const {
|
IUnknown* Surface::GetSwapChainPanel() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
ASSERT(mType == Type::WindowsSwapChainPanel);
|
ASSERT(mType == Type::WindowsSwapChainPanel);
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
return mSwapChainPanel.Get();
|
return mSwapChainPanel.Get();
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include "dawn/native/d3d12/d3d12_platform.h"
|
#include "dawn/native/d3d12/d3d12_platform.h"
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
// Forward declare IUnknown
|
// Forward declare IUnknown
|
||||||
// GetCoreWindow needs to return an IUnknown pointer
|
// GetCoreWindow needs to return an IUnknown pointer
|
||||||
|
@ -112,13 +112,13 @@ class Surface final : public ErrorMonad {
|
||||||
void* mHInstance = nullptr;
|
void* mHInstance = nullptr;
|
||||||
void* mHWND = nullptr;
|
void* mHWND = nullptr;
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
// WindowsCoreWindow
|
// WindowsCoreWindow
|
||||||
ComPtr<IUnknown> mCoreWindow;
|
ComPtr<IUnknown> mCoreWindow;
|
||||||
|
|
||||||
// WindowsSwapChainPanel
|
// WindowsSwapChainPanel
|
||||||
ComPtr<IUnknown> mSwapChainPanel;
|
ComPtr<IUnknown> mSwapChainPanel;
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
// Xlib
|
// Xlib
|
||||||
void* mXDisplay = nullptr;
|
void* mXDisplay = nullptr;
|
||||||
|
|
|
@ -73,11 +73,11 @@ MaybeError ValidateSwapChainDescriptor(const DeviceBase* device,
|
||||||
// TODO(crbug.com/dawn/160): Lift this restriction once wgpu::Instance::GetPreferredSurfaceFormat is
|
// TODO(crbug.com/dawn/160): Lift this restriction once wgpu::Instance::GetPreferredSurfaceFormat is
|
||||||
// implemented.
|
// implemented.
|
||||||
// TODO(dawn:286):
|
// TODO(dawn:286):
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::RGBA8Unorm;
|
constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
#else
|
#else
|
||||||
constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::BGRA8Unorm;
|
constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::BGRA8Unorm;
|
||||||
#endif // !defined(DAWN_PLATFORM_ANDROID)
|
#endif // !DAWN_PLATFORM_IS(ANDROID)
|
||||||
DAWN_INVALID_IF(descriptor->format != kRequireSwapChainFormat,
|
DAWN_INVALID_IF(descriptor->format != kRequireSwapChainFormat,
|
||||||
"Format (%s) is not %s, which is (currently) the only accepted format.",
|
"Format (%s) is not %s, which is (currently) the only accepted format.",
|
||||||
descriptor->format, kRequireSwapChainFormat);
|
descriptor->format, kRequireSwapChainFormat);
|
||||||
|
|
|
@ -111,7 +111,7 @@ MaybeError PlatformFunctions::LoadFunctions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError PlatformFunctions::LoadD3D12() {
|
MaybeError PlatformFunctions::LoadD3D12() {
|
||||||
#if DAWN_PLATFORM_WINUWP
|
#if DAWN_PLATFORM_IS(WINUWP)
|
||||||
d3d12CreateDevice = &D3D12CreateDevice;
|
d3d12CreateDevice = &D3D12CreateDevice;
|
||||||
d3d12GetDebugInterface = &D3D12GetDebugInterface;
|
d3d12GetDebugInterface = &D3D12GetDebugInterface;
|
||||||
d3d12SerializeRootSignature = &D3D12SerializeRootSignature;
|
d3d12SerializeRootSignature = &D3D12SerializeRootSignature;
|
||||||
|
@ -138,7 +138,7 @@ MaybeError PlatformFunctions::LoadD3D12() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError PlatformFunctions::LoadD3D11() {
|
MaybeError PlatformFunctions::LoadD3D11() {
|
||||||
#if DAWN_PLATFORM_WINUWP
|
#if DAWN_PLATFORM_IS(WINUWP)
|
||||||
d3d11on12CreateDevice = &D3D11On12CreateDevice;
|
d3d11on12CreateDevice = &D3D11On12CreateDevice;
|
||||||
#else
|
#else
|
||||||
std::string error;
|
std::string error;
|
||||||
|
@ -152,7 +152,7 @@ MaybeError PlatformFunctions::LoadD3D11() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError PlatformFunctions::LoadDXGI() {
|
MaybeError PlatformFunctions::LoadDXGI() {
|
||||||
#if DAWN_PLATFORM_WINUWP
|
#if DAWN_PLATFORM_IS(WINUWP)
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
// DXGIGetDebugInterface1 is tagged as a development-only capability
|
// DXGIGetDebugInterface1 is tagged as a development-only capability
|
||||||
// which implies that linking to this function will cause
|
// which implies that linking to this function will cause
|
||||||
|
@ -226,7 +226,7 @@ void PlatformFunctions::LoadDXCompiler(const std::string& baseWindowsSDKPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError PlatformFunctions::LoadFXCompiler() {
|
MaybeError PlatformFunctions::LoadFXCompiler() {
|
||||||
#if DAWN_PLATFORM_WINUWP
|
#if DAWN_PLATFORM_IS(WINUWP)
|
||||||
d3dCompile = &D3DCompile;
|
d3dCompile = &D3DCompile;
|
||||||
d3dDisassemble = &D3DDisassemble;
|
d3dDisassemble = &D3DDisassemble;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "dawn/native/metal/BufferMTL.h"
|
#include "dawn/native/metal/BufferMTL.h"
|
||||||
#include "dawn/native/metal/DeviceMTL.h"
|
#include "dawn/native/metal/DeviceMTL.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
#import <IOKit/IOKitLib.h>
|
#import <IOKit/IOKitLib.h>
|
||||||
#include "dawn/common/IOKitRef.h"
|
#include "dawn/common/IOKitRef.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,7 +46,7 @@ struct Vendor {
|
||||||
uint32_t vendorId;
|
uint32_t vendorId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
const Vendor kVendors[] = {{"AMD", gpu_info::kVendorID_AMD},
|
const Vendor kVendors[] = {{"AMD", gpu_info::kVendorID_AMD},
|
||||||
{"Radeon", gpu_info::kVendorID_AMD},
|
{"Radeon", gpu_info::kVendorID_AMD},
|
||||||
{"Intel", gpu_info::kVendorID_Intel},
|
{"Intel", gpu_info::kVendorID_Intel},
|
||||||
|
@ -159,7 +159,7 @@ bool IsMetalSupported() {
|
||||||
// TODO(dawn:1181): Dawn native should allow non-conformant WebGPU on macOS 10.11
|
// TODO(dawn:1181): Dawn native should allow non-conformant WebGPU on macOS 10.11
|
||||||
return IsMacOSVersionAtLeast(10, 12);
|
return IsMacOSVersionAtLeast(10, 12);
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_IOS)
|
#elif DAWN_PLATFORM_IS(IOS)
|
||||||
MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||||
DAWN_UNUSED(device);
|
DAWN_UNUSED(device);
|
||||||
*ids = PCIIDs{0, 0};
|
*ids = PCIIDs{0, 0};
|
||||||
|
@ -277,10 +277,10 @@ class Adapter : public AdapterBase {
|
||||||
mDeviceId = ids.deviceId;
|
mDeviceId = ids.deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_IOS)
|
#if DAWN_PLATFORM_IS(IOS)
|
||||||
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
||||||
const char* systemName = "iOS ";
|
const char* systemName = "iOS ";
|
||||||
#elif defined(DAWN_PLATFORM_MACOS)
|
#elif DAWN_PLATFORM_IS(MACOS)
|
||||||
if ([device isLowPower]) {
|
if ([device isLowPower]) {
|
||||||
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
||||||
} else {
|
} else {
|
||||||
|
@ -310,12 +310,12 @@ class Adapter : public AdapterBase {
|
||||||
|
|
||||||
MaybeError InitializeSupportedFeaturesImpl() override {
|
MaybeError InitializeSupportedFeaturesImpl() override {
|
||||||
// Check compressed texture format with deprecated MTLFeatureSet way.
|
// Check compressed texture format with deprecated MTLFeatureSet way.
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
|
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
|
||||||
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
|
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_PLATFORM_IOS)
|
#if DAWN_PLATFORM_IS(IOS)
|
||||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) {
|
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) {
|
||||||
mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2);
|
mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2);
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ class Adapter : public AdapterBase {
|
||||||
{MTLCommonCounterTimestamp})) {
|
{MTLCommonCounterTimestamp})) {
|
||||||
bool enableTimestampQuery = true;
|
bool enableTimestampQuery = true;
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
// Disable timestamp query on < macOS 11.0 on AMD GPU because WriteTimestamp
|
// Disable timestamp query on < macOS 11.0 on AMD GPU because WriteTimestamp
|
||||||
// fails to call without any copy commands on MTLBlitCommandEncoder. This issue
|
// fails to call without any copy commands on MTLBlitCommandEncoder. This issue
|
||||||
// has been fixed on macOS 11.0. See crbug.com/dawn/545.
|
// has been fixed on macOS 11.0. See crbug.com/dawn/545.
|
||||||
|
@ -379,7 +379,7 @@ class Adapter : public AdapterBase {
|
||||||
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
|
mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
// MTLPixelFormatDepth24Unorm_Stencil8 is only available on macOS 10.11+
|
// MTLPixelFormatDepth24Unorm_Stencil8 is only available on macOS 10.11+
|
||||||
if ([*mDevice isDepth24Stencil8PixelFormatSupported]) {
|
if ([*mDevice isDepth24Stencil8PixelFormatSupported]) {
|
||||||
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
|
||||||
|
@ -628,7 +628,7 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<AdapterBase>> adapters;
|
||||||
BOOL supportedVersion = NO;
|
BOOL supportedVersion = NO;
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
if (@available(macOS 10.11, *)) {
|
if (@available(macOS 10.11, *)) {
|
||||||
supportedVersion = YES;
|
supportedVersion = YES;
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_IOS)
|
#if DAWN_PLATFORM_IS(IOS)
|
||||||
if (@available(iOS 8.0, *)) {
|
if (@available(iOS 8.0, *)) {
|
||||||
supportedVersion = YES;
|
supportedVersion = YES;
|
||||||
// iOS only has a single device so MTLCopyAllDevices doesn't exist there.
|
// iOS only has a single device so MTLCopyAllDevices doesn't exist there.
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "dawn/native/metal/BufferMTL.h"
|
#include "dawn/native/metal/BufferMTL.h"
|
||||||
|
|
||||||
#include "dawn/common/Math.h"
|
#include "dawn/common/Math.h"
|
||||||
|
#include "dawn/common/Platform.h"
|
||||||
#include "dawn/native/CommandBuffer.h"
|
#include "dawn/native/CommandBuffer.h"
|
||||||
#include "dawn/native/metal/CommandRecordingContext.h"
|
#include "dawn/native/metal/CommandRecordingContext.h"
|
||||||
#include "dawn/native/metal/DeviceMTL.h"
|
#include "dawn/native/metal/DeviceMTL.h"
|
||||||
|
@ -41,7 +42,7 @@ uint64_t Buffer::QueryMaxBufferLength(id<MTLDevice> mtlDevice) {
|
||||||
|
|
||||||
// Earlier versions of Metal had maximums defined in the Metal feature set tables
|
// Earlier versions of Metal had maximums defined in the Metal feature set tables
|
||||||
// https://metalbyexample.com/wp-content/uploads/Metal-Feature-Set-Tables-2018.pdf
|
// https://metalbyexample.com/wp-content/uploads/Metal-Feature-Set-Tables-2018.pdf
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
// 10.12 and 10.13 have a 1Gb limit.
|
// 10.12 and 10.13 have a 1Gb limit.
|
||||||
if (@available(macOS 10.12, *)) {
|
if (@available(macOS 10.12, *)) {
|
||||||
// |maxBufferLength| isn't always available on older systems. If available, use
|
// |maxBufferLength| isn't always available on older systems. If available, use
|
||||||
|
@ -72,7 +73,7 @@ MaybeError Buffer::Initialize(bool mappedAtCreation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t alignment = 1;
|
uint32_t alignment = 1;
|
||||||
#ifdef DAWN_PLATFORM_MACOS
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
// [MTLBlitCommandEncoder fillBuffer] requires the size to be a multiple of 4 on MacOS.
|
// [MTLBlitCommandEncoder fillBuffer] requires the size to be a multiple of 4 on MacOS.
|
||||||
alignment = 4;
|
alignment = 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -158,26 +158,26 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
|
||||||
void Device::InitTogglesFromDriver() {
|
void Device::InitTogglesFromDriver() {
|
||||||
{
|
{
|
||||||
bool haveStoreAndMSAAResolve = false;
|
bool haveStoreAndMSAAResolve = false;
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
if (@available(macOS 10.12, *)) {
|
if (@available(macOS 10.12, *)) {
|
||||||
haveStoreAndMSAAResolve =
|
haveStoreAndMSAAResolve =
|
||||||
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
|
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_IOS)
|
#elif DAWN_PLATFORM_IS(IOS)
|
||||||
haveStoreAndMSAAResolve = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2];
|
haveStoreAndMSAAResolve = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2];
|
||||||
#endif
|
#endif
|
||||||
// On tvOS, we would need MTLFeatureSet_tvOS_GPUFamily2_v1.
|
// On tvOS, we would need MTLFeatureSet_tvOS_GPUFamily2_v1.
|
||||||
SetToggle(Toggle::EmulateStoreAndMSAAResolve, !haveStoreAndMSAAResolve);
|
SetToggle(Toggle::EmulateStoreAndMSAAResolve, !haveStoreAndMSAAResolve);
|
||||||
|
|
||||||
bool haveSamplerCompare = true;
|
bool haveSamplerCompare = true;
|
||||||
#if defined(DAWN_PLATFORM_IOS)
|
#if DAWN_PLATFORM_IS(IOS)
|
||||||
haveSamplerCompare = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
|
haveSamplerCompare = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
|
||||||
#endif
|
#endif
|
||||||
// TODO(crbug.com/dawn/342): Investigate emulation -- possibly expensive.
|
// TODO(crbug.com/dawn/342): Investigate emulation -- possibly expensive.
|
||||||
SetToggle(Toggle::MetalDisableSamplerCompare, !haveSamplerCompare);
|
SetToggle(Toggle::MetalDisableSamplerCompare, !haveSamplerCompare);
|
||||||
|
|
||||||
bool haveBaseVertexBaseInstance = true;
|
bool haveBaseVertexBaseInstance = true;
|
||||||
#if defined(DAWN_PLATFORM_IOS)
|
#if DAWN_PLATFORM_IS(IOS)
|
||||||
haveBaseVertexBaseInstance =
|
haveBaseVertexBaseInstance =
|
||||||
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
|
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -108,11 +108,11 @@ MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
||||||
[*mLayer setDevice:ToBackend(GetDevice())->GetMTLDevice()];
|
[*mLayer setDevice:ToBackend(GetDevice())->GetMTLDevice()];
|
||||||
[*mLayer setPixelFormat:MetalPixelFormat(GetFormat())];
|
[*mLayer setPixelFormat:MetalPixelFormat(GetFormat())];
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
if (@available(macos 10.13, *)) {
|
if (@available(macos 10.13, *)) {
|
||||||
[*mLayer setDisplaySyncEnabled:(GetPresentMode() != wgpu::PresentMode::Immediate)];
|
[*mLayer setDisplaySyncEnabled:(GetPresentMode() != wgpu::PresentMode::Immediate)];
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_MACOS)
|
#endif // DAWN_PLATFORM_IS(MACOS)
|
||||||
|
|
||||||
// There is no way to control Fifo vs. Mailbox in Metal.
|
// There is no way to control Fifo vs. Mailbox in Metal.
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ bool AllowFormatReinterpretationWithoutFlag(MTLPixelFormat origin,
|
||||||
case MTLPixelFormatBGRA8Unorm_sRGB:
|
case MTLPixelFormatBGRA8Unorm_sRGB:
|
||||||
return reinterpretation == MTLPixelFormatRGBA8Unorm_sRGB ||
|
return reinterpretation == MTLPixelFormatRGBA8Unorm_sRGB ||
|
||||||
reinterpretation == MTLPixelFormatBGRA8Unorm;
|
reinterpretation == MTLPixelFormatBGRA8Unorm;
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
case MTLPixelFormatBC1_RGBA:
|
case MTLPixelFormatBC1_RGBA:
|
||||||
return reinterpretation == MTLPixelFormatBC1_RGBA_sRGB;
|
return reinterpretation == MTLPixelFormatBC1_RGBA_sRGB;
|
||||||
case MTLPixelFormatBC1_RGBA_sRGB:
|
case MTLPixelFormatBC1_RGBA_sRGB:
|
||||||
|
@ -216,9 +216,9 @@ uint32_t GetIOSurfacePlane(wgpu::TextureAspect aspect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
MTLStorageMode kIOSurfaceStorageMode = MTLStorageModeManaged;
|
MTLStorageMode kIOSurfaceStorageMode = MTLStorageModeManaged;
|
||||||
#elif defined(DAWN_PLATFORM_IOS)
|
#elif DAWN_PLATFORM_IS(IOS)
|
||||||
MTLStorageMode kIOSurfaceStorageMode = MTLStorageModePrivate;
|
MTLStorageMode kIOSurfaceStorageMode = MTLStorageModePrivate;
|
||||||
#else
|
#else
|
||||||
#error "Unsupported Apple platform."
|
#error "Unsupported Apple platform."
|
||||||
|
@ -321,7 +321,7 @@ MTLPixelFormat MetalPixelFormat(wgpu::TextureFormat format) {
|
||||||
case wgpu::TextureFormat::Stencil8:
|
case wgpu::TextureFormat::Stencil8:
|
||||||
return MTLPixelFormatStencil8;
|
return MTLPixelFormatStencil8;
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
case wgpu::TextureFormat::Depth24UnormStencil8:
|
case wgpu::TextureFormat::Depth24UnormStencil8:
|
||||||
return MTLPixelFormatDepth24Unorm_Stencil8;
|
return MTLPixelFormatDepth24Unorm_Stencil8;
|
||||||
|
|
||||||
|
@ -1069,7 +1069,7 @@ MaybeError TextureView::Initialize(const TextureViewDescriptor* descriptor) {
|
||||||
if (textureFormat == MTLPixelFormatDepth32Float_Stencil8) {
|
if (textureFormat == MTLPixelFormatDepth32Float_Stencil8) {
|
||||||
viewFormat = MTLPixelFormatX32_Stencil8;
|
viewFormat = MTLPixelFormatX32_Stencil8;
|
||||||
}
|
}
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
else if (textureFormat == MTLPixelFormatDepth24Unorm_Stencil8) {
|
else if (textureFormat == MTLPixelFormatDepth24Unorm_Stencil8) {
|
||||||
viewFormat = MTLPixelFormatX24_Stencil8;
|
viewFormat = MTLPixelFormatX24_Stencil8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "dawn/native/opengl/OpenGLFunctions.h"
|
#include "dawn/native/opengl/OpenGLFunctions.h"
|
||||||
|
|
||||||
// Remove windows.h macros after glad's include of windows.h
|
// Remove windows.h macros after glad's include of windows.h
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include "dawn/common/windows_with_undefs.h"
|
#include "dawn/common/windows_with_undefs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -30,28 +30,28 @@
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/283): Link against the Vulkan Loader and remove this.
|
// TODO(crbug.com/dawn/283): Link against the Vulkan Loader and remove this.
|
||||||
#if defined(DAWN_ENABLE_SWIFTSHADER)
|
#if defined(DAWN_ENABLE_SWIFTSHADER)
|
||||||
#if defined(DAWN_PLATFORM_LINUX) || defined(DAWN_PLATFORM_FUSCHIA)
|
#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(FUSCHIA)
|
||||||
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.so";
|
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.so";
|
||||||
#elif defined(DAWN_PLATFORM_WINDOWS)
|
#elif DAWN_PLATFORM_IS(WINDOWS)
|
||||||
constexpr char kSwiftshaderLibName[] = "vk_swiftshader.dll";
|
constexpr char kSwiftshaderLibName[] = "vk_swiftshader.dll";
|
||||||
#elif defined(DAWN_PLATFORM_MACOS)
|
#elif DAWN_PLATFORM_IS(MACOS)
|
||||||
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.dylib";
|
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.dylib";
|
||||||
#else
|
#else
|
||||||
#error "Unimplemented Swiftshader Vulkan backend platform"
|
#error "Unimplemented Swiftshader Vulkan backend platform"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_LINUX)
|
#if DAWN_PLATFORM_IS(LINUX)
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
constexpr char kVulkanLibName[] = "libvulkan.so";
|
constexpr char kVulkanLibName[] = "libvulkan.so";
|
||||||
#else
|
#else
|
||||||
constexpr char kVulkanLibName[] = "libvulkan.so.1";
|
constexpr char kVulkanLibName[] = "libvulkan.so.1";
|
||||||
#endif
|
#endif
|
||||||
#elif defined(DAWN_PLATFORM_WINDOWS)
|
#elif DAWN_PLATFORM_IS(WINDOWS)
|
||||||
constexpr char kVulkanLibName[] = "vulkan-1.dll";
|
constexpr char kVulkanLibName[] = "vulkan-1.dll";
|
||||||
#elif defined(DAWN_PLATFORM_MACOS)
|
#elif DAWN_PLATFORM_IS(MACOS)
|
||||||
constexpr char kVulkanLibName[] = "libvulkan.dylib";
|
constexpr char kVulkanLibName[] = "libvulkan.dylib";
|
||||||
#elif defined(DAWN_PLATFORM_FUCHSIA)
|
#elif DAWN_PLATFORM_IS(FUCHSIA)
|
||||||
constexpr char kVulkanLibName[] = "libvulkan.so";
|
constexpr char kVulkanLibName[] = "libvulkan.so";
|
||||||
#else
|
#else
|
||||||
#error "Unimplemented Vulkan backend platform"
|
#error "Unimplemented Vulkan backend platform"
|
||||||
|
@ -445,12 +445,12 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
|
|
||||||
InstanceBase* instance = GetInstance();
|
InstanceBase* instance = GetInstance();
|
||||||
for (ICD icd : kICDs) {
|
for (ICD icd : kICDs) {
|
||||||
#if defined(DAWN_PLATFORM_MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
// On Mac, we don't expect non-Swiftshader Vulkan to be available.
|
// On Mac, we don't expect non-Swiftshader Vulkan to be available.
|
||||||
if (icd == ICD::None) {
|
if (icd == ICD::None) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_MACOS)
|
#endif // DAWN_PLATFORM_IS(MACOS)
|
||||||
if (options->forceSwiftShader && icd != ICD::SwiftShader) {
|
if (options->forceSwiftShader && icd != ICD::SwiftShader) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
namespace dawn::native::vulkan {
|
namespace dawn::native::vulkan {
|
||||||
|
|
||||||
#if DAWN_PLATFORM_LINUX
|
#if DAWN_PLATFORM_IS(LINUX)
|
||||||
// File descriptor
|
// File descriptor
|
||||||
using ExternalMemoryHandle = int;
|
using ExternalMemoryHandle = int;
|
||||||
// File descriptor
|
// File descriptor
|
||||||
using ExternalSemaphoreHandle = int;
|
using ExternalSemaphoreHandle = int;
|
||||||
#elif DAWN_PLATFORM_FUCHSIA
|
#elif DAWN_PLATFORM_IS(FUCHSIA)
|
||||||
// Really a Zircon vmo handle.
|
// Really a Zircon vmo handle.
|
||||||
using ExternalMemoryHandle = zx_handle_t;
|
using ExternalMemoryHandle = zx_handle_t;
|
||||||
// Really a Zircon event handle.
|
// Really a Zircon event handle.
|
||||||
|
|
|
@ -184,7 +184,7 @@ DawnSwapChainError NativeSwapChainImpl::GetNextTexture(DawnSwapChainNextTexture*
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTexture->texture.u64 =
|
nextTexture->texture.u64 =
|
||||||
#if defined(DAWN_PLATFORM_64_BIT)
|
#if DAWN_PLATFORM_IS(64_BIT)
|
||||||
reinterpret_cast<uint64_t>
|
reinterpret_cast<uint64_t>
|
||||||
#endif
|
#endif
|
||||||
(*mSwapChainImages[mLastImageIndex]);
|
(*mSwapChainImages[mLastImageIndex]);
|
||||||
|
|
|
@ -115,7 +115,7 @@ ResultOrError<VkSurfaceKHR> CreateVulkanSurface(Adapter* adapter, Surface* surfa
|
||||||
break;
|
break;
|
||||||
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
case Surface::Type::WindowsHWND:
|
case Surface::Type::WindowsHWND:
|
||||||
if (info.HasExt(InstanceExt::Win32Surface)) {
|
if (info.HasExt(InstanceExt::Win32Surface)) {
|
||||||
VkWin32SurfaceCreateInfoKHR createInfo;
|
VkWin32SurfaceCreateInfoKHR createInfo;
|
||||||
|
@ -132,9 +132,9 @@ ResultOrError<VkSurfaceKHR> CreateVulkanSurface(Adapter* adapter, Surface* surfa
|
||||||
return vkSurface;
|
return vkSurface;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
case Surface::Type::AndroidWindow: {
|
case Surface::Type::AndroidWindow: {
|
||||||
if (info.HasExt(InstanceExt::AndroidSurface)) {
|
if (info.HasExt(InstanceExt::AndroidSurface)) {
|
||||||
ASSERT(surface->GetAndroidNativeWindow() != nullptr);
|
ASSERT(surface->GetAndroidNativeWindow() != nullptr);
|
||||||
|
@ -156,7 +156,7 @@ ResultOrError<VkSurfaceKHR> CreateVulkanSurface(Adapter* adapter, Surface* surfa
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
#if defined(DAWN_USE_WAYLAND)
|
#if defined(DAWN_USE_WAYLAND)
|
||||||
case Surface::Type::WaylandSurface: {
|
case Surface::Type::WaylandSurface: {
|
||||||
|
@ -449,7 +449,7 @@ ResultOrError<SwapChain::Config> SwapChain::ChooseConfig(
|
||||||
config.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
config.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||||
|
|
||||||
config.alphaMode = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
config.alphaMode = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||||
#if !defined(DAWN_PLATFORM_ANDROID)
|
#if !DAWN_PLATFORM_IS(ANDROID)
|
||||||
DAWN_INVALID_IF(
|
DAWN_INVALID_IF(
|
||||||
(surfaceInfo.capabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) == 0,
|
(surfaceInfo.capabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) == 0,
|
||||||
"Vulkan SwapChain must support opaque alpha.");
|
"Vulkan SwapChain must support opaque alpha.");
|
||||||
|
@ -467,7 +467,7 @@ ResultOrError<SwapChain::Config> SwapChain::ChooseConfig(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // #if !defined(DAWN_PLATFORM_ANDROID)
|
#endif // #if !DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
// Choose the number of images for the swapchain= and clamp it to the min and max from the
|
// Choose the number of images for the swapchain= and clamp it to the min and max from the
|
||||||
// surface capabilities. maxImageCount = 0 means there is no limit.
|
// surface capabilities. maxImageCount = 0 means there is no limit.
|
||||||
|
|
|
@ -60,7 +60,7 @@ WGPUTextureFormat GetNativeSwapChainPreferredFormat(const DawnSwapChainImplement
|
||||||
AdapterDiscoveryOptions::AdapterDiscoveryOptions()
|
AdapterDiscoveryOptions::AdapterDiscoveryOptions()
|
||||||
: AdapterDiscoveryOptionsBase(WGPUBackendType_Vulkan) {}
|
: AdapterDiscoveryOptionsBase(WGPUBackendType_Vulkan) {}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_LINUX)
|
#if DAWN_PLATFORM_IS(LINUX)
|
||||||
ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD()
|
ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD()
|
||||||
: ExternalImageDescriptorFD(ExternalImageType::OpaqueFD) {}
|
: ExternalImageDescriptorFD(ExternalImageType::OpaqueFD) {}
|
||||||
|
|
||||||
|
@ -72,10 +72,10 @@ ExternalImageExportInfoOpaqueFD::ExternalImageExportInfoOpaqueFD()
|
||||||
|
|
||||||
ExternalImageExportInfoDmaBuf::ExternalImageExportInfoDmaBuf()
|
ExternalImageExportInfoDmaBuf::ExternalImageExportInfoDmaBuf()
|
||||||
: ExternalImageExportInfoFD(ExternalImageType::DmaBuf) {}
|
: ExternalImageExportInfoFD(ExternalImageType::DmaBuf) {}
|
||||||
#endif // DAWN_PLATFORM_LINUX
|
#endif // DAWN_PLATFORM_IS(LINUX)
|
||||||
|
|
||||||
WGPUTexture WrapVulkanImage(WGPUDevice device, const ExternalImageDescriptorVk* descriptor) {
|
WGPUTexture WrapVulkanImage(WGPUDevice device, const ExternalImageDescriptorVk* descriptor) {
|
||||||
#if defined(DAWN_PLATFORM_LINUX)
|
#if DAWN_PLATFORM_IS(LINUX)
|
||||||
switch (descriptor->GetType()) {
|
switch (descriptor->GetType()) {
|
||||||
case ExternalImageType::OpaqueFD:
|
case ExternalImageType::OpaqueFD:
|
||||||
case ExternalImageType::DmaBuf: {
|
case ExternalImageType::DmaBuf: {
|
||||||
|
@ -91,7 +91,7 @@ WGPUTexture WrapVulkanImage(WGPUDevice device, const ExternalImageDescriptorVk*
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif // DAWN_PLATFORM_LINUX
|
#endif // DAWN_PLATFORM_IS(LINUX)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExportVulkanImage(WGPUTexture texture,
|
bool ExportVulkanImage(WGPUTexture texture,
|
||||||
|
@ -100,7 +100,7 @@ bool ExportVulkanImage(WGPUTexture texture,
|
||||||
if (texture == nullptr) {
|
if (texture == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if defined(DAWN_PLATFORM_LINUX)
|
#if DAWN_PLATFORM_IS(LINUX)
|
||||||
switch (info->GetType()) {
|
switch (info->GetType()) {
|
||||||
case ExternalImageType::OpaqueFD:
|
case ExternalImageType::OpaqueFD:
|
||||||
case ExternalImageType::DmaBuf: {
|
case ExternalImageType::DmaBuf: {
|
||||||
|
@ -116,7 +116,7 @@ bool ExportVulkanImage(WGPUTexture texture,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // DAWN_PLATFORM_LINUX
|
#endif // DAWN_PLATFORM_IS(LINUX)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dawn::native::vulkan
|
} // namespace dawn::native::vulkan
|
||||||
|
|
|
@ -195,18 +195,18 @@ MaybeError VulkanFunctions::LoadInstanceProcs(VkInstance instance,
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_USE_WAYLAND)
|
#endif // defined(DAWN_USE_WAYLAND)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
if (globalInfo.HasExt(InstanceExt::Win32Surface)) {
|
if (globalInfo.HasExt(InstanceExt::Win32Surface)) {
|
||||||
GET_INSTANCE_PROC(CreateWin32SurfaceKHR);
|
GET_INSTANCE_PROC(CreateWin32SurfaceKHR);
|
||||||
GET_INSTANCE_PROC(GetPhysicalDeviceWin32PresentationSupportKHR);
|
GET_INSTANCE_PROC(GetPhysicalDeviceWin32PresentationSupportKHR);
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
if (globalInfo.HasExt(InstanceExt::AndroidSurface)) {
|
if (globalInfo.HasExt(InstanceExt::AndroidSurface)) {
|
||||||
GET_INSTANCE_PROC(CreateAndroidSurfaceKHR);
|
GET_INSTANCE_PROC(CreateAndroidSurfaceKHR);
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
if (globalInfo.HasExt(InstanceExt::XlibSurface)) {
|
if (globalInfo.HasExt(InstanceExt::XlibSurface)) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_VULKAN_VULKANFUNCTIONS_H_
|
#ifndef SRC_DAWN_NATIVE_VULKAN_VULKANFUNCTIONS_H_
|
||||||
#define SRC_DAWN_NATIVE_VULKAN_VULKANFUNCTIONS_H_
|
#define SRC_DAWN_NATIVE_VULKAN_VULKANFUNCTIONS_H_
|
||||||
|
|
||||||
|
#include "dawn/common/Compiler.h"
|
||||||
#include "dawn/common/vulkan_platform.h"
|
#include "dawn/common/vulkan_platform.h"
|
||||||
|
|
||||||
#include "dawn/native/Error.h"
|
#include "dawn/native/Error.h"
|
||||||
|
@ -26,7 +27,7 @@ namespace dawn::native::vulkan {
|
||||||
struct VulkanGlobalInfo;
|
struct VulkanGlobalInfo;
|
||||||
struct VulkanDeviceInfo;
|
struct VulkanDeviceInfo;
|
||||||
|
|
||||||
#if defined(UNDEFINED_SANITIZER) && defined(DAWN_COMPILER_CLANG)
|
#if defined(UNDEFINED_SANITIZER) && DAWN_COMPILER_IS(CLANG)
|
||||||
#define DAWN_NO_SANITIZE_VK_FN 1
|
#define DAWN_NO_SANITIZE_VK_FN 1
|
||||||
#else
|
#else
|
||||||
#define DAWN_NO_SANITIZE_VK_FN 0
|
#define DAWN_NO_SANITIZE_VK_FN 0
|
||||||
|
@ -156,16 +157,16 @@ struct VulkanFunctions {
|
||||||
GetPhysicalDeviceWaylandPresentationSupportKHR = nullptr;
|
GetPhysicalDeviceWaylandPresentationSupportKHR = nullptr;
|
||||||
#endif // defined(DAWN_USE_WAYLAND)
|
#endif // defined(DAWN_USE_WAYLAND)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
// KHR_win32_surface
|
// KHR_win32_surface
|
||||||
VkFn<PFN_vkCreateWin32SurfaceKHR> CreateWin32SurfaceKHR = nullptr;
|
VkFn<PFN_vkCreateWin32SurfaceKHR> CreateWin32SurfaceKHR = nullptr;
|
||||||
VkFn<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR>
|
VkFn<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR>
|
||||||
GetPhysicalDeviceWin32PresentationSupportKHR = nullptr;
|
GetPhysicalDeviceWin32PresentationSupportKHR = nullptr;
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_ANDROID)
|
#if DAWN_PLATFORM_IS(ANDROID)
|
||||||
VkFn<PFN_vkCreateAndroidSurfaceKHR> CreateAndroidSurfaceKHR = nullptr;
|
VkFn<PFN_vkCreateAndroidSurfaceKHR> CreateAndroidSurfaceKHR = nullptr;
|
||||||
#endif // defined(DAWN_PLATFORM_ANDROID)
|
#endif // DAWN_PLATFORM_IS(ANDROID)
|
||||||
|
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
// KHR_xlib_surface
|
// KHR_xlib_surface
|
||||||
|
|
|
@ -452,7 +452,7 @@ std::unique_ptr<dawn::native::Instance> DawnTestEnvironment::CreateInstanceAndDi
|
||||||
if (!mANGLEBackend.empty()) {
|
if (!mANGLEBackend.empty()) {
|
||||||
platform = mANGLEBackend.c_str();
|
platform = mANGLEBackend.c_str();
|
||||||
} else {
|
} else {
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
platform = "d3d11";
|
platform = "d3d11";
|
||||||
#else
|
#else
|
||||||
platform = "swiftshader";
|
platform = "swiftshader";
|
||||||
|
@ -851,7 +851,7 @@ bool DawnTestBase::IsWARP() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsWindows() const {
|
bool DawnTestBase::IsWindows() const {
|
||||||
#ifdef DAWN_PLATFORM_WINDOWS
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
|
@ -859,7 +859,7 @@ bool DawnTestBase::IsWindows() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsLinux() const {
|
bool DawnTestBase::IsLinux() const {
|
||||||
#ifdef DAWN_PLATFORM_LINUX
|
#if DAWN_PLATFORM_IS(LINUX)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
|
@ -867,7 +867,7 @@ bool DawnTestBase::IsLinux() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsMacOS(int32_t majorVersion, int32_t minorVersion) const {
|
bool DawnTestBase::IsMacOS(int32_t majorVersion, int32_t minorVersion) const {
|
||||||
#ifdef DAWN_PLATFORM_MACOS
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
if (majorVersion == -1 && minorVersion == -1) {
|
if (majorVersion == -1 && minorVersion == -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ TEST_P(ComputeDispatchTests, DirectNoop) {
|
||||||
|
|
||||||
// Test basic indirect
|
// Test basic indirect
|
||||||
TEST_P(ComputeDispatchTests, IndirectBasic) {
|
TEST_P(ComputeDispatchTests, IndirectBasic) {
|
||||||
#ifdef DAWN_PLATFORM_32_BIT
|
#if DAWN_PLATFORM_IS(32_BIT)
|
||||||
// TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
|
// TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
|
||||||
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
|
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,7 +246,7 @@ TEST_P(ComputeDispatchTests, IndirectNoop) {
|
||||||
|
|
||||||
// Test indirect with buffer offset
|
// Test indirect with buffer offset
|
||||||
TEST_P(ComputeDispatchTests, IndirectOffset) {
|
TEST_P(ComputeDispatchTests, IndirectOffset) {
|
||||||
#ifdef DAWN_PLATFORM_32_BIT
|
#if DAWN_PLATFORM_IS(32_BIT)
|
||||||
// TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
|
// TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
|
||||||
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
|
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
|
||||||
#endif
|
#endif
|
||||||
|
@ -263,7 +263,7 @@ TEST_P(ComputeDispatchTests, IndirectOffsetWithoutNumWorkgroups) {
|
||||||
|
|
||||||
// Test indirect dispatches at max limit.
|
// Test indirect dispatches at max limit.
|
||||||
TEST_P(ComputeDispatchTests, MaxWorkgroups) {
|
TEST_P(ComputeDispatchTests, MaxWorkgroups) {
|
||||||
#ifdef DAWN_PLATFORM_32_BIT
|
#if DAWN_PLATFORM_IS(32_BIT)
|
||||||
// TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
|
// TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
|
||||||
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
|
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -122,7 +122,7 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
|
||||||
maxBufferBindingSize =
|
maxBufferBindingSize =
|
||||||
std::min(maxBufferBindingSize, uint64_t(2) * 1024 * 1024 * 1024);
|
std::min(maxBufferBindingSize, uint64_t(2) * 1024 * 1024 * 1024);
|
||||||
// With WARP or on 32-bit platforms, such large buffer allocations often fail.
|
// With WARP or on 32-bit platforms, such large buffer allocations often fail.
|
||||||
#ifdef DAWN_PLATFORM_32_BIT
|
#if DAWN_PLATFORM_IS(32_BIT)
|
||||||
if (IsWindows()) {
|
if (IsWindows()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
// Include windows.h before GLFW so GLFW's APIENTRY macro doesn't conflict with windows.h's.
|
// Include windows.h before GLFW so GLFW's APIENTRY macro doesn't conflict with windows.h's.
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include "dawn/common/windows_with_undefs.h"
|
#include "dawn/common/windows_with_undefs.h"
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ TEST_F(WindowSurfaceInstanceTests, TwoChainedDescriptors) {
|
||||||
AssertSurfaceCreation(&descriptor, false);
|
AssertSurfaceCreation(&descriptor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
// Tests that GLFWUtils returns a descriptor of HWND type
|
// Tests that GLFWUtils returns a descriptor of HWND type
|
||||||
TEST_F(WindowSurfaceInstanceTests, CorrectSTypeHWND) {
|
TEST_F(WindowSurfaceInstanceTests, CorrectSTypeHWND) {
|
||||||
|
@ -160,7 +160,7 @@ TEST_F(WindowSurfaceInstanceTests, InvalidHWND) {
|
||||||
AssertSurfaceCreation(&descriptor, false);
|
AssertSurfaceCreation(&descriptor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // defined(DAWN_PLATFORM_WINDOWS)
|
#else // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
// Test using HWND when it is not supported
|
// Test using HWND when it is not supported
|
||||||
TEST_F(WindowSurfaceInstanceTests, HWNDSurfacesAreInvalid) {
|
TEST_F(WindowSurfaceInstanceTests, HWNDSurfacesAreInvalid) {
|
||||||
|
@ -173,7 +173,7 @@ TEST_F(WindowSurfaceInstanceTests, HWNDSurfacesAreInvalid) {
|
||||||
AssertSurfaceCreation(&descriptor, false);
|
AssertSurfaceCreation(&descriptor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // defined(DAWN_PLATFORM_WINDOWS)
|
#endif // DAWN_PLATFORM_IS(WINDOWS)
|
||||||
|
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ TEST(StackContainer, BufferAlignment) {
|
||||||
aligned16->push_back(AlignedData<16>());
|
aligned16->push_back(AlignedData<16>());
|
||||||
EXPECT_ALIGNED(&aligned16[0], 16);
|
EXPECT_ALIGNED(&aligned16[0], 16);
|
||||||
|
|
||||||
#if !defined(DAWN_COMPILER_GCC) || defined(__x86_64__) || defined(__i386__)
|
#if !DAWN_COMPILER_IS(GCC) || defined(__x86_64__) || defined(__i386__)
|
||||||
// It seems that non-X86 gcc doesn't respect greater than 16 byte alignment.
|
// It seems that non-X86 gcc doesn't respect greater than 16 byte alignment.
|
||||||
// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33721 for details.
|
// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33721 for details.
|
||||||
// TODO(sbc): Re-enable this if GCC starts respecting higher alignments.
|
// TODO(sbc): Re-enable this if GCC starts respecting higher alignments.
|
||||||
|
|
|
@ -29,9 +29,9 @@ namespace {
|
||||||
class EGLFunctions {
|
class EGLFunctions {
|
||||||
public:
|
public:
|
||||||
EGLFunctions() {
|
EGLFunctions() {
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
const char* eglLib = "libEGL.dll";
|
const char* eglLib = "libEGL.dll";
|
||||||
#elif defined(DAWN_PLATFORM_MACOS)
|
#elif DAWN_PLATFORM_IS(MACOS)
|
||||||
const char* eglLib = "libEGL.dylib";
|
const char* eglLib = "libEGL.dylib";
|
||||||
#else
|
#else
|
||||||
const char* eglLib = "libEGL.so";
|
const char* eglLib = "libEGL.so";
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
#include "dawn/utils/GLFWUtils.h"
|
#include "dawn/utils/GLFWUtils.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_USE_X11)
|
#if defined(DAWN_USE_X11)
|
||||||
|
@ -68,7 +68,7 @@ std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(GLF
|
||||||
|
|
||||||
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) {
|
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) {
|
||||||
switch (glfwGetPlatform()) {
|
switch (glfwGetPlatform()) {
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
case GLFW_PLATFORM_WIN32: {
|
case GLFW_PLATFORM_WIN32: {
|
||||||
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
|
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
|
||||||
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
|
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
#include "dawn/common/Platform.h"
|
#include "dawn/common/Platform.h"
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#elif defined(DAWN_PLATFORM_POSIX)
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#else
|
#else
|
||||||
#error "Unsupported platform."
|
#error "Unsupported platform."
|
||||||
|
@ -26,11 +26,11 @@
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
void USleep(unsigned int usecs) {
|
void USleep(unsigned int usecs) {
|
||||||
Sleep(static_cast<DWORD>(usecs / 1000));
|
Sleep(static_cast<DWORD>(usecs / 1000));
|
||||||
}
|
}
|
||||||
#elif defined(DAWN_PLATFORM_POSIX)
|
#elif DAWN_PLATFORM_IS(POSIX)
|
||||||
void USleep(unsigned int usecs) {
|
void USleep(unsigned int usecs) {
|
||||||
usleep(usecs);
|
usleep(usecs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue