Rename src/common macros NXT_* to DAWN_*

This commit is contained in:
Corentin Wallez 2018-07-18 13:37:54 +02:00 committed by Corentin Wallez
parent 33ca49614d
commit 83a9c9d6d9
28 changed files with 122 additions and 122 deletions

View File

@ -109,7 +109,7 @@
//* Returns the required transfer size for `record` in addition to the transfer structure. //* Returns the required transfer size for `record` in addition to the transfer structure.
size_t {{name}}GetExtraRequiredSize(const {{name}}& record) { size_t {{name}}GetExtraRequiredSize(const {{name}}& record) {
NXT_UNUSED(record); DAWN_UNUSED(record);
size_t result = 0; size_t result = 0;
@ -140,8 +140,8 @@
//* and `provider` to serialize objects. //* and `provider` to serialize objects.
void {{name}}Serialize(const {{name}}& record, {{name}}Transfer* transfer, void {{name}}Serialize(const {{name}}& record, {{name}}Transfer* transfer,
char* buffer, const ObjectIdProvider& provider) { char* buffer, const ObjectIdProvider& provider) {
NXT_UNUSED(provider); DAWN_UNUSED(provider);
NXT_UNUSED(buffer); DAWN_UNUSED(buffer);
//* Handle special transfer members of methods. //* Handle special transfer members of methods.
{% if is_method %} {% if is_method %}
@ -189,10 +189,10 @@
//* Ids to actual objects. //* Ids to actual objects.
DeserializeResult {{name}}Deserialize({{name}}* record, const {{name}}Transfer* transfer, DeserializeResult {{name}}Deserialize({{name}}* record, const {{name}}Transfer* transfer,
const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver) { const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver) {
NXT_UNUSED(allocator); DAWN_UNUSED(allocator);
NXT_UNUSED(resolver); DAWN_UNUSED(resolver);
NXT_UNUSED(buffer); DAWN_UNUSED(buffer);
NXT_UNUSED(size); DAWN_UNUSED(size);
//* Handle special transfer members for methods //* Handle special transfer members for methods
{% if is_method %} {% if is_method %}

View File

@ -33,7 +33,7 @@ namespace backend {
void HandleError(const char* message); void HandleError(const char* message);
bool ConsumedError(MaybeError maybeError) { bool ConsumedError(MaybeError maybeError) {
if (NXT_UNLIKELY(maybeError.IsError())) { if (DAWN_UNLIKELY(maybeError.IsError())) {
ConsumeError(maybeError.AcquireError()); ConsumeError(maybeError.AcquireError());
return true; return true;
} }

View File

@ -56,7 +56,7 @@ namespace backend {
#define DAWN_TRY(EXPR) \ #define DAWN_TRY(EXPR) \
{ \ { \
auto DAWN_LOCAL_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(); \ ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
AppendBacktrace(error, __FILE__, __func__, __LINE__); \ AppendBacktrace(error, __FILE__, __func__, __LINE__); \
return {error}; \ return {error}; \
@ -70,7 +70,7 @@ namespace backend {
#define DAWN_TRY_ASSIGN(VAR, EXPR) \ #define DAWN_TRY_ASSIGN(VAR, EXPR) \
{ \ { \
auto DAWN_LOCAL_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(); \ ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
AppendBacktrace(error, __FILE__, __func__, __LINE__); \ AppendBacktrace(error, __FILE__, __func__, __LINE__); \
return {error}; \ return {error}; \

View File

@ -49,22 +49,22 @@ namespace backend {
class PerStage { class PerStage {
public: public:
T& operator[](dawn::ShaderStage stage) { 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)]; return mData[static_cast<uint32_t>(stage)];
} }
const T& operator[](dawn::ShaderStage stage) const { 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)]; return mData[static_cast<uint32_t>(stage)];
} }
T& operator[](dawn::ShaderStageBit stageBit) { T& operator[](dawn::ShaderStageBit stageBit) {
uint32_t bit = static_cast<uint32_t>(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)]; return mData[Log2(bit)];
} }
const T& operator[](dawn::ShaderStageBit stageBit) const { const T& operator[](dawn::ShaderStageBit stageBit) const {
uint32_t bit = static_cast<uint32_t>(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)]; return mData[Log2(bit)];
} }

View File

@ -35,7 +35,7 @@ namespace backend { namespace d3d12 {
case dawn::BindingType::StorageBuffer: case dawn::BindingType::StorageBuffer:
return mMap[3]; return mMap[3];
default: default:
NXT_UNREACHABLE(); DAWN_UNREACHABLE();
} }
} }

View File

@ -27,7 +27,7 @@ using Microsoft::WRL::ComPtr;
// Remove windows.h macros after d3d12's include of windows.h // Remove windows.h macros after d3d12's include of windows.h
#include "common/Platform.h" #include "common/Platform.h"
#if defined(NXT_PLATFORM_WINDOWS) #if defined(DAWN_PLATFORM_WINDOWS)
# include "common/windows_with_undefs.h" # include "common/windows_with_undefs.h"
#endif #endif

View File

@ -24,7 +24,7 @@
#include "glad/glad.h" #include "glad/glad.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(NXT_PLATFORM_WINDOWS) #if defined(DAWN_PLATFORM_WINDOWS)
# include "common/windows_with_undefs.h" # include "common/windows_with_undefs.h"
#endif #endif

View File

@ -51,7 +51,7 @@ namespace backend { namespace opengl {
spirv_cross::CompilerGLSL::Options options; spirv_cross::CompilerGLSL::Options options;
// TODO(cwallez@chromium.org): discover the backing context version and use that. // 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; options.version = 410;
#else #else
options.version = 440; options.version = 440;

View File

@ -42,9 +42,9 @@
#include <iostream> #include <iostream>
#if NXT_PLATFORM_LINUX #if DAWN_PLATFORM_LINUX
const char kVulkanLibName[] = "libvulkan.so.1"; const char kVulkanLibName[] = "libvulkan.so.1";
#elif NXT_PLATFORM_WINDOWS #elif DAWN_PLATFORM_WINDOWS
const char kVulkanLibName[] = "vulkan-1.dll"; const char kVulkanLibName[] = "vulkan-1.dll";
#else #else
# error "Unimplemented Vulkan backend platform" # error "Unimplemented Vulkan backend platform"

View File

@ -22,5 +22,5 @@ void HandleAssertionFailure(const char* file,
const char* condition) { const char* condition) {
std::cerr << "Assertion failure at " << file << ":" << line << " (" << function std::cerr << "Assertion failure at " << file << ":" << line << " (" << function
<< "): " << condition << std::endl; << "): " << condition << std::endl;
NXT_BREAKPOINT(); DAWN_BREAKPOINT();
} }

View File

@ -22,7 +22,7 @@
// release it does nothing at runtime. // release it does nothing at runtime.
// //
// In case of name clashes (with for example a testing library), you can define the // 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: // These asserts feature:
// - Logging of the error with file, line and function information. // - 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 // 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(NXT_COMPILER_MSVC) #if defined(DAWN_COMPILER_MSVC)
# define NXT_ASSERT_LOOP_CONDITION (0, 0) # define DAWN_ASSERT_LOOP_CONDITION (0, 0)
#else #else
# define NXT_ASSERT_LOOP_CONDITION (0) # define DAWN_ASSERT_LOOP_CONDITION (0)
#endif #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 // expect of an assert and in release it tries to give hints to make the compiler generate better
// code. // code.
#if defined(NXT_ENABLE_ASSERTS) #if defined(DAWN_ENABLE_ASSERTS)
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) \ # define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
do { \ do { \
if (!(condition)) { \ if (!(condition)) { \
HandleAssertionFailure(file, func, line, #condition); \ HandleAssertionFailure(file, func, line, #condition); \
} \ } \
} while (NXT_ASSERT_LOOP_CONDITION) } while (DAWN_ASSERT_LOOP_CONDITION)
#else #else
# if defined(NXT_COMPILER_MSVC) # if defined(DAWN_COMPILER_MSVC)
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition) # define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
# elif defined(NXT_COMPILER_CLANG) && defined(__builtin_assume) # elif defined(DAWN_COMPILER_CLANG) && defined(__builtin_assume)
# define NXT_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 NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) \ # define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
do { \ do { \
NXT_UNUSED(sizeof(condition)); \ DAWN_UNUSED(sizeof(condition)); \
} while (NXT_ASSERT_LOOP_CONDITION) } while (DAWN_ASSERT_LOOP_CONDITION)
# endif # endif
#endif #endif
#define NXT_ASSERT(condition) NXT_ASSERT_CALLSITE_HELPER(__FILE__, __func__, __LINE__, condition) #define DAWN_ASSERT(condition) DAWN_ASSERT_CALLSITE_HELPER(__FILE__, __func__, __LINE__, condition)
#define NXT_UNREACHABLE() \ #define DAWN_UNREACHABLE() \
do { \ do { \
NXT_ASSERT(NXT_ASSERT_LOOP_CONDITION && "Unreachable code hit"); \ DAWN_ASSERT(DAWN_ASSERT_LOOP_CONDITION && "Unreachable code hit"); \
NXT_BUILTIN_UNREACHABLE(); \ DAWN_BUILTIN_UNREACHABLE(); \
} while (NXT_ASSERT_LOOP_CONDITION) } while (DAWN_ASSERT_LOOP_CONDITION)
#if !defined(NXT_SKIP_ASSERT_SHORTHANDS) #if !defined(DAWN_SKIP_ASSERT_SHORTHANDS)
# define ASSERT NXT_ASSERT # define ASSERT DAWN_ASSERT
# define UNREACHABLE NXT_UNREACHABLE # define UNREACHABLE DAWN_UNREACHABLE
#endif #endif
void HandleAssertionFailure(const char* file, void HandleAssertionFailure(const char* file,

View File

@ -94,7 +94,7 @@ BitSetIterator<N, T>::Iterator::Iterator(const std::bitset<N>& bits)
template <size_t N, typename T> template <size_t N, typename T>
typename BitSetIterator<N, T>::Iterator& BitSetIterator<N, T>::Iterator::operator++() { typename BitSetIterator<N, T>::Iterator& BitSetIterator<N, T>::Iterator::operator++() {
NXT_ASSERT(mBits.any()); DAWN_ASSERT(mBits.any());
mBits.set(mCurrentBit - mOffset, 0); mBits.set(mCurrentBit - mOffset, 0);
mCurrentBit = getNextBit(); mCurrentBit = getNextBit();
return *this; return *this;

View File

@ -16,31 +16,31 @@
#define COMMON_COMPILER_H_ #define COMMON_COMPILER_H_
// Defines macros for compiler-specific functionality // Defines macros for compiler-specific functionality
// - NXT_COMPILER_[CLANG|GCC|MSVC]: Compiler detection // - DAWN_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
// - NXT_BREAKPOINT(): Raises an exception and breaks in the debugger // - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
// - NXT_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable // - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
// - NXT_NO_DISCARD: An attribute that is C++17 [[nodiscard]] where available // - DAWN_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_(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. // (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 // Clang and GCC
#if defined(__GNUC__) #if defined(__GNUC__)
# if defined(__clang__) # if defined(__clang__)
# define NXT_COMPILER_CLANG # define DAWN_COMPILER_CLANG
# else # else
# define NXT_COMPILER_GCC # define DAWN_COMPILER_GCC
# endif # endif
# if defined(__i386__) || defined(__x86_64__) # 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 # else
# error "Implement BREAKPOINT on your platform" # error "Implement BREAKPOINT on your platform"
# endif # endif
# define NXT_BUILTIN_UNREACHABLE() __builtin_unreachable() # define DAWN_BUILTIN_UNREACHABLE() __builtin_unreachable()
# define NXT_LIKELY(x) __builtin_expect(!!(x), 1) # define DAWN_LIKELY(x) __builtin_expect(!!(x), 1)
# define NXT_UNLIKELY(x) __builtin_expect(!!(x), 0) # define DAWN_UNLIKELY(x) __builtin_expect(!!(x), 0)
# if !defined(__has_cpp_attribute) # if !defined(__has_cpp_attribute)
# define __has_cpp_attribute(name) 0 # 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 // Also avoid warn_unused_result with GCC because it is only a function attribute and not a type
// attribute. // attribute.
# if __has_cpp_attribute(warn_unused_result) && defined(__clang__) # if __has_cpp_attribute(warn_unused_result) && defined(__clang__)
# define NXT_NO_DISCARD __attribute__((warn_unused_result)) # define DAWN_NO_DISCARD __attribute__((warn_unused_result))
# elif NXT_CPP_VERSION >= 17 && __has_cpp_attribute(nodiscard) # elif DAWN_CPP_VERSION >= 17 && __has_cpp_attribute(nodiscard)
# define NXT_NO_DISCARD [[nodiscard]] # define DAWN_NO_DISCARD [[nodiscard]]
# endif # endif
// MSVC // MSVC
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define NXT_COMPILER_MSVC # define DAWN_COMPILER_MSVC
extern void __cdecl __debugbreak(void); 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]] // Visual Studio 2017 15.3 adds support for [[nodiscard]]
# if _MSC_VER >= 1911 && NXT_CPP_VERSION >= 17 # if _MSC_VER >= 1911 && DAWN_CPP_VERSION >= 17
# define NXT_NO_DISCARD [[nodiscard]] # define DAWN_NO_DISCARD [[nodiscard]]
# endif # endif
#else #else
@ -74,17 +74,17 @@ extern void __cdecl __debugbreak(void);
#endif #endif
// 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 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. // Add noop replacements for macros for features that aren't supported by the compiler.
#if !defined(NXT_LIKELY) #if !defined(DAWN_LIKELY)
# define NXT_LIKELY(X) X # define DAWN_LIKELY(X) X
#endif #endif
#if !defined(NXT_UNLIKELY) #if !defined(DAWN_UNLIKELY)
# define NXT_UNLIKELY(X) X # define DAWN_UNLIKELY(X) X
#endif #endif
#if !defined(NXT_NO_DISCARD) #if !defined(DAWN_NO_DISCARD)
# define NXT_NO_DISCARD # define DAWN_NO_DISCARD
#endif #endif
#endif // COMMON_COMPILER_H_ #endif // COMMON_COMPILER_H_

View File

@ -16,9 +16,9 @@
#include "common/Platform.h" #include "common/Platform.h"
#if NXT_PLATFORM_WINDOWS #if DAWN_PLATFORM_WINDOWS
# include "common/windows_with_undefs.h" # include "common/windows_with_undefs.h"
#elif NXT_PLATFORM_POSIX #elif DAWN_PLATFORM_POSIX
# include <dlfcn.h> # include <dlfcn.h>
#else #else
# error "Unsupported platform for DynamicLib" # error "Unsupported platform for DynamicLib"
@ -42,13 +42,13 @@ 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 NXT_PLATFORM_WINDOWS #if DAWN_PLATFORM_WINDOWS
mHandle = LoadLibraryA(filename.c_str()); mHandle = LoadLibraryA(filename.c_str());
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 NXT_PLATFORM_POSIX #elif DAWN_PLATFORM_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) {
@ -66,9 +66,9 @@ void DynamicLib::Close() {
return; return;
} }
#if NXT_PLATFORM_WINDOWS #if DAWN_PLATFORM_WINDOWS
FreeLibrary(static_cast<HMODULE>(mHandle)); FreeLibrary(static_cast<HMODULE>(mHandle));
#elif NXT_PLATFORM_POSIX #elif DAWN_PLATFORM_POSIX
dlclose(mHandle); dlclose(mHandle);
#else #else
# error "Unsupported platform for DynamicLib" # error "Unsupported platform for DynamicLib"
@ -80,13 +80,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 NXT_PLATFORM_WINDOWS #if DAWN_PLATFORM_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 NXT_PLATFORM_POSIX #elif DAWN_PLATFORM_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) {

View File

@ -36,9 +36,9 @@ size_t Hash(const 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(NXT_PLATFORM_64_BIT) #if defined(DAWN_PLATFORM_64_BIT)
const size_t offset = 0x9e3779b97f4a7c16; const size_t offset = 0x9e3779b97f4a7c16;
#elif defined(NXT_PLATFORM_32_BIT) #elif defined(DAWN_PLATFORM_32_BIT)
const size_t offset = 0x9e3779b9; const size_t offset = 0x9e3779b9;
#else #else
# error "Unsupported platform" # error "Unsupported platform"

View File

@ -16,13 +16,13 @@
#include "common/Assert.h" #include "common/Assert.h"
#if defined(NXT_COMPILER_MSVC) #if defined(DAWN_COMPILER_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(NXT_COMPILER_MSVC) #if defined(DAWN_COMPILER_MSVC)
unsigned long firstBitIndex = 0ul; unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanForward(&firstBitIndex, bits); unsigned char ret = _BitScanForward(&firstBitIndex, bits);
ASSERT(ret != 0); ASSERT(ret != 0);
@ -34,7 +34,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(NXT_COMPILER_MSVC) #if defined(DAWN_COMPILER_MSVC)
unsigned long firstBitIndex = 0ul; unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanReverse(&firstBitIndex, value); unsigned char ret = _BitScanReverse(&firstBitIndex, value);
ASSERT(ret != 0); ASSERT(ret != 0);

View File

@ -16,22 +16,22 @@
#define COMMON_PLATFORM_H_ #define COMMON_PLATFORM_H_
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
# define NXT_PLATFORM_WINDOWS 1 # define DAWN_PLATFORM_WINDOWS 1
#elif defined(__linux__) #elif defined(__linux__)
# define NXT_PLATFORM_LINUX 1 # define DAWN_PLATFORM_LINUX 1
# define NXT_PLATFORM_POSIX 1 # define DAWN_PLATFORM_POSIX 1
#elif defined(__APPLE__) #elif defined(__APPLE__)
# define NXT_PLATFORM_APPLE 1 # define DAWN_PLATFORM_APPLE 1
# define NXT_PLATFORM_POSIX 1 # define DAWN_PLATFORM_POSIX 1
#else #else
# error "Unsupported platform." # error "Unsupported platform."
#endif #endif
#if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__) #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"); static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
#elif defined(_WIN32) || defined(__i386__) || defined(__arm__) #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"); static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
#else #else
# error "Unsupported platform" # error "Unsupported platform"

View File

@ -55,7 +55,7 @@ class Result;
// Specialization of Result for returning errors only via pointers. It is basically a pointer // Specialization of Result for returning errors only via pointers. It is basically a pointer
// where nullptr is both Success and Empty. // where nullptr is both Success and Empty.
template <typename E> template <typename E>
class NXT_NO_DISCARD Result<void, E*> { class DAWN_NO_DISCARD Result<void, E*> {
public: public:
Result(); Result();
Result(E* error); 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 // 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. // tagged pointer. The tag for Success is 0 so that returning the value is fastest.
template <typename T, typename E> template <typename T, typename E>
class NXT_NO_DISCARD Result<T*, E*> { class DAWN_NO_DISCARD Result<T*, E*> {
public: public:
static_assert(alignof_if_defined_else_default<T, 4> >= 4, static_assert(alignof_if_defined_else_default<T, 4> >= 4,
"Result<T*, E*> reserves two bits for tagging pointers"); "Result<T*, E*> reserves two bits for tagging pointers");

View File

@ -117,7 +117,7 @@ class SerialQueue {
template <typename T> template <typename T>
void SerialQueue<T>::Enqueue(const T& value, Serial serial) { 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) { if (Empty() || mStorage.back().first < serial) {
mStorage.emplace_back(SerialPair(serial, {})); mStorage.emplace_back(SerialPair(serial, {}));
@ -127,7 +127,7 @@ void SerialQueue<T>::Enqueue(const T& value, Serial serial) {
template <typename T> template <typename T>
void SerialQueue<T>::Enqueue(T&& value, Serial serial) { 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) { if (Empty() || mStorage.back().first < serial) {
mStorage.emplace_back(SerialPair(serial, {})); mStorage.emplace_back(SerialPair(serial, {}));
@ -137,15 +137,15 @@ void SerialQueue<T>::Enqueue(T&& value, Serial serial) {
template <typename T> template <typename T>
void SerialQueue<T>::Enqueue(const std::vector<T>& values, Serial serial) { void SerialQueue<T>::Enqueue(const std::vector<T>& values, Serial serial) {
NXT_ASSERT(values.size() > 0); DAWN_ASSERT(values.size() > 0);
NXT_ASSERT(Empty() || mStorage.back().first <= serial); DAWN_ASSERT(Empty() || mStorage.back().first <= serial);
mStorage.emplace_back(SerialPair(serial, {values})); mStorage.emplace_back(SerialPair(serial, {values}));
} }
template <typename T> template <typename T>
void SerialQueue<T>::Enqueue(std::vector<T>&& values, Serial serial) { void SerialQueue<T>::Enqueue(std::vector<T>&& values, Serial serial) {
NXT_ASSERT(values.size() > 0); DAWN_ASSERT(values.size() > 0);
NXT_ASSERT(Empty() || mStorage.back().first <= serial); DAWN_ASSERT(Empty() || mStorage.back().first <= serial);
mStorage.emplace_back(SerialPair(serial, {values})); mStorage.emplace_back(SerialPair(serial, {values}));
} }
@ -186,7 +186,7 @@ void SerialQueue<T>::ClearUpTo(Serial serial) {
template <typename T> template <typename T>
Serial SerialQueue<T>::FirstSerial() const { Serial SerialQueue<T>::FirstSerial() const {
NXT_ASSERT(!Empty()); DAWN_ASSERT(!Empty());
return mStorage.front().first; return mStorage.front().first;
} }

View File

@ -89,7 +89,7 @@ class VkNonDispatchableHandle {
// Remove windows.h macros after vulkan_platform's include of windows.h // Remove windows.h macros after vulkan_platform's include of windows.h
#include "common/Platform.h" #include "common/Platform.h"
#if defined(NXT_PLATFORM_WINDOWS) #if defined(DAWN_PLATFORM_WINDOWS)
# include "common/windows_with_undefs.h" # include "common/windows_with_undefs.h"
#endif #endif

View File

@ -17,7 +17,7 @@
#include "common/Compiler.h" #include "common/Compiler.h"
#if !defined(NXT_PLATFORM_WINDOWS) #if !defined(DAWN_PLATFORM_WINDOWS)
# error "windows_with_undefs.h included on non-Windows" # error "windows_with_undefs.h included on non-Windows"
#endif #endif

View File

@ -129,10 +129,10 @@ bool gTestUsesWire = false;
void NXTTest::SetUp() { void NXTTest::SetUp() {
mBinding = utils::CreateBinding(ParamToBackendType(GetParam())); mBinding = utils::CreateBinding(ParamToBackendType(GetParam()));
NXT_ASSERT(mBinding != nullptr); DAWN_ASSERT(mBinding != nullptr);
GLFWwindow* testWindow = GetWindowForBackend(mBinding, GetParam()); GLFWwindow* testWindow = GetWindowForBackend(mBinding, GetParam());
NXT_ASSERT(testWindow != nullptr); DAWN_ASSERT(testWindow != nullptr);
mBinding->SetWindow(testWindow); mBinding->SetWindow(testWindow);
@ -323,7 +323,7 @@ void NXTTest::MapSlotsSynchronously() {
void NXTTest::SlotMapReadCallback(nxtBufferMapAsyncStatus status, void NXTTest::SlotMapReadCallback(nxtBufferMapAsyncStatus status,
const void* data, const void* data,
nxtCallbackUserdata userdata_) { 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_)); auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
userdata->test->mReadbackSlots[userdata->slot].mappedData = data; userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
@ -334,7 +334,7 @@ void NXTTest::SlotMapReadCallback(nxtBufferMapAsyncStatus status,
void NXTTest::ResolveExpectations() { void NXTTest::ResolveExpectations() {
for (const auto& expectation : mDeferredExpectations) { 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. // Get a pointer to the mapped copy of the data for the expectation.
const char* data = reinterpret_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData); const char* data = reinterpret_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData);
@ -343,7 +343,7 @@ void NXTTest::ResolveExpectations() {
uint32_t size; uint32_t size;
std::vector<char> packedData; std::vector<char> packedData;
if (expectation.rowBytes != expectation.rowPitch) { 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 rowCount = (expectation.size + expectation.rowPitch - 1) / expectation.rowPitch;
uint32_t packedSize = rowCount * expectation.rowBytes; uint32_t packedSize = rowCount * expectation.rowBytes;
packedData.resize(packedSize); packedData.resize(packedSize);
@ -436,7 +436,7 @@ namespace detail {
template<typename T> template<typename T>
testing::AssertionResult ExpectEq<T>::Check(const void* data, size_t size) { 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); const T* actual = reinterpret_cast<const T*>(data);

View File

@ -54,7 +54,7 @@ class InputStateTest : public NXTTest {
case VertexFormat::FloatR32: case VertexFormat::FloatR32:
return component >= 1; return component >= 1;
default: default:
NXT_UNREACHABLE(); DAWN_UNREACHABLE();
} }
} }

View File

@ -51,7 +51,7 @@ TEST_F(BitSetIteratorTest, EmptySet) {
// causing an unreachable code warning in MSVS // causing an unreachable code warning in MSVS
bool sawBit = false; bool sawBit = false;
for (unsigned long bit : IterateBitSet(mStateBits)) { for (unsigned long bit : IterateBitSet(mStateBits)) {
NXT_UNUSED(bit); DAWN_UNUSED(bit);
sawBit = true; sawBit = true;
} }
EXPECT_FALSE(sawBit); EXPECT_FALSE(sawBit);

View File

@ -178,7 +178,7 @@ TEST(ErrorTests, TRY_RESULT_Error) {
auto Try = [ReturnError]() -> ResultOrError<int*> { auto Try = [ReturnError]() -> ResultOrError<int*> {
int* result = nullptr; int* result = nullptr;
DAWN_TRY_ASSIGN(result, ReturnError()); DAWN_TRY_ASSIGN(result, ReturnError());
NXT_UNUSED(result); DAWN_UNUSED(result);
// DAWN_TRY should return before this point // DAWN_TRY should return before this point
EXPECT_FALSE(true); EXPECT_FALSE(true);
@ -233,7 +233,7 @@ TEST(ErrorTests, TRY_RESULT_ConversionToError) {
auto Try = [ReturnError]() -> MaybeError { auto Try = [ReturnError]() -> MaybeError {
int* result = nullptr; int* result = nullptr;
DAWN_TRY_ASSIGN(result, ReturnError()); DAWN_TRY_ASSIGN(result, ReturnError());
NXT_UNUSED(result); DAWN_UNUSED(result);
return {}; return {};
}; };

View File

@ -27,7 +27,7 @@ TEST(SerialQueue, BasicTest) {
// Iterating on empty queue 1) works 2) doesn't produce any values // Iterating on empty queue 1) works 2) doesn't produce any values
for (int value : queue.IterateAll()) { for (int value : queue.IterateAll()) {
NXT_UNUSED(value); DAWN_UNUSED(value);
ASSERT_TRUE(false); ASSERT_TRUE(false);
} }
@ -50,7 +50,7 @@ TEST(SerialQueue, BasicTest) {
ASSERT_TRUE(queue.Empty()); ASSERT_TRUE(queue.Empty());
for (int value : queue.IterateAll()) { for (int value : queue.IterateAll()) {
NXT_UNUSED(value); DAWN_UNUSED(value);
ASSERT_TRUE(false); ASSERT_TRUE(false);
} }
} }

View File

@ -99,7 +99,7 @@ namespace utils {
class OpenGLBinding : public BackendBinding { class OpenGLBinding : public BackendBinding {
public: public:
void SetupGLFWWindowHints() override { void SetupGLFWWindowHints() override {
#if defined(NXT_PLATFORM_APPLE) #if defined(DAWN_PLATFORM_APPLE)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);

View File

@ -14,9 +14,9 @@
#include "common/Platform.h" #include "common/Platform.h"
#if defined(NXT_PLATFORM_WINDOWS) #if defined(DAWN_PLATFORM_WINDOWS)
# include <Windows.h> # include <Windows.h>
#elif defined(NXT_PLATFORM_POSIX) #elif defined(DAWN_PLATFORM_POSIX)
# include <unistd.h> # include <unistd.h>
#else #else
# error "Unsupported platform." # error "Unsupported platform."
@ -24,11 +24,11 @@
namespace utils { namespace utils {
#if defined(NXT_PLATFORM_WINDOWS) #if defined(DAWN_PLATFORM_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(NXT_PLATFORM_POSIX) #elif defined(DAWN_PLATFORM_POSIX)
void USleep(unsigned int usecs) { void USleep(unsigned int usecs) {
usleep(usecs); usleep(usecs);
} }