Edit

kc3-lang/angle/src/libANGLE/VertexArray_unittest.cpp

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2017-04-12 09:53:01
    Hash : 6de51858
    Message : Optimize angle::BitSetIterator. Adds a new custom bitset template to handle packing as many bits as possible into a single variable. Intelligently select the right class depending on platform features and bit sizes. For now, always use a packed 64-bit set on 64-bit, instead of using a 32-bit set for smaller bitsets. BUG=angleproject:1814 Change-Id: I3ffef815c15515555833f6fc9302d8a4eee5423b Reviewed-on: https://chromium-review.googlesource.com/471827 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>

  • src/libANGLE/VertexArray_unittest.cpp
  • //
    // Copyright 2017 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.
    //
    // Unit tests for VertexArray and related classes.
    //
    
    #include "gmock/gmock.h"
    #include "gtest/gtest.h"
    
    #include "common/bitset_utils.h"
    #include "common/utilities.h"
    #include "libANGLE/VertexArray.h"
    
    using namespace gl;
    
    // Tests that function GetAttribIndex computes the index properly.
    TEST(VertexArrayTest, VerifyGetAttribIndex)
    {
        VertexArray::DirtyBits dirtyBits;
        size_t bits[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 90};
        int count     = sizeof(bits) / sizeof(size_t);
        for (int i = 0; i < count; i++)
        {
            dirtyBits.set(bits[i]);
        }
    
        for (size_t dirtyBit : dirtyBits)
        {
            size_t index = VertexArray::GetAttribIndex(dirtyBit);
            if (dirtyBit < VertexArray::DIRTY_BIT_ATTRIB_MAX_ENABLED)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_ATTRIB_0_ENABLED, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_ATTRIB_MAX_POINTER)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_ATTRIB_0_POINTER, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_ATTRIB_MAX_FORMAT)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_ATTRIB_0_FORMAT, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_ATTRIB_MAX_BINDING)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_ATTRIB_0_BINDING, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_BINDING_MAX_BUFFER)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_BINDING_0_BUFFER, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_BINDING_MAX_DIVISOR)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_BINDING_0_DIVISOR, index);
            }
            else
                ASSERT_TRUE(false);
        }
    }