// // Copyright 2016 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // VaryingPacking_unittest.cpp: // Tests for ANGLE's internal varying packing algorithm. // #include <gtest/gtest.h> // 'None' is defined as 'struct None {};' in // third_party/googletest/src/googletest/include/gtest/internal/gtest-type-util.h. // But 'None' is also define as a numberic constant 0L in <X11/X.h>. // So we need to include gtest first to avoid such conflict. #include "libANGLE/Program.h" #include "libANGLE/VaryingPacking.h" usingnamespacegl; namespace { class VaryingPackingTest : public ::testing::TestWithParam<GLuint> { … }; std::vector<sh::ShaderVariable> MakeVaryings(GLenum type, size_t count, size_t arraySize) { … } void AddVaryings(std::vector<sh::ShaderVariable> *varyings, GLenum type, size_t count, size_t arraySize) { … } // Test that a single varying can't overflow the packing. TEST_P(VaryingPackingTest, OneVaryingLargerThanMax) { … } // This will overflow the available varying space. TEST_P(VaryingPackingTest, MaxPlusOneVaryingVec3) { … } // This will overflow the available varying space. TEST_P(VaryingPackingTest, MaxPlusOneVaryingVec3Array) { … } // This will overflow the available varying space. TEST_P(VaryingPackingTest, MaxVaryingVec3AndOneVec2) { … } // This should work since two vec2s are packed in a single register. TEST_P(VaryingPackingTest, MaxPlusOneVaryingVec2) { … } // Same for this one as above. TEST_P(VaryingPackingTest, TwiceMaxVaryingVec2) { … } // This should not work since it overflows available varying space. TEST_P(VaryingPackingTest, TooManyVaryingVec2) { … } // This should work according to the example GL packing rules - the float varyings are slotted // into the end of the vec3 varying arrays. TEST_P(VaryingPackingTest, MaxVaryingVec3ArrayAndFloatArrays) { … } // This should not work - it has one too many float arrays. TEST_P(VaryingPackingTest, MaxVaryingVec3ArrayAndMaxPlusOneFloatArray) { … } // WebGL should fail to pack max+1 vec2 arrays, unlike our more relaxed packing. TEST_P(VaryingPackingTest, MaxPlusOneMat2VaryingsFailsWebGL) { … } // Makes separate tests for different values of kMaxVaryings. INSTANTIATE_TEST_SUITE_P(…); } // anonymous namespace