Edit

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

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2018-03-27 09:44:32
    Hash : e858cb1d
    Message : Split VAO dirty bits to speed iteration. Using > 64 bits (we had over 90) would use a much slower dirty bit iteration. Speed this up by splitting the dirty bits into two levels. The first top level only has a single dirty bit per attrib, per binding, and one bit for the element array buffer. The next level has separate dirty bits for attribs and bindings. The D3D11 back-end doesn't actually care about individual dirty bits of attribs or bindings, since it resets entire attributes at a time, but the GL back-end only refreshes the necessary info. Improves the score of a simple state change microbenchmark by 15% on the D3D11 and GL back-ends with a no-op driver. Real-world impact will be smaller. Also includes a test suppression for an NVIDIA bug that surfaced when we changed the order of that GL commands were sent to the driver. BUG=angleproject:2389 Change-Id: If8d5e5eb0b27e2a77e20535e33626183d372d311 Reviewed-on: https://chromium-review.googlesource.com/556799 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@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 GetIndexFromDirtyBit computes the index properly.
    TEST(VertexArrayTest, VerifyGetIndexFromDirtyBit)
    {
        VertexArray::DirtyBits dirtyBits;
        constexpr size_t bits[] = {1, 4, 9, 16, 25};
        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_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
                ASSERT_TRUE(false);
        }
    }