Commit bca88739 by Jamie Madill Committed by Commit Bot

Add a perf test that cycles through many VBOs.

Stresses the RenderPass buffer tracking in the Vulkan back-end. Bug: angleproject:4950 Change-Id: I33d38d8703d0e333d0092195d34228d90f1af52a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2358522Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 7870cf3f
...@@ -23,9 +23,12 @@ enum class StateChange ...@@ -23,9 +23,12 @@ enum class StateChange
ManyVertexBuffers, ManyVertexBuffers,
Texture, Texture,
Program, Program,
VertexBufferCycle,
InvalidEnum, InvalidEnum,
}; };
constexpr size_t kCycleVBOPoolSize = 200;
struct DrawArraysPerfParams : public DrawCallPerfParams struct DrawArraysPerfParams : public DrawCallPerfParams
{ {
DrawArraysPerfParams() = default; DrawArraysPerfParams() = default;
...@@ -59,6 +62,9 @@ std::string DrawArraysPerfParams::story() const ...@@ -59,6 +62,9 @@ std::string DrawArraysPerfParams::story() const
case StateChange::Program: case StateChange::Program:
strstr << "_prog_change"; strstr << "_prog_change";
break; break;
case StateChange::VertexBufferCycle:
strstr << "_vbo_cycle";
break;
default: default:
break; break;
} }
...@@ -122,6 +128,8 @@ class DrawCallPerfBenchmark : public ANGLERenderTest, ...@@ -122,6 +128,8 @@ class DrawCallPerfBenchmark : public ANGLERenderTest,
GLuint mTexture1 = 0; GLuint mTexture1 = 0;
GLuint mTexture2 = 0; GLuint mTexture2 = 0;
int mNumTris = GetParam().numTris; int mNumTris = GetParam().numTris;
std::vector<GLuint> mVBOPool;
size_t mCurrentVBO = 0;
}; };
DrawCallPerfBenchmark::DrawCallPerfBenchmark() : ANGLERenderTest("DrawCallPerf", GetParam()) {} DrawCallPerfBenchmark::DrawCallPerfBenchmark() : ANGLERenderTest("DrawCallPerf", GetParam()) {}
...@@ -176,6 +184,16 @@ void main() ...@@ -176,6 +184,16 @@ void main()
glEnableVertexAttribArray(3); glEnableVertexAttribArray(3);
glEnableVertexAttribArray(4); glEnableVertexAttribArray(4);
} }
else if (params.stateChange == StateChange::VertexBufferCycle)
{
mProgram1 = SetupSimpleDrawProgram();
for (size_t bufferIndex = 0; bufferIndex < kCycleVBOPoolSize; ++bufferIndex)
{
GLuint buffer = Create2DTriangleBuffer(mNumTris, GL_STATIC_DRAW);
mVBOPool.push_back(buffer);
}
}
else else
{ {
mProgram1 = SetupSimpleDrawProgram(); mProgram1 = SetupSimpleDrawProgram();
...@@ -247,6 +265,11 @@ void DrawCallPerfBenchmark::destroyBenchmark() ...@@ -247,6 +265,11 @@ void DrawCallPerfBenchmark::destroyBenchmark()
glDeleteTextures(1, &mTexture1); glDeleteTextures(1, &mTexture1);
glDeleteTextures(1, &mTexture2); glDeleteTextures(1, &mTexture2);
glDeleteFramebuffers(1, &mFBO); glDeleteFramebuffers(1, &mFBO);
if (!mVBOPool.empty())
{
glDeleteBuffers(mVBOPool.size(), mVBOPool.data());
}
} }
void ClearThenDraw(unsigned int iterations, GLsizei numElements) void ClearThenDraw(unsigned int iterations, GLsizei numElements)
...@@ -340,6 +363,21 @@ void ChangeProgramThenDraw(unsigned int iterations, ...@@ -340,6 +363,21 @@ void ChangeProgramThenDraw(unsigned int iterations,
} }
} }
void CycleVertexBufferThenDraw(unsigned int iterations,
GLsizei numElements,
const std::vector<GLuint> &vbos,
size_t *currentVBO)
{
for (unsigned int it = 0; it < iterations; it++)
{
GLuint vbo = vbos[*currentVBO];
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, numElements);
*currentVBO = (*currentVBO + 1) % vbos.size();
}
}
void DrawCallPerfBenchmark::drawBenchmark() void DrawCallPerfBenchmark::drawBenchmark()
{ {
// This workaround fixes a huge queue of graphics commands accumulating on the GL // This workaround fixes a huge queue of graphics commands accumulating on the GL
...@@ -380,6 +418,10 @@ void DrawCallPerfBenchmark::drawBenchmark() ...@@ -380,6 +418,10 @@ void DrawCallPerfBenchmark::drawBenchmark()
JustDraw(params.iterationsPerStep, numElements); JustDraw(params.iterationsPerStep, numElements);
} }
break; break;
case StateChange::VertexBufferCycle:
CycleVertexBufferThenDraw(params.iterationsPerStep, numElements, mVBOPool,
&mCurrentVBO);
break;
case StateChange::InvalidEnum: case StateChange::InvalidEnum:
FAIL() << "Invalid state change."; FAIL() << "Invalid state change.";
break; break;
...@@ -399,6 +441,13 @@ DrawArraysPerfParams CombineStateChange(const DrawArraysPerfParams &in, StateCha ...@@ -399,6 +441,13 @@ DrawArraysPerfParams CombineStateChange(const DrawArraysPerfParams &in, StateCha
{ {
DrawArraysPerfParams out = in; DrawArraysPerfParams out = in;
out.stateChange = stateChange; out.stateChange = stateChange;
// Crank up iteration count to ensure we cycle through all VBs before a swap.
if (stateChange == StateChange::VertexBufferCycle)
{
out.iterationsPerStep = kCycleVBOPoolSize * 2;
}
return out; return out;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment