Hash :
dde78e8c
        
        Author :
  
        
        Date :
2017-05-22T14:13:27
        
      
ES31: Implement Vertex Attrib Binding on OpenGL This patch intends to implement Vertex Attrib Binding on OpenGL back-ends: 1. Add supports for updating vertex attributes by Vertex Attrib Binding APIs. 2. Refactor the process of updating vertex attribtues in class VertexArray to make it easier to implement this feature. BUG=angleproject:1593 TEST=dEQP-GLES31.functional.vertex_attribute_binding.* Change-Id: I800e61518c552b94b84c415895ad31668b0a84b2 Reviewed-on: https://chromium-review.googlesource.com/510251 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
//
// 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, 36, 49, 64, 81, 92};
    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_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);
    }
}