Rename src/common macros NXT_* to DAWN_*
This commit is contained in:
parent
33ca49614d
commit
83a9c9d6d9
|
@ -109,7 +109,7 @@
|
|||
|
||||
//* Returns the required transfer size for `record` in addition to the transfer structure.
|
||||
size_t {{name}}GetExtraRequiredSize(const {{name}}& record) {
|
||||
NXT_UNUSED(record);
|
||||
DAWN_UNUSED(record);
|
||||
|
||||
size_t result = 0;
|
||||
|
||||
|
@ -140,8 +140,8 @@
|
|||
//* and `provider` to serialize objects.
|
||||
void {{name}}Serialize(const {{name}}& record, {{name}}Transfer* transfer,
|
||||
char* buffer, const ObjectIdProvider& provider) {
|
||||
NXT_UNUSED(provider);
|
||||
NXT_UNUSED(buffer);
|
||||
DAWN_UNUSED(provider);
|
||||
DAWN_UNUSED(buffer);
|
||||
|
||||
//* Handle special transfer members of methods.
|
||||
{% if is_method %}
|
||||
|
@ -189,10 +189,10 @@
|
|||
//* Ids to actual objects.
|
||||
DeserializeResult {{name}}Deserialize({{name}}* record, const {{name}}Transfer* transfer,
|
||||
const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver) {
|
||||
NXT_UNUSED(allocator);
|
||||
NXT_UNUSED(resolver);
|
||||
NXT_UNUSED(buffer);
|
||||
NXT_UNUSED(size);
|
||||
DAWN_UNUSED(allocator);
|
||||
DAWN_UNUSED(resolver);
|
||||
DAWN_UNUSED(buffer);
|
||||
DAWN_UNUSED(size);
|
||||
|
||||
//* Handle special transfer members for methods
|
||||
{% if is_method %}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace backend {
|
|||
void HandleError(const char* message);
|
||||
|
||||
bool ConsumedError(MaybeError maybeError) {
|
||||
if (NXT_UNLIKELY(maybeError.IsError())) {
|
||||
if (DAWN_UNLIKELY(maybeError.IsError())) {
|
||||
ConsumeError(maybeError.AcquireError());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace backend {
|
|||
#define DAWN_TRY(EXPR) \
|
||||
{ \
|
||||
auto DAWN_LOCAL_VAR = EXPR; \
|
||||
if (NXT_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
|
||||
if (DAWN_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
|
||||
ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
|
||||
AppendBacktrace(error, __FILE__, __func__, __LINE__); \
|
||||
return {error}; \
|
||||
|
@ -70,7 +70,7 @@ namespace backend {
|
|||
#define DAWN_TRY_ASSIGN(VAR, EXPR) \
|
||||
{ \
|
||||
auto DAWN_LOCAL_VAR = EXPR; \
|
||||
if (NXT_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
|
||||
if (DAWN_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
|
||||
ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
|
||||
AppendBacktrace(error, __FILE__, __func__, __LINE__); \
|
||||
return {error}; \
|
||||
|
|
|
@ -49,22 +49,22 @@ namespace backend {
|
|||
class PerStage {
|
||||
public:
|
||||
T& operator[](dawn::ShaderStage stage) {
|
||||
NXT_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
DAWN_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return mData[static_cast<uint32_t>(stage)];
|
||||
}
|
||||
const T& operator[](dawn::ShaderStage stage) const {
|
||||
NXT_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
DAWN_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return mData[static_cast<uint32_t>(stage)];
|
||||
}
|
||||
|
||||
T& operator[](dawn::ShaderStageBit stageBit) {
|
||||
uint32_t bit = static_cast<uint32_t>(stageBit);
|
||||
NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
return mData[Log2(bit)];
|
||||
}
|
||||
const T& operator[](dawn::ShaderStageBit stageBit) const {
|
||||
uint32_t bit = static_cast<uint32_t>(stageBit);
|
||||
NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
return mData[Log2(bit)];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace backend { namespace d3d12 {
|
|||
case dawn::BindingType::StorageBuffer:
|
||||
return mMap[3];
|
||||
default:
|
||||
NXT_UNREACHABLE();
|
||||
DAWN_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ using Microsoft::WRL::ComPtr;
|
|||
|
||||
// Remove windows.h macros after d3d12's include of windows.h
|
||||
#include "common/Platform.h"
|
||||
#if defined(NXT_PLATFORM_WINDOWS)
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
# include "common/windows_with_undefs.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "glad/glad.h"
|
||||
|
||||
// Remove windows.h macros after glad's include of windows.h
|
||||
#if defined(NXT_PLATFORM_WINDOWS)
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
# include "common/windows_with_undefs.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace backend { namespace opengl {
|
|||
spirv_cross::CompilerGLSL::Options options;
|
||||
|
||||
// TODO(cwallez@chromium.org): discover the backing context version and use that.
|
||||
#if defined(NXT_PLATFORM_APPLE)
|
||||
#if defined(DAWN_PLATFORM_APPLE)
|
||||
options.version = 410;
|
||||
#else
|
||||
options.version = 440;
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#if NXT_PLATFORM_LINUX
|
||||
#if DAWN_PLATFORM_LINUX
|
||||
const char kVulkanLibName[] = "libvulkan.so.1";
|
||||
#elif NXT_PLATFORM_WINDOWS
|
||||
#elif DAWN_PLATFORM_WINDOWS
|
||||
const char kVulkanLibName[] = "vulkan-1.dll";
|
||||
#else
|
||||
# error "Unimplemented Vulkan backend platform"
|
||||
|
|
|
@ -22,5 +22,5 @@ void HandleAssertionFailure(const char* file,
|
|||
const char* condition) {
|
||||
std::cerr << "Assertion failure at " << file << ":" << line << " (" << function
|
||||
<< "): " << condition << std::endl;
|
||||
NXT_BREAKPOINT();
|
||||
DAWN_BREAKPOINT();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// release it does nothing at runtime.
|
||||
//
|
||||
// In case of name clashes (with for example a testing library), you can define the
|
||||
// NXT_SKIP_ASSERT_SHORTHANDS to only define the NXT_ prefixed macros.
|
||||
// DAWN_SKIP_ASSERT_SHORTHANDS to only define the DAWN_ prefixed macros.
|
||||
//
|
||||
// These asserts feature:
|
||||
// - Logging of the error with file, line and function information.
|
||||
|
@ -31,45 +31,45 @@
|
|||
|
||||
// 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.
|
||||
#if defined(NXT_COMPILER_MSVC)
|
||||
# define NXT_ASSERT_LOOP_CONDITION (0, 0)
|
||||
#if defined(DAWN_COMPILER_MSVC)
|
||||
# define DAWN_ASSERT_LOOP_CONDITION (0, 0)
|
||||
#else
|
||||
# define NXT_ASSERT_LOOP_CONDITION (0)
|
||||
# define DAWN_ASSERT_LOOP_CONDITION (0)
|
||||
#endif
|
||||
|
||||
// NXT_ASSERT_CALLSITE_HELPER generates the actual assert code. In Debug it does what you would
|
||||
// DAWN_ASSERT_CALLSITE_HELPER generates the actual assert code. In Debug it does what you would
|
||||
// expect of an assert and in release it tries to give hints to make the compiler generate better
|
||||
// code.
|
||||
#if defined(NXT_ENABLE_ASSERTS)
|
||||
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||
#if defined(DAWN_ENABLE_ASSERTS)
|
||||
# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
HandleAssertionFailure(file, func, line, #condition); \
|
||||
} \
|
||||
} while (NXT_ASSERT_LOOP_CONDITION)
|
||||
} while (DAWN_ASSERT_LOOP_CONDITION)
|
||||
#else
|
||||
# if defined(NXT_COMPILER_MSVC)
|
||||
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
|
||||
# elif defined(NXT_COMPILER_CLANG) && defined(__builtin_assume)
|
||||
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
|
||||
# if defined(DAWN_COMPILER_MSVC)
|
||||
# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
|
||||
# elif defined(DAWN_COMPILER_CLANG) && defined(__builtin_assume)
|
||||
# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
|
||||
# else
|
||||
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||
do { \
|
||||
NXT_UNUSED(sizeof(condition)); \
|
||||
} while (NXT_ASSERT_LOOP_CONDITION)
|
||||
# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||
do { \
|
||||
DAWN_UNUSED(sizeof(condition)); \
|
||||
} while (DAWN_ASSERT_LOOP_CONDITION)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define NXT_ASSERT(condition) NXT_ASSERT_CALLSITE_HELPER(__FILE__, __func__, __LINE__, condition)
|
||||
#define NXT_UNREACHABLE() \
|
||||
do { \
|
||||
NXT_ASSERT(NXT_ASSERT_LOOP_CONDITION && "Unreachable code hit"); \
|
||||
NXT_BUILTIN_UNREACHABLE(); \
|
||||
} while (NXT_ASSERT_LOOP_CONDITION)
|
||||
#define DAWN_ASSERT(condition) DAWN_ASSERT_CALLSITE_HELPER(__FILE__, __func__, __LINE__, condition)
|
||||
#define DAWN_UNREACHABLE() \
|
||||
do { \
|
||||
DAWN_ASSERT(DAWN_ASSERT_LOOP_CONDITION && "Unreachable code hit"); \
|
||||
DAWN_BUILTIN_UNREACHABLE(); \
|
||||
} while (DAWN_ASSERT_LOOP_CONDITION)
|
||||
|
||||
#if !defined(NXT_SKIP_ASSERT_SHORTHANDS)
|
||||
# define ASSERT NXT_ASSERT
|
||||
# define UNREACHABLE NXT_UNREACHABLE
|
||||
#if !defined(DAWN_SKIP_ASSERT_SHORTHANDS)
|
||||
# define ASSERT DAWN_ASSERT
|
||||
# define UNREACHABLE DAWN_UNREACHABLE
|
||||
#endif
|
||||
|
||||
void HandleAssertionFailure(const char* file,
|
||||
|
|
|
@ -94,7 +94,7 @@ BitSetIterator<N, T>::Iterator::Iterator(const std::bitset<N>& bits)
|
|||
|
||||
template <size_t N, typename T>
|
||||
typename BitSetIterator<N, T>::Iterator& BitSetIterator<N, T>::Iterator::operator++() {
|
||||
NXT_ASSERT(mBits.any());
|
||||
DAWN_ASSERT(mBits.any());
|
||||
mBits.set(mCurrentBit - mOffset, 0);
|
||||
mCurrentBit = getNextBit();
|
||||
return *this;
|
||||
|
|
|
@ -16,31 +16,31 @@
|
|||
#define COMMON_COMPILER_H_
|
||||
|
||||
// Defines macros for compiler-specific functionality
|
||||
// - NXT_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
|
||||
// - NXT_BREAKPOINT(): Raises an exception and breaks in the debugger
|
||||
// - NXT_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
|
||||
// - NXT_NO_DISCARD: An attribute that is C++17 [[nodiscard]] where available
|
||||
// - NXT_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
|
||||
// - DAWN_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
|
||||
// - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
|
||||
// - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
|
||||
// - DAWN_NO_DISCARD: An attribute that is C++17 [[nodiscard]] where available
|
||||
// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
|
||||
// (resp. false) to help it generate code that leads to better branch prediction.
|
||||
// - NXT_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
|
||||
// - DAWN_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
|
||||
|
||||
// Clang and GCC
|
||||
#if defined(__GNUC__)
|
||||
# if defined(__clang__)
|
||||
# define NXT_COMPILER_CLANG
|
||||
# define DAWN_COMPILER_CLANG
|
||||
# else
|
||||
# define NXT_COMPILER_GCC
|
||||
# define DAWN_COMPILER_GCC
|
||||
# endif
|
||||
|
||||
# if defined(__i386__) || defined(__x86_64__)
|
||||
# define NXT_BREAKPOINT() __asm__ __volatile__("int $3\n\t")
|
||||
# define DAWN_BREAKPOINT() __asm__ __volatile__("int $3\n\t")
|
||||
# else
|
||||
# error "Implement BREAKPOINT on your platform"
|
||||
# endif
|
||||
|
||||
# define NXT_BUILTIN_UNREACHABLE() __builtin_unreachable()
|
||||
# define NXT_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
# define NXT_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
# define DAWN_BUILTIN_UNREACHABLE() __builtin_unreachable()
|
||||
# define DAWN_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
# define DAWN_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
# if !defined(__has_cpp_attribute)
|
||||
# define __has_cpp_attribute(name) 0
|
||||
|
@ -50,23 +50,23 @@
|
|||
// Also avoid warn_unused_result with GCC because it is only a function attribute and not a type
|
||||
// attribute.
|
||||
# if __has_cpp_attribute(warn_unused_result) && defined(__clang__)
|
||||
# define NXT_NO_DISCARD __attribute__((warn_unused_result))
|
||||
# elif NXT_CPP_VERSION >= 17 && __has_cpp_attribute(nodiscard)
|
||||
# define NXT_NO_DISCARD [[nodiscard]]
|
||||
# define DAWN_NO_DISCARD __attribute__((warn_unused_result))
|
||||
# elif DAWN_CPP_VERSION >= 17 && __has_cpp_attribute(nodiscard)
|
||||
# define DAWN_NO_DISCARD [[nodiscard]]
|
||||
# endif
|
||||
|
||||
// MSVC
|
||||
#elif defined(_MSC_VER)
|
||||
# define NXT_COMPILER_MSVC
|
||||
# define DAWN_COMPILER_MSVC
|
||||
|
||||
extern void __cdecl __debugbreak(void);
|
||||
# define NXT_BREAKPOINT() __debugbreak()
|
||||
# define DAWN_BREAKPOINT() __debugbreak()
|
||||
|
||||
# define NXT_BUILTIN_UNREACHABLE() __assume(false)
|
||||
# define DAWN_BUILTIN_UNREACHABLE() __assume(false)
|
||||
|
||||
// Visual Studio 2017 15.3 adds support for [[nodiscard]]
|
||||
# if _MSC_VER >= 1911 && NXT_CPP_VERSION >= 17
|
||||
# define NXT_NO_DISCARD [[nodiscard]]
|
||||
# if _MSC_VER >= 1911 && DAWN_CPP_VERSION >= 17
|
||||
# define DAWN_NO_DISCARD [[nodiscard]]
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
@ -74,17 +74,17 @@ extern void __cdecl __debugbreak(void);
|
|||
#endif
|
||||
|
||||
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
|
||||
#define NXT_UNUSED(EXPR) (void)EXPR
|
||||
#define DAWN_UNUSED(EXPR) (void)EXPR
|
||||
|
||||
// Add noop replacements for macros for features that aren't supported by the compiler.
|
||||
#if !defined(NXT_LIKELY)
|
||||
# define NXT_LIKELY(X) X
|
||||
#if !defined(DAWN_LIKELY)
|
||||
# define DAWN_LIKELY(X) X
|
||||
#endif
|
||||
#if !defined(NXT_UNLIKELY)
|
||||
# define NXT_UNLIKELY(X) X
|
||||
#if !defined(DAWN_UNLIKELY)
|
||||
# define DAWN_UNLIKELY(X) X
|
||||
#endif
|
||||
#if !defined(NXT_NO_DISCARD)
|
||||
# define NXT_NO_DISCARD
|
||||
#if !defined(DAWN_NO_DISCARD)
|
||||
# define DAWN_NO_DISCARD
|
||||
#endif
|
||||
|
||||
#endif // COMMON_COMPILER_H_
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
#include "common/Platform.h"
|
||||
|
||||
#if NXT_PLATFORM_WINDOWS
|
||||
#if DAWN_PLATFORM_WINDOWS
|
||||
# include "common/windows_with_undefs.h"
|
||||
#elif NXT_PLATFORM_POSIX
|
||||
#elif DAWN_PLATFORM_POSIX
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# error "Unsupported platform for DynamicLib"
|
||||
|
@ -42,13 +42,13 @@ bool DynamicLib::Valid() const {
|
|||
}
|
||||
|
||||
bool DynamicLib::Open(const std::string& filename, std::string* error) {
|
||||
#if NXT_PLATFORM_WINDOWS
|
||||
#if DAWN_PLATFORM_WINDOWS
|
||||
mHandle = LoadLibraryA(filename.c_str());
|
||||
|
||||
if (mHandle == nullptr && error != nullptr) {
|
||||
*error = "Windows Error: " + std::to_string(GetLastError());
|
||||
}
|
||||
#elif NXT_PLATFORM_POSIX
|
||||
#elif DAWN_PLATFORM_POSIX
|
||||
mHandle = dlopen(filename.c_str(), RTLD_NOW);
|
||||
|
||||
if (mHandle == nullptr && error != nullptr) {
|
||||
|
@ -66,9 +66,9 @@ void DynamicLib::Close() {
|
|||
return;
|
||||
}
|
||||
|
||||
#if NXT_PLATFORM_WINDOWS
|
||||
#if DAWN_PLATFORM_WINDOWS
|
||||
FreeLibrary(static_cast<HMODULE>(mHandle));
|
||||
#elif NXT_PLATFORM_POSIX
|
||||
#elif DAWN_PLATFORM_POSIX
|
||||
dlclose(mHandle);
|
||||
#else
|
||||
# error "Unsupported platform for DynamicLib"
|
||||
|
@ -80,13 +80,13 @@ void DynamicLib::Close() {
|
|||
void* DynamicLib::GetProc(const std::string& procName, std::string* error) const {
|
||||
void* proc = nullptr;
|
||||
|
||||
#if NXT_PLATFORM_WINDOWS
|
||||
#if DAWN_PLATFORM_WINDOWS
|
||||
proc = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(mHandle), procName.c_str()));
|
||||
|
||||
if (proc == nullptr && error != nullptr) {
|
||||
*error = "Windows Error: " + std::to_string(GetLastError());
|
||||
}
|
||||
#elif NXT_PLATFORM_POSIX
|
||||
#elif DAWN_PLATFORM_POSIX
|
||||
proc = reinterpret_cast<void*>(dlsym(mHandle, procName.c_str()));
|
||||
|
||||
if (proc == nullptr && error != nullptr) {
|
||||
|
|
|
@ -36,9 +36,9 @@ size_t Hash(const T& value) {
|
|||
// return hash;
|
||||
template <typename T>
|
||||
void HashCombine(size_t* hash, const T& value) {
|
||||
#if defined(NXT_PLATFORM_64_BIT)
|
||||
#if defined(DAWN_PLATFORM_64_BIT)
|
||||
const size_t offset = 0x9e3779b97f4a7c16;
|
||||
#elif defined(NXT_PLATFORM_32_BIT)
|
||||
#elif defined(DAWN_PLATFORM_32_BIT)
|
||||
const size_t offset = 0x9e3779b9;
|
||||
#else
|
||||
# error "Unsupported platform"
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
#include "common/Assert.h"
|
||||
|
||||
#if defined(NXT_COMPILER_MSVC)
|
||||
#if defined(DAWN_COMPILER_MSVC)
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
uint32_t ScanForward(uint32_t bits) {
|
||||
ASSERT(bits != 0);
|
||||
#if defined(NXT_COMPILER_MSVC)
|
||||
#if defined(DAWN_COMPILER_MSVC)
|
||||
unsigned long firstBitIndex = 0ul;
|
||||
unsigned char ret = _BitScanForward(&firstBitIndex, bits);
|
||||
ASSERT(ret != 0);
|
||||
|
@ -34,7 +34,7 @@ uint32_t ScanForward(uint32_t bits) {
|
|||
|
||||
uint32_t Log2(uint32_t value) {
|
||||
ASSERT(value != 0);
|
||||
#if defined(NXT_COMPILER_MSVC)
|
||||
#if defined(DAWN_COMPILER_MSVC)
|
||||
unsigned long firstBitIndex = 0ul;
|
||||
unsigned char ret = _BitScanReverse(&firstBitIndex, value);
|
||||
ASSERT(ret != 0);
|
||||
|
|
|
@ -16,22 +16,22 @@
|
|||
#define COMMON_PLATFORM_H_
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# define NXT_PLATFORM_WINDOWS 1
|
||||
# define DAWN_PLATFORM_WINDOWS 1
|
||||
#elif defined(__linux__)
|
||||
# define NXT_PLATFORM_LINUX 1
|
||||
# define NXT_PLATFORM_POSIX 1
|
||||
# define DAWN_PLATFORM_LINUX 1
|
||||
# define DAWN_PLATFORM_POSIX 1
|
||||
#elif defined(__APPLE__)
|
||||
# define NXT_PLATFORM_APPLE 1
|
||||
# define NXT_PLATFORM_POSIX 1
|
||||
# define DAWN_PLATFORM_APPLE 1
|
||||
# define DAWN_PLATFORM_POSIX 1
|
||||
#else
|
||||
# error "Unsupported platform."
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__)
|
||||
# define NXT_PLATFORM_64_BIT 1
|
||||
# define DAWN_PLATFORM_64_BIT 1
|
||||
static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
|
||||
#elif defined(_WIN32) || defined(__i386__) || defined(__arm__)
|
||||
# define NXT_PLATFORM_32_BIT 1
|
||||
# define DAWN_PLATFORM_32_BIT 1
|
||||
static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
|
||||
#else
|
||||
# error "Unsupported platform"
|
||||
|
|
|
@ -55,7 +55,7 @@ class Result;
|
|||
// Specialization of Result for returning errors only via pointers. It is basically a pointer
|
||||
// where nullptr is both Success and Empty.
|
||||
template <typename E>
|
||||
class NXT_NO_DISCARD Result<void, E*> {
|
||||
class DAWN_NO_DISCARD Result<void, E*> {
|
||||
public:
|
||||
Result();
|
||||
Result(E* error);
|
||||
|
@ -85,7 +85,7 @@ constexpr size_t alignof_if_defined_else_default<T, Default, decltype(alignof(T)
|
|||
// Specialization of Result when both the error an success are pointers. It is implemented as a
|
||||
// tagged pointer. The tag for Success is 0 so that returning the value is fastest.
|
||||
template <typename T, typename E>
|
||||
class NXT_NO_DISCARD Result<T*, E*> {
|
||||
class DAWN_NO_DISCARD Result<T*, E*> {
|
||||
public:
|
||||
static_assert(alignof_if_defined_else_default<T, 4> >= 4,
|
||||
"Result<T*, E*> reserves two bits for tagging pointers");
|
||||
|
|
|
@ -117,7 +117,7 @@ class SerialQueue {
|
|||
|
||||
template <typename T>
|
||||
void SerialQueue<T>::Enqueue(const T& value, Serial serial) {
|
||||
NXT_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
DAWN_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
|
||||
if (Empty() || mStorage.back().first < serial) {
|
||||
mStorage.emplace_back(SerialPair(serial, {}));
|
||||
|
@ -127,7 +127,7 @@ void SerialQueue<T>::Enqueue(const T& value, Serial serial) {
|
|||
|
||||
template <typename T>
|
||||
void SerialQueue<T>::Enqueue(T&& value, Serial serial) {
|
||||
NXT_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
DAWN_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
|
||||
if (Empty() || mStorage.back().first < serial) {
|
||||
mStorage.emplace_back(SerialPair(serial, {}));
|
||||
|
@ -137,15 +137,15 @@ void SerialQueue<T>::Enqueue(T&& value, Serial serial) {
|
|||
|
||||
template <typename T>
|
||||
void SerialQueue<T>::Enqueue(const std::vector<T>& values, Serial serial) {
|
||||
NXT_ASSERT(values.size() > 0);
|
||||
NXT_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
DAWN_ASSERT(values.size() > 0);
|
||||
DAWN_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
mStorage.emplace_back(SerialPair(serial, {values}));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SerialQueue<T>::Enqueue(std::vector<T>&& values, Serial serial) {
|
||||
NXT_ASSERT(values.size() > 0);
|
||||
NXT_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
DAWN_ASSERT(values.size() > 0);
|
||||
DAWN_ASSERT(Empty() || mStorage.back().first <= serial);
|
||||
mStorage.emplace_back(SerialPair(serial, {values}));
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ void SerialQueue<T>::ClearUpTo(Serial serial) {
|
|||
|
||||
template <typename T>
|
||||
Serial SerialQueue<T>::FirstSerial() const {
|
||||
NXT_ASSERT(!Empty());
|
||||
DAWN_ASSERT(!Empty());
|
||||
return mStorage.front().first;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ class VkNonDispatchableHandle {
|
|||
|
||||
// Remove windows.h macros after vulkan_platform's include of windows.h
|
||||
#include "common/Platform.h"
|
||||
#if defined(NXT_PLATFORM_WINDOWS)
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
# include "common/windows_with_undefs.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "common/Compiler.h"
|
||||
|
||||
#if !defined(NXT_PLATFORM_WINDOWS)
|
||||
#if !defined(DAWN_PLATFORM_WINDOWS)
|
||||
# error "windows_with_undefs.h included on non-Windows"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -129,10 +129,10 @@ bool gTestUsesWire = false;
|
|||
|
||||
void NXTTest::SetUp() {
|
||||
mBinding = utils::CreateBinding(ParamToBackendType(GetParam()));
|
||||
NXT_ASSERT(mBinding != nullptr);
|
||||
DAWN_ASSERT(mBinding != nullptr);
|
||||
|
||||
GLFWwindow* testWindow = GetWindowForBackend(mBinding, GetParam());
|
||||
NXT_ASSERT(testWindow != nullptr);
|
||||
DAWN_ASSERT(testWindow != nullptr);
|
||||
|
||||
mBinding->SetWindow(testWindow);
|
||||
|
||||
|
@ -323,7 +323,7 @@ void NXTTest::MapSlotsSynchronously() {
|
|||
void NXTTest::SlotMapReadCallback(nxtBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
nxtCallbackUserdata userdata_) {
|
||||
NXT_ASSERT(status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||
DAWN_ASSERT(status == NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||
|
||||
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
||||
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
|
||||
|
@ -334,7 +334,7 @@ void NXTTest::SlotMapReadCallback(nxtBufferMapAsyncStatus status,
|
|||
|
||||
void NXTTest::ResolveExpectations() {
|
||||
for (const auto& expectation : mDeferredExpectations) {
|
||||
NXT_ASSERT(mReadbackSlots[expectation.readbackSlot].mappedData != nullptr);
|
||||
DAWN_ASSERT(mReadbackSlots[expectation.readbackSlot].mappedData != nullptr);
|
||||
|
||||
// Get a pointer to the mapped copy of the data for the expectation.
|
||||
const char* data = reinterpret_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData);
|
||||
|
@ -343,7 +343,7 @@ void NXTTest::ResolveExpectations() {
|
|||
uint32_t size;
|
||||
std::vector<char> packedData;
|
||||
if (expectation.rowBytes != expectation.rowPitch) {
|
||||
NXT_ASSERT(expectation.rowPitch > expectation.rowBytes);
|
||||
DAWN_ASSERT(expectation.rowPitch > expectation.rowBytes);
|
||||
uint32_t rowCount = (expectation.size + expectation.rowPitch - 1) / expectation.rowPitch;
|
||||
uint32_t packedSize = rowCount * expectation.rowBytes;
|
||||
packedData.resize(packedSize);
|
||||
|
@ -436,7 +436,7 @@ namespace detail {
|
|||
|
||||
template<typename T>
|
||||
testing::AssertionResult ExpectEq<T>::Check(const void* data, size_t size) {
|
||||
NXT_ASSERT(size == sizeof(T) * mExpected.size());
|
||||
DAWN_ASSERT(size == sizeof(T) * mExpected.size());
|
||||
|
||||
const T* actual = reinterpret_cast<const T*>(data);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class InputStateTest : public NXTTest {
|
|||
case VertexFormat::FloatR32:
|
||||
return component >= 1;
|
||||
default:
|
||||
NXT_UNREACHABLE();
|
||||
DAWN_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ TEST_F(BitSetIteratorTest, EmptySet) {
|
|||
// causing an unreachable code warning in MSVS
|
||||
bool sawBit = false;
|
||||
for (unsigned long bit : IterateBitSet(mStateBits)) {
|
||||
NXT_UNUSED(bit);
|
||||
DAWN_UNUSED(bit);
|
||||
sawBit = true;
|
||||
}
|
||||
EXPECT_FALSE(sawBit);
|
||||
|
|
|
@ -178,7 +178,7 @@ TEST(ErrorTests, TRY_RESULT_Error) {
|
|||
auto Try = [ReturnError]() -> ResultOrError<int*> {
|
||||
int* result = nullptr;
|
||||
DAWN_TRY_ASSIGN(result, ReturnError());
|
||||
NXT_UNUSED(result);
|
||||
DAWN_UNUSED(result);
|
||||
|
||||
// DAWN_TRY should return before this point
|
||||
EXPECT_FALSE(true);
|
||||
|
@ -233,7 +233,7 @@ TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
|||
auto Try = [ReturnError]() -> MaybeError {
|
||||
int* result = nullptr;
|
||||
DAWN_TRY_ASSIGN(result, ReturnError());
|
||||
NXT_UNUSED(result);
|
||||
DAWN_UNUSED(result);
|
||||
|
||||
return {};
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ TEST(SerialQueue, BasicTest) {
|
|||
|
||||
// Iterating on empty queue 1) works 2) doesn't produce any values
|
||||
for (int value : queue.IterateAll()) {
|
||||
NXT_UNUSED(value);
|
||||
DAWN_UNUSED(value);
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ TEST(SerialQueue, BasicTest) {
|
|||
ASSERT_TRUE(queue.Empty());
|
||||
|
||||
for (int value : queue.IterateAll()) {
|
||||
NXT_UNUSED(value);
|
||||
DAWN_UNUSED(value);
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace utils {
|
|||
class OpenGLBinding : public BackendBinding {
|
||||
public:
|
||||
void SetupGLFWWindowHints() override {
|
||||
#if defined(NXT_PLATFORM_APPLE)
|
||||
#if defined(DAWN_PLATFORM_APPLE)
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
#include "common/Platform.h"
|
||||
|
||||
#if defined(NXT_PLATFORM_WINDOWS)
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
# include <Windows.h>
|
||||
#elif defined(NXT_PLATFORM_POSIX)
|
||||
#elif defined(DAWN_PLATFORM_POSIX)
|
||||
# include <unistd.h>
|
||||
#else
|
||||
# error "Unsupported platform."
|
||||
|
@ -24,11 +24,11 @@
|
|||
|
||||
namespace utils {
|
||||
|
||||
#if defined(NXT_PLATFORM_WINDOWS)
|
||||
#if defined(DAWN_PLATFORM_WINDOWS)
|
||||
void USleep(unsigned int usecs) {
|
||||
Sleep(static_cast<DWORD>(usecs / 1000));
|
||||
}
|
||||
#elif defined(NXT_PLATFORM_POSIX)
|
||||
#elif defined(DAWN_PLATFORM_POSIX)
|
||||
void USleep(unsigned int usecs) {
|
||||
usleep(usecs);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue