Commit 431cbc8e by Jamie Madill

Benchmark point sprites test with several varyings.

A potential performance slowdown could be our geometry shader using extra logic in packing varyings. Test this by adding a variable number of varyings to the point sprites benchmark. Initial tests show it could slow down the test by about 30-40% or so, stil not catastrophic compared to D3D9. BUG=angle:705 Change-Id: Ia815f0ee28e2af2d3dc4d9f5675c27bbeb4cb119 Reviewed-on: https://chromium-review.googlesource.com/216468Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ea0e8733
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <iostream>
#include "shader_utils.h" #include "shader_utils.h"
#include "random_utils.h" #include "random_utils.h"
...@@ -17,7 +18,8 @@ std::string PointSpritesParams::name() const ...@@ -17,7 +18,8 @@ std::string PointSpritesParams::name() const
std::stringstream strstr; std::stringstream strstr;
strstr << "PointSprites - " << BenchmarkParams::name() strstr << "PointSprites - " << BenchmarkParams::name()
<< " - " << count << " sprites - size " << size; << " - " << count << " sprites - size " << size
<< " - " << numVaryings << " varyings";
return strstr.str(); return strstr.str();
} }
...@@ -32,27 +34,61 @@ PointSpritesBenchmark::PointSpritesBenchmark(const PointSpritesParams &params) ...@@ -32,27 +34,61 @@ PointSpritesBenchmark::PointSpritesBenchmark(const PointSpritesParams &params)
bool PointSpritesBenchmark::initializeBenchmark() bool PointSpritesBenchmark::initializeBenchmark()
{ {
const std::string vs = SHADER_SOURCE std::stringstream vstrstr;
(
attribute vec2 vPosition; // Verify "numVaryings" is within MAX_VARYINGS limit
uniform float uPointSize; GLint maxVaryings;
void main() glGetIntegerv(GL_MAX_VARYING_VECTORS, &maxVaryings);
{
gl_Position = vec4(vPosition, 0.0, 1.0); if (mParams.numVaryings > static_cast<unsigned int>(maxVaryings))
gl_PointSize = uPointSize; {
} std::cerr << "Varying count (" << mParams.numVaryings << ")"
); << " exceeds maximum varyings: " << maxVaryings << std::endl;
return false;
const std::string fs = SHADER_SOURCE }
(
precision mediump float; vstrstr << "attribute vec2 vPosition;\n"
void main() "uniform float uPointSize;\n";
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); for (unsigned int varCount = 0; varCount < mParams.numVaryings; varCount++)
} {
); vstrstr << "varying vec4 v" << varCount << ";\n";
}
mProgram = CompileProgram(vs, fs);
vstrstr << "void main()\n"
"{\n";
for (unsigned int varCount = 0; varCount < mParams.numVaryings; varCount++)
{
vstrstr << " v" << varCount << " = vec4(1.0);\n";
}
vstrstr << " gl_Position = vec4(vPosition, 0, 1.0);\n"
" gl_PointSize = uPointSize;\n"
"}";
std::stringstream fstrstr;
fstrstr << "precision mediump float;\n";
for (unsigned int varCount = 0; varCount < mParams.numVaryings; varCount++)
{
fstrstr << "varying vec4 v" << varCount << ";\n";
}
fstrstr << "void main()\n"
"{\n"
" vec4 colorOut = vec4(1.0, 0.0, 0.0, 1.0);\n";
for (unsigned int varCount = 0; varCount < mParams.numVaryings; varCount++)
{
fstrstr << " colorOut.r += v" << varCount << ".r;\n";
}
fstrstr << " gl_FragColor = colorOut;\n"
"}\n";
mProgram = CompileProgram(vstrstr.str(), fstrstr.str());
if (!mProgram) if (!mProgram)
{ {
return false; return false;
......
...@@ -11,6 +11,7 @@ struct PointSpritesParams : public BenchmarkParams ...@@ -11,6 +11,7 @@ struct PointSpritesParams : public BenchmarkParams
unsigned int iterations; unsigned int iterations;
unsigned int count; unsigned int count;
float size; float size;
unsigned int numVaryings;
virtual std::string name() const; virtual std::string name() const;
}; };
......
...@@ -112,6 +112,7 @@ int main(int argc, char **argv) ...@@ -112,6 +112,7 @@ int main(int argc, char **argv)
params.iterations = 10; params.iterations = 10;
params.count = 10; params.count = 10;
params.size = 3.0f; params.size = 3.0f;
params.numVaryings = 3;
pointSpriteParams.push_back(params); pointSpriteParams.push_back(params);
} }
......
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