Edit

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

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2018-04-04 05:26:59
    Hash : 0946393d
    Message : Move Buffer Subject/Observer to front end. This makes BufferImpl into an Observer Subject. It also refactors the Vertex Array updates for the D3D11 backend use more of a dirty bit coding style. This change makes it so Buffer contents changes trigger front-end dirty bits from the back-end, which may be undesirable. Bug: angleproject:2389 Change-Id: Iac8ce1171284a86851c18cd1373ddf24fcefe40b Reviewed-on: https://chromium-review.googlesource.com/979812 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 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 GetIndexFromDirtyBit computes the index properly.
    TEST(VertexArrayTest, VerifyGetIndexFromDirtyBit)
    {
        VertexArray::DirtyBits dirtyBits;
        constexpr size_t bits[] = {1, 4, 9, 16, 25, 35};
        constexpr GLint count   = sizeof(bits) / sizeof(size_t);
        for (GLint i = 0; i < count; i++)
        {
            dirtyBits.set(bits[i]);
        }
    
        for (size_t dirtyBit : dirtyBits)
        {
            const size_t index = VertexArray::GetVertexIndexFromDirtyBit(dirtyBit);
            if (dirtyBit < VertexArray::DIRTY_BIT_ATTRIB_0)
            {
                continue;
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_ATTRIB_MAX)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_ATTRIB_0, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_BINDING_MAX)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_BINDING_0, index);
            }
            else if (dirtyBit < VertexArray::DIRTY_BIT_BUFFER_DATA_MAX)
            {
                EXPECT_EQ(dirtyBit - VertexArray::DIRTY_BIT_BUFFER_DATA_0, index);
            }
            else
                ASSERT_TRUE(false);
        }
    }