chromium/third_party/angle/src/tests/gl_tests/InstancingTest.cpp

//
// Copyright 2015 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.
//

#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"

usingnamespaceangle;

namespace
{
enum Geometry
{};
enum Storage
{};
enum Draw
{};
enum Vendor
{};
}  // namespace

class InstancingTest : public ANGLETest<>
{};

constexpr unsigned InstancingTest::kMaxDrawn;
constexpr float InstancingTest::kDrawSize;
constexpr GLfloat InstancingTest::kQuadVertices[];
constexpr GLfloat InstancingTest::kTriFanVertices[];
constexpr GLfloat InstancingTest::kPointVertices[];
constexpr GLushort InstancingTest::kQuadIndices[];
constexpr GLubyte InstancingTest::kTriFanIndices[];
constexpr GLushort InstancingTest::kPointIndices[];

#define TEST_INDEXED(attrib, geometry, storage, vendor)

#define TEST_NONINDEXED(attrib, geometry, storage, vendor, offset)

#define TEST_DIVISOR(numInstance, divisor)

// D3D9 has a special codepath that rearranges the input layout sent to D3D,
// to ensure that slot/stream zero of the input layout doesn't contain per-instance data, so
// we test with attribute 0 being instanced, as will as attribute 1 being instanced.
//
// Tests with a non-zero 'offset' check that "first" parameter to glDrawArraysInstancedANGLE is only
// an offset into the non-instanced vertex attributes.
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()
TEST_INDEXED()

// offset should be 0 or 4 for quads, 0 or 8 for triangle fan
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()

// offset should be 0 or 2 for points
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()
TEST_NONINDEXED()

// The following tests produce each value of 'lastDrawn' in runTest() from 1 to kMaxDrawn, a few
// different ways.
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()
TEST_DIVISOR()

// Test line loop instanced draw
TEST_P(InstancingTest, LineLoop)
{}

class InstancingTestES3 : public InstancingTest
{};

class InstancingTestES31 : public InstancingTest
{};

// Verify that VertexAttribDivisor can update both binding divisor and attribBinding.
TEST_P(InstancingTestES31, UpdateAttribBindingByVertexAttribDivisor)
{}

// Verify that a large divisor that also changes doesn't cause issues and renders correctly.
TEST_P(InstancingTestES3, LargeDivisor)
{}

// This is a regression test. If VertexAttribDivisor was returned as a signed integer, it would be
// incorrectly clamped down to the maximum signed integer.
TEST_P(InstancingTestES3, LargestDivisor)
{}

// Regression test for D3D11 streaming of GL_DYNAMIC_DRAW buffers not taking into account instanced
// attributes for buffer size calculations. http://crbug.com/1425606
TEST_P(InstancingTestES3, D3D11StreamingInstancedData)
{}

// Regression test for D3D11 streaming of GL_DYNAMIC_DRAW buffers not taking into account instanced
// attributes for buffer size calculations. http://crbug.com/1425606
TEST_P(InstancingTestES3, D3D11StreamingInstancedData2)
{}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST();
ANGLE_INSTANTIATE_TEST_ES3();

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST();
ANGLE_INSTANTIATE_TEST_ES31();

ANGLE_INSTANTIATE_TEST_ES2();