// Copyright 2017 The Dawn & Tint Authors // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <limits> #include <utility> #include <vector> #include "dawn/native/CommandAllocator.h" #include "gtest/gtest.h" namespace dawn::native { // Definition of the command types used in the tests enum class CommandType { … }; struct CommandDraw { … }; struct CommandPipeline { … }; struct CommandPushConstants { … }; constexpr int kBigBufferSize = …; struct CommandBig { … }; struct CommandSmall { … }; // Test allocating nothing works TEST(CommandAllocator, DoNothingAllocator) { … } // Test iterating over nothing works TEST(CommandAllocator, DoNothingAllocatorWithIterator) { … } // Test basic usage of allocator + iterator TEST(CommandAllocator, Basic) { … } // Test basic usage of allocator + iterator with data TEST(CommandAllocator, BasicWithData) { … } // Test basic iterating several times TEST(CommandAllocator, MultipleIterations) { … } // Test large commands work TEST(CommandAllocator, LargeCommands) { … } // Test many small commands work TEST(CommandAllocator, ManySmallCommands) { … } /* ________ * / \ * | POUIC! | * \_ ______/ * v * ()_() * (O.o) * (> <)o */ // Test usage of iterator.Reset TEST(CommandAllocator, IteratorReset) { … } // Test iterating empty iterators TEST(CommandAllocator, EmptyIterator) { … } template <size_t A> struct alignas(A) AlignedStruct { … }; // Test for overflows in Allocate's computations, size 1 variant TEST(CommandAllocator, AllocationOverflow_1) { … } // Test for overflows in Allocate's computations, size 2 variant TEST(CommandAllocator, AllocationOverflow_2) { … } // Test for overflows in Allocate's computations, size 4 variant TEST(CommandAllocator, AllocationOverflow_4) { … } // Test for overflows in Allocate's computations, size 8 variant TEST(CommandAllocator, AllocationOverflow_8) { … } template <int DefaultValue> struct IntWithDefault { … }; // Test that the allcator correctly defaults initalizes data for Allocate TEST(CommandAllocator, AllocateDefaultInitializes) { … } // Test that the allocator correctly default-initalizes data for AllocateData TEST(CommandAllocator, AllocateDataDefaultInitializes) { … } // Tests flattening of multiple CommandAllocators into a single CommandIterator using // AcquireCommandBlocks. TEST(CommandAllocator, AcquireCommandBlocks) { … } } // namespace dawn::native