From 83a9c9d6d904cccc88371a96fe94c39028ecd3c7 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 18 Jul 2018 13:37:54 +0200 Subject: [PATCH] Rename src/common macros NXT_* to DAWN_* --- generator/templates/wire/WireCmd.cpp | 14 +++--- src/backend/Device.h | 2 +- src/backend/Error.h | 4 +- src/backend/PerStage.h | 8 +-- src/backend/d3d12/ShaderModuleD3D12.cpp | 2 +- src/backend/d3d12/d3d12_platform.h | 2 +- src/backend/opengl/DeviceGL.h | 2 +- src/backend/opengl/ShaderModuleGL.cpp | 2 +- src/backend/vulkan/DeviceVk.cpp | 4 +- src/common/Assert.cpp | 2 +- src/common/Assert.h | 50 +++++++++---------- src/common/BitSetIterator.h | 2 +- src/common/Compiler.h | 54 ++++++++++----------- src/common/DynamicLib.cpp | 16 +++--- src/common/HashUtils.h | 4 +- src/common/Math.cpp | 6 +-- src/common/Platform.h | 14 +++--- src/common/Result.h | 4 +- src/common/SerialQueue.h | 14 +++--- src/common/vulkan_platform.h | 2 +- src/common/windows_with_undefs.h | 2 +- src/tests/NXTTest.cpp | 12 ++--- src/tests/end2end/InputStateTests.cpp | 2 +- src/tests/unittests/BitSetIteratorTests.cpp | 2 +- src/tests/unittests/ErrorTests.cpp | 4 +- src/tests/unittests/SerialQueueTests.cpp | 4 +- src/utils/OpenGLBinding.cpp | 2 +- src/utils/SystemUtils.cpp | 8 +-- 28 files changed, 122 insertions(+), 122 deletions(-) diff --git a/generator/templates/wire/WireCmd.cpp b/generator/templates/wire/WireCmd.cpp index 7f3e4b9de5..48b9f08279 100644 --- a/generator/templates/wire/WireCmd.cpp +++ b/generator/templates/wire/WireCmd.cpp @@ -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 %} diff --git a/src/backend/Device.h b/src/backend/Device.h index 363703b2f4..45bac74a8d 100644 --- a/src/backend/Device.h +++ b/src/backend/Device.h @@ -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; } diff --git a/src/backend/Error.h b/src/backend/Error.h index 11ba3b3cc5..5d02869419 100644 --- a/src/backend/Error.h +++ b/src/backend/Error.h @@ -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}; \ diff --git a/src/backend/PerStage.h b/src/backend/PerStage.h index d615ebee27..350405e144 100644 --- a/src/backend/PerStage.h +++ b/src/backend/PerStage.h @@ -49,22 +49,22 @@ namespace backend { class PerStage { public: T& operator[](dawn::ShaderStage stage) { - NXT_ASSERT(static_cast(stage) < kNumStages); + DAWN_ASSERT(static_cast(stage) < kNumStages); return mData[static_cast(stage)]; } const T& operator[](dawn::ShaderStage stage) const { - NXT_ASSERT(static_cast(stage) < kNumStages); + DAWN_ASSERT(static_cast(stage) < kNumStages); return mData[static_cast(stage)]; } T& operator[](dawn::ShaderStageBit stageBit) { uint32_t bit = static_cast(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(stageBit); - NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages)); + DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages)); return mData[Log2(bit)]; } diff --git a/src/backend/d3d12/ShaderModuleD3D12.cpp b/src/backend/d3d12/ShaderModuleD3D12.cpp index fd505c881a..0511b76385 100644 --- a/src/backend/d3d12/ShaderModuleD3D12.cpp +++ b/src/backend/d3d12/ShaderModuleD3D12.cpp @@ -35,7 +35,7 @@ namespace backend { namespace d3d12 { case dawn::BindingType::StorageBuffer: return mMap[3]; default: - NXT_UNREACHABLE(); + DAWN_UNREACHABLE(); } } diff --git a/src/backend/d3d12/d3d12_platform.h b/src/backend/d3d12/d3d12_platform.h index 68a226786f..bfe66b4838 100644 --- a/src/backend/d3d12/d3d12_platform.h +++ b/src/backend/d3d12/d3d12_platform.h @@ -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 diff --git a/src/backend/opengl/DeviceGL.h b/src/backend/opengl/DeviceGL.h index 65cf19f23b..58c53297e3 100644 --- a/src/backend/opengl/DeviceGL.h +++ b/src/backend/opengl/DeviceGL.h @@ -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 diff --git a/src/backend/opengl/ShaderModuleGL.cpp b/src/backend/opengl/ShaderModuleGL.cpp index 8eef5acfa7..5adb95431f 100644 --- a/src/backend/opengl/ShaderModuleGL.cpp +++ b/src/backend/opengl/ShaderModuleGL.cpp @@ -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; diff --git a/src/backend/vulkan/DeviceVk.cpp b/src/backend/vulkan/DeviceVk.cpp index 10a459db42..1dbe3c32ec 100644 --- a/src/backend/vulkan/DeviceVk.cpp +++ b/src/backend/vulkan/DeviceVk.cpp @@ -42,9 +42,9 @@ #include -#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" diff --git a/src/common/Assert.cpp b/src/common/Assert.cpp index c8afedafa3..fc88fd2a8e 100644 --- a/src/common/Assert.cpp +++ b/src/common/Assert.cpp @@ -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(); } diff --git a/src/common/Assert.h b/src/common/Assert.h index a0f3ab7f93..1957e99441 100644 --- a/src/common/Assert.h +++ b/src/common/Assert.h @@ -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, diff --git a/src/common/BitSetIterator.h b/src/common/BitSetIterator.h index d73cb24fe9..432433a940 100644 --- a/src/common/BitSetIterator.h +++ b/src/common/BitSetIterator.h @@ -94,7 +94,7 @@ BitSetIterator::Iterator::Iterator(const std::bitset& bits) template typename BitSetIterator::Iterator& BitSetIterator::Iterator::operator++() { - NXT_ASSERT(mBits.any()); + DAWN_ASSERT(mBits.any()); mBits.set(mCurrentBit - mOffset, 0); mCurrentBit = getNextBit(); return *this; diff --git a/src/common/Compiler.h b/src/common/Compiler.h index 16bab3f4cb..15b6ce58a2 100644 --- a/src/common/Compiler.h +++ b/src/common/Compiler.h @@ -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_ diff --git a/src/common/DynamicLib.cpp b/src/common/DynamicLib.cpp index 6e30e4c983..6de7ced7f3 100644 --- a/src/common/DynamicLib.cpp +++ b/src/common/DynamicLib.cpp @@ -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 #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(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(GetProcAddress(static_cast(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(dlsym(mHandle, procName.c_str())); if (proc == nullptr && error != nullptr) { diff --git a/src/common/HashUtils.h b/src/common/HashUtils.h index 987135c1c3..4b0306cbba 100644 --- a/src/common/HashUtils.h +++ b/src/common/HashUtils.h @@ -36,9 +36,9 @@ size_t Hash(const T& value) { // return hash; template 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" diff --git a/src/common/Math.cpp b/src/common/Math.cpp index 41caa766ab..6aec721a1d 100644 --- a/src/common/Math.cpp +++ b/src/common/Math.cpp @@ -16,13 +16,13 @@ #include "common/Assert.h" -#if defined(NXT_COMPILER_MSVC) +#if defined(DAWN_COMPILER_MSVC) # include #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); diff --git a/src/common/Platform.h b/src/common/Platform.h index d7a9229f98..3b84fa76ad 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -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" diff --git a/src/common/Result.h b/src/common/Result.h index ad45d32e08..1aeac54162 100644 --- a/src/common/Result.h +++ b/src/common/Result.h @@ -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 -class NXT_NO_DISCARD Result { +class DAWN_NO_DISCARD Result { public: Result(); Result(E* error); @@ -85,7 +85,7 @@ constexpr size_t alignof_if_defined_else_default -class NXT_NO_DISCARD Result { +class DAWN_NO_DISCARD Result { public: static_assert(alignof_if_defined_else_default >= 4, "Result reserves two bits for tagging pointers"); diff --git a/src/common/SerialQueue.h b/src/common/SerialQueue.h index 5c33d760d5..3fcead82c3 100644 --- a/src/common/SerialQueue.h +++ b/src/common/SerialQueue.h @@ -117,7 +117,7 @@ class SerialQueue { template void SerialQueue::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::Enqueue(const T& value, Serial serial) { template void SerialQueue::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::Enqueue(T&& value, Serial serial) { template void SerialQueue::Enqueue(const std::vector& 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 void SerialQueue::Enqueue(std::vector&& 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::ClearUpTo(Serial serial) { template Serial SerialQueue::FirstSerial() const { - NXT_ASSERT(!Empty()); + DAWN_ASSERT(!Empty()); return mStorage.front().first; } diff --git a/src/common/vulkan_platform.h b/src/common/vulkan_platform.h index d34cf395ab..6381e4f7fa 100644 --- a/src/common/vulkan_platform.h +++ b/src/common/vulkan_platform.h @@ -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 diff --git a/src/common/windows_with_undefs.h b/src/common/windows_with_undefs.h index 6226314067..c4815464a6 100644 --- a/src/common/windows_with_undefs.h +++ b/src/common/windows_with_undefs.h @@ -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 diff --git a/src/tests/NXTTest.cpp b/src/tests/NXTTest.cpp index df482cfcd2..11bd443017 100644 --- a/src/tests/NXTTest.cpp +++ b/src/tests/NXTTest.cpp @@ -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(static_cast(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(mReadbackSlots[expectation.readbackSlot].mappedData); @@ -343,7 +343,7 @@ void NXTTest::ResolveExpectations() { uint32_t size; std::vector 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 testing::AssertionResult ExpectEq::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(data); diff --git a/src/tests/end2end/InputStateTests.cpp b/src/tests/end2end/InputStateTests.cpp index b8d7621d53..a14ac14218 100644 --- a/src/tests/end2end/InputStateTests.cpp +++ b/src/tests/end2end/InputStateTests.cpp @@ -54,7 +54,7 @@ class InputStateTest : public NXTTest { case VertexFormat::FloatR32: return component >= 1; default: - NXT_UNREACHABLE(); + DAWN_UNREACHABLE(); } } diff --git a/src/tests/unittests/BitSetIteratorTests.cpp b/src/tests/unittests/BitSetIteratorTests.cpp index 4bffd61e70..cc6c3edf05 100644 --- a/src/tests/unittests/BitSetIteratorTests.cpp +++ b/src/tests/unittests/BitSetIteratorTests.cpp @@ -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); diff --git a/src/tests/unittests/ErrorTests.cpp b/src/tests/unittests/ErrorTests.cpp index a11c5b08f5..925ca57e15 100644 --- a/src/tests/unittests/ErrorTests.cpp +++ b/src/tests/unittests/ErrorTests.cpp @@ -178,7 +178,7 @@ TEST(ErrorTests, TRY_RESULT_Error) { auto Try = [ReturnError]() -> ResultOrError { 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 {}; }; diff --git a/src/tests/unittests/SerialQueueTests.cpp b/src/tests/unittests/SerialQueueTests.cpp index accdedd375..2c45c2f65a 100644 --- a/src/tests/unittests/SerialQueueTests.cpp +++ b/src/tests/unittests/SerialQueueTests.cpp @@ -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); } } diff --git a/src/utils/OpenGLBinding.cpp b/src/utils/OpenGLBinding.cpp index fcfe673bf5..8e7e64a17b 100644 --- a/src/utils/OpenGLBinding.cpp +++ b/src/utils/OpenGLBinding.cpp @@ -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); diff --git a/src/utils/SystemUtils.cpp b/src/utils/SystemUtils.cpp index aa54d24728..b72a2ca058 100644 --- a/src/utils/SystemUtils.cpp +++ b/src/utils/SystemUtils.cpp @@ -14,9 +14,9 @@ #include "common/Platform.h" -#if defined(NXT_PLATFORM_WINDOWS) +#if defined(DAWN_PLATFORM_WINDOWS) # include -#elif defined(NXT_PLATFORM_POSIX) +#elif defined(DAWN_PLATFORM_POSIX) # include #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(usecs / 1000)); } -#elif defined(NXT_PLATFORM_POSIX) +#elif defined(DAWN_PLATFORM_POSIX) void USleep(unsigned int usecs) { usleep(usecs); }