Vulkan: Update a test to triger large dirty bit handling

Some traces bind one VBO to a large number of VAOs,and use glBufferData
to change buffer size frequently,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: I99292825b8cb5bba58cc6b37e3baa7adcd02c780
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3301536
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Cheryl Wei 2021-11-25 13:37:58 +08:00 коммит произвёл Angle LUCI CQ
Родитель d3aa873cf6
Коммит 268653c987
1 изменённых файлов: 33 добавлений и 3 удалений

Просмотреть файл

@ -19,6 +19,7 @@ enum class TestMode
{
BufferData,
BindBuffer,
UpdateBufferData,
};
struct VertexArrayParams final : public RenderTestParams
@ -36,9 +37,10 @@ struct VertexArrayParams final : public RenderTestParams
std::string story() const override;
int numVertexArrays = 1000;
int numBuffers = 5;
TestMode testMode = TestMode::BufferData;
int numVertexArrays = 2000;
int numBuffers = 5;
GLuint bufferSize[5] = {384, 1028, 192, 384, 192};
TestMode testMode = TestMode::BufferData;
};
std::ostream &operator<<(std::ostream &os, const VertexArrayParams &params)
@ -57,6 +59,10 @@ std::string VertexArrayParams::story() const
{
strstr << "_bindbuffer";
}
else if (testMode == TestMode::UpdateBufferData)
{
strstr << "_updatebufferdata";
}
return strstr.str();
}
@ -72,6 +78,7 @@ class VertexArrayBenchmark : public ANGLERenderTest,
void drawBenchmark() override;
void rebindVertexArray(GLuint vertexArrayID, GLuint bufferID);
void updateBufferData(GLuint vertexArrayID, GLuint bufferID, GLuint bufferSize);
private:
std::vector<GLuint> mBuffers;
@ -137,6 +144,19 @@ void VertexArrayBenchmark::rebindVertexArray(GLuint vertexArrayID, GLuint buffer
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void VertexArrayBenchmark::updateBufferData(GLuint vertexArrayID,
GLuint bufferID,
GLuint bufferSize)
{
glBindVertexArray(vertexArrayID);
glBindBuffer(GL_ARRAY_BUFFER, bufferID);
glEnableVertexAttribArray(mAttribLocation);
glVertexAttribPointer(mAttribLocation, 1, GL_FLOAT, GL_FALSE, 4, nullptr);
glBufferData(GL_ARRAY_BUFFER, bufferSize, nullptr, GL_STATIC_DRAW);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void VertexArrayBenchmark::destroyBenchmark()
{
glDeleteProgram(mProgram);
@ -153,6 +173,15 @@ void VertexArrayBenchmark::drawBenchmark()
{
glBufferData(GL_ARRAY_BUFFER, 128, nullptr, GL_STATIC_DRAW);
}
else if (params.testMode == TestMode::UpdateBufferData)
{
int bufferSizeIndex = 0;
for (GLuint vertexArray : mVertexArrays)
{
bufferSizeIndex = ((bufferSizeIndex + 1) == 5) ? 0 : (bufferSizeIndex + 1);
updateBufferData(vertexArray, mBuffers[0], params.bufferSize[bufferSizeIndex]);
}
}
else
{
int bufferIndex = 0;
@ -189,5 +218,6 @@ ANGLE_INSTANTIATE_TEST(VertexArrayBenchmark,
VulkanParams(),
VulkanNullParams(TestMode::BindBuffer),
VulkanNullParams(TestMode::BufferData),
VulkanNullParams(TestMode::UpdateBufferData),
params::Native(VertexArrayParams()));
} // namespace