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 @@
#include <cassert>
#include <sstream>
#include <iostream>
#include "shader_utils.h"
#include "random_utils.h"
......@@ -17,7 +18,8 @@ std::string PointSpritesParams::name() const
std::stringstream strstr;
strstr << "PointSprites - " << BenchmarkParams::name()
<< " - " << count << " sprites - size " << size;
<< " - " << count << " sprites - size " << size
<< " - " << numVaryings << " varyings";
return strstr.str();
}
......@@ -32,27 +34,61 @@ PointSpritesBenchmark::PointSpritesBenchmark(const PointSpritesParams &params)
bool PointSpritesBenchmark::initializeBenchmark()
{
const std::string vs = SHADER_SOURCE
(
attribute vec2 vPosition;
uniform float uPointSize;
void main()
{
gl_Position = vec4(vPosition, 0.0, 1.0);
gl_PointSize = uPointSize;
}
);
const std::string fs = SHADER_SOURCE
(
precision mediump float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
mProgram = CompileProgram(vs, fs);
std::stringstream vstrstr;
// Verify "numVaryings" is within MAX_VARYINGS limit
GLint maxVaryings;
glGetIntegerv(GL_MAX_VARYING_VECTORS, &maxVaryings);
if (mParams.numVaryings > static_cast<unsigned int>(maxVaryings))
{
std::cerr << "Varying count (" << mParams.numVaryings << ")"
<< " exceeds maximum varyings: " << maxVaryings << std::endl;
return false;
}
vstrstr << "attribute vec2 vPosition;\n"
"uniform float uPointSize;\n";
for (unsigned int varCount = 0; varCount < mParams.numVaryings; varCount++)
{
vstrstr << "varying vec4 v" << varCount << ";\n";
}
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)
{
return false;
......
......@@ -11,6 +11,7 @@ struct PointSpritesParams : public BenchmarkParams
unsigned int iterations;
unsigned int count;
float size;
unsigned int numVaryings;
virtual std::string name() const;
};
......
......@@ -112,6 +112,7 @@ int main(int argc, char **argv)
params.iterations = 10;
params.count = 10;
params.size = 3.0f;
params.numVaryings = 3;
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