Hash :
ba319ba3
Author :
Date :
2018-12-29T10:29:33
Re-land "Load entry points dynamically in tests and samples." Fixes the Android/ChromeOS/Fuchsia builds by using consistent EGL headers. This CL adds a dynamic loader generator based on XML files. It also refactors the entry point generation script to move the XML parsing into a helper class. Additionally this includes a new GLES 1.0 base header. The new header allows for function pointer types and hiding prototypes. All tests and samples now load ANGLE dynamically. In the future this will be extended to load entry points from the driver directly when possible. This will allow us to perform more accurate A/B testing. The new build configuration leads to some tests having more warnings applied. The CL includes fixes for the new warnings. Bug: angleproject:2995 Change-Id: I5a8772f41a0f89570b3736b785f44b7de1539b57 Reviewed-on: https://chromium-review.googlesource.com/c/1392382 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: 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
//
// Copyright 2016 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.
//
// DynamicPromotionPerfTest:
// Tests that ANGLE will promote buffer specfied with DYNAMIC usage to static after a number of
// iterations without changing the data. It specifically affects the D3D back-end, which treats
// dynamic and static buffers quite differently.
//
#include "ANGLEPerfTest.h"
#include "common/vector_utils.h"
#include "util/random_utils.h"
#include "util/shader_utils.h"
using namespace angle;
namespace
{
constexpr unsigned int kIterationsPerStep = 4;
struct DynamicPromotionParams final : public RenderTestParams
{
DynamicPromotionParams() { iterationsPerStep = kIterationsPerStep; }
std::string suffix() const override;
size_t vertexCount = 1024;
};
std::string DynamicPromotionParams::suffix() const
{
return RenderTestParams::suffix();
}
std::ostream &operator<<(std::ostream &os, const DynamicPromotionParams ¶ms)
{
os << params.suffix().substr(1);
return os;
}
class DynamicPromotionPerfTest : public ANGLERenderTest,
public testing::WithParamInterface<DynamicPromotionParams>
{
public:
DynamicPromotionPerfTest();
void initializeBenchmark() override;
void destroyBenchmark() override;
void drawBenchmark() override;
private:
GLuint mProgram;
GLuint mElementArrayBuffer;
GLuint mArrayBuffer;
};
DynamicPromotionPerfTest::DynamicPromotionPerfTest()
: ANGLERenderTest("DynamicPromotion", GetParam()),
mProgram(0),
mElementArrayBuffer(0),
mArrayBuffer(0)
{}
void DynamicPromotionPerfTest::initializeBenchmark()
{
constexpr char kVertexShaderSource[] =
"attribute vec2 position;\n"
"attribute vec3 color;\n"
"varying vec3 vColor;\n"
"void main()\n"
"{\n"
" vColor = color;\n"
" gl_Position = vec4(position, 0, 1);\n"
"}";
constexpr char kFragmentShaderSource[] =
"varying mediump vec3 vColor;\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(vColor, 1);\n"
"}";
mProgram = CompileProgram(kVertexShaderSource, kFragmentShaderSource);
ASSERT_NE(0u, mProgram);
const size_t vertexCount = GetParam().vertexCount;
std::vector<GLushort> indexData;
std::vector<Vector2> positionData;
std::vector<Vector3> colorData;
ASSERT_GE(static_cast<size_t>(std::numeric_limits<GLushort>::max()), vertexCount);
RNG rng(1);
for (size_t index = 0; index < vertexCount; ++index)
{
indexData.push_back(static_cast<GLushort>(index));
Vector2 position(rng.randomNegativeOneToOne(), rng.randomNegativeOneToOne());
positionData.push_back(position);
Vector3 color(rng.randomFloat(), rng.randomFloat(), rng.randomFloat());
colorData.push_back(color);
}
glGenBuffers(1, &mElementArrayBuffer);
glGenBuffers(1, &mArrayBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mElementArrayBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mArrayBuffer);
GLsizeiptr elementArraySize = sizeof(GLushort) * vertexCount;
GLsizeiptr positionArraySize = sizeof(Vector2) * vertexCount;
GLsizeiptr colorArraySize = sizeof(Vector3) * vertexCount;
// The DYNAMIC_DRAW usage is the key to the test.
glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementArraySize, indexData.data(), GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, positionArraySize + colorArraySize, nullptr, GL_DYNAMIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, positionArraySize, positionData.data());
glBufferSubData(GL_ARRAY_BUFFER, positionArraySize, colorArraySize, colorData.data());
glUseProgram(mProgram);
GLint positionLocation = glGetAttribLocation(mProgram, "position");
ASSERT_NE(-1, positionLocation);
GLint colorLocation = glGetAttribLocation(mProgram, "color");
ASSERT_NE(-1, colorLocation);
glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
glVertexAttribPointer(colorLocation, 3, GL_FLOAT, GL_FALSE, 0,
reinterpret_cast<const void *>(positionArraySize));
glEnableVertexAttribArray(positionLocation);
glEnableVertexAttribArray(colorLocation);
ASSERT_GL_NO_ERROR();
}
void DynamicPromotionPerfTest::destroyBenchmark()
{
glDeleteProgram(mProgram);
glDeleteBuffers(1, &mElementArrayBuffer);
glDeleteBuffers(1, &mArrayBuffer);
}
void DynamicPromotionPerfTest::drawBenchmark()
{
unsigned int iterations = GetParam().iterationsPerStep;
size_t vertexCount = GetParam().vertexCount;
glClear(GL_COLOR_BUFFER_BIT);
for (unsigned int count = 0; count < iterations; ++count)
{
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(vertexCount), GL_UNSIGNED_SHORT, nullptr);
}
ASSERT_GL_NO_ERROR();
}
DynamicPromotionParams DynamicPromotionD3D11Params()
{
DynamicPromotionParams params;
params.eglParameters = egl_platform::D3D11();
return params;
}
DynamicPromotionParams DynamicPromotionD3D9Params()
{
DynamicPromotionParams params;
params.eglParameters = egl_platform::D3D9();
return params;
}
TEST_P(DynamicPromotionPerfTest, Run)
{
run();
}
ANGLE_INSTANTIATE_TEST(DynamicPromotionPerfTest,
DynamicPromotionD3D11Params(),
DynamicPromotionD3D9Params());
} // anonymous namespace