Commit 257b9ad9 by Shahbaz Youssefi Committed by Commit Bot

Add a perf test for scissored draw calls

Bug: angleproject:4988 Change-Id: I59facc66aaa2af216d3a6c6ef1e4efa934a45cb8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2506779Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 39b777c6
...@@ -24,6 +24,7 @@ enum class StateChange ...@@ -24,6 +24,7 @@ enum class StateChange
Texture, Texture,
Program, Program,
VertexBufferCycle, VertexBufferCycle,
Scissor,
InvalidEnum, InvalidEnum,
}; };
...@@ -65,6 +66,9 @@ std::string DrawArraysPerfParams::story() const ...@@ -65,6 +66,9 @@ std::string DrawArraysPerfParams::story() const
case StateChange::VertexBufferCycle: case StateChange::VertexBufferCycle:
strstr << "_vbo_cycle"; strstr << "_vbo_cycle";
break; break;
case StateChange::Scissor:
strstr << "_scissor_change";
break;
default: default:
break; break;
} }
...@@ -378,6 +382,90 @@ void CycleVertexBufferThenDraw(unsigned int iterations, ...@@ -378,6 +382,90 @@ void CycleVertexBufferThenDraw(unsigned int iterations,
} }
} }
void ChangeScissorThenDraw(unsigned int iterations,
GLsizei numElements,
unsigned int windowWidth,
unsigned int windowHeight)
{
// Change scissor as such:
//
// - Start with a narrow vertical bar:
//
// Scissor
// |
// V
// +-----+-+-----+
// | | | | <-- Window
// | | | |
// | | | |
// | | | |
// | | | |
// | | | |
// +-----+-+-----+
//
// - Gradually reduce height and increase width, to end up with a narrow horizontal bar:
//
// +-------------+
// | |
// | |
// +-------------+ <-- Scissor
// +-------------+
// | |
// | |
// +-------------+
//
// - If more iterations left, restart, but shift the initial bar left to cover more area:
//
// +---+-+-------+ +-------------+
// | | | | | |
// | | | | +-------------+
// | | | | ---> | |
// | | | | | |
// | | | | +-------------+
// | | | | | |
// +---+-+-------+ +-------------+
//
// +-+-+---------+ +-------------+
// | | | | +-------------+
// | | | | | |
// | | | | ---> | |
// | | | | | |
// | | | | | |
// | | | | +-------------+
// +-+-+---------+ +-------------+
glEnable(GL_SCISSOR_TEST);
constexpr unsigned int kScissorStep = 2;
unsigned int scissorX = windowWidth / 2 - 1;
unsigned int scissorY = 0;
unsigned int scissorWidth = 2;
unsigned int scissorHeight = windowHeight;
unsigned int scissorPatternIteration = 0;
for (unsigned int it = 0; it < iterations; it++)
{
glScissor(scissorX, scissorY, scissorWidth, scissorHeight);
glDrawArrays(GL_TRIANGLES, 0, numElements);
if (scissorX < kScissorStep || scissorHeight < kScissorStep * 2)
{
++scissorPatternIteration;
scissorX = windowWidth / 2 - 1 - scissorPatternIteration * 2;
scissorY = 0;
scissorWidth = 2;
scissorHeight = windowHeight;
}
else
{
scissorX -= kScissorStep;
scissorY += kScissorStep;
scissorWidth += kScissorStep * 2;
scissorHeight -= kScissorStep * 2;
}
}
}
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
...@@ -422,6 +510,10 @@ void DrawCallPerfBenchmark::drawBenchmark() ...@@ -422,6 +510,10 @@ void DrawCallPerfBenchmark::drawBenchmark()
CycleVertexBufferThenDraw(params.iterationsPerStep, numElements, mVBOPool, CycleVertexBufferThenDraw(params.iterationsPerStep, numElements, mVBOPool,
&mCurrentVBO); &mCurrentVBO);
break; break;
case StateChange::Scissor:
ChangeScissorThenDraw(params.iterationsPerStep, numElements, getWindow()->getWidth(),
getWindow()->getHeight());
break;
case StateChange::InvalidEnum: case StateChange::InvalidEnum:
FAIL() << "Invalid state change."; FAIL() << "Invalid state change.";
break; break;
......
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