SampleApps: Refactor to use cli args the same way

Bug: angleproject:2669
Change-Id: Ica5b49e63e8af69595cdde3737b0aa1808d7d841
Reviewed-on: https://chromium-review.googlesource.com/1104377
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Luc Ferron <lucferron@chromium.org>
This commit is contained in:
Luc Ferron 2018-06-18 08:28:50 -04:00 коммит произвёл Commit Bot
Родитель 6ed167a99d
Коммит 17cee57247
22 изменённых файлов: 94 добавлений и 156 удалений

Просмотреть файл

@ -23,8 +23,8 @@
class FlatShadingSample : public SampleApplication
{
public:
FlatShadingSample(EGLint displayType)
: SampleApplication("FlatShadingSample", 1280, 720, 1, 0, displayType)
FlatShadingSample(int argc, char **argv)
: SampleApplication("FlatShadingSample", argc, argv, 1, 0)
{
}
@ -102,13 +102,6 @@ class FlatShadingSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
FlatShadingSample app(displayType);
FlatShadingSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -21,8 +21,8 @@
class GLES1HelloTriangleSample : public SampleApplication
{
public:
GLES1HelloTriangleSample(EGLint displayType)
: SampleApplication("GLES1HelloTriangle", 1280, 720, 1, 0, displayType)
GLES1HelloTriangleSample(int argc, char **argv)
: SampleApplication("GLES1HelloTriangle", argc, argv, 1, 0)
{
}
@ -55,13 +55,6 @@ class GLES1HelloTriangleSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
GLES1HelloTriangleSample app(displayType);
GLES1HelloTriangleSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -23,8 +23,8 @@
class SimpleLightingSample : public SampleApplication
{
public:
SimpleLightingSample(EGLint displayType)
: SampleApplication("SimpleLightingSample", 1280, 720, 1, 0, displayType)
SimpleLightingSample(int argc, char **argv)
: SampleApplication("SimpleLightingSample", argc, argv, 1, 0)
{
}
@ -112,13 +112,6 @@ class SimpleLightingSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
SimpleLightingSample app(displayType);
SimpleLightingSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -22,8 +22,8 @@
class GLES1SimpleTexture2DSample : public SampleApplication
{
public:
GLES1SimpleTexture2DSample(EGLint displayType)
: SampleApplication("GLES1SimpleTexture2D", 1280, 720, 1, 0, displayType)
GLES1SimpleTexture2DSample(int argc, char **argv)
: SampleApplication("GLES1SimpleTexture2D", argc, argv, 1, 0)
{
}
@ -82,13 +82,6 @@ class GLES1SimpleTexture2DSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
GLES1SimpleTexture2DSample app(displayType);
GLES1SimpleTexture2DSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -19,8 +19,8 @@
class HelloTriangleSample : public SampleApplication
{
public:
HelloTriangleSample(EGLint displayType)
: SampleApplication("HelloTriangle", 1280, 720, 2, 0, displayType)
HelloTriangleSample(int argc, char **argv)
: SampleApplication("HelloTriangle", argc, argv, 2, 0)
{
}
@ -87,13 +87,6 @@ class HelloTriangleSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
HelloTriangleSample app(displayType);
HelloTriangleSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -20,10 +20,7 @@
class MipMap2DSample : public SampleApplication
{
public:
MipMap2DSample()
: SampleApplication("MipMap2D", 1280, 720)
{
}
MipMap2DSample(int argc, char **argv) : SampleApplication("MipMap2D", argc, argv) {}
virtual bool initialize()
{
@ -160,6 +157,6 @@ class MipMap2DSample : public SampleApplication
int main(int argc, char **argv)
{
MipMap2DSample app;
MipMap2DSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -22,10 +22,7 @@
class MultiTextureSample : public SampleApplication
{
public:
MultiTextureSample()
: SampleApplication("MultiTexture", 1280, 720)
{
}
MultiTextureSample(int argc, char **argv) : SampleApplication("MultiTexture", argc, argv) {}
GLuint loadTexture(const std::string &path)
{
@ -171,6 +168,6 @@ class MultiTextureSample : public SampleApplication
int main(int argc, char **argv)
{
MultiTextureSample app;
MultiTextureSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -19,8 +19,8 @@ using namespace angle;
class MultiWindowSample : public SampleApplication
{
public:
MultiWindowSample()
: SampleApplication("MultiWindow", 256, 256)
MultiWindowSample(int argc, char **argv)
: SampleApplication("MultiWindow", argc, argv, 2, 0, 256, 256)
{
}
@ -193,6 +193,6 @@ class MultiWindowSample : public SampleApplication
int main(int argc, char **argv)
{
MultiWindowSample app;
MultiWindowSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -24,8 +24,8 @@
class MultipleDrawBuffersSample : public SampleApplication
{
public:
MultipleDrawBuffersSample()
: SampleApplication("MultipleDrawBuffers", 1280, 720)
MultipleDrawBuffersSample(int argc, char **argv)
: SampleApplication("MultipleDrawBuffers", argc, argv)
{
}
@ -221,6 +221,6 @@ class MultipleDrawBuffersSample : public SampleApplication
int main(int argc, char **argv)
{
MultipleDrawBuffersSample app;
MultipleDrawBuffersSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -42,8 +42,8 @@ void FillTranslationMatrix(float xOffset, float yOffset, float zOffset, float *m
class MultiviewSample : public SampleApplication
{
public:
MultiviewSample()
: SampleApplication("Multiview", 1280, 720, 3, 0),
MultiviewSample(int argc, char **argv)
: SampleApplication("Multiview", argc, argv, 3, 0),
mMultiviewProgram(0),
mMultiviewPersperiveUniformLoc(-1),
mMultiviewLeftEyeCameraUniformLoc(-1),
@ -377,6 +377,6 @@ class MultiviewSample : public SampleApplication
int main(int argc, char **argv)
{
MultiviewSample app;
MultiviewSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -29,10 +29,7 @@ using namespace angle;
class ParticleSystemSample : public SampleApplication
{
public:
ParticleSystemSample()
: SampleApplication("ParticleSystem", 1280, 720)
{
}
ParticleSystemSample(int argc, char **argv) : SampleApplication("ParticleSystem", argc, argv) {}
bool initialize() override
{
@ -224,6 +221,6 @@ class ParticleSystemSample : public SampleApplication
int main(int argc, char **argv)
{
ParticleSystemSample app;
ParticleSystemSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -25,10 +25,7 @@
class PostSubBufferSample : public SampleApplication
{
public:
PostSubBufferSample()
: SampleApplication("PostSubBuffer", 1280, 720)
{
}
PostSubBufferSample(int argc, char **argv) : SampleApplication("PostSubBuffer", argc, argv) {}
virtual bool initialize()
{
@ -169,6 +166,6 @@ class PostSubBufferSample : public SampleApplication
int main(int argc, char **argv)
{
PostSubBufferSample app;
PostSubBufferSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -10,27 +10,53 @@
#include "angle_gl.h"
#include <iostream>
#include <string.h>
#include <iostream>
#include <utility>
namespace
{
const char *kUseAngleArg = "--use-angle=";
using DisplayTypeInfo = std::pair<const char *, EGLint>;
const DisplayTypeInfo kDisplayTypes[] = {
{"d3d9", EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE}, {"d3d11", EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE},
{"gl", EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE}, {"gles", EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE},
{"null", EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE}, {"vulkan", EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE}};
EGLint GetDisplayTypeFromArg(const char *displayTypeArg)
{
for (const auto &displayTypeInfo : kDisplayTypes)
{
if (strcmp(displayTypeInfo.first, displayTypeArg) == 0)
{
std::cout << "Using ANGLE back-end API: " << displayTypeInfo.first << std::endl;
return displayTypeInfo.second;
}
}
std::cout << "Unknown ANGLE back-end API: " << displayTypeArg << std::endl;
return EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
}
} // anonymous namespace
SampleApplication::SampleApplication(const std::string &name,
size_t width,
size_t height,
SampleApplication::SampleApplication(std::string name,
int argc,
char **argv,
EGLint glesMajorVersion,
EGLint glesMinorVersion,
EGLint requestedRenderer)
: mName(name), mWidth(width), mHeight(height), mRunning(false)
size_t width,
size_t height)
: mName(std::move(name)), mWidth(width), mHeight(height), mRunning(false)
{
EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1 && strncmp(argv[1], kUseAngleArg, strlen(kUseAngleArg)) == 0)
{
requestedRenderer = GetDisplayTypeFromArg(argv[1] + strlen(kUseAngleArg));
}
mEGLWindow.reset(new EGLWindow(glesMajorVersion, glesMinorVersion,
EGLPlatformParameters(requestedRenderer)));
mTimer.reset(CreateTimer());
@ -170,18 +196,4 @@ void SampleApplication::exit()
bool SampleApplication::popEvent(Event *event)
{
return mOSWindow->popEvent(event);
}
EGLint GetDisplayTypeFromArg(const char *displayTypeArg)
{
for (const auto &displayTypeInfo : kDisplayTypes)
{
if (strcmp(displayTypeInfo.first, displayTypeArg) == 0)
{
return displayTypeInfo.second;
}
}
std::cout << "Unknown ANGLE back-end API: " << displayTypeArg << std::endl;
return EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
}
}

Просмотреть файл

@ -23,12 +23,13 @@ class EGLWindow;
class SampleApplication
{
public:
SampleApplication(const std::string &name,
size_t width,
size_t height,
EGLint glesMajorVersion = 2,
EGLint glesMinorVersion = 0,
EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
SampleApplication(std::string name,
int argc,
char **argv,
EGLint glesMajorVersion = 2,
EGLint glesMinorVersion = 0,
size_t width = 1280,
size_t height = 720);
virtual ~SampleApplication();
virtual bool initialize();
@ -61,6 +62,4 @@ class SampleApplication
std::unique_ptr<OSWindow> mOSWindow;
};
EGLint GetDisplayTypeFromArg(const char *displayTypeArg);
#endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H

Просмотреть файл

@ -28,8 +28,8 @@ using namespace angle;
class SimpleInstancingSample : public SampleApplication
{
public:
SimpleInstancingSample()
: SampleApplication("SimpleInstancing", 1280, 720)
SimpleInstancingSample(int argc, char **argv)
: SampleApplication("SimpleInstancing", argc, argv)
{
}
@ -197,6 +197,6 @@ class SimpleInstancingSample : public SampleApplication
int main(int argc, char **argv)
{
SimpleInstancingSample app;
SimpleInstancingSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -20,8 +20,7 @@
class SimpleTexture2DSample : public SampleApplication
{
public:
SimpleTexture2DSample(EGLint displayType)
: SampleApplication("SimpleTexture2D", 1280, 720, 2, 0, displayType)
SimpleTexture2DSample(int argc, char **argv) : SampleApplication("SimpleTexture2D", argc, argv)
{
}
@ -132,13 +131,6 @@ class SimpleTexture2DSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
SimpleTexture2DSample app(displayType);
SimpleTexture2DSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -21,8 +21,8 @@
class SimpleTextureCubemapSample : public SampleApplication
{
public:
SimpleTextureCubemapSample(EGLint displayType)
: SampleApplication("SimpleTextureCubemap", 1280, 720, 2, 0, displayType)
SimpleTextureCubemapSample(int argc, char **argv)
: SampleApplication("SimpleTextureCubemap", argc, argv)
{
}
@ -129,13 +129,6 @@ class SimpleTextureCubemapSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
SimpleTextureCubemapSample app(displayType);
SimpleTextureCubemapSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -25,8 +25,8 @@
class SimpleVertexShaderSample : public SampleApplication
{
public:
SimpleVertexShaderSample(EGLint displayType)
: SampleApplication("SimpleVertexShader", 1280, 720, 2, 0, displayType)
SimpleVertexShaderSample(int argc, char **argv)
: SampleApplication("SimpleVertexShader", argc, argv)
{
}
@ -144,13 +144,6 @@ class SimpleVertexShaderSample : public SampleApplication
int main(int argc, char **argv)
{
EGLint displayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
if (argc > 1)
{
displayType = GetDisplayTypeFromArg(argv[1]);
}
SimpleVertexShaderSample app(displayType);
SimpleVertexShaderSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -19,8 +19,8 @@
class StencilOperationsSample : public SampleApplication
{
public:
StencilOperationsSample()
: SampleApplication("StencilOperations", 1280, 720)
StencilOperationsSample(int argc, char **argv)
: SampleApplication("StencilOperations", argc, argv)
{
}
@ -233,6 +233,6 @@ class StencilOperationsSample : public SampleApplication
int main(int argc, char **argv)
{
StencilOperationsSample app;
StencilOperationsSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -46,8 +46,8 @@
class TexRedefBenchSample : public SampleApplication
{
public:
TexRedefBenchSample()
: SampleApplication("Microbench", 1280, 1280),
TexRedefBenchSample(int argc, char **argv)
: SampleApplication("Microbench", argc, argv, 2, 0, 1280, 1280),
mPixelsResize(nullptr),
mPixelsNewTex(nullptr),
mTimeFrame(false),
@ -272,6 +272,6 @@ class TexRedefBenchSample : public SampleApplication
int main(int argc, char **argv)
{
TexRedefBenchSample app;
TexRedefBenchSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -20,10 +20,7 @@
class TextureWrapSample : public SampleApplication
{
public:
TextureWrapSample()
: SampleApplication("TextureWrap", 1280, 720)
{
}
TextureWrapSample(int argc, char **argv) : SampleApplication("TextureWrap", argc, argv) {}
virtual bool initialize()
{
@ -151,6 +148,6 @@ private:
int main(int argc, char **argv)
{
TextureWrapSample app;
TextureWrapSample app(argc, argv);
return app.run();
}

Просмотреть файл

@ -27,9 +27,8 @@
class TriangleFanBenchSample : public SampleApplication
{
public:
TriangleFanBenchSample()
: SampleApplication("Microbench", 1280, 1280),
mFrameCount(0)
TriangleFanBenchSample(int argc, char **argv)
: SampleApplication("Microbench", argc, argv, 2, 0, 1280, 1280), mFrameCount(0)
{
}
@ -234,6 +233,6 @@ class TriangleFanBenchSample : public SampleApplication
int main(int argc, char **argv)
{
TriangleFanBenchSample app;
TriangleFanBenchSample app(argc, argv);
return app.run();
}