Hash :
b8d2664f
        
        Author :
  
        
        Date :
2017-10-27T18:14:14
        
      
Run angle_perftests on GLES backend Adds OPENGLES_NULL configuration and selects between OPENGL and OPENGLES based on whether building for Android. Also 2 small changes to get the newly enabled tests to pass on N5X: 1. Require GL_EXT_texture_storage in TexSubImage test 2. Limit numVertexUniforms and numFragmentUniforms to 64 in MatrixUniforms test BUG=675997 Change-Id: I5439e5fb7e93b3a928f12594761115d56f60d81b Reviewed-on: https://chromium-review.googlesource.com/748522 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PointSpritesBenchmark:
//   Performance test for ANGLE point sprites.
//
//
#include "ANGLEPerfTest.h"
#include <iostream>
#include <sstream>
#include "shader_utils.h"
#include "random_utils.h"
using namespace angle;
namespace
{
struct PointSpritesParams final : public RenderTestParams
{
    PointSpritesParams()
    {
        // Common default params
        majorVersion = 2;
        minorVersion = 0;
        windowWidth = 1280;
        windowHeight = 720;
        iterations   = 100;
        count = 10;
        size = 3.0f;
        numVaryings = 3;
    }
    std::string suffix() const override;
    unsigned int count;
    float size;
    unsigned int numVaryings;
    // static parameters
    unsigned int iterations;
};
std::ostream &operator<<(std::ostream &os, const PointSpritesParams ¶ms)
{
    os << params.suffix().substr(1);
    return os;
}
class PointSpritesBenchmark : public ANGLERenderTest,
                              public ::testing::WithParamInterface<PointSpritesParams>
{
  public:
    PointSpritesBenchmark();
    void initializeBenchmark() override;
    void destroyBenchmark() override;
    void drawBenchmark() override;
  private:
    GLuint mProgram;
    GLuint mBuffer;
    RNG mRNG;
};
std::string PointSpritesParams::suffix() const
{
    std::stringstream strstr;
    strstr << RenderTestParams::suffix()
           << "_" << count << "_" << size << "px"
           << "_" << numVaryings << "vars";
    return strstr.str();
}
PointSpritesBenchmark::PointSpritesBenchmark()
    : ANGLERenderTest("PointSprites", GetParam()), mRNG(1)
{
}
void PointSpritesBenchmark::initializeBenchmark()
{
    const auto ¶ms = GetParam();
    ASSERT_LT(0u, params.iterations);
    std::stringstream vstrstr;
    // Verify "numVaryings" is within MAX_VARYINGS limit
    GLint maxVaryings;
    glGetIntegerv(GL_MAX_VARYING_VECTORS, &maxVaryings);
    if (params.numVaryings > static_cast<unsigned int>(maxVaryings))
    {
        FAIL() << "Varying count (" << params.numVaryings << ")"
               << " exceeds maximum varyings: " << maxVaryings << std::endl;
    }
    vstrstr << "attribute vec2 vPosition;\n"
               "uniform float uPointSize;\n";
    for (unsigned int varCount = 0; varCount < params.numVaryings; varCount++)
    {
        vstrstr << "varying vec4 v" << varCount << ";\n";
    }
    vstrstr << "void main()\n"
               "{\n";
    for (unsigned int varCount = 0; varCount < params.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 < params.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 < params.numVaryings; varCount++)
    {
        fstrstr << "    colorOut.r += v" << varCount << ".r;\n";
    }
    fstrstr << "    gl_FragColor = colorOut;\n"
               "}\n";
    mProgram = CompileProgram(vstrstr.str(), fstrstr.str());
    ASSERT_NE(0u, mProgram);
    // Use the program object
    glUseProgram(mProgram);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    std::vector<float> vertexPositions(params.count * 2);
    for (size_t pointIndex = 0; pointIndex < vertexPositions.size(); ++pointIndex)
    {
        vertexPositions[pointIndex] = mRNG.randomNegativeOneToOne();
    }
    glGenBuffers(1, &mBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
    glBufferData(GL_ARRAY_BUFFER, vertexPositions.size() * sizeof(float), &vertexPositions[0], GL_STATIC_DRAW);
    GLint positionLocation = glGetAttribLocation(mProgram, "vPosition");
    ASSERT_NE(-1, positionLocation);
    glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
    glEnableVertexAttribArray(positionLocation);
    // Set the viewport
    glViewport(0, 0, getWindow()->getWidth(), getWindow()->getHeight());
    GLint pointSizeLocation = glGetUniformLocation(mProgram, "uPointSize");
    ASSERT_NE(-1, pointSizeLocation);
    glUniform1f(pointSizeLocation, params.size);
    ASSERT_GL_NO_ERROR();
}
void PointSpritesBenchmark::destroyBenchmark()
{
    glDeleteProgram(mProgram);
    glDeleteBuffers(1, &mBuffer);
}
void PointSpritesBenchmark::drawBenchmark()
{
    glClear(GL_COLOR_BUFFER_BIT);
    const auto ¶ms = GetParam();
    for (unsigned int it = 0; it < params.iterations; it++)
    {
        //TODO(jmadill): Indexed point rendering. ANGLE is bad at this.
        glDrawArrays(GL_POINTS, 0, params.count);
    }
    ASSERT_GL_NO_ERROR();
}
PointSpritesParams D3D11Params()
{
    PointSpritesParams params;
    params.eglParameters = egl_platform::D3D11();
    return params;
}
PointSpritesParams D3D9Params()
{
    PointSpritesParams params;
    params.eglParameters = egl_platform::D3D9();
    return params;
}
PointSpritesParams OpenGLOrGLESParams()
{
    PointSpritesParams params;
    params.eglParameters = egl_platform::OPENGL_OR_GLES(false);
    return params;
}
} // namespace
TEST_P(PointSpritesBenchmark, Run)
{
    run();
}
ANGLE_INSTANTIATE_TEST(PointSpritesBenchmark, D3D11Params(), D3D9Params(), OpenGLOrGLESParams());