Namespace dawn/common/ and dawn/utils/ in dawn::
Only Constants.h remains in no namespace; but it may be addressed in the future as well. Bug: dawn:302 Change-Id: Ib9b9ab4b974ad1de1bb9f2302f4d24d8216f55e4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132841 Kokoro: Austin Eng <enga@chromium.org> Auto-Submit: Austin Eng <enga@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
0bb1bb3067
commit
2731b76ded
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace gpu_info {
|
||||
namespace dawn::gpu_info {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -151,4 +151,4 @@ std::string GetArchitectureName(PCIVendorID vendorId, PCIDeviceID deviceId) {
|
|||
return "";
|
||||
}
|
||||
|
||||
} // namespace gpu_info
|
||||
} // namespace dawn::gpu_info
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
using PCIVendorID = uint32_t;
|
||||
using PCIDeviceID = uint32_t;
|
||||
|
||||
namespace gpu_info {
|
||||
namespace dawn::gpu_info {
|
||||
|
||||
// Vendor IDs
|
||||
{% for vendor in vendors %}
|
||||
|
@ -51,5 +51,5 @@ namespace gpu_info {
|
|||
std::string GetVendorName(PCIVendorID vendorId);
|
||||
std::string GetArchitectureName(PCIVendorID vendorId, PCIDeviceID deviceId);
|
||||
|
||||
} // namespace gpu_info
|
||||
} // namespace dawn::gpu_info
|
||||
#endif // SRC_DAWN_COMMON_GPUINFO_AUTOGEN_H_
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <cstddef>
|
||||
#include <new>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename T>
|
||||
T* AllocNoThrow(size_t count) {
|
||||
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER)
|
||||
|
@ -30,4 +32,6 @@ T* AllocNoThrow(size_t count) {
|
|||
return new (std::nothrow) T[count];
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ALLOC_H_
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
#include "dawn/common/Log.h"
|
||||
#include "dawn/common/Platform.h"
|
||||
|
||||
#if DAWN_COMPILER_IS(MSVC)
|
||||
extern void __cdecl __debugbreak(void);
|
||||
#endif
|
||||
|
||||
namespace dawn {
|
||||
|
||||
#if DAWN_COMPILER_IS(CLANG) || DAWN_COMPILER_IS(GCC)
|
||||
void BreakPoint() {
|
||||
#if DAWN_PLATFORM_IS(X86)
|
||||
|
@ -43,7 +49,6 @@ void BreakPoint() {
|
|||
}
|
||||
|
||||
#elif DAWN_COMPILER_IS(MSVC)
|
||||
extern void __cdecl __debugbreak(void);
|
||||
void BreakPoint() {
|
||||
__debugbreak();
|
||||
}
|
||||
|
@ -64,3 +69,5 @@ void HandleAssertionFailure(const char* file,
|
|||
BreakPoint();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -41,11 +41,11 @@
|
|||
// expect of an assert and in release it tries to give hints to make the compiler generate better
|
||||
// code.
|
||||
#if defined(DAWN_ENABLE_ASSERTS)
|
||||
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
HandleAssertionFailure(file, func, line, #condition); \
|
||||
} \
|
||||
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
dawn::HandleAssertionFailure(file, func, line, #condition); \
|
||||
} \
|
||||
} while (DAWN_ASSERT_LOOP_CONDITION)
|
||||
#else
|
||||
#if DAWN_COMPILER_IS(MSVC)
|
||||
|
@ -72,9 +72,13 @@
|
|||
#define UNREACHABLE DAWN_UNREACHABLE
|
||||
#endif
|
||||
|
||||
namespace dawn {
|
||||
|
||||
void HandleAssertionFailure(const char* file,
|
||||
const char* function,
|
||||
int line,
|
||||
const char* condition);
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ASSERT_H_
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "dawn/common/Math.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// This is ANGLE's BitSetIterator class with a customizable return type.
|
||||
// Types have been updated to be more specific.
|
||||
// TODO(crbug.com/dawn/306): it could be optimized, in particular when N <= 64
|
||||
|
@ -131,4 +133,6 @@ BitSetIterator<N, uint32_t> IterateBitSet(const std::bitset<N>& bitset) {
|
|||
return BitSetIterator<N, uint32_t>(bitset);
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_BITSETITERATOR_H_
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "dawn/common/NonCopyable.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename T>
|
||||
class ConcurrentCache : public NonMovable {
|
||||
public:
|
||||
|
@ -51,4 +53,6 @@ class ConcurrentCache : public NonMovable {
|
|||
std::unordered_set<T*, typename T::HashFunc, typename T::EqualityFunc> mCache;
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_CONCURRENTCACHE_H_
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include "dawn/common/RefBase.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename T>
|
||||
struct CoreFoundationRefTraits {
|
||||
static constexpr T kNullValue = nullptr;
|
||||
|
@ -39,4 +41,6 @@ CFRef<T> AcquireCFRef(T pointee) {
|
|||
return ref;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_COREFOUNDATIONREF_H_
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "dawn/common/Platform.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||
#include "dawn/common/windows_with_undefs.h"
|
||||
#if DAWN_PLATFORM_IS(WINUWP)
|
||||
|
@ -106,3 +108,5 @@ void* DynamicLib::GetProc(const std::string& procName, std::string* error) const
|
|||
|
||||
return proc;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
class DynamicLib {
|
||||
public:
|
||||
DynamicLib() = default;
|
||||
|
@ -51,4 +53,6 @@ class DynamicLib {
|
|||
void* mHandle = nullptr;
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_DYNAMICLIB_H_
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace gpu_info {
|
||||
namespace dawn::gpu_info {
|
||||
namespace {
|
||||
// Intel
|
||||
// Referenced from the following Mesa source code:
|
||||
|
@ -105,4 +105,4 @@ bool IsSkylake(PCIDeviceID deviceId) {
|
|||
return std::find(Skylake.cbegin(), Skylake.cend(), deviceId) != Skylake.cend();
|
||||
}
|
||||
|
||||
} // namespace gpu_info
|
||||
} // namespace dawn::gpu_info
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "dawn/common/GPUInfo_autogen.h"
|
||||
#include "dawn/common/StackContainer.h"
|
||||
|
||||
namespace gpu_info {
|
||||
namespace dawn::gpu_info {
|
||||
|
||||
// Four uint16 fields could cover almost all driver version schemas:
|
||||
// D3D12: AA.BB.CCC.DDDD
|
||||
|
@ -61,5 +61,5 @@ int CompareIntelMesaDriverVersion(const DriverVersion& version1, const DriverVer
|
|||
// Intel architectures
|
||||
bool IsSkylake(PCIDeviceID deviceId);
|
||||
|
||||
} // namespace gpu_info
|
||||
} // namespace dawn::gpu_info
|
||||
#endif // SRC_DAWN_COMMON_GPUINFO_H_
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "dawn/common/TypedInteger.h"
|
||||
#include "dawn/common/ityp_bitset.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// Wrapper around std::hash to make it a templated function instead of a functor. It is marginally
|
||||
// nicer, and avoids adding to the std namespace to add hashing of other types.
|
||||
template <typename T>
|
||||
|
@ -88,12 +90,14 @@ size_t Hash(const std::bitset<N>& value) {
|
|||
}
|
||||
#endif
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
namespace std {
|
||||
template <typename Index, size_t N>
|
||||
struct hash<ityp::bitset<Index, N>> {
|
||||
struct hash<dawn::ityp::bitset<Index, N>> {
|
||||
public:
|
||||
size_t operator()(const ityp::bitset<Index, N>& value) const {
|
||||
return Hash(static_cast<const std::bitset<N>&>(value));
|
||||
size_t operator()(const dawn::ityp::bitset<Index, N>& value) const {
|
||||
return dawn::Hash(static_cast<const std::bitset<N>&>(value));
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include "dawn/common/RefBase.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename T>
|
||||
struct IOKitRefTraits {
|
||||
static constexpr T kNullValue = IO_OBJECT_NULL;
|
||||
|
@ -39,4 +41,6 @@ IORef<T> AcquireIORef(T pointee) {
|
|||
return ref;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_IOKITREF_H_
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// Simple LinkedList type. (See the Q&A section to understand how this
|
||||
// differs from std::list).
|
||||
//
|
||||
|
@ -247,4 +249,6 @@ LinkedListIterator<T> end(LinkedList<T>& l) {
|
|||
return LinkedListIterator<T>(l.tail()->next());
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_LINKEDLIST_H_
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
namespace dawn {
|
||||
|
||||
uint32_t ScanForward(uint32_t bits) {
|
||||
ASSERT(bits != 0);
|
||||
#if DAWN_COMPILER_IS(MSVC)
|
||||
|
@ -162,3 +164,5 @@ uint64_t RoundUp(uint64_t n, uint64_t m) {
|
|||
ASSERT(m <= std::numeric_limits<uint64_t>::max() - n);
|
||||
return ((n + m - 1) / m) * m;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// The following are not valid for 0
|
||||
uint32_t ScanForward(uint32_t bits);
|
||||
uint32_t Log2(uint32_t value);
|
||||
|
@ -125,4 +127,6 @@ constexpr bool IsSubset(T1 subset, T2 set) {
|
|||
return bitsAlsoInSet == subset;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_MATH_H_
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#error "NSRef can only be used in Objective C/C++ code."
|
||||
#endif
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// This file contains smart pointers that automatically reference and release Objective C objects
|
||||
// and prototocals in a manner very similar to Ref<>. Note that NSRef<> and NSPRef's constructor add
|
||||
// a reference to the object by default, so the pattern to get a reference for a newly created
|
||||
|
@ -108,4 +110,6 @@ NSPRef<T> AcquireNSPRef(T pointee) {
|
|||
return ref;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_NSREF_H_
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#ifndef SRC_DAWN_COMMON_NONCOPYABLE_H_
|
||||
#define SRC_DAWN_COMMON_NONCOPYABLE_H_
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// A base class to make a class non-copyable.
|
||||
class NonCopyable {
|
||||
protected:
|
||||
|
@ -40,4 +42,6 @@ class NonMovable : NonCopyable {
|
|||
void operator=(NonMovable&&) = delete;
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_NONCOPYABLE_H_
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace dawn {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
|
@ -81,4 +82,6 @@ bool RangesOverlap(T x0, T x1, T y0, T y1) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_NUMERIC_H_
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include <cstddef>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
class PlacementAllocated {
|
||||
public:
|
||||
// Delete the default new operator so this can only be created with placement new.
|
||||
|
@ -39,4 +41,6 @@ class PlacementAllocated {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_PLACEMENTALLOCATED_H_
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "dawn/common/Assert.h"
|
||||
#include "dawn/common/Compiler.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// A common class for various smart-pointers acting on referenceable/releasable pointer-like
|
||||
// objects. Logic for each specialization can be customized using a Traits type that looks
|
||||
// like the following:
|
||||
|
@ -162,4 +164,6 @@ class RefBase {
|
|||
T mValue;
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_REFBASE_H_
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
static constexpr size_t kPayloadBits = 1;
|
||||
static constexpr uint64_t kPayloadMask = (uint64_t(1) << kPayloadBits) - 1;
|
||||
static constexpr uint64_t kRefCountIncrement = (uint64_t(1) << kPayloadBits);
|
||||
|
@ -121,3 +123,5 @@ void RefCounted::DeleteThis() {
|
|||
void RefCounted::LockAndDeleteThis() {
|
||||
DeleteThis();
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "dawn/common/RefBase.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
class RefCount {
|
||||
public:
|
||||
// Create a refcount with a payload. The refcount starts initially at one.
|
||||
|
@ -88,4 +90,6 @@ Ref<T> AcquireRef(T* pointee) {
|
|||
return ref;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_REFCOUNTED_H_
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "dawn/common/Result.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// Implementation details of the tagged pointer Results
|
||||
namespace detail {
|
||||
|
||||
|
@ -28,3 +30,4 @@ PayloadType GetPayloadType(intptr_t payload) {
|
|||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace dawn
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "dawn/common/Assert.h"
|
||||
#include "dawn/common/Compiler.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// Result<T, E> is the following sum type (Haskell notation):
|
||||
//
|
||||
// data Result T E = Success T | Error E | Empty
|
||||
|
@ -511,4 +513,6 @@ std::unique_ptr<E> Result<T, E>::AcquireError() {
|
|||
return std::move(mError);
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_RESULT_H_
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "dawn/common/SerialStorage.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename Serial, typename Value>
|
||||
class SerialMap;
|
||||
|
||||
|
@ -74,4 +76,6 @@ void SerialMap<Serial, Value>::Enqueue(std::vector<Value>&& values, Serial seria
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_SERIALMAP_H_
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "dawn/common/SerialStorage.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename Serial, typename Value>
|
||||
class SerialQueue;
|
||||
|
||||
|
@ -83,4 +85,6 @@ void SerialQueue<Serial, Value>::Enqueue(std::vector<Value>&& values, Serial ser
|
|||
this->mStorage.emplace_back(serial, std::move(values));
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_SERIALQUEUE_H_
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "dawn/common/Assert.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename T>
|
||||
struct SerialStorageTraits {};
|
||||
|
||||
|
@ -315,4 +317,6 @@ const typename SerialStorage<Derived>::Value& SerialStorage<Derived>::ConstItera
|
|||
return *mSerialIterator;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_SERIALSTORAGE_H_
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "dawn/common/Assert.h"
|
||||
#include "dawn/common/Math.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// IndexLinkNode
|
||||
|
||||
SlabAllocatorImpl::IndexLinkNode::IndexLinkNode(Index index, Index nextIndex)
|
||||
|
@ -241,3 +243,5 @@ void SlabAllocatorImpl::GetNewSlab() {
|
|||
|
||||
mAvailableSlabs.Prepend(new (alignedPtr) Slab(allocation, node));
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "dawn/common/Numeric.h"
|
||||
#include "dawn/common/PlacementAllocated.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// The SlabAllocator allocates objects out of one or more fixed-size contiguous "slabs" of memory.
|
||||
// This makes it very quick to allocate and deallocate fixed-size objects because the allocator only
|
||||
// needs to index an offset into pre-allocated memory. It is similar to a pool-allocator that
|
||||
|
@ -179,4 +181,6 @@ class SlabAllocator : public SlabAllocatorImpl {
|
|||
void Deallocate(T* object) { SlabAllocatorImpl::Deallocate(object); }
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_SLABALLOCATOR_H_
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "dawn/common/Compiler.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// This allocator can be used with STL containers to provide a stack buffer
|
||||
// from which to allocate memory and overflows onto the heap. This stack buffer
|
||||
// would be allocated on the stack and allows us to avoid heap operations in
|
||||
|
@ -235,4 +237,6 @@ class StackVector
|
|||
StackVector& operator=(StackVector&& rhs) = delete;
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_STACKCONTAINER_H_
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||
const char* GetPathSeparator() {
|
||||
return "\\";
|
||||
|
@ -228,3 +230,5 @@ bool ScopedEnvironmentVar::Set(const char* variableName, const char* value) {
|
|||
mIsSet = SetEnvironmentVar(variableName, value);
|
||||
return mIsSet;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "dawn/common/Platform.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
const char* GetPathSeparator();
|
||||
// Returns a pair of the environment variable's value, and a boolean indicating whether the variable
|
||||
// was present.
|
||||
|
@ -55,4 +57,6 @@ class ScopedEnvironmentVar {
|
|||
bool mIsSet = false;
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_SYSTEMUTILS_H_
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
void GetMacOSVersion(int32_t* majorVersion, int32_t* minorVersion) {
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
ASSERT(majorVersion != nullptr);
|
||||
|
@ -31,3 +33,5 @@ bool IsMacOSVersionAtLeast(uint32_t majorVersion, uint32_t minorVersion) {
|
|||
return
|
||||
[NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:{majorVersion, minorVersion, 0}];
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include <type_traits>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
template <typename LHS, typename RHS = LHS, typename T = void>
|
||||
struct HasEqualityOperator {
|
||||
static constexpr const bool value = false;
|
||||
|
@ -43,4 +45,6 @@ struct IsCString {
|
|||
static constexpr const bool value = Eval();
|
||||
};
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_TYPETRAITS_H_
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "dawn/common/Assert.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// TypedInteger is helper class that provides additional type safety in Debug.
|
||||
// - Integers of different (Tag, BaseIntegerType) may not be used interoperably
|
||||
// - Allows casts only to the underlying type.
|
||||
|
@ -31,8 +33,8 @@
|
|||
// typedef of the underlying type.
|
||||
//
|
||||
// Example:
|
||||
// using UintA = TypedInteger<struct TypeA, uint32_t>;
|
||||
// using UintB = TypedInteger<struct TypeB, uint32_t>;
|
||||
// using UintA = dawn::TypedInteger<struct TypeA, uint32_t>;
|
||||
// using UintB = dawn::TypedInteger<struct TypeB, uint32_t>;
|
||||
//
|
||||
// in Release:
|
||||
// using UintA = uint32_t;
|
||||
|
@ -208,23 +210,24 @@ class alignas(T) TypedIntegerImpl {
|
|||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace dawn
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename Tag, typename T>
|
||||
class numeric_limits<detail::TypedIntegerImpl<Tag, T>> : public numeric_limits<T> {
|
||||
class numeric_limits<dawn::detail::TypedIntegerImpl<Tag, T>> : public numeric_limits<T> {
|
||||
public:
|
||||
static detail::TypedIntegerImpl<Tag, T> max() noexcept {
|
||||
return detail::TypedIntegerImpl<Tag, T>(std::numeric_limits<T>::max());
|
||||
static dawn::detail::TypedIntegerImpl<Tag, T> max() noexcept {
|
||||
return dawn::detail::TypedIntegerImpl<Tag, T>(std::numeric_limits<T>::max());
|
||||
}
|
||||
static detail::TypedIntegerImpl<Tag, T> min() noexcept {
|
||||
return detail::TypedIntegerImpl<Tag, T>(std::numeric_limits<T>::min());
|
||||
static dawn::detail::TypedIntegerImpl<Tag, T> min() noexcept {
|
||||
return dawn::detail::TypedIntegerImpl<Tag, T>(std::numeric_limits<T>::min());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace ityp {
|
||||
namespace dawn::ityp {
|
||||
|
||||
// These helpers below are provided since the default arithmetic operators for small integer
|
||||
// types like uint8_t and uint16_t return integers, not their same type. To avoid lots of
|
||||
|
@ -232,17 +235,19 @@ namespace ityp {
|
|||
// ityp::Sub(a, b) instead.
|
||||
|
||||
template <typename Tag, typename T>
|
||||
constexpr ::detail::TypedIntegerImpl<Tag, T> Add(::detail::TypedIntegerImpl<Tag, T> lhs,
|
||||
::detail::TypedIntegerImpl<Tag, T> rhs) {
|
||||
return ::detail::TypedIntegerImpl<Tag, T>(
|
||||
static_cast<T>(::detail::TypedIntegerImpl<Tag, T>::AddImpl(lhs, rhs)));
|
||||
constexpr ::dawn::detail::TypedIntegerImpl<Tag, T> Add(
|
||||
::dawn::detail::TypedIntegerImpl<Tag, T> lhs,
|
||||
::dawn::detail::TypedIntegerImpl<Tag, T> rhs) {
|
||||
return ::dawn::detail::TypedIntegerImpl<Tag, T>(
|
||||
static_cast<T>(::dawn::detail::TypedIntegerImpl<Tag, T>::AddImpl(lhs, rhs)));
|
||||
}
|
||||
|
||||
template <typename Tag, typename T>
|
||||
constexpr ::detail::TypedIntegerImpl<Tag, T> Sub(::detail::TypedIntegerImpl<Tag, T> lhs,
|
||||
::detail::TypedIntegerImpl<Tag, T> rhs) {
|
||||
return ::detail::TypedIntegerImpl<Tag, T>(
|
||||
static_cast<T>(::detail::TypedIntegerImpl<Tag, T>::SubImpl(lhs, rhs)));
|
||||
constexpr ::dawn::detail::TypedIntegerImpl<Tag, T> Sub(
|
||||
::dawn::detail::TypedIntegerImpl<Tag, T> lhs,
|
||||
::dawn::detail::TypedIntegerImpl<Tag, T> rhs) {
|
||||
return ::dawn::detail::TypedIntegerImpl<Tag, T>(
|
||||
static_cast<T>(::dawn::detail::TypedIntegerImpl<Tag, T>::SubImpl(lhs, rhs)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -255,6 +260,6 @@ constexpr std::enable_if_t<std::is_integral<T>::value, T> Sub(T lhs, T rhs) {
|
|||
return static_cast<T>(lhs - rhs);
|
||||
}
|
||||
|
||||
} // namespace ityp
|
||||
} // namespace dawn::ityp
|
||||
|
||||
#endif // SRC_DAWN_COMMON_TYPEDINTEGER_H_
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include <type_traits>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
// UnderlyingType is similar to std::underlying_type_t. It is a passthrough for already
|
||||
// integer types which simplifies getting the underlying primitive type for an arbitrary
|
||||
// template parameter. It includes a specialization for detail::TypedIntegerImpl which yields
|
||||
|
@ -48,4 +50,6 @@ struct UnderlyingTypeImpl<TypedIntegerImpl<Tag, I>> {
|
|||
template <typename T>
|
||||
using UnderlyingType = typename detail::UnderlyingTypeImpl<T>::type;
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_UNDERLYINGTYPE_H_
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "dawn/common/windows_with_undefs.h"
|
||||
|
||||
namespace dawn {
|
||||
|
||||
std::string WCharToUTF8(const wchar_t* input) {
|
||||
// The -1 argument asks WideCharToMultiByte to use the null terminator to know the size of
|
||||
// input. It will return a size that includes the null terminator.
|
||||
|
@ -41,3 +43,5 @@ std::wstring UTF8ToWStr(const char* input) {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace dawn {
|
||||
|
||||
std::string WCharToUTF8(const wchar_t* input);
|
||||
|
||||
std::wstring UTF8ToWStr(const char* input);
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_WINDOWSUTILS_H_
|
||||
|
|
|
@ -24,16 +24,16 @@
|
|||
#include "dawn/common/TypedInteger.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace ityp {
|
||||
namespace dawn::ityp {
|
||||
|
||||
// ityp::array is a helper class that wraps std::array with the restriction that
|
||||
// indices must be a particular type |Index|. Dawn uses multiple flat maps of
|
||||
// index-->data, and this class helps ensure an indices cannot be passed interchangably
|
||||
// to a flat map of a different type.
|
||||
template <typename Index, typename Value, size_t Size>
|
||||
class array : private std::array<Value, Size> {
|
||||
class array : private ::std::array<Value, Size> {
|
||||
using I = UnderlyingType<Index>;
|
||||
using Base = std::array<Value, Size>;
|
||||
using Base = ::std::array<Value, Size>;
|
||||
|
||||
static_assert(Size <= std::numeric_limits<I>::max());
|
||||
|
||||
|
@ -85,6 +85,6 @@ class array : private std::array<Value, Size> {
|
|||
using Base::front;
|
||||
};
|
||||
|
||||
} // namespace ityp
|
||||
} // namespace dawn::ityp
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ITYP_ARRAY_H_
|
||||
|
|
|
@ -20,14 +20,15 @@
|
|||
#include "dawn/common/TypedInteger.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace dawn {
|
||||
namespace ityp {
|
||||
|
||||
// ityp::bitset is a helper class that wraps std::bitset with the restriction that
|
||||
// indices must be a particular type |Index|.
|
||||
template <typename Index, size_t N>
|
||||
class bitset : private std::bitset<N> {
|
||||
class bitset : private ::std::bitset<N> {
|
||||
using I = UnderlyingType<Index>;
|
||||
using Base = std::bitset<N>;
|
||||
using Base = ::std::bitset<N>;
|
||||
|
||||
static_assert(sizeof(I) <= sizeof(size_t));
|
||||
|
||||
|
@ -168,4 +169,6 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
|
|||
#endif // DAWN_COMPILER_IS(MSVC)
|
||||
}
|
||||
|
||||
} // namespace dawn
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ITYP_BITSET_H_
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "dawn/common/TypedInteger.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace ityp {
|
||||
namespace dawn::ityp {
|
||||
|
||||
// ityp::span is a helper class that wraps an unowned packed array of type |Value|.
|
||||
// It stores the size and pointer to first element. It has the restriction that
|
||||
|
@ -82,6 +82,6 @@ class span {
|
|||
Index mSize;
|
||||
};
|
||||
|
||||
} // namespace ityp
|
||||
} // namespace dawn::ityp
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ITYP_SPAN_H_
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "dawn/common/StackContainer.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace ityp {
|
||||
namespace dawn::ityp {
|
||||
|
||||
template <typename Index, typename Value, size_t StaticCapacity>
|
||||
class stack_vec : private StackVector<Value, StaticCapacity> {
|
||||
|
@ -72,6 +72,6 @@ class stack_vec : private StackVector<Value, StaticCapacity> {
|
|||
Index size() const { return Index(static_cast<I>(this->container().size())); }
|
||||
};
|
||||
|
||||
} // namespace ityp
|
||||
} // namespace dawn::ityp
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ITYP_STACK_VEC_H_
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "dawn/common/TypedInteger.h"
|
||||
#include "dawn/common/UnderlyingType.h"
|
||||
|
||||
namespace ityp {
|
||||
namespace dawn::ityp {
|
||||
|
||||
// ityp::vector is a helper class that wraps std::vector with the restriction that
|
||||
// indices must be a particular type |Index|.
|
||||
|
@ -94,6 +94,6 @@ class vector : public std::vector<Value> {
|
|||
void reserve(Index size) { Base::reserve(static_cast<I>(size)); }
|
||||
};
|
||||
|
||||
} // namespace ityp
|
||||
} // namespace dawn::ityp
|
||||
|
||||
#endif // SRC_DAWN_COMMON_ITYP_VECTOR_H_
|
||||
|
|
|
@ -30,7 +30,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
wgpu::AdapterProperties properties;
|
||||
adapter.GetProperties(&properties);
|
||||
|
||||
return gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID);
|
||||
return dawn::gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID);
|
||||
},
|
||||
true /* supportsErrorInjection */);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,8 @@ int Run(const fuzzing::Program& program, bool (*AdapterSupported)(const dawn::na
|
|||
std::unique_ptr<dawn::wire::WireServer> wireServer(new dawn_wire::WireServer(serverDesc));
|
||||
wireServer->InjectInstance(sInstance->Get(), kInstanceObjectId, 0);
|
||||
|
||||
static utils::TerribleCommandBuffer* mCommandBuffer = new utils::TerribleCommandBuffer();
|
||||
static dawn::utilsTerribleCommandBuffer* mCommandBuffer =
|
||||
new dawn::utilsTerribleCommandBuffer();
|
||||
static dawn::wire::ChunkedCommandSerializer mSerializer =
|
||||
dawn::wire::ChunkedCommandSerializer(mCommandBuffer);
|
||||
mCommandBuffer->SetHandler(wireServer.get());
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
namespace dawn {
|
||||
template <typename T>
|
||||
class Ref;
|
||||
} // namespace dawn
|
||||
|
||||
namespace dawn::native {
|
||||
|
||||
|
|
|
@ -164,8 +164,8 @@ class Stream<T, std::enable_if_t<std::is_enum_v<T>>> {
|
|||
|
||||
// Stream specialization for TypedInteger.
|
||||
template <typename Tag, typename Integer>
|
||||
class Stream<::detail::TypedIntegerImpl<Tag, Integer>> {
|
||||
using T = ::detail::TypedIntegerImpl<Tag, Integer>;
|
||||
class Stream<::dawn::detail::TypedIntegerImpl<Tag, Integer>> {
|
||||
using T = ::dawn::detail::TypedIntegerImpl<Tag, Integer>;
|
||||
|
||||
public:
|
||||
static void Write(Sink* s, const T& t) { StreamIn(s, static_cast<Integer>(t)); }
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
|
||||
#include "dawn/native/Error.h"
|
||||
|
||||
namespace dawn {
|
||||
class DynamicLib;
|
||||
} // namespace dawn
|
||||
|
||||
namespace dawn::native::vulkan {
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "dawn/native/dawn_platform.h"
|
||||
#include "dawn/native/webgpu_absl_format_autogen.h"
|
||||
|
||||
namespace ityp {
|
||||
namespace dawn::ityp {
|
||||
template <typename Index, typename Value>
|
||||
class span;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void init() {
|
|||
queue = device.GetQueue();
|
||||
swapchain = GetSwapChain();
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
wgpu::ShaderModule vsModule = dawn::utils::CreateShaderModule(device, R"(
|
||||
struct Constants {
|
||||
scale : f32,
|
||||
time : f32,
|
||||
|
@ -112,16 +112,16 @@ void init() {
|
|||
return output;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
wgpu::ShaderModule fsModule = dawn::utils::CreateShaderModule(device, R"(
|
||||
@fragment fn main(@location(0) v_color : vec4f) -> @location(0) vec4f {
|
||||
return v_color;
|
||||
})");
|
||||
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
wgpu::BindGroupLayout bgl = dawn::utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform, true}});
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor;
|
||||
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||
dawn::utils::ComboRenderPipelineDescriptor descriptor;
|
||||
descriptor.layout = dawn::utils::MakeBasicPipelineLayout(device, &bgl);
|
||||
descriptor.vertex.module = vsModule;
|
||||
descriptor.cFragment.module = fsModule;
|
||||
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||
|
@ -143,7 +143,7 @@ void init() {
|
|||
bufferDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
||||
ubo = device.CreateBuffer(&bufferDesc);
|
||||
|
||||
bindGroup = utils::MakeBindGroup(device, bgl, {{0, ubo, 0, sizeof(ShaderData)}});
|
||||
bindGroup = dawn::utils::MakeBindGroup(device, bgl, {{0, ubo, 0, sizeof(ShaderData)}});
|
||||
}
|
||||
|
||||
int frameCount = 0;
|
||||
|
@ -155,7 +155,7 @@ void frame() {
|
|||
}
|
||||
queue.WriteBuffer(ubo, 0, shaderData.data(), kNumTriangles * sizeof(ShaderData));
|
||||
|
||||
utils::ComboRenderPassDescriptor renderPass({backbufferView});
|
||||
dawn::utils::ComboRenderPassDescriptor renderPass({backbufferView});
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
|
@ -182,10 +182,10 @@ int main(int argc, const char* argv[]) {
|
|||
}
|
||||
init();
|
||||
|
||||
utils::Timer* timer = utils::CreateTimer();
|
||||
dawn::utils::Timer* timer = dawn::utils::CreateTimer();
|
||||
timer->Start();
|
||||
while (!ShouldQuit()) {
|
||||
utils::ScopedAutoreleasePool pool;
|
||||
dawn::utils::ScopedAutoreleasePool pool;
|
||||
ProcessEvents();
|
||||
frameCount++;
|
||||
frame();
|
||||
|
|
|
@ -42,13 +42,13 @@ void init() {
|
|||
);
|
||||
return vec4f(pos[VertexIndex], 0.0, 1.0);
|
||||
})";
|
||||
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).MoveToCHandle();
|
||||
WGPUShaderModule vsModule = dawn::utils::CreateShaderModule(device, vs).MoveToCHandle();
|
||||
|
||||
const char* fs = R"(
|
||||
@fragment fn main() -> @location(0) vec4f {
|
||||
return vec4f(1.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).MoveToCHandle();
|
||||
WGPUShaderModule fsModule = dawn::utils::CreateShaderModule(device, fs).MoveToCHandle();
|
||||
|
||||
{
|
||||
WGPURenderPipelineDescriptor descriptor = {};
|
||||
|
@ -142,9 +142,9 @@ int main(int argc, const char* argv[]) {
|
|||
init();
|
||||
|
||||
while (!ShouldQuit()) {
|
||||
utils::ScopedAutoreleasePool pool;
|
||||
dawn::utils::ScopedAutoreleasePool pool;
|
||||
ProcessEvents();
|
||||
frame();
|
||||
utils::USleep(16000);
|
||||
dawn::utils::USleep(16000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,11 +65,11 @@ void initBuffers() {
|
|||
{0.00, 0.02},
|
||||
}};
|
||||
modelBuffer =
|
||||
utils::CreateBufferFromData(device, &model, sizeof(model), wgpu::BufferUsage::Vertex);
|
||||
dawn::utils::CreateBufferFromData(device, &model, sizeof(model), wgpu::BufferUsage::Vertex);
|
||||
|
||||
SimParams params = {0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles};
|
||||
updateParams =
|
||||
utils::CreateBufferFromData(device, ¶ms, sizeof(params), wgpu::BufferUsage::Uniform);
|
||||
updateParams = dawn::utils::CreateBufferFromData(device, ¶ms, sizeof(params),
|
||||
wgpu::BufferUsage::Uniform);
|
||||
|
||||
std::vector<Particle> initialParticles(kNumParticles);
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ void initBuffers() {
|
|||
}
|
||||
|
||||
void initRender() {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
wgpu::ShaderModule vsModule = dawn::utils::CreateShaderModule(device, R"(
|
||||
struct VertexIn {
|
||||
@location(0) a_particlePos : vec2f,
|
||||
@location(1) a_particleVel : vec2f,
|
||||
|
@ -112,7 +112,7 @@ void initRender() {
|
|||
}
|
||||
)");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
wgpu::ShaderModule fsModule = dawn::utils::CreateShaderModule(device, R"(
|
||||
@fragment
|
||||
fn main() -> @location(0) vec4f {
|
||||
return vec4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
@ -121,7 +121,7 @@ void initRender() {
|
|||
|
||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor;
|
||||
dawn::utils::ComboRenderPipelineDescriptor descriptor;
|
||||
|
||||
|