From 2731b76ded528e777698a4f53fc2201989a1cb80 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 17 May 2023 18:41:02 +0000 Subject: [PATCH] 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 Auto-Submit: Austin Eng Reviewed-by: Loko Kung Commit-Queue: Austin Eng --- generator/templates/dawn/common/GPUInfo.cpp | 4 +- generator/templates/dawn/common/GPUInfo.h | 4 +- src/dawn/common/Alloc.h | 4 + src/dawn/common/Assert.cpp | 9 +- src/dawn/common/Assert.h | 14 +- src/dawn/common/BitSetIterator.h | 4 + src/dawn/common/ConcurrentCache.h | 4 + src/dawn/common/CoreFoundationRef.h | 4 + src/dawn/common/DynamicLib.cpp | 4 + src/dawn/common/DynamicLib.h | 4 + src/dawn/common/GPUInfo.cpp | 4 +- src/dawn/common/GPUInfo.h | 4 +- src/dawn/common/HashUtils.h | 10 +- src/dawn/common/IOKitRef.h | 4 + src/dawn/common/LinkedList.h | 4 + src/dawn/common/Math.cpp | 4 + src/dawn/common/Math.h | 4 + src/dawn/common/NSRef.h | 4 + src/dawn/common/NonCopyable.h | 4 + src/dawn/common/Numeric.h | 3 + src/dawn/common/PlacementAllocated.h | 4 + src/dawn/common/RefBase.h | 4 + src/dawn/common/RefCounted.cpp | 4 + src/dawn/common/RefCounted.h | 4 + src/dawn/common/Result.cpp | 3 + src/dawn/common/Result.h | 4 + src/dawn/common/SerialMap.h | 4 + src/dawn/common/SerialQueue.h | 4 + src/dawn/common/SerialStorage.h | 4 + src/dawn/common/SlabAllocator.cpp | 4 + src/dawn/common/SlabAllocator.h | 4 + src/dawn/common/StackContainer.h | 4 + src/dawn/common/SystemUtils.cpp | 4 + src/dawn/common/SystemUtils.h | 4 + src/dawn/common/SystemUtils_mac.mm | 4 + src/dawn/common/TypeTraits.h | 4 + src/dawn/common/TypedInteger.h | 39 ++-- src/dawn/common/UnderlyingType.h | 4 + src/dawn/common/WindowsUtils.cpp | 4 + src/dawn/common/WindowsUtils.h | 4 + src/dawn/common/ityp_array.h | 8 +- src/dawn/common/ityp_bitset.h | 7 +- src/dawn/common/ityp_span.h | 4 +- src/dawn/common/ityp_stack_vec.h | 4 +- src/dawn/common/ityp_vector.h | 4 +- .../DawnWireServerAndVulkanBackendFuzzer.cpp | 2 +- src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzer.cpp | 3 +- src/dawn/native/Forward.h | 2 + src/dawn/native/stream/Stream.h | 4 +- src/dawn/native/vulkan/VulkanFunctions.h | 2 + src/dawn/native/webgpu_absl_format.h | 2 +- src/dawn/samples/Animometer.cpp | 18 +- src/dawn/samples/CHelloTriangle.cpp | 8 +- src/dawn/samples/ComputeBoids.cpp | 26 +-- src/dawn/samples/CppHelloTriangle.cpp | 35 +-- src/dawn/samples/ManualSwapChainTest.cpp | 12 +- src/dawn/samples/SampleUtils.cpp | 12 +- src/dawn/tests/DawnTest.cpp | 119 +++++----- src/dawn/tests/DawnTest.h | 19 +- .../tests/end2end/AdapterDiscoveryTests.cpp | 36 +-- src/dawn/tests/end2end/BindGroupTests.cpp | 10 +- .../tests/end2end/BufferZeroInitTests.cpp | 30 +-- src/dawn/tests/end2end/ClipSpaceTests.cpp | 6 + src/dawn/tests/end2end/ColorStateTests.cpp | 6 + .../tests/end2end/CommandEncoderTests.cpp | 6 + .../end2end/CompressedTextureFormatTests.cpp | 8 +- .../end2end/ComputeCopyStorageBufferTests.cpp | 6 + .../tests/end2end/ComputeDispatchTests.cpp | 6 + .../tests/end2end/ComputeFlowControlTests.cpp | 6 + .../ComputeLayoutMemoryBufferTests.cpp | 8 +- .../end2end/ComputeSharedMemoryTests.cpp | 6 + .../ComputeStorageBufferBarrierTests.cpp | 6 + .../CopyExternalTextureForBrowserTests.cpp | 5 +- src/dawn/tests/end2end/CopyTests.cpp | 6 + .../end2end/CopyTextureForBrowserTests.cpp | 6 +- .../end2end/CreatePipelineAsyncTests.cpp | 6 +- src/dawn/tests/end2end/CullingTests.cpp | 6 + src/dawn/tests/end2end/D3D12CachingTests.cpp | 8 +- .../end2end/D3DResourceWrappingTests.cpp | 178 ++++++++------- src/dawn/tests/end2end/DebugMarkerTests.cpp | 6 + src/dawn/tests/end2end/DepthBiasTests.cpp | 6 + .../tests/end2end/DepthStencilCopyTests.cpp | 6 +- .../tests/end2end/DepthStencilLoadOpTests.cpp | 4 +- .../end2end/DepthStencilSamplingTests.cpp | 7 +- .../tests/end2end/DepthStencilStateTests.cpp | 6 + src/dawn/tests/end2end/DestroyTests.cpp | 6 + .../end2end/DeviceInitializationTests.cpp | 28 ++- .../tests/end2end/DeviceLifetimeTests.cpp | 6 + src/dawn/tests/end2end/DeviceLostTests.cpp | 6 + .../end2end/DrawIndexedIndirectTests.cpp | 6 + src/dawn/tests/end2end/DrawIndexedTests.cpp | 6 + src/dawn/tests/end2end/DrawIndirectTests.cpp | 6 + src/dawn/tests/end2end/DrawTests.cpp | 6 + .../end2end/DynamicBufferOffsetTests.cpp | 6 + src/dawn/tests/end2end/EntryPointTests.cpp | 6 + .../tests/end2end/ExperimentalDP4aTests.cpp | 7 +- .../tests/end2end/ExternalTextureTests.cpp | 5 +- .../tests/end2end/FirstIndexOffsetTests.cpp | 12 +- src/dawn/tests/end2end/FragDepthTests.cpp | 6 + .../end2end/GpuMemorySynchronizationTests.cpp | 6 + .../tests/end2end/IOSurfaceWrappingTests.cpp | 54 ++--- src/dawn/tests/end2end/IndexFormatTests.cpp | 6 + src/dawn/tests/end2end/MaxLimitTests.cpp | 6 + .../end2end/MultisampledRenderingTests.cpp | 6 + .../end2end/MultisampledSamplingTests.cpp | 7 +- src/dawn/tests/end2end/MultithreadTests.cpp | 7 +- .../end2end/NonzeroTextureCreationTests.cpp | 6 +- src/dawn/tests/end2end/ObjectCachingTests.cpp | 6 + src/dawn/tests/end2end/OpArrayLengthTests.cpp | 6 + .../tests/end2end/PipelineCachingTests.cpp | 6 +- .../tests/end2end/PipelineLayoutTests.cpp | 6 + .../tests/end2end/PrimitiveStateTests.cpp | 6 + .../tests/end2end/PrimitiveTopologyTests.cpp | 6 + src/dawn/tests/end2end/QueryTests.cpp | 6 + src/dawn/tests/end2end/QueueTests.cpp | 6 + .../ReadOnlyDepthStencilAttachmentTests.cpp | 8 +- .../tests/end2end/RenderAttachmentTests.cpp | 6 + src/dawn/tests/end2end/RenderBundleTests.cpp | 6 + .../tests/end2end/RenderPassLoadOpTests.cpp | 6 + src/dawn/tests/end2end/RenderPassTests.cpp | 6 + .../end2end/RequiredBufferSizeInCopyTests.cpp | 8 +- .../end2end/SamplerFilterAnisotropicTests.cpp | 8 +- src/dawn/tests/end2end/SamplerTests.cpp | 8 +- src/dawn/tests/end2end/ScissorTests.cpp | 6 + src/dawn/tests/end2end/ShaderF16Tests.cpp | 6 +- src/dawn/tests/end2end/ShaderTests.cpp | 6 + .../tests/end2end/ShaderValidationTests.cpp | 6 + .../tests/end2end/StorageTextureTests.cpp | 6 +- .../SubresourceRenderAttachmentTests.cpp | 6 + src/dawn/tests/end2end/SwapChainTests.cpp | 8 +- .../end2end/SwapChainValidationTests.cpp | 8 +- src/dawn/tests/end2end/Texture3DTests.cpp | 6 + .../tests/end2end/TextureCorruptionTests.cpp | 9 +- src/dawn/tests/end2end/TextureFormatTests.cpp | 10 +- .../tests/end2end/TextureSubresourceTests.cpp | 6 + src/dawn/tests/end2end/TextureViewTests.cpp | 8 +- .../tests/end2end/TextureZeroInitTests.cpp | 191 ++++++++-------- src/dawn/tests/end2end/VertexFormatTests.cpp | 8 +- .../end2end/VertexOnlyRenderPipelineTests.cpp | 6 + src/dawn/tests/end2end/VertexStateTests.cpp | 6 + src/dawn/tests/end2end/VideoViewsTests.cpp | 7 + src/dawn/tests/end2end/VideoViewsTests.h | 28 ++- .../tests/end2end/VideoViewsTests_gbm.cpp | 17 +- .../tests/end2end/VideoViewsTests_mac.cpp | 12 +- .../tests/end2end/VideoViewsTests_win.cpp | 19 +- .../end2end/ViewportOrientationTests.cpp | 6 + src/dawn/tests/end2end/ViewportTests.cpp | 6 + src/dawn/tests/end2end/WindowSurfaceTests.cpp | 12 +- .../mocks/platform/CachingInterfaceMock.h | 4 +- src/dawn/tests/perf_tests/DawnPerfTest.cpp | 2 +- src/dawn/tests/perf_tests/DawnPerfTest.h | 4 +- .../tests/perf_tests/DawnPerfTestPlatform.cpp | 6 +- .../tests/perf_tests/DawnPerfTestPlatform.h | 4 +- src/dawn/tests/perf_tests/DrawCallPerf.cpp | 6 +- .../tests/perf_tests/ShaderRobustnessPerf.cpp | 7 +- .../perf_tests/SubresourceTrackingPerf.cpp | 6 + src/dawn/tests/unittests/AsyncTaskTests.cpp | 16 +- .../tests/unittests/BitSetIteratorTests.cpp | 6 + src/dawn/tests/unittests/ChainUtilsTests.cpp | 210 +++++++++--------- .../tests/unittests/ConcurrentCacheTests.cpp | 21 +- .../tests/unittests/EnumMaskIteratorTests.cpp | 2 +- src/dawn/tests/unittests/FeatureTests.cpp | 76 ++++--- src/dawn/tests/unittests/GPUInfoTests.cpp | 7 +- .../tests/unittests/GetProcAddressTests.cpp | 27 ++- src/dawn/tests/unittests/ITypArrayTests.cpp | 6 + src/dawn/tests/unittests/ITypBitsetTests.cpp | 6 + src/dawn/tests/unittests/ITypSpanTests.cpp | 6 + src/dawn/tests/unittests/ITypVectorTests.cpp | 6 + src/dawn/tests/unittests/LimitsTests.cpp | 128 ++++++----- src/dawn/tests/unittests/LinkedListTests.cpp | 6 + src/dawn/tests/unittests/MathTests.cpp | 7 +- src/dawn/tests/unittests/MutexTests.cpp | 18 +- src/dawn/tests/unittests/NumericTests.cpp | 8 +- .../tests/unittests/PerThreadProcTests.cpp | 20 +- .../unittests/PlacementAllocatedTests.cpp | 9 +- src/dawn/tests/unittests/RefBaseTests.cpp | 6 +- src/dawn/tests/unittests/RefCountedTests.cpp | 6 + src/dawn/tests/unittests/ResultTests.cpp | 2 + src/dawn/tests/unittests/SerialMapTests.cpp | 6 + src/dawn/tests/unittests/SerialQueueTests.cpp | 6 + .../tests/unittests/SlabAllocatorTests.cpp | 6 +- .../tests/unittests/StackContainerTests.cpp | 14 +- src/dawn/tests/unittests/SystemUtilsTests.cpp | 6 + src/dawn/tests/unittests/ToggleTests.cpp | 71 +++--- .../tests/unittests/TypedIntegerTests.cpp | 6 + src/dawn/tests/unittests/UnicodeTests.cpp | 14 +- .../tests/unittests/WindowsUtilsTests.cpp | 6 + .../tests/unittests/d3d12/CopySplitTests.cpp | 3 +- .../unittests/native/AllowedErrorTests.cpp | 2 +- src/dawn/tests/unittests/native/BlobTests.cpp | 2 - .../unittests/native/CacheRequestTests.cpp | 4 +- .../native/CommandBufferEncodingTests.cpp | 2 + .../native/CreatePipelineAsyncTaskTests.cpp | 2 +- .../unittests/native/DestroyObjectTests.cpp | 15 +- .../unittests/native/DeviceAsyncTaskTests.cpp | 3 +- .../unittests/native/DeviceCreationTests.cpp | 2 + .../native/ObjectContentHasherTests.cpp | 2 - .../tests/unittests/native/StreamTests.cpp | 22 +- .../validation/BindGroupValidationTests.cpp | 8 +- .../CommandBufferValidationTests.cpp | 24 +- .../ComputeIndirectValidationTests.cpp | 6 + .../validation/ComputeValidationTests.cpp | 6 + .../CopyCommandsValidationTests.cpp | 14 +- .../validation/CopyTextureForBrowserTests.cpp | 11 +- .../validation/DebugMarkerValidationTests.cpp | 6 + .../DrawIndirectValidationTests.cpp | 6 + ...VertexAndIndexBufferOOBValidationTests.cpp | 3 + .../DynamicStateCommandValidationTests.cpp | 6 + .../validation/ExternalTextureTests.cpp | 5 +- .../GetBindGroupLayoutValidationTests.cpp | 92 ++++---- .../validation/IndexBufferValidationTests.cpp | 6 + .../InternalUsageValidationTests.cpp | 8 +- .../tests/unittests/validation/LabelTests.cpp | 117 +++++----- .../MinimumBufferSizeValidationTests.cpp | 6 +- .../OverridableConstantsValidationTests.cpp | 8 +- .../PipelineAndPassCompatibilityTests.cpp | 6 +- .../validation/QueryValidationTests.cpp | 12 +- .../validation/QueueSubmitValidationTests.cpp | 2 + .../QueueWriteTextureValidationTests.cpp | 4 +- .../RenderBundleValidationTests.cpp | 6 +- .../RenderPassDescriptorValidationTests.cpp | 2 + .../RenderPipelineValidationTests.cpp | 14 +- .../validation/ResourceUsageTrackingTests.cpp | 2 + .../ShaderModuleValidationTests.cpp | 18 +- .../StorageTextureValidationTests.cpp | 10 +- .../validation/TextureSubresourceTests.cpp | 2 + .../validation/TextureValidationTests.cpp | 14 +- .../validation/TextureViewValidationTests.cpp | 4 +- .../validation/ToggleValidationTests.cpp | 15 +- .../validation/UnsafeAPIValidationTests.cpp | 8 +- .../unittests/validation/ValidationTest.cpp | 2 +- .../unittests/validation/ValidationTest.h | 6 +- .../VertexBufferValidationTests.cpp | 6 + .../validation/VertexStateValidationTests.cpp | 6 + .../validation/VideoViewsValidationTests.cpp | 4 +- ...leBufferBindingAliasingValidationTests.cpp | 7 +- ...eTextureBindingAliasingValidationTests.cpp | 7 +- .../tests/unittests/wire/WireAdapterTests.cpp | 2 +- .../unittests/wire/WireArgumentTests.cpp | 2 + .../tests/unittests/wire/WireBasicTests.cpp | 2 + .../unittests/wire/WireBufferMappingTests.cpp | 6 +- .../wire/WireCreatePipelineAsyncTests.cpp | 3 +- .../wire/WireDeviceLifetimeTests.cpp | 14 +- .../unittests/wire/WireDisconnectTests.cpp | 6 +- .../unittests/wire/WireErrorCallbackTests.cpp | 6 +- .../unittests/wire/WireExtensionTests.cpp | 2 + .../unittests/wire/WireInjectDeviceTests.cpp | 2 + .../wire/WireInjectInstanceTests.cpp | 2 +- .../wire/WireInjectSwapChainTests.cpp | 2 + .../unittests/wire/WireInjectTextureTests.cpp | 2 + .../unittests/wire/WireInstanceTests.cpp | 2 +- .../wire/WireMemoryTransferServiceTests.cpp | 10 +- .../unittests/wire/WireOptionalTests.cpp | 2 + .../tests/unittests/wire/WireQueueTests.cpp | 2 + .../unittests/wire/WireShaderModuleTests.cpp | 6 +- src/dawn/tests/unittests/wire/WireTest.cpp | 4 +- src/dawn/tests/unittests/wire/WireTest.h | 6 +- .../white_box/BufferAllocatedSizeTests.cpp | 12 +- src/dawn/tests/white_box/D3D11BufferTests.cpp | 48 ++-- .../white_box/D3D12DescriptorHeapTests.cpp | 40 ++-- .../tests/white_box/D3D12ResidencyTests.cpp | 46 ++-- .../white_box/D3D12ResourceHeapTests.cpp | 2 + .../tests/white_box/EGLImageWrappingTests.cpp | 22 +- .../GPUTimestampCalibrationTests.cpp | 6 +- .../white_box/GPUTimestampCalibrationTests.h | 4 + .../GPUTimestampCalibrationTests_D3D12.cpp | 11 +- .../GPUTimestampCalibrationTests_Metal.mm | 7 + .../white_box/InternalResourceUsageTests.cpp | 12 +- .../InternalStorageBufferBindingTests.cpp | 19 +- .../white_box/QueryInternalShaderTests.cpp | 16 +- .../white_box/VulkanErrorInjectorTests.cpp | 8 +- .../white_box/VulkanImageWrappingTests.cpp | 30 ++- .../VulkanImageWrappingTests_DmaBuf.cpp | 6 +- .../VulkanImageWrappingTests_OpaqueFD.cpp | 22 +- .../ComboRenderBundleEncoderDescriptor.cpp | 4 +- .../ComboRenderBundleEncoderDescriptor.h | 4 +- .../utils/ComboRenderPipelineDescriptor.cpp | 4 +- .../utils/ComboRenderPipelineDescriptor.h | 4 +- src/dawn/utils/EmptyDebugLogger.cpp | 4 +- src/dawn/utils/OSXTimer.cpp | 4 +- src/dawn/utils/ObjCUtils.h | 4 +- src/dawn/utils/ObjCUtils.mm | 4 +- src/dawn/utils/PlatformDebugLogger.h | 4 +- src/dawn/utils/PosixTimer.cpp | 4 +- src/dawn/utils/ScopedAutoreleasePool.cpp | 4 +- src/dawn/utils/ScopedAutoreleasePool.h | 6 +- src/dawn/utils/ScopedAutoreleasePool.mm | 4 +- src/dawn/utils/SystemUtils.cpp | 4 +- src/dawn/utils/SystemUtils.h | 2 +- src/dawn/utils/TerribleCommandBuffer.cpp | 4 +- src/dawn/utils/TerribleCommandBuffer.h | 4 +- src/dawn/utils/TestUtils.cpp | 25 ++- src/dawn/utils/TestUtils.h | 4 +- src/dawn/utils/TextureUtils.cpp | 4 +- src/dawn/utils/TextureUtils.h | 4 +- src/dawn/utils/Timer.h | 4 +- src/dawn/utils/WGPUHelpers.cpp | 4 +- src/dawn/utils/WGPUHelpers.h | 10 +- src/dawn/utils/WindowsDebugLogger.cpp | 4 +- src/dawn/utils/WindowsTimer.cpp | 4 +- src/dawn/utils/WireHelper.cpp | 12 +- src/dawn/utils/WireHelper.h | 4 +- 302 files changed, 2225 insertions(+), 1255 deletions(-) diff --git a/generator/templates/dawn/common/GPUInfo.cpp b/generator/templates/dawn/common/GPUInfo.cpp index f24c26255f..f144e5e772 100644 --- a/generator/templates/dawn/common/GPUInfo.cpp +++ b/generator/templates/dawn/common/GPUInfo.cpp @@ -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 diff --git a/generator/templates/dawn/common/GPUInfo.h b/generator/templates/dawn/common/GPUInfo.h index f058008cd4..5d93207e7c 100644 --- a/generator/templates/dawn/common/GPUInfo.h +++ b/generator/templates/dawn/common/GPUInfo.h @@ -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_ diff --git a/src/dawn/common/Alloc.h b/src/dawn/common/Alloc.h index 23bc92d934..388795fd02 100644 --- a/src/dawn/common/Alloc.h +++ b/src/dawn/common/Alloc.h @@ -18,6 +18,8 @@ #include #include +namespace dawn { + template 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_ diff --git a/src/dawn/common/Assert.cpp b/src/dawn/common/Assert.cpp index 221ee22a90..b4bf6c577b 100644 --- a/src/dawn/common/Assert.cpp +++ b/src/dawn/common/Assert.cpp @@ -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 diff --git a/src/dawn/common/Assert.h b/src/dawn/common/Assert.h index 244cd41e95..849116ec2f 100644 --- a/src/dawn/common/Assert.h +++ b/src/dawn/common/Assert.h @@ -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_ diff --git a/src/dawn/common/BitSetIterator.h b/src/dawn/common/BitSetIterator.h index a011249714..b3bb4c2b7b 100644 --- a/src/dawn/common/BitSetIterator.h +++ b/src/dawn/common/BitSetIterator.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 IterateBitSet(const std::bitset& bitset) { return BitSetIterator(bitset); } +} // namespace dawn + #endif // SRC_DAWN_COMMON_BITSETITERATOR_H_ diff --git a/src/dawn/common/ConcurrentCache.h b/src/dawn/common/ConcurrentCache.h index 99c41ac6b4..188d0b208a 100644 --- a/src/dawn/common/ConcurrentCache.h +++ b/src/dawn/common/ConcurrentCache.h @@ -21,6 +21,8 @@ #include "dawn/common/NonCopyable.h" +namespace dawn { + template class ConcurrentCache : public NonMovable { public: @@ -51,4 +53,6 @@ class ConcurrentCache : public NonMovable { std::unordered_set mCache; }; +} // namespace dawn + #endif // SRC_DAWN_COMMON_CONCURRENTCACHE_H_ diff --git a/src/dawn/common/CoreFoundationRef.h b/src/dawn/common/CoreFoundationRef.h index 3a4724e6ec..f07501a527 100644 --- a/src/dawn/common/CoreFoundationRef.h +++ b/src/dawn/common/CoreFoundationRef.h @@ -19,6 +19,8 @@ #include "dawn/common/RefBase.h" +namespace dawn { + template struct CoreFoundationRefTraits { static constexpr T kNullValue = nullptr; @@ -39,4 +41,6 @@ CFRef AcquireCFRef(T pointee) { return ref; } +} // namespace dawn + #endif // SRC_DAWN_COMMON_COREFOUNDATIONREF_H_ diff --git a/src/dawn/common/DynamicLib.cpp b/src/dawn/common/DynamicLib.cpp index 479ca653c6..4dde2f0fba 100644 --- a/src/dawn/common/DynamicLib.cpp +++ b/src/dawn/common/DynamicLib.cpp @@ -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 diff --git a/src/dawn/common/DynamicLib.h b/src/dawn/common/DynamicLib.h index a5980f5fc2..7fd2df2fd5 100644 --- a/src/dawn/common/DynamicLib.h +++ b/src/dawn/common/DynamicLib.h @@ -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_ diff --git a/src/dawn/common/GPUInfo.cpp b/src/dawn/common/GPUInfo.cpp index b46f2429ee..154589e668 100644 --- a/src/dawn/common/GPUInfo.cpp +++ b/src/dawn/common/GPUInfo.cpp @@ -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 diff --git a/src/dawn/common/GPUInfo.h b/src/dawn/common/GPUInfo.h index dab977f08e..6800ff2c7a 100644 --- a/src/dawn/common/GPUInfo.h +++ b/src/dawn/common/GPUInfo.h @@ -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_ diff --git a/src/dawn/common/HashUtils.h b/src/dawn/common/HashUtils.h index e8d17821f4..416ef76c20 100644 --- a/src/dawn/common/HashUtils.h +++ b/src/dawn/common/HashUtils.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 @@ -88,12 +90,14 @@ size_t Hash(const std::bitset& value) { } #endif +} // namespace dawn + namespace std { template -struct hash> { +struct hash> { public: - size_t operator()(const ityp::bitset& value) const { - return Hash(static_cast&>(value)); + size_t operator()(const dawn::ityp::bitset& value) const { + return dawn::Hash(static_cast&>(value)); } }; } // namespace std diff --git a/src/dawn/common/IOKitRef.h b/src/dawn/common/IOKitRef.h index 33367b1e4c..3a128432f0 100644 --- a/src/dawn/common/IOKitRef.h +++ b/src/dawn/common/IOKitRef.h @@ -19,6 +19,8 @@ #include "dawn/common/RefBase.h" +namespace dawn { + template struct IOKitRefTraits { static constexpr T kNullValue = IO_OBJECT_NULL; @@ -39,4 +41,6 @@ IORef AcquireIORef(T pointee) { return ref; } +} // namespace dawn + #endif // SRC_DAWN_COMMON_IOKITREF_H_ diff --git a/src/dawn/common/LinkedList.h b/src/dawn/common/LinkedList.h index b0f990fccb..4a92aa8471 100644 --- a/src/dawn/common/LinkedList.h +++ b/src/dawn/common/LinkedList.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 end(LinkedList& l) { return LinkedListIterator(l.tail()->next()); } +} // namespace dawn + #endif // SRC_DAWN_COMMON_LINKEDLIST_H_ diff --git a/src/dawn/common/Math.cpp b/src/dawn/common/Math.cpp index a3794e2502..ffe351acc4 100644 --- a/src/dawn/common/Math.cpp +++ b/src/dawn/common/Math.cpp @@ -25,6 +25,8 @@ #include #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::max() - n); return ((n + m - 1) / m) * m; } + +} // namespace dawn diff --git a/src/dawn/common/Math.h b/src/dawn/common/Math.h index c8b518fb89..e23376e770 100644 --- a/src/dawn/common/Math.h +++ b/src/dawn/common/Math.h @@ -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_ diff --git a/src/dawn/common/NSRef.h b/src/dawn/common/NSRef.h index 4afb5e0390..9db459b2f0 100644 --- a/src/dawn/common/NSRef.h +++ b/src/dawn/common/NSRef.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 AcquireNSPRef(T pointee) { return ref; } +} // namespace dawn + #endif // SRC_DAWN_COMMON_NSREF_H_ diff --git a/src/dawn/common/NonCopyable.h b/src/dawn/common/NonCopyable.h index 8223ad583d..41edc84b2c 100644 --- a/src/dawn/common/NonCopyable.h +++ b/src/dawn/common/NonCopyable.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_ diff --git a/src/dawn/common/Numeric.h b/src/dawn/common/Numeric.h index 7be33c87f9..8f1d4aa63d 100644 --- a/src/dawn/common/Numeric.h +++ b/src/dawn/common/Numeric.h @@ -21,6 +21,7 @@ #include "dawn/common/Assert.h" +namespace dawn { namespace detail { template @@ -81,4 +82,6 @@ bool RangesOverlap(T x0, T x1, T y0, T y1) { } } +} // namespace dawn + #endif // SRC_DAWN_COMMON_NUMERIC_H_ diff --git a/src/dawn/common/PlacementAllocated.h b/src/dawn/common/PlacementAllocated.h index dc097ac136..daf60b27be 100644 --- a/src/dawn/common/PlacementAllocated.h +++ b/src/dawn/common/PlacementAllocated.h @@ -17,6 +17,8 @@ #include +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_ diff --git a/src/dawn/common/RefBase.h b/src/dawn/common/RefBase.h index 1539547176..5662cd3dc2 100644 --- a/src/dawn/common/RefBase.h +++ b/src/dawn/common/RefBase.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_ diff --git a/src/dawn/common/RefCounted.cpp b/src/dawn/common/RefCounted.cpp index b5d244134a..aa91c85589 100644 --- a/src/dawn/common/RefCounted.cpp +++ b/src/dawn/common/RefCounted.cpp @@ -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 diff --git a/src/dawn/common/RefCounted.h b/src/dawn/common/RefCounted.h index 839b47dc16..0ab74278dc 100644 --- a/src/dawn/common/RefCounted.h +++ b/src/dawn/common/RefCounted.h @@ -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 AcquireRef(T* pointee) { return ref; } +} // namespace dawn + #endif // SRC_DAWN_COMMON_REFCOUNTED_H_ diff --git a/src/dawn/common/Result.cpp b/src/dawn/common/Result.cpp index c009df682d..f79d80765a 100644 --- a/src/dawn/common/Result.cpp +++ b/src/dawn/common/Result.cpp @@ -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 diff --git a/src/dawn/common/Result.h b/src/dawn/common/Result.h index 849cd30170..0630e2851c 100644 --- a/src/dawn/common/Result.h +++ b/src/dawn/common/Result.h @@ -24,6 +24,8 @@ #include "dawn/common/Assert.h" #include "dawn/common/Compiler.h" +namespace dawn { + // Result is the following sum type (Haskell notation): // // data Result T E = Success T | Error E | Empty @@ -511,4 +513,6 @@ std::unique_ptr Result::AcquireError() { return std::move(mError); } +} // namespace dawn + #endif // SRC_DAWN_COMMON_RESULT_H_ diff --git a/src/dawn/common/SerialMap.h b/src/dawn/common/SerialMap.h index 6ada5d997d..3180f39ffa 100644 --- a/src/dawn/common/SerialMap.h +++ b/src/dawn/common/SerialMap.h @@ -21,6 +21,8 @@ #include "dawn/common/SerialStorage.h" +namespace dawn { + template class SerialMap; @@ -74,4 +76,6 @@ void SerialMap::Enqueue(std::vector&& values, Serial seria } } +} // namespace dawn + #endif // SRC_DAWN_COMMON_SERIALMAP_H_ diff --git a/src/dawn/common/SerialQueue.h b/src/dawn/common/SerialQueue.h index 378952e6c9..0a08896af4 100644 --- a/src/dawn/common/SerialQueue.h +++ b/src/dawn/common/SerialQueue.h @@ -20,6 +20,8 @@ #include "dawn/common/SerialStorage.h" +namespace dawn { + template class SerialQueue; @@ -83,4 +85,6 @@ void SerialQueue::Enqueue(std::vector&& values, Serial ser this->mStorage.emplace_back(serial, std::move(values)); } +} // namespace dawn + #endif // SRC_DAWN_COMMON_SERIALQUEUE_H_ diff --git a/src/dawn/common/SerialStorage.h b/src/dawn/common/SerialStorage.h index 0d4c8b5d6a..c25c67ffd3 100644 --- a/src/dawn/common/SerialStorage.h +++ b/src/dawn/common/SerialStorage.h @@ -20,6 +20,8 @@ #include "dawn/common/Assert.h" +namespace dawn { + template struct SerialStorageTraits {}; @@ -315,4 +317,6 @@ const typename SerialStorage::Value& SerialStorage::ConstItera return *mSerialIterator; } +} // namespace dawn + #endif // SRC_DAWN_COMMON_SERIALSTORAGE_H_ diff --git a/src/dawn/common/SlabAllocator.cpp b/src/dawn/common/SlabAllocator.cpp index b4d18275c2..f319de2494 100644 --- a/src/dawn/common/SlabAllocator.cpp +++ b/src/dawn/common/SlabAllocator.cpp @@ -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 diff --git a/src/dawn/common/SlabAllocator.h b/src/dawn/common/SlabAllocator.h index e828dea40c..7542b42130 100644 --- a/src/dawn/common/SlabAllocator.h +++ b/src/dawn/common/SlabAllocator.h @@ -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_ diff --git a/src/dawn/common/StackContainer.h b/src/dawn/common/StackContainer.h index 1d1d7ca401..2e03749613 100644 --- a/src/dawn/common/StackContainer.h +++ b/src/dawn/common/StackContainer.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_ diff --git a/src/dawn/common/SystemUtils.cpp b/src/dawn/common/SystemUtils.cpp index 2e29820728..92b27f0234 100644 --- a/src/dawn/common/SystemUtils.cpp +++ b/src/dawn/common/SystemUtils.cpp @@ -33,6 +33,8 @@ #include +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 diff --git a/src/dawn/common/SystemUtils.h b/src/dawn/common/SystemUtils.h index ed37085348..d862c2c172 100644 --- a/src/dawn/common/SystemUtils.h +++ b/src/dawn/common/SystemUtils.h @@ -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_ diff --git a/src/dawn/common/SystemUtils_mac.mm b/src/dawn/common/SystemUtils_mac.mm index b706c20f6d..d2d7c66512 100644 --- a/src/dawn/common/SystemUtils_mac.mm +++ b/src/dawn/common/SystemUtils_mac.mm @@ -18,6 +18,8 @@ #import +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 diff --git a/src/dawn/common/TypeTraits.h b/src/dawn/common/TypeTraits.h index f3cb5303c4..6792429e09 100644 --- a/src/dawn/common/TypeTraits.h +++ b/src/dawn/common/TypeTraits.h @@ -17,6 +17,8 @@ #include +namespace dawn { + template 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_ diff --git a/src/dawn/common/TypedInteger.h b/src/dawn/common/TypedInteger.h index b9d43a4468..8afa1f1e8f 100644 --- a/src/dawn/common/TypedInteger.h +++ b/src/dawn/common/TypedInteger.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; -// using UintB = TypedInteger; +// using UintA = dawn::TypedInteger; +// using UintB = dawn::TypedInteger; // // in Release: // using UintA = uint32_t; @@ -208,23 +210,24 @@ class alignas(T) TypedIntegerImpl { }; } // namespace detail +} // namespace dawn namespace std { template -class numeric_limits> : public numeric_limits { +class numeric_limits> : public numeric_limits { public: - static detail::TypedIntegerImpl max() noexcept { - return detail::TypedIntegerImpl(std::numeric_limits::max()); + static dawn::detail::TypedIntegerImpl max() noexcept { + return dawn::detail::TypedIntegerImpl(std::numeric_limits::max()); } - static detail::TypedIntegerImpl min() noexcept { - return detail::TypedIntegerImpl(std::numeric_limits::min()); + static dawn::detail::TypedIntegerImpl min() noexcept { + return dawn::detail::TypedIntegerImpl(std::numeric_limits::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 -constexpr ::detail::TypedIntegerImpl Add(::detail::TypedIntegerImpl lhs, - ::detail::TypedIntegerImpl rhs) { - return ::detail::TypedIntegerImpl( - static_cast(::detail::TypedIntegerImpl::AddImpl(lhs, rhs))); +constexpr ::dawn::detail::TypedIntegerImpl Add( + ::dawn::detail::TypedIntegerImpl lhs, + ::dawn::detail::TypedIntegerImpl rhs) { + return ::dawn::detail::TypedIntegerImpl( + static_cast(::dawn::detail::TypedIntegerImpl::AddImpl(lhs, rhs))); } template -constexpr ::detail::TypedIntegerImpl Sub(::detail::TypedIntegerImpl lhs, - ::detail::TypedIntegerImpl rhs) { - return ::detail::TypedIntegerImpl( - static_cast(::detail::TypedIntegerImpl::SubImpl(lhs, rhs))); +constexpr ::dawn::detail::TypedIntegerImpl Sub( + ::dawn::detail::TypedIntegerImpl lhs, + ::dawn::detail::TypedIntegerImpl rhs) { + return ::dawn::detail::TypedIntegerImpl( + static_cast(::dawn::detail::TypedIntegerImpl::SubImpl(lhs, rhs))); } template @@ -255,6 +260,6 @@ constexpr std::enable_if_t::value, T> Sub(T lhs, T rhs) { return static_cast(lhs - rhs); } -} // namespace ityp +} // namespace dawn::ityp #endif // SRC_DAWN_COMMON_TYPEDINTEGER_H_ diff --git a/src/dawn/common/UnderlyingType.h b/src/dawn/common/UnderlyingType.h index b4ff8ea604..4e908ca419 100644 --- a/src/dawn/common/UnderlyingType.h +++ b/src/dawn/common/UnderlyingType.h @@ -17,6 +17,8 @@ #include +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> { template using UnderlyingType = typename detail::UnderlyingTypeImpl::type; +} // namespace dawn + #endif // SRC_DAWN_COMMON_UNDERLYINGTYPE_H_ diff --git a/src/dawn/common/WindowsUtils.cpp b/src/dawn/common/WindowsUtils.cpp index 6a5b143d17..ebf6839a1f 100644 --- a/src/dawn/common/WindowsUtils.cpp +++ b/src/dawn/common/WindowsUtils.cpp @@ -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 diff --git a/src/dawn/common/WindowsUtils.h b/src/dawn/common/WindowsUtils.h index 1a2b906976..0d58207750 100644 --- a/src/dawn/common/WindowsUtils.h +++ b/src/dawn/common/WindowsUtils.h @@ -17,8 +17,12 @@ #include +namespace dawn { + std::string WCharToUTF8(const wchar_t* input); std::wstring UTF8ToWStr(const char* input); +} // namespace dawn + #endif // SRC_DAWN_COMMON_WINDOWSUTILS_H_ diff --git a/src/dawn/common/ityp_array.h b/src/dawn/common/ityp_array.h index a4103027f9..1a2053842e 100644 --- a/src/dawn/common/ityp_array.h +++ b/src/dawn/common/ityp_array.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 -class array : private std::array { +class array : private ::std::array { using I = UnderlyingType; - using Base = std::array; + using Base = ::std::array; static_assert(Size <= std::numeric_limits::max()); @@ -85,6 +85,6 @@ class array : private std::array { using Base::front; }; -} // namespace ityp +} // namespace dawn::ityp #endif // SRC_DAWN_COMMON_ITYP_ARRAY_H_ diff --git a/src/dawn/common/ityp_bitset.h b/src/dawn/common/ityp_bitset.h index a5544e15d2..66dcbb3e93 100644 --- a/src/dawn/common/ityp_bitset.h +++ b/src/dawn/common/ityp_bitset.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 -class bitset : private std::bitset { +class bitset : private ::std::bitset { using I = UnderlyingType; - using Base = std::bitset; + using Base = ::std::bitset; static_assert(sizeof(I) <= sizeof(size_t)); @@ -168,4 +169,6 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset& bitset) { #endif // DAWN_COMPILER_IS(MSVC) } +} // namespace dawn + #endif // SRC_DAWN_COMMON_ITYP_BITSET_H_ diff --git a/src/dawn/common/ityp_span.h b/src/dawn/common/ityp_span.h index 4f76b57bd2..7262d3482f 100644 --- a/src/dawn/common/ityp_span.h +++ b/src/dawn/common/ityp_span.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_ diff --git a/src/dawn/common/ityp_stack_vec.h b/src/dawn/common/ityp_stack_vec.h index d35adf6d98..4bdd667599 100644 --- a/src/dawn/common/ityp_stack_vec.h +++ b/src/dawn/common/ityp_stack_vec.h @@ -22,7 +22,7 @@ #include "dawn/common/StackContainer.h" #include "dawn/common/UnderlyingType.h" -namespace ityp { +namespace dawn::ityp { template class stack_vec : private StackVector { @@ -72,6 +72,6 @@ class stack_vec : private StackVector { Index size() const { return Index(static_cast(this->container().size())); } }; -} // namespace ityp +} // namespace dawn::ityp #endif // SRC_DAWN_COMMON_ITYP_STACK_VEC_H_ diff --git a/src/dawn/common/ityp_vector.h b/src/dawn/common/ityp_vector.h index 3d402cfdbb..8f9d7a8840 100644 --- a/src/dawn/common/ityp_vector.h +++ b/src/dawn/common/ityp_vector.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 { void reserve(Index size) { Base::reserve(static_cast(size)); } }; -} // namespace ityp +} // namespace dawn::ityp #endif // SRC_DAWN_COMMON_ITYP_VECTOR_H_ diff --git a/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp index 36ac282936..3d2c6b56a9 100644 --- a/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerAndVulkanBackendFuzzer.cpp @@ -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 */); } diff --git a/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzer.cpp b/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzer.cpp index d26eeecefd..682f4e753b 100644 --- a/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzer.cpp +++ b/src/dawn/fuzzers/lpmfuzz/DawnLPMFuzzer.cpp @@ -102,7 +102,8 @@ int Run(const fuzzing::Program& program, bool (*AdapterSupported)(const dawn::na std::unique_ptr 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()); diff --git a/src/dawn/native/Forward.h b/src/dawn/native/Forward.h index 2537d2d322..bcf07a698c 100644 --- a/src/dawn/native/Forward.h +++ b/src/dawn/native/Forward.h @@ -17,8 +17,10 @@ #include +namespace dawn { template class Ref; +} // namespace dawn namespace dawn::native { diff --git a/src/dawn/native/stream/Stream.h b/src/dawn/native/stream/Stream.h index d077cccc60..6b934216a5 100644 --- a/src/dawn/native/stream/Stream.h +++ b/src/dawn/native/stream/Stream.h @@ -164,8 +164,8 @@ class Stream>> { // Stream specialization for TypedInteger. template -class Stream<::detail::TypedIntegerImpl> { - using T = ::detail::TypedIntegerImpl; +class Stream<::dawn::detail::TypedIntegerImpl> { + using T = ::dawn::detail::TypedIntegerImpl; public: static void Write(Sink* s, const T& t) { StreamIn(s, static_cast(t)); } diff --git a/src/dawn/native/vulkan/VulkanFunctions.h b/src/dawn/native/vulkan/VulkanFunctions.h index 5b6cb4a121..f12c6f6de8 100644 --- a/src/dawn/native/vulkan/VulkanFunctions.h +++ b/src/dawn/native/vulkan/VulkanFunctions.h @@ -20,7 +20,9 @@ #include "dawn/native/Error.h" +namespace dawn { class DynamicLib; +} // namespace dawn namespace dawn::native::vulkan { diff --git a/src/dawn/native/webgpu_absl_format.h b/src/dawn/native/webgpu_absl_format.h index 1b3bdcb9c4..65e514d1c1 100644 --- a/src/dawn/native/webgpu_absl_format.h +++ b/src/dawn/native/webgpu_absl_format.h @@ -19,7 +19,7 @@ #include "dawn/native/dawn_platform.h" #include "dawn/native/webgpu_absl_format_autogen.h" -namespace ityp { +namespace dawn::ityp { template class span; } diff --git a/src/dawn/samples/Animometer.cpp b/src/dawn/samples/Animometer.cpp index 4c509d8109..c3d6217f3f 100644 --- a/src/dawn/samples/Animometer.cpp +++ b/src/dawn/samples/Animometer.cpp @@ -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(); diff --git a/src/dawn/samples/CHelloTriangle.cpp b/src/dawn/samples/CHelloTriangle.cpp index 59451ca734..f6e16dccd0 100644 --- a/src/dawn/samples/CHelloTriangle.cpp +++ b/src/dawn/samples/CHelloTriangle.cpp @@ -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); } } diff --git a/src/dawn/samples/ComputeBoids.cpp b/src/dawn/samples/ComputeBoids.cpp index d289c23fbf..56944c07ed 100644 --- a/src/dawn/samples/ComputeBoids.cpp +++ b/src/dawn/samples/ComputeBoids.cpp @@ -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 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; descriptor.vertex.module = vsModule; descriptor.vertex.bufferCount = 2; @@ -147,7 +147,7 @@ void initRender() { } void initSim() { - wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( + wgpu::ShaderModule module = dawn::utils::CreateShaderModule(device, R"( struct Particle { pos : vec2f, vel : vec2f, @@ -242,14 +242,14 @@ void initSim() { } )"); - auto bgl = utils::MakeBindGroupLayout( + auto bgl = dawn::utils::MakeBindGroupLayout( device, { {0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform}, {1, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}, {2, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}, }); - wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl); + wgpu::PipelineLayout pl = dawn::utils::MakeBasicPipelineLayout(device, &bgl); wgpu::ComputePipelineDescriptor csDesc; csDesc.layout = pl; @@ -258,7 +258,7 @@ void initSim() { updatePipeline = device.CreateComputePipeline(&csDesc); for (uint32_t i = 0; i < 2; ++i) { - updateBGs[i] = utils::MakeBindGroup( + updateBGs[i] = dawn::utils::MakeBindGroup( device, bgl, { {0, updateParams, 0, sizeof(SimParams)}, @@ -281,7 +281,7 @@ wgpu::CommandBuffer createCommandBuffer(const wgpu::TextureView backbufferView, } { - utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView); + dawn::utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); pass.SetPipeline(renderPipeline); pass.SetVertexBuffer(0, bufferDst); @@ -322,9 +322,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); } } diff --git a/src/dawn/samples/CppHelloTriangle.cpp b/src/dawn/samples/CppHelloTriangle.cpp index 8f7299f087..0cb9f5a762 100644 --- a/src/dawn/samples/CppHelloTriangle.cpp +++ b/src/dawn/samples/CppHelloTriangle.cpp @@ -41,14 +41,14 @@ void initBuffers() { 1, 2, }; - indexBuffer = - utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index); + indexBuffer = dawn::utils::CreateBufferFromData(device, indexData, sizeof(indexData), + wgpu::BufferUsage::Index); static const float vertexData[12] = { 0.0f, 0.5f, 0.0f, 1.0f, -0.5f, -0.5f, 0.0f, 1.0f, 0.5f, -0.5f, 0.0f, 1.0f, }; - vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), - wgpu::BufferUsage::Vertex); + vertexBuffer = dawn::utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), + wgpu::BufferUsage::Vertex); } void initTextures() { @@ -71,11 +71,12 @@ void initTextures() { data[i] = static_cast(i % 253); } - wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( + wgpu::Buffer stagingBuffer = dawn::utils::CreateBufferFromData( device, data.data(), static_cast(data.size()), wgpu::BufferUsage::CopySrc); wgpu::ImageCopyBuffer imageCopyBuffer = - utils::CreateImageCopyBuffer(stagingBuffer, 0, 4 * 1024); - wgpu::ImageCopyTexture imageCopyTexture = utils::CreateImageCopyTexture(texture, 0, {0, 0, 0}); + dawn::utils::CreateImageCopyBuffer(stagingBuffer, 0, 4 * 1024); + wgpu::ImageCopyTexture imageCopyTexture = + dawn::utils::CreateImageCopyTexture(texture, 0, {0, 0, 0}); wgpu::Extent3D copySize = {1024, 1024, 1}; wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); @@ -94,13 +95,13 @@ void init() { initBuffers(); initTextures(); - wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( + wgpu::ShaderModule vsModule = dawn::utils::CreateShaderModule(device, R"( @vertex fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f { return pos; })"); - wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( + wgpu::ShaderModule fsModule = dawn::utils::CreateShaderModule(device, R"( @group(0) @binding(0) var mySampler: sampler; @group(0) @binding(1) var myTexture : texture_2d; @@ -109,18 +110,18 @@ void init() { return textureSample(myTexture, mySampler, FragCoord.xy / vec2f(640.0, 480.0)); })"); - auto bgl = utils::MakeBindGroupLayout( + auto bgl = dawn::utils::MakeBindGroupLayout( device, { {0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}, {1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}, }); - wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl); + wgpu::PipelineLayout pl = dawn::utils::MakeBasicPipelineLayout(device, &bgl); depthStencilView = CreateDefaultDepthStencilView(device); - 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.vertex.bufferCount = 1; descriptor.cBuffers[0].arrayStride = 4 * sizeof(float); @@ -134,7 +135,7 @@ void init() { wgpu::TextureView view = texture.CreateView(); - bindGroup = utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, view}}); + bindGroup = dawn::utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, view}}); } struct { @@ -149,7 +150,7 @@ void frame() { } wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView(); - utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView); + dawn::utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView); wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); { @@ -175,9 +176,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); } } diff --git a/src/dawn/samples/ManualSwapChainTest.cpp b/src/dawn/samples/ManualSwapChainTest.cpp index 01c0c9fb0d..5be6a914bf 100644 --- a/src/dawn/samples/ManualSwapChainTest.cpp +++ b/src/dawn/samples/ManualSwapChainTest.cpp @@ -136,7 +136,7 @@ void DoRender(WindowData* data) { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); if (data->renderTriangle) { - utils::ComboRenderPassDescriptor desc({view}); + dawn::utils::ComboRenderPassDescriptor desc({view}); // Use Load to check the swapchain is lazy cleared (we shouldn't see garbage from previous // frames). desc.cColorAttachments[0].loadOp = wgpu::LoadOp::Load; @@ -151,7 +151,7 @@ void DoRender(WindowData* data) { data->clearCycle = 1.0f; } - utils::ComboRenderPassDescriptor desc({view}); + dawn::utils::ComboRenderPassDescriptor desc({view}); desc.cColorAttachments[0].loadOp = wgpu::LoadOp::Clear; desc.cColorAttachments[0].clearValue = {data->clearCycle, 1.0f - data->clearCycle, 0.0f, 1.0f}; @@ -314,8 +314,8 @@ int main(int argc, const char* argv[]) { queue = device.GetQueue(); // The hacky pipeline to render a triangle. - utils::ComboRenderPipelineDescriptor pipelineDesc; - pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( + dawn::utils::ComboRenderPipelineDescriptor pipelineDesc; + pipelineDesc.vertex.module = dawn::utils::CreateShaderModule(device, R"( @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f { var pos = array( @@ -325,7 +325,7 @@ int main(int argc, const char* argv[]) { ); return vec4f(pos[VertexIndex], 0.0, 1.0); })"); - pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( + pipelineDesc.cFragment.module = dawn::utils::CreateShaderModule(device, R"( @fragment fn main() -> @location(0) vec4f { return vec4f(1.0, 0.0, 0.0, 1.0); })"); @@ -337,7 +337,7 @@ int main(int argc, const char* argv[]) { AddWindow(); while (windows.size() != 0) { - utils::ScopedAutoreleasePool pool; + dawn::utils::ScopedAutoreleasePool pool; glfwPollEvents(); wgpuInstanceProcessEvents(instance->Get()); diff --git a/src/dawn/samples/SampleUtils.cpp b/src/dawn/samples/SampleUtils.cpp index 0dc2eee658..9d11d889c2 100644 --- a/src/dawn/samples/SampleUtils.cpp +++ b/src/dawn/samples/SampleUtils.cpp @@ -102,15 +102,15 @@ static GLFWwindow* window = nullptr; static dawn::wire::WireServer* wireServer = nullptr; static dawn::wire::WireClient* wireClient = nullptr; -static utils::TerribleCommandBuffer* c2sBuf = nullptr; -static utils::TerribleCommandBuffer* s2cBuf = nullptr; +static dawn::utils::TerribleCommandBuffer* c2sBuf = nullptr; +static dawn::utils::TerribleCommandBuffer* s2cBuf = nullptr; static constexpr uint32_t kWidth = 640; static constexpr uint32_t kHeight = 480; wgpu::Device CreateCppDawnDevice() { - ScopedEnvironmentVar angleDefaultPlatform; - if (GetEnvironmentVar("ANGLE_DEFAULT_PLATFORM").first.empty()) { + dawn::ScopedEnvironmentVar angleDefaultPlatform; + if (dawn::GetEnvironmentVar("ANGLE_DEFAULT_PLATFORM").first.empty()) { angleDefaultPlatform.Set("ANGLE_DEFAULT_PLATFORM", "swiftshader"); } @@ -194,8 +194,8 @@ wgpu::Device CreateCppDawnDevice() { break; case CmdBufType::Terrible: { - c2sBuf = new utils::TerribleCommandBuffer(); - s2cBuf = new utils::TerribleCommandBuffer(); + c2sBuf = new dawn::utils::TerribleCommandBuffer(); + s2cBuf = new dawn::utils::TerribleCommandBuffer(); dawn::wire::WireServerDescriptor serverDesc = {}; serverDesc.procs = &backendProcs; diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index 0b8f1bab79..73a4fccc90 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp @@ -171,8 +171,8 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) { ParseArgs(argc, argv); if (mBackendValidationLevel != dawn::native::BackendValidationLevel::Disabled) { - mPlatformDebugLogger = - std::unique_ptr(utils::CreatePlatformDebugLogger()); + mPlatformDebugLogger = std::unique_ptr( + dawn::utils::CreatePlatformDebugLogger()); } // Create a temporary instance to select available and preferred adapters. This is done before @@ -397,7 +397,7 @@ std::unique_ptr DawnTestEnvironment::CreateInstanceAndDi instance->EnableAdapterBlocklist(false); #ifdef DAWN_ENABLE_BACKEND_OPENGLES - if (GetEnvironmentVar("ANGLE_DEFAULT_PLATFORM").first.empty()) { + if (dawn::GetEnvironmentVar("ANGLE_DEFAULT_PLATFORM").first.empty()) { const char* platform; if (!mANGLEBackend.empty()) { platform = mANGLEBackend.c_str(); @@ -408,7 +408,7 @@ std::unique_ptr DawnTestEnvironment::CreateInstanceAndDi platform = "swiftshader"; #endif } - SetEnvironmentVar("ANGLE_DEFAULT_PLATFORM", platform); + dawn::SetEnvironmentVar("ANGLE_DEFAULT_PLATFORM", platform); } #endif // DAWN_ENABLE_BACKEND_OPENGLES @@ -718,7 +718,8 @@ DawnTestBase::DawnTestBase(const AdapterTestParam& param) : mParam(param) { callback(WGPURequestDeviceStatus_Success, cDevice, nullptr, userdata); }; - mWireHelper = utils::CreateWireHelper(procs, gTestEnv->UsesWire(), gTestEnv->GetWireTraceDir()); + mWireHelper = + dawn::utils::CreateWireHelper(procs, gTestEnv->UsesWire(), gTestEnv->GetWireTraceDir()); } DawnTestBase::~DawnTestBase() { @@ -770,36 +771,36 @@ bool DawnTestBase::IsVulkan() const { } bool DawnTestBase::IsAMD() const { - return gpu_info::IsAMD(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsAMD(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsApple() const { - return gpu_info::IsApple(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsApple(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsARM() const { - return gpu_info::IsARM(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsARM(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsImgTec() const { - return gpu_info::IsImgTec(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsImgTec(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsIntel() const { - return gpu_info::IsIntel(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsIntel(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsNvidia() const { - return gpu_info::IsNvidia(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsNvidia(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsQualcomm() const { - return gpu_info::IsQualcomm(mParam.adapterProperties.vendorID); + return dawn::gpu_info::IsQualcomm(mParam.adapterProperties.vendorID); } bool DawnTestBase::IsSwiftshader() const { - return gpu_info::IsGoogleSwiftshader(mParam.adapterProperties.vendorID, - mParam.adapterProperties.deviceID); + return dawn::gpu_info::IsGoogleSwiftshader(mParam.adapterProperties.vendorID, + mParam.adapterProperties.deviceID); } bool DawnTestBase::IsANGLE() const { @@ -812,15 +813,15 @@ bool DawnTestBase::IsANGLESwiftShader() const { } bool DawnTestBase::IsWARP() const { - return gpu_info::IsMicrosoftWARP(mParam.adapterProperties.vendorID, - mParam.adapterProperties.deviceID); + return dawn::gpu_info::IsMicrosoftWARP(mParam.adapterProperties.vendorID, + mParam.adapterProperties.deviceID); } bool DawnTestBase::IsIntelGen12() const { - return gpu_info::IsIntelGen12LP(mParam.adapterProperties.vendorID, - mParam.adapterProperties.deviceID) || - gpu_info::IsIntelGen12HP(mParam.adapterProperties.vendorID, - mParam.adapterProperties.deviceID); + return dawn::gpu_info::IsIntelGen12LP(mParam.adapterProperties.vendorID, + mParam.adapterProperties.deviceID) || + dawn::gpu_info::IsIntelGen12HP(mParam.adapterProperties.vendorID, + mParam.adapterProperties.deviceID); } bool DawnTestBase::IsWindows() const { @@ -845,7 +846,7 @@ bool DawnTestBase::IsMacOS(int32_t majorVersion, int32_t minorVersion) const { return true; } int32_t majorVersionOut, minorVersionOut = 0; - GetMacOSVersion(&majorVersionOut, &minorVersionOut); + dawn::GetMacOSVersion(&majorVersionOut, &minorVersionOut); return (majorVersion != -1 && majorVersion == majorVersionOut) && (minorVersion != -1 && minorVersion == minorVersionOut); #else @@ -1146,7 +1147,7 @@ std::ostringstream& DawnTestBase::AddBufferExpectation(const char* file, uint64_t offset, uint64_t size, detail::Expectation* expectation) { - uint64_t alignedSize = Align(size, uint64_t(4)); + uint64_t alignedSize = dawn::Align(size, uint64_t(4)); auto readback = ReserveReadback(device, alignedSize); // We need to enqueue the copy immediately because by the time we resolve the expectation, @@ -1187,24 +1188,25 @@ std::ostringstream& DawnTestBase::AddTextureExpectationImpl(const char* file, ASSERT(targetDevice != nullptr); if (bytesPerRow == 0) { - bytesPerRow = Align(extent.width * dataSize, kTextureBytesPerRowAlignment); + bytesPerRow = dawn::Align(extent.width * dataSize, kTextureBytesPerRowAlignment); } else { ASSERT(bytesPerRow >= extent.width * dataSize); - ASSERT(bytesPerRow == Align(bytesPerRow, kTextureBytesPerRowAlignment)); + ASSERT(bytesPerRow == dawn::Align(bytesPerRow, kTextureBytesPerRowAlignment)); } uint32_t rowsPerImage = extent.height; - uint32_t size = utils::RequiredBytesInCopy(bytesPerRow, rowsPerImage, extent.width, - extent.height, extent.depthOrArrayLayers, dataSize); + uint32_t size = + dawn::utils::RequiredBytesInCopy(bytesPerRow, rowsPerImage, extent.width, extent.height, + extent.depthOrArrayLayers, dataSize); - auto readback = ReserveReadback(targetDevice, Align(size, 4)); + auto readback = ReserveReadback(targetDevice, dawn::Align(size, 4)); // We need to enqueue the copy immediately because by the time we resolve the expectation, // the texture might have been modified. wgpu::ImageCopyTexture imageCopyTexture = - utils::CreateImageCopyTexture(texture, level, origin, aspect); - wgpu::ImageCopyBuffer imageCopyBuffer = - utils::CreateImageCopyBuffer(readback.buffer, readback.offset, bytesPerRow, rowsPerImage); + dawn::utils::CreateImageCopyTexture(texture, level, origin, aspect); + wgpu::ImageCopyBuffer imageCopyBuffer = dawn::utils::CreateImageCopyBuffer( + readback.buffer, readback.offset, bytesPerRow, rowsPerImage); wgpu::CommandEncoder encoder = targetDevice.CreateCommandEncoder(); encoder.CopyTextureToBuffer(&imageCopyTexture, &imageCopyBuffer, &extent); @@ -1284,7 +1286,8 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t } )"; - wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shaderSource.str().c_str()); + wgpu::ShaderModule csModule = + dawn::utils::CreateShaderModule(device, shaderSource.str().c_str()); wgpu::ComputePipelineDescriptor pipelineDescriptor; pipelineDescriptor.compute.module = csModule; @@ -1295,12 +1298,12 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t // Create and initialize the slot buffer so that it won't unexpectedly affect the count of // resources lazily cleared. const std::vector initialBufferData(width * height * componentCount * sampleCount, 0.f); - wgpu::Buffer readbackBuffer = utils::CreateBufferFromData( + wgpu::Buffer readbackBuffer = dawn::utils::CreateBufferFromData( device, initialBufferData.data(), sizeof(float) * initialBufferData.size(), wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage); - wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), - {{0, textureView}, {1, readbackBuffer}}); + wgpu::BindGroup bindGroup = dawn::utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), + {{0, textureView}, {1, readbackBuffer}}); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::ComputePassEncoder pass = commandEncoder.BeginComputePass(); @@ -1399,9 +1402,9 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData( // Upload the depth data. wgpu::ImageCopyTexture imageCopyTexture = - utils::CreateImageCopyTexture(depthDataTexture, 0, {0, 0, 0}); + dawn::utils::CreateImageCopyTexture(depthDataTexture, 0, {0, 0, 0}); wgpu::TextureDataLayout textureDataLayout = - utils::CreateTextureDataLayout(0, sizeof(float) * width); + dawn::utils::CreateTextureDataLayout(0, sizeof(float) * width); wgpu::Extent3D copyExtent = {width, height, 1}; queue.WriteTexture(&imageCopyTexture, expectedDepth.data(), @@ -1409,9 +1412,9 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData( } // Pipeline for a full screen quad. - utils::ComboRenderPipelineDescriptor pipelineDescriptor; + dawn::utils::ComboRenderPipelineDescriptor pipelineDescriptor; - pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( + pipelineDescriptor.vertex.module = dawn::utils::CreateShaderModule(device, R"( @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f { var pos = array( @@ -1424,7 +1427,7 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData( if (depthDataTexture) { // Sample the input texture and write out depth. |result| will only be set to 1 if we // pass the depth test. - pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( + pipelineDescriptor.cFragment.module = dawn::utils::CreateShaderModule(device, R"( @group(0) @binding(0) var texture0 : texture_2d; struct FragmentOut { @@ -1440,7 +1443,7 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData( return output; })"); } else { - pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( + pipelineDescriptor.cFragment.module = dawn::utils::CreateShaderModule(device, R"( @fragment fn main() -> @location(0) u32 { return 1u; @@ -1466,8 +1469,8 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData( viewDesc.baseArrayLayer = arrayLayer; viewDesc.arrayLayerCount = 1; - utils::ComboRenderPassDescriptor passDescriptor({colorTexture.CreateView()}, - texture.CreateView(&viewDesc)); + dawn::utils::ComboRenderPassDescriptor passDescriptor({colorTexture.CreateView()}, + texture.CreateView(&viewDesc)); passDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = wgpu::LoadOp::Load; passDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = wgpu::LoadOp::Load; switch (format) { @@ -1494,8 +1497,8 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData( pass.SetPipeline(pipeline); if (depthDataTexture) { // Bind the depth data texture. - pass.SetBindGroup(0, utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), - {{0, depthDataTexture.CreateView()}})); + pass.SetBindGroup(0, dawn::utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), + {{0, depthDataTexture.CreateView()}})); } pass.Draw(3); pass.End(); @@ -1516,7 +1519,7 @@ void DawnTestBase::WaitABit(wgpu::Instance targetInstance) { } FlushWire(); - utils::USleep(100); + dawn::utils::USleep(100); } void DawnTestBase::FlushWire() { @@ -1553,8 +1556,8 @@ DawnTestBase::ReadbackReservation DawnTestBase::ReserveReadback(wgpu::Device tar // resource lazy clear in the tests. const std::vector initialBufferData(readbackSize, 0u); slot.buffer = - utils::CreateBufferFromData(targetDevice, initialBufferData.data(), readbackSize, - wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst); + dawn::utils::CreateBufferFromData(targetDevice, initialBufferData.data(), readbackSize, + wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst); // This readback might be called from multiple threads dawn::Mutex::AutoLock lg(&mMutex); @@ -1675,19 +1678,19 @@ void DawnTestBase::ResolveDeferredExpectationsNow() { } } -bool utils::RGBA8::operator==(const utils::RGBA8& other) const { +bool dawn::utils::RGBA8::operator==(const dawn::utils::RGBA8& other) const { return r == other.r && g == other.g && b == other.b && a == other.a; } -bool utils::RGBA8::operator!=(const utils::RGBA8& other) const { +bool dawn::utils::RGBA8::operator!=(const dawn::utils::RGBA8& other) const { return !(*this == other); } -bool utils::RGBA8::operator<=(const utils::RGBA8& other) const { +bool dawn::utils::RGBA8::operator<=(const dawn::utils::RGBA8& other) const { return (r <= other.r && g <= other.g && b <= other.b && a <= other.a); } -bool utils::RGBA8::operator>=(const utils::RGBA8& other) const { +bool dawn::utils::RGBA8::operator>=(const dawn::utils::RGBA8& other) const { return (r >= other.r && g >= other.g && b >= other.b && a >= other.a); } @@ -1724,12 +1727,12 @@ testing::AssertionResult CheckImpl(const T& expected, const U& actual, const T& } template <> -testing::AssertionResult CheckImpl(const utils::RGBA8& expected, - const utils::RGBA8& actual, - const utils::RGBA8& tolerance) { +testing::AssertionResult CheckImpl(const dawn::utils::RGBA8& expected, + const dawn::utils::RGBA8& actual, + const dawn::utils::RGBA8& tolerance) { if (abs(expected.r - actual.r) > tolerance.r || abs(expected.g - actual.g) > tolerance.g || abs(expected.b - actual.b) > tolerance.b || abs(expected.a - actual.a) > tolerance.a) { - return tolerance == utils::RGBA8{} + return tolerance == dawn::utils::RGBA8{} ? testing::AssertionFailure() << expected << ", actual " << actual : testing::AssertionFailure() << "within " << tolerance << " of " << expected << ", actual " << actual; @@ -1767,7 +1770,7 @@ template <> testing::AssertionResult CheckImpl(const float& expected, const uint16_t& actual, const float& tolerance) { - float actualF32 = Float16ToFloat32(actual); + float actualF32 = dawn::Float16ToFloat32(actual); if (abs(expected - actualF32) > tolerance) { return tolerance == 0.0 ? testing::AssertionFailure() << expected << ", actual " << actualF32 @@ -1835,7 +1838,7 @@ template class ExpectEq; template class ExpectEq; template class ExpectEq; template class ExpectEq; -template class ExpectEq; +template class ExpectEq; template class ExpectEq; template class ExpectEq; @@ -1892,5 +1895,5 @@ testing::AssertionResult ExpectBetweenColors::Check(const void* data, size_t return testing::AssertionSuccess(); } -template class ExpectBetweenColors; +template class ExpectBetweenColors; } // namespace detail diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h index e76365928e..ea5dc00e10 100644 --- a/src/dawn/tests/DawnTest.h +++ b/src/dawn/tests/DawnTest.h @@ -127,11 +127,11 @@ struct GLFWwindow; -namespace utils { +namespace dawn::utils { class PlatformDebugLogger; class TerribleCommandBuffer; class WireHelper; -} // namespace utils +} // namespace dawn::utils namespace detail { class Expectation; @@ -214,7 +214,7 @@ class DawnTestEnvironment : public testing::Environment { std::vector mDevicePreferences; std::vector mAdapterProperties; - std::unique_ptr mPlatformDebugLogger; + std::unique_ptr mPlatformDebugLogger; }; class DawnTestBase { @@ -352,8 +352,9 @@ class DawnTestBase { uint32_t level = 0, wgpu::TextureAspect aspect = wgpu::TextureAspect::All, uint32_t bytesPerRow = 0) { - uint32_t texelBlockSize = utils::GetTexelBlockSizeInBytes(format); - uint32_t texelComponentCount = utils::GetWGSLRenderableColorTextureComponentCount(format); + uint32_t texelBlockSize = dawn::utils::GetTexelBlockSizeInBytes(format); + uint32_t texelComponentCount = + dawn::utils::GetWGSLRenderableColorTextureComponentCount(format); return AddTextureExpectationImpl( file, line, std::move(targetDevice), @@ -583,9 +584,9 @@ class DawnTestBase { void* GetUniqueUserdata(); private: - utils::ScopedAutoreleasePool mObjCAutoreleasePool; + dawn::utils::ScopedAutoreleasePool mObjCAutoreleasePool; AdapterTestParam mParam; - std::unique_ptr mWireHelper; + std::unique_ptr mWireHelper; wgpu::Instance mInstance; wgpu::Adapter mAdapter; @@ -836,7 +837,7 @@ extern template class ExpectEq; extern template class ExpectEq; extern template class ExpectEq; extern template class ExpectEq; -extern template class ExpectEq; +extern template class ExpectEq; extern template class ExpectEq; extern template class ExpectEq; @@ -858,7 +859,7 @@ class ExpectBetweenColors : public Expectation { // A color is considered between color0 and color1 when all channel values are within range of // each counterparts. It doesn't matter which value is higher or lower. Essentially color = // lerp(color0, color1, t) where t is [0,1]. But I don't want to be too strict here. -extern template class ExpectBetweenColors; +extern template class ExpectBetweenColors; class CustomTextureExpectation : public Expectation { public: diff --git a/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp b/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp index 18ab303a93..904272d52f 100644 --- a/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp +++ b/src/dawn/tests/end2end/AdapterDiscoveryTests.cpp @@ -47,6 +47,7 @@ #include +namespace dawn { namespace { using testing::_; @@ -58,9 +59,9 @@ class AdapterDiscoveryTests : public ::testing::Test {}; #if defined(DAWN_ENABLE_BACKEND_VULKAN) // Test only discovering the SwiftShader adapter TEST(AdapterDiscoveryTests, OnlySwiftShader) { - dawn::native::Instance instance; + native::Instance instance; - dawn::native::vulkan::AdapterDiscoveryOptions options; + native::vulkan::AdapterDiscoveryOptions options; options.forceSwiftShader = true; instance.DiscoverAdapters(&options); @@ -78,9 +79,9 @@ TEST(AdapterDiscoveryTests, OnlySwiftShader) { // Test discovering only Vulkan adapters TEST(AdapterDiscoveryTests, OnlyVulkan) { - dawn::native::Instance instance; + native::Instance instance; - dawn::native::vulkan::AdapterDiscoveryOptions options; + native::vulkan::AdapterDiscoveryOptions options; instance.DiscoverAdapters(&options); const auto& adapters = instance.GetAdapters(); @@ -96,9 +97,9 @@ TEST(AdapterDiscoveryTests, OnlyVulkan) { #if defined(DAWN_ENABLE_BACKEND_D3D11) // Test discovering only D3D11 adapters TEST(AdapterDiscoveryTests, OnlyD3D11) { - dawn::native::Instance instance; + native::Instance instance; - dawn::native::d3d11::AdapterDiscoveryOptions options; + native::d3d11::AdapterDiscoveryOptions options; instance.DiscoverAdapters(&options); const auto& adapters = instance.GetAdapters(); @@ -124,9 +125,9 @@ TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D11) { break; // No more adapters to enumerate. } - dawn::native::Instance instance; + native::Instance instance; - dawn::native::d3d11::AdapterDiscoveryOptions options; + native::d3d11::AdapterDiscoveryOptions options; options.dxgiAdapter = std::move(dxgiAdapter); instance.DiscoverAdapters(&options); @@ -144,9 +145,9 @@ TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D11) { #if defined(DAWN_ENABLE_BACKEND_D3D12) // Test discovering only D3D12 adapters TEST(AdapterDiscoveryTests, OnlyD3D12) { - dawn::native::Instance instance; + native::Instance instance; - dawn::native::d3d12::AdapterDiscoveryOptions options; + native::d3d12::AdapterDiscoveryOptions options; instance.DiscoverAdapters(&options); const auto& adapters = instance.GetAdapters(); @@ -172,9 +173,9 @@ TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D12) { break; // No more adapters to enumerate. } - dawn::native::Instance instance; + native::Instance instance; - dawn::native::d3d12::AdapterDiscoveryOptions options; + native::d3d12::AdapterDiscoveryOptions options; options.dxgiAdapter = std::move(dxgiAdapter); instance.DiscoverAdapters(&options); @@ -192,9 +193,9 @@ TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D12) { #if defined(DAWN_ENABLE_BACKEND_METAL) // Test discovering only Metal adapters TEST(AdapterDiscoveryTests, OnlyMetal) { - dawn::native::Instance instance; + native::Instance instance; - dawn::native::metal::AdapterDiscoveryOptions options; + native::metal::AdapterDiscoveryOptions options; instance.DiscoverAdapters(&options); const auto& adapters = instance.GetAdapters(); @@ -211,10 +212,10 @@ TEST(AdapterDiscoveryTests, OnlyMetal) { // Test discovering the Metal backend, then the Vulkan backend // does not duplicate adapters. TEST(AdapterDiscoveryTests, OneBackendThenTheOther) { - dawn::native::Instance instance; + native::Instance instance; uint32_t metalAdapterCount = 0; { - dawn::native::metal::AdapterDiscoveryOptions options; + native::metal::AdapterDiscoveryOptions options; instance.DiscoverAdapters(&options); const auto& adapters = instance.GetAdapters(); @@ -227,7 +228,7 @@ TEST(AdapterDiscoveryTests, OneBackendThenTheOther) { } } { - dawn::native::vulkan::AdapterDiscoveryOptions options; + native::vulkan::AdapterDiscoveryOptions options; instance.DiscoverAdapters(&options); uint32_t metalAdapterCount2 = 0; @@ -445,3 +446,4 @@ TEST_F(AdapterCreationTest, GetInstance) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/BindGroupTests.cpp b/src/dawn/tests/end2end/BindGroupTests.cpp index 79075300be..d01089a6ad 100644 --- a/src/dawn/tests/end2end/BindGroupTests.cpp +++ b/src/dawn/tests/end2end/BindGroupTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static uint32_t kRTSize = 8; class BindGroupTests : public DawnTest { @@ -1330,8 +1333,8 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) { // This is a regression test for crbug.com/dawn/355 which tests that destruction of a bind group // that holds the last reference to its bind group layout does not result in a use-after-free. In // the bug, the destructor of BindGroupBase, when destroying member mLayout, -// Ref assigns to Ref::mPointee, AFTER calling Release(). After the BGL is -// destroyed, the storage for |mPointee| has been freed. +// Ref assigns to Ref::mPointee, AFTER calling Release(). After the BGL +// is destroyed, the storage for |mPointee| has been freed. TEST_P(BindGroupTests, LastReferenceToBindGroupLayout) { wgpu::BufferDescriptor bufferDesc; bufferDesc.size = sizeof(float); @@ -1513,3 +1516,6 @@ DAWN_INSTANTIATE_TEST(BindGroupTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/BufferZeroInitTests.cpp b/src/dawn/tests/end2end/BufferZeroInitTests.cpp index ee5997a3c1..973223a317 100644 --- a/src/dawn/tests/end2end/BufferZeroInitTests.cpp +++ b/src/dawn/tests/end2end/BufferZeroInitTests.cpp @@ -20,20 +20,21 @@ #include "dawn/utils/TestUtils.h" #include "dawn/utils/WGPUHelpers.h" -#define EXPECT_LAZY_CLEAR(N, statement) \ - do { \ - if (UsesWire()) { \ - statement; \ - } else { \ - size_t lazyClearsBefore = dawn::native::GetLazyClearCountForTesting(device.Get()); \ - statement; \ - size_t lazyClearsAfter = dawn::native::GetLazyClearCountForTesting(device.Get()); \ - EXPECT_EQ(N, lazyClearsAfter - lazyClearsBefore); \ - } \ - } while (0) - +namespace dawn { namespace { +#define EXPECT_LAZY_CLEAR(N, statement) \ + do { \ + if (UsesWire()) { \ + statement; \ + } else { \ + size_t lazyClearsBefore = native::GetLazyClearCountForTesting(device.Get()); \ + statement; \ + size_t lazyClearsAfter = native::GetLazyClearCountForTesting(device.Get()); \ + EXPECT_EQ(N, lazyClearsAfter - lazyClearsBefore); \ + } \ + } while (0) + struct BufferZeroInitInCopyT2BSpec { wgpu::Extent3D textureSize; uint64_t bufferOffset; @@ -43,8 +44,6 @@ struct BufferZeroInitInCopyT2BSpec { uint32_t lazyClearCount; }; -} // anonymous namespace - class BufferZeroInitTest : public DawnTest { protected: std::vector GetRequiredFeatures() override { @@ -1388,3 +1387,6 @@ DAWN_INSTANTIATE_TEST(BufferZeroInitTest, OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}), OpenGLESBackend({"nonzero_clear_resources_on_creation_for_testing"}), VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ClipSpaceTests.cpp b/src/dawn/tests/end2end/ClipSpaceTests.cpp index 5f8c07e02a..1a872a77d7 100644 --- a/src/dawn/tests/end2end/ClipSpaceTests.cpp +++ b/src/dawn/tests/end2end/ClipSpaceTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ClipSpaceTest : public DawnTest { protected: wgpu::RenderPipeline CreatePipelineForTest() { @@ -99,3 +102,6 @@ DAWN_INSTANTIATE_TEST(ClipSpaceTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ColorStateTests.cpp b/src/dawn/tests/end2end/ColorStateTests.cpp index c5e35b144f..0cd08144fb 100644 --- a/src/dawn/tests/end2end/ColorStateTests.cpp +++ b/src/dawn/tests/end2end/ColorStateTests.cpp @@ -24,6 +24,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 64; class ColorStateTest : public DawnTest { @@ -1195,3 +1198,6 @@ DAWN_INSTANTIATE_TEST(ColorStateTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CommandEncoderTests.cpp b/src/dawn/tests/end2end/CommandEncoderTests.cpp index 14f227e7a7..d608cd8489 100644 --- a/src/dawn/tests/end2end/CommandEncoderTests.cpp +++ b/src/dawn/tests/end2end/CommandEncoderTests.cpp @@ -15,6 +15,9 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class CommandEncoderTests : public DawnTest {}; // Tests WriteBuffer commands on CommandEncoder. @@ -52,3 +55,6 @@ DAWN_INSTANTIATE_TEST(CommandEncoderTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp b/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp index 17b8bca721..705c19d0cd 100644 --- a/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp @@ -23,6 +23,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // The helper struct to configure the copies between buffers and textures. struct CopyConfig { wgpu::TextureDescriptor textureDescriptor; @@ -34,10 +37,8 @@ struct CopyConfig { uint32_t rowsPerImage = wgpu::kCopyStrideUndefined; }; -namespace { using TextureFormat = wgpu::TextureFormat; DAWN_TEST_PARAM_STRUCT(CompressedTextureFormatTestParams, TextureFormat); -} // namespace class CompressedTextureFormatTest : public DawnTestWithParams { protected: @@ -1324,3 +1325,6 @@ DAWN_INSTANTIATE_TEST_P(CompressedTextureWriteTextureTest, OpenGLESBackend(), VulkanBackend()}, std::vector(utils::kCompressedFormats.begin(), utils::kCompressedFormats.end())); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ComputeCopyStorageBufferTests.cpp b/src/dawn/tests/end2end/ComputeCopyStorageBufferTests.cpp index 4cd8fe56a2..3a179467bd 100644 --- a/src/dawn/tests/end2end/ComputeCopyStorageBufferTests.cpp +++ b/src/dawn/tests/end2end/ComputeCopyStorageBufferTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ComputeCopyStorageBufferTests : public DawnTest { public: static constexpr int kInstances = 4; @@ -151,3 +154,6 @@ DAWN_INSTANTIATE_TEST(ComputeCopyStorageBufferTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ComputeDispatchTests.cpp b/src/dawn/tests/end2end/ComputeDispatchTests.cpp index 005d32cb91..7e372e35dd 100644 --- a/src/dawn/tests/end2end/ComputeDispatchTests.cpp +++ b/src/dawn/tests/end2end/ComputeDispatchTests.cpp @@ -18,6 +18,9 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static std::initializer_list kSentinelData{0, 0, 0}; class ComputeDispatchTests : public DawnTest { @@ -319,3 +322,6 @@ DAWN_INSTANTIATE_TEST(ComputeDispatchTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ComputeFlowControlTests.cpp b/src/dawn/tests/end2end/ComputeFlowControlTests.cpp index 6c22093898..7fffb8e2b8 100644 --- a/src/dawn/tests/end2end/ComputeFlowControlTests.cpp +++ b/src/dawn/tests/end2end/ComputeFlowControlTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // Tests flow control in WGSL shaders. This helps to identify bugs either in Tint's WGSL // compilation, or driver shader compilation. class ComputeFlowControlTests : public DawnTest { @@ -506,3 +509,6 @@ DAWN_INSTANTIATE_TEST(ComputeFlowControlTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp index ae15fee9f9..54bbb63589 100644 --- a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp +++ b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp @@ -22,6 +22,7 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { // Helper for replacing all occurrences of substr in str with replacement @@ -594,9 +595,9 @@ fn main() { })"; // https://www.w3.org/TR/WGSL/#alignment-and-size - // Structure size: roundUp(AlignOf(S), OffsetOf(S, L) + SizeOf(S, L)) + // Structure size: RoundUp(AlignOf(S), OffsetOf(S, L) + SizeOf(S, L)) // https://www.w3.org/TR/WGSL/#storage-class-constraints - // RequiredAlignOf(S, uniform): roundUp(16, max(AlignOf(T0), ..., AlignOf(TN))) + // RequiredAlignOf(S, uniform): RoundUp(16, max(AlignOf(T0), ..., AlignOf(TN))) uint32_t dataAlign = isUniform ? std::max(size_t(16u), field.GetAlign()) : field.GetAlign(); // https://www.w3.org/TR/WGSL/#structure-layout-rules @@ -1152,4 +1153,5 @@ INSTANTIATE_TEST_SUITE_P(, DawnTestBase::PrintToStringParamName("ComputeLayoutMemoryBufferTests")); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ComputeLayoutMemoryBufferTests); -} // namespace +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp b/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp index 57ad5b6118..a1857f5f3c 100644 --- a/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp +++ b/src/dawn/tests/end2end/ComputeSharedMemoryTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ComputeSharedMemoryTests : public DawnTest { public: static constexpr uint32_t kInstances = 11; @@ -204,3 +207,6 @@ DAWN_INSTANTIATE_TEST(ComputeSharedMemoryTests, OpenGLESBackend(), VulkanBackend(), VulkanBackend({}, {"use_vulkan_zero_initialize_workgroup_memory_extension"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ComputeStorageBufferBarrierTests.cpp b/src/dawn/tests/end2end/ComputeStorageBufferBarrierTests.cpp index e2319d7a90..4abcfc59a4 100644 --- a/src/dawn/tests/end2end/ComputeStorageBufferBarrierTests.cpp +++ b/src/dawn/tests/end2end/ComputeStorageBufferBarrierTests.cpp @@ -17,6 +17,9 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ComputeStorageBufferBarrierTests : public DawnTest { protected: static constexpr uint32_t kNumValues = 100; @@ -415,3 +418,6 @@ DAWN_INSTANTIATE_TEST(ComputeStorageBufferBarrierTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CopyExternalTextureForBrowserTests.cpp b/src/dawn/tests/end2end/CopyExternalTextureForBrowserTests.cpp index b2ec4428b0..530ab8bebb 100644 --- a/src/dawn/tests/end2end/CopyExternalTextureForBrowserTests.cpp +++ b/src/dawn/tests/end2end/CopyExternalTextureForBrowserTests.cpp @@ -18,6 +18,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { wgpu::Texture Create2DTexture(wgpu::Device device, @@ -275,7 +276,6 @@ class CopyExternalTextureForBrowserTests_Basic EXPECT_TEXTURE_EQ(expected.data(), dstTexture, dstOrigin, copySize); } }; -} // anonymous namespace TEST_P(CopyExternalTextureForBrowserTests_Basic, Copy) { DAWN_SUPPRESS_TEST_IF(IsOpenGLES()); @@ -386,3 +386,6 @@ DAWN_INSTANTIATE_TEST_P( CopyRect::BottomRight, CopyRect::FullSize}), std::vector({ScaleType::UpScale, ScaleType::DownScale, ScaleType::NoScale}), std::vector({false, true})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CopyTests.cpp b/src/dawn/tests/end2end/CopyTests.cpp index 012f4b0241..fd6d3d991b 100644 --- a/src/dawn/tests/end2end/CopyTests.cpp +++ b/src/dawn/tests/end2end/CopyTests.cpp @@ -23,6 +23,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // For MinimumBufferSpec bytesPerRow and rowsPerImage, compute a default from the copy extent. constexpr uint32_t kStrideComputeDefault = 0xFFFF'FFFEul; @@ -2922,3 +2925,6 @@ DAWN_INSTANTIATE_TEST(T2TCopyFromDirtyHeapTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp b/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp index 91c65a2944..a6dd7aff8c 100644 --- a/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp +++ b/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp @@ -22,7 +22,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + static constexpr wgpu::TextureFormat kTextureFormat = wgpu::TextureFormat::RGBA8Unorm; // Set default texture size to single line texture for color conversion tests. @@ -148,7 +150,6 @@ static constexpr std::array ColorSpac } // }}; -} // anonymous namespace template class CopyTextureForBrowserTests : public Parent { @@ -1225,3 +1226,6 @@ DAWN_INSTANTIATE_TEST_P(CopyTextureForBrowser_ColorSpace, wgpu::AlphaMode::Unpremultiplied}), std::vector({wgpu::AlphaMode::Premultiplied, wgpu::AlphaMode::Unpremultiplied})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp b/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp index 5d945be8a2..966da24469 100644 --- a/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp +++ b/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp @@ -18,14 +18,15 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + struct CreatePipelineAsyncTask { wgpu::ComputePipeline computePipeline = nullptr; wgpu::RenderPipeline renderPipeline = nullptr; bool isCompleted = false; std::string message; }; -} // anonymous namespace class CreatePipelineAsyncTest : public DawnTest { protected: @@ -961,3 +962,6 @@ DAWN_INSTANTIATE_TEST(CreatePipelineAsyncTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/CullingTests.cpp b/src/dawn/tests/end2end/CullingTests.cpp index 47d30cc490..f388b2cf01 100644 --- a/src/dawn/tests/end2end/CullingTests.cpp +++ b/src/dawn/tests/end2end/CullingTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class CullingTest : public DawnTest { protected: wgpu::RenderPipeline CreatePipelineForTest(wgpu::FrontFace frontFace, wgpu::CullMode cullMode) { @@ -133,3 +136,6 @@ DAWN_INSTANTIATE_TEST(CullingTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/D3D12CachingTests.cpp b/src/dawn/tests/end2end/D3D12CachingTests.cpp index db1bdd2c72..7c27171fe2 100644 --- a/src/dawn/tests/end2end/D3D12CachingTests.cpp +++ b/src/dawn/tests/end2end/D3D12CachingTests.cpp @@ -21,9 +21,10 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + using ::testing::NiceMock; -} // namespace class D3D12CachingTests : public DawnTest { protected: @@ -33,7 +34,7 @@ class D3D12CachingTests : public DawnTest { DAWN_SKIP_TEST_IF_BASE(true, "suppressed", "TODO(dawn:1341)"); } - std::unique_ptr CreateTestPlatform() override { + std::unique_ptr CreateTestPlatform() override { return std::make_unique(&mMockCache); } @@ -181,3 +182,6 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) { } DAWN_INSTANTIATE_TEST(D3D12CachingTests, D3D12Backend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/D3DResourceWrappingTests.cpp b/src/dawn/tests/end2end/D3DResourceWrappingTests.cpp index 2ad995993b..f48c0c9144 100644 --- a/src/dawn/tests/end2end/D3DResourceWrappingTests.cpp +++ b/src/dawn/tests/end2end/D3DResourceWrappingTests.cpp @@ -32,6 +32,7 @@ using Microsoft::WRL::ComPtr; +namespace dawn { namespace { class D3DResourceTestBase : public DawnTest { @@ -48,8 +49,7 @@ class D3DResourceTestBase : public DawnTest { } // Create the D3D11 device/contexts that will be used in subsequent tests - ComPtr dxgiAdapter = - dawn::native::d3d::GetDXGIAdapter(device.GetAdapter().Get()); + ComPtr dxgiAdapter = native::d3d::GetDXGIAdapter(device.GetAdapter().Get()); DXGI_ADAPTER_DESC adapterDesc; HRESULT hr = dxgiAdapter->GetDesc(&adapterDesc); @@ -98,7 +98,7 @@ class D3DResourceTestBase : public DawnTest { } protected: - std::unique_ptr CreateExternalImage( + std::unique_ptr CreateExternalImage( WGPUDevice targetDevice, ID3D11Texture2D* d3d11Texture, const wgpu::TextureDescriptor* dawnDesc) const { @@ -111,13 +111,13 @@ class D3DResourceTestBase : public DawnTest { &textureSharedHandle), S_OK); - dawn::native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc; + native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc; externalImageDesc.cTextureDescriptor = reinterpret_cast(dawnDesc); externalImageDesc.sharedHandle = textureSharedHandle; - std::unique_ptr externalImage = - dawn::native::d3d::ExternalImageDXGI::Create(targetDevice, &externalImageDesc); + std::unique_ptr externalImage = + native::d3d::ExternalImageDXGI::Create(targetDevice, &externalImageDesc); // Now that we've created all of our resources, we can close the handle // since we no longer need it. @@ -126,17 +126,16 @@ class D3DResourceTestBase : public DawnTest { return externalImage; } - void WrapSharedHandle( - const wgpu::TextureDescriptor* dawnDesc, - const D3D11_TEXTURE2D_DESC* baseD3dDescriptor, - wgpu::Texture* dawnTexture, - ID3D11Texture2D** d3d11TextureOut, - std::unique_ptr* externalImageOut) const { + void WrapSharedHandle(const wgpu::TextureDescriptor* dawnDesc, + const D3D11_TEXTURE2D_DESC* baseD3dDescriptor, + wgpu::Texture* dawnTexture, + ID3D11Texture2D** d3d11TextureOut, + std::unique_ptr* externalImageOut) const { ComPtr d3d11Texture; HRESULT hr = mD3d11Device->CreateTexture2D(baseD3dDescriptor, nullptr, &d3d11Texture); ASSERT_EQ(hr, S_OK); - std::unique_ptr externalImage = + std::unique_ptr externalImage = CreateExternalImage(device.Get(), d3d11Texture.Get(), dawnDesc); // Cannot access a non-existent external image (ex. validation error). @@ -144,7 +143,7 @@ class D3DResourceTestBase : public DawnTest { return; } - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.usage = static_cast(dawnDesc->usage); *dawnTexture = wgpu::Texture::Acquire(externalImage->BeginAccess(&externalAccessDesc)); @@ -165,8 +164,6 @@ class D3DResourceTestBase : public DawnTest { wgpu::TextureDescriptor baseDawnDescriptor; }; -} // anonymous namespace - // A small fixture used to initialize default data for the D3DResource validation tests. // These tests are skipped if the harness is using the wire. class D3DSharedHandleValidation : public D3DResourceTestBase {}; @@ -177,13 +174,13 @@ TEST_P(D3DSharedHandleValidation, Success) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); ASSERT_NE(texture.Get(), nullptr); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); } @@ -199,13 +196,13 @@ TEST_P(D3DSharedHandleValidation, SuccessWithInternalUsageDescriptor) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); ASSERT_NE(texture.Get(), nullptr); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); } @@ -220,7 +217,7 @@ TEST_P(D3DSharedHandleValidation, InvalidTextureDescriptor) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -234,7 +231,7 @@ TEST_P(D3DSharedHandleValidation, InvalidMipLevelCount) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -248,7 +245,7 @@ TEST_P(D3DSharedHandleValidation, InvalidDepth) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -262,7 +259,7 @@ TEST_P(D3DSharedHandleValidation, InvalidSampleCount) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -276,7 +273,7 @@ TEST_P(D3DSharedHandleValidation, InvalidWidth) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -290,7 +287,7 @@ TEST_P(D3DSharedHandleValidation, InvalidHeight) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -304,7 +301,7 @@ TEST_P(D3DSharedHandleValidation, InvalidFormat) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -318,7 +315,7 @@ TEST_P(D3DSharedHandleValidation, InvalidNumD3DMipLevels) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -332,7 +329,7 @@ TEST_P(D3DSharedHandleValidation, InvalidD3DArraySize) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; ASSERT_DEVICE_ERROR(WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage)); @@ -438,23 +435,22 @@ class D3DSharedHandleUsageTests : public D3DResourceTestBase { d3d11DeviceContext4->Signal(d3d11Fence, fenceSignalValue); } - void WaitAndWrapD3D11Texture( - const wgpu::TextureDescriptor& dawnDescriptor, - HANDLE sharedHandle, - HANDLE fenceSharedHandle, - uint64_t fenceWaitValue, - wgpu::Texture* dawnTextureOut, - std::unique_ptr* externalImageOut, - bool isInitialized) const { - dawn::native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc = {}; + void WaitAndWrapD3D11Texture(const wgpu::TextureDescriptor& dawnDescriptor, + HANDLE sharedHandle, + HANDLE fenceSharedHandle, + uint64_t fenceWaitValue, + wgpu::Texture* dawnTextureOut, + std::unique_ptr* externalImageOut, + bool isInitialized) const { + native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc = {}; externalImageDesc.sharedHandle = sharedHandle; externalImageDesc.cTextureDescriptor = reinterpret_cast(&dawnDescriptor); - std::unique_ptr externalImage = - dawn::native::d3d::ExternalImageDXGI::Create(device.Get(), &externalImageDesc); + std::unique_ptr externalImage = + native::d3d::ExternalImageDXGI::Create(device.Get(), &externalImageDesc); - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.isInitialized = isInitialized; externalAccessDesc.usage = static_cast(dawnDescriptor.usage); if (fenceSharedHandle != nullptr) { @@ -465,14 +461,13 @@ class D3DSharedHandleUsageTests : public D3DResourceTestBase { *externalImageOut = std::move(externalImage); } - void WrapAndClearD3D11Texture( - const wgpu::TextureDescriptor& dawnDescriptor, - const D3D11_TEXTURE2D_DESC& d3dDescriptor, - const wgpu::Color& clearColor, - wgpu::Texture* dawnTextureOut, - ID3D11Texture2D** d3d11TextureOut, - std::unique_ptr* externalImageOut, - bool isInitialized = true) const { + void WrapAndClearD3D11Texture(const wgpu::TextureDescriptor& dawnDescriptor, + const D3D11_TEXTURE2D_DESC& d3dDescriptor, + const wgpu::Color& clearColor, + wgpu::Texture* dawnTextureOut, + ID3D11Texture2D** d3d11TextureOut, + std::unique_ptr* externalImageOut, + bool isInitialized = true) const { ComPtr d3d11Texture; ComPtr d3d11Fence; HANDLE sharedHandle = nullptr; @@ -496,7 +491,7 @@ class D3DSharedHandleUsageTests : public D3DResourceTestBase { void ExpectPixelRGBA8EQ(ID3D11Texture2D* d3d11Texture, const wgpu::Color& color, - const dawn::native::d3d::ExternalImageDXGIFenceDescriptor* waitFence) { + const native::d3d::ExternalImageDXGIFenceDescriptor* waitFence) { D3D11_TEXTURE2D_DESC texture2DDesc; d3d11Texture->GetDesc(&texture2DDesc); @@ -573,7 +568,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D) { const wgpu::Color clearColor{1.0f, 1.0f, 0.0f, 1.0f}; wgpu::Texture dawnSrcTexture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, clearColor, &dawnSrcTexture, &d3d11Texture, &externalImage); ASSERT_NE(dawnSrcTexture.Get(), nullptr); @@ -582,7 +577,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D) { wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&baseDawnDescriptor); SimpleCopyTextureToTexture(dawnSrcTexture, dawnCopyDestTexture); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(dawnSrcTexture.Get(), &signalFence); dawnSrcTexture.Destroy(); @@ -601,7 +596,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearInD3D11ReadbackInD3D) { const wgpu::Color clearColor{1.0f, 1.0f, 0.0f, 1.0f}; wgpu::Texture dawnTexture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, clearColor, &dawnTexture, &d3d11Texture, &externalImage); ASSERT_NE(dawnTexture.Get(), nullptr); @@ -612,7 +607,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearInD3D11ReadbackInD3D) { clearColor.a * 255), dawnTexture, 0, 0); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(dawnTexture.Get(), &signalFence); dawnTexture.Destroy(); } @@ -630,7 +625,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearInD3DReadbackInD3D11) { const wgpu::Color d3d11ClearColor{1.0f, 1.0f, 0.0f, 1.0f}; wgpu::Texture dawnTexture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, d3d11ClearColor, &dawnTexture, &d3d11Texture, &externalImage, /*isInitialized=*/true); ASSERT_NE(dawnTexture.Get(), nullptr); @@ -638,7 +633,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearInD3DReadbackInD3D11) { const wgpu::Color d3dClearColor{0.0f, 0.0f, 1.0f, 1.0f}; ClearImage(dawnTexture, d3dClearColor, device); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(dawnTexture.Get(), &signalFence); dawnTexture.Destroy(); @@ -662,7 +657,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearTwiceInD3DReadbackInD3D11) { const wgpu::Color d3d11ClearColor{1.0f, 1.0f, 0.0f, 1.0f}; wgpu::Texture dawnTexture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, d3d11ClearColor, &dawnTexture, &d3d11Texture, &externalImage, /*isInitialized=*/true); ASSERT_NE(dawnTexture.Get(), nullptr); @@ -673,7 +668,7 @@ TEST_P(D3DSharedHandleUsageTests, ClearTwiceInD3DReadbackInD3D11) { const wgpu::Color d3dClearColor2{0.0f, 1.0f, 1.0f, 1.0f}; ClearImage(dawnTexture, d3dClearColor2, device); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(dawnTexture.Get(), &signalFence); dawnTexture.Destroy(); @@ -692,7 +687,7 @@ TEST_P(D3DSharedHandleUsageTests, UninitializedTextureIsCleared) { const wgpu::Color clearColor{1.0f, 0.0f, 0.0f, 1.0f}; wgpu::Texture dawnTexture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapAndClearD3D11Texture(baseDawnDescriptor, baseD3dDescriptor, clearColor, &dawnTexture, &d3d11Texture, &externalImage, /*isInitialized=*/false); ASSERT_NE(dawnTexture.Get(), nullptr); @@ -701,7 +696,7 @@ TEST_P(D3DSharedHandleUsageTests, UninitializedTextureIsCleared) { // to clear the source texture on the D3D device. EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8(0, 0, 0, 0), dawnTexture, 0, 0); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(dawnTexture.Get(), &signalFence); dawnTexture.Destroy(); } @@ -715,7 +710,7 @@ TEST_P(D3DSharedHandleUsageTests, ReuseExternalImage) { // Create the first Dawn texture then clear it to red. wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); { @@ -728,12 +723,12 @@ TEST_P(D3DSharedHandleUsageTests, ReuseExternalImage) { // Once finished with the first texture, destroy it so we may re-acquire the external image // again. - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); // Create another Dawn texture then clear it with another color. - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.isInitialized = true; externalAccessDesc.usage = static_cast(baseDawnDescriptor.usage); externalAccessDesc.waitFences.push_back(signalFence); @@ -774,7 +769,7 @@ TEST_P(D3DSharedHandleUsageTests, ConcurrentExternalImageReadAccess) { // Create Dawn texture with write access, then clear it to red. wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); @@ -783,35 +778,35 @@ TEST_P(D3DSharedHandleUsageTests, ConcurrentExternalImageReadAccess) { ASSERT_NE(texture.Get(), nullptr); ClearImage(texture.Get(), solidRed, device); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); - std::unique_ptr externalImage2 = + std::unique_ptr externalImage2 = CreateExternalImage(device2.Get(), d3d11Texture.Get(), &baseDawnDescriptor); EXPECT_NE(externalImage2, nullptr); - std::unique_ptr externalImage3 = + std::unique_ptr externalImage3 = CreateExternalImage(device3.Get(), d3d11Texture.Get(), &baseDawnDescriptor); EXPECT_NE(externalImage3, nullptr); - std::unique_ptr externalImage4 = + std::unique_ptr externalImage4 = CreateExternalImage(device4.Get(), d3d11Texture.Get(), &baseDawnDescriptor); EXPECT_NE(externalImage4, nullptr); - std::unique_ptr externalImage5 = + std::unique_ptr externalImage5 = CreateExternalImage(device5.Get(), d3d11Texture.Get(), &baseDawnDescriptor); EXPECT_NE(externalImage5, nullptr); // Create two Dawn textures for concurrent read on second device. - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.isInitialized = true; externalAccessDesc.usage = WGPUTextureUsage_CopySrc; externalAccessDesc.waitFences = {signalFence}; // Concurrent read access on device 2 and 3. - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence2; - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence3; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence2; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence3; { wgpu::Texture texture2 = wgpu::Texture::Acquire(externalImage2->BeginAccess(&externalAccessDesc)); @@ -837,7 +832,7 @@ TEST_P(D3DSharedHandleUsageTests, ConcurrentExternalImageReadAccess) { externalAccessDesc.waitFences = {signalFence2, signalFence3}; // Exclusive read-write access on device 4. - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence4; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence4; { wgpu::Texture texture4 = wgpu::Texture::Acquire(externalImage4->BeginAccess(&externalAccessDesc)); @@ -858,7 +853,7 @@ TEST_P(D3DSharedHandleUsageTests, ConcurrentExternalImageReadAccess) { externalAccessDesc.waitFences = {signalFence4}; // Import texture on device 5, but do nothing with it. - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence5; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence5; { wgpu::Texture texture5 = wgpu::Texture::Acquire(externalImage5->BeginAccess(&externalAccessDesc)); @@ -914,16 +909,16 @@ TEST_P(D3DSharedHandleUsageTests, ExternalImageUsage) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); ASSERT_NE(texture.Get(), nullptr); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.isInitialized = true; externalAccessDesc.usage = WGPUTextureUsage_StorageBinding; externalAccessDesc.waitFences.push_back(signalFence); @@ -943,7 +938,7 @@ TEST_P(D3DSharedHandleUsageTests, InvalidateExternalImageOnDestroyDevice) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; // Create the Dawn texture then clear it to red. WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, @@ -952,14 +947,14 @@ TEST_P(D3DSharedHandleUsageTests, InvalidateExternalImageOnDestroyDevice) { ASSERT_NE(texture.Get(), nullptr); ClearImage(texture.Get(), solidRed, device); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); // Do not readback pixels since that requires device to be alive during DawnTest::TearDown(). DestroyDevice(); - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.isInitialized = true; externalAccessDesc.usage = static_cast(baseDawnDescriptor.usage); @@ -972,7 +967,7 @@ TEST_P(D3DSharedHandleUsageTests, DisallowExternalImageAfterDestroyDevice) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; DestroyDevice(); @@ -990,7 +985,7 @@ TEST_P(D3DSharedHandleUsageTests, CallWriteBufferBeforeDestroyingExternalImage) wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); @@ -1000,7 +995,7 @@ TEST_P(D3DSharedHandleUsageTests, CallWriteBufferBeforeDestroyingExternalImage) wgpu::Buffer buffer = utils::CreateBufferFromData( device, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst, {kExpected}); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); texture.Destroy(); externalImage = nullptr; @@ -1015,7 +1010,7 @@ TEST_P(D3DSharedHandleUsageTests, SRGBReinterpretation) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; // The texture will be reinterpreted as sRGB. wgpu::TextureViewDescriptor viewDesc = {}; @@ -1071,13 +1066,13 @@ class D3DSharedHandleMultithreadTests : public D3DSharedHandleUsageTests { TEST_P(D3DSharedHandleMultithreadTests, DestroyDeviceBeforeImageNoDeadLock) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); ASSERT_NE(texture.Get(), nullptr); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); EXPECT_TRUE(externalImage->IsValid()); @@ -1091,7 +1086,7 @@ TEST_P(D3DSharedHandleMultithreadTests, DestroyDeviceBeforeImageNoDeadLock) { TEST_P(D3DSharedHandleMultithreadTests, DestroyDeviceAndUseImageInParallel) { wgpu::Texture texture; ComPtr d3d11Texture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture, &externalImage); @@ -1099,7 +1094,7 @@ TEST_P(D3DSharedHandleMultithreadTests, DestroyDeviceAndUseImageInParallel) { EXPECT_TRUE(externalImage->IsValid()); std::thread thread1([&] { - dawn::native::d3d::ExternalImageDXGIFenceDescriptor signalFence; + native::d3d::ExternalImageDXGIFenceDescriptor signalFence; externalImage->EndAccess(texture.Get(), &signalFence); }); @@ -1133,11 +1128,11 @@ TEST_P(D3DSharedHandleMultithreadTests, ClearInD3D12ReadbackInD3D11_TwoThreads) CreateSharedD3D11Texture(baseD3dDescriptor, &d3d11Texture, &d3d11Fence, &sharedHandle, &fenceSharedHandle); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor d3dSignalFence; + native::d3d::ExternalImageDXGIFenceDescriptor d3dSignalFence; std::thread d3dThread([=, &d3dSignalFence] { wgpu::Texture dawnTexture; - std::unique_ptr externalImage; + std::unique_ptr externalImage; WaitAndWrapD3D11Texture(baseDawnDescriptor, sharedHandle, fenceSharedHandle, /*fenceWaitValue=*/kD3D11FenceSignalValue, &dawnTexture, &externalImage, /*isInitialized=*/true); @@ -1176,3 +1171,6 @@ TEST_P(D3DSharedHandleMultithreadTests, ClearInD3D12ReadbackInD3D11_TwoThreads) DAWN_INSTANTIATE_TEST(D3DSharedHandleValidation, D3D11Backend(), D3D12Backend()); DAWN_INSTANTIATE_TEST(D3DSharedHandleUsageTests, D3D11Backend(), D3D12Backend()); DAWN_INSTANTIATE_TEST(D3DSharedHandleMultithreadTests, D3D11Backend(), D3D12Backend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DebugMarkerTests.cpp b/src/dawn/tests/end2end/DebugMarkerTests.cpp index e73c8bedc0..a873892d42 100644 --- a/src/dawn/tests/end2end/DebugMarkerTests.cpp +++ b/src/dawn/tests/end2end/DebugMarkerTests.cpp @@ -16,6 +16,9 @@ #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class DebugMarkerTests : public DawnTest {}; // Make sure that calling a marker API without a debugging tool attached doesn't cause a failure. @@ -52,3 +55,6 @@ DAWN_INSTANTIATE_TEST(DebugMarkerTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DepthBiasTests.cpp b/src/dawn/tests/end2end/DepthBiasTests.cpp index 78538c11f6..4f291b5c70 100644 --- a/src/dawn/tests/end2end/DepthBiasTests.cpp +++ b/src/dawn/tests/end2end/DepthBiasTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 2; enum class QuadAngle { Flat, TiltedX }; @@ -396,3 +399,6 @@ DAWN_INSTANTIATE_TEST(DepthBiasTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp index 37d04cb305..91e399716b 100644 --- a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp @@ -25,7 +25,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + using TextureFormat = wgpu::TextureFormat; DAWN_TEST_PARAM_STRUCT(DepthStencilCopyTestParams, TextureFormat); @@ -38,7 +40,6 @@ constexpr std::array kValidDepthCopyTextureFormats = { constexpr std::array kValidDepthCopyFromBufferFormats = { wgpu::TextureFormat::Depth16Unorm, }; -} // namespace class DepthStencilCopyTests : public DawnTestWithParams { protected: @@ -1093,3 +1094,6 @@ DAWN_INSTANTIATE_TEST_P( std::vector{wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureFormat::Depth24Plus}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp index 29bb81d9cd..837f8bec09 100644 --- a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp @@ -19,6 +19,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { using Format = wgpu::TextureFormat; @@ -420,4 +421,5 @@ DAWN_INSTANTIATE_TEST_P(DepthTextureClearTwiceTest, wgpu::TextureFormat::Depth24PlusStencil8}, {true, false}); -} // namespace +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp b/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp index 58f84f23a6..a2627ee726 100644 --- a/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp @@ -20,7 +20,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + using TextureFormat = wgpu::TextureFormat; DAWN_TEST_PARAM_STRUCT(DepthStencilSamplingTestParams, TextureFormat); @@ -40,8 +42,6 @@ const std::vector kNormalizedTextureValues = {0.0, 0.3, 0.4, 0.5, 1.0}; // Test the limits, and some values in between. const std::vector kStencilValues = {0, 1, 38, 255}; -} // anonymous namespace - class DepthStencilSamplingTest : public DawnTestWithParams { protected: enum class TestAspectAndSamplerType { @@ -938,3 +938,6 @@ DAWN_INSTANTIATE_TEST_P(StencilSamplingTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()}, std::vector(utils::kStencilFormats.begin(), utils::kStencilFormats.end())); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DepthStencilStateTests.cpp b/src/dawn/tests/end2end/DepthStencilStateTests.cpp index 0c9457e10e..e66e4fc205 100644 --- a/src/dawn/tests/end2end/DepthStencilStateTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilStateTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 64; class DepthStencilStateTest : public DawnTest { @@ -847,3 +850,6 @@ DAWN_INSTANTIATE_TEST(DepthStencilStateTest, OpenGLESBackend(), VulkanBackend({"vulkan_use_d32s8"}, {}), VulkanBackend({}, {"vulkan_use_d32s8"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DestroyTests.cpp b/src/dawn/tests/end2end/DestroyTests.cpp index 4b903f5e04..962e6a8d4f 100644 --- a/src/dawn/tests/end2end/DestroyTests.cpp +++ b/src/dawn/tests/end2end/DestroyTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + using ::testing::HasSubstr; constexpr uint32_t kRTSize = 4; @@ -219,3 +222,6 @@ DAWN_INSTANTIATE_TEST(DestroyTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DeviceInitializationTests.cpp b/src/dawn/tests/end2end/DeviceInitializationTests.cpp index 7738b0c51a..69e4d5e863 100644 --- a/src/dawn/tests/end2end/DeviceInitializationTests.cpp +++ b/src/dawn/tests/end2end/DeviceInitializationTests.cpp @@ -21,9 +21,12 @@ #include "dawn/utils/SystemUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class DeviceInitializationTest : public testing::Test { protected: - void SetUp() override { dawnProcSetProcs(&dawn::native::GetProcs()); } + void SetUp() override { dawnProcSetProcs(&native::GetProcs()); } void TearDown() override { dawnProcSetProcs(nullptr); } @@ -73,10 +76,10 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) { // We want to create a device on a fresh instance and adapter each time. std::vector availableAdapterProperties; { - auto instance = std::make_unique(); + auto instance = std::make_unique(); instance->EnableAdapterBlocklist(false); instance->DiscoverDefaultAdapters(); - for (const dawn::native::Adapter& adapter : instance->GetAdapters()) { + for (const native::Adapter& adapter : instance->GetAdapters()) { wgpu::AdapterProperties properties; adapter.GetProperties(&properties); @@ -91,10 +94,10 @@ TEST_F(DeviceInitializationTest, DeviceOutlivesInstance) { for (const wgpu::AdapterProperties& desiredProperties : availableAdapterProperties) { wgpu::Device device; - auto instance = std::make_unique(); + auto instance = std::make_unique(); instance->EnableAdapterBlocklist(false); instance->DiscoverDefaultAdapters(); - for (dawn::native::Adapter& adapter : instance->GetAdapters()) { + for (native::Adapter& adapter : instance->GetAdapters()) { wgpu::AdapterProperties properties; adapter.GetProperties(&properties); @@ -122,10 +125,10 @@ TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) { // We want to create a device on a fresh instance and adapter each time. std::vector availableAdapterProperties; { - auto instance = std::make_unique(); + auto instance = std::make_unique(); instance->EnableAdapterBlocklist(false); instance->DiscoverDefaultAdapters(); - for (const dawn::native::Adapter& adapter : instance->GetAdapters()) { + for (const native::Adapter& adapter : instance->GetAdapters()) { wgpu::AdapterProperties properties; adapter.GetProperties(&properties); @@ -143,14 +146,14 @@ TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) { for (const wgpu::AdapterProperties& desiredProperties : availableAdapterProperties) { wgpu::Adapter adapter; - auto instance = std::make_unique(); + auto instance = std::make_unique(); instance->EnableAdapterBlocklist(false); // Save a pointer to the instance. // It will only be valid as long as the instance is alive. WGPUInstance unsafeInstancePtr = instance->Get(); instance->DiscoverDefaultAdapters(); - for (dawn::native::Adapter& nativeAdapter : instance->GetAdapters()) { + for (native::Adapter& nativeAdapter : instance->GetAdapters()) { wgpu::AdapterProperties properties; nativeAdapter.GetProperties(&properties); @@ -164,9 +167,9 @@ TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) { // holding onto the instance. The instance should have cleared all internal // references to adapters when the last external ref is dropped. adapter = wgpu::Adapter(nativeAdapter.Get()); - EXPECT_GT(dawn::native::GetAdapterCountForTesting(unsafeInstancePtr), 0u); + EXPECT_GT(native::GetAdapterCountForTesting(unsafeInstancePtr), 0u); instance.reset(); - EXPECT_EQ(dawn::native::GetAdapterCountForTesting(unsafeInstancePtr), 0u); + EXPECT_EQ(native::GetAdapterCountForTesting(unsafeInstancePtr), 0u); break; } } @@ -176,3 +179,6 @@ TEST_F(DeviceInitializationTest, AdapterOutlivesInstance) { } } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DeviceLifetimeTests.cpp b/src/dawn/tests/end2end/DeviceLifetimeTests.cpp index 83d13b0041..7a2cb09e76 100644 --- a/src/dawn/tests/end2end/DeviceLifetimeTests.cpp +++ b/src/dawn/tests/end2end/DeviceLifetimeTests.cpp @@ -17,6 +17,9 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class DeviceLifetimeTests : public DawnTest {}; // Test that the device can be dropped before its queue. @@ -557,3 +560,6 @@ DAWN_INSTANTIATE_TEST(DeviceLifetimeTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DeviceLostTests.cpp b/src/dawn/tests/end2end/DeviceLostTests.cpp index 61691c444b..68f2155743 100644 --- a/src/dawn/tests/end2end/DeviceLostTests.cpp +++ b/src/dawn/tests/end2end/DeviceLostTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/WGPUHelpers.h" #include "gmock/gmock.h" +namespace dawn { +namespace { + using testing::_; using testing::Exactly; using testing::MockCallback; @@ -540,3 +543,6 @@ DAWN_INSTANTIATE_TEST(DeviceLostTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DrawIndexedIndirectTests.cpp b/src/dawn/tests/end2end/DrawIndexedIndirectTests.cpp index 549a5bb34d..a66e69cec8 100644 --- a/src/dawn/tests/end2end/DrawIndexedIndirectTests.cpp +++ b/src/dawn/tests/end2end/DrawIndexedIndirectTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 4; class DrawIndexedIndirectTest : public DawnTest { @@ -716,3 +719,6 @@ DAWN_INSTANTIATE_TEST(DrawIndexedIndirectTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DrawIndexedTests.cpp b/src/dawn/tests/end2end/DrawIndexedTests.cpp index 48b5a6c314..16e7be04e7 100644 --- a/src/dawn/tests/end2end/DrawIndexedTests.cpp +++ b/src/dawn/tests/end2end/DrawIndexedTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 4; class DrawIndexedTest : public DawnTest { @@ -162,3 +165,6 @@ DAWN_INSTANTIATE_TEST(DrawIndexedTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DrawIndirectTests.cpp b/src/dawn/tests/end2end/DrawIndirectTests.cpp index b1ee3953f7..c1d75e1d24 100644 --- a/src/dawn/tests/end2end/DrawIndirectTests.cpp +++ b/src/dawn/tests/end2end/DrawIndirectTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 4; class DrawIndirectTest : public DawnTest { @@ -135,3 +138,6 @@ DAWN_INSTANTIATE_TEST(DrawIndirectTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DrawTests.cpp b/src/dawn/tests/end2end/DrawTests.cpp index e7ffbca209..ecb7479033 100644 --- a/src/dawn/tests/end2end/DrawTests.cpp +++ b/src/dawn/tests/end2end/DrawTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 4; class DrawTest : public DawnTest { @@ -107,3 +110,6 @@ DAWN_INSTANTIATE_TEST(DrawTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp b/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp index 8f1d59e9ab..53d9d9b914 100644 --- a/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp +++ b/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 400; constexpr uint32_t kBindingSize = 8; @@ -586,3 +589,6 @@ DAWN_INSTANTIATE_TEST_P(ClampedOOBDynamicBufferOffsetTests, {wgpu::BufferUsage::Uniform, wgpu::BufferUsage::Storage}, {false, true}, {false, true}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/EntryPointTests.cpp b/src/dawn/tests/end2end/EntryPointTests.cpp index 2bd1ca47e0..2f38c9bde7 100644 --- a/src/dawn/tests/end2end/EntryPointTests.cpp +++ b/src/dawn/tests/end2end/EntryPointTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class EntryPointTests : public DawnTest {}; // Test creating a render pipeline from two entryPoints in the same module. @@ -149,3 +152,6 @@ DAWN_INSTANTIATE_TEST(EntryPointTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ExperimentalDP4aTests.cpp b/src/dawn/tests/end2end/ExperimentalDP4aTests.cpp index ae642a2f77..def6f225c9 100644 --- a/src/dawn/tests/end2end/ExperimentalDP4aTests.cpp +++ b/src/dawn/tests/end2end/ExperimentalDP4aTests.cpp @@ -17,12 +17,12 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + using RequestDP4aExtension = bool; DAWN_TEST_PARAM_STRUCT(ExperimentalDP4aTestsParams, RequestDP4aExtension); -} // anonymous namespace - class ExperimentalDP4aTests : public DawnTestWithParams { protected: std::vector GetRequiredFeatures() override { @@ -136,3 +136,6 @@ DAWN_INSTANTIATE_TEST_P(ExperimentalDP4aTests, VulkanBackend(), }, {true, false}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ExternalTextureTests.cpp b/src/dawn/tests/end2end/ExternalTextureTests.cpp index 420493acaf..d32bacefa6 100644 --- a/src/dawn/tests/end2end/ExternalTextureTests.cpp +++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp @@ -16,6 +16,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { wgpu::Texture Create2DTexture(wgpu::Device device, @@ -107,7 +108,6 @@ class ExternalTextureTests : public DawnTest { wgpu::ShaderModule vsModule; wgpu::ShaderModule fsSampleExternalTextureModule; }; -} // anonymous namespace TEST_P(ExternalTextureTests, CreateExternalTextureSuccess) { wgpu::Texture texture = Create2DTexture(device, kWidth, kHeight, kFormat, kSampledUsage); @@ -1002,3 +1002,6 @@ DAWN_INSTANTIATE_TEST(ExternalTextureTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp b/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp index 29b0dcf87f..3437826564 100644 --- a/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp +++ b/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp @@ -21,6 +21,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 1; enum class DrawMode { @@ -39,12 +42,14 @@ bool IsIndirectDraw(DrawMode mode) { return mode == DrawMode::NonIndexedIndirect || mode == DrawMode::IndexedIndirect; } -namespace dawn { +} // anonymous namespace + template <> struct IsDawnBitmask { static constexpr bool enable = true; }; -} // namespace dawn + +namespace { class FirstIndexOffsetTests : public DawnTest { public: @@ -328,3 +333,6 @@ DAWN_INSTANTIATE_TEST(FirstIndexOffsetTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/FragDepthTests.cpp b/src/dawn/tests/end2end/FragDepthTests.cpp index 5376e7b029..910440bb8f 100644 --- a/src/dawn/tests/end2end/FragDepthTests.cpp +++ b/src/dawn/tests/end2end/FragDepthTests.cpp @@ -16,6 +16,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr wgpu::TextureFormat kDepthFormat = wgpu::TextureFormat::Depth32Float; class FragDepthTests : public DawnTest {}; @@ -233,3 +236,6 @@ DAWN_INSTANTIATE_TEST(FragDepthTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp index f19f888409..86cc4fa839 100644 --- a/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp +++ b/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class GpuMemorySyncTests : public DawnTest { protected: wgpu::Buffer CreateBuffer() { @@ -654,3 +657,6 @@ DAWN_INSTANTIATE_TEST(MultipleWriteThenMultipleReadTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/IOSurfaceWrappingTests.cpp b/src/dawn/tests/end2end/IOSurfaceWrappingTests.cpp index 47e8fafed6..dcc8f3699c 100644 --- a/src/dawn/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/dawn/tests/end2end/IOSurfaceWrappingTests.cpp @@ -26,6 +26,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { void AddIntegerValue(CFMutableDictionaryRef dictionary, const CFStringRef key, int32_t value) { @@ -96,17 +97,15 @@ class IOSurfaceTestBase : public DawnTest { wgpu::Texture WrapIOSurface(const wgpu::TextureDescriptor* descriptor, IOSurfaceRef ioSurface, bool isInitialized = true) { - dawn::native::metal::ExternalImageDescriptorIOSurface externDesc; + native::metal::ExternalImageDescriptorIOSurface externDesc; externDesc.cTextureDescriptor = reinterpret_cast(descriptor); externDesc.ioSurface = ioSurface; externDesc.isInitialized = isInitialized; - WGPUTexture texture = dawn::native::metal::WrapIOSurface(device.Get(), &externDesc); + WGPUTexture texture = native::metal::WrapIOSurface(device.Get(), &externDesc); return wgpu::Texture::Acquire(texture); } }; -} // anonymous namespace - // A small fixture used to initialize default data for the IOSurface validation tests. // These tests are skipped if the harness is using the wire. class IOSurfaceValidationTests : public IOSurfaceTestBase { @@ -369,7 +368,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { queue.Submit(1, &commands); // Wait for the commands touching the IOSurface to be scheduled - dawn::native::metal::WaitForCommandsToBeScheduled(device.Get()); + native::metal::WaitForCommandsToBeScheduled(device.Get()); // Check the correct data was written IOSurfaceLock(ioSurface, kIOSurfaceLockReadOnly, nullptr); @@ -481,8 +480,8 @@ TEST_P(IOSurfaceUsageTests, UninitializedTextureIsCleared) { wgpu::Texture ioSurfaceTexture = WrapIOSurface(&textureDescriptor, ioSurface.get(), false); EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8(0, 0, 0, 0), ioSurfaceTexture, 0, 0); - dawn::native::metal::ExternalImageIOSurfaceEndAccessDescriptor endAccessDesc; - dawn::native::metal::IOSurfaceEndAccess(ioSurfaceTexture.Get(), &endAccessDesc); + native::metal::ExternalImageIOSurfaceEndAccessDescriptor endAccessDesc; + native::metal::IOSurfaceEndAccess(ioSurfaceTexture.Get(), &endAccessDesc); EXPECT_TRUE(endAccessDesc.isInitialized); } @@ -517,8 +516,8 @@ TEST_P(IOSurfaceUsageTests, UninitializedOnEndAccess) { wgpu::CommandBuffer commandBuffer = encoder.Finish(); queue.Submit(1, &commandBuffer); - dawn::native::metal::ExternalImageIOSurfaceEndAccessDescriptor endAccessDesc; - dawn::native::metal::IOSurfaceEndAccess(ioSurfaceTexture.Get(), &endAccessDesc); + native::metal::ExternalImageIOSurfaceEndAccessDescriptor endAccessDesc; + native::metal::IOSurfaceEndAccess(ioSurfaceTexture.Get(), &endAccessDesc); EXPECT_FALSE(endAccessDesc.isInitialized); } @@ -548,14 +547,14 @@ TEST_P(IOSurfaceUsageTests, WriteThenConcurrentReadThenWrite) { textureDesc.usage = wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc; // Wrap ioSurface - dawn::native::metal::ExternalImageDescriptorIOSurface writeExternDesc; + native::metal::ExternalImageDescriptorIOSurface writeExternDesc; writeExternDesc.cTextureDescriptor = reinterpret_cast(&textureDesc); writeExternDesc.ioSurface = ioSurface.get(); writeExternDesc.isInitialized = true; - wgpu::Texture writeTexture = wgpu::Texture::Acquire( - dawn::native::metal::WrapIOSurface(writeDevice.Get(), &writeExternDesc)); + wgpu::Texture writeTexture = + wgpu::Texture::Acquire(native::metal::WrapIOSurface(writeDevice.Get(), &writeExternDesc)); // Clear the texture to green. { @@ -568,11 +567,11 @@ TEST_P(IOSurfaceUsageTests, WriteThenConcurrentReadThenWrite) { } // End access. - dawn::native::metal::ExternalImageIOSurfaceEndAccessDescriptor endWriteAccessDesc; - dawn::native::metal::IOSurfaceEndAccess(writeTexture.Get(), &endWriteAccessDesc); + native::metal::ExternalImageIOSurfaceEndAccessDescriptor endWriteAccessDesc; + native::metal::IOSurfaceEndAccess(writeTexture.Get(), &endWriteAccessDesc); EXPECT_TRUE(endWriteAccessDesc.isInitialized); - dawn::native::metal::ExternalImageDescriptorIOSurface externDesc; + native::metal::ExternalImageDescriptorIOSurface externDesc; externDesc.cTextureDescriptor = reinterpret_cast(&textureDesc); externDesc.ioSurface = ioSurface.get(); externDesc.isInitialized = true; @@ -581,28 +580,28 @@ TEST_P(IOSurfaceUsageTests, WriteThenConcurrentReadThenWrite) { // Wrap on two separate devices to read it. wgpu::Texture readTexture1 = - wgpu::Texture::Acquire(dawn::native::metal::WrapIOSurface(readDevice1.Get(), &externDesc)); + wgpu::Texture::Acquire(native::metal::WrapIOSurface(readDevice1.Get(), &externDesc)); wgpu::Texture readTexture2 = - wgpu::Texture::Acquire(dawn::native::metal::WrapIOSurface(readDevice2.Get(), &externDesc)); + wgpu::Texture::Acquire(native::metal::WrapIOSurface(readDevice2.Get(), &externDesc)); // Expect the texture to be green EXPECT_TEXTURE_EQ(readDevice1, utils::RGBA8(0, 255, 0, 255), readTexture1, {0, 0}); EXPECT_TEXTURE_EQ(readDevice2, utils::RGBA8(0, 255, 0, 255), readTexture2, {0, 0}); // End access on both read textures. - dawn::native::metal::ExternalImageIOSurfaceEndAccessDescriptor endReadAccessDesc1; - dawn::native::metal::IOSurfaceEndAccess(readTexture1.Get(), &endReadAccessDesc1); + native::metal::ExternalImageIOSurfaceEndAccessDescriptor endReadAccessDesc1; + native::metal::IOSurfaceEndAccess(readTexture1.Get(), &endReadAccessDesc1); EXPECT_TRUE(endReadAccessDesc1.isInitialized); - dawn::native::metal::ExternalImageIOSurfaceEndAccessDescriptor endReadAccessDesc2; - dawn::native::metal::IOSurfaceEndAccess(readTexture2.Get(), &endReadAccessDesc2); + native::metal::ExternalImageIOSurfaceEndAccessDescriptor endReadAccessDesc2; + native::metal::IOSurfaceEndAccess(readTexture2.Get(), &endReadAccessDesc2); EXPECT_TRUE(endReadAccessDesc2.isInitialized); // Import again for writing. It should not race with the previous reads. writeExternDesc.waitEvents = {endReadAccessDesc1, endReadAccessDesc2}; writeExternDesc.isInitialized = true; - writeTexture = wgpu::Texture::Acquire( - dawn::native::metal::WrapIOSurface(writeDevice.Get(), &writeExternDesc)); + writeTexture = + wgpu::Texture::Acquire(native::metal::WrapIOSurface(writeDevice.Get(), &writeExternDesc)); // Clear the texture to blue. { @@ -615,7 +614,7 @@ TEST_P(IOSurfaceUsageTests, WriteThenConcurrentReadThenWrite) { } // Finally, expect the contents to be blue now. EXPECT_TEXTURE_EQ(writeDevice, utils::RGBA8(0, 0, 255, 255), writeTexture, {0, 0}); - dawn::native::metal::IOSurfaceEndAccess(writeTexture.Get(), &endWriteAccessDesc); + native::metal::IOSurfaceEndAccess(writeTexture.Get(), &endWriteAccessDesc); EXPECT_TRUE(endWriteAccessDesc.isInitialized); } @@ -662,8 +661,8 @@ TEST_P(IOSurfaceMultithreadTests, UninitializedTexturesAreCleared_OnMultipleThre wgpu::Texture ioSurfaceTexture = WrapIOSurface(&textureDescriptor, ioSurface.get(), false); EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8(0, 0, 0, 0), ioSurfaceTexture, 0, 0); - dawn::native::metal::ExternalImageIOSurfaceEndAccessDescriptor endAccessDesc; - dawn::native::metal::IOSurfaceEndAccess(ioSurfaceTexture.Get(), &endAccessDesc); + native::metal::ExternalImageIOSurfaceEndAccessDescriptor endAccessDesc; + native::metal::IOSurfaceEndAccess(ioSurfaceTexture.Get(), &endAccessDesc); EXPECT_TRUE(endAccessDesc.isInitialized); }); } @@ -683,3 +682,6 @@ DAWN_INSTANTIATE_TEST(IOSurfaceValidationTests, MetalBackend()); DAWN_INSTANTIATE_TEST(IOSurfaceTransientAttachmentValidationTests, MetalBackend()); DAWN_INSTANTIATE_TEST(IOSurfaceUsageTests, MetalBackend()); DAWN_INSTANTIATE_TEST(IOSurfaceMultithreadTests, MetalBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/IndexFormatTests.cpp b/src/dawn/tests/end2end/IndexFormatTests.cpp index e46073da1b..b16d67fb61 100644 --- a/src/dawn/tests/end2end/IndexFormatTests.cpp +++ b/src/dawn/tests/end2end/IndexFormatTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 400; class IndexFormatTest : public DawnTest { @@ -493,3 +496,6 @@ DAWN_INSTANTIATE_TEST(LineStripPrimitiveRestartTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/MaxLimitTests.cpp b/src/dawn/tests/end2end/MaxLimitTests.cpp index fcffdfe908..70ad974ea8 100644 --- a/src/dawn/tests/end2end/MaxLimitTests.cpp +++ b/src/dawn/tests/end2end/MaxLimitTests.cpp @@ -23,6 +23,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class MaxLimitTests : public DawnTest { public: wgpu::RequiredLimits GetRequiredLimits(const wgpu::SupportedLimits& supported) override { @@ -707,3 +710,6 @@ DAWN_INSTANTIATE_TEST(MaxLimitTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp index 72d95c3f99..bc16753b1b 100644 --- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class MultisampledRenderingTest : public DawnTest { protected: void SetUp() override { @@ -1217,3 +1220,6 @@ DAWN_INSTANTIATE_TEST(MultisampledRenderingWithTransientAttachmentTest, MetalBackend({"always_resolve_into_zero_level_and_layer"}), MetalBackend({"always_resolve_into_zero_level_and_layer", "emulate_store_and_msaa_resolve"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/MultisampledSamplingTests.cpp b/src/dawn/tests/end2end/MultisampledSamplingTests.cpp index 358e98152b..d86a976899 100644 --- a/src/dawn/tests/end2end/MultisampledSamplingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledSamplingTests.cpp @@ -19,7 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + // https://github.com/gpuweb/gpuweb/issues/108 // Vulkan, Metal, and D3D11 have the same standard multisample pattern. D3D12 is the same as // D3D11 but it was left out of the documentation. @@ -32,14 +34,12 @@ static constexpr std::array, 4> kSamplePositions = { {0.875 * 2 - 1, 1 - 0.375 * 2}, {0.125 * 2 - 1, 1 - 0.625 * 2}, {0.625 * 2 - 1, 1 - 0.875 * 2}}}; -} // anonymous namespace class MultisampledSamplingTest : public DawnTest { protected: static constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::R8Unorm; static constexpr wgpu::TextureFormat kDepthFormat = wgpu::TextureFormat::Depth32Float; - static constexpr wgpu::TextureFormat kDepthOutFormat = wgpu::TextureFormat::R32Float; static constexpr uint32_t kSampleCount = 4; // Render pipeline for drawing to a multisampled color and depth attachment. @@ -264,3 +264,6 @@ DAWN_INSTANTIATE_TEST(MultisampledSamplingTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/MultithreadTests.cpp b/src/dawn/tests/end2end/MultithreadTests.cpp index 166caacf98..a6665d0072 100644 --- a/src/dawn/tests/end2end/MultithreadTests.cpp +++ b/src/dawn/tests/end2end/MultithreadTests.cpp @@ -32,7 +32,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + template class LockStep { public: @@ -1343,8 +1345,6 @@ TEST_P(MultithreadTimestampQueryTests, ResolveQuerySets_InParallel) { }); } -} // namespace - DAWN_INSTANTIATE_TEST(MultithreadTests, D3D12Backend(), MetalBackend(), @@ -1393,3 +1393,6 @@ DAWN_INSTANTIATE_TEST(MultithreadTimestampQueryTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp b/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp index c10b87668b..c9ba1bb455 100644 --- a/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp +++ b/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp @@ -22,6 +22,7 @@ #include "dawn/utils/TestUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { using Format = wgpu::TextureFormat; @@ -258,8 +259,6 @@ class NonzeroDepthStencilTextureCreationTests : public NonzeroTextureCreationTes class NonzeroStencilTextureCreationTests : public NonzeroTextureCreationTests {}; class NonzeroMultisampledTextureCreationTests : public NonzeroTextureCreationTests {}; -} // anonymous namespace - // Test that texture clears to a non-zero value because toggle is enabled. TEST_P(NonzeroTextureCreationTests, TextureCreationClears) { Run(); @@ -455,3 +454,6 @@ DAWN_INSTANTIATE_TEST_P( {0u}, // mip {4u} // sample count ); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ObjectCachingTests.cpp b/src/dawn/tests/end2end/ObjectCachingTests.cpp index aa4ca7b43f..d9c768f032 100644 --- a/src/dawn/tests/end2end/ObjectCachingTests.cpp +++ b/src/dawn/tests/end2end/ObjectCachingTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ObjectCachingTest : public DawnTest {}; // Test that BindGroupLayouts are correctly deduplicated. @@ -451,3 +454,6 @@ DAWN_INSTANTIATE_TEST(ObjectCachingTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/OpArrayLengthTests.cpp b/src/dawn/tests/end2end/OpArrayLengthTests.cpp index c560b2ae56..0f41d98ff4 100644 --- a/src/dawn/tests/end2end/OpArrayLengthTests.cpp +++ b/src/dawn/tests/end2end/OpArrayLengthTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class OpArrayLengthTest : public DawnTest { protected: void SetUp() override { @@ -280,3 +283,6 @@ DAWN_INSTANTIATE_TEST(OpArrayLengthTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/PipelineCachingTests.cpp b/src/dawn/tests/end2end/PipelineCachingTests.cpp index d5d8062fc0..1c38c5aa18 100644 --- a/src/dawn/tests/end2end/PipelineCachingTests.cpp +++ b/src/dawn/tests/end2end/PipelineCachingTests.cpp @@ -20,6 +20,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { using ::testing::NiceMock; @@ -97,7 +98,7 @@ static constexpr std::string_view kFragmentShaderBindGroup01Uniform = R"( class PipelineCachingTests : public DawnTest { protected: - std::unique_ptr CreateTestPlatform() override { + std::unique_ptr CreateTestPlatform() override { return std::make_unique(&mMockCache); } @@ -647,4 +648,5 @@ DAWN_INSTANTIATE_TEST(SinglePipelineCachingTests, OpenGLESBackend(), VulkanBackend()); -} // namespace +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/PipelineLayoutTests.cpp b/src/dawn/tests/end2end/PipelineLayoutTests.cpp index dca4be3f26..e80329adcc 100644 --- a/src/dawn/tests/end2end/PipelineLayoutTests.cpp +++ b/src/dawn/tests/end2end/PipelineLayoutTests.cpp @@ -18,6 +18,9 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class PipelineLayoutTests : public DawnTest {}; // Test creating a PipelineLayout with multiple BGLs where the first BGL uses the max number of @@ -149,3 +152,6 @@ DAWN_INSTANTIATE_TEST(PipelineLayoutTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/PrimitiveStateTests.cpp b/src/dawn/tests/end2end/PrimitiveStateTests.cpp index 5c3a2bd7be..fca5de1951 100644 --- a/src/dawn/tests/end2end/PrimitiveStateTests.cpp +++ b/src/dawn/tests/end2end/PrimitiveStateTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 1; class DepthClippingTest : public DawnTest { @@ -363,3 +366,6 @@ DAWN_INSTANTIATE_TEST(DepthClippingTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/PrimitiveTopologyTests.cpp b/src/dawn/tests/end2end/PrimitiveTopologyTests.cpp index 1ad47c7ba0..d8e7a59e97 100644 --- a/src/dawn/tests/end2end/PrimitiveTopologyTests.cpp +++ b/src/dawn/tests/end2end/PrimitiveTopologyTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // Primitive topology tests work by drawing the following vertices with all the different primitive // topology states: // ------------------------------------- @@ -304,3 +307,6 @@ DAWN_INSTANTIATE_TEST(PrimitiveTopologyTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/QueryTests.cpp b/src/dawn/tests/end2end/QueryTests.cpp index 63209e5b4c..1badcdd846 100644 --- a/src/dawn/tests/end2end/QueryTests.cpp +++ b/src/dawn/tests/end2end/QueryTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // Clear the content of the result buffer into 0xFFFFFFFF. constexpr static uint64_t kSentinelValue = ~uint64_t(0u); constexpr static uint64_t kZero = 0u; @@ -1283,3 +1286,6 @@ DAWN_INSTANTIATE_TEST(TimestampQueryInsidePassesTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/QueueTests.cpp b/src/dawn/tests/end2end/QueueTests.cpp index 8531181305..7fab0d0ec7 100644 --- a/src/dawn/tests/end2end/QueueTests.cpp +++ b/src/dawn/tests/end2end/QueueTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class QueueTests : public DawnTest {}; // Test that GetQueue always returns the same object. @@ -789,3 +792,6 @@ DAWN_INSTANTIATE_TEST(QueueWriteTextureTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp b/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp index 06e66885e9..df747233fd 100644 --- a/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp +++ b/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp @@ -19,12 +19,13 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static uint32_t kSize = 4; -namespace { using TextureFormat = wgpu::TextureFormat; DAWN_TEST_PARAM_STRUCT(ReadOnlyDepthStencilAttachmentTestsParams, TextureFormat); -} // namespace class ReadOnlyDepthStencilAttachmentTests : public DawnTestWithParams { @@ -353,3 +354,6 @@ DAWN_INSTANTIATE_TEST_P(ReadOnlyStencilAttachmentTests, MetalBackend(), VulkanBackend()}, std::vector(utils::kStencilFormats.begin(), utils::kStencilFormats.end())); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/RenderAttachmentTests.cpp b/src/dawn/tests/end2end/RenderAttachmentTests.cpp index dbc095c859..1973d79c94 100644 --- a/src/dawn/tests/end2end/RenderAttachmentTests.cpp +++ b/src/dawn/tests/end2end/RenderAttachmentTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class RenderAttachmentTest : public DawnTest {}; // Test that it is ok to have more fragment outputs than color attachments. @@ -83,3 +86,6 @@ DAWN_INSTANTIATE_TEST(RenderAttachmentTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/RenderBundleTests.cpp b/src/dawn/tests/end2end/RenderBundleTests.cpp index abdefab972..ddb34b4750 100644 --- a/src/dawn/tests/end2end/RenderBundleTests.cpp +++ b/src/dawn/tests/end2end/RenderBundleTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 4; const utils::RGBA8 kColors[2] = {utils::RGBA8::kGreen, utils::RGBA8::kBlue}; @@ -200,3 +203,6 @@ DAWN_INSTANTIATE_TEST(RenderBundleTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp b/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp index f25f5fd037..5f71f01ea8 100644 --- a/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp +++ b/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp @@ -24,6 +24,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 16; class DrawQuad { @@ -720,3 +723,6 @@ DAWN_INSTANTIATE_TEST(RenderPassLoadOpTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/RenderPassTests.cpp b/src/dawn/tests/end2end/RenderPassTests.cpp index 624578d494..5a9259a428 100644 --- a/src/dawn/tests/end2end/RenderPassTests.cpp +++ b/src/dawn/tests/end2end/RenderPassTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRTSize = 16; constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm; @@ -371,3 +374,6 @@ DAWN_INSTANTIATE_TEST(RenderPassTest_RegressionDawn1389, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp b/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp index 58c45cef65..45c75868b7 100644 --- a/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp +++ b/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp @@ -19,13 +19,15 @@ #include "dawn/utils/TestUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static wgpu::Extent3D kCopySize = {1, 1}; constexpr static uint64_t kOffset = 0; constexpr static uint64_t kBytesPerRow = 256; constexpr static wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm; constexpr static uint32_t kBytesPerBlock = 4; -namespace { enum class Type { B2TCopy, T2BCopy }; std::ostream& operator<<(std::ostream& o, Type copyType) { @@ -48,7 +50,6 @@ DAWN_TEST_PARAM_STRUCT(RequiredBufferSizeInCopyTestsParams, TextureDimension, CopyDepth, ExtraRowsPerImage); -} // namespace // Tests in this file are used to expose an error on D3D12 about required minimum buffer size. // See detailed bug reports at crbug.com/dawn/1278, 1288, 1289. @@ -205,3 +206,6 @@ DAWN_INSTANTIATE_TEST_P( {wgpu::TextureDimension::e3D, wgpu::TextureDimension::e2D}, {2u, 1u}, {1u, 0u}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp b/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp index 9e9f118fc9..5f792b3436 100644 --- a/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp +++ b/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp @@ -21,16 +21,17 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 16; -namespace { // MipLevel colors, ordering from base level to high level // each mipmap of the texture is having a different color // so we can check if the sampler anisotropic filtering is fetching // from the correct miplevel const std::array colors = {utils::RGBA8::kRed, utils::RGBA8::kGreen, utils::RGBA8::kBlue}; -} // namespace class SamplerFilterAnisotropicTest : public DawnTest { protected: @@ -293,3 +294,6 @@ DAWN_INSTANTIATE_TEST(SamplerFilterAnisotropicTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/SamplerTests.cpp b/src/dawn/tests/end2end/SamplerTests.cpp index 3de3fb38bf..94f2080b30 100644 --- a/src/dawn/tests/end2end/SamplerTests.cpp +++ b/src/dawn/tests/end2end/SamplerTests.cpp @@ -22,9 +22,11 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 64; -namespace { struct AddressModeTestCase { wgpu::AddressMode mMode; uint8_t mExpected2; @@ -47,7 +49,6 @@ AddressModeTestCase addressModes[] = { 255, }, }; -} // namespace class SamplerTest : public DawnTest { protected: @@ -211,3 +212,6 @@ DAWN_INSTANTIATE_TEST(SamplerTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ScissorTests.cpp b/src/dawn/tests/end2end/ScissorTests.cpp index 5d9a2fab8b..4a6c537d4d 100644 --- a/src/dawn/tests/end2end/ScissorTests.cpp +++ b/src/dawn/tests/end2end/ScissorTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ScissorTest : public DawnTest { protected: wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) { @@ -158,3 +161,6 @@ DAWN_INSTANTIATE_TEST(ScissorTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ShaderF16Tests.cpp b/src/dawn/tests/end2end/ShaderF16Tests.cpp index 9c72ff0cfd..666b6e9b89 100644 --- a/src/dawn/tests/end2end/ShaderF16Tests.cpp +++ b/src/dawn/tests/end2end/ShaderF16Tests.cpp @@ -18,6 +18,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { constexpr uint32_t kRTSize = 16; @@ -26,8 +27,6 @@ constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm; using RequireShaderF16Feature = bool; DAWN_TEST_PARAM_STRUCT(ShaderF16TestsParams, RequireShaderF16Feature); -} // anonymous namespace - class ShaderF16Tests : public DawnTestWithParams { public: wgpu::Texture CreateDefault2DTexture() { @@ -451,3 +450,6 @@ DAWN_INSTANTIATE_TEST_P(ShaderF16Tests, OpenGLESBackend(), }, {true, false}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ShaderTests.cpp b/src/dawn/tests/end2end/ShaderTests.cpp index 76c8161950..fc94c481a6 100644 --- a/src/dawn/tests/end2end/ShaderTests.cpp +++ b/src/dawn/tests/end2end/ShaderTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ShaderTests : public DawnTest { public: wgpu::Buffer CreateBuffer(const uint32_t count) { @@ -1467,3 +1470,6 @@ DAWN_INSTANTIATE_TEST(ShaderTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ShaderValidationTests.cpp b/src/dawn/tests/end2end/ShaderValidationTests.cpp index 9555f729fe..403b2253ef 100644 --- a/src/dawn/tests/end2end/ShaderValidationTests.cpp +++ b/src/dawn/tests/end2end/ShaderValidationTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // The compute shader workgroup size is settled at compute pipeline creation time. // The validation code in dawn is in each backend (not including Null backend) thus this test needs // to be as part of a dawn_end2end_tests instead of the dawn_unittests @@ -382,3 +385,6 @@ DAWN_INSTANTIATE_TEST(WorkgroupSizeValidationTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/StorageTextureTests.cpp b/src/dawn/tests/end2end/StorageTextureTests.cpp index 040363260e..ff6e15871d 100644 --- a/src/dawn/tests/end2end/StorageTextureTests.cpp +++ b/src/dawn/tests/end2end/StorageTextureTests.cpp @@ -24,13 +24,14 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + bool OpenGLESSupportsStorageTexture(wgpu::TextureFormat format) { // TODO(crbug.com/dawn/595): 32-bit RG* formats are unsupported on OpenGL ES. return format != wgpu::TextureFormat::RG32Float && format != wgpu::TextureFormat::RG32Sint && format != wgpu::TextureFormat::RG32Uint; } -} // namespace class StorageTextureTests : public DawnTest { public: @@ -1014,3 +1015,6 @@ DAWN_INSTANTIATE_TEST(StorageTextureZeroInitTests, OpenGLESBackend({"nonzero_clear_resources_on_creation_for_testing"}), MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}), VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp b/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp index 9722c531d0..ee136945d3 100644 --- a/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp +++ b/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // Test that rendering to a subresource of a texture works. class SubresourceRenderAttachmentTest : public DawnTest { constexpr static uint32_t kRTSize = 2; @@ -178,3 +181,6 @@ DAWN_INSTANTIATE_TEST(SubresourceRenderAttachmentTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/SwapChainTests.cpp b/src/dawn/tests/end2end/SwapChainTests.cpp index bf333656b8..779db53971 100644 --- a/src/dawn/tests/end2end/SwapChainTests.cpp +++ b/src/dawn/tests/end2end/SwapChainTests.cpp @@ -23,6 +23,9 @@ #include "GLFW/glfw3.h" +namespace dawn { +namespace { + class SwapChainTests : public DawnTest { public: void SetUp() override { @@ -30,7 +33,7 @@ class SwapChainTests : public DawnTest { DAWN_TEST_UNSUPPORTED_IF(UsesWire()); glfwSetErrorCallback([](int code, const char* message) { - dawn::ErrorLog() << "GLFW error " << code << " " << message; + ErrorLog() << "GLFW error " << code << " " << message; }); // GLFW can fail to start in headless environments, in which SwapChainTests are @@ -397,3 +400,6 @@ DAWN_INSTANTIATE_TEST(SwapChainWithAdditionalUsageTests, MetalBackend(), NullBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/SwapChainValidationTests.cpp b/src/dawn/tests/end2end/SwapChainValidationTests.cpp index 5e2ddabf13..6b0b8afee3 100644 --- a/src/dawn/tests/end2end/SwapChainValidationTests.cpp +++ b/src/dawn/tests/end2end/SwapChainValidationTests.cpp @@ -22,6 +22,9 @@ #include "GLFW/glfw3.h" +namespace dawn { +namespace { + class SwapChainValidationTests : public DawnTest { public: void SetUp() override { @@ -30,7 +33,7 @@ class SwapChainValidationTests : public DawnTest { DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("skip_validation")); glfwSetErrorCallback([](int code, const char* message) { - dawn::ErrorLog() << "GLFW error " << code << " " << message; + ErrorLog() << "GLFW error " << code << " " << message; }); DAWN_TEST_UNSUPPORTED_IF(!glfwInit()); @@ -338,3 +341,6 @@ TEST_P(SwapChainValidationTests, CreateSwapChainFailsAfterDevLost) { } DAWN_INSTANTIATE_TEST(SwapChainValidationTests, MetalBackend(), NullBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/Texture3DTests.cpp b/src/dawn/tests/end2end/Texture3DTests.cpp index 6a6381deb6..bac85923d8 100644 --- a/src/dawn/tests/end2end/Texture3DTests.cpp +++ b/src/dawn/tests/end2end/Texture3DTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/TestUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static uint32_t kRTSize = 4; constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm; @@ -123,3 +126,6 @@ DAWN_INSTANTIATE_TEST(Texture3DTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/TextureCorruptionTests.cpp b/src/dawn/tests/end2end/TextureCorruptionTests.cpp index 1f0b5a7b12..d9a17f79ea 100644 --- a/src/dawn/tests/end2end/TextureCorruptionTests.cpp +++ b/src/dawn/tests/end2end/TextureCorruptionTests.cpp @@ -20,12 +20,14 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // 2D array textures with particular dimensions may corrupt on some devices. This test creates some // 2d-array textures with different dimensions, and test them one by one. For each sub-test, the // tested texture is written via different methods, then read back from the texture and verify the // data. -namespace { enum class WriteType { ClearTexture, WriteTexture, // Write the tested texture via writeTexture API @@ -85,8 +87,6 @@ DAWN_TEST_PARAM_STRUCT(TextureCorruptionTestsParams, SampleCount, WriteType); -} // namespace - class TextureCorruptionTests : public DawnTestWithParams { protected: virtual std::ostringstream& DoSingleTest(wgpu::Texture texture, @@ -461,3 +461,6 @@ DAWN_INSTANTIATE_TEST_P(TextureCorruptionTests_WriteType, {WriteType::ClearTexture, WriteType::WriteTexture, WriteType::B2TCopy, WriteType::RenderConstant, WriteType::RenderFromTextureSample, WriteType::RenderFromTextureLoad}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/TextureFormatTests.cpp b/src/dawn/tests/end2end/TextureFormatTests.cpp index b5cb90c60d..5c87de4599 100644 --- a/src/dawn/tests/end2end/TextureFormatTests.cpp +++ b/src/dawn/tests/end2end/TextureFormatTests.cpp @@ -25,6 +25,7 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { enum class TextureComponentType { @@ -33,8 +34,6 @@ enum class TextureComponentType { Uint, }; -} - // An expectation for float buffer content that can correctly compare different NaN values and // supports a basic tolerance for comparison of finite values. class ExpectFloatWithTolerance : public detail::Expectation { @@ -843,8 +842,8 @@ TEST_P(TextureFormatTest, RG11B10Ufloat) { // TODO(https://crbug.com/swiftshader/147) Rendering INFINITY and NaN isn't handled // correctly by swiftshader if ((IsVulkan() && IsSwiftshader()) || IsANGLE()) { - dawn::WarningLog() << "Skip Rendering test because Swiftshader doesn't render INFINITY " - "and NaN correctly for RG11B10Ufloat texture format."; + WarningLog() << "Skip Rendering test because Swiftshader doesn't render INFINITY " + "and NaN correctly for RG11B10Ufloat texture format."; } else { DoFormatRenderingTest( {wgpu::TextureFormat::RG11B10Ufloat, 4, TextureComponentType::Float, 4}, @@ -907,3 +906,6 @@ DAWN_INSTANTIATE_TEST(TextureFormatTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/TextureSubresourceTests.cpp b/src/dawn/tests/end2end/TextureSubresourceTests.cpp index 169f89d164..cbe4d31467 100644 --- a/src/dawn/tests/end2end/TextureSubresourceTests.cpp +++ b/src/dawn/tests/end2end/TextureSubresourceTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class TextureSubresourceTest : public DawnTest { public: static constexpr uint32_t kSize = 4u; @@ -194,3 +197,6 @@ DAWN_INSTANTIATE_TEST(TextureSubresourceTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/TextureViewTests.cpp b/src/dawn/tests/end2end/TextureViewTests.cpp index 0ed2be291d..ae52dd14a3 100644 --- a/src/dawn/tests/end2end/TextureViewTests.cpp +++ b/src/dawn/tests/end2end/TextureViewTests.cpp @@ -24,11 +24,13 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr static unsigned int kRTSize = 64; constexpr wgpu::TextureFormat kDefaultFormat = wgpu::TextureFormat::RGBA8Unorm; constexpr uint32_t kBytesPerTexel = 4; -namespace { wgpu::Texture Create2DTexture(wgpu::Device device, uint32_t width, uint32_t height, @@ -91,7 +93,6 @@ wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) { } )"); } -} // anonymous namespace class TextureViewSamplingTest : public DawnTest { protected: @@ -1143,3 +1144,6 @@ DAWN_INSTANTIATE_TEST(TextureView1DTest, VulkanBackend(), OpenGLBackend(), OpenGLESBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/TextureZeroInitTests.cpp b/src/dawn/tests/end2end/TextureZeroInitTests.cpp index 9f958e2245..6ddcfcc5a1 100644 --- a/src/dawn/tests/end2end/TextureZeroInitTests.cpp +++ b/src/dawn/tests/end2end/TextureZeroInitTests.cpp @@ -21,16 +21,19 @@ #include "dawn/utils/TestUtils.h" #include "dawn/utils/WGPUHelpers.h" -#define EXPECT_LAZY_CLEAR(N, statement) \ - do { \ - if (UsesWire()) { \ - statement; \ - } else { \ - size_t lazyClearsBefore = dawn::native::GetLazyClearCountForTesting(device.Get()); \ - statement; \ - size_t lazyClearsAfter = dawn::native::GetLazyClearCountForTesting(device.Get()); \ - EXPECT_EQ(N, lazyClearsAfter - lazyClearsBefore); \ - } \ +namespace dawn { +namespace { + +#define EXPECT_LAZY_CLEAR(N, statement) \ + do { \ + if (UsesWire()) { \ + statement; \ + } else { \ + size_t lazyClearsBefore = native::GetLazyClearCountForTesting(device.Get()); \ + statement; \ + size_t lazyClearsAfter = native::GetLazyClearCountForTesting(device.Get()); \ + EXPECT_EQ(N, lazyClearsAfter - lazyClearsBefore); \ + } \ } while (0) class TextureZeroInitTest : public DawnTest { @@ -168,7 +171,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferSource) { EXPECT_LAZY_CLEAR(1u, EXPECT_PIXEL_RGBA8_EQ(filledWithZeros, texture, 0, 0)); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // This tests that the code path of CopyTextureToBuffer with multiple texture array layers clears @@ -203,8 +206,7 @@ TEST_P(TextureZeroInitTest, CopyMultipleTextureArrayLayersToBufferSource) { EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commandBuffer)); // Expect texture subresource initialized to be true - EXPECT_TRUE( - dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, kArrayLayers)); + EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, kArrayLayers)); const std::vector kExpectedAllZero(kSize * kSize, {0, 0, 0, 0}); for (uint32_t layer = 0; layer < kArrayLayers; ++layer) { @@ -253,8 +255,8 @@ TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) { baseMipLevel); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - renderPass.color.Get(), baseMipLevel, 1, baseArrayLayer, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(renderPass.color.Get(), baseMipLevel, 1, + baseArrayLayer, 1)); } // Test that non-zero array layers clears subresource to Zero after first use. @@ -296,8 +298,8 @@ TEST_P(TextureZeroInitTest, RenderingArrayLayerClearsToZero) { baseMipLevel); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - renderPass.color.Get(), baseMipLevel, 1, baseArrayLayer, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(renderPass.color.Get(), baseMipLevel, 1, + baseArrayLayer, 1)); } // This tests CopyBufferToTexture fully overwrites copy so lazy init is not needed. @@ -328,7 +330,7 @@ TEST_P(TextureZeroInitTest, CopyBufferToTexture) { EXPECT_TEXTURE_EQ(expected.data(), texture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // Test for a copy only to a subset of the subresource, lazy init is necessary to clear the other @@ -363,7 +365,7 @@ TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) { EXPECT_TEXTURE_EQ(expectedZeros.data(), texture, {kSize / 2, 0}, {kSize / 2, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // This tests CopyBufferToTexture fully overwrites a range of subresources, so lazy initialization @@ -394,8 +396,8 @@ TEST_P(TextureZeroInitTest, CopyBufferToTextureMultipleArrayLayers) { EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); // Expect texture subresource initialized to be true - EXPECT_TRUE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, - kCopyLayerCount)); + EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, + kCopyLayerCount)); const std::vector expected100(kSize * kSize, {100, 100, 100, 100}); for (uint32_t layer = kBaseArrayLayer; layer < kBaseArrayLayer + kCopyLayerCount; ++layer) { @@ -435,8 +437,8 @@ TEST_P(TextureZeroInitTest, CopyTextureToTexture) { EXPECT_TEXTURE_EQ(expected.data(), dstTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(dstTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(dstTexture.Get(), 0, 1, 0, 1)); } // This Tests the CopyTextureToTexture's copy only to a subset of the subresource, lazy init is @@ -492,8 +494,8 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) { EXPECT_TEXTURE_EQ(expectedWithZeros.data(), dstTexture, {kSize / 2, 0}, {kSize / 2, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(dstTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(dstTexture.Get(), 0, 1, 0, 1)); } // This tests the texture with depth attachment and load op load will init depth stencil texture to @@ -538,7 +540,7 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepth) { EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); } // This tests the texture with stencil attachment and load op load will init depth stencil texture @@ -583,7 +585,7 @@ TEST_P(TextureZeroInitTest, RenderingLoadingStencil) { EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); } // This tests the texture with depth stencil attachment and load op load will init depth stencil @@ -625,7 +627,7 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) { EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(srcTexture.Get(), 0, 1, 0, 1)); } // Test that clear state is tracked independently for depth/stencil textures. @@ -656,12 +658,12 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) { } // "all" subresources are not initialized; Depth is not initialized - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_All)); - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_DepthOnly)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_StencilOnly)); + EXPECT_EQ(false, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_All)); + EXPECT_EQ(false, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_DepthOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_StencilOnly)); // Now load both depth and stencil. Depth should be cleared and stencil should stay the same // at 2. @@ -695,12 +697,12 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) { } // Everything is initialized now - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_All)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_DepthOnly)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_StencilOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_All)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_DepthOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_StencilOnly)); // TODO(crbug.com/dawn/439): Implement stencil copies on other platforms if (IsMetal() || IsVulkan() || IsD3D12()) { @@ -731,12 +733,12 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) { } // "all" subresources are not initialized; Stencil is not initialized - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_All)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_DepthOnly)); - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_StencilOnly)); + EXPECT_EQ(false, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_All)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_DepthOnly)); + EXPECT_EQ(false, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_StencilOnly)); // Now load both depth and stencil. Stencil should be cleared and depth should stay the same // at 0.7. @@ -769,12 +771,12 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) { } // Everything is initialized now - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_All)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_DepthOnly)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_StencilOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_All)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_DepthOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, + 1, WGPUTextureAspect_StencilOnly)); // TODO(crbug.com/dawn/439): Implement stencil copies on other platforms if (IsMetal() || IsVulkan() || IsD3D12()) { @@ -942,12 +944,12 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilCopyAfterDiscard) { } // "all" subresources are not initialized; Stencil is not initialized - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, - 0, 1, WGPUTextureAspect_All)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_DepthOnly)); - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_StencilOnly)); + EXPECT_EQ(false, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1, + WGPUTextureAspect_All)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1, + WGPUTextureAspect_DepthOnly)); + EXPECT_EQ(false, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1, + WGPUTextureAspect_StencilOnly)); // Check by copy that the stencil data is lazily cleared to 0. std::vector expected(kSize * kSize, 0); @@ -955,12 +957,12 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilCopyAfterDiscard) { {kSize, kSize}, 0, wgpu::TextureAspect::StencilOnly)); // Everything is initialized now - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, - 0, 1, WGPUTextureAspect_All)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_DepthOnly)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - depthStencilTexture.Get(), 0, 1, 0, 1, WGPUTextureAspect_StencilOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1, + WGPUTextureAspect_All)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1, + WGPUTextureAspect_DepthOnly)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1, + WGPUTextureAspect_StencilOnly)); // Now load both depth and stencil. Stencil should be cleared and depth should stay the same // at 0.3. @@ -1012,8 +1014,7 @@ TEST_P(TextureZeroInitTest, ColorAttachmentsClear) { EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, - dawn::native::IsTextureSubresourceInitialized(renderPass.color.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(renderPass.color.Get(), 0, 1, 0, 1)); } // This tests the clearing of sampled textures in render pass @@ -1057,7 +1058,7 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) { EXPECT_TEXTURE_EQ(expectedWithZeros.data(), renderTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(renderTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(renderTexture.Get(), 0, 1, 0, 1)); } // This is a regression test for a bug where a texture wouldn't get clear for a pass if at least @@ -1114,7 +1115,7 @@ TEST_P(TextureZeroInitTest, TextureBothSampledAndAttachmentClear) { EXPECT_TEXTURE_EQ(&utils::RGBA8::kZero, texture, {0, 0, 1}, {1, 1}); // The whole texture is now initialized. - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 2)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 2)); } // This tests the clearing of sampled textures during compute pass @@ -1176,7 +1177,7 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) { EXPECT_BUFFER_U32_RANGE_EQ(expectedWithZeros.data(), bufferTex, 0, kFormatBlockByteSize); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // This tests that the code path of CopyTextureToBuffer clears correctly for non-renderable textures @@ -1209,7 +1210,7 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClear) { EXPECT_BUFFER_U32_RANGE_EQ(expectedWithZeros.data(), bufferDst, 0, kSize); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // This tests that the code path of CopyTextureToBuffer clears correctly for non-renderable textures @@ -1244,7 +1245,7 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClearUnalignedSize) { EXPECT_BUFFER_U32_RANGE_EQ(expectedWithZeros.data(), bufferDst, 0, kUnalignedSize); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // This tests that the code path of CopyTextureToBuffer clears correctly for non-renderable textures @@ -1278,7 +1279,7 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClearWithMultiArrayLayers) { EXPECT_BUFFER_U32_RANGE_EQ(expectedWithZeros.data(), bufferDst, 0, 8); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 1, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 1, 1)); } // This tests that storeOp clear resets resource state to uninitialized. @@ -1342,8 +1343,8 @@ TEST_P(TextureZeroInitTest, RenderPassStoreOpClear) { 1u, EXPECT_TEXTURE_EQ(expectedWithZeros.data(), renderTexture, {0, 0}, {kSize, kSize})); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(renderTexture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(renderTexture.Get(), 0, 1, 0, 1)); } // This tests storeOp Clear on depth and stencil textures. @@ -1396,8 +1397,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencilStoreOpClear) { // Expect texture subresource initialized to be false since storeop is clear, sets // subresource as uninitialized - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, - 1, 0, 1)); + EXPECT_EQ(false, + native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1)); } // Now we put the depth stencil texture back into renderpass, it should be cleared by loadop @@ -1421,8 +1422,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencilStoreOpClear) { // Expect texture subresource initialized to be false since storeop is clear, sets // subresource as uninitialized - EXPECT_EQ(false, dawn::native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, - 1, 0, 1)); + EXPECT_EQ(false, + native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0, 1)); } } @@ -1499,7 +1500,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedMip) { {mipSize, mipSize}, 1)); // Expect the whole texture to be initialized - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(sampleTexture.Get(), 0, 2, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(sampleTexture.Get(), 0, 2, 0, 1)); } // Test that if one layer of a texture is initialized and another is uninitialized, lazy clearing @@ -1580,7 +1581,7 @@ TEST_P(TextureZeroInitTest, PreservesInitializedArrayLayer) { 0u, EXPECT_TEXTURE_EQ(expectedWithTwos.data(), sampleTexture, {0, 0, 1}, {kSize, kSize})); // Expect the whole texture to be initialized - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(sampleTexture.Get(), 0, 1, 0, 2)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(sampleTexture.Get(), 0, 1, 0, 2)); } // This is a regression test for crbug.com/dawn/451 where the lazy texture @@ -1622,7 +1623,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) { } // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } // In this test WriteTexture fully overwrites a texture @@ -1651,7 +1652,7 @@ TEST_P(TextureZeroInitTest, WriteWholeTexture) { &textureDataLayout, ©Size)); // Expect texture initialized to be true - EXPECT_TRUE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0}, {kSize, kSize}); } @@ -1685,7 +1686,7 @@ TEST_P(TextureZeroInitTest, WriteTextureHalf) { &textureDataLayout, ©Size)); // Expect texture initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); std::vector expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0}); // first half filled with 100, by the data @@ -1726,8 +1727,8 @@ TEST_P(TextureZeroInitTest, WriteWholeTextureArray) { &textureDataLayout, ©Size)); // Expect texture subresource initialized to be true - EXPECT_TRUE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, - kCopyLayerCount)); + EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, + kCopyLayerCount)); for (uint32_t layer = kBaseArrayLayer; layer < kBaseArrayLayer + kCopyLayerCount; ++layer) { EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0, layer}, {kSize, kSize}); @@ -1767,8 +1768,8 @@ TEST_P(TextureZeroInitTest, WriteTextureArrayHalf) { &textureDataLayout, ©Size)); // Expect texture subresource initialized to be true - EXPECT_EQ(true, dawn::native::IsTextureSubresourceInitialized( - texture.Get(), 0, 1, kBaseArrayLayer, kCopyLayerCount)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, + kCopyLayerCount)); std::vector expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0}); for (uint32_t layer = kBaseArrayLayer; layer < kBaseArrayLayer + kCopyLayerCount; ++layer) { @@ -1809,7 +1810,7 @@ TEST_P(TextureZeroInitTest, WriteWholeTextureAtMipLevel) { &textureDataLayout, ©Size)); // Expect texture initialized to be true - EXPECT_TRUE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), kMipLevel, 1, 0, 1)); + EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), kMipLevel, 1, 0, 1)); EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0}, {kMipSize, kMipSize}, kMipLevel); } @@ -1847,8 +1848,7 @@ TEST_P(TextureZeroInitTest, WriteTextureHalfAtMipLevel) { &textureDataLayout, ©Size)); // Expect texture initialized to be true - EXPECT_EQ(true, - dawn::native::IsTextureSubresourceInitialized(texture.Get(), kMipLevel, 1, 0, 1)); + EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), kMipLevel, 1, 0, 1)); std::vector expectedZeros((kMipSize / 2) * kMipSize, {0, 0, 0, 0}); // first half filled with 100, by the data @@ -1865,14 +1865,14 @@ TEST_P(TextureZeroInitTest, ErrorTextureIsUninitialized) { // Test CreateErrorTexture. wgpu::Texture texture = device.CreateErrorTexture(&descriptor); - EXPECT_FALSE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_FALSE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); // Test CreateTexture with an error descriptor. if (!HasToggleEnabled("skip_validation")) { descriptor = CreateTextureDescriptor(1, 1, wgpu::TextureUsage::CopyDst, static_cast(-4)); ASSERT_DEVICE_ERROR(texture = device.CreateTexture(&descriptor)); - EXPECT_FALSE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); + EXPECT_FALSE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); } } @@ -2006,8 +2006,8 @@ class CompressedTextureZeroInitTest : public TextureZeroInitTest { {0x00, 0x20, 0x08, 0xFF}); EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {0, 0}, {nonPaddedCopyExtent.width, nonPaddedCopyExtent.height}); - EXPECT_TRUE(dawn::native::IsTextureSubresourceInitialized(bcTexture.Get(), viewMipmapLevel, - 1, baseArrayLayer, 1)); + EXPECT_TRUE(native::IsTextureSubresourceInitialized(bcTexture.Get(), viewMipmapLevel, 1, + baseArrayLayer, 1)); // If we only copied to half the texture, check the other half is initialized to black if (halfCopyTest) { @@ -2327,3 +2327,6 @@ DAWN_INSTANTIATE_TEST(CompressedTextureZeroInitTest, OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}), OpenGLESBackend({"nonzero_clear_resources_on_creation_for_testing"}), VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/VertexFormatTests.cpp b/src/dawn/tests/end2end/VertexFormatTests.cpp index 42c6aec826..22a85c026e 100644 --- a/src/dawn/tests/end2end/VertexFormatTests.cpp +++ b/src/dawn/tests/end2end/VertexFormatTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // Vertex format tests all work the same way: the test will render a triangle. // Each test will set up a vertex buffer, and the vertex shader will check that // the vertex content is the same as what we expected. On success it outputs green, @@ -33,7 +36,7 @@ constexpr uint32_t kVertexNum = 3; std::vector Float32ToFloat16(std::vector data) { std::vector expectedData; for (auto& element : data) { - expectedData.push_back(Float32ToFloat16(element)); + expectedData.push_back(dawn::Float32ToFloat16(element)); } return expectedData; } @@ -835,3 +838,6 @@ DAWN_INSTANTIATE_TEST(VertexFormatTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp b/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp index bdf9ab86da..4e1afec2bd 100644 --- a/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp +++ b/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8; constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm; constexpr uint32_t kRTWidth = 4; @@ -319,3 +322,6 @@ DAWN_INSTANTIATE_TEST(VertexOnlyRenderPipelineTest, OpenGLESBackend({"use_placeholder_fragment_in_vertex_only_pipeline"}), VulkanBackend(), VulkanBackend({"use_placeholder_fragment_in_vertex_only_pipeline"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/VertexStateTests.cpp b/src/dawn/tests/end2end/VertexStateTests.cpp index 5a962aba62..9c86138e8e 100644 --- a/src/dawn/tests/end2end/VertexStateTests.cpp +++ b/src/dawn/tests/end2end/VertexStateTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + using wgpu::VertexFormat; using wgpu::VertexStepMode; @@ -698,3 +701,6 @@ DAWN_INSTANTIATE_TEST(OptionalVertexStateTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/VideoViewsTests.cpp b/src/dawn/tests/end2end/VideoViewsTests.cpp index eee92bdd3b..4af6bee8ba 100644 --- a/src/dawn/tests/end2end/VideoViewsTests.cpp +++ b/src/dawn/tests/end2end/VideoViewsTests.cpp @@ -18,6 +18,8 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { + VideoViewsTestBackend::PlatformTexture::PlatformTexture(wgpu::Texture&& texture) : wgpuTexture(texture) {} VideoViewsTestBackend::PlatformTexture::~PlatformTexture() = default; @@ -218,6 +220,8 @@ TEST_P(VideoViewsTests, CreateVideoTextureWithoutInitializedData) { mBackend->DestroyVideoTextureForTest(std::move(platformTexture)); } +namespace { + // Samples the luminance (Y) plane from an imported NV12 texture into a single channel of an RGBA // output attachment and checks for the expected pixel value in the rendered quad. TEST_P(VideoViewsTests, NV12SampleYtoR) { @@ -486,3 +490,6 @@ TEST_P(VideoViewsTests, NV12SampleYUVtoRGBMultipleSamplers) { } DAWN_INSTANTIATE_TEST(VideoViewsTests, VideoViewsTestBackend::Backend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/VideoViewsTests.h b/src/dawn/tests/end2end/VideoViewsTests.h index d3d95207fb..4b2175ce5b 100644 --- a/src/dawn/tests/end2end/VideoViewsTests.h +++ b/src/dawn/tests/end2end/VideoViewsTests.h @@ -21,6 +21,8 @@ #include "dawn/tests/DawnTest.h" +namespace dawn { + class VideoViewsTestBackend { public: static BackendTestConfig Backend(); @@ -63,21 +65,21 @@ class VideoViewsTests : public DawnTest { // RGB colors converted into YUV (per plane), for testing. // RGB colors are mapped to the BT.601 definition of luma. // https://docs.microsoft.com/en-us/windows/win32/medfound/about-yuv-video - static constexpr std::array kYellowYUVColor = { - utils::RGBA8{210, 0, 0, 0xFF}, // Y - utils::RGBA8{16, 146, 0, 0xFF}}; // UV + static constexpr std::array kYellowYUVColor = { + dawn::utils::RGBA8{210, 0, 0, 0xFF}, // Y + dawn::utils::RGBA8{16, 146, 0, 0xFF}}; // UV - static constexpr std::array kWhiteYUVColor = { - utils::RGBA8{235, 0, 0, 0xFF}, // Y - utils::RGBA8{128, 128, 0, 0xFF}}; // UV + static constexpr std::array kWhiteYUVColor = { + dawn::utils::RGBA8{235, 0, 0, 0xFF}, // Y + dawn::utils::RGBA8{128, 128, 0, 0xFF}}; // UV - static constexpr std::array kBlueYUVColor = { - utils::RGBA8{41, 0, 0, 0xFF}, // Y - utils::RGBA8{240, 110, 0, 0xFF}}; // UV + static constexpr std::array kBlueYUVColor = { + dawn::utils::RGBA8{41, 0, 0, 0xFF}, // Y + dawn::utils::RGBA8{240, 110, 0, 0xFF}}; // UV - static constexpr std::array kRedYUVColor = { - utils::RGBA8{81, 0, 0, 0xFF}, // Y - utils::RGBA8{90, 240, 0, 0xFF}}; // UV + static constexpr std::array kRedYUVColor = { + dawn::utils::RGBA8{81, 0, 0, 0xFF}, // Y + dawn::utils::RGBA8{90, 240, 0, 0xFF}}; // UV static std::vector GetTestTextureData(wgpu::TextureFormat format, bool isCheckerboard); static uint32_t NumPlanes(wgpu::TextureFormat format); @@ -97,4 +99,6 @@ class VideoViewsTests : public DawnTest { bool mIsMultiPlanarFormatsSupported = false; }; +} // namespace dawn + #endif // SRC_DAWN_TESTS_END2END_VIDEOVIEWSTESTS_H_ diff --git a/src/dawn/tests/end2end/VideoViewsTests_gbm.cpp b/src/dawn/tests/end2end/VideoViewsTests_gbm.cpp index d9adb4f5b4..ba7f1dd965 100644 --- a/src/dawn/tests/end2end/VideoViewsTests_gbm.cpp +++ b/src/dawn/tests/end2end/VideoViewsTests_gbm.cpp @@ -24,6 +24,9 @@ #include "dawn/common/Assert.h" #include "dawn/native/VulkanBackend.h" +namespace dawn { +namespace { + // "linux-chromeos-rel"'s gbm.h is too old to compile, missing this change at least: // https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1963001/10/gbm.h#244 #ifndef MINIGBM @@ -178,7 +181,7 @@ class VideoViewsTestBackendGbm : public VideoViewsTestBackend { internalDesc.internalUsage = wgpu::TextureUsage::CopySrc; textureDesc.nextInChain = &internalDesc; - dawn::native::vulkan::ExternalImageDescriptorDmaBuf descriptor = {}; + native::vulkan::ExternalImageDescriptorDmaBuf descriptor = {}; descriptor.cTextureDescriptor = reinterpret_cast(&textureDesc); descriptor.isInitialized = true; @@ -191,7 +194,7 @@ class VideoViewsTestBackendGbm : public VideoViewsTestBackend { descriptor.drmModifier = gbm_bo_get_modifier(gbmBo); descriptor.waitFDs = {}; - WGPUTexture texture = dawn::native::vulkan::WrapVulkanImage(mWGPUDevice, &descriptor); + WGPUTexture texture = native::vulkan::WrapVulkanImage(mWGPUDevice, &descriptor); if (texture != nullptr) { return std::make_unique(wgpu::Texture::Acquire(texture), gbmBo); } else { @@ -202,9 +205,9 @@ class VideoViewsTestBackendGbm : public VideoViewsTestBackend { void DestroyVideoTextureForTest( std::unique_ptr&& platformTexture) override { // Exports the signal and ignores it. - dawn::native::vulkan::ExternalImageExportInfoDmaBuf exportInfo; - dawn::native::vulkan::ExportVulkanImage(platformTexture->wgpuTexture.Get(), - VK_IMAGE_LAYOUT_UNDEFINED, &exportInfo); + native::vulkan::ExternalImageExportInfoDmaBuf exportInfo; + native::vulkan::ExportVulkanImage(platformTexture->wgpuTexture.Get(), + VK_IMAGE_LAYOUT_UNDEFINED, &exportInfo); for (int fd : exportInfo.semaphoreHandles) { ASSERT_NE(fd, -1); close(fd); @@ -218,6 +221,8 @@ class VideoViewsTestBackendGbm : public VideoViewsTestBackend { gbm_device* mGbmDevice = nullptr; }; +} // anonymous namespace + // static BackendTestConfig VideoViewsTestBackend::Backend() { return VulkanBackend(); @@ -227,3 +232,5 @@ BackendTestConfig VideoViewsTestBackend::Backend() { std::unique_ptr VideoViewsTestBackend::Create() { return std::make_unique(); } + +} // namespace dawn diff --git a/src/dawn/tests/end2end/VideoViewsTests_mac.cpp b/src/dawn/tests/end2end/VideoViewsTests_mac.cpp index d23cc1355c..02c91fd1d4 100644 --- a/src/dawn/tests/end2end/VideoViewsTests_mac.cpp +++ b/src/dawn/tests/end2end/VideoViewsTests_mac.cpp @@ -25,15 +25,15 @@ #include "dawn/common/CoreFoundationRef.h" #include "dawn/native/MetalBackend.h" +namespace dawn { namespace { + void AddIntegerValue(CFMutableDictionaryRef dictionary, const CFStringRef key, int32_t value) { CFNumberRef number(CFNumberCreate(nullptr, kCFNumberSInt32Type, &value)); CFDictionaryAddValue(dictionary, key, number); CFRelease(number); } -} // anonymous namespace - class PlatformTextureIOSurface : public VideoViewsTestBackend::PlatformTexture { public: PlatformTextureIOSurface(wgpu::Texture&& texture, IOSurfaceRef iosurface) @@ -158,14 +158,14 @@ class VideoViewsTestBackendIOSurface : public VideoViewsTestBackend { internalDesc.internalUsage = wgpu::TextureUsage::CopySrc; textureDesc.nextInChain = &internalDesc; - dawn::native::metal::ExternalImageDescriptorIOSurface descriptor = {}; + native::metal::ExternalImageDescriptorIOSurface descriptor = {}; descriptor.cTextureDescriptor = reinterpret_cast(&textureDesc); descriptor.isInitialized = true; descriptor.ioSurface = surface; return std::make_unique( - wgpu::Texture::Acquire(dawn::native::metal::WrapIOSurface(mWGPUDevice, &descriptor)), + wgpu::Texture::Acquire(native::metal::WrapIOSurface(mWGPUDevice, &descriptor)), surface); } @@ -175,6 +175,8 @@ class VideoViewsTestBackendIOSurface : public VideoViewsTestBackend { WGPUDevice mWGPUDevice = nullptr; }; +} // anonymous namespace + // static BackendTestConfig VideoViewsTestBackend::Backend() { return MetalBackend(); @@ -184,3 +186,5 @@ BackendTestConfig VideoViewsTestBackend::Backend() { std::unique_ptr VideoViewsTestBackend::Create() { return std::make_unique(); } + +} // namespace dawn diff --git a/src/dawn/tests/end2end/VideoViewsTests_win.cpp b/src/dawn/tests/end2end/VideoViewsTests_win.cpp index cf06ce4ff8..f5b5e42bc8 100644 --- a/src/dawn/tests/end2end/VideoViewsTests_win.cpp +++ b/src/dawn/tests/end2end/VideoViewsTests_win.cpp @@ -26,6 +26,9 @@ #include "dawn/common/Assert.h" #include "dawn/native/D3D12Backend.h" +namespace dawn { +namespace { + using Microsoft::WRL::ComPtr; class PlatformTextureWin : public VideoViewsTestBackend::PlatformTexture { @@ -45,7 +48,7 @@ class VideoViewsTestBackendWin : public VideoViewsTestBackend { // Create the D3D11 device/contexts that will be used in subsequent tests ComPtr dxgiAdapter = - dawn::native::d3d::GetDXGIAdapter(wgpuDeviceGetAdapter(device)); + native::d3d::GetDXGIAdapter(wgpuDeviceGetAdapter(device)); ComPtr d3d11Device; D3D_FEATURE_LEVEL d3dFeatureLevel; @@ -161,22 +164,22 @@ class VideoViewsTestBackendWin : public VideoViewsTestBackend { ASSERT(hr == S_OK); // Open the DX11 texture in Dawn from the shared handle and return it as a WebGPU texture. - dawn::native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc; + native::d3d::ExternalImageDescriptorDXGISharedHandle externalImageDesc; externalImageDesc.cTextureDescriptor = reinterpret_cast(&textureDesc); externalImageDesc.sharedHandle = sharedHandle; - std::unique_ptr externalImage = - dawn::native::d3d::ExternalImageDXGI::Create(mWGPUDevice, &externalImageDesc); + std::unique_ptr externalImage = + native::d3d::ExternalImageDXGI::Create(mWGPUDevice, &externalImageDesc); // Handle is no longer needed once resources are created. ::CloseHandle(sharedHandle); - dawn::native::d3d::ExternalImageDXGIFenceDescriptor fenceDesc; + native::d3d::ExternalImageDXGIFenceDescriptor fenceDesc; fenceDesc.fenceHandle = fenceSharedHandle; fenceDesc.fenceValue = 1; - dawn::native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; + native::d3d::ExternalImageDXGIBeginAccessDescriptor externalAccessDesc; externalAccessDesc.isInitialized = true; externalAccessDesc.usage = static_cast(textureDesc.usage); externalAccessDesc.waitFences = {}; @@ -196,6 +199,8 @@ class VideoViewsTestBackendWin : public VideoViewsTestBackend { ComPtr mD3d11Device; }; +} // anonymous namespace + // static BackendTestConfig VideoViewsTestBackend::Backend() { return D3D12Backend(); @@ -204,3 +209,5 @@ BackendTestConfig VideoViewsTestBackend::Backend() { std::unique_ptr VideoViewsTestBackend::Create() { return std::make_unique(); } + +} // namespace dawn diff --git a/src/dawn/tests/end2end/ViewportOrientationTests.cpp b/src/dawn/tests/end2end/ViewportOrientationTests.cpp index 11b7fdcb1d..70738b93f3 100644 --- a/src/dawn/tests/end2end/ViewportOrientationTests.cpp +++ b/src/dawn/tests/end2end/ViewportOrientationTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ViewportOrientationTests : public DawnTest {}; // Test that the pixel in viewport coordinate (-1, -1) matches texel (0, 0) @@ -65,3 +68,6 @@ DAWN_INSTANTIATE_TEST(ViewportOrientationTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/ViewportTests.cpp b/src/dawn/tests/end2end/ViewportTests.cpp index 6233c4ad7c..e74b30cf06 100644 --- a/src/dawn/tests/end2end/ViewportTests.cpp +++ b/src/dawn/tests/end2end/ViewportTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ViewportTest : public DawnTest { private: void SetUp() override { @@ -226,3 +229,6 @@ DAWN_INSTANTIATE_TEST(ViewportTest, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/end2end/WindowSurfaceTests.cpp b/src/dawn/tests/end2end/WindowSurfaceTests.cpp index 31ec57a57e..9656a45f93 100644 --- a/src/dawn/tests/end2end/WindowSurfaceTests.cpp +++ b/src/dawn/tests/end2end/WindowSurfaceTests.cpp @@ -40,17 +40,20 @@ #include "GLFW/glfw3native.h" +namespace dawn { +namespace { + // Test for wgpu::Surface creation that only need an instance (no devices) and don't need all the // complexity of DawnTest. class WindowSurfaceInstanceTests : public testing::Test { public: void SetUp() override { glfwSetErrorCallback([](int code, const char* message) { - dawn::ErrorLog() << "GLFW error " << code << " " << message; + ErrorLog() << "GLFW error " << code << " " << message; }); DAWN_TEST_UNSUPPORTED_IF(!glfwInit()); - dawnProcSetProcs(&dawn::native::GetProcs()); + dawnProcSetProcs(&native::GetProcs()); mInstance = wgpu::CreateInstance(); } @@ -64,7 +67,7 @@ class WindowSurfaceInstanceTests : public testing::Test { void AssertSurfaceCreation(const wgpu::SurfaceDescriptor* descriptor, bool succeeds) { wgpu::Surface surface = mInstance.CreateSurface(descriptor); - ASSERT_EQ(dawn::native::CheckIsErrorForTesting(surface.Get()), !succeeds); + ASSERT_EQ(native::CheckIsErrorForTesting(surface.Get()), !succeeds); } GLFWwindow* CreateWindow() { @@ -248,3 +251,6 @@ TEST_F(WindowSurfaceInstanceTests, MetalSurfacesAreInvalid) { } #endif // defined(DAWN_ENABLE_BACKEND_METAL) + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/mocks/platform/CachingInterfaceMock.h b/src/dawn/tests/mocks/platform/CachingInterfaceMock.h index 79cff16fd8..d156632ccf 100644 --- a/src/dawn/tests/mocks/platform/CachingInterfaceMock.h +++ b/src/dawn/tests/mocks/platform/CachingInterfaceMock.h @@ -39,8 +39,8 @@ // Hit / Add help readability, and enforce the args are passed correctly in the expected order. #define EXPECT_CACHE_STATS(cache, HitN, AddN, statement) \ do { \ - using Hit = TypedInteger; \ - using Add = TypedInteger; \ + using Hit = dawn::TypedInteger; \ + using Add = dawn::TypedInteger; \ static_assert(std::is_same_v); \ static_assert(std::is_same_v); \ FlushWire(); \ diff --git a/src/dawn/tests/perf_tests/DawnPerfTest.cpp b/src/dawn/tests/perf_tests/DawnPerfTest.cpp index f53b806901..521cbf8624 100644 --- a/src/dawn/tests/perf_tests/DawnPerfTest.cpp +++ b/src/dawn/tests/perf_tests/DawnPerfTest.cpp @@ -178,7 +178,7 @@ DawnPerfTestBase::DawnPerfTestBase(DawnTestBase* test, : mTest(test), mIterationsPerStep(iterationsPerStep), mMaxStepsInFlight(maxStepsInFlight), - mTimer(utils::CreateTimer()) {} + mTimer(dawn::utils::CreateTimer()) {} DawnPerfTestBase::~DawnPerfTestBase() = default; diff --git a/src/dawn/tests/perf_tests/DawnPerfTest.h b/src/dawn/tests/perf_tests/DawnPerfTest.h index 20d2a2f9ca..77b92fadd7 100644 --- a/src/dawn/tests/perf_tests/DawnPerfTest.h +++ b/src/dawn/tests/perf_tests/DawnPerfTest.h @@ -20,7 +20,7 @@ #include "dawn/tests/DawnTest.h" -namespace utils { +namespace dawn::utils { class Timer; } @@ -108,7 +108,7 @@ class DawnPerfTestBase { unsigned int mStepsToRun = 0; unsigned int mNumStepsPerformed = 0; double mCpuTime; - std::unique_ptr mTimer; + std::unique_ptr mTimer; }; template diff --git a/src/dawn/tests/perf_tests/DawnPerfTestPlatform.cpp b/src/dawn/tests/perf_tests/DawnPerfTestPlatform.cpp index 32e77fd3cc..2ca9b19c7b 100644 --- a/src/dawn/tests/perf_tests/DawnPerfTestPlatform.cpp +++ b/src/dawn/tests/perf_tests/DawnPerfTestPlatform.cpp @@ -44,7 +44,7 @@ static_assert(static_cast(dawn::platform::TraceCategory::GPUWork) == 3 } // anonymous namespace DawnPerfTestPlatform::DawnPerfTestPlatform() - : dawn::platform::Platform(), mTimer(utils::CreateTimer()) {} + : dawn::platform::Platform(), mTimer(dawn::utils::CreateTimer()) {} DawnPerfTestPlatform::~DawnPerfTestPlatform() = default; @@ -112,8 +112,8 @@ uint64_t DawnPerfTestPlatform::AddTraceEvent(char phase, buffer->emplace_back(phase, info->category, name, id, timestamp); size_t hash = 0; - HashCombine(&hash, buffer->size()); - HashCombine(&hash, std::this_thread::get_id()); + dawn::HashCombine(&hash, buffer->size()); + dawn::HashCombine(&hash, std::this_thread::get_id()); return static_cast(hash); } diff --git a/src/dawn/tests/perf_tests/DawnPerfTestPlatform.h b/src/dawn/tests/perf_tests/DawnPerfTestPlatform.h index 6c3a95eddd..1c0521ff13 100644 --- a/src/dawn/tests/perf_tests/DawnPerfTestPlatform.h +++ b/src/dawn/tests/perf_tests/DawnPerfTestPlatform.h @@ -24,7 +24,7 @@ #include "dawn/platform/DawnPlatform.h" -namespace utils { +namespace dawn::utils { class Timer; } @@ -80,7 +80,7 @@ class DawnPerfTestPlatform : public dawn::platform::Platform { unsigned char flags) override; bool mRecordTraceEvents = false; - std::unique_ptr mTimer; + std::unique_ptr mTimer; // Trace event record. // Each uses their own trace event buffer, but the PerfTestPlatform owns all of them in diff --git a/src/dawn/tests/perf_tests/DrawCallPerf.cpp b/src/dawn/tests/perf_tests/DrawCallPerf.cpp index 640e156137..6f7d0ec718 100644 --- a/src/dawn/tests/perf_tests/DrawCallPerf.cpp +++ b/src/dawn/tests/perf_tests/DrawCallPerf.cpp @@ -22,6 +22,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { constexpr unsigned int kNumDraws = 2000; @@ -195,8 +196,6 @@ std::ostream& operator<<(std::ostream& ostream, const DrawCallParamForTest& test return ostream; } -} // anonymous namespace - // DrawCallPerf is an uber-benchmark with supports many parameterizations. // The specific parameterizations we care about are explicitly instantiated at the bottom // of this test file. @@ -650,3 +649,6 @@ DAWN_INSTANTIATE_TEST_P( MakeParam(BindGroup::Dynamic, UniformData::Dynamic), // Update per-draw data: Dynamic bind groups }); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp b/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp index 3b174ad017..7868b7bd38 100644 --- a/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp +++ b/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp @@ -18,7 +18,9 @@ #include "dawn/tests/perf_tests/DawnPerfTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + constexpr uint32_t kTileSize = 32u; const std::string& kMatMulFloatHeader = R"( @@ -378,8 +380,6 @@ using DimInner = uint32_t; using DimBOuter = uint32_t; DAWN_TEST_PARAM_STRUCT(ShaderRobustnessParams, MatMulMethod, DimAOuter, DimInner, DimBOuter); -} // namespace - // Test the execution time of matrix multiplication (A [dimAOuter, dimInner] * B [dimInner, // dimBOuter]) on the GPU and see the difference between robustness on and off. class ShaderRobustnessPerf : public DawnPerfTestWithParams { @@ -508,3 +508,6 @@ DAWN_INSTANTIATE_TEST_P(ShaderRobustnessPerf, {512u}, {512u}, {512u}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/perf_tests/SubresourceTrackingPerf.cpp b/src/dawn/tests/perf_tests/SubresourceTrackingPerf.cpp index e3ccb6f586..d22510e4ee 100644 --- a/src/dawn/tests/perf_tests/SubresourceTrackingPerf.cpp +++ b/src/dawn/tests/perf_tests/SubresourceTrackingPerf.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + struct SubresourceTrackingParams : AdapterTestParam { SubresourceTrackingParams(const AdapterTestParam& param, uint32_t arrayLayerCountIn, @@ -147,3 +150,6 @@ DAWN_INSTANTIATE_TEST_P(SubresourceTrackingPerf, {D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend()}, {1, 4, 16, 256}, {2, 3, 8}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/AsyncTaskTests.cpp b/src/dawn/tests/unittests/AsyncTaskTests.cpp index a61baa945c..7c87c57462 100644 --- a/src/dawn/tests/unittests/AsyncTaskTests.cpp +++ b/src/dawn/tests/unittests/AsyncTaskTests.cpp @@ -14,7 +14,7 @@ // // AsyncTaskTests: -// Simple tests for dawn::native::AsyncTask and dawn::native::AsnycTaskManager. +// Simple tests for native::AsyncTask and native::AsnycTaskManager. #include #include @@ -27,6 +27,7 @@ #include "dawn/platform/DawnPlatform.h" #include "gtest/gtest.h" +namespace dawn { namespace { struct SimpleTaskResult { @@ -61,22 +62,20 @@ void DoTask(ConcurrentTaskResultQueue* resultQueue, uint32_t id) { resultQueue->AddResult(std::move(result)); } -} // anonymous namespace - class AsyncTaskTest : public testing::Test {}; // Emulate the basic usage of worker thread pool in Create*PipelineAsync(). TEST_F(AsyncTaskTest, Basic) { - dawn::platform::Platform platform; - std::unique_ptr pool = platform.CreateWorkerTaskPool(); + platform::Platform platform; + std::unique_ptr pool = platform.CreateWorkerTaskPool(); - dawn::native::AsyncTaskManager taskManager(pool.get()); + native::AsyncTaskManager taskManager(pool.get()); ConcurrentTaskResultQueue taskResultQueue; constexpr size_t kTaskCount = 4u; std::set idset; for (uint32_t i = 0; i < kTaskCount; ++i) { - dawn::native::AsyncTask asyncTask([&taskResultQueue, i] { DoTask(&taskResultQueue, i); }); + native::AsyncTask asyncTask([&taskResultQueue, i] { DoTask(&taskResultQueue, i); }); taskManager.PostTask(std::move(asyncTask)); idset.insert(i); } @@ -90,3 +89,6 @@ TEST_F(AsyncTaskTest, Basic) { } ASSERT_TRUE(idset.empty()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/BitSetIteratorTests.cpp b/src/dawn/tests/unittests/BitSetIteratorTests.cpp index b1c2a0c765..e06e3d2d16 100644 --- a/src/dawn/tests/unittests/BitSetIteratorTests.cpp +++ b/src/dawn/tests/unittests/BitSetIteratorTests.cpp @@ -18,6 +18,9 @@ #include "dawn/common/ityp_bitset.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + // This is ANGLE's BitSetIterator_unittests.cpp file. class BitSetIteratorTest : public testing::Test { @@ -218,3 +221,6 @@ TEST_F(ITypBitsetIteratorTest, NonLValueBitset) { EXPECT_EQ((mStateBits & otherBits).count(), seenBits.size()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ChainUtilsTests.cpp b/src/dawn/tests/unittests/ChainUtilsTests.cpp index 45055f18bc..537d506372 100644 --- a/src/dawn/tests/unittests/ChainUtilsTests.cpp +++ b/src/dawn/tests/unittests/ChainUtilsTests.cpp @@ -17,20 +17,23 @@ #include "dawn/native/ChainUtils_autogen.h" #include "dawn/native/dawn_platform.h" +namespace dawn { +namespace { + // Checks that we cannot find any structs in an empty chain TEST(ChainUtilsTests, FindEmptyChain) { { - const dawn::native::PrimitiveDepthClipControl* info = nullptr; - const dawn::native::ChainedStruct* chained = nullptr; - dawn::native::FindInChain(chained, &info); + const native::PrimitiveDepthClipControl* info = nullptr; + const native::ChainedStruct* chained = nullptr; + native::FindInChain(chained, &info); ASSERT_EQ(nullptr, info); } { - dawn::native::DawnAdapterPropertiesPowerPreference* info = nullptr; - dawn::native::ChainedStructOut* chained = nullptr; - dawn::native::FindInChain(chained, &info); + native::DawnAdapterPropertiesPowerPreference* info = nullptr; + native::ChainedStructOut* chained = nullptr; + native::FindInChain(chained, &info); ASSERT_EQ(nullptr, info); } @@ -39,22 +42,22 @@ TEST(ChainUtilsTests, FindEmptyChain) { // Checks that searching a chain for a present struct returns that struct TEST(ChainUtilsTests, FindPresentInChain) { { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; chain1.nextInChain = &chain2; - const dawn::native::PrimitiveDepthClipControl* info1 = nullptr; - const dawn::native::ShaderModuleSPIRVDescriptor* info2 = nullptr; - dawn::native::FindInChain(&chain1, &info1); - dawn::native::FindInChain(&chain1, &info2); + const native::PrimitiveDepthClipControl* info1 = nullptr; + const native::ShaderModuleSPIRVDescriptor* info2 = nullptr; + native::FindInChain(&chain1, &info1); + native::FindInChain(&chain1, &info2); ASSERT_NE(nullptr, info1); ASSERT_NE(nullptr, info2); } { - dawn::native::DawnAdapterPropertiesPowerPreference chain; - dawn::native::DawnAdapterPropertiesPowerPreference* output = nullptr; - dawn::native::FindInChain(&chain, &output); + native::DawnAdapterPropertiesPowerPreference chain; + native::DawnAdapterPropertiesPowerPreference* output = nullptr; + native::FindInChain(&chain, &output); ASSERT_NE(nullptr, output); } @@ -63,19 +66,19 @@ TEST(ChainUtilsTests, FindPresentInChain) { // Checks that searching a chain for a struct that doesn't exist returns a nullptr TEST(ChainUtilsTests, FindMissingInChain) { { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; chain1.nextInChain = &chain2; - const dawn::native::SurfaceDescriptorFromMetalLayer* info = nullptr; - dawn::native::FindInChain(&chain1, &info); + const native::SurfaceDescriptorFromMetalLayer* info = nullptr; + native::FindInChain(&chain1, &info); ASSERT_EQ(nullptr, info); } { - dawn::native::AdapterProperties adapterProperties; - dawn::native::DawnAdapterPropertiesPowerPreference* output = nullptr; - dawn::native::FindInChain(adapterProperties.nextInChain, &output); + native::AdapterProperties adapterProperties; + native::DawnAdapterPropertiesPowerPreference* output = nullptr; + native::FindInChain(adapterProperties.nextInChain, &output); ASSERT_EQ(nullptr, output); } @@ -84,23 +87,23 @@ TEST(ChainUtilsTests, FindMissingInChain) { // Checks that validation rejects chains with duplicate STypes TEST(ChainUtilsTests, ValidateDuplicateSTypes) { { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; - dawn::native::PrimitiveDepthClipControl chain3; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; + native::PrimitiveDepthClipControl chain3; chain1.nextInChain = &chain2; chain2.nextInChain = &chain3; - dawn::native::MaybeError result = dawn::native::ValidateSTypes(&chain1, {}); + native::MaybeError result = native::ValidateSTypes(&chain1, {}); ASSERT_TRUE(result.IsError()); result.AcquireError(); } { - dawn::native::DawnAdapterPropertiesPowerPreference chain1; - dawn::native::DawnAdapterPropertiesPowerPreference chain2; + native::DawnAdapterPropertiesPowerPreference chain1; + native::DawnAdapterPropertiesPowerPreference chain2; chain1.nextInChain = &chain2; - dawn::native::MaybeError result = dawn::native::ValidateSTypes(&chain1, {}); + native::MaybeError result = native::ValidateSTypes(&chain1, {}); ASSERT_TRUE(result.IsError()); result.AcquireError(); } @@ -109,29 +112,29 @@ TEST(ChainUtilsTests, ValidateDuplicateSTypes) { // Checks that validation rejects chains that contain unspecified STypes TEST(ChainUtilsTests, ValidateUnspecifiedSTypes) { { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; - dawn::native::ShaderModuleWGSLDescriptor chain3; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; + native::ShaderModuleWGSLDescriptor chain3; chain1.nextInChain = &chain2; chain2.nextInChain = &chain3; - dawn::native::MaybeError result = - dawn::native::ValidateSTypes(&chain1, { - {wgpu::SType::PrimitiveDepthClipControl}, - {wgpu::SType::ShaderModuleSPIRVDescriptor}, - }); + native::MaybeError result = + native::ValidateSTypes(&chain1, { + {wgpu::SType::PrimitiveDepthClipControl}, + {wgpu::SType::ShaderModuleSPIRVDescriptor}, + }); ASSERT_TRUE(result.IsError()); result.AcquireError(); } { - dawn::native::DawnAdapterPropertiesPowerPreference chain1; - dawn::native::ChainedStructOut chain2; + native::DawnAdapterPropertiesPowerPreference chain1; + native::ChainedStructOut chain2; chain2.sType = wgpu::SType::RenderPassDescriptorMaxDrawCount; chain1.nextInChain = &chain2; - dawn::native::MaybeError result = dawn::native::ValidateSTypes( - &chain1, {{wgpu::SType::DawnAdapterPropertiesPowerPreference}}); + native::MaybeError result = + native::ValidateSTypes(&chain1, {{wgpu::SType::DawnAdapterPropertiesPowerPreference}}); ASSERT_TRUE(result.IsError()); result.AcquireError(); } @@ -140,13 +143,13 @@ TEST(ChainUtilsTests, ValidateUnspecifiedSTypes) { // Checks that validation rejects chains that contain multiple STypes from the same oneof // constraint. TEST(ChainUtilsTests, ValidateOneOfFailure) { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; - dawn::native::ShaderModuleWGSLDescriptor chain3; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; + native::ShaderModuleWGSLDescriptor chain3; chain1.nextInChain = &chain2; chain2.nextInChain = &chain3; - dawn::native::MaybeError result = dawn::native::ValidateSTypes( + native::MaybeError result = native::ValidateSTypes( &chain1, {{wgpu::SType::ShaderModuleSPIRVDescriptor, wgpu::SType::ShaderModuleWGSLDescriptor}}); ASSERT_TRUE(result.IsError()); @@ -156,11 +159,11 @@ TEST(ChainUtilsTests, ValidateOneOfFailure) { // Checks that validation accepts chains that match the constraints. TEST(ChainUtilsTests, ValidateSuccess) { { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; chain1.nextInChain = &chain2; - dawn::native::MaybeError result = dawn::native::ValidateSTypes( + native::MaybeError result = native::ValidateSTypes( &chain1, { {wgpu::SType::ShaderModuleSPIRVDescriptor, wgpu::SType::ShaderModuleWGSLDescriptor}, @@ -171,9 +174,9 @@ TEST(ChainUtilsTests, ValidateSuccess) { } { - dawn::native::DawnAdapterPropertiesPowerPreference chain1; - dawn::native::MaybeError result = dawn::native::ValidateSTypes( - &chain1, {{wgpu::SType::DawnAdapterPropertiesPowerPreference}}); + native::DawnAdapterPropertiesPowerPreference chain1; + native::MaybeError result = + native::ValidateSTypes(&chain1, {{wgpu::SType::DawnAdapterPropertiesPowerPreference}}); ASSERT_TRUE(result.IsSuccess()); } } @@ -181,25 +184,25 @@ TEST(ChainUtilsTests, ValidateSuccess) { // Checks that validation always passes on empty chains. TEST(ChainUtilsTests, ValidateEmptyChain) { { - const dawn::native::ChainedStruct* chain = nullptr; - dawn::native::MaybeError result = - dawn::native::ValidateSTypes(chain, { - {wgpu::SType::ShaderModuleSPIRVDescriptor}, - {wgpu::SType::PrimitiveDepthClipControl}, - }); + const native::ChainedStruct* chain = nullptr; + native::MaybeError result = + native::ValidateSTypes(chain, { + {wgpu::SType::ShaderModuleSPIRVDescriptor}, + {wgpu::SType::PrimitiveDepthClipControl}, + }); ASSERT_TRUE(result.IsSuccess()); - result = dawn::native::ValidateSTypes(chain, {}); + result = native::ValidateSTypes(chain, {}); ASSERT_TRUE(result.IsSuccess()); } { - dawn::native::ChainedStructOut* chain = nullptr; - dawn::native::MaybeError result = dawn::native::ValidateSTypes( - chain, {{wgpu::SType::DawnAdapterPropertiesPowerPreference}}); + native::ChainedStructOut* chain = nullptr; + native::MaybeError result = + native::ValidateSTypes(chain, {{wgpu::SType::DawnAdapterPropertiesPowerPreference}}); ASSERT_TRUE(result.IsSuccess()); - result = dawn::native::ValidateSTypes(chain, {}); + result = native::ValidateSTypes(chain, {}); ASSERT_TRUE(result.IsSuccess()); } } @@ -207,25 +210,25 @@ TEST(ChainUtilsTests, ValidateEmptyChain) { // Checks that singleton validation always passes on empty chains. TEST(ChainUtilsTests, ValidateSingleEmptyChain) { { - const dawn::native::ChainedStruct* chain = nullptr; - dawn::native::MaybeError result = - dawn::native::ValidateSingleSType(chain, wgpu::SType::ShaderModuleSPIRVDescriptor); + const native::ChainedStruct* chain = nullptr; + native::MaybeError result = + native::ValidateSingleSType(chain, wgpu::SType::ShaderModuleSPIRVDescriptor); ASSERT_TRUE(result.IsSuccess()); - result = dawn::native::ValidateSingleSType(chain, wgpu::SType::ShaderModuleSPIRVDescriptor, - wgpu::SType::PrimitiveDepthClipControl); + result = native::ValidateSingleSType(chain, wgpu::SType::ShaderModuleSPIRVDescriptor, + wgpu::SType::PrimitiveDepthClipControl); ASSERT_TRUE(result.IsSuccess()); } { - dawn::native::ChainedStructOut* chain = nullptr; - dawn::native::MaybeError result = dawn::native::ValidateSingleSType( - chain, wgpu::SType::DawnAdapterPropertiesPowerPreference); + native::ChainedStructOut* chain = nullptr; + native::MaybeError result = + native::ValidateSingleSType(chain, wgpu::SType::DawnAdapterPropertiesPowerPreference); ASSERT_TRUE(result.IsSuccess()); - result = dawn::native::ValidateSingleSType( - chain, wgpu::SType::DawnAdapterPropertiesPowerPreference, - wgpu::SType::PrimitiveDepthClipControl); + result = + native::ValidateSingleSType(chain, wgpu::SType::DawnAdapterPropertiesPowerPreference, + wgpu::SType::PrimitiveDepthClipControl); ASSERT_TRUE(result.IsSuccess()); } } @@ -233,28 +236,28 @@ TEST(ChainUtilsTests, ValidateSingleEmptyChain) { // Checks that singleton validation always fails on chains with multiple children. TEST(ChainUtilsTests, ValidateSingleMultiChain) { { - dawn::native::PrimitiveDepthClipControl chain1; - dawn::native::ShaderModuleSPIRVDescriptor chain2; + native::PrimitiveDepthClipControl chain1; + native::ShaderModuleSPIRVDescriptor chain2; chain1.nextInChain = &chain2; - dawn::native::MaybeError result = - dawn::native::ValidateSingleSType(&chain1, wgpu::SType::PrimitiveDepthClipControl); + native::MaybeError result = + native::ValidateSingleSType(&chain1, wgpu::SType::PrimitiveDepthClipControl); ASSERT_TRUE(result.IsError()); result.AcquireError(); - result = dawn::native::ValidateSingleSType(&chain1, wgpu::SType::PrimitiveDepthClipControl, - wgpu::SType::ShaderModuleSPIRVDescriptor); + result = native::ValidateSingleSType(&chain1, wgpu::SType::PrimitiveDepthClipControl, + wgpu::SType::ShaderModuleSPIRVDescriptor); ASSERT_TRUE(result.IsError()); result.AcquireError(); } { - dawn::native::DawnAdapterPropertiesPowerPreference chain1; - dawn::native::DawnAdapterPropertiesPowerPreference chain2; + native::DawnAdapterPropertiesPowerPreference chain1; + native::DawnAdapterPropertiesPowerPreference chain2; chain1.nextInChain = &chain2; - dawn::native::MaybeError result = dawn::native::ValidateSingleSType( - &chain1, wgpu::SType::DawnAdapterPropertiesPowerPreference); + native::MaybeError result = + native::ValidateSingleSType(&chain1, wgpu::SType::DawnAdapterPropertiesPowerPreference); ASSERT_TRUE(result.IsError()); result.AcquireError(); } @@ -263,26 +266,25 @@ TEST(ChainUtilsTests, ValidateSingleMultiChain) { // Checks that singleton validation passes when the one of constraint is met. TEST(ChainUtilsTests, ValidateSingleSatisfied) { { - dawn::native::ShaderModuleWGSLDescriptor chain1; + native::ShaderModuleWGSLDescriptor chain1; - dawn::native::MaybeError result = - dawn::native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleWGSLDescriptor); + native::MaybeError result = + native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleWGSLDescriptor); ASSERT_TRUE(result.IsSuccess()); - result = - dawn::native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleSPIRVDescriptor, - wgpu::SType::ShaderModuleWGSLDescriptor); + result = native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleSPIRVDescriptor, + wgpu::SType::ShaderModuleWGSLDescriptor); ASSERT_TRUE(result.IsSuccess()); - result = dawn::native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleWGSLDescriptor, - wgpu::SType::ShaderModuleSPIRVDescriptor); + result = native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleWGSLDescriptor, + wgpu::SType::ShaderModuleSPIRVDescriptor); ASSERT_TRUE(result.IsSuccess()); } { - dawn::native::DawnAdapterPropertiesPowerPreference chain1; - dawn::native::MaybeError result = dawn::native::ValidateSingleSType( - &chain1, wgpu::SType::DawnAdapterPropertiesPowerPreference); + native::DawnAdapterPropertiesPowerPreference chain1; + native::MaybeError result = + native::ValidateSingleSType(&chain1, wgpu::SType::DawnAdapterPropertiesPowerPreference); ASSERT_TRUE(result.IsSuccess()); } } @@ -290,27 +292,29 @@ TEST(ChainUtilsTests, ValidateSingleSatisfied) { // Checks that singleton validation passes when the oneof constraint is not met. TEST(ChainUtilsTests, ValidateSingleUnsatisfied) { { - dawn::native::PrimitiveDepthClipControl chain1; + native::PrimitiveDepthClipControl chain1; - dawn::native::MaybeError result = - dawn::native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleWGSLDescriptor); + native::MaybeError result = + native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleWGSLDescriptor); ASSERT_TRUE(result.IsError()); result.AcquireError(); - result = - dawn::native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleSPIRVDescriptor, - wgpu::SType::ShaderModuleWGSLDescriptor); + result = native::ValidateSingleSType(&chain1, wgpu::SType::ShaderModuleSPIRVDescriptor, + wgpu::SType::ShaderModuleWGSLDescriptor); ASSERT_TRUE(result.IsError()); result.AcquireError(); } { - dawn::native::ChainedStructOut chain1; + native::ChainedStructOut chain1; chain1.sType = wgpu::SType::ShaderModuleWGSLDescriptor; - dawn::native::MaybeError result = dawn::native::ValidateSingleSType( - &chain1, wgpu::SType::DawnAdapterPropertiesPowerPreference); + native::MaybeError result = + native::ValidateSingleSType(&chain1, wgpu::SType::DawnAdapterPropertiesPowerPreference); ASSERT_TRUE(result.IsError()); result.AcquireError(); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ConcurrentCacheTests.cpp b/src/dawn/tests/unittests/ConcurrentCacheTests.cpp index 1d4f91d3df..e8e2a935d8 100644 --- a/src/dawn/tests/unittests/ConcurrentCacheTests.cpp +++ b/src/dawn/tests/unittests/ConcurrentCacheTests.cpp @@ -21,7 +21,9 @@ #include "dawn/utils/SystemUtils.h" #include "gtest/gtest.h" +namespace dawn { namespace { + class SimpleCachedObject { public: explicit SimpleCachedObject(size_t value) : mValue(value) {} @@ -42,16 +44,14 @@ class SimpleCachedObject { size_t mValue; }; -} // anonymous namespace - class ConcurrentCacheTest : public testing::Test { public: ConcurrentCacheTest() : mPool(mPlatform.CreateWorkerTaskPool()), mTaskManager(mPool.get()) {} protected: - dawn::platform::Platform mPlatform; - std::unique_ptr mPool; - dawn::native::AsyncTaskManager mTaskManager; + platform::Platform mPlatform; + std::unique_ptr mPool; + native::AsyncTaskManager mTaskManager; ConcurrentCache mCache; }; @@ -65,10 +65,10 @@ TEST_F(ConcurrentCacheTest, InsertAtSameTime) { std::pair anotherInsertOutput = {}; ConcurrentCache* cachePtr = &mCache; - dawn::native::AsyncTask asyncTask1([&insertOutput, cachePtr, &cachedObject] { + native::AsyncTask asyncTask1([&insertOutput, cachePtr, &cachedObject] { insertOutput = cachePtr->Insert(&cachedObject); }); - dawn::native::AsyncTask asyncTask2([&anotherInsertOutput, cachePtr, &anotherCachedObject] { + native::AsyncTask asyncTask2([&anotherInsertOutput, cachePtr, &anotherCachedObject] { anotherInsertOutput = cachePtr->Insert(&anotherCachedObject); }); mTaskManager.PostTask(std::move(asyncTask1)); @@ -87,12 +87,12 @@ TEST_F(ConcurrentCacheTest, EraseAfterInsertion) { std::pair insertOutput = {}; ConcurrentCache* cachePtr = &mCache; - dawn::native::AsyncTask insertTask([&insertOutput, cachePtr, &cachedObject] { + native::AsyncTask insertTask([&insertOutput, cachePtr, &cachedObject] { insertOutput = cachePtr->Insert(&cachedObject); }); size_t erasedObjectCount = 0; - dawn::native::AsyncTask eraseTask([&erasedObjectCount, cachePtr, &cachedObject] { + native::AsyncTask eraseTask([&erasedObjectCount, cachePtr, &cachedObject] { while (cachePtr->Find(&cachedObject) == nullptr) { utils::USleep(100); } @@ -108,3 +108,6 @@ TEST_F(ConcurrentCacheTest, EraseAfterInsertion) { ASSERT_TRUE(insertOutput.second); ASSERT_EQ(1u, erasedObjectCount); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/EnumMaskIteratorTests.cpp b/src/dawn/tests/unittests/EnumMaskIteratorTests.cpp index fec0376430..bf09defe34 100644 --- a/src/dawn/tests/unittests/EnumMaskIteratorTests.cpp +++ b/src/dawn/tests/unittests/EnumMaskIteratorTests.cpp @@ -34,7 +34,7 @@ struct EnumBitmaskSize { namespace dawn { template <> -struct IsDawnBitmask { +struct IsDawnBitmask { static constexpr bool enable = true; }; diff --git a/src/dawn/tests/unittests/FeatureTests.cpp b/src/dawn/tests/unittests/FeatureTests.cpp index 4e66d03727..8789e5341f 100644 --- a/src/dawn/tests/unittests/FeatureTests.cpp +++ b/src/dawn/tests/unittests/FeatureTests.cpp @@ -20,50 +20,51 @@ #include "dawn/native/null/DeviceNull.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + class FeatureTests : public testing::Test { public: FeatureTests() : testing::Test(), - mInstanceBase(dawn::native::InstanceBase::Create()), + mInstanceBase(native::InstanceBase::Create()), mPhysicalDevice(mInstanceBase.Get()), mUnsafePhysicalDeviceDisallow(mInstanceBase.Get()), mUnsafePhysicalDevice(mInstanceBase.Get()), - mAdapterBase(&mPhysicalDevice, dawn::native::FeatureLevel::Core), + mAdapterBase(&mPhysicalDevice, native::FeatureLevel::Core), mUnsafeAdapterBaseDisallow( &mUnsafePhysicalDeviceDisallow, - dawn::native::FeatureLevel::Core, - dawn::native::TogglesState(dawn::native::ToggleStage::Adapter) - .SetForTesting(dawn::native::Toggle::DisallowUnsafeAPIs, false, false)), - mUnsafeAdapterBase( - &mUnsafePhysicalDevice, - dawn::native::FeatureLevel::Core, - dawn::native::TogglesState(dawn::native::ToggleStage::Adapter) - .SetForTesting(dawn::native::Toggle::AllowUnsafeAPIs, true, true)) {} + native::FeatureLevel::Core, + native::TogglesState(native::ToggleStage::Adapter) + .SetForTesting(native::Toggle::DisallowUnsafeAPIs, false, false)), + mUnsafeAdapterBase(&mUnsafePhysicalDevice, + native::FeatureLevel::Core, + native::TogglesState(native::ToggleStage::Adapter) + .SetForTesting(native::Toggle::AllowUnsafeAPIs, true, true)) {} std::vector GetAllFeatureNames() { std::vector allFeatureNames(kTotalFeaturesCount); for (size_t i = 0; i < kTotalFeaturesCount; ++i) { - allFeatureNames[i] = FeatureEnumToAPIFeature(static_cast(i)); + allFeatureNames[i] = FeatureEnumToAPIFeature(static_cast(i)); } return allFeatureNames; } - static constexpr size_t kTotalFeaturesCount = - static_cast(dawn::native::Feature::EnumCount); + static constexpr size_t kTotalFeaturesCount = static_cast(native::Feature::EnumCount); protected: // By default DisallowUnsafeAPIs is enabled in this instance. - Ref mInstanceBase; - dawn::native::null::PhysicalDevice mPhysicalDevice; + Ref mInstanceBase; + native::null::PhysicalDevice mPhysicalDevice; // TODO(dawn:1685) Remove duplicated unsafe objects once DisallowUnsafeAPIs is removed. - dawn::native::null::PhysicalDevice mUnsafePhysicalDeviceDisallow; - dawn::native::null::PhysicalDevice mUnsafePhysicalDevice; + native::null::PhysicalDevice mUnsafePhysicalDeviceDisallow; + native::null::PhysicalDevice mUnsafePhysicalDevice; // The adapter that inherit toggles states from the instance, also have DisallowUnsafeAPIs // enabled. - dawn::native::AdapterBase mAdapterBase; + native::AdapterBase mAdapterBase; // TODO(dawn:1685) Remove duplicated unsafe objects once DisallowUnsafeAPIs is removed. - dawn::native::AdapterBase mUnsafeAdapterBaseDisallow; - dawn::native::AdapterBase mUnsafeAdapterBase; + native::AdapterBase mUnsafeAdapterBaseDisallow; + native::AdapterBase mUnsafeAdapterBase; }; // Test the creation of a device will fail if the requested feature is not supported on the @@ -71,7 +72,7 @@ class FeatureTests : public testing::Test { TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) { const std::vector kAllFeatureNames = GetAllFeatureNames(); for (size_t i = 0; i < kTotalFeaturesCount; ++i) { - dawn::native::Feature notSupportedFeature = static_cast(i); + native::Feature notSupportedFeature = static_cast(i); std::vector featureNamesWithoutOne = kAllFeatureNames; featureNamesWithoutOne.erase(featureNamesWithoutOne.begin() + i); @@ -79,7 +80,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) { // Test that the default adapter validates features as expected. { mPhysicalDevice.SetSupportedFeaturesForTesting(featureNamesWithoutOne); - dawn::native::Adapter adapterWithoutFeature(&mAdapterBase); + native::Adapter adapterWithoutFeature(&mAdapterBase); wgpu::DeviceDescriptor deviceDescriptor; wgpu::FeatureName featureName = FeatureEnumToAPIFeature(notSupportedFeature); @@ -95,7 +96,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) { // TODO(dawn:1685) Remove this block once DisallowUnsafeAPIs is removed. { mUnsafePhysicalDeviceDisallow.SetSupportedFeaturesForTesting(featureNamesWithoutOne); - dawn::native::Adapter adapterWithoutFeature(&mUnsafeAdapterBaseDisallow); + native::Adapter adapterWithoutFeature(&mUnsafeAdapterBaseDisallow); wgpu::DeviceDescriptor deviceDescriptor; wgpu::FeatureName featureName = FeatureEnumToAPIFeature(notSupportedFeature); @@ -110,7 +111,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) { // Test that an adapter with AllowUnsafeApis enabled validates features as expected. { mUnsafePhysicalDevice.SetSupportedFeaturesForTesting(featureNamesWithoutOne); - dawn::native::Adapter adapterWithoutFeature(&mUnsafeAdapterBase); + native::Adapter adapterWithoutFeature(&mUnsafeAdapterBase); wgpu::DeviceDescriptor deviceDescriptor; wgpu::FeatureName featureName = FeatureEnumToAPIFeature(notSupportedFeature); @@ -128,13 +129,13 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) { // toggle disabled for experimental features), and Device.GetEnabledFeatures() can return the names // of the enabled features correctly. TEST_F(FeatureTests, RequireAndGetEnabledFeatures) { - dawn::native::Adapter adapter(&mAdapterBase); - dawn::native::Adapter unsafeAdapterDisallow(&mUnsafeAdapterBaseDisallow); - dawn::native::Adapter unsafeAdapterAllow(&mUnsafeAdapterBase); - dawn::native::FeaturesInfo featuresInfo; + native::Adapter adapter(&mAdapterBase); + native::Adapter unsafeAdapterDisallow(&mUnsafeAdapterBaseDisallow); + native::Adapter unsafeAdapterAllow(&mUnsafeAdapterBase); + native::FeaturesInfo featuresInfo; for (size_t i = 0; i < kTotalFeaturesCount; ++i) { - dawn::native::Feature feature = static_cast(i); + native::Feature feature = static_cast(i); wgpu::FeatureName featureName = FeatureEnumToAPIFeature(feature); wgpu::DeviceDescriptor deviceDescriptor; @@ -143,13 +144,13 @@ TEST_F(FeatureTests, RequireAndGetEnabledFeatures) { // Test with the default adapter. { - dawn::native::DeviceBase* deviceBase = dawn::native::FromAPI(adapter.CreateDevice( + native::DeviceBase* deviceBase = native::FromAPI(adapter.CreateDevice( reinterpret_cast(&deviceDescriptor))); // Creating a device with experimental feature requires the adapter enables // AllowUnsafeAPIs or disables DisallowUnsafeApis, otherwise expect validation error. if (featuresInfo.GetFeatureInfo(featureName)->featureState == - dawn::native::FeatureInfo::FeatureState::Experimental) { + native::FeatureInfo::FeatureState::Experimental) { ASSERT_EQ(nullptr, deviceBase) << i; } else { // Requiring stable features should succeed. @@ -166,9 +167,8 @@ TEST_F(FeatureTests, RequireAndGetEnabledFeatures) { // always succeed. // TODO(dawn:1685) Remove this block once DisallowUnsafeAPIs is removed. { - dawn::native::DeviceBase* deviceBase = - dawn::native::FromAPI(unsafeAdapterDisallow.CreateDevice( - reinterpret_cast(&deviceDescriptor))); + native::DeviceBase* deviceBase = native::FromAPI(unsafeAdapterDisallow.CreateDevice( + reinterpret_cast(&deviceDescriptor))); ASSERT_NE(nullptr, deviceBase); ASSERT_EQ(1u, deviceBase->APIEnumerateFeatures(nullptr)); @@ -181,9 +181,8 @@ TEST_F(FeatureTests, RequireAndGetEnabledFeatures) { // Test with the adapter with AllowUnsafeApis toggles enabled, creating device should always // succeed. { - dawn::native::DeviceBase* deviceBase = - dawn::native::FromAPI(unsafeAdapterAllow.CreateDevice( - reinterpret_cast(&deviceDescriptor))); + native::DeviceBase* deviceBase = native::FromAPI(unsafeAdapterAllow.CreateDevice( + reinterpret_cast(&deviceDescriptor))); ASSERT_NE(nullptr, deviceBase); ASSERT_EQ(1u, deviceBase->APIEnumerateFeatures(nullptr)); @@ -194,3 +193,6 @@ TEST_F(FeatureTests, RequireAndGetEnabledFeatures) { } } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/GPUInfoTests.cpp b/src/dawn/tests/unittests/GPUInfoTests.cpp index be01489b83..89cccdf441 100644 --- a/src/dawn/tests/unittests/GPUInfoTests.cpp +++ b/src/dawn/tests/unittests/GPUInfoTests.cpp @@ -16,7 +16,9 @@ #include "dawn/common/GPUInfo.h" +namespace dawn { namespace { + const PCIVendorID vendorID = 0x8086; // Intel D3D12 const gpu_info::DriverVersion version1 = {20, 19, 15, 5107}; @@ -28,8 +30,6 @@ const gpu_info::DriverVersion version5 = {100, 9466}; const gpu_info::DriverVersion version6 = {101, 3222}; const gpu_info::DriverVersion version7 = {101, 3790}; -} // anonymous namespace - TEST(GPUInfo, CompareWindowsDriverVersion) { EXPECT_EQ(gpu_info::CompareWindowsDriverVersion(vendorID, version1, version2), -1); EXPECT_EQ(gpu_info::CompareWindowsDriverVersion(vendorID, version2, version3), -1); @@ -41,3 +41,6 @@ TEST(GPUInfo, CompareWindowsDriverVersion) { EXPECT_EQ(gpu_info::CompareWindowsDriverVersion(vendorID, version3, version6), -1); EXPECT_EQ(gpu_info::CompareWindowsDriverVersion(vendorID, version4, version7), -1); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/GetProcAddressTests.cpp b/src/dawn/tests/unittests/GetProcAddressTests.cpp index 2641a3cc24..8b8313774c 100644 --- a/src/dawn/tests/unittests/GetProcAddressTests.cpp +++ b/src/dawn/tests/unittests/GetProcAddressTests.cpp @@ -24,6 +24,7 @@ #include "dawn/utils/TerribleCommandBuffer.h" #include "dawn/wire/WireClient.h" +namespace dawn { namespace { // dawn_wire and dawn_native contain duplicated code for the handling of GetProcAddress @@ -55,28 +56,28 @@ class GetProcAddressTests : public testing::TestWithParam { public: GetProcAddressTests() : testing::TestWithParam(), - mNativeInstance(dawn::native::InstanceBase::Create()), - mAdapterBase(AcquireRef(new dawn::native::null::PhysicalDevice(mNativeInstance.Get())), - dawn::native::FeatureLevel::Core) {} + mNativeInstance(native::InstanceBase::Create()), + mAdapterBase(AcquireRef(new native::null::PhysicalDevice(mNativeInstance.Get())), + native::FeatureLevel::Core) {} void SetUp() override { switch (GetParam()) { case DawnFlavor::Native: { mDevice = wgpu::Device::Acquire( reinterpret_cast(mAdapterBase.APICreateDevice())); - mProcs = dawn::native::GetProcs(); + mProcs = native::GetProcs(); break; } case DawnFlavor::Wire: { mC2sBuf = std::make_unique(); - dawn::wire::WireClientDescriptor clientDesc = {}; + wire::WireClientDescriptor clientDesc = {}; clientDesc.serializer = mC2sBuf.get(); - mWireClient = std::make_unique(clientDesc); + mWireClient = std::make_unique(clientDesc); mDevice = wgpu::Device::Acquire(mWireClient->ReserveDevice().device); - mProcs = dawn::wire::client::GetProcs(); + mProcs = wire::client::GetProcs(); break; } @@ -94,11 +95,11 @@ class GetProcAddressTests : public testing::TestWithParam { } protected: - Ref mNativeInstance; - dawn::native::AdapterBase mAdapterBase; + Ref mNativeInstance; + native::AdapterBase mAdapterBase; std::unique_ptr mC2sBuf; - std::unique_ptr mWireClient; + std::unique_ptr mWireClient; wgpu::Device mDevice; DawnProcTable mProcs; @@ -159,16 +160,18 @@ INSTANTIATE_TEST_SUITE_P(, testing::PrintToStringParamName()); TEST(GetProcAddressInternalTests, CheckDawnNativeProcMapOrder) { - std::vector names = dawn::native::GetProcMapNamesForTesting(); + std::vector names = native::GetProcMapNamesForTesting(); for (size_t i = 1; i < names.size(); i++) { ASSERT_LT(std::string(names[i - 1]), std::string(names[i])); } } TEST(GetProcAddressInternalTests, CheckDawnWireClientProcMapOrder) { - std::vector names = dawn::wire::client::GetProcMapNamesForTesting(); + std::vector names = wire::client::GetProcMapNamesForTesting(); for (size_t i = 1; i < names.size(); i++) { ASSERT_LT(std::string(names[i - 1]), std::string(names[i])); } } + } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ITypArrayTests.cpp b/src/dawn/tests/unittests/ITypArrayTests.cpp index d8fa1fc1bd..deb4ffb067 100644 --- a/src/dawn/tests/unittests/ITypArrayTests.cpp +++ b/src/dawn/tests/unittests/ITypArrayTests.cpp @@ -17,6 +17,9 @@ #include "dawn/common/TypedInteger.h" #include "dawn/common/ityp_array.h" +namespace dawn { +namespace { + class ITypArrayTest : public testing::Test { protected: using Key = TypedInteger; @@ -89,3 +92,6 @@ TEST_F(ITypArrayTest, BeginEndFrontBackData) { ASSERT_EQ(&constArr.back(), &constArr[Key(9)]); ASSERT_EQ(constArr.data(), &constArr[Key(0)]); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ITypBitsetTests.cpp b/src/dawn/tests/unittests/ITypBitsetTests.cpp index 68b7ddb3dc..ce641da753 100644 --- a/src/dawn/tests/unittests/ITypBitsetTests.cpp +++ b/src/dawn/tests/unittests/ITypBitsetTests.cpp @@ -19,6 +19,9 @@ #include "dawn/common/TypedInteger.h" #include "dawn/common/ityp_bitset.h" +namespace dawn { +namespace { + class ITypBitsetTest : public testing::Test { protected: using Key = TypedInteger; @@ -207,3 +210,6 @@ TEST_F(ITypBitsetTest, GetHighestBitIndexPlusOne) { EXPECT_EQ(40u, static_cast(GetHighestBitIndexPlusOne(Bitset40(0xF000000000)))); EXPECT_EQ(40u, static_cast(GetHighestBitIndexPlusOne(Bitset40(0xFFFFFFFFFF)))); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ITypSpanTests.cpp b/src/dawn/tests/unittests/ITypSpanTests.cpp index b050d7135f..3a51fd2a60 100644 --- a/src/dawn/tests/unittests/ITypSpanTests.cpp +++ b/src/dawn/tests/unittests/ITypSpanTests.cpp @@ -19,6 +19,9 @@ #include "dawn/common/TypedInteger.h" #include "dawn/common/ityp_span.h" +namespace dawn { +namespace { + class ITypSpanTest : public testing::Test { protected: using Key = TypedInteger; @@ -79,3 +82,6 @@ TEST_F(ITypSpanTest, BeginEndFrontBackData) { ASSERT_EQ(&constSpan.back(), &constSpan[Key(9)]); ASSERT_EQ(constSpan.data(), &constSpan[Key(0)]); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ITypVectorTests.cpp b/src/dawn/tests/unittests/ITypVectorTests.cpp index 3c3af49cb6..910ba825cf 100644 --- a/src/dawn/tests/unittests/ITypVectorTests.cpp +++ b/src/dawn/tests/unittests/ITypVectorTests.cpp @@ -18,6 +18,9 @@ #include "dawn/common/ityp_vector.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + class ITypVectorTest : public testing::Test { protected: using Key = TypedInteger; @@ -179,3 +182,6 @@ TEST_F(ITypVectorTest, BeginEndFrontBackData) { ASSERT_EQ(&constVec.back(), &constVec[Key(9)]); ASSERT_EQ(constVec.data(), &constVec[Key(0)]); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/LimitsTests.cpp b/src/dawn/tests/unittests/LimitsTests.cpp index dbac9e7d1b..4515a8839a 100644 --- a/src/dawn/tests/unittests/LimitsTests.cpp +++ b/src/dawn/tests/unittests/LimitsTests.cpp @@ -17,12 +17,15 @@ #include "dawn/common/Constants.h" #include "dawn/native/Limits.h" +namespace dawn { +namespace { + // Test |GetDefaultLimits| returns the default. TEST(Limits, GetDefaultLimits) { - dawn::native::Limits limits = {}; + native::Limits limits = {}; EXPECT_NE(limits.maxBindGroups, 4u); - dawn::native::GetDefaultLimits(&limits); + native::GetDefaultLimits(&limits); EXPECT_EQ(limits.maxBindGroups, 4u); } @@ -30,11 +33,11 @@ TEST(Limits, GetDefaultLimits) { // Test |ReifyDefaultLimits| populates the default if // values are undefined. TEST(Limits, ReifyDefaultLimits_PopulatesDefault) { - dawn::native::Limits limits; + native::Limits limits; limits.maxComputeWorkgroupStorageSize = wgpu::kLimitU32Undefined; limits.maxStorageBufferBindingSize = wgpu::kLimitU64Undefined; - dawn::native::Limits reified = dawn::native::ReifyDefaultLimits(limits); + native::Limits reified = native::ReifyDefaultLimits(limits); EXPECT_EQ(reified.maxComputeWorkgroupStorageSize, 16384u); EXPECT_EQ(reified.maxStorageBufferBindingSize, 134217728ul); } @@ -42,11 +45,11 @@ TEST(Limits, ReifyDefaultLimits_PopulatesDefault) { // Test |ReifyDefaultLimits| clamps to the default if // values are worse than the default. TEST(Limits, ReifyDefaultLimits_Clamps) { - dawn::native::Limits limits; + native::Limits limits; limits.maxStorageBuffersPerShaderStage = 4; limits.minUniformBufferOffsetAlignment = 512; - dawn::native::Limits reified = dawn::native::ReifyDefaultLimits(limits); + native::Limits reified = native::ReifyDefaultLimits(limits); EXPECT_EQ(reified.maxStorageBuffersPerShaderStage, 8u); EXPECT_EQ(reified.minUniformBufferOffsetAlignment, 256u); } @@ -55,19 +58,19 @@ TEST(Limits, ReifyDefaultLimits_Clamps) { // than supported. TEST(Limits, ValidateLimits) { // Start with the default for supported. - dawn::native::Limits defaults; - dawn::native::GetDefaultLimits(&defaults); + native::Limits defaults; + native::GetDefaultLimits(&defaults); // Test supported == required is valid. { - dawn::native::Limits required = defaults; + native::Limits required = defaults; EXPECT_TRUE(ValidateLimits(defaults, required).IsSuccess()); } // Test supported == required is valid, when they are not default. { - dawn::native::Limits supported = defaults; - dawn::native::Limits required = defaults; + native::Limits supported = defaults; + native::Limits required = defaults; supported.maxBindGroups += 1; required.maxBindGroups += 1; EXPECT_TRUE(ValidateLimits(supported, required).IsSuccess()); @@ -75,47 +78,47 @@ TEST(Limits, ValidateLimits) { // Test that default-initialized (all undefined) is valid. { - dawn::native::Limits required = {}; + native::Limits required = {}; EXPECT_TRUE(ValidateLimits(defaults, required).IsSuccess()); } // Test that better than supported is invalid for "maximum" limits. { - dawn::native::Limits required = {}; + native::Limits required = {}; required.maxTextureDimension3D = defaults.maxTextureDimension3D + 1; - dawn::native::MaybeError err = ValidateLimits(defaults, required); + native::MaybeError err = ValidateLimits(defaults, required); EXPECT_TRUE(err.IsError()); err.AcquireError(); } // Test that worse than supported is valid for "maximum" limits. { - dawn::native::Limits required = {}; + native::Limits required = {}; required.maxComputeWorkgroupSizeX = defaults.maxComputeWorkgroupSizeX - 1; EXPECT_TRUE(ValidateLimits(defaults, required).IsSuccess()); } // Test that better than min is invalid for "alignment" limits. { - dawn::native::Limits required = {}; + native::Limits required = {}; required.minUniformBufferOffsetAlignment = defaults.minUniformBufferOffsetAlignment / 2; - dawn::native::MaybeError err = ValidateLimits(defaults, required); + native::MaybeError err = ValidateLimits(defaults, required); EXPECT_TRUE(err.IsError()); err.AcquireError(); } // Test that worse than min and a power of two is valid for "alignment" limits. { - dawn::native::Limits required = {}; + native::Limits required = {}; required.minStorageBufferOffsetAlignment = defaults.minStorageBufferOffsetAlignment * 2; EXPECT_TRUE(ValidateLimits(defaults, required).IsSuccess()); } // Test that worse than min and not a power of two is invalid for "alignment" limits. { - dawn::native::Limits required = {}; + native::Limits required = {}; required.minStorageBufferOffsetAlignment = defaults.minStorageBufferOffsetAlignment * 3; - dawn::native::MaybeError err = ValidateLimits(defaults, required); + native::MaybeError err = ValidateLimits(defaults, required); EXPECT_TRUE(err.IsError()); err.AcquireError(); } @@ -123,46 +126,46 @@ TEST(Limits, ValidateLimits) { // Test that |ApplyLimitTiers| degrades limits to the next best tier. TEST(Limits, ApplyLimitTiers) { - auto SetLimitsStorageBufferBindingSizeTier2 = [](dawn::native::Limits* limits) { + auto SetLimitsStorageBufferBindingSizeTier2 = [](native::Limits* limits) { // Tier 2 of maxStorageBufferBindingSize is 1GB limits->maxStorageBufferBindingSize = 1073741824; // Also set the maxBufferSize to be large enough, as ApplyLimitTiers ensures tired // maxStorageBufferBindingSize no larger than tiered maxBufferSize. limits->maxBufferSize = 2147483648; }; - dawn::native::Limits limitsStorageBufferBindingSizeTier2; - dawn::native::GetDefaultLimits(&limitsStorageBufferBindingSizeTier2); + native::Limits limitsStorageBufferBindingSizeTier2; + native::GetDefaultLimits(&limitsStorageBufferBindingSizeTier2); SetLimitsStorageBufferBindingSizeTier2(&limitsStorageBufferBindingSizeTier2); - auto SetLimitsStorageBufferBindingSizeTier3 = [](dawn::native::Limits* limits) { + auto SetLimitsStorageBufferBindingSizeTier3 = [](native::Limits* limits) { // Tier 3 of maxStorageBufferBindingSize is 2GB-4 limits->maxStorageBufferBindingSize = 2147483644; // Also set the maxBufferSize to be large enough, as ApplyLimitTiers ensures tired // maxStorageBufferBindingSize no larger than tiered maxBufferSize. limits->maxBufferSize = 2147483648; }; - dawn::native::Limits limitsStorageBufferBindingSizeTier3; - dawn::native::GetDefaultLimits(&limitsStorageBufferBindingSizeTier3); + native::Limits limitsStorageBufferBindingSizeTier3; + native::GetDefaultLimits(&limitsStorageBufferBindingSizeTier3); SetLimitsStorageBufferBindingSizeTier3(&limitsStorageBufferBindingSizeTier3); - auto SetLimitsComputeWorkgroupStorageSizeTier1 = [](dawn::native::Limits* limits) { + auto SetLimitsComputeWorkgroupStorageSizeTier1 = [](native::Limits* limits) { limits->maxComputeWorkgroupStorageSize = 16384; }; - dawn::native::Limits limitsComputeWorkgroupStorageSizeTier1; - dawn::native::GetDefaultLimits(&limitsComputeWorkgroupStorageSizeTier1); + native::Limits limitsComputeWorkgroupStorageSizeTier1; + native::GetDefaultLimits(&limitsComputeWorkgroupStorageSizeTier1); SetLimitsComputeWorkgroupStorageSizeTier1(&limitsComputeWorkgroupStorageSizeTier1); - auto SetLimitsComputeWorkgroupStorageSizeTier3 = [](dawn::native::Limits* limits) { + auto SetLimitsComputeWorkgroupStorageSizeTier3 = [](native::Limits* limits) { limits->maxComputeWorkgroupStorageSize = 65536; }; - dawn::native::Limits limitsComputeWorkgroupStorageSizeTier3; - dawn::native::GetDefaultLimits(&limitsComputeWorkgroupStorageSizeTier3); + native::Limits limitsComputeWorkgroupStorageSizeTier3; + native::GetDefaultLimits(&limitsComputeWorkgroupStorageSizeTier3); SetLimitsComputeWorkgroupStorageSizeTier3(&limitsComputeWorkgroupStorageSizeTier3); // Test that applying tiers to limits that are exactly // equal to a tier returns the same values. { - dawn::native::Limits limits = limitsStorageBufferBindingSizeTier2; + native::Limits limits = limitsStorageBufferBindingSizeTier2; EXPECT_EQ(ApplyLimitTiers(limits), limits); limits = limitsStorageBufferBindingSizeTier3; @@ -171,7 +174,7 @@ TEST(Limits, ApplyLimitTiers) { // Test all limits slightly worse than tier 3. { - dawn::native::Limits limits = limitsStorageBufferBindingSizeTier3; + native::Limits limits = limitsStorageBufferBindingSizeTier3; limits.maxStorageBufferBindingSize -= 1; EXPECT_EQ(ApplyLimitTiers(limits), limitsStorageBufferBindingSizeTier2); } @@ -179,28 +182,28 @@ TEST(Limits, ApplyLimitTiers) { // Test that limits may match one tier exactly and be degraded in another tier. // Degrading to one tier does not affect the other tier. { - dawn::native::Limits limits = limitsComputeWorkgroupStorageSizeTier3; + native::Limits limits = limitsComputeWorkgroupStorageSizeTier3; // Set tier 3 and change one limit to be insufficent. SetLimitsStorageBufferBindingSizeTier3(&limits); limits.maxStorageBufferBindingSize -= 1; - dawn::native::Limits tiered = ApplyLimitTiers(limits); + native::Limits tiered = ApplyLimitTiers(limits); // Check that |tiered| has the limits of memorySize tier 2 - dawn::native::Limits tieredWithMemorySizeTier2 = tiered; + native::Limits tieredWithMemorySizeTier2 = tiered; SetLimitsStorageBufferBindingSizeTier2(&tieredWithMemorySizeTier2); EXPECT_EQ(tiered, tieredWithMemorySizeTier2); // Check that |tiered| has the limits of bindingSpace tier 3 - dawn::native::Limits tieredWithBindingSpaceTier3 = tiered; + native::Limits tieredWithBindingSpaceTier3 = tiered; SetLimitsComputeWorkgroupStorageSizeTier3(&tieredWithBindingSpaceTier3); EXPECT_EQ(tiered, tieredWithBindingSpaceTier3); } // Test that limits may be simultaneously degraded in two tiers independently. { - dawn::native::Limits limits; - dawn::native::GetDefaultLimits(&limits); + native::Limits limits; + native::GetDefaultLimits(&limits); SetLimitsComputeWorkgroupStorageSizeTier3(&limits); SetLimitsStorageBufferBindingSizeTier3(&limits); limits.maxComputeWorkgroupStorageSize = @@ -208,9 +211,9 @@ TEST(Limits, ApplyLimitTiers) { limits.maxStorageBufferBindingSize = limitsStorageBufferBindingSizeTier2.maxStorageBufferBindingSize + 1; - dawn::native::Limits tiered = ApplyLimitTiers(limits); + native::Limits tiered = ApplyLimitTiers(limits); - dawn::native::Limits expected = tiered; + native::Limits expected = tiered; SetLimitsComputeWorkgroupStorageSizeTier1(&expected); SetLimitsStorageBufferBindingSizeTier2(&expected); EXPECT_EQ(tiered, expected); @@ -221,8 +224,8 @@ TEST(Limits, ApplyLimitTiers) { // maxBufferSize restriction. TEST(Limits, TieredMaxStorageBufferBindingSizeNoLargerThanMaxBufferSize) { // Start with the default for supported. - dawn::native::Limits defaults; - dawn::native::GetDefaultLimits(&defaults); + native::Limits defaults; + native::GetDefaultLimits(&defaults); // Test reported maxStorageBufferBindingSize around 128MB, 1GB, 2GB-4 and 4GB-4. constexpr uint64_t storageSizeTier1 = 134217728ull; // 128MB @@ -248,11 +251,11 @@ TEST(Limits, TieredMaxStorageBufferBindingSizeNoLargerThanMaxBufferSize) { for (uint64_t reportedMaxStorageBufferBindingSizes : possibleReportedMaxStorageBufferBindingSizes) { for (uint64_t reportedMaxBufferSizes : possibleReportedMaxBufferSizes) { - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxStorageBufferBindingSize = reportedMaxStorageBufferBindingSizes; limits.maxBufferSize = reportedMaxBufferSizes; - dawn::native::Limits tiered = ApplyLimitTiers(limits); + native::Limits tiered = ApplyLimitTiers(limits); EXPECT_LE(tiered.maxStorageBufferBindingSize, tiered.maxBufferSize); } @@ -263,8 +266,8 @@ TEST(Limits, TieredMaxStorageBufferBindingSizeNoLargerThanMaxBufferSize) { // maxBufferSize restriction. TEST(Limits, TieredMaxUniformBufferBindingSizeNoLargerThanMaxBufferSize) { // Start with the default for supported. - dawn::native::Limits defaults; - dawn::native::GetDefaultLimits(&defaults); + native::Limits defaults; + native::GetDefaultLimits(&defaults); // Test reported maxStorageBufferBindingSize around 64KB, and a large 1GB. constexpr uint64_t uniformSizeTier1 = 65536ull; // 64KB @@ -286,11 +289,11 @@ TEST(Limits, TieredMaxUniformBufferBindingSizeNoLargerThanMaxBufferSize) { for (uint64_t reportedMaxUniformBufferBindingSizes : possibleReportedMaxUniformBufferBindingSizes) { for (uint64_t reportedMaxBufferSizes : possibleReportedMaxBufferSizes) { - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxUniformBufferBindingSize = reportedMaxUniformBufferBindingSizes; limits.maxBufferSize = reportedMaxBufferSizes; - dawn::native::Limits tiered = ApplyLimitTiers(limits); + native::Limits tiered = ApplyLimitTiers(limits); EXPECT_LE(tiered.maxUniformBufferBindingSize, tiered.maxBufferSize); } @@ -300,12 +303,12 @@ TEST(Limits, TieredMaxUniformBufferBindingSizeNoLargerThanMaxBufferSize) { // Test |NormalizeLimits| works to enforce restriction of limits. TEST(Limits, NormalizeLimits) { // Start with the default for supported. - dawn::native::Limits defaults; - dawn::native::GetDefaultLimits(&defaults); + native::Limits defaults; + native::GetDefaultLimits(&defaults); // Test specific limit values are clamped to internal Dawn constants. { - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxVertexBufferArrayStride = kMaxVertexBufferArrayStride + 1; limits.maxColorAttachments = uint32_t(kMaxColorAttachments) + 1; limits.maxBindGroups = kMaxBindGroups + 1; @@ -338,7 +341,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxStorageBufferBindingSize = reportedMaxBufferSize; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxStorageBufferBindingSize = reportedMaxStorageBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -350,7 +353,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxStorageBufferBindingSize = reportedMaxBufferSize - 1; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxStorageBufferBindingSize = reportedMaxStorageBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -363,7 +366,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxStorageBufferBindingSize = reportedMaxBufferSize + 1; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxStorageBufferBindingSize = reportedMaxStorageBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -377,7 +380,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxStorageBufferBindingSize = 4294967295; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxStorageBufferBindingSize = reportedMaxStorageBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -392,7 +395,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxUniformBufferBindingSize = reportedMaxBufferSize - 1; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxUniformBufferBindingSize = reportedMaxUniformBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -404,7 +407,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxUniformBufferBindingSize = reportedMaxBufferSize; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxUniformBufferBindingSize = reportedMaxUniformBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -417,7 +420,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxUniformBufferBindingSize = reportedMaxBufferSize + 1; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxUniformBufferBindingSize = reportedMaxUniformBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -431,7 +434,7 @@ TEST(Limits, NormalizeLimits) { { constexpr uint64_t reportedMaxBufferSize = 2147483648; constexpr uint64_t reportedMaxUniformBufferBindingSize = 4294967295; - dawn::native::Limits limits = defaults; + native::Limits limits = defaults; limits.maxUniformBufferBindingSize = reportedMaxUniformBufferBindingSize; limits.maxBufferSize = reportedMaxBufferSize; @@ -441,3 +444,6 @@ TEST(Limits, NormalizeLimits) { EXPECT_EQ(limits.maxUniformBufferBindingSize, reportedMaxBufferSize); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/LinkedListTests.cpp b/src/dawn/tests/unittests/LinkedListTests.cpp index 4867339dff..7f497d238e 100644 --- a/src/dawn/tests/unittests/LinkedListTests.cpp +++ b/src/dawn/tests/unittests/LinkedListTests.cpp @@ -10,6 +10,9 @@ #include "dawn/common/LinkedList.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + class Node : public LinkNode { public: explicit Node(int id) : id_(id) {} @@ -456,3 +459,6 @@ TEST(LinkedList, RangeBasedEndIsEnd) { LinkedList list; EXPECT_EQ(list.end(), *end(list)); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/MathTests.cpp b/src/dawn/tests/unittests/MathTests.cpp index a38fb675dd..02b52452aa 100644 --- a/src/dawn/tests/unittests/MathTests.cpp +++ b/src/dawn/tests/unittests/MathTests.cpp @@ -30,11 +30,13 @@ enum class TestEnum { } // namespace wgpu namespace dawn { + template <> struct IsDawnBitmask { static constexpr bool enable = true; }; -} // namespace dawn + +namespace { // Tests for ScanForward TEST(Math, ScanForward) { @@ -355,3 +357,6 @@ TEST(Math, IsSubset) { ASSERT_FALSE(IsSubset(wgpu::TestEnum::C, wgpu::TestEnum::A | wgpu::TestEnum::B)); ASSERT_FALSE(IsSubset(wgpu::TestEnum::A | wgpu::TestEnum::C, wgpu::TestEnum::A)); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/MutexTests.cpp b/src/dawn/tests/unittests/MutexTests.cpp index 6a4398b966..6b5f84ff20 100644 --- a/src/dawn/tests/unittests/MutexTests.cpp +++ b/src/dawn/tests/unittests/MutexTests.cpp @@ -15,13 +15,14 @@ #include "dawn/common/Mutex.h" #include "gtest/gtest.h" +namespace dawn { namespace { + #if defined(DAWN_ENABLE_ASSERTS) constexpr bool kAssertEnabled = true; #else constexpr bool kAssertEnabled = false; #endif -} // namespace class MutexTest : public ::testing::Test { protected: @@ -32,7 +33,7 @@ class MutexTest : public ::testing::Test { } } - dawn::Mutex mMutex; + Mutex mMutex; }; // Simple Lock() then Unlock() test. @@ -46,7 +47,7 @@ TEST_F(MutexTest, SimpleLockUnlock) { // Test AutoLock automatically locks the mutex and unlocks it when out of scope. TEST_F(MutexTest, AutoLock) { { - dawn::Mutex::AutoLock autoLock(&mMutex); + Mutex::AutoLock autoLock(&mMutex); EXPECT_TRUE(mMutex.IsLockedByCurrentThread()); } EXPECT_FALSE(mMutex.IsLockedByCurrentThread()); @@ -54,10 +55,10 @@ TEST_F(MutexTest, AutoLock) { // Test AutoLockAndHoldRef will keep the mutex alive TEST_F(MutexTest, AutoLockAndHoldRef) { - auto* mutex = new dawn::Mutex(); + auto* mutex = new Mutex(); EXPECT_EQ(mutex->GetRefCountForTesting(), 1u); { - dawn::Mutex::AutoLockAndHoldRef autoLock(mutex); + Mutex::AutoLockAndHoldRef autoLock(mutex); EXPECT_TRUE(mutex->IsLockedByCurrentThread()); EXPECT_EQ(mutex->GetRefCountForTesting(), 2u); @@ -85,13 +86,16 @@ TEST_F(MutexDeathTest, DoubleLockCalls) { TEST_F(MutexDeathTest, LockThenAutoLock) { mMutex.Lock(); EXPECT_TRUE(mMutex.IsLockedByCurrentThread()); - ASSERT_DEATH({ dawn::Mutex::AutoLock autoLock(&mMutex); }, ""); + ASSERT_DEATH({ Mutex::AutoLock autoLock(&mMutex); }, ""); mMutex.Unlock(); } // Use AutoLock then call Lock() should cause assertion failure. TEST_F(MutexDeathTest, AutoLockThenLock) { - dawn::Mutex::AutoLock autoLock(&mMutex); + Mutex::AutoLock autoLock(&mMutex); EXPECT_TRUE(mMutex.IsLockedByCurrentThread()); ASSERT_DEATH({ mMutex.Lock(); }, ""); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/NumericTests.cpp b/src/dawn/tests/unittests/NumericTests.cpp index d94344aa7e..b544bae981 100644 --- a/src/dawn/tests/unittests/NumericTests.cpp +++ b/src/dawn/tests/unittests/NumericTests.cpp @@ -15,8 +15,11 @@ #include "dawn/common/Numeric.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + // Tests for RangesOverlap -TEST(Numeric, RangesOverlap) { +TEST(Numeric, angesOverlap) { // Range contains only one number ASSERT_EQ(true, RangesOverlap(0, 0, 0, 0)); ASSERT_EQ(false, RangesOverlap(0, 0, 1, 1)); @@ -57,3 +60,6 @@ TEST(Numeric, RangesOverlap) { ASSERT_EQ(true, RangesOverlap(-9, 12, 4, 16)); ASSERT_EQ(false, RangesOverlap(-9, -3, -2, 0)); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/PerThreadProcTests.cpp b/src/dawn/tests/unittests/PerThreadProcTests.cpp index 839c72516f..bf318c16fd 100644 --- a/src/dawn/tests/unittests/PerThreadProcTests.cpp +++ b/src/dawn/tests/unittests/PerThreadProcTests.cpp @@ -23,17 +23,20 @@ #include "dawn/native/null/DeviceNull.h" #include "dawn/webgpu_cpp.h" +namespace dawn { +namespace { + class PerThreadProcTests : public testing::Test { public: PerThreadProcTests() - : mNativeInstance(dawn::native::InstanceBase::Create()), - mAdapterBase(AcquireRef(new dawn::native::null::PhysicalDevice(mNativeInstance.Get())), - dawn::native::FeatureLevel::Core) {} + : mNativeInstance(native::InstanceBase::Create()), + mAdapterBase(AcquireRef(new native::null::PhysicalDevice(mNativeInstance.Get())), + native::FeatureLevel::Core) {} ~PerThreadProcTests() override = default; protected: - Ref mNativeInstance; - dawn::native::AdapterBase mAdapterBase; + Ref mNativeInstance; + native::AdapterBase mAdapterBase; }; // Test that procs can be set per thread. This test overrides deviceCreateBuffer with a placeholder @@ -64,7 +67,7 @@ TEST_F(PerThreadProcTests, DispatchesPerThread) { wgpu::Device::Acquire(reinterpret_cast(mAdapterBase.APICreateDevice())); std::thread threadA([&]() { - DawnProcTable procs = dawn::native::GetProcs(); + DawnProcTable procs = native::GetProcs(); procs.deviceCreateBuffer = [](WGPUDevice device, WGPUBufferDescriptor const* descriptor) -> WGPUBuffer { EXPECT_EQ(std::this_thread::get_id(), threadIdA); @@ -85,7 +88,7 @@ TEST_F(PerThreadProcTests, DispatchesPerThread) { }); std::thread threadB([&]() { - DawnProcTable procs = dawn::native::GetProcs(); + DawnProcTable procs = native::GetProcs(); procs.deviceCreateBuffer = [](WGPUDevice device, WGPUBufferDescriptor const* bufferDesc) -> WGPUBuffer { EXPECT_EQ(std::this_thread::get_id(), threadIdB); @@ -117,3 +120,6 @@ TEST_F(PerThreadProcTests, DispatchesPerThread) { dawnProcSetProcs(nullptr); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/PlacementAllocatedTests.cpp b/src/dawn/tests/unittests/PlacementAllocatedTests.cpp index b80050081b..6028bea3b8 100644 --- a/src/dawn/tests/unittests/PlacementAllocatedTests.cpp +++ b/src/dawn/tests/unittests/PlacementAllocatedTests.cpp @@ -18,11 +18,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + using testing::InSequence; using testing::StrictMock; -namespace { - enum class DestructedClass { Foo, Bar, @@ -48,7 +49,6 @@ struct Foo : PlacementAllocated { struct Bar : Foo { ~Bar() override { mockDestructor->Call(this, DestructedClass::Bar); } }; -} // namespace // Test that deletion calls the destructor and does not free memory. TEST_F(PlacementAllocatedTests, DeletionDoesNotFreeMemory) { @@ -107,3 +107,6 @@ TEST_F(PlacementAllocatedTests, DeletingBaseClassCallsDerivedDestructor) { free(ptr); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/RefBaseTests.cpp b/src/dawn/tests/unittests/RefBaseTests.cpp index 6436c8a4ed..8117290d5d 100644 --- a/src/dawn/tests/unittests/RefBaseTests.cpp +++ b/src/dawn/tests/unittests/RefBaseTests.cpp @@ -18,7 +18,9 @@ #include "dawn/common/RefBase.h" #include "gmock/gmock.h" +namespace dawn { namespace { + using Id = uint32_t; enum class Action { @@ -98,7 +100,6 @@ struct RefTrackerTraits { constexpr RefTracker RefTrackerTraits::kNullValue; using Ref = RefBase; -} // namespace TEST(RefBase, Acquire) { Events events; @@ -301,3 +302,6 @@ TEST(RefBase, TCopyAssignmentAlternate) { Event{Action::kAssign, 2, 1}, // copy tracker1 Event{Action::kMarker, 30})); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/RefCountedTests.cpp b/src/dawn/tests/unittests/RefCountedTests.cpp index 5f2312e3f3..40ee4e91ee 100644 --- a/src/dawn/tests/unittests/RefCountedTests.cpp +++ b/src/dawn/tests/unittests/RefCountedTests.cpp @@ -18,6 +18,9 @@ #include "dawn/common/RefCounted.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + class RCTest : public RefCounted { public: RCTest() : RefCounted() {} @@ -396,3 +399,6 @@ TEST(Ref, InitializeInto) { ref = nullptr; EXPECT_TRUE(deleted); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ResultTests.cpp b/src/dawn/tests/unittests/ResultTests.cpp index a588631186..f187e04702 100644 --- a/src/dawn/tests/unittests/ResultTests.cpp +++ b/src/dawn/tests/unittests/ResultTests.cpp @@ -20,6 +20,7 @@ #include "dawn/common/Result.h" #include "gtest/gtest.h" +namespace dawn { namespace { template @@ -384,3 +385,4 @@ TEST(ResultGeneric, ReturningSuccess) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/SerialMapTests.cpp b/src/dawn/tests/unittests/SerialMapTests.cpp index 6ac7954d22..860d7b7ec0 100644 --- a/src/dawn/tests/unittests/SerialMapTests.cpp +++ b/src/dawn/tests/unittests/SerialMapTests.cpp @@ -19,6 +19,9 @@ #include "dawn/common/TypedInteger.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + using TestSerialMap = SerialMap; // A number of basic tests for SerialMap that are difficult to split from one another @@ -183,3 +186,6 @@ TEST(SerialMap, TypedInteger) { } ASSERT_TRUE(expectedValues.empty()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/SerialQueueTests.cpp b/src/dawn/tests/unittests/SerialQueueTests.cpp index 232d751649..48e8c5123b 100644 --- a/src/dawn/tests/unittests/SerialQueueTests.cpp +++ b/src/dawn/tests/unittests/SerialQueueTests.cpp @@ -19,6 +19,9 @@ #include "dawn/common/TypedInteger.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + using TestSerialQueue = SerialQueue; // A number of basic tests for SerialQueue that are difficult to split from one another @@ -175,3 +178,6 @@ TEST(SerialQueue, TypedInteger) { } ASSERT_TRUE(expectedValues.empty()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/SlabAllocatorTests.cpp b/src/dawn/tests/unittests/SlabAllocatorTests.cpp index 33f2b164ac..3e569f8fb6 100644 --- a/src/dawn/tests/unittests/SlabAllocatorTests.cpp +++ b/src/dawn/tests/unittests/SlabAllocatorTests.cpp @@ -19,6 +19,7 @@ #include "dawn/common/SlabAllocator.h" #include "gtest/gtest.h" +namespace dawn { namespace { struct Foo : public PlacementAllocated { @@ -31,8 +32,6 @@ struct alignas(256) AlignedFoo : public Foo { using Foo::Foo; }; -} // namespace - // Test that a slab allocator of a single object works. TEST(SlabAllocatorTests, Single) { SlabAllocator allocator(1 * sizeof(Foo)); @@ -179,3 +178,6 @@ TEST(SlabAllocatorTests, AllocateDeallocateMany) { allocator.Deallocate(object); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/StackContainerTests.cpp b/src/dawn/tests/unittests/StackContainerTests.cpp index a5635b95f7..be13d5f30e 100644 --- a/src/dawn/tests/unittests/StackContainerTests.cpp +++ b/src/dawn/tests/unittests/StackContainerTests.cpp @@ -12,6 +12,7 @@ #include "dawn/common/StackContainer.h" #include "gtest/gtest.h" +namespace dawn { namespace { class Placeholder : public RefCounted { @@ -24,8 +25,6 @@ class Placeholder : public RefCounted { int* const mAlive; }; -} // namespace - TEST(StackContainer, Vector) { const int stack_size = 3; StackVector vect; @@ -94,8 +93,6 @@ TEST(StackContainer, VectorDoubleDelete) { // Shouldn't crash at exit. } -namespace { - template class AlignedData { public: @@ -106,8 +103,6 @@ class AlignedData { alignas(alignment) char data_[alignment]; }; -} // anonymous namespace - #define EXPECT_ALIGNED(ptr, align) EXPECT_EQ(0u, reinterpret_cast(ptr) & (align - 1)) TEST(StackContainer, BufferAlignment) { @@ -133,9 +128,13 @@ TEST(StackContainer, BufferAlignment) { #endif } +} // anonymous namespace + template class StackVector; template class StackVector, 2>; +namespace { + template void CheckStackVectorElements(const StackVector& vec, std::initializer_list expected) { auto expected_it = expected.begin(); @@ -165,3 +164,6 @@ TEST(StackContainer, Iteration) { vect->resize(1); CheckStackVectorElements(vect, {8}); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/SystemUtilsTests.cpp b/src/dawn/tests/unittests/SystemUtilsTests.cpp index b3d2a94dc2..1428d02f3c 100644 --- a/src/dawn/tests/unittests/SystemUtilsTests.cpp +++ b/src/dawn/tests/unittests/SystemUtilsTests.cpp @@ -19,6 +19,9 @@ #include "gmock/gmock-matchers.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + using ::testing::_; using ::testing::Pair; @@ -116,3 +119,6 @@ TEST(SystemUtilsTests, ScopedEnvironmentVarRestoresNotSet) { } EXPECT_THAT(GetEnvironmentVar("ScopedEnvironmentVarForTest"), Pair("", false)); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/ToggleTests.cpp b/src/dawn/tests/unittests/ToggleTests.cpp index a498306f45..0b69561bd8 100644 --- a/src/dawn/tests/unittests/ToggleTests.cpp +++ b/src/dawn/tests/unittests/ToggleTests.cpp @@ -27,6 +27,7 @@ #include "dawn/utils/WGPUHelpers.h" #include "gtest/gtest.h" +namespace dawn { namespace { using testing::Contains; @@ -37,18 +38,18 @@ using testing::StrEq; class InstanceToggleTest : public testing::Test { protected: - void SetUp() override { dawnProcSetProcs(&dawn::native::GetProcs()); } + void SetUp() override { dawnProcSetProcs(&native::GetProcs()); } void TearDown() override { dawnProcSetProcs(nullptr); } }; // Test that instance toggles are set by requirement or default as expected. TEST_F(InstanceToggleTest, InstanceTogglesSet) { - auto validateInstanceToggles = [](const dawn::native::Instance* nativeInstance, + auto validateInstanceToggles = [](const native::Instance* nativeInstance, std::initializer_list enableToggles, std::initializer_list disableToggles) { - const dawn::native::InstanceBase* instance = dawn::native::FromAPI(nativeInstance->Get()); - const dawn::native::TogglesState& instanceTogglesState = instance->GetTogglesState(); + const native::InstanceBase* instance = native::FromAPI(nativeInstance->Get()); + const native::TogglesState& instanceTogglesState = instance->GetTogglesState(); std::vector enabledToggles = instanceTogglesState.GetEnabledToggleNames(); std::vector disabledToggles = instanceTogglesState.GetDisabledToggleNames(); EXPECT_EQ(disabledToggles.size(), disableToggles.size()); @@ -63,17 +64,17 @@ TEST_F(InstanceToggleTest, InstanceTogglesSet) { // Create instance with no toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; // Create an instance with default toggles, where AllowUnsafeAPIs is disabled and // DisallowUnsafeAPIs is enabled. - instance = std::make_unique(); + instance = std::make_unique(); validateInstanceToggles(instance.get(), {"disallow_unsafe_apis"}, {"allow_unsafe_apis"}); } // Create instance with empty toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; // Make an instance descriptor chaining an empty toggles descriptor WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -84,13 +85,13 @@ TEST_F(InstanceToggleTest, InstanceTogglesSet) { // Create an instance with default toggles, where AllowUnsafeAPIs is disabled and // DisallowUnsafeAPIs is enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceToggles(instance.get(), {"disallow_unsafe_apis"}, {"allow_unsafe_apis"}); } // Create instance with DisallowUnsafeAPIs explicitly enabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* disallowUnsafeApisToggle = "disallow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -102,13 +103,13 @@ TEST_F(InstanceToggleTest, InstanceTogglesSet) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with DisallowUnsafeApis explicitly enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceToggles(instance.get(), {disallowUnsafeApisToggle}, {"allow_unsafe_apis"}); } // Create instance with DisallowUnsafeAPIs explicitly disabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* disallowUnsafeApisToggle = "disallow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -120,14 +121,14 @@ TEST_F(InstanceToggleTest, InstanceTogglesSet) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with DisallowUnsafeApis explicitly disabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceToggles(instance.get(), {}, {disallowUnsafeApisToggle, "allow_unsafe_apis"}); } // Create instance with AllowUnsafeAPIs explicitly enabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* allowUnsafeApisToggle = "allow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -139,14 +140,14 @@ TEST_F(InstanceToggleTest, InstanceTogglesSet) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with AllowUnsafeAPIs explicitly enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceToggles(instance.get(), {allowUnsafeApisToggle, "disallow_unsafe_apis"}, {}); } // Create instance with AllowUnsafeAPIs explicitly disabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* allowUnsafeApisToggle = "allow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -158,22 +159,22 @@ TEST_F(InstanceToggleTest, InstanceTogglesSet) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with AllowUnsafeAPIs explicitly disabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceToggles(instance.get(), {"disallow_unsafe_apis"}, {allowUnsafeApisToggle}); } } // Test that instance toggles are inherited to the adapters and devices it creates. TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { - auto validateInstanceTogglesInheritedToAdapter = [&](dawn::native::Instance* nativeInstance) { - dawn::native::InstanceBase* instance = dawn::native::FromAPI(nativeInstance->Get()); - const dawn::native::TogglesState& instanceTogglesState = instance->GetTogglesState(); + auto validateInstanceTogglesInheritedToAdapter = [&](native::Instance* nativeInstance) { + native::InstanceBase* instance = native::FromAPI(nativeInstance->Get()); + const native::TogglesState& instanceTogglesState = instance->GetTogglesState(); // Discover adapters with default toggles. instance->DiscoverDefaultAdapters(); // Get the adapter created by instance with default toggles. - Ref nullAdapter; + Ref nullAdapter; for (auto& adapter : instance->GetAdapters()) { if (adapter->GetPhysicalDevice()->GetBackendType() == wgpu::BackendType::Null) { nullAdapter = adapter; @@ -184,14 +185,14 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { auto& adapterTogglesState = nullAdapter->GetTogglesState(); // Creater a default device. - dawn::native::DeviceBase* nullDevice = nullAdapter->APICreateDevice(); + native::DeviceBase* nullDevice = nullAdapter->APICreateDevice(); // Check instance toggles are inherited by adapter and device. - dawn::native::TogglesInfo togglesInfo; - static_assert(std::is_same_v, int>); - for (int i = 0; i < static_cast(dawn::native::Toggle::EnumCount); i++) { - dawn::native::Toggle toggle = static_cast(i); - if (togglesInfo.GetToggleInfo(toggle)->stage != dawn::native::ToggleStage::Instance) { + native::TogglesInfo togglesInfo; + static_assert(std::is_same_v, int>); + for (int i = 0; i < static_cast(native::Toggle::EnumCount); i++) { + native::Toggle toggle = static_cast(i); + if (togglesInfo.GetToggleInfo(toggle)->stage != native::ToggleStage::Instance) { continue; } EXPECT_EQ(instanceTogglesState.IsSet(toggle), adapterTogglesState.IsSet(toggle)); @@ -205,7 +206,7 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { // Create instance with DisallowUnsafeAPIs explicitly enabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* disallowUnsafeApisToggle = "disallow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -217,13 +218,13 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with DisallowUnsafeApis explicitly enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceTogglesInheritedToAdapter(instance.get()); } // Create instance with DisallowUnsafeAPIs explicitly disabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* disallowUnsafeApisToggle = "disallow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -235,13 +236,13 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with DisallowUnsafeApis explicitly enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceTogglesInheritedToAdapter(instance.get()); } // Create instance with AllowUnsafeAPIs explicitly enabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* allowUnsafeApisToggle = "allow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -253,13 +254,13 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with DisallowUnsafeApis explicitly enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceTogglesInheritedToAdapter(instance.get()); } // Create instance with AllowUnsafeAPIs explicitly disabled in toggles descriptor { - std::unique_ptr instance; + std::unique_ptr instance; const char* allowUnsafeApisToggle = "allow_unsafe_apis"; WGPUDawnTogglesDescriptor instanceTogglesDesc = {}; @@ -271,8 +272,10 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) { instanceDesc.nextInChain = &instanceTogglesDesc.chain; // Create an instance with DisallowUnsafeApis explicitly enabled. - instance = std::make_unique(&instanceDesc); + instance = std::make_unique(&instanceDesc); validateInstanceTogglesInheritedToAdapter(instance.get()); } } + } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/TypedIntegerTests.cpp b/src/dawn/tests/unittests/TypedIntegerTests.cpp index fd9bf7702a..b4edb07a12 100644 --- a/src/dawn/tests/unittests/TypedIntegerTests.cpp +++ b/src/dawn/tests/unittests/TypedIntegerTests.cpp @@ -18,6 +18,9 @@ #include "dawn/common/UnderlyingType.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + class TypedIntegerTest : public testing::Test { protected: using Unsigned = TypedInteger; @@ -233,3 +236,6 @@ TEST_F(TypedIntegerTest, NegationOverflow) { } #endif // defined(DAWN_ENABLE_ASSERTS) + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/UnicodeTests.cpp b/src/dawn/tests/unittests/UnicodeTests.cpp index ef08790403..e43027adcf 100644 --- a/src/dawn/tests/unittests/UnicodeTests.cpp +++ b/src/dawn/tests/unittests/UnicodeTests.cpp @@ -15,6 +15,9 @@ #include "dawn/native/ShaderModule.h" #include "dawn/tests/unittests/validation/ValidationTest.h" +namespace dawn { +namespace { + class CountUTF16CodeUnitsFromUTF8StringTest : public ValidationTest {}; TEST_F(CountUTF16CodeUnitsFromUTF8StringTest, ValidUnicodeString) { @@ -40,8 +43,8 @@ TEST_F(CountUTF16CodeUnitsFromUTF8StringTest, ValidUnicodeString) { }}; for (const TestCase& testCase : kTestCases) { - dawn::native::ResultOrError resultOrError = - dawn::native::CountUTF16CodeUnitsFromUTF8String(std::string_view(testCase.u8String)); + native::ResultOrError resultOrError = + native::CountUTF16CodeUnitsFromUTF8String(std::string_view(testCase.u8String)); ASSERT_TRUE(resultOrError.IsSuccess()); ASSERT_EQ(testCase.lengthInUTF16, resultOrError.AcquireSuccess()); } @@ -65,9 +68,12 @@ TEST_F(CountUTF16CodeUnitsFromUTF8StringTest, InvalidUnicodeString) { }}; for (const char* testCase : kTestCases) { - dawn::native::ResultOrError resultOrError = - dawn::native::CountUTF16CodeUnitsFromUTF8String(std::string_view(testCase)); + native::ResultOrError resultOrError = + native::CountUTF16CodeUnitsFromUTF8String(std::string_view(testCase)); ASSERT_TRUE(resultOrError.IsError()); std::ignore = resultOrError.AcquireError(); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/WindowsUtilsTests.cpp b/src/dawn/tests/unittests/WindowsUtilsTests.cpp index 70b209ef99..6e689be070 100644 --- a/src/dawn/tests/unittests/WindowsUtilsTests.cpp +++ b/src/dawn/tests/unittests/WindowsUtilsTests.cpp @@ -16,6 +16,9 @@ #include "dawn/common/WindowsUtils.h" +namespace dawn { +namespace { + TEST(WindowsUtilsTests, WCharToUTF8) { // Test the empty string ASSERT_EQ("", WCharToUTF8(L"")); @@ -49,3 +52,6 @@ TEST(WindowsUtilsTests, UTF8ToWStr) { // Test three-byte utf8 codepoint ASSERT_EQ(L"\x1050", UTF8ToWStr("\xe1\x81\x90")); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp index 1bb9939880..d1857f80ce 100644 --- a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp +++ b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp @@ -369,8 +369,6 @@ constexpr uint32_t kCheckValues[] = {1, 2, 3, 4, 5, 6, 7, 8, // 15, 31, 63, 127, 257, 511, 1023, 2047, // misalignments 17, 33, 65, 129, 257, 513, 1025, 2049}; -} // namespace - class CopySplitTest : public testing::TestWithParam { protected: void DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) { @@ -526,4 +524,5 @@ INSTANTIATE_TEST_SUITE_P(, CopySplitTest, testing::Values(wgpu::TextureDimension::e2D, wgpu::TextureDimension::e3D)); +} // anonymous namespace } // namespace dawn::native::d3d12 diff --git a/src/dawn/tests/unittests/native/AllowedErrorTests.cpp b/src/dawn/tests/unittests/native/AllowedErrorTests.cpp index f140798984..504a5e4e25 100644 --- a/src/dawn/tests/unittests/native/AllowedErrorTests.cpp +++ b/src/dawn/tests/unittests/native/AllowedErrorTests.cpp @@ -468,5 +468,5 @@ TEST_F(AllowedErrorTests, InjectError) { EXPECT_CALL(mDeviceLostCb, Call(WGPUDeviceLostReason_Destroyed, _, this)).Times(1); } -} // namespace +} // anonymous namespace } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/BlobTests.cpp b/src/dawn/tests/unittests/native/BlobTests.cpp index 4bf081d172..05f8a7d4c6 100644 --- a/src/dawn/tests/unittests/native/BlobTests.cpp +++ b/src/dawn/tests/unittests/native/BlobTests.cpp @@ -20,7 +20,6 @@ #include "gtest/gtest.h" namespace dawn::native { - namespace { // Test that a blob starts empty. @@ -220,5 +219,4 @@ TEST(BlobTests, AlignTo) { } } // namespace - } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/CacheRequestTests.cpp b/src/dawn/tests/unittests/native/CacheRequestTests.cpp index 6d14f848e7..8e79f13817 100644 --- a/src/dawn/tests/unittests/native/CacheRequestTests.cpp +++ b/src/dawn/tests/unittests/native/CacheRequestTests.cpp @@ -22,7 +22,6 @@ #include "dawn/tests/mocks/platform/CachingInterfaceMock.h" namespace dawn::native { - namespace { using ::testing::_; @@ -304,6 +303,5 @@ TEST_F(CacheRequestTests, CacheHitError) { EXPECT_FALSE(result.IsCached()); } -} // namespace - +} // anonymous namespace } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp b/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp index aaf1f3b5f6..e86ce6f844 100644 --- a/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp +++ b/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp @@ -22,6 +22,7 @@ #include "dawn/utils/WGPUHelpers.h" namespace dawn::native { +namespace { class CommandBufferEncodingTests : public DawnNativeTest { protected: @@ -309,4 +310,5 @@ TEST_F(CommandBufferEncodingTests, StateNotLeakedAfterRestore) { EXPECT_FALSE(stateTracker->HasPipeline()); } +} // anonymous namespace } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/CreatePipelineAsyncTaskTests.cpp b/src/dawn/tests/unittests/native/CreatePipelineAsyncTaskTests.cpp index 9509850fdb..ba203abf5d 100644 --- a/src/dawn/tests/unittests/native/CreatePipelineAsyncTaskTests.cpp +++ b/src/dawn/tests/unittests/native/CreatePipelineAsyncTaskTests.cpp @@ -187,5 +187,5 @@ TEST_F(CreatePipelineAsyncTaskTests, LongAsyncTaskFinishesBeforeDeviceIsDropped) EXPECT_TRUE(done); } -} // namespace +} // anonymous namespace } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/DestroyObjectTests.cpp b/src/dawn/tests/unittests/native/DestroyObjectTests.cpp index d2af77566b..6ee00e0af6 100644 --- a/src/dawn/tests/unittests/native/DestroyObjectTests.cpp +++ b/src/dawn/tests/unittests/native/DestroyObjectTests.cpp @@ -1044,17 +1044,18 @@ class DestroyObjectRegressionTests : public DawnNativeTest {}; // CommandEncoder, that destroying the device still works as expected (and does not cause // double-free). TEST_F(DestroyObjectRegressionTests, LastRefInCommandRenderPipeline) { - ::utils::BasicRenderPass pass = ::utils::CreateBasicRenderPass(device, 1, 1); + ::dawn::utils::BasicRenderPass pass = ::dawn::utils::CreateBasicRenderPass(device, 1, 1); - ::utils::ComboRenderPassDescriptor passDesc{}; + ::dawn::utils::ComboRenderPassDescriptor passDesc{}; wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::RenderPassEncoder renderEncoder = encoder.BeginRenderPass(&pass.renderPassInfo); - ::utils::ComboRenderPipelineDescriptor pipelineDesc; + ::dawn::utils::ComboRenderPipelineDescriptor pipelineDesc; pipelineDesc.cTargets[0].writeMask = wgpu::ColorWriteMask::None; - pipelineDesc.vertex.module = ::utils::CreateShaderModule(device, kVertexShader.data()); + pipelineDesc.vertex.module = ::dawn::utils::CreateShaderModule(device, kVertexShader.data()); pipelineDesc.vertex.entryPoint = "main"; - pipelineDesc.cFragment.module = ::utils::CreateShaderModule(device, kFragmentShader.data()); + pipelineDesc.cFragment.module = + ::dawn::utils::CreateShaderModule(device, kFragmentShader.data()); pipelineDesc.cFragment.entryPoint = "main"; renderEncoder.SetPipeline(device.CreateRenderPipeline(&pipelineDesc)); @@ -1069,12 +1070,12 @@ TEST_F(DestroyObjectRegressionTests, LastRefInCommandComputePipeline) { wgpu::ComputePassEncoder computeEncoder = encoder.BeginComputePass(); wgpu::ComputePipelineDescriptor pipelineDesc; - pipelineDesc.compute.module = ::utils::CreateShaderModule(device, kComputeShader.data()); + pipelineDesc.compute.module = ::dawn::utils::CreateShaderModule(device, kComputeShader.data()); pipelineDesc.compute.entryPoint = "main"; computeEncoder.SetPipeline(device.CreateComputePipeline(&pipelineDesc)); device.Destroy(); } -} // namespace +} // anonymous namespace } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/DeviceAsyncTaskTests.cpp b/src/dawn/tests/unittests/native/DeviceAsyncTaskTests.cpp index 8309005a30..a3567e28e3 100644 --- a/src/dawn/tests/unittests/native/DeviceAsyncTaskTests.cpp +++ b/src/dawn/tests/unittests/native/DeviceAsyncTaskTests.cpp @@ -25,6 +25,7 @@ namespace dawn::native { namespace { + using ::testing::Test; class DeviceAsyncTaskTests : public DawnMockTest {}; @@ -46,5 +47,5 @@ TEST_F(DeviceAsyncTaskTests, LongAsyncTaskFinishesBeforeDeviceIsDropped) { EXPECT_TRUE(done.load()); } -} // namespace +} // anonymous namespace } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp index a7d4ebed08..620b4d553f 100644 --- a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp +++ b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp @@ -26,6 +26,7 @@ #include "dawn/utils/WGPUHelpers.h" #include "gtest/gtest.h" +namespace dawn::native { namespace { using testing::Contains; @@ -426,3 +427,4 @@ TEST_F(DeviceCreationTest, RequestDeviceFailure) { } } // anonymous namespace +} // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/ObjectContentHasherTests.cpp b/src/dawn/tests/unittests/native/ObjectContentHasherTests.cpp index bf926fe304..e039f92f61 100644 --- a/src/dawn/tests/unittests/native/ObjectContentHasherTests.cpp +++ b/src/dawn/tests/unittests/native/ObjectContentHasherTests.cpp @@ -21,7 +21,6 @@ #include "dawn/tests/DawnNativeTest.h" namespace dawn::native { - namespace { class ObjectContentHasherTests : public DawnNativeTest {}; @@ -77,5 +76,4 @@ TEST(ObjectContentHasherTests, HashCombine) { } } // namespace - } // namespace dawn::native diff --git a/src/dawn/tests/unittests/native/StreamTests.cpp b/src/dawn/tests/unittests/native/StreamTests.cpp index 7b1f93ef1e..fb5b5d1f17 100644 --- a/src/dawn/tests/unittests/native/StreamTests.cpp +++ b/src/dawn/tests/unittests/native/StreamTests.cpp @@ -31,23 +31,28 @@ #include "tint/tint.h" namespace dawn::native::stream { +namespace { // Testing classes with mock serializing implemented for testing. class A { public: - MOCK_METHOD(void, WriteMock, (stream::Sink*, const A&), (const)); + MOCK_METHOD(void, WriteMock, (Sink*, const A&), (const)); }; -template <> -void stream::Stream::Write(stream::Sink* s, const A& t) { - t.WriteMock(s, t); -} struct Nested { A a1; A a2; }; + +} // anonymous namespace + template <> -void stream::Stream::Write(stream::Sink* s, const Nested& t) { +void Stream::Write(Sink* s, const A& t) { + t.WriteMock(s, t); +} + +template <> +void Stream::Write(Sink* s, const Nested& t) { StreamIn(s, t.a1); StreamIn(s, t.a2); } @@ -96,7 +101,7 @@ TEST(SerializeTests, StreamInIterable) { constexpr size_t kIterableSize = 100; std::vector vec(kIterableSize); - auto iterable = stream::Iterable(vec.data(), kIterableSize); + auto iterable = Iterable(vec.data(), kIterableSize); // Expect write to be called for each element for (const auto& a : vec) { @@ -483,6 +488,5 @@ REGISTER_TYPED_TEST_SUITE_P(StreamParameterizedTests, DeserializeEmpty); INSTANTIATE_TYPED_TEST_SUITE_P(DawnUnittests, StreamParameterizedTests, StreamValueTestTypes, ); -} // namespace - +} // anonymous namespace } // namespace dawn::native::stream diff --git a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp index f093cf7157..fe02002a0e 100644 --- a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class BindGroupValidationTest : public ValidationTest { public: wgpu::Texture CreateTexture(wgpu::TextureUsage usage, @@ -79,7 +82,7 @@ class BindGroupValidationTest : public ValidationTest { return desc; } - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8}; descriptor.requiredFeatures = requiredFeatures; @@ -3070,3 +3073,6 @@ TEST_F(SamplerTypeBindingTest, SamplerAndBindGroupMatches) { utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler()}}); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/CommandBufferValidationTests.cpp b/src/dawn/tests/unittests/validation/CommandBufferValidationTests.cpp index ab139ed5d6..013d25f595 100644 --- a/src/dawn/tests/unittests/validation/CommandBufferValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/CommandBufferValidationTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + using ::testing::HasSubstr; class CommandBufferValidationTest : public ValidationTest {}; @@ -341,7 +344,7 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&placeholderRenderPass); pass.End(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("Destroyed encoder cannot be finished.")); } @@ -350,13 +353,13 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&placeholderRenderPass); pass.End(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); } // Destroyed encoder should allow encoding, and emit error on finish. { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&placeholderRenderPass); pass.End(); ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("Destroyed encoder cannot be finished.")); @@ -365,7 +368,7 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) { // Destroyed encoder should allow encoding and shouldn't emit an error if never finished. { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&placeholderRenderPass); pass.End(); } @@ -376,21 +379,21 @@ TEST_F(CommandBufferValidationTest, DestroyEncoder) { wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&placeholderRenderPass); pass.End(); encoder.Finish(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); } // Destroying an encoder twice should not emit any errors. { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - dawn::native::FromAPI(encoder.Get())->Destroy(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); } // Destroying an encoder twice and then calling finish should fail. { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - dawn::native::FromAPI(encoder.Get())->Destroy(); - dawn::native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); + native::FromAPI(encoder.Get())->Destroy(); ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("Destroyed encoder cannot be finished.")); } } @@ -423,3 +426,6 @@ TEST_F(CommandBufferValidationTest, EncodeAfterDeviceDestroyed) { ASSERT_DEVICE_ERROR(encoder.Finish(), HasSubstr("[Invalid CommandEncoder] is invalid.")); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ComputeIndirectValidationTests.cpp b/src/dawn/tests/unittests/validation/ComputeIndirectValidationTests.cpp index 2363c85dac..087a0c915c 100644 --- a/src/dawn/tests/unittests/validation/ComputeIndirectValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/ComputeIndirectValidationTests.cpp @@ -17,6 +17,9 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ComputeIndirectValidationTest : public ValidationTest { protected: void SetUp() override { @@ -95,3 +98,6 @@ TEST_F(ComputeIndirectValidationTest, IndirectUsage) { // Error case: using a buffer with the vertex usage is an error. TestIndirectOffset(utils::Expectation::Failure, {1, 2, 3}, 0, wgpu::BufferUsage::Vertex); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ComputeValidationTests.cpp b/src/dawn/tests/unittests/validation/ComputeValidationTests.cpp index 77ab331ba3..d2c34bcb3c 100644 --- a/src/dawn/tests/unittests/validation/ComputeValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/ComputeValidationTests.cpp @@ -16,6 +16,9 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + // TODO(cwallez@chromium.org): Add a regression test for Disptach validation trying to acces the // input state. @@ -84,3 +87,6 @@ TEST_F(ComputeValidationTest, PerDimensionDispatchSizeLimits_InvalidAll) { const uint32_t max = GetSupportedLimits().limits.maxComputeWorkgroupsPerDimension; ASSERT_DEVICE_ERROR(TestDispatch(max + 1, max + 1, max + 1)); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp b/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp index b2eafe8840..8808a23416 100644 --- a/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp @@ -22,6 +22,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class CopyCommandTest : public ValidationTest { protected: wgpu::Buffer CreateBuffer(uint64_t size, wgpu::BufferUsage usage) { @@ -420,7 +423,7 @@ TEST_F(CopyCommandTest_B2B, CopyWithinSameBuffer) { class CopyCommandTest_B2T : public CopyCommandTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8}; descriptor.requiredFeatures = requiredFeatures; @@ -1028,7 +1031,7 @@ TEST_F(CopyCommandTest_B2T, RequiredBytesInCopyOverflow) { class CopyCommandTest_T2B : public CopyCommandTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8}; descriptor.requiredFeatures = requiredFeatures; @@ -1665,7 +1668,7 @@ TEST_F(CopyCommandTest_T2B, RequiredBytesInCopyOverflow) { class CopyCommandTest_T2T : public CopyCommandTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8}; descriptor.requiredFeatures = requiredFeatures; @@ -2144,7 +2147,7 @@ TEST_F(CopyCommandTest_T2T, CopyWithinSameTexture) { class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC, wgpu::FeatureName::TextureCompressionETC2, @@ -2652,3 +2655,6 @@ TEST_F(CopyCommandTest_ClearBuffer, BuffersInErrorState) { encoder.ClearBuffer(errorBuffer, 0, 4); ASSERT_DEVICE_ERROR(encoder.Finish()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/CopyTextureForBrowserTests.cpp b/src/dawn/tests/unittests/validation/CopyTextureForBrowserTests.cpp index 1c3ab63dd6..9c7e1921c5 100644 --- a/src/dawn/tests/unittests/validation/CopyTextureForBrowserTests.cpp +++ b/src/dawn/tests/unittests/validation/CopyTextureForBrowserTests.cpp @@ -20,7 +20,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + wgpu::Texture Create2DTexture( wgpu::Device device, uint32_t width, @@ -70,8 +72,6 @@ wgpu::ExternalTexture CreateExternalTexture(wgpu::Device device, uint32_t width, return device.CreateExternalTexture(&externalDesc); } -} // namespace - class CopyTextureForBrowserTest : public ValidationTest { protected: void TestCopyTextureForBrowser(utils::Expectation expectation, @@ -101,7 +101,7 @@ class CopyTextureForBrowserTest : public ValidationTest { class CopyTextureForBrowserInternalUsageTest : public CopyTextureForBrowserTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName feature = wgpu::FeatureName::DawnInternalUsages; descriptor.requiredFeatures = &feature; @@ -142,7 +142,7 @@ class CopyExternalTextureForBrowserTest : public ValidationTest { class CopyExternalTextureForBrowserInternalUsageTest : public CopyExternalTextureForBrowserTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName feature = wgpu::FeatureName::DawnInternalUsages; descriptor.requiredFeatures = &feature; @@ -954,3 +954,6 @@ TEST_F(CopyExternalTextureForBrowserInternalUsageTest, InternalUsage) { destination, 0, {0, 0, 0}, {16, 16, 1}, wgpu::TextureAspect::All, options); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/DebugMarkerValidationTests.cpp b/src/dawn/tests/unittests/validation/DebugMarkerValidationTests.cpp index dfb5810fee..f634ec5749 100644 --- a/src/dawn/tests/unittests/validation/DebugMarkerValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/DebugMarkerValidationTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderBundleEncoderDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class DebugMarkerValidationTest : public ValidationTest {}; // Correct usage of debug markers should succeed in render pass. @@ -253,3 +256,6 @@ TEST_F(DebugMarkerValidationTest, NestedRenderInCommandEncoderIndependent) { } ASSERT_DEVICE_ERROR(encoder.Finish()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/DrawIndirectValidationTests.cpp b/src/dawn/tests/unittests/validation/DrawIndirectValidationTests.cpp index 37e010a90c..18f03a155b 100644 --- a/src/dawn/tests/unittests/validation/DrawIndirectValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/DrawIndirectValidationTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class DrawIndirectValidationTest : public ValidationTest { protected: void SetUp() override { @@ -160,3 +163,6 @@ TEST_F(DrawIndirectValidationTest, IndirectUsage) { TestIndirectOffset(utils::Expectation::Failure, {1, 2, 3, 4, 5}, 0, true, wgpu::BufferUsage::Vertex); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp b/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp index 95df68470e..a6c312415f 100644 --- a/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp @@ -19,7 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + constexpr uint32_t kRTSize = 4; constexpr uint32_t kFloat32x2Stride = 2 * sizeof(float); constexpr uint32_t kFloat32x4Stride = 4 * sizeof(float); @@ -1005,3 +1007,4 @@ TEST_F(DrawVertexAndIndexBufferOOBValidationTests, SetBufferMultipleTime) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/DynamicStateCommandValidationTests.cpp b/src/dawn/tests/unittests/validation/DynamicStateCommandValidationTests.cpp index 329e38cffb..df1b79df90 100644 --- a/src/dawn/tests/unittests/validation/DynamicStateCommandValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/DynamicStateCommandValidationTests.cpp @@ -18,6 +18,9 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class SetViewportTest : public ValidationTest { protected: void TestViewportCall(bool success, @@ -256,3 +259,6 @@ TEST_F(SetStencilReferenceTest, AllBitsAllowed) { } encoder.Finish(); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp b/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp index 9a424c2d1a..a6dc44d0f6 100644 --- a/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp +++ b/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp @@ -17,7 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + class ExternalTextureTest : public ValidationTest { public: wgpu::TextureDescriptor CreateTextureDescriptor( @@ -641,4 +643,5 @@ TEST_F(ExternalTextureTest, SubmitExternalTextureWithDestroyedPlane) { } } -} // namespace +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp b/src/dawn/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp index 38bd185060..74662fd385 100644 --- a/src/dawn/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp @@ -17,6 +17,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class GetBindGroupLayoutTests : public ValidationTest { protected: wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) { @@ -234,50 +237,50 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) { }; // Textures not used default to non-filtering - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(emptyVertexModule, unusedTextureFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(emptyVertexModule, unusedTextureFragmentModule).Get(), filteringBGL.Get())); // Textures used with textureLoad default to non-filtering - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(emptyVertexModule, textureLoadFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(emptyVertexModule, textureLoadFragmentModule).Get(), filteringBGL.Get())); // Textures used with textureLoad on both stages default to non-filtering - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureLoadVertexModule, textureLoadFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureLoadVertexModule, textureLoadFragmentModule).Get(), filteringBGL.Get())); // Textures used with textureSample default to filtering - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(emptyVertexModule, textureSampleFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(emptyVertexModule, textureSampleFragmentModule).Get(), filteringBGL.Get())); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureSampleVertexModule, unusedTextureFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureSampleVertexModule, unusedTextureFragmentModule).Get(), filteringBGL.Get())); // Textures used with both textureLoad and textureSample default to filtering - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureLoadVertexModule, textureSampleFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureLoadVertexModule, textureSampleFragmentModule).Get(), filteringBGL.Get())); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureSampleVertexModule, textureLoadFragmentModule).Get(), nonFilteringBGL.Get())); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( BGLFromModules(textureSampleVertexModule, textureLoadFragmentModule).Get(), filteringBGL.Get())); } @@ -317,7 +320,7 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) { desc.entryCount = 1; desc.entries = &binding; - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -351,7 +354,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { @fragment fn main() { var pos : vec4f = ssbo.pos; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } { @@ -365,7 +368,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { @fragment fn main() { var pos : vec4f = uniforms.pos; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -380,7 +383,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { @fragment fn main() { var pos : vec4f = ssbo.pos; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -394,7 +397,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -406,7 +409,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -419,7 +422,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { @fragment fn main() { _ = mySampler; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } } @@ -447,7 +450,7 @@ TEST_F(GetBindGroupLayoutTests, ExternalTextureBindingType) { @fragment fn main() { _ = myExternalTexture; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -475,7 +478,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -487,7 +490,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -499,7 +502,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -511,7 +514,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -523,7 +526,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -535,7 +538,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } } @@ -563,7 +566,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -575,7 +578,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -587,7 +590,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) { @fragment fn main() { _ = textureDimensions(myTexture); })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } } @@ -620,7 +623,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) { @fragment fn main() { var pos : vec4f = uniforms.pos; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -635,7 +638,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) { @fragment fn main() { var pos : vec4f = uniforms.pos; })"); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } @@ -650,7 +653,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) { @fragment fn main() { var pos : vec4f = uniforms.pos; })"); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get())); } } @@ -762,7 +765,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) { descriptor.vertex.module = vsModule4; descriptor.cFragment.module = fsModule4; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), bgl4.Get())); } @@ -771,7 +774,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) { descriptor.vertex.module = vsModule64; descriptor.cFragment.module = fsModule4; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), bgl64.Get())); } @@ -780,7 +783,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) { descriptor.vertex.module = vsModule4; descriptor.cFragment.module = fsModule64; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), bgl64.Get())); } } @@ -834,7 +837,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); binding.visibility = wgpu::ShaderStage::Vertex; - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), device.CreateBindGroupLayout(&desc).Get())); } @@ -845,7 +848,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); binding.visibility = wgpu::ShaderStage::Fragment; - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), device.CreateBindGroupLayout(&desc).Get())); } @@ -856,7 +859,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); binding.visibility = wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Vertex; - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), device.CreateBindGroupLayout(&desc).Get())); } } @@ -1006,11 +1009,11 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) { wgpu::BindGroupLayout emptyBindGroupLayout = device.CreateBindGroupLayout(&desc); - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(0).Get(), emptyBindGroupLayout.Get())); // Used - EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_TRUE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(1).Get(), emptyBindGroupLayout.Get())); // Not Used. - EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( + EXPECT_FALSE(native::BindGroupLayoutBindingsEqualForTesting( pipeline.GetBindGroupLayout(2).Get(), emptyBindGroupLayout.Get())); // Used. ASSERT_DEVICE_ERROR(pipeline.GetBindGroupLayout(3)); // Past last defined BGL, error! } @@ -1136,3 +1139,6 @@ TEST_F(GetBindGroupLayoutTests, FullOfEmptyBGLs) { EXPECT_EQ(pipeline.GetBindGroupLayout(2).Get(), emptyBGL.Get()); EXPECT_EQ(pipeline.GetBindGroupLayout(3).Get(), emptyBGL.Get()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/IndexBufferValidationTests.cpp b/src/dawn/tests/unittests/validation/IndexBufferValidationTests.cpp index f241e530fa..98e18d4a14 100644 --- a/src/dawn/tests/unittests/validation/IndexBufferValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/IndexBufferValidationTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class IndexBufferValidationTest : public ValidationTest { protected: wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format, @@ -302,3 +305,6 @@ TEST_F(IndexBufferValidationTest, OffsetAlignment) { ASSERT_DEVICE_ERROR(encoder.Finish()); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/InternalUsageValidationTests.cpp b/src/dawn/tests/unittests/validation/InternalUsageValidationTests.cpp index e4d82d3a1a..537acb422d 100644 --- a/src/dawn/tests/unittests/validation/InternalUsageValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/InternalUsageValidationTests.cpp @@ -16,6 +16,9 @@ #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class InternalUsageValidationDisabledTest : public ValidationTest {}; // Test that using DawnTextureInternalUsageDescriptor is an error if DawnInternalUsages is not @@ -64,7 +67,7 @@ TEST_F(InternalUsageValidationDisabledTest, CommandEncoderDescriptorRequiresFeat } class TextureInternalUsageValidationTest : public ValidationTest { - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnInternalUsages}; descriptor.requiredFeatures = requiredFeatures; @@ -313,3 +316,6 @@ TEST_F(TextureInternalUsageValidationTest, CommandValidation) { encoder.Finish(); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/LabelTests.cpp b/src/dawn/tests/unittests/validation/LabelTests.cpp index b99a13f741..5776315a20 100644 --- a/src/dawn/tests/unittests/validation/LabelTests.cpp +++ b/src/dawn/tests/unittests/validation/LabelTests.cpp @@ -18,6 +18,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class LabelTest : public ValidationTest { void SetUp() override { ValidationTest::SetUp(); @@ -37,7 +40,7 @@ TEST_F(LabelTest, BindGroup) { // The label should be empty if one was not set. { wgpu::BindGroup bindGroup = device.CreateBindGroup(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(bindGroup.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(bindGroup.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -45,7 +48,7 @@ TEST_F(LabelTest, BindGroup) { { wgpu::BindGroup bindGroup = device.CreateBindGroup(&descriptor); bindGroup.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(bindGroup.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(bindGroup.Get()); ASSERT_EQ(label, readbackLabel); } @@ -53,7 +56,7 @@ TEST_F(LabelTest, BindGroup) { { descriptor.label = label.c_str(); wgpu::BindGroup bindGroup = device.CreateBindGroup(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(bindGroup.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(bindGroup.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -68,7 +71,7 @@ TEST_F(LabelTest, BindGroupLayout) { // The label should be empty if one was not set. { wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(bindGroupLayout.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(bindGroupLayout.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -76,7 +79,7 @@ TEST_F(LabelTest, BindGroupLayout) { { wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&descriptor); bindGroupLayout.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(bindGroupLayout.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(bindGroupLayout.Get()); ASSERT_EQ(label, readbackLabel); } @@ -84,7 +87,7 @@ TEST_F(LabelTest, BindGroupLayout) { { descriptor.label = label.c_str(); wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(bindGroupLayout.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(bindGroupLayout.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -98,7 +101,7 @@ TEST_F(LabelTest, Buffer) { // The label should be empty if one was not set. { wgpu::Buffer buffer = device.CreateBuffer(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(buffer.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(buffer.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -106,7 +109,7 @@ TEST_F(LabelTest, Buffer) { { wgpu::Buffer buffer = device.CreateBuffer(&descriptor); buffer.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(buffer.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(buffer.Get()); ASSERT_EQ(label, readbackLabel); } @@ -114,7 +117,7 @@ TEST_F(LabelTest, Buffer) { { descriptor.label = label.c_str(); wgpu::Buffer buffer = device.CreateBuffer(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(buffer.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(buffer.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -127,7 +130,7 @@ TEST_F(LabelTest, CommandBuffer) { { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandBuffer commandBuffer = encoder.Finish(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(commandBuffer.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(commandBuffer.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -136,7 +139,7 @@ TEST_F(LabelTest, CommandBuffer) { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandBuffer commandBuffer = encoder.Finish(&descriptor); commandBuffer.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(commandBuffer.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(commandBuffer.Get()); ASSERT_EQ(label, readbackLabel); } @@ -145,7 +148,7 @@ TEST_F(LabelTest, CommandBuffer) { descriptor.label = label.c_str(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandBuffer commandBuffer = encoder.Finish(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(commandBuffer.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(commandBuffer.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -157,7 +160,7 @@ TEST_F(LabelTest, CommandEncoder) { // The label should be empty if one was not set. { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -165,7 +168,7 @@ TEST_F(LabelTest, CommandEncoder) { { wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&descriptor); encoder.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); } @@ -173,7 +176,7 @@ TEST_F(LabelTest, CommandEncoder) { { descriptor.label = label.c_str(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -187,7 +190,7 @@ TEST_F(LabelTest, ComputePassEncoder) { // The label should be empty if one was not set. { wgpu::ComputePassEncoder encoder = commandEncoder.BeginComputePass(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_TRUE(readbackLabel.empty()); encoder.End(); } @@ -196,7 +199,7 @@ TEST_F(LabelTest, ComputePassEncoder) { { wgpu::ComputePassEncoder encoder = commandEncoder.BeginComputePass(&descriptor); encoder.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); encoder.End(); } @@ -205,7 +208,7 @@ TEST_F(LabelTest, ComputePassEncoder) { { descriptor.label = label.c_str(); wgpu::ComputePassEncoder encoder = commandEncoder.BeginComputePass(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); encoder.End(); } @@ -237,7 +240,7 @@ TEST_F(LabelTest, ExternalTexture) { // The label should be empty if one was not set. { wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(externalTexture.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(externalTexture.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -245,7 +248,7 @@ TEST_F(LabelTest, ExternalTexture) { { wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&descriptor); externalTexture.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(externalTexture.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(externalTexture.Get()); ASSERT_EQ(label, readbackLabel); } @@ -253,7 +256,7 @@ TEST_F(LabelTest, ExternalTexture) { { descriptor.label = label.c_str(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(externalTexture.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(externalTexture.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -269,7 +272,7 @@ TEST_F(LabelTest, PipelineLayout) { // The label should be empty if one was not set. { wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipelineLayout.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipelineLayout.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -277,7 +280,7 @@ TEST_F(LabelTest, PipelineLayout) { { wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor); pipelineLayout.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipelineLayout.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipelineLayout.Get()); ASSERT_EQ(label, readbackLabel); } @@ -285,7 +288,7 @@ TEST_F(LabelTest, PipelineLayout) { { descriptor.label = label.c_str(); wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipelineLayout.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipelineLayout.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -300,7 +303,7 @@ TEST_F(LabelTest, QuerySet) { // The label should be empty if one was not set. { wgpu::QuerySet querySet = device.CreateQuerySet(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(querySet.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(querySet.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -308,7 +311,7 @@ TEST_F(LabelTest, QuerySet) { { wgpu::QuerySet querySet = device.CreateQuerySet(&descriptor); querySet.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(querySet.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(querySet.Get()); ASSERT_EQ(label, readbackLabel); } @@ -316,7 +319,7 @@ TEST_F(LabelTest, QuerySet) { { descriptor.label = label.c_str(); wgpu::QuerySet querySet = device.CreateQuerySet(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(querySet.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(querySet.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -329,8 +332,7 @@ TEST_F(LabelTest, Queue) { wgpu::DeviceDescriptor descriptor; wgpu::Device labelDevice = wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor)); - std::string readbackLabel = - dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(labelDevice.GetQueue().Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -340,8 +342,7 @@ TEST_F(LabelTest, Queue) { wgpu::Device labelDevice = wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor)); labelDevice.GetQueue().SetLabel(label.c_str()); - std::string readbackLabel = - dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(labelDevice.GetQueue().Get()); ASSERT_EQ(label, readbackLabel); } @@ -351,8 +352,7 @@ TEST_F(LabelTest, Queue) { descriptor.defaultQueue.label = label.c_str(); wgpu::Device labelDevice = wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor)); - std::string readbackLabel = - dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(labelDevice.GetQueue().Get()); ASSERT_EQ(label, readbackLabel); } } @@ -367,7 +367,7 @@ TEST_F(LabelTest, RenderBundleEncoder) { // The label should be empty if one was not set. { wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -375,7 +375,7 @@ TEST_F(LabelTest, RenderBundleEncoder) { { wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor); encoder.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); } @@ -383,7 +383,7 @@ TEST_F(LabelTest, RenderBundleEncoder) { { descriptor.label = label.c_str(); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -403,7 +403,7 @@ TEST_F(LabelTest, RenderPassEncoder) { // The label should be empty if one was not set. { wgpu::RenderPassEncoder encoder = commandEncoder.BeginRenderPass(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_TRUE(readbackLabel.empty()); encoder.End(); } @@ -412,7 +412,7 @@ TEST_F(LabelTest, RenderPassEncoder) { { wgpu::RenderPassEncoder encoder = commandEncoder.BeginRenderPass(&descriptor); encoder.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); encoder.End(); } @@ -421,7 +421,7 @@ TEST_F(LabelTest, RenderPassEncoder) { { descriptor.label = label.c_str(); wgpu::RenderPassEncoder encoder = commandEncoder.BeginRenderPass(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(encoder.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(encoder.Get()); ASSERT_EQ(label, readbackLabel); encoder.End(); } @@ -434,7 +434,7 @@ TEST_F(LabelTest, Sampler) { // The label should be empty if one was not set. { wgpu::Sampler sampler = device.CreateSampler(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(sampler.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(sampler.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -442,7 +442,7 @@ TEST_F(LabelTest, Sampler) { { wgpu::Sampler sampler = device.CreateSampler(&descriptor); sampler.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(sampler.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(sampler.Get()); ASSERT_EQ(label, readbackLabel); } @@ -450,7 +450,7 @@ TEST_F(LabelTest, Sampler) { { descriptor.label = label.c_str(); wgpu::Sampler sampler = device.CreateSampler(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(sampler.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(sampler.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -470,7 +470,7 @@ TEST_F(LabelTest, Texture) { // The label should be empty if one was not set. { wgpu::Texture texture = device.CreateTexture(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(texture.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(texture.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -478,7 +478,7 @@ TEST_F(LabelTest, Texture) { { wgpu::Texture texture = device.CreateTexture(&descriptor); texture.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(texture.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(texture.Get()); ASSERT_EQ(label, readbackLabel); } @@ -486,7 +486,7 @@ TEST_F(LabelTest, Texture) { { descriptor.label = label.c_str(); wgpu::Texture texture = device.CreateTexture(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(texture.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(texture.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -508,7 +508,7 @@ TEST_F(LabelTest, TextureView) { // The label should be empty if one was not set. { wgpu::TextureView textureView = texture.CreateView(); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(textureView.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(textureView.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -516,7 +516,7 @@ TEST_F(LabelTest, TextureView) { { wgpu::TextureView textureView = texture.CreateView(); textureView.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(textureView.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(textureView.Get()); ASSERT_EQ(label, readbackLabel); } @@ -525,7 +525,7 @@ TEST_F(LabelTest, TextureView) { wgpu::TextureViewDescriptor viewDescriptor; viewDescriptor.label = label.c_str(); wgpu::TextureView textureView = texture.CreateView(&viewDescriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(textureView.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(textureView.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -550,7 +550,7 @@ TEST_F(LabelTest, RenderPipeline) { // The label should be empty if one was not set. { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipeline.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipeline.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -558,7 +558,7 @@ TEST_F(LabelTest, RenderPipeline) { { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); pipeline.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipeline.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipeline.Get()); ASSERT_EQ(label, readbackLabel); } @@ -566,7 +566,7 @@ TEST_F(LabelTest, RenderPipeline) { { descriptor.label = label.c_str(); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipeline.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipeline.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -586,7 +586,7 @@ TEST_F(LabelTest, ComputePipeline) { // The label should be empty if one was not set. { wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipeline.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipeline.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -594,7 +594,7 @@ TEST_F(LabelTest, ComputePipeline) { { wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&descriptor); pipeline.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipeline.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipeline.Get()); ASSERT_EQ(label, readbackLabel); } @@ -602,7 +602,7 @@ TEST_F(LabelTest, ComputePipeline) { { descriptor.label = label.c_str(); wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(pipeline.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(pipeline.Get()); ASSERT_EQ(label, readbackLabel); } } @@ -622,7 +622,7 @@ TEST_F(LabelTest, ShaderModule) { // The label should be empty if one was not set. { wgpu::ShaderModule shaderModule = device.CreateShaderModule(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(shaderModule.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(shaderModule.Get()); ASSERT_TRUE(readbackLabel.empty()); } @@ -630,7 +630,7 @@ TEST_F(LabelTest, ShaderModule) { { wgpu::ShaderModule shaderModule = device.CreateShaderModule(&descriptor); shaderModule.SetLabel(label.c_str()); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(shaderModule.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(shaderModule.Get()); ASSERT_EQ(label, readbackLabel); } @@ -638,7 +638,10 @@ TEST_F(LabelTest, ShaderModule) { { descriptor.label = label.c_str(); wgpu::ShaderModule shaderModule = device.CreateShaderModule(&descriptor); - std::string readbackLabel = dawn::native::GetObjectLabelForTesting(shaderModule.Get()); + std::string readbackLabel = native::GetObjectLabelForTesting(shaderModule.Get()); ASSERT_EQ(label, readbackLabel); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/MinimumBufferSizeValidationTests.cpp b/src/dawn/tests/unittests/validation/MinimumBufferSizeValidationTests.cpp index d04d274d14..39d74b119c 100644 --- a/src/dawn/tests/unittests/validation/MinimumBufferSizeValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/MinimumBufferSizeValidationTests.cpp @@ -21,7 +21,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + // Helper for describing bindings throughout the tests struct BindingDescriptor { uint32_t group; @@ -146,7 +148,6 @@ std::vector CombineBindings( } return result; } -} // namespace class MinBufferSizeTestsBase : public ValidationTest { public: @@ -623,3 +624,6 @@ TEST_F(MinBufferSizePipelineCreationTests, NonStructVec3) { } }); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp b/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp index dd80de0dce..2af8626bd1 100644 --- a/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp @@ -19,9 +19,12 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ComputePipelineOverridableConstantsValidationTest : public ValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor deviceDescriptor) override { std::vector enabledToggles; std::vector disabledToggles; @@ -385,3 +388,6 @@ TEST_F(ComputePipelineOverridableConstantsValidationTest, OutofRangeValue) { ASSERT_DEVICE_ERROR(TestCreatePipeline(constants)); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp b/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp index 25143474dc..c65e7ed385 100644 --- a/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp +++ b/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp @@ -18,13 +18,14 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" +namespace dawn { +namespace { + constexpr static uint32_t kSize = 4; // Note that format Depth24PlusStencil8 has both depth and stencil aspects, so parameters // depthReadOnly and stencilReadOnly should be the same in render pass and render bundle. wgpu::TextureFormat kFormat = wgpu::TextureFormat::Depth24PlusStencil8; -namespace { - class RenderPipelineAndPassCompatibilityTests : public ValidationTest { public: wgpu::RenderPipeline CreatePipeline(wgpu::TextureFormat format, @@ -179,3 +180,4 @@ TEST_F(RenderPipelineAndPassCompatibilityTests, // - pipeline and pass compatibility tests for compute. } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/QueryValidationTests.cpp b/src/dawn/tests/unittests/validation/QueryValidationTests.cpp index 108ef48af5..ca59f0ab50 100644 --- a/src/dawn/tests/unittests/validation/QueryValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/QueryValidationTests.cpp @@ -17,6 +17,9 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class QuerySetValidationTest : public ValidationTest { protected: wgpu::QuerySet CreateQuerySet( @@ -273,7 +276,7 @@ TEST_F(OcclusionQueryValidationTest, InvalidBeginAndEnd) { class TimestampQueryValidationTest : public QuerySetValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::TimestampQuery}; descriptor.requiredFeatures = requiredFeatures; @@ -566,7 +569,7 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnCommandEncoder) { class TimestampQueryInsidePassesValidationTest : public QuerySetValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { // The timestamp query feature must be supported if the timestamp query inside passes // feature is supported. Enable timestamp query for validating queries overwrite inside and @@ -709,7 +712,7 @@ TEST_F(TimestampQueryInsidePassesValidationTest, WriteTimestampOnRenderPassEncod class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { // Create a device with pipeline statistic query feature required. Note that Pipeline // statistic query is an unsafe API, while AllowUnsafeApis instance toggle is enabled @@ -905,3 +908,6 @@ TEST_F(ResolveQuerySetValidationTest, ResolveToInvalidBufferAndOffset) { ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp b/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp index 38beb5e18e..56a6300d63 100644 --- a/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp @@ -17,6 +17,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class QueueSubmitValidationTest : public ValidationTest {}; @@ -363,3 +364,4 @@ TEST_F(QueueSubmitValidationTest, SubmitWithUnusedComputeTextures) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/QueueWriteTextureValidationTests.cpp b/src/dawn/tests/unittests/validation/QueueWriteTextureValidationTests.cpp index fd42e347e8..2bffbde260 100644 --- a/src/dawn/tests/unittests/validation/QueueWriteTextureValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/QueueWriteTextureValidationTests.cpp @@ -20,6 +20,7 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class QueueWriteTextureValidationTest : public ValidationTest { @@ -536,7 +537,7 @@ TEST_F(QueueWriteTextureValidationTest, WriteToStencilAspect) { class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC, wgpu::FeatureName::TextureCompressionETC2, @@ -787,3 +788,4 @@ TEST_F(WriteTextureTest_CompressedTextureFormats, WriteToMultipleArrayLayers) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp index 1db904e5df..e15ea2b40f 100644 --- a/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp @@ -20,6 +20,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class RenderBundleValidationTest : public ValidationTest { @@ -121,8 +122,6 @@ class RenderBundleValidationTest : public ValidationTest { wgpu::BindGroup bg1Vertex; }; -} // anonymous namespace - // Test creating and encoding an empty render bundle. TEST_F(RenderBundleValidationTest, Empty) { PlaceholderRenderPass renderPass(device); @@ -1204,3 +1203,6 @@ TEST_F(RenderBundleValidationTest, RenderBundleColorFormatsBytesPerSample) { } } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp index 006f6aa651..3e368d9470 100644 --- a/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp @@ -21,6 +21,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class RenderPassDescriptorValidationTest : public ValidationTest { @@ -1529,3 +1530,4 @@ TEST_F(RenderPassDescriptorValidationTest, RenderPassColorAttachmentBytesPerSamp // TODO(cwallez@chromium.org): Constraints on attachment aliasing? } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp index 4e339b65c4..71c515f993 100644 --- a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -22,9 +22,12 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class RenderPipelineValidationTest : public ValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::ShaderF16}; descriptor.requiredFeatures = requiredFeatures; @@ -57,13 +60,11 @@ class RenderPipelineValidationTest : public ValidationTest { wgpu::ShaderModule fsModuleUint; }; -namespace { bool BlendFactorContainsSrcAlpha(const wgpu::BlendFactor& blendFactor) { return blendFactor == wgpu::BlendFactor::SrcAlpha || blendFactor == wgpu::BlendFactor::OneMinusSrcAlpha || blendFactor == wgpu::BlendFactor::SrcAlphaSaturated; } -} // namespace // Test cases where creation should succeed TEST_F(RenderPipelineValidationTest, CreationSuccess) { @@ -1595,7 +1596,7 @@ TEST_F(RenderPipelineValidationTest, RenderPipelineColorAttachmentBytesPerSample class DepthClipControlValidationTest : public RenderPipelineValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DepthClipControl}; descriptor.requiredFeatures = requiredFeatures; @@ -1894,7 +1895,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute class RenderPipelineTransientAttachmentValidationTest : public RenderPipelineValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::ShaderF16, wgpu::FeatureName::TransientAttachments}; @@ -1999,3 +2000,6 @@ TEST_F(RenderPipelineTransientAttachmentValidationTest, LoadCausesError) { ASSERT_DEVICE_ERROR(encoder.Finish()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ResourceUsageTrackingTests.cpp b/src/dawn/tests/unittests/validation/ResourceUsageTrackingTests.cpp index 846b637909..e11fda23f9 100644 --- a/src/dawn/tests/unittests/validation/ResourceUsageTrackingTests.cpp +++ b/src/dawn/tests/unittests/validation/ResourceUsageTrackingTests.cpp @@ -19,6 +19,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class ResourceUsageTrackingTest : public ValidationTest { @@ -1683,3 +1684,4 @@ TEST_F(ResourceUsageTrackingTest, IndirectBufferWithReadOrWriteStorage) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp index cf7a896b20..8414dadcb2 100644 --- a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp @@ -21,6 +21,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class ShaderModuleValidationTest : public ValidationTest {}; #if TINT_BUILD_SPV_READER @@ -239,7 +242,7 @@ TEST_F(ShaderModuleValidationTest, OnlySpirvOptionsDescriptor) { // Tests that shader module compilation messages can be queried. TEST_F(ShaderModuleValidationTest, GetCompilationMessages) { - // This test works assuming ShaderModule is backed by a dawn::native::ShaderModuleBase, which + // This test works assuming ShaderModule is backed by a native::ShaderModuleBase, which // is not the case on the wire. DAWN_SKIP_TEST_IF(UsesWire()); @@ -248,8 +251,8 @@ TEST_F(ShaderModuleValidationTest, GetCompilationMessages) { return vec4f(0.0, 1.0, 0.0, 1.0); })"); - dawn::native::ShaderModuleBase* shaderModuleBase = dawn::native::FromAPI(shaderModule.Get()); - dawn::native::OwnedCompilationMessages* messages = shaderModuleBase->GetCompilationMessages(); + native::ShaderModuleBase* shaderModuleBase = native::FromAPI(shaderModule.Get()); + native::OwnedCompilationMessages* messages = shaderModuleBase->GetCompilationMessages(); messages->ClearMessages(); messages->AddMessageForTesting("Info Message"); messages->AddMessageForTesting("Warning Message", wgpu::CompilationMessageType::Warning); @@ -703,7 +706,7 @@ TEST_F(ShaderModuleValidationTest, WgslNullptrShader) { // Tests that WGSL extension with deprecated source member still works but emits warning. TEST_F(ShaderModuleValidationTest, SourceToCodeMemberDeprecation) { - // This test works assuming ShaderModule is backed by a dawn::native::ShaderModuleBase, which + // This test works assuming ShaderModule is backed by a native::ShaderModuleBase, which // is not the case on the wire. DAWN_SKIP_TEST_IF(UsesWire()); @@ -721,6 +724,9 @@ TEST_F(ShaderModuleValidationTest, SourceToCodeMemberDeprecation) { wgslDesc.code = "@compute @workgroup_size(1) fn main() {}"; wgpu::ShaderModule codeShader = device.CreateShaderModule(&descriptor); - EXPECT_TRUE(dawn::native::ShaderModuleBase::EqualityFunc()( - dawn::native::FromAPI(sourceShader.Get()), dawn::native::FromAPI(codeShader.Get()))); + EXPECT_TRUE(native::ShaderModuleBase::EqualityFunc()(native::FromAPI(sourceShader.Get()), + native::FromAPI(codeShader.Get()))); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp index b8b1ee1a90..030ab73fd5 100644 --- a/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class StorageTextureValidationTests : public ValidationTest { protected: void SetUp() override { @@ -269,7 +272,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInShaders) { class BGRA8UnormStorageTextureInShaderValidationTests : public StorageTextureValidationTests { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::BGRA8UnormStorage}; descriptor.requiredFeatures = requiredFeatures; @@ -427,7 +430,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroupLayout) { class BGRA8UnormStorageBindGroupLayoutTest : public StorageTextureValidationTests { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::BGRA8UnormStorage}; descriptor.requiredFeatures = requiredFeatures; @@ -857,3 +860,6 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneComput encoder.Finish(); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/TextureSubresourceTests.cpp b/src/dawn/tests/unittests/validation/TextureSubresourceTests.cpp index 78f5b668de..74dcaee1f9 100644 --- a/src/dawn/tests/unittests/validation/TextureSubresourceTests.cpp +++ b/src/dawn/tests/unittests/validation/TextureSubresourceTests.cpp @@ -16,6 +16,7 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" +namespace dawn { namespace { class TextureSubresourceTest : public ValidationTest { @@ -133,3 +134,4 @@ TEST_F(TextureSubresourceTest, ArrayLayersTest) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/TextureValidationTests.cpp b/src/dawn/tests/unittests/validation/TextureValidationTests.cpp index 3d3d4aee3d..4a512fda61 100644 --- a/src/dawn/tests/unittests/validation/TextureValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/TextureValidationTests.cpp @@ -20,6 +20,7 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { constexpr wgpu::TextureFormat kNonRenderableColorFormats[] = { @@ -699,7 +700,7 @@ TEST_F(TextureValidationTest, UseASTCFormatWithoutEnablingFeature) { class D32S8TextureFormatsValidationTests : public TextureValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8}; descriptor.requiredFeatures = requiredFeatures; @@ -721,7 +722,7 @@ TEST_F(D32S8TextureFormatsValidationTests, DepthStencilFormatsFor3D) { class CompressedTextureFormatsValidationTests : public TextureValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC, wgpu::FeatureName::TextureCompressionETC2, @@ -879,7 +880,7 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureSize) { class RG11B10UfloatTextureFormatsValidationTests : public TextureValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::RG11B10UfloatRenderable}; descriptor.requiredFeatures = requiredFeatures; @@ -902,7 +903,7 @@ TEST_F(RG11B10UfloatTextureFormatsValidationTests, RenderableFeature) { class BGRA8UnormTextureFormatsValidationTests : public TextureValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::BGRA8UnormStorage}; descriptor.requiredFeatures = requiredFeatures; @@ -1038,7 +1039,7 @@ TEST_F(TextureValidationTest, TransientAttachmentOnUnsupportedDevice) { class TransientAttachmentValidationTest : public TextureValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::TransientAttachments}; descriptor.requiredFeatures = requiredFeatures; @@ -1081,4 +1082,5 @@ TEST_F(TransientAttachmentValidationTest, FlagsBeyondRenderAttachment) { ASSERT_DEVICE_ERROR(device.CreateTexture(&desc)); } -} // namespace +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp b/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp index e7eefaa642..1ef586bba2 100644 --- a/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp @@ -16,6 +16,7 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" +namespace dawn { namespace { class TextureViewValidationTest : public ValidationTest {}; @@ -916,7 +917,7 @@ TEST_F(TextureViewValidationTest, AspectMustExist) { class D32S8TextureViewValidationTests : public ValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8}; descriptor.requiredFeatures = requiredFeatures; @@ -961,3 +962,4 @@ TEST_F(D32S8TextureViewValidationTests, TextureViewFormatCompatibility) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ToggleValidationTests.cpp b/src/dawn/tests/unittests/validation/ToggleValidationTests.cpp index c6d3dcd8f2..694065c24f 100644 --- a/src/dawn/tests/unittests/validation/ToggleValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/ToggleValidationTests.cpp @@ -16,6 +16,7 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" +namespace dawn { namespace { class ToggleValidationTest : public ValidationTest { @@ -25,12 +26,12 @@ class ToggleValidationTest : public ValidationTest { } }; -// Tests querying the detail of a toggle from dawn::native::InstanceBase works correctly. +// Tests querying the detail of a toggle from native::InstanceBase works correctly. TEST_F(ToggleValidationTest, QueryToggleInfo) { // Query with a valid toggle name { const char* kValidToggleName = "emulate_store_and_msaa_resolve"; - const dawn::native::ToggleInfo* toggleInfo = GetToggleInfo(kValidToggleName); + const native::ToggleInfo* toggleInfo = GetToggleInfo(kValidToggleName); ASSERT_NE(nullptr, toggleInfo); ASSERT_NE(nullptr, toggleInfo->name); ASSERT_NE(nullptr, toggleInfo->description); @@ -40,7 +41,7 @@ TEST_F(ToggleValidationTest, QueryToggleInfo) { // Query with an invalid toggle name { const char* kInvalidToggleName = "!@#$%^&*"; - const dawn::native::ToggleInfo* toggleInfo = GetToggleInfo(kInvalidToggleName); + const native::ToggleInfo* toggleInfo = GetToggleInfo(kInvalidToggleName); ASSERT_EQ(nullptr, toggleInfo); } } @@ -58,7 +59,7 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) { wgpu::Device deviceWithToggle = wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor)); - std::vector toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get()); + std::vector toggleNames = native::GetTogglesUsed(deviceWithToggle.Get()); bool validToggleExists = false; for (const char* toggle : toggleNames) { if (strcmp(toggle, kValidToggleName) == 0) { @@ -79,7 +80,7 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) { wgpu::Device deviceWithToggle = wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor)); - std::vector toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get()); + std::vector toggleNames = native::GetTogglesUsed(deviceWithToggle.Get()); bool InvalidToggleExists = false; for (const char* toggle : toggleNames) { if (strcmp(toggle, kInvalidToggleName) == 0) { @@ -100,7 +101,7 @@ TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) { wgpu::Device deviceWithToggle = wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor)); - std::vector toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get()); + std::vector toggleNames = native::GetTogglesUsed(deviceWithToggle.Get()); bool validToggleExists = false; for (const char* toggle : toggleNames) { if (strcmp(toggle, kValidToggleName) == 0) { @@ -109,4 +110,6 @@ TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) { } ASSERT_EQ(validToggleExists, true); } + } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp index a74dca7d66..8e65789a95 100644 --- a/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp @@ -20,15 +20,16 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + using testing::HasSubstr; -} // anonymous namespace class UnsafeAPIValidationTest : public ValidationTest { protected: // UnsafeAPIValidationTest create the device with the AllowUnsafeAPIs toggle explicitly // disabled, which overrides the inheritance. - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { // Disable the AllowUnsafeAPIs toggles in device toggles descriptor to override the // inheritance and create a device disallowing unsafe apis. @@ -55,3 +56,6 @@ TEST_F(UnsafeAPIValidationTest, chromium_disable_uniformity_analysis) { } )")); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/ValidationTest.cpp b/src/dawn/tests/unittests/validation/ValidationTest.cpp index 9d738412aa..d3b4ba538f 100644 --- a/src/dawn/tests/unittests/validation/ValidationTest.cpp +++ b/src/dawn/tests/unittests/validation/ValidationTest.cpp @@ -124,7 +124,7 @@ ValidationTest::ValidationTest() { callback(WGPURequestDeviceStatus_Success, cDevice, nullptr, userdata); }; - mWireHelper = utils::CreateWireHelper(procs, gUseWire, gWireTraceDir.c_str()); + mWireHelper = dawn::utils::CreateWireHelper(procs, gUseWire, gWireTraceDir.c_str()); } void ValidationTest::SetUp() { diff --git a/src/dawn/tests/unittests/validation/ValidationTest.h b/src/dawn/tests/unittests/validation/ValidationTest.h index 9586134a54..7088755cc3 100644 --- a/src/dawn/tests/unittests/validation/ValidationTest.h +++ b/src/dawn/tests/unittests/validation/ValidationTest.h @@ -89,9 +89,9 @@ } while (0) #define EXPECT_DEPRECATION_WARNING(statement) EXPECT_DEPRECATION_WARNINGS(statement, 1) -namespace utils { +namespace dawn::utils { class WireHelper; -} // namespace utils +} // namespace dawn::utils void InitDawnValidationTestEnvironment(int argc, char** argv); @@ -150,7 +150,7 @@ class ValidationTest : public testing::Test { std::unique_ptr mDawnInstance; wgpu::Instance mInstance; dawn::native::Adapter mBackendAdapter; - std::unique_ptr mWireHelper; + std::unique_ptr mWireHelper; WGPUDevice mLastCreatedBackendDevice; static void OnDeviceError(WGPUErrorType type, const char* message, void* userdata); diff --git a/src/dawn/tests/unittests/validation/VertexBufferValidationTests.cpp b/src/dawn/tests/unittests/validation/VertexBufferValidationTests.cpp index b413d565bb..edcba5675f 100644 --- a/src/dawn/tests/unittests/validation/VertexBufferValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/VertexBufferValidationTests.cpp @@ -20,6 +20,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class VertexBufferValidationTest : public ValidationTest { protected: void SetUp() override { @@ -1041,3 +1044,6 @@ TEST_F(VertexBufferValidationTest, DrawStrideLimitsVertexMultipleAttributes) { } ASSERT_DEVICE_ERROR(encoder.Finish()); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp b/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp index d486184786..2db0748d20 100644 --- a/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp @@ -19,6 +19,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class VertexStateTest : public ValidationTest { protected: void CreatePipeline(bool success, @@ -442,3 +445,6 @@ TEST_F(VertexStateTest, UnusedBufferZeroAttribute) { state.cVertexBuffers[0].stepMode = wgpu::VertexStepMode::VertexBufferNotUsed; CreatePipeline(false, state, kPlaceholderVertexShader); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/VideoViewsValidationTests.cpp b/src/dawn/tests/unittests/validation/VideoViewsValidationTests.cpp index d1d6585093..57c17e7de8 100644 --- a/src/dawn/tests/unittests/validation/VideoViewsValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/VideoViewsValidationTests.cpp @@ -17,11 +17,12 @@ #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class VideoViewsValidation : public ValidationTest { protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter, + WGPUDevice CreateTestDevice(native::Adapter dawnAdapter, wgpu::DeviceDescriptor descriptor) override { wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnMultiPlanarFormats}; descriptor.requiredFeatures = requiredFeatures; @@ -338,3 +339,4 @@ TEST_F(VideoViewsValidation, WriteTexturePlaneAspectsFails) { } } // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/WritableBufferBindingAliasingValidationTests.cpp b/src/dawn/tests/unittests/validation/WritableBufferBindingAliasingValidationTests.cpp index 6b9366a70c..c1ba330eb2 100644 --- a/src/dawn/tests/unittests/validation/WritableBufferBindingAliasingValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/WritableBufferBindingAliasingValidationTests.cpp @@ -22,7 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + // Helper for describing bindings throughout the tests struct BindingDescriptor { utils::BindingInitializationHelper binding; @@ -108,8 +110,6 @@ std::string CreateFragmentShaderWithBindings(const BindingDescriptorGroups& bind GenerateReferenceString(bindingsGroups, wgpu::ShaderStage::Fragment) + "}"; } -} // namespace - class WritableBufferBindingAliasingValidationTests : public ValidationTest { public: wgpu::Buffer CreateBuffer(uint64_t bufferSize, wgpu::BufferUsage usage) { @@ -635,3 +635,6 @@ TEST_F(WritableBufferBindingAliasingValidationTests, SetBindGroupLazyAspectDynam commandEncoder.Finish(); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/validation/WritableTextureBindingAliasingValidationTests.cpp b/src/dawn/tests/unittests/validation/WritableTextureBindingAliasingValidationTests.cpp index 3bf6736248..a5ce5b29af 100644 --- a/src/dawn/tests/unittests/validation/WritableTextureBindingAliasingValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/WritableTextureBindingAliasingValidationTests.cpp @@ -22,7 +22,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { + using BindingDescriptorGroups = std::vector>; struct TestSet { @@ -97,8 +99,6 @@ const char* kVertexShader = R"( } )"; -} // namespace - class WritableTextureBindingAliasingValidationTests : public ValidationTest { public: wgpu::Texture CreateTexture(wgpu::TextureUsage usage, @@ -530,3 +530,6 @@ TEST_F(WritableTextureBindingAliasingValidationTests, SetBindGroupLazyAspect) { commandEncoder.Finish(); } } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/wire/WireAdapterTests.cpp b/src/dawn/tests/unittests/wire/WireAdapterTests.cpp index 1a1c6f1393..5bc98aacd0 100644 --- a/src/dawn/tests/unittests/wire/WireAdapterTests.cpp +++ b/src/dawn/tests/unittests/wire/WireAdapterTests.cpp @@ -362,5 +362,5 @@ TEST_F(WireAdapterTests, RequestDeviceWireDisconnectedBeforeCallback) { GetWireClient()->Disconnect(); } -} // namespace +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireArgumentTests.cpp b/src/dawn/tests/unittests/wire/WireArgumentTests.cpp index bc8054c75f..6cea00b089 100644 --- a/src/dawn/tests/unittests/wire/WireArgumentTests.cpp +++ b/src/dawn/tests/unittests/wire/WireArgumentTests.cpp @@ -19,6 +19,7 @@ #include "dawn/tests/unittests/wire/WireTest.h" namespace dawn::wire { +namespace { using testing::_; using testing::Return; @@ -369,4 +370,5 @@ TEST_F(WireArgumentTests, DISABLED_NullptrInArray) { FlushClient(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireBasicTests.cpp b/src/dawn/tests/unittests/wire/WireBasicTests.cpp index 34a9c7ff2b..ebbd0c770c 100644 --- a/src/dawn/tests/unittests/wire/WireBasicTests.cpp +++ b/src/dawn/tests/unittests/wire/WireBasicTests.cpp @@ -15,6 +15,7 @@ #include "dawn/tests/unittests/wire/WireTest.h" namespace dawn::wire { +namespace { using testing::Return; @@ -79,4 +80,5 @@ TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) { FlushClient(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireBufferMappingTests.cpp b/src/dawn/tests/unittests/wire/WireBufferMappingTests.cpp index ea396bba39..ba848c25d1 100644 --- a/src/dawn/tests/unittests/wire/WireBufferMappingTests.cpp +++ b/src/dawn/tests/unittests/wire/WireBufferMappingTests.cpp @@ -20,6 +20,7 @@ #include "dawn/wire/WireClient.h" namespace dawn::wire { +namespace { using testing::_; using testing::InvokeWithoutArgs; @@ -27,8 +28,6 @@ using testing::Mock; using testing::Return; using testing::StrictMock; -namespace { - // Mock class to add expectations on the wire calling callbacks class MockBufferMapCallback { public: @@ -40,8 +39,6 @@ void ToMockBufferMapCallback(WGPUBufferMapAsyncStatus status, void* userdata) { mockBufferMapCallback->Call(status, userdata); } -} // anonymous namespace - class WireBufferMappingTests : public WireTest { public: WireBufferMappingTests() {} @@ -937,4 +934,5 @@ TEST_F(WireBufferMappingWriteTests, MapInsideCallbackBeforeDestruction) { wgpuBufferRelease(buffer); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireCreatePipelineAsyncTests.cpp b/src/dawn/tests/unittests/wire/WireCreatePipelineAsyncTests.cpp index 7486e030db..2cc9dca803 100644 --- a/src/dawn/tests/unittests/wire/WireCreatePipelineAsyncTests.cpp +++ b/src/dawn/tests/unittests/wire/WireCreatePipelineAsyncTests.cpp @@ -67,8 +67,6 @@ void ToMockCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus statu mockCreateRenderPipelineAsyncCallback->Call(status, pipeline, message, userdata); } -} // anonymous namespace - class WireCreatePipelineAsyncTest : public WireTest { public: void SetUp() override { @@ -376,4 +374,5 @@ TEST_F(WireCreatePipelineAsyncTest, DeviceDeletedBeforeCallback) { DefaultApiDeviceWasReleased(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp b/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp index 333a63705f..cba6890f54 100644 --- a/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp +++ b/src/dawn/tests/unittests/wire/WireDeviceLifetimeTests.cpp @@ -20,6 +20,9 @@ #include "dawn/webgpu.h" #include "gtest/gtest.h" +namespace dawn { +namespace { + static WGPUDevice lastBackendDevice = nullptr; class WireDeviceLifetimeTests : public testing::Test { @@ -28,7 +31,7 @@ class WireDeviceLifetimeTests : public testing::Test { : nativeProcs(BuildProcs()), wireHelper(utils::CreateWireHelper(nativeProcs, /* useWire */ true)) { WGPUInstanceDescriptor instanceDesc = {}; - nativeInstance = std::make_unique(&instanceDesc); + nativeInstance = std::make_unique(&instanceDesc); instance = wireHelper->RegisterInstance(nativeInstance->Get()); } @@ -50,7 +53,7 @@ class WireDeviceLifetimeTests : public testing::Test { const DawnProcTable nativeProcs; std::unique_ptr wireHelper; - std::unique_ptr nativeInstance; + std::unique_ptr nativeInstance; wgpu::Instance instance; wgpu::Adapter adapter; @@ -59,11 +62,11 @@ class WireDeviceLifetimeTests : public testing::Test { // static variable `lastBackendDevice`. This lets tests control the wire device and the native // backend device separately. DawnProcTable BuildProcs() { - DawnProcTable nativeProcs = dawn::native::GetProcs(); + DawnProcTable nativeProcs = native::GetProcs(); nativeProcs.adapterRequestDevice = [](WGPUAdapter adapter, const WGPUDeviceDescriptor* desc, WGPURequestDeviceCallback callback, void* userdata) { using WrappedUserdata = std::pair; - dawn::native::GetProcs().adapterRequestDevice( + native::GetProcs().adapterRequestDevice( adapter, desc, [](WGPURequestDeviceStatus status, WGPUDevice device, char const* message, void* userdata) { @@ -213,3 +216,6 @@ TEST_F(WireDeviceLifetimeTests, DeviceDroppedFromWireThenLostCallback) { // callbacks. nativeProcs.deviceRelease(oldDevice); } + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp b/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp index ec244e0d5e..62b4cb7376 100644 --- a/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp +++ b/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp @@ -19,6 +19,7 @@ #include "dawn/wire/WireClient.h" namespace dawn::wire { +namespace { using testing::_; using testing::Exactly; @@ -28,12 +29,8 @@ using testing::Return; using testing::Sequence; using testing::StrEq; -namespace { - class WireDisconnectTests : public WireTest {}; -} // anonymous namespace - // Test that commands are not received if the client disconnects. TEST_F(WireDisconnectTests, CommandsAfterDisconnect) { // Check that commands work at all. @@ -183,4 +180,5 @@ TEST_F(WireDisconnectTests, DeleteClientDestroysObjects) { DefaultApiDeviceWasReleased(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp b/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp index f08e118338..dc73918c74 100644 --- a/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp +++ b/src/dawn/tests/unittests/wire/WireErrorCallbackTests.cpp @@ -18,6 +18,7 @@ #include "dawn/wire/WireClient.h" namespace dawn::wire { +namespace { using testing::_; using testing::DoAll; @@ -27,8 +28,6 @@ using testing::SaveArg; using testing::StrEq; using testing::StrictMock; -namespace { - // Mock classes to add expectations on the wire calling callbacks class MockDeviceErrorCallback { public: @@ -70,8 +69,6 @@ void ToMockDeviceLostCallback(WGPUDeviceLostReason reason, const char* message, mockDeviceLostCallback->Call(reason, message, userdata); } -} // anonymous namespace - class WireErrorCallbackTests : public WireTest { public: WireErrorCallbackTests() {} @@ -386,4 +383,5 @@ TEST_F(WireErrorCallbackTests, DeviceLostCallback) { FlushServer(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireExtensionTests.cpp b/src/dawn/tests/unittests/wire/WireExtensionTests.cpp index b36e2447e4..e10e41bc17 100644 --- a/src/dawn/tests/unittests/wire/WireExtensionTests.cpp +++ b/src/dawn/tests/unittests/wire/WireExtensionTests.cpp @@ -15,6 +15,7 @@ #include "dawn/tests/unittests/wire/WireTest.h" namespace dawn::wire { +namespace { using testing::_; using testing::Invoke; @@ -244,4 +245,5 @@ TEST_F(WireExtensionTests, ValidAndInvalidSTypeInChain) { FlushClient(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireInjectDeviceTests.cpp b/src/dawn/tests/unittests/wire/WireInjectDeviceTests.cpp index f2a50da4f1..cf84c2ed4d 100644 --- a/src/dawn/tests/unittests/wire/WireInjectDeviceTests.cpp +++ b/src/dawn/tests/unittests/wire/WireInjectDeviceTests.cpp @@ -18,6 +18,7 @@ #include "dawn/wire/WireServer.h" namespace dawn::wire { +namespace { using testing::_; using testing::Exactly; @@ -274,4 +275,5 @@ TEST_F(WireInjectDeviceTests, ReclaimDeviceReservation) { } } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp b/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp index 3f18faceb0..04dbd96721 100644 --- a/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp +++ b/src/dawn/tests/unittests/wire/WireInjectInstanceTests.cpp @@ -117,5 +117,5 @@ TEST_F(WireInjectInstanceTests, ReclaimInstanceReservation) { } } -} // namespace +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireInjectSwapChainTests.cpp b/src/dawn/tests/unittests/wire/WireInjectSwapChainTests.cpp index f06d53e06f..e7f0f83284 100644 --- a/src/dawn/tests/unittests/wire/WireInjectSwapChainTests.cpp +++ b/src/dawn/tests/unittests/wire/WireInjectSwapChainTests.cpp @@ -18,6 +18,7 @@ #include "dawn/wire/WireServer.h" namespace dawn::wire { +namespace { using testing::Mock; @@ -115,4 +116,5 @@ TEST_F(WireInjectSwapChainTests, ReclaimSwapChainReservation) { } } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireInjectTextureTests.cpp b/src/dawn/tests/unittests/wire/WireInjectTextureTests.cpp index 005522f738..35f8dde18b 100644 --- a/src/dawn/tests/unittests/wire/WireInjectTextureTests.cpp +++ b/src/dawn/tests/unittests/wire/WireInjectTextureTests.cpp @@ -18,6 +18,7 @@ #include "dawn/wire/WireServer.h" namespace dawn::wire { +namespace { using testing::Mock; using testing::Return; @@ -181,4 +182,5 @@ TEST_F(WireInjectTextureTests, ReservedTextureReflection) { ASSERT_EQ(desc.sampleCount, wgpuTextureGetSampleCount(texture)); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireInstanceTests.cpp b/src/dawn/tests/unittests/wire/WireInstanceTests.cpp index 029348b997..8cb35f4ef3 100644 --- a/src/dawn/tests/unittests/wire/WireInstanceTests.cpp +++ b/src/dawn/tests/unittests/wire/WireInstanceTests.cpp @@ -296,5 +296,5 @@ TEST_F(WireInstanceTests, RequestAdapterWireDisconnectBeforeCallback) { GetWireClient()->Disconnect(); } -} // namespace +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireMemoryTransferServiceTests.cpp b/src/dawn/tests/unittests/wire/WireMemoryTransferServiceTests.cpp index ca347b92e3..7ab43a4b05 100644 --- a/src/dawn/tests/unittests/wire/WireMemoryTransferServiceTests.cpp +++ b/src/dawn/tests/unittests/wire/WireMemoryTransferServiceTests.cpp @@ -20,6 +20,7 @@ #include "dawn/wire/server/ServerMemoryTransferService_mock.h" namespace dawn::wire { +namespace { using testing::_; using testing::Eq; @@ -30,8 +31,6 @@ using testing::Return; using testing::StrictMock; using testing::WithArg; -namespace { - // Mock class to add expectations on the wire calling callbacks class MockBufferMapCallback { public: @@ -43,8 +42,6 @@ void ToMockBufferMapCallback(WGPUBufferMapAsyncStatus status, void* userdata) { mockBufferMapCallback->Call(status, userdata); } -} // anonymous namespace - // WireMemoryTransferServiceTests test the MemoryTransferService with buffer mapping. // They test the basic success and error cases for buffer mapping, and they test // mocked failures of each fallible MemoryTransferService method that an embedder @@ -320,8 +317,8 @@ class WireMemoryTransferServiceTests : public WireTest { // mUpdatedBufferContent| after all writes are flushed. static uint32_t mUpdatedBufferContent; - StrictMock serverMemoryTransferService; - StrictMock clientMemoryTransferService; + StrictMock serverMemoryTransferService; + StrictMock clientMemoryTransferService; }; uint32_t WireMemoryTransferServiceTests::mBufferContent = 1337; @@ -1065,4 +1062,5 @@ TEST_F(WireMemoryTransferServiceTests, MappedAtCreationAndMapWriteSuccess) { EXPECT_CALL(serverMemoryTransferService, OnWriteHandleDestroy(serverHandle)).Times(1); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireOptionalTests.cpp b/src/dawn/tests/unittests/wire/WireOptionalTests.cpp index 2061021d7c..e76bd95648 100644 --- a/src/dawn/tests/unittests/wire/WireOptionalTests.cpp +++ b/src/dawn/tests/unittests/wire/WireOptionalTests.cpp @@ -15,6 +15,7 @@ #include "dawn/tests/unittests/wire/WireTest.h" namespace dawn::wire { +namespace { using testing::_; using testing::Return; @@ -179,4 +180,5 @@ TEST_F(WireOptionalTests, OptionalStructPointer) { FlushClient(); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireQueueTests.cpp b/src/dawn/tests/unittests/wire/WireQueueTests.cpp index 278a1716e1..cb031409f5 100644 --- a/src/dawn/tests/unittests/wire/WireQueueTests.cpp +++ b/src/dawn/tests/unittests/wire/WireQueueTests.cpp @@ -18,6 +18,7 @@ #include "dawn/wire/WireClient.h" namespace dawn::wire { +namespace { using testing::_; using testing::InvokeWithoutArgs; @@ -197,4 +198,5 @@ TEST_F(WireQueueTests, DeviceThenDefaultQueueReleased) { // since it is always destructed after the test TearDown, and we cannot create a new queue obj // with wgpuDeviceGetQueue +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireShaderModuleTests.cpp b/src/dawn/tests/unittests/wire/WireShaderModuleTests.cpp index 479b080571..26451d8138 100644 --- a/src/dawn/tests/unittests/wire/WireShaderModuleTests.cpp +++ b/src/dawn/tests/unittests/wire/WireShaderModuleTests.cpp @@ -18,6 +18,7 @@ #include "dawn/wire/WireClient.h" namespace dawn::wire { +namespace { using testing::_; using testing::InvokeWithoutArgs; @@ -25,8 +26,6 @@ using testing::Mock; using testing::Return; using testing::StrictMock; -namespace { - // Mock class to add expectations on the wire calling callbacks class MockCompilationInfoCallback { public: @@ -44,8 +43,6 @@ void ToMockGetCompilationInfoCallback(WGPUCompilationInfoRequestStatus status, mockCompilationInfoCallback->Call(status, info, userdata); } -} // anonymous namespace - class WireShaderModuleTests : public WireTest { public: WireShaderModuleTests() {} @@ -239,4 +236,5 @@ TEST_F(WireShaderModuleTests, GetCompilationInfoInsideCallbackBeforeDestruction) wgpuShaderModuleRelease(shaderModule); } +} // anonymous namespace } // namespace dawn::wire diff --git a/src/dawn/tests/unittests/wire/WireTest.cpp b/src/dawn/tests/unittests/wire/WireTest.cpp index 5f4fbeac35..4a0fd26d3c 100644 --- a/src/dawn/tests/unittests/wire/WireTest.cpp +++ b/src/dawn/tests/unittests/wire/WireTest.cpp @@ -48,8 +48,8 @@ void WireTest::SetUp() { EXPECT_CALL(api, OnDeviceSetDeviceLostCallback(_, _, _)).Times(Exactly(1)); SetupIgnoredCallExpectations(); - mS2cBuf = std::make_unique(); - mC2sBuf = std::make_unique(mWireServer.get()); + mS2cBuf = std::make_unique(); + mC2sBuf = std::make_unique(mWireServer.get()); dawn::wire::WireServerDescriptor serverDesc = {}; serverDesc.procs = &mockProcs; diff --git a/src/dawn/tests/unittests/wire/WireTest.h b/src/dawn/tests/unittests/wire/WireTest.h index 0cbd156d2d..340a2fe189 100644 --- a/src/dawn/tests/unittests/wire/WireTest.h +++ b/src/dawn/tests/unittests/wire/WireTest.h @@ -103,7 +103,7 @@ class MemoryTransferService; } // namespace server } // namespace dawn::wire -namespace utils { +namespace dawn::utils { class TerribleCommandBuffer; } @@ -140,8 +140,8 @@ class WireTest : public testing::Test { std::unique_ptr mWireServer; std::unique_ptr mWireClient; - std::unique_ptr mS2cBuf; - std::unique_ptr mC2sBuf; + std::unique_ptr mS2cBuf; + std::unique_ptr mC2sBuf; }; #endif // SRC_DAWN_TESTS_UNITTESTS_WIRE_WIRETEST_H_ diff --git a/src/dawn/tests/white_box/BufferAllocatedSizeTests.cpp b/src/dawn/tests/white_box/BufferAllocatedSizeTests.cpp index cfa90260ab..0506b90c62 100644 --- a/src/dawn/tests/white_box/BufferAllocatedSizeTests.cpp +++ b/src/dawn/tests/white_box/BufferAllocatedSizeTests.cpp @@ -19,6 +19,9 @@ #include "dawn/common/Math.h" #include "dawn/native/DawnNative.h" +namespace dawn { +namespace { + class BufferAllocatedSizeTests : public DawnTest { protected: wgpu::Buffer CreateBuffer(wgpu::BufferUsage usage, uint64_t size) { @@ -53,7 +56,7 @@ TEST_P(BufferAllocatedSizeTests, UniformUsage) { { const uint32_t bufferSize = kMinBufferSize; wgpu::Buffer buffer = CreateBuffer(wgpu::BufferUsage::Uniform, bufferSize); - EXPECT_EQ(dawn::native::GetAllocatedSizeForTesting(buffer.Get()), + EXPECT_EQ(native::GetAllocatedSizeForTesting(buffer.Get()), Align(bufferSize, requiredBufferAlignment)); } @@ -63,7 +66,7 @@ TEST_P(BufferAllocatedSizeTests, UniformUsage) { const uint32_t bufferSize = std::max(1u + requiredBufferAlignment, kMinBufferSize); wgpu::Buffer buffer = CreateBuffer(wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage, bufferSize); - EXPECT_EQ(dawn::native::GetAllocatedSizeForTesting(buffer.Get()), + EXPECT_EQ(native::GetAllocatedSizeForTesting(buffer.Get()), Align(bufferSize, requiredBufferAlignment)); } @@ -72,7 +75,7 @@ TEST_P(BufferAllocatedSizeTests, UniformUsage) { const uint32_t bufferSize = kMinBufferSize; wgpu::Buffer buffer = CreateBuffer(wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage, bufferSize); - EXPECT_EQ(dawn::native::GetAllocatedSizeForTesting(buffer.Get()), + EXPECT_EQ(native::GetAllocatedSizeForTesting(buffer.Get()), Align(bufferSize, requiredBufferAlignment)); } } @@ -83,3 +86,6 @@ DAWN_INSTANTIATE_TEST(BufferAllocatedSizeTests, OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/D3D11BufferTests.cpp b/src/dawn/tests/white_box/D3D11BufferTests.cpp index 4ece2ef9d4..0b53876443 100644 --- a/src/dawn/tests/white_box/D3D11BufferTests.cpp +++ b/src/dawn/tests/white_box/D3D11BufferTests.cpp @@ -21,6 +21,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class D3D11BufferTests : public DawnTest { protected: void SetUp() override { @@ -38,8 +41,7 @@ class D3D11BufferTests : public DawnTest { } ID3D11Device* GetD3D11Device() { - return dawn::native::d3d11::ToBackend(dawn::native::FromAPI((device.Get()))) - ->GetD3D11Device(); + return native::d3d11::ToBackend(native::FromAPI((device.Get())))->GetD3D11Device(); } template @@ -94,8 +96,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_EQ(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -104,8 +106,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::CopySrc; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_EQ(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -113,8 +115,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Vertex; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -122,8 +124,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Index; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -131,8 +133,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Indirect; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -140,8 +142,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -149,8 +151,8 @@ TEST_P(D3D11BufferTests, CreateUniformBuffer) { { wgpu::BufferUsage usage = wgpu::BufferUsage::Storage; wgpu::Buffer buffer = CreateBuffer(4, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_EQ(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -164,8 +166,8 @@ TEST_P(D3D11BufferTests, WriteUniformBuffer) { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::CopySrc; wgpu::Buffer buffer = CreateBuffer(data.size(), usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_EQ(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -180,8 +182,8 @@ TEST_P(D3D11BufferTests, WriteUniformBuffer) { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Vertex | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::CopySrc; wgpu::Buffer buffer = CreateBuffer(data.size(), usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = + native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -203,8 +205,7 @@ TEST_P(D3D11BufferTests, WriteUniformBufferWithComputeShader) { wgpu::BufferUsage usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::CopySrc; wgpu::Buffer buffer = CreateBuffer(bufferSize, usage); - dawn::native::d3d11::Buffer* d3d11Buffer = - dawn::native::d3d11::ToBackend(dawn::native::FromAPI(buffer.Get())); + native::d3d11::Buffer* d3d11Buffer = native::d3d11::ToBackend(native::FromAPI(buffer.Get())); EXPECT_NE(d3d11Buffer->GetD3D11NonConstantBuffer(), nullptr); EXPECT_NE(d3d11Buffer->GetD3D11ConstantBuffer(), nullptr); @@ -310,3 +311,6 @@ TEST_P(D3D11BufferTests, WriteUniformBufferWithComputeShader) { } DAWN_INSTANTIATE_TEST(D3D11BufferTests, D3D11Backend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp index 75e9d10fc5..f5dcf95cce 100644 --- a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -27,6 +27,7 @@ #include "dawn/utils/WGPUHelpers.h" namespace dawn::native::d3d12 { +namespace { constexpr uint32_t kRTSize = 4; @@ -110,7 +111,7 @@ class PlaceholderStagingDescriptorAllocator { D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) {} CPUDescriptorHeapAllocation AllocateCPUDescriptors() { - dawn::native::ResultOrError result = + native::ResultOrError result = mAllocator.AllocateCPUDescriptors(); return (result.IsSuccess()) ? result.AcquireSuccess() : CPUDescriptorHeapAllocation{}; } @@ -123,8 +124,8 @@ class PlaceholderStagingDescriptorAllocator { // Verify the shader visible view heaps switch over within a single submit. TEST_P(D3D12DescriptorHeapTests, SwitchOverViewHeap) { - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; @@ -223,8 +224,8 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) { // Verify shader-visible heaps can be recycled for multiple submits. TEST_P(D3D12DescriptorHeapTests, PoolHeapsInMultipleSubmits) { // Use small heaps to count only pool-allocated switches. - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); ShaderVisibleDescriptorAllocator* allocator = mD3DDevice->GetSamplerShaderVisibleDescriptorAllocator(); @@ -265,8 +266,8 @@ TEST_P(D3D12DescriptorHeapTests, PoolHeapsInMultipleSubmits) { // Verify shader-visible heaps do not recycle in a pending submit. TEST_P(D3D12DescriptorHeapTests, PoolHeapsInPendingSubmit) { // Use small heaps to count only pool-allocated switches. - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); constexpr uint32_t kNumOfSwitches = 5; @@ -297,8 +298,8 @@ TEST_P(D3D12DescriptorHeapTests, PoolHeapsInPendingSubmit) { // once no longer pending. TEST_P(D3D12DescriptorHeapTests, PoolHeapsInPendingAndMultipleSubmits) { // Use small heaps to count only pool-allocated switches. - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); constexpr uint32_t kNumOfSwitches = 5; @@ -432,8 +433,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) { // draws, the result is the arithmetic sum of the sequence after the framebuffer is blended // by accumulation. By checking for this sum, we ensure each bindgroup was encoded // correctly. - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); utils::BasicRenderPass renderPass = MakeRenderPass(kRTSize, kRTSize, wgpu::TextureFormat::R16Float); @@ -506,8 +507,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) { // The first descriptor's memory will be reused when the second submit encodes |heapSize| // descriptors. TEST_P(D3D12DescriptorHeapTests, EncodeUBOOverflowMultipleSubmit) { - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); // TODO(crbug.com/dawn/742): Test output is wrong with D3D12 + WARP. DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsWARP()); @@ -594,8 +595,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeUBOOverflowMultipleSubmit) { // Shader-visible heaps should switch out once then re-encode the first descriptor at a new // offset in the heap. TEST_P(D3D12DescriptorHeapTests, EncodeReuseUBOOverflow) { - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); @@ -655,8 +656,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeReuseUBOOverflow) { // Shader-visible heaps should switch out once then re-encode the // first descriptor at the same offset in the heap. TEST_P(D3D12DescriptorHeapTests, EncodeReuseUBOMultipleSubmits) { - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); @@ -735,8 +736,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeReuseUBOMultipleSubmits) { // Verify encoding many sampler and ubo worth of bindgroups. // Shader-visible heaps should switch out |kNumOfViewHeaps| times. TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) { - DAWN_TEST_UNSUPPORTED_IF(!mD3DDevice->IsToggleEnabled( - dawn::native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); + DAWN_TEST_UNSUPPORTED_IF( + !mD3DDevice->IsToggleEnabled(native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); // Create a solid filled texture. wgpu::TextureDescriptor descriptor; @@ -1067,4 +1068,5 @@ DAWN_INSTANTIATE_TEST(D3D12DescriptorHeapTests, D3D12Backend(), D3D12Backend({"use_d3d12_small_shader_visible_heap"})); +} // anonymous namespace } // namespace dawn::native::d3d12 diff --git a/src/dawn/tests/white_box/D3D12ResidencyTests.cpp b/src/dawn/tests/white_box/D3D12ResidencyTests.cpp index 5f281ee38b..db4e0de67d 100644 --- a/src/dawn/tests/white_box/D3D12ResidencyTests.cpp +++ b/src/dawn/tests/white_box/D3D12ResidencyTests.cpp @@ -23,6 +23,9 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + constexpr uint32_t kRestrictedBudgetSize = 100000000; // 100MB constexpr uint32_t kDirectlyAllocatedResourceSize = 5000000; // 5MB constexpr uint32_t kSuballocatedResourceSize = 1000000; // 1MB @@ -41,8 +44,8 @@ class D3D12ResidencyTestBase : public DawnTest { DAWN_TEST_UNSUPPORTED_IF(UsesWire()); // Restrict Dawn's budget to create an artificial budget. - dawn::native::d3d12::Device* d3dDevice = - dawn::native::d3d12::ToBackend(dawn::native::FromAPI((device.Get()))); + native::d3d12::Device* d3dDevice = + native::d3d12::ToBackend(native::FromAPI((device.Get()))); d3dDevice->GetResidencyManager()->RestrictBudgetForTesting(kRestrictedBudgetSize); // Initialize a source buffer on the GPU to serve as a source to quickly copy data to other @@ -92,22 +95,20 @@ class D3D12ResidencyTestBase : public DawnTest { class D3D12ResourceResidencyTests : public D3D12ResidencyTestBase { protected: bool CheckAllocationMethod(wgpu::Buffer buffer, - dawn::native::AllocationMethod allocationMethod) const { - dawn::native::d3d12::Buffer* d3dBuffer = - dawn::native::d3d12::ToBackend(dawn::native::FromAPI((buffer.Get()))); + native::AllocationMethod allocationMethod) const { + native::d3d12::Buffer* d3dBuffer = + native::d3d12::ToBackend(native::FromAPI((buffer.Get()))); return d3dBuffer->CheckAllocationMethodForTesting(allocationMethod); } bool CheckIfBufferIsResident(wgpu::Buffer buffer) const { - dawn::native::d3d12::Buffer* d3dBuffer = - dawn::native::d3d12::ToBackend(dawn::native::FromAPI((buffer.Get()))); + native::d3d12::Buffer* d3dBuffer = + native::d3d12::ToBackend(native::FromAPI((buffer.Get()))); return d3dBuffer->CheckIsResidentForTesting(); } bool IsUMA() const { - return dawn::native::d3d12::ToBackend(dawn::native::FromAPI(device.Get())) - ->GetDeviceInfo() - .isUMA; + return native::d3d12::ToBackend(native::FromAPI(device.Get()))->GetDeviceInfo().isUMA; } }; @@ -124,8 +125,7 @@ TEST_P(D3D12ResourceResidencyTests, OvercommitSmallResources) { // internally. for (uint32_t i = 0; i < bufferSet1.size(); i++) { EXPECT_TRUE(CheckIfBufferIsResident(bufferSet1[i])); - EXPECT_TRUE( - CheckAllocationMethod(bufferSet1[i], dawn::native::AllocationMethod::kSubAllocated)); + EXPECT_TRUE(CheckAllocationMethod(bufferSet1[i], native::AllocationMethod::kSubAllocated)); } // Create enough directly-allocated buffers to use the entire budget. @@ -163,7 +163,7 @@ TEST_P(D3D12ResourceResidencyTests, OvercommitLargeResources) { // allocated internally. for (uint32_t i = 0; i < bufferSet1.size(); i++) { EXPECT_TRUE(CheckIfBufferIsResident(bufferSet1[i])); - EXPECT_TRUE(CheckAllocationMethod(bufferSet1[i], dawn::native::AllocationMethod::kDirect)); + EXPECT_TRUE(CheckAllocationMethod(bufferSet1[i], native::AllocationMethod::kDirect)); } // Create enough directly-allocated buffers to use the entire budget. @@ -320,14 +320,14 @@ TEST_P(D3D12ResourceResidencyTests, OvercommitInASingleSubmit) { TEST_P(D3D12ResourceResidencyTests, SetExternalReservation) { // Set an external reservation of 20% the budget. We should succesfully reserve the amount we // request. - uint64_t amountReserved = dawn::native::d3d12::SetExternalMemoryReservation( - device.Get(), kRestrictedBudgetSize * .2, dawn::native::d3d12::MemorySegment::Local); + uint64_t amountReserved = native::d3d12::SetExternalMemoryReservation( + device.Get(), kRestrictedBudgetSize * .2, native::d3d12::MemorySegment::Local); EXPECT_EQ(amountReserved, kRestrictedBudgetSize * .2); // If we're on a non-UMA device, we should also check the NON_LOCAL memory segment. if (!IsUMA()) { - amountReserved = dawn::native::d3d12::SetExternalMemoryReservation( - device.Get(), kRestrictedBudgetSize * .2, dawn::native::d3d12::MemorySegment::NonLocal); + amountReserved = native::d3d12::SetExternalMemoryReservation( + device.Get(), kRestrictedBudgetSize * .2, native::d3d12::MemorySegment::NonLocal); EXPECT_EQ(amountReserved, kRestrictedBudgetSize * .2); } } @@ -371,14 +371,13 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { wgpu::Sampler sampler = device.CreateSampler(); - dawn::native::d3d12::Device* d3dDevice = - dawn::native::d3d12::ToBackend(dawn::native::FromAPI(device.Get())); + native::d3d12::Device* d3dDevice = native::d3d12::ToBackend(native::FromAPI(device.Get())); - dawn::native::d3d12::ShaderVisibleDescriptorAllocator* allocator = + native::d3d12::ShaderVisibleDescriptorAllocator* allocator = d3dDevice->GetViewShaderVisibleDescriptorAllocator(); const uint64_t heapSize = allocator->GetShaderVisibleHeapSizeForTesting(); - const dawn::native::d3d12::HeapVersionID heapSerial = + const native::d3d12::HeapVersionID heapSerial = allocator->GetShaderVisibleHeapSerialForTesting(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); @@ -405,7 +404,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { // Check the heap serial to ensure the heap has switched. EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), - heapSerial + dawn::native::d3d12::HeapVersionID(1)); + heapSerial + native::d3d12::HeapVersionID(1)); // Check that currrently bound ShaderVisibleHeap is locked resident. EXPECT_TRUE(allocator->IsShaderVisibleHeapLockedResidentForTesting()); @@ -426,3 +425,6 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { DAWN_INSTANTIATE_TEST(D3D12ResourceResidencyTests, D3D12Backend()); DAWN_INSTANTIATE_TEST(D3D12DescriptorResidencyTests, D3D12Backend({"use_d3d12_small_shader_visible_heap"})); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp b/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp index d1a3ff04c8..d90eb1dfad 100644 --- a/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp +++ b/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp @@ -19,6 +19,7 @@ #include "dawn/tests/DawnTest.h" namespace dawn::native::d3d12 { +namespace { class D3D12ResourceHeapTests : public DawnTest { protected: @@ -105,4 +106,5 @@ TEST_P(D3D12ResourceHeapTests, AlignUBO) { DAWN_INSTANTIATE_TEST(D3D12ResourceHeapTests, D3D12Backend()); +} // anonymous namespace } // namespace dawn::native::d3d12 diff --git a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp index 3b2b97e061..04f6a6875f 100644 --- a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp +++ b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp @@ -24,6 +24,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { class EGLFunctions { @@ -110,8 +111,6 @@ class ScopedEGLImage { GLuint mTexture = 0; }; -} // anonymous namespace - class EGLImageTestBase : public DawnTest { protected: std::vector GetRequiredFeatures() override { @@ -126,9 +125,9 @@ class EGLImageTestBase : public DawnTest { GLenum type, void* data, size_t size) { - dawn::native::opengl::Device* openglDevice = - dawn::native::opengl::ToBackend(dawn::native::FromAPI(device.Get())); - const dawn::native::opengl::OpenGLFunctions& gl = openglDevice->GetGL(); + native::opengl::Device* openglDevice = + native::opengl::ToBackend(native::FromAPI(device.Get())); + const native::opengl::OpenGLFunctions& gl = openglDevice->GetGL(); GLuint tex; gl.GenTextures(1, &tex); gl.BindTexture(GL_TEXTURE_2D, tex); @@ -143,10 +142,10 @@ class EGLImageTestBase : public DawnTest { return ScopedEGLImage(egl.DestroyImage, gl.DeleteTextures, dpy, eglImage, tex); } wgpu::Texture WrapEGLImage(const wgpu::TextureDescriptor* descriptor, EGLImage eglImage) { - dawn::native::opengl::ExternalImageDescriptorEGLImage externDesc; + native::opengl::ExternalImageDescriptorEGLImage externDesc; externDesc.cTextureDescriptor = reinterpret_cast(descriptor); externDesc.image = eglImage; - WGPUTexture texture = dawn::native::opengl::WrapExternalEGLImage(device.Get(), &externDesc); + WGPUTexture texture = native::opengl::WrapExternalEGLImage(device.Get(), &externDesc); return wgpu::Texture::Acquire(texture); } EGLFunctions egl; @@ -298,9 +297,9 @@ class EGLImageUsageTests : public EGLImageTestBase { GLenum glType, void* data, size_t dataSize) { - dawn::native::opengl::Device* openglDevice = - dawn::native::opengl::ToBackend(dawn::native::FromAPI(device.Get())); - const dawn::native::opengl::OpenGLFunctions& gl = openglDevice->GetGL(); + native::opengl::Device* openglDevice = + native::opengl::ToBackend(native::FromAPI(device.Get())); + const native::opengl::OpenGLFunctions& gl = openglDevice->GetGL(); // Get a texture view for the eglImage wgpu::TextureDescriptor textureDescriptor; @@ -379,3 +378,6 @@ TEST_P(EGLImageUsageTests, ClearRGBA8EGLImage) { DAWN_INSTANTIATE_TEST(EGLImageValidationTests, OpenGLESBackend()); DAWN_INSTANTIATE_TEST(EGLImageUsageTests, OpenGLESBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp b/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp index 93e659ed2b..7759e192ad 100644 --- a/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp +++ b/src/dawn/tests/white_box/GPUTimestampCalibrationTests.cpp @@ -21,6 +21,7 @@ #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { using FeatureName = wgpu::FeatureName; @@ -82,8 +83,6 @@ class ExpectBetweenTimestamps : public ::detail::Expectation { float mErrorToleranceRatio; }; -} // anonymous namespace - class GPUTimestampCalibrationTests : public DawnTestWithParams { protected: void SetUp() override { @@ -305,3 +304,6 @@ DAWN_INSTANTIATE_TEST_P( MetalBackend({}, {"disable_timestamp_query_conversion"})}, {wgpu::FeatureName::TimestampQuery, wgpu::FeatureName::TimestampQueryInsidePasses}, {EncoderType::NonPass, EncoderType::ComputePass, EncoderType::RenderPass}); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/GPUTimestampCalibrationTests.h b/src/dawn/tests/white_box/GPUTimestampCalibrationTests.h index 8920b4d31e..2cc29fa109 100644 --- a/src/dawn/tests/white_box/GPUTimestampCalibrationTests.h +++ b/src/dawn/tests/white_box/GPUTimestampCalibrationTests.h @@ -17,6 +17,8 @@ #include +namespace dawn { + class GPUTimestampCalibrationTestBackend { public: static std::unique_ptr Create(const wgpu::Device& device); @@ -27,4 +29,6 @@ class GPUTimestampCalibrationTestBackend { virtual float GetTimestampPeriod() const = 0; }; +} // namespace dawn + #endif // SRC_DAWN_TESTS_WHITE_BOX_GPUTIMESTAMPCALIBRATIONTESTS_H_ diff --git a/src/dawn/tests/white_box/GPUTimestampCalibrationTests_D3D12.cpp b/src/dawn/tests/white_box/GPUTimestampCalibrationTests_D3D12.cpp index ba2f238d97..de1143bda8 100644 --- a/src/dawn/tests/white_box/GPUTimestampCalibrationTests_D3D12.cpp +++ b/src/dawn/tests/white_box/GPUTimestampCalibrationTests_D3D12.cpp @@ -17,10 +17,13 @@ #include "dawn/native/d3d12/DeviceD3D12.h" #include "dawn/tests/white_box/GPUTimestampCalibrationTests.h" +namespace dawn { +namespace { + class GPUTimestampCalibrationTestsD3D12 : public GPUTimestampCalibrationTestBackend { public: explicit GPUTimestampCalibrationTestsD3D12(const wgpu::Device& device) { - mBackendDevice = dawn::native::d3d12::ToBackend(dawn::native::FromAPI(device.Get())); + mBackendDevice = native::d3d12::ToBackend(native::FromAPI(device.Get())); } bool IsSupported() const override { return true; } @@ -32,11 +35,15 @@ class GPUTimestampCalibrationTestsD3D12 : public GPUTimestampCalibrationTestBack float GetTimestampPeriod() const override { return mBackendDevice->GetTimestampPeriodInNS(); } private: - dawn::native::d3d12::Device* mBackendDevice; + native::d3d12::Device* mBackendDevice; }; +} // anonymous namespace + // static std::unique_ptr GPUTimestampCalibrationTestBackend::Create( const wgpu::Device& device) { return std::make_unique(device); } + +} // namespace dawn diff --git a/src/dawn/tests/white_box/GPUTimestampCalibrationTests_Metal.mm b/src/dawn/tests/white_box/GPUTimestampCalibrationTests_Metal.mm index 73b3df07db..cf0db9d6b4 100644 --- a/src/dawn/tests/white_box/GPUTimestampCalibrationTests_Metal.mm +++ b/src/dawn/tests/white_box/GPUTimestampCalibrationTests_Metal.mm @@ -17,6 +17,9 @@ #include "dawn/native/metal/DeviceMTL.h" #include "dawn/tests/white_box/GPUTimestampCalibrationTests.h" +namespace dawn { +namespace { + class GPUTimestampCalibrationTestsMetal : public GPUTimestampCalibrationTestBackend { public: explicit GPUTimestampCalibrationTestsMetal(const wgpu::Device& device) { @@ -44,8 +47,12 @@ class GPUTimestampCalibrationTestsMetal : public GPUTimestampCalibrationTestBack dawn::native::metal::Device* mBackendDevice; }; +} // anonymous namespace + // static std::unique_ptr GPUTimestampCalibrationTestBackend::Create( const wgpu::Device& device) { return std::make_unique(device); } + +} // namespace dawn diff --git a/src/dawn/tests/white_box/InternalResourceUsageTests.cpp b/src/dawn/tests/white_box/InternalResourceUsageTests.cpp index 5e46b504e9..a2c17cec49 100644 --- a/src/dawn/tests/white_box/InternalResourceUsageTests.cpp +++ b/src/dawn/tests/white_box/InternalResourceUsageTests.cpp @@ -16,6 +16,9 @@ #include "dawn/native/dawn_platform.h" +namespace dawn { +namespace { + class InternalResourceUsageTests : public DawnTest { protected: wgpu::Buffer CreateBuffer(wgpu::BufferUsage usage) { @@ -32,9 +35,9 @@ class InternalResourceUsageTests : public DawnTest { TEST_P(InternalResourceUsageTests, InternalBufferUsage) { DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("skip_validation")); - ASSERT_DEVICE_ERROR(CreateBuffer(dawn::native::kReadOnlyStorageBuffer)); + ASSERT_DEVICE_ERROR(CreateBuffer(native::kReadOnlyStorageBuffer)); - ASSERT_DEVICE_ERROR(CreateBuffer(dawn::native::kInternalStorageBuffer)); + ASSERT_DEVICE_ERROR(CreateBuffer(native::kInternalStorageBuffer)); } DAWN_INSTANTIATE_TEST(InternalResourceUsageTests, NullBackend()); @@ -48,7 +51,7 @@ TEST_P(InternalBindingTypeTests, InternalStorageBufferBindingType) { wgpu::BindGroupLayoutEntry bglEntry; bglEntry.binding = 0; - bglEntry.buffer.type = dawn::native::kInternalStorageBufferBinding; + bglEntry.buffer.type = native::kInternalStorageBufferBinding; bglEntry.visibility = wgpu::ShaderStage::Compute; wgpu::BindGroupLayoutDescriptor bglDesc; @@ -58,3 +61,6 @@ TEST_P(InternalBindingTypeTests, InternalStorageBufferBindingType) { } DAWN_INSTANTIATE_TEST(InternalBindingTypeTests, NullBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp b/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp index 0be3d3b4b7..b5715175c9 100644 --- a/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp +++ b/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp @@ -20,6 +20,9 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { +namespace { + class InternalStorageBufferBindingTests : public DawnTest { protected: static constexpr uint32_t kNumValues = 4; @@ -45,22 +48,21 @@ class InternalStorageBufferBindingTests : public DawnTest { )"); // Create binding group layout with internal storage buffer binding type - dawn::native::BindGroupLayoutEntry bglEntry; + native::BindGroupLayoutEntry bglEntry; bglEntry.binding = 0; - bglEntry.buffer.type = dawn::native::kInternalStorageBufferBinding; + bglEntry.buffer.type = native::kInternalStorageBufferBinding; bglEntry.visibility = wgpu::ShaderStage::Compute; - dawn::native::BindGroupLayoutDescriptor bglDesc; + native::BindGroupLayoutDescriptor bglDesc; bglDesc.entryCount = 1; bglDesc.entries = &bglEntry; - dawn::native::DeviceBase* nativeDevice = dawn::native::FromAPI(device.Get()); + native::DeviceBase* nativeDevice = native::FromAPI(device.Get()); - Ref bglRef = + Ref bglRef = nativeDevice->CreateBindGroupLayout(&bglDesc, true).AcquireSuccess(); - wgpu::BindGroupLayout bgl = - wgpu::BindGroupLayout::Acquire(dawn::native::ToAPI(bglRef.Detach())); + wgpu::BindGroupLayout bgl = wgpu::BindGroupLayout::Acquire(native::ToAPI(bglRef.Detach())); // Create pipeline layout wgpu::PipelineLayoutDescriptor plDesc; @@ -111,3 +113,6 @@ DAWN_INSTANTIATE_TEST(InternalStorageBufferBindingTests, D3D12Backend(), MetalBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/QueryInternalShaderTests.cpp b/src/dawn/tests/white_box/QueryInternalShaderTests.cpp index ae8562372a..bb25ae8ccb 100644 --- a/src/dawn/tests/white_box/QueryInternalShaderTests.cpp +++ b/src/dawn/tests/white_box/QueryInternalShaderTests.cpp @@ -20,19 +20,20 @@ #include "dawn/tests/DawnTest.h" #include "dawn/utils/WGPUHelpers.h" +namespace dawn { namespace { void EncodeConvertTimestampsToNanoseconds(wgpu::CommandEncoder encoder, wgpu::Buffer timestamps, wgpu::Buffer availability, wgpu::Buffer params) { - ASSERT_TRUE(dawn::native::EncodeConvertTimestampsToNanoseconds( - dawn::native::FromAPI(encoder.Get()), dawn::native::FromAPI(timestamps.Get()), - dawn::native::FromAPI(availability.Get()), dawn::native::FromAPI(params.Get())) + ASSERT_TRUE(native::EncodeConvertTimestampsToNanoseconds( + native::FromAPI(encoder.Get()), native::FromAPI(timestamps.Get()), + native::FromAPI(availability.Get()), native::FromAPI(params.Get())) .IsSuccess()); } -class InternalShaderExpectation : public detail::Expectation { +class InternalShaderExpectation : public ::detail::Expectation { public: ~InternalShaderExpectation() override = default; @@ -78,8 +79,6 @@ class InternalShaderExpectation : public detail::Expectation { std::vector mExpected; }; -} // anonymous namespace - constexpr static uint64_t kSentinelValue = ~uint64_t(0u); class QueryInternalShaderTests : public DawnTest { @@ -167,7 +166,7 @@ class QueryInternalShaderTests : public DawnTest { kQueryCount * sizeof(uint32_t), wgpu::BufferUsage::Storage); // The params uniform buffer - dawn::native::TimestampParams params(firstQuery, queryCount, destinationOffset, period); + native::TimestampParams params(firstQuery, queryCount, destinationOffset, period); wgpu::Buffer paramsBuffer = utils::CreateBufferFromData(device, ¶ms, sizeof(params), wgpu::BufferUsage::Uniform); @@ -231,3 +230,6 @@ TEST_P(QueryInternalShaderTests, TimestampComputeShader) { } DAWN_INSTANTIATE_TEST(QueryInternalShaderTests, D3D12Backend(), MetalBackend(), VulkanBackend()); + +} // anonymous namespace +} // namespace dawn diff --git a/src/dawn/tests/white_box/VulkanErrorInjectorTests.cpp b/src/dawn/tests/white_box/VulkanErrorInjectorTests.cpp index 209fd6be19..d72fb937d3 100644 --- a/src/dawn/tests/white_box/VulkanErrorInjectorTests.cpp +++ b/src/dawn/tests/white_box/VulkanErrorInjectorTests.cpp @@ -22,21 +22,20 @@ #include "dawn/native/vulkan/VulkanError.h" namespace dawn::native::vulkan { - namespace { + class VulkanErrorInjectorTests : public DawnTest { public: void SetUp() override { DawnTest::SetUp(); DAWN_TEST_UNSUPPORTED_IF(UsesWire()); - mDeviceVk = dawn::native::vulkan::ToBackend(dawn::native::FromAPI(device.Get())); + mDeviceVk = native::vulkan::ToBackend(native::FromAPI(device.Get())); } protected: - dawn::native::vulkan::Device* mDeviceVk; + native::vulkan::Device* mDeviceVk; }; -} // anonymous namespace TEST_P(VulkanErrorInjectorTests, InjectErrorOnCreateBuffer) { VkBufferCreateInfo createInfo = {}; @@ -123,4 +122,5 @@ TEST_P(VulkanErrorInjectorTests, InjectErrorOnCreateBuffer) { DAWN_INSTANTIATE_TEST(VulkanErrorInjectorTests, VulkanBackend()); +} // anonymous namespace } // namespace dawn::native::vulkan diff --git a/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp b/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp index 6cdd6dbaa1..f79568edde 100644 --- a/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp +++ b/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp @@ -24,9 +24,6 @@ namespace dawn::native::vulkan { -using ExternalTexture = VulkanImageWrappingTestBackend::ExternalTexture; -using ExternalSemaphore = VulkanImageWrappingTestBackend::ExternalSemaphore; - void VulkanImageWrappingTestBackend::SetParam( const VulkanImageWrappingTestBackend::TestParams& params) { mParams = params; @@ -38,6 +35,9 @@ const VulkanImageWrappingTestBackend::TestParams& VulkanImageWrappingTestBackend namespace { +using ExternalTexture = VulkanImageWrappingTestBackend::ExternalTexture; +using ExternalSemaphore = VulkanImageWrappingTestBackend::ExternalSemaphore; + using UseDedicatedAllocation = bool; using DetectDedicatedAllocation = bool; DAWN_TEST_PARAM_STRUCT(ImageWrappingParams, UseDedicatedAllocation, DetectDedicatedAllocation); @@ -145,8 +145,6 @@ class VulkanImageWrappingTestBase : public DawnTestWithParams defaultTexture; }; -} // namespace - using VulkanImageWrappingValidationTests = VulkanImageWrappingTestBase; // Test no error occurs if the import is valid @@ -265,25 +263,24 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase { } // Create another device based on the original - adapterBase = dawn::native::FromAPI(device.Get())->GetAdapter(); + adapterBase = native::FromAPI(device.Get())->GetAdapter(); deviceDescriptor.nextInChain = &deviceTogglesDesc; deviceTogglesDesc.enabledToggles = GetParam().forceEnabledWorkarounds.data(); deviceTogglesDesc.enabledTogglesCount = GetParam().forceEnabledWorkarounds.size(); deviceTogglesDesc.disabledToggles = GetParam().forceDisabledWorkarounds.data(); deviceTogglesDesc.disabledTogglesCount = GetParam().forceDisabledWorkarounds.size(); - secondDeviceVk = - dawn::native::vulkan::ToBackend(adapterBase->APICreateDevice(&deviceDescriptor)); - secondDevice = wgpu::Device::Acquire(dawn::native::ToAPI(secondDeviceVk)); + secondDeviceVk = native::vulkan::ToBackend(adapterBase->APICreateDevice(&deviceDescriptor)); + secondDevice = wgpu::Device::Acquire(native::ToAPI(secondDeviceVk)); } protected: - dawn::native::AdapterBase* adapterBase; - dawn::native::DeviceDescriptor deviceDescriptor; - dawn::native::DawnTogglesDescriptor deviceTogglesDesc; + native::AdapterBase* adapterBase; + native::DeviceDescriptor deviceDescriptor; + native::DawnTogglesDescriptor deviceTogglesDesc; wgpu::Device secondDevice; - dawn::native::vulkan::Device* secondDeviceVk; + native::vulkan::Device* secondDeviceVk; // Clear a texture on a given device void ClearImage(wgpu::Device dawnDevice, wgpu::Texture wrappedTexture, wgpu::Color clearColor) { @@ -613,9 +610,9 @@ TEST_P(VulkanImageWrappingUsageTests, ChainTextureCopy) { // device 1 = |device| // device 2 = |secondDevice| // Create device 3 - dawn::native::vulkan::Device* thirdDeviceVk = - dawn::native::vulkan::ToBackend(adapterBase->APICreateDevice(&deviceDescriptor)); - wgpu::Device thirdDevice = wgpu::Device::Acquire(dawn::native::ToAPI(thirdDeviceVk)); + native::vulkan::Device* thirdDeviceVk = + native::vulkan::ToBackend(adapterBase->APICreateDevice(&deviceDescriptor)); + wgpu::Device thirdDevice = wgpu::Device::Acquire(native::ToAPI(thirdDeviceVk)); // Make queue for device 2 and 3 wgpu::Queue secondDeviceQueue = secondDevice.GetQueue(); @@ -888,4 +885,5 @@ DAWN_INSTANTIATE_TEST_P(VulkanImageWrappingUsageTests, {true, false} // DetectDedicatedAllocation ); +} // anonymous namespace } // namespace dawn::native::vulkan diff --git a/src/dawn/tests/white_box/VulkanImageWrappingTests_DmaBuf.cpp b/src/dawn/tests/white_box/VulkanImageWrappingTests_DmaBuf.cpp index 1373e1db6d..5598f37970 100644 --- a/src/dawn/tests/white_box/VulkanImageWrappingTests_DmaBuf.cpp +++ b/src/dawn/tests/white_box/VulkanImageWrappingTests_DmaBuf.cpp @@ -82,7 +82,7 @@ class ExternalTextureDmaBuf : public VulkanImageWrappingTestBackend::ExternalTex class VulkanImageWrappingTestBackendDmaBuf : public VulkanImageWrappingTestBackend { public: explicit VulkanImageWrappingTestBackendDmaBuf(const wgpu::Device& device) { - mDeviceVk = dawn::native::vulkan::ToBackend(dawn::native::FromAPI(device.Get())); + mDeviceVk = native::vulkan::ToBackend(native::FromAPI(device.Get())); } ~VulkanImageWrappingTestBackendDmaBuf() { @@ -139,7 +139,7 @@ class VulkanImageWrappingTestBackendDmaBuf : public VulkanImageWrappingTestBacke descriptorDmaBuf.drmModifier = textureDmaBuf->drmModifier; return wgpu::Texture::Acquire( - dawn::native::vulkan::WrapVulkanImage(device.Get(), &descriptorDmaBuf)); + native::vulkan::WrapVulkanImage(device.Get(), &descriptorDmaBuf)); } bool ExportImage(const wgpu::Texture& texture, @@ -196,7 +196,7 @@ class VulkanImageWrappingTestBackendDmaBuf : public VulkanImageWrappingTestBacke } gbm_device* mGbmDevice = nullptr; - dawn::native::vulkan::Device* mDeviceVk; + native::vulkan::Device* mDeviceVk; }; // static diff --git a/src/dawn/tests/white_box/VulkanImageWrappingTests_OpaqueFD.cpp b/src/dawn/tests/white_box/VulkanImageWrappingTests_OpaqueFD.cpp index a99e5c384b..2010491c0c 100644 --- a/src/dawn/tests/white_box/VulkanImageWrappingTests_OpaqueFD.cpp +++ b/src/dawn/tests/white_box/VulkanImageWrappingTests_OpaqueFD.cpp @@ -52,7 +52,7 @@ class ExternalSemaphoreOpaqueFD : public VulkanImageWrappingTestBackend::Externa class ExternalTextureOpaqueFD : public VulkanImageWrappingTestBackend::ExternalTexture { public: - ExternalTextureOpaqueFD(dawn::native::vulkan::Device* device, + ExternalTextureOpaqueFD(native::vulkan::Device* device, int fd, VkDeviceMemory allocation, VkImage handle, @@ -80,7 +80,7 @@ class ExternalTextureOpaqueFD : public VulkanImageWrappingTestBackend::ExternalT int Dup() const { return dup(mFd); } private: - dawn::native::vulkan::Device* mDevice; + native::vulkan::Device* mDevice; int mFd = -1; VkDeviceMemory mAllocation = VK_NULL_HANDLE; VkImage mHandle = VK_NULL_HANDLE; @@ -93,7 +93,7 @@ class ExternalTextureOpaqueFD : public VulkanImageWrappingTestBackend::ExternalT class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBackend { public: explicit VulkanImageWrappingTestBackendOpaqueFD(const wgpu::Device& device) : mDevice(device) { - mDeviceVk = dawn::native::vulkan::ToBackend(dawn::native::FromAPI(device.Get())); + mDeviceVk = native::vulkan::ToBackend(native::FromAPI(device.Get())); } bool SupportsTestParams(const TestParams& params) const override { @@ -156,7 +156,7 @@ class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBac } return wgpu::Texture::Acquire( - dawn::native::vulkan::WrapVulkanImage(device.Get(), &descriptorOpaqueFD)); + native::vulkan::WrapVulkanImage(device.Get(), &descriptorOpaqueFD)); } bool ExportImage(const wgpu::Texture& texture, @@ -175,7 +175,7 @@ class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBac private: // Creates a VkImage with external memory - ::VkResult CreateImage(dawn::native::vulkan::Device* deviceVk, + ::VkResult CreateImage(native::vulkan::Device* deviceVk, uint32_t width, uint32_t height, VkFormat format, @@ -209,7 +209,7 @@ class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBac } // Allocates memory for an image - ::VkResult AllocateMemory(dawn::native::vulkan::Device* deviceVk, + ::VkResult AllocateMemory(native::vulkan::Device* deviceVk, VkImage handle, VkDeviceMemory* allocation, VkDeviceSize* allocationSize, @@ -249,14 +249,12 @@ class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBac } // Binds memory to an image - ::VkResult BindMemory(dawn::native::vulkan::Device* deviceVk, - VkImage handle, - VkDeviceMemory memory) { + ::VkResult BindMemory(native::vulkan::Device* deviceVk, VkImage handle, VkDeviceMemory memory) { return deviceVk->fn.BindImageMemory(deviceVk->GetVkDevice(), handle, memory, 0); } // Extracts a file descriptor representing memory on a device - int GetMemoryFd(dawn::native::vulkan::Device* deviceVk, VkDeviceMemory memory) { + int GetMemoryFd(native::vulkan::Device* deviceVk, VkDeviceMemory memory) { VkMemoryGetFdInfoKHR getFdInfo; getFdInfo.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR; getFdInfo.pNext = nullptr; @@ -271,7 +269,7 @@ class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBac } // Prepares and exports memory for an image on a given device - void CreateBindExportImage(dawn::native::vulkan::Device* deviceVk, + void CreateBindExportImage(native::vulkan::Device* deviceVk, uint32_t width, uint32_t height, VkFormat format, @@ -282,7 +280,7 @@ class VulkanImageWrappingTestBackendOpaqueFD : public VulkanImageWrappingTestBac int* memoryFd) {} wgpu::Device mDevice; - dawn::native::vulkan::Device* mDeviceVk; + native::vulkan::Device* mDeviceVk; }; // static diff --git a/src/dawn/utils/ComboRenderBundleEncoderDescriptor.cpp b/src/dawn/utils/ComboRenderBundleEncoderDescriptor.cpp index 4b21e3257b..aec005c52d 100644 --- a/src/dawn/utils/ComboRenderBundleEncoderDescriptor.cpp +++ b/src/dawn/utils/ComboRenderBundleEncoderDescriptor.cpp @@ -16,7 +16,7 @@ #include "dawn/utils/WGPUHelpers.h" -namespace utils { +namespace dawn::utils { ComboRenderBundleEncoderDescriptor::ComboRenderBundleEncoderDescriptor() { wgpu::RenderBundleEncoderDescriptor* descriptor = this; @@ -25,4 +25,4 @@ ComboRenderBundleEncoderDescriptor::ComboRenderBundleEncoderDescriptor() { descriptor->colorFormats = &cColorFormats[0]; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/ComboRenderBundleEncoderDescriptor.h b/src/dawn/utils/ComboRenderBundleEncoderDescriptor.h index 3f4db0a6da..1bb3f618c9 100644 --- a/src/dawn/utils/ComboRenderBundleEncoderDescriptor.h +++ b/src/dawn/utils/ComboRenderBundleEncoderDescriptor.h @@ -20,7 +20,7 @@ #include "dawn/common/Constants.h" #include "dawn/webgpu_cpp.h" -namespace utils { +namespace dawn::utils { class ComboRenderBundleEncoderDescriptor : public wgpu::RenderBundleEncoderDescriptor { public: @@ -29,6 +29,6 @@ class ComboRenderBundleEncoderDescriptor : public wgpu::RenderBundleEncoderDescr std::array cColorFormats; }; -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_ diff --git a/src/dawn/utils/ComboRenderPipelineDescriptor.cpp b/src/dawn/utils/ComboRenderPipelineDescriptor.cpp index 5f20cc0456..0a3e718005 100644 --- a/src/dawn/utils/ComboRenderPipelineDescriptor.cpp +++ b/src/dawn/utils/ComboRenderPipelineDescriptor.cpp @@ -16,7 +16,7 @@ #include "dawn/utils/WGPUHelpers.h" -namespace utils { +namespace dawn::utils { ComboVertexState::ComboVertexState() { vertexBufferCount = 0; @@ -146,4 +146,4 @@ void ComboRenderPipelineDescriptor::DisableDepthStencil() { this->depthStencil = nullptr; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/ComboRenderPipelineDescriptor.h b/src/dawn/utils/ComboRenderPipelineDescriptor.h index 70a2b9ca63..07707ae3e4 100644 --- a/src/dawn/utils/ComboRenderPipelineDescriptor.h +++ b/src/dawn/utils/ComboRenderPipelineDescriptor.h @@ -20,7 +20,7 @@ #include "dawn/common/Constants.h" #include "dawn/webgpu_cpp.h" -namespace utils { +namespace dawn::utils { // Primarily used by tests to easily set up the vertex buffer state portion of a RenderPipeline. class ComboVertexState { @@ -59,6 +59,6 @@ class ComboRenderPipelineDescriptor : public wgpu::RenderPipelineDescriptor { wgpu::DepthStencilState cDepthStencil; }; -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_ diff --git a/src/dawn/utils/EmptyDebugLogger.cpp b/src/dawn/utils/EmptyDebugLogger.cpp index a8b2d24086..4b4eae617a 100644 --- a/src/dawn/utils/EmptyDebugLogger.cpp +++ b/src/dawn/utils/EmptyDebugLogger.cpp @@ -14,7 +14,7 @@ #include "dawn/utils/PlatformDebugLogger.h" -namespace utils { +namespace dawn::utils { class EmptyDebugLogger : public PlatformDebugLogger { public: @@ -26,4 +26,4 @@ PlatformDebugLogger* CreatePlatformDebugLogger() { return new EmptyDebugLogger(); } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/OSXTimer.cpp b/src/dawn/utils/OSXTimer.cpp index ac749b1500..3ca360807c 100644 --- a/src/dawn/utils/OSXTimer.cpp +++ b/src/dawn/utils/OSXTimer.cpp @@ -18,7 +18,7 @@ #include "dawn/utils/Timer.h" -namespace utils { +namespace dawn::utils { class OSXTimer : public Timer { public: @@ -71,4 +71,4 @@ Timer* CreateTimer() { return new OSXTimer(); } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/ObjCUtils.h b/src/dawn/utils/ObjCUtils.h index 86318192b8..2cd4986155 100644 --- a/src/dawn/utils/ObjCUtils.h +++ b/src/dawn/utils/ObjCUtils.h @@ -19,11 +19,11 @@ // of ObjectiveC calls, when they cannot be converted to ObjectiveC++ because they are used on // multiple platforms. -namespace utils { +namespace dawn::utils { // The returned CALayer is autoreleased. void* CreatePlaceholderCALayer(); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_OBJCUTILS_H_ diff --git a/src/dawn/utils/ObjCUtils.mm b/src/dawn/utils/ObjCUtils.mm index 171f5fcbf6..960c683fc2 100644 --- a/src/dawn/utils/ObjCUtils.mm +++ b/src/dawn/utils/ObjCUtils.mm @@ -16,10 +16,10 @@ #include -namespace utils { +namespace dawn::utils { void* CreatePlaceholderCALayer() { return [CALayer layer]; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/PlatformDebugLogger.h b/src/dawn/utils/PlatformDebugLogger.h index a67af179ea..447d3f380e 100644 --- a/src/dawn/utils/PlatformDebugLogger.h +++ b/src/dawn/utils/PlatformDebugLogger.h @@ -15,7 +15,7 @@ #ifndef SRC_DAWN_UTILS_PLATFORMDEBUGLOGGER_H_ #define SRC_DAWN_UTILS_PLATFORMDEBUGLOGGER_H_ -namespace utils { +namespace dawn::utils { class PlatformDebugLogger { public: @@ -24,6 +24,6 @@ class PlatformDebugLogger { PlatformDebugLogger* CreatePlatformDebugLogger(); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_PLATFORMDEBUGLOGGER_H_ diff --git a/src/dawn/utils/PosixTimer.cpp b/src/dawn/utils/PosixTimer.cpp index 9b43e185bb..ca4fd5181d 100644 --- a/src/dawn/utils/PosixTimer.cpp +++ b/src/dawn/utils/PosixTimer.cpp @@ -17,7 +17,7 @@ #include "dawn/utils/Timer.h" -namespace utils { +namespace dawn::utils { namespace { @@ -68,4 +68,4 @@ Timer* CreateTimer() { return new PosixTimer(); } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/ScopedAutoreleasePool.cpp b/src/dawn/utils/ScopedAutoreleasePool.cpp index da5b098b3d..f4fd6100f6 100644 --- a/src/dawn/utils/ScopedAutoreleasePool.cpp +++ b/src/dawn/utils/ScopedAutoreleasePool.cpp @@ -16,7 +16,7 @@ #include "dawn/common/Compiler.h" -namespace utils { +namespace dawn::utils { ScopedAutoreleasePool::ScopedAutoreleasePool() : mPool(nullptr) { DAWN_UNUSED(mPool); @@ -30,4 +30,4 @@ ScopedAutoreleasePool& ScopedAutoreleasePool::operator=(ScopedAutoreleasePool&& return *this; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/ScopedAutoreleasePool.h b/src/dawn/utils/ScopedAutoreleasePool.h index 4f724ca43a..1313b2797b 100644 --- a/src/dawn/utils/ScopedAutoreleasePool.h +++ b/src/dawn/utils/ScopedAutoreleasePool.h @@ -19,7 +19,7 @@ #include "dawn/common/Compiler.h" -namespace utils { +namespace dawn::utils { /** * ScopedAutoreleasePool is a scoped class which initializes an NSAutoreleasePool on @@ -36,7 +36,7 @@ namespace utils { * frame loop. Ex.) * void frame() { * // Any protocol objects will be reclaimed when this object falls out of scope. - * utils::ScopedAutoreleasePool pool; + * dawn::utils::ScopedAutoreleasePool pool; * * // do rendering ... * } @@ -56,6 +56,6 @@ class [[nodiscard]] ScopedAutoreleasePool { void* mPool = nullptr; }; -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_SCOPEDAUTORELEASEPOOL_H_ diff --git a/src/dawn/utils/ScopedAutoreleasePool.mm b/src/dawn/utils/ScopedAutoreleasePool.mm index 7aa5472455..0136de36e2 100644 --- a/src/dawn/utils/ScopedAutoreleasePool.mm +++ b/src/dawn/utils/ScopedAutoreleasePool.mm @@ -16,7 +16,7 @@ #import -namespace utils { +namespace dawn::utils { ScopedAutoreleasePool::ScopedAutoreleasePool() : mPool([[NSAutoreleasePool alloc] init]) {} @@ -40,4 +40,4 @@ ScopedAutoreleasePool& ScopedAutoreleasePool::operator=(ScopedAutoreleasePool&& return *this; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/SystemUtils.cpp b/src/dawn/utils/SystemUtils.cpp index 693a6ceb10..5a130b9dc5 100644 --- a/src/dawn/utils/SystemUtils.cpp +++ b/src/dawn/utils/SystemUtils.cpp @@ -24,7 +24,7 @@ #error "Unsupported platform." #endif -namespace utils { +namespace dawn::utils { #if DAWN_PLATFORM_IS(WINDOWS) void USleep(unsigned int usecs) { @@ -38,4 +38,4 @@ void USleep(unsigned int usecs) { #error "Implement USleep for your platform." #endif -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/SystemUtils.h b/src/dawn/utils/SystemUtils.h index bf14cdd175..ea7d393b6d 100644 --- a/src/dawn/utils/SystemUtils.h +++ b/src/dawn/utils/SystemUtils.h @@ -15,7 +15,7 @@ #ifndef SRC_DAWN_UTILS_SYSTEMUTILS_H_ #define SRC_DAWN_UTILS_SYSTEMUTILS_H_ -namespace utils { +namespace dawn::utils { void USleep(unsigned int usecs); } diff --git a/src/dawn/utils/TerribleCommandBuffer.cpp b/src/dawn/utils/TerribleCommandBuffer.cpp index 3e100d53ea..656b01abbf 100644 --- a/src/dawn/utils/TerribleCommandBuffer.cpp +++ b/src/dawn/utils/TerribleCommandBuffer.cpp @@ -16,7 +16,7 @@ #include "dawn/common/Assert.h" -namespace utils { +namespace dawn::utils { TerribleCommandBuffer::TerribleCommandBuffer() {} @@ -54,4 +54,4 @@ bool TerribleCommandBuffer::Flush() { return success; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/TerribleCommandBuffer.h b/src/dawn/utils/TerribleCommandBuffer.h index 3fac52fb05..69c8a2dcfb 100644 --- a/src/dawn/utils/TerribleCommandBuffer.h +++ b/src/dawn/utils/TerribleCommandBuffer.h @@ -17,7 +17,7 @@ #include "dawn/wire/Wire.h" -namespace utils { +namespace dawn::utils { class TerribleCommandBuffer : public dawn::wire::CommandSerializer { public: @@ -37,6 +37,6 @@ class TerribleCommandBuffer : public dawn::wire::CommandSerializer { char mBuffer[1000000]; }; -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_TERRIBLECOMMANDBUFFER_H_ diff --git a/src/dawn/utils/TestUtils.cpp b/src/dawn/utils/TestUtils.cpp index bf7b247802..f276471b93 100644 --- a/src/dawn/utils/TestUtils.cpp +++ b/src/dawn/utils/TestUtils.cpp @@ -25,7 +25,7 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" -namespace utils { +namespace dawn::utils { const RGBA8 RGBA8::kZero = RGBA8(0, 0, 0, 0); const RGBA8 RGBA8::kBlack = RGBA8(0, 0, 0, 255); @@ -41,8 +41,8 @@ std::ostream& operator<<(std::ostream& stream, const RGBA8& color) { } uint32_t GetMinimumBytesPerRow(wgpu::TextureFormat format, uint32_t width) { - const uint32_t bytesPerBlock = utils::GetTexelBlockSizeInBytes(format); - const uint32_t blockWidth = utils::GetTextureFormatBlockWidth(format); + const uint32_t bytesPerBlock = dawn::utils::GetTexelBlockSizeInBytes(format); + const uint32_t blockWidth = dawn::utils::GetTextureFormatBlockWidth(format); ASSERT(width % blockWidth == 0); return Align(bytesPerBlock * (width / blockWidth), kTextureBytesPerRowAlignment); } @@ -53,7 +53,7 @@ TextureDataCopyLayout GetTextureDataCopyLayoutForTextureAtLevel(wgpu::TextureFor wgpu::TextureDimension dimension, uint32_t rowsPerImage) { // Compressed texture formats not supported in this function yet. - ASSERT(utils::GetTextureFormatBlockWidth(format) == 1); + ASSERT(dawn::utils::GetTextureFormatBlockWidth(format) == 1); TextureDataCopyLayout layout; @@ -79,7 +79,7 @@ TextureDataCopyLayout GetTextureDataCopyLayoutForTextureAtLevel(wgpu::TextureFor layout.byteLength = RequiredBytesInCopy(layout.bytesPerRow, appliedRowsPerImage, layout.mipSize, format); - const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(format); + const uint32_t bytesPerTexel = dawn::utils::GetTexelBlockSizeInBytes(format); layout.texelBlocksPerRow = layout.bytesPerRow / bytesPerTexel; layout.texelBlocksPerImage = layout.bytesPerImage / bytesPerTexel; layout.texelBlockCount = layout.byteLength / bytesPerTexel; @@ -91,9 +91,9 @@ uint64_t RequiredBytesInCopy(uint64_t bytesPerRow, uint64_t rowsPerImage, wgpu::Extent3D copyExtent, wgpu::TextureFormat textureFormat) { - uint32_t blockSize = utils::GetTexelBlockSizeInBytes(textureFormat); - uint32_t blockWidth = utils::GetTextureFormatBlockWidth(textureFormat); - uint32_t blockHeight = utils::GetTextureFormatBlockHeight(textureFormat); + uint32_t blockSize = dawn::utils::GetTexelBlockSizeInBytes(textureFormat); + uint32_t blockWidth = dawn::utils::GetTextureFormatBlockWidth(textureFormat); + uint32_t blockHeight = dawn::utils::GetTextureFormatBlockHeight(textureFormat); ASSERT(copyExtent.width % blockWidth == 0); uint32_t widthInBlocks = copyExtent.width / blockWidth; ASSERT(copyExtent.height % blockHeight == 0); @@ -127,7 +127,7 @@ uint64_t GetTexelCountInCopyRegion(uint64_t bytesPerRow, wgpu::Extent3D copyExtent, wgpu::TextureFormat textureFormat) { return RequiredBytesInCopy(bytesPerRow, rowsPerImage, copyExtent, textureFormat) / - utils::GetTexelBlockSizeInBytes(textureFormat); + dawn::utils::GetTexelBlockSizeInBytes(textureFormat); } void UnalignDynamicUploader(wgpu::Device device) { @@ -139,9 +139,10 @@ void UnalignDynamicUploader(wgpu::Device device) { descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc; wgpu::Texture texture = device.CreateTexture(&descriptor); - wgpu::ImageCopyTexture imageCopyTexture = utils::CreateImageCopyTexture(texture, 0, {0, 0, 0}); + wgpu::ImageCopyTexture imageCopyTexture = + dawn::utils::CreateImageCopyTexture(texture, 0, {0, 0, 0}); wgpu::TextureDataLayout textureDataLayout = - utils::CreateTextureDataLayout(0, wgpu::kCopyStrideUndefined); + dawn::utils::CreateTextureDataLayout(0, wgpu::kCopyStrideUndefined); wgpu::Extent3D copyExtent = {1, 1, 1}; // WriteTexture with exactly 1 byte of data. @@ -210,4 +211,4 @@ void RunInParallel(uint32_t numThreads, } } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/TestUtils.h b/src/dawn/utils/TestUtils.h index 9654b72116..047ec42400 100644 --- a/src/dawn/utils/TestUtils.h +++ b/src/dawn/utils/TestUtils.h @@ -20,7 +20,7 @@ #include "dawn/webgpu_cpp.h" -namespace utils { +namespace dawn::utils { struct RGBA8 { constexpr RGBA8() : RGBA8(0, 0, 0, 0) {} @@ -89,6 +89,6 @@ void RunInParallel(uint32_t numThreads, const std::function& workerFunc, const std::function& mainThreadFunc = nullptr); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_TESTUTILS_H_ diff --git a/src/dawn/utils/TextureUtils.cpp b/src/dawn/utils/TextureUtils.cpp index b4e60fc829..0a30394a7a 100644 --- a/src/dawn/utils/TextureUtils.cpp +++ b/src/dawn/utils/TextureUtils.cpp @@ -14,7 +14,7 @@ #include "dawn/utils/TextureUtils.h" -namespace utils { +namespace dawn::utils { bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format) { switch (format) { case wgpu::TextureFormat::R32Uint: @@ -740,4 +740,4 @@ wgpu::TextureDimension ViewDimensionToTextureDimension(const wgpu::TextureViewDi } } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/TextureUtils.h b/src/dawn/utils/TextureUtils.h index 964df10023..79cce307a0 100644 --- a/src/dawn/utils/TextureUtils.h +++ b/src/dawn/utils/TextureUtils.h @@ -21,7 +21,7 @@ #include "dawn/common/Assert.h" -namespace utils { +namespace dawn::utils { static constexpr std::array kAllTextureFormats = { wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::R8Snorm, @@ -242,6 +242,6 @@ const char* GetWGSLImageFormatQualifier(wgpu::TextureFormat textureFormat); uint32_t GetWGSLRenderableColorTextureComponentCount(wgpu::TextureFormat textureFormat); wgpu::TextureDimension ViewDimensionToTextureDimension(const wgpu::TextureViewDimension dimension); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_TEXTUREUTILS_H_ diff --git a/src/dawn/utils/Timer.h b/src/dawn/utils/Timer.h index a7438e78a8..0a03a93f31 100644 --- a/src/dawn/utils/Timer.h +++ b/src/dawn/utils/Timer.h @@ -15,7 +15,7 @@ #ifndef SRC_DAWN_UTILS_TIMER_H_ #define SRC_DAWN_UTILS_TIMER_H_ -namespace utils { +namespace dawn::utils { class Timer { public: @@ -35,6 +35,6 @@ class Timer { Timer* CreateTimer(); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_TIMER_H_ diff --git a/src/dawn/utils/WGPUHelpers.cpp b/src/dawn/utils/WGPUHelpers.cpp index ee9c14bccc..b9c3e186be 100644 --- a/src/dawn/utils/WGPUHelpers.cpp +++ b/src/dawn/utils/WGPUHelpers.cpp @@ -39,7 +39,7 @@ std::array kGammaDecodeBT709 = {2.2, 1.0 / 1.099, 0.099 / 1.099, 1 / 4 std::array kGammaEncodeSrgb = {1 / 2.4, 1.137119, 0.0, 12.92, 0.0031308, -0.055, 0.0}; } // namespace -namespace utils { +namespace dawn::utils { #if TINT_BUILD_SPV_READER wgpu::ShaderModule CreateShaderModuleFromASM( const wgpu::Device& device, @@ -418,4 +418,4 @@ ColorSpaceConversionInfo GetYUVBT709ToRGBSRGBColorSpaceConversionInfo() { return info; } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/WGPUHelpers.h b/src/dawn/utils/WGPUHelpers.h index f05e323be9..efaaefa858 100644 --- a/src/dawn/utils/WGPUHelpers.h +++ b/src/dawn/utils/WGPUHelpers.h @@ -23,7 +23,7 @@ #include "dawn/utils/TextureUtils.h" #include "dawn/webgpu_cpp.h" -namespace utils { +namespace dawn::utils { enum Expectation { Success, Failure }; @@ -89,7 +89,7 @@ struct BasicRenderPass { uint32_t height; wgpu::Texture color; wgpu::TextureFormat colorFormat; - utils::ComboRenderPassDescriptor renderPassInfo; + dawn::utils::ComboRenderPassDescriptor renderPassInfo; }; BasicRenderPass CreateBasicRenderPass( const wgpu::Device& device, @@ -107,7 +107,7 @@ extern wgpu::ExternalTextureBindingLayout kExternalTextureBindingLayout; // Helpers to make creating bind group layouts look nicer: // -// utils::MakeBindGroupLayout(device, { +// dawn::utils::MakeBindGroupLayout(device, { // {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}, // {1, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}, // {3, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float} @@ -148,7 +148,7 @@ wgpu::BindGroupLayout MakeBindGroupLayout( // Helpers to make creating bind groups look nicer: // -// utils::MakeBindGroup(device, layout, { +// dawn::utils::MakeBindGroup(device, layout, { // {0, mySampler}, // {1, myBuffer, offset, size}, // {3, myTextureView} @@ -192,6 +192,6 @@ struct ColorSpaceConversionInfo { ColorSpaceConversionInfo GetYUVBT709ToRGBSRGBColorSpaceConversionInfo(); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_WGPUHELPERS_H_ diff --git a/src/dawn/utils/WindowsDebugLogger.cpp b/src/dawn/utils/WindowsDebugLogger.cpp index 3f7fbed9c3..5a23966a97 100644 --- a/src/dawn/utils/WindowsDebugLogger.cpp +++ b/src/dawn/utils/WindowsDebugLogger.cpp @@ -20,7 +20,7 @@ #include "dawn/common/Assert.h" #include "dawn/common/windows_with_undefs.h" -namespace utils { +namespace dawn::utils { class WindowsDebugLogger : public PlatformDebugLogger { public: @@ -107,4 +107,4 @@ PlatformDebugLogger* CreatePlatformDebugLogger() { return new WindowsDebugLogger(); } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/WindowsTimer.cpp b/src/dawn/utils/WindowsTimer.cpp index 99e1d734d0..efbfdcb0df 100644 --- a/src/dawn/utils/WindowsTimer.cpp +++ b/src/dawn/utils/WindowsTimer.cpp @@ -16,7 +16,7 @@ #include "dawn/utils/Timer.h" -namespace utils { +namespace dawn::utils { class WindowsTimer : public Timer { public: @@ -85,4 +85,4 @@ Timer* CreateTimer() { return new WindowsTimer(); } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/WireHelper.cpp b/src/dawn/utils/WireHelper.cpp index 609e8ff9d3..19db20190a 100644 --- a/src/dawn/utils/WireHelper.cpp +++ b/src/dawn/utils/WireHelper.cpp @@ -30,7 +30,7 @@ #include "dawn/wire/WireClient.h" #include "dawn/wire/WireServer.h" -namespace utils { +namespace dawn::utils { namespace { @@ -95,8 +95,8 @@ class WireHelperDirect : public WireHelper { class WireHelperProxy : public WireHelper { public: explicit WireHelperProxy(const char* wireTraceDir, const DawnProcTable& procs) { - mC2sBuf = std::make_unique(); - mS2cBuf = std::make_unique(); + mC2sBuf = std::make_unique(); + mS2cBuf = std::make_unique(); dawn::wire::WireServerDescriptor serverDesc = {}; serverDesc.procs = &procs; @@ -138,8 +138,8 @@ class WireHelperProxy : public WireHelper { bool FlushServer() override { return mS2cBuf->Flush(); } private: - std::unique_ptr mC2sBuf; - std::unique_ptr mS2cBuf; + std::unique_ptr mC2sBuf; + std::unique_ptr mS2cBuf; std::unique_ptr mWireServerTraceLayer; std::unique_ptr mWireServer; std::unique_ptr mWireClient; @@ -161,4 +161,4 @@ WireHelper::~WireHelper() { dawnProcSetProcs(nullptr); } -} // namespace utils +} // namespace dawn::utils diff --git a/src/dawn/utils/WireHelper.h b/src/dawn/utils/WireHelper.h index 3f52938532..ed7e272fa6 100644 --- a/src/dawn/utils/WireHelper.h +++ b/src/dawn/utils/WireHelper.h @@ -23,7 +23,7 @@ struct DawnProcTable; -namespace utils { +namespace dawn::utils { class WireHelper { public: @@ -45,6 +45,6 @@ std::unique_ptr CreateWireHelper(const DawnProcTable& procs, bool useWire, const char* wireTraceDir = nullptr); -} // namespace utils +} // namespace dawn::utils #endif // SRC_DAWN_UTILS_WIREHELPER_H_