Hash :
e10a4031
Author :
Date :
2021-09-08T15:57:00
Vulkan: Add a test to triger large VAO dirty bit handling. Some traces bind one VBO to a large number of VAOs,this will cause glBufferData spending a lot of time doing VAO dirty bit handling,which leads to high cpu load in these traces.This test could triger this issue. Bug: angleproject:6371 Change-Id: Iedc6630b497cb0f62ea0129aefc19c717c3ef905 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3147173 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Sunny Sun <sunny.sun@arm.com> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
//
// Copyright 2021 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.
//
// VertexArrayPerfTest:
// Performance test for glBindVertexArray.
//
#include "ANGLEPerfTest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
namespace
{
struct VertexArrayParams final : public RenderTestParams
{
VertexArrayParams()
{
iterationsPerStep = 1;
// Common default params
majorVersion = 3;
minorVersion = 0;
windowWidth = 720;
windowHeight = 720;
}
std::string story() const override;
};
std::ostream &operator<<(std::ostream &os, const VertexArrayParams ¶ms)
{
os << params.backendAndStory().substr(1);
return os;
}
std::string VertexArrayParams::story() const
{
std::stringstream strstr;
strstr << RenderTestParams::story();
return strstr.str();
}
class VertexArrayBenchmark : public ANGLERenderTest,
public ::testing::WithParamInterface<VertexArrayParams>
{
public:
VertexArrayBenchmark();
void initializeBenchmark() override;
void destroyBenchmark() override;
void drawBenchmark() override;
private:
GLBuffer mBuffer;
GLuint mProgram = 0;
GLint mAttribLocation = 0;
GLVertexArray vertexArrays[1000];
};
VertexArrayBenchmark::VertexArrayBenchmark() : ANGLERenderTest("VertexArrayPerf", GetParam()) {}
void VertexArrayBenchmark::initializeBenchmark()
{
constexpr char kVS[] = R"(attribute vec4 position;
attribute float in_attrib;
varying float v_attrib;
void main()
{
v_attrib = in_attrib;
gl_Position = position;
})";
constexpr char kFS[] = R"(precision mediump float;
varying float v_attrib;
void main()
{
gl_FragColor = vec4(v_attrib, 0, 0, 1);
})";
mProgram = CompileProgram(kVS, kFS);
ASSERT_NE(0u, mProgram);
mAttribLocation = glGetAttribLocation(mProgram, "in_attrib");
ASSERT_NE(mAttribLocation, -1);
}
void VertexArrayBenchmark::destroyBenchmark()
{
glDeleteProgram(mProgram);
}
void VertexArrayBenchmark::drawBenchmark()
{
// Bind one VBO to 1000 VAOs.
for (GLuint i = 0; i < 1000; i++)
{
glBindVertexArray(vertexArrays[i]);
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glEnableVertexAttribArray(mAttribLocation);
glVertexAttribPointer(mAttribLocation, 1, GL_FLOAT, GL_FALSE, 4, nullptr);
glVertexAttribDivisor(mAttribLocation, 1);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glBufferData(GL_ARRAY_BUFFER, 128, nullptr, GL_STATIC_DRAW);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
VertexArrayParams VulkanParams()
{
VertexArrayParams params;
params.eglParameters = egl_platform::VULKAN();
return params;
}
TEST_P(VertexArrayBenchmark, Run)
{
run();
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VertexArrayBenchmark);
ANGLE_INSTANTIATE_TEST(VertexArrayBenchmark, VulkanParams());
} // namespace