diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 18:11:13 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 18:11:13 +0200 |
commit | 4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch) | |
tree | f000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/tests/test_utils | |
parent | 3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff) | |
download | UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip |
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/tests/test_utils')
-rwxr-xr-x | gfx/angle/src/tests/test_utils/ANGLETest.cpp | 71 | ||||
-rwxr-xr-x | gfx/angle/src/tests/test_utils/ANGLETest.h | 45 | ||||
-rwxr-xr-x | gfx/angle/src/tests/test_utils/compiler_test.cpp | 98 | ||||
-rwxr-xr-x | gfx/angle/src/tests/test_utils/compiler_test.h | 29 | ||||
-rwxr-xr-x | gfx/angle/src/tests/test_utils/gl_raii.h | 1 |
5 files changed, 81 insertions, 163 deletions
diff --git a/gfx/angle/src/tests/test_utils/ANGLETest.cpp b/gfx/angle/src/tests/test_utils/ANGLETest.cpp index 77f1d8dec..1a9d8b50f 100755 --- a/gfx/angle/src/tests/test_utils/ANGLETest.cpp +++ b/gfx/angle/src/tests/test_utils/ANGLETest.cpp @@ -30,6 +30,8 @@ const GLColor GLColor::transparentBlack = GLColor(0u, 0u, 0u, 0u); const GLColor GLColor::white = GLColor(255u, 255u, 255u, 255u); const GLColor GLColor::yellow = GLColor(255u, 255u, 0, 255u); +const GLColor16 GLColor16::white = GLColor16(65535u, 65535u, 65535u, 65535u); + namespace { float ColorNorm(GLubyte channelValue) @@ -136,6 +138,14 @@ GLColor::GLColor(const Vector4 &floatColor) { } +GLColor::GLColor(const GLColor16 &color16) + : R(static_cast<GLubyte>(color16.R)), + G(static_cast<GLubyte>(color16.G)), + B(static_cast<GLubyte>(color16.B)), + A(static_cast<GLubyte>(color16.A)) +{ +} + GLColor::GLColor(GLuint colorValue) : R(0), G(0), B(0), A(0) { memcpy(&R, &colorValue, sizeof(GLuint)); @@ -167,6 +177,35 @@ std::ostream &operator<<(std::ostream &ostream, const GLColor &color) return ostream; } +GLColor16::GLColor16() : R(0), G(0), B(0), A(0) +{ +} + +GLColor16::GLColor16(GLushort r, GLushort g, GLushort b, GLushort a) : R(r), G(g), B(b), A(a) +{ +} + +GLColor16 ReadColor16(GLint x, GLint y) +{ + GLColor16 actual; + glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_SHORT, &actual.R); + EXPECT_GL_NO_ERROR(); + return actual; +} + +bool operator==(const GLColor16 &a, const GLColor16 &b) +{ + return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A; +} + +std::ostream &operator<<(std::ostream &ostream, const GLColor16 &color) +{ + ostream << "(" << static_cast<unsigned int>(color.R) << ", " + << static_cast<unsigned int>(color.G) << ", " << static_cast<unsigned int>(color.B) + << ", " << static_cast<unsigned int>(color.A) << ")"; + return ostream; +} + } // namespace angle // static @@ -549,14 +588,6 @@ bool ANGLETest::eglClientExtensionEnabled(const std::string &extName) return checkExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName); } -bool ANGLETest::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName) -{ - PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT = - reinterpret_cast<PFNEGLQUERYDEVICESTRINGEXTPROC>( - eglGetProcAddress("eglQueryDeviceStringEXT")); - return checkExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName); -} - void ANGLETest::setWindowWidth(int width) { mWidth = width; @@ -612,16 +643,6 @@ void ANGLETest::setNoErrorEnabled(bool enabled) mEGLWindow->setNoErrorEnabled(enabled); } -void ANGLETest::setWebGLCompatibilityEnabled(bool webglCompatibility) -{ - mEGLWindow->setWebGLCompatibilityEnabled(webglCompatibility); -} - -void ANGLETest::setBindGeneratesResource(bool bindGeneratesResource) -{ - mEGLWindow->setBindGeneratesResource(bindGeneratesResource); -} - int ANGLETest::getClientMajorVersion() const { return mEGLWindow->getClientMajorVersion(); @@ -794,20 +815,6 @@ bool IsWindows() #endif } -bool IsDebug() -{ -#if !defined(NDEBUG) - return true; -#else - return false; -#endif -} - -bool IsRelease() -{ - return !IsDebug(); -} - EGLint ANGLETest::getPlatformRenderer() const { assert(mEGLWindow); diff --git a/gfx/angle/src/tests/test_utils/ANGLETest.h b/gfx/angle/src/tests/test_utils/ANGLETest.h index a1bef48e6..b735887d6 100755 --- a/gfx/angle/src/tests/test_utils/ANGLETest.h +++ b/gfx/angle/src/tests/test_utils/ANGLETest.h @@ -59,11 +59,14 @@ struct GLColorRGB static const GLColorRGB yellow; }; +struct GLColor16; + struct GLColor { GLColor(); GLColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a); GLColor(const Vector4 &floatColor); + GLColor(const GLColor16 &color16); GLColor(GLuint colorValue); Vector4 toNormalizedVector() const; @@ -92,6 +95,28 @@ bool operator==(const GLColor &a, const GLColor &b); std::ostream &operator<<(std::ostream &ostream, const GLColor &color); GLColor ReadColor(GLint x, GLint y); +struct GLColor16 +{ + GLColor16(); + GLColor16(GLushort r, GLushort g, GLushort b, GLushort a); + + GLushort R, G, B, A; + + static const GLColor16 white; +}; + +// Useful to cast any type to GLushort. +template <typename TR, typename TG, typename TB, typename TA> +GLColor16 MakeGLColor16(TR r, TG g, TB b, TA a) +{ + return GLColor16(static_cast<GLushort>(r), static_cast<GLushort>(g), static_cast<GLushort>(b), + static_cast<GLushort>(a)); +} + +bool operator==(const GLColor16 &a, const GLColor16 &b); +std::ostream &operator<<(std::ostream &ostream, const GLColor16 &color); +GLColor16 ReadColor16(GLint x, GLint y); + } // namespace angle #define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \ @@ -116,6 +141,8 @@ GLColor ReadColor(GLint x, GLint y); #define EXPECT_PIXEL_COLOR_NEAR(x, y, angleColor, abs_error) \ EXPECT_PIXEL_NEAR(x, y, angleColor.R, angleColor.G, angleColor.B, angleColor.A, abs_error) +#define EXPECT_PIXEL_COLOR16_EQ(x, y, angleColor) EXPECT_EQ(angleColor, angle::ReadColor16(x, y)) + #define EXPECT_COLOR_NEAR(expected, actual, abs_error) \ \ { \ @@ -172,7 +199,6 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> static GLuint compileShader(GLenum type, const std::string &source); static bool extensionEnabled(const std::string &extName); static bool eglClientExtensionEnabled(const std::string &extName); - static bool eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName); void setWindowWidth(int width); void setWindowHeight(int height); @@ -185,8 +211,6 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> void setMultisampleEnabled(bool enabled); void setDebugEnabled(bool enabled); void setNoErrorEnabled(bool enabled); - void setWebGLCompatibilityEnabled(bool webglCompatibility); - void setBindGeneratesResource(bool bindGeneratesResource); int getClientMajorVersion() const; int getClientMinorVersion() const; @@ -253,22 +277,7 @@ bool IsLinux(); bool IsOSX(); bool IsWindows(); -// Debug/Release -bool IsDebug(); -bool IsRelease(); - // Negative tests may trigger expected errors/warnings in the ANGLE Platform. void IgnoreANGLEPlatformMessages(); -// Note: git cl format messes up this formatting. -#define ANGLE_SKIP_TEST_IF(COND) \ - \ -if(COND) \ - \ -{ \ - std::cout << "Test skipped: " #COND "." << std::endl; \ - return; \ - \ -} - #endif // ANGLE_TESTS_ANGLE_TEST_H_ diff --git a/gfx/angle/src/tests/test_utils/compiler_test.cpp b/gfx/angle/src/tests/test_utils/compiler_test.cpp index 873541ecd..ea758b893 100755 --- a/gfx/angle/src/tests/test_utils/compiler_test.cpp +++ b/gfx/angle/src/tests/test_utils/compiler_test.cpp @@ -11,79 +11,16 @@ #include "angle_gl.h" #include "compiler/translator/Compiler.h" -namespace sh -{ - -namespace -{ - -class ShaderVariableFinder : public TIntermTraverser -{ - public: - ShaderVariableFinder(const TString &variableName, TBasicType basicType) - : TIntermTraverser(true, false, false), - mVariableName(variableName), - mNodeFound(nullptr), - mBasicType(basicType) - { - } - - void visitSymbol(TIntermSymbol *node) - { - if (node->getBasicType() == mBasicType && node->getSymbol() == mVariableName) - { - mNodeFound = node; - } - } - - bool isFound() const { return mNodeFound != nullptr; } - const TIntermSymbol *getNode() const { return mNodeFound; } - - private: - TString mVariableName; - TIntermSymbol *mNodeFound; - TBasicType mBasicType; -}; - -class FunctionCallFinder : public TIntermTraverser -{ - public: - FunctionCallFinder(const TString &functionName) - : TIntermTraverser(true, false, false), mFunctionName(functionName), mNodeFound(nullptr) - { - } - - bool visitAggregate(Visit visit, TIntermAggregate *node) override - { - if (node->getOp() == EOpFunctionCall && - node->getFunctionSymbolInfo()->getName() == mFunctionName) - { - mNodeFound = node; - return false; - } - return true; - } - - bool isFound() const { return mNodeFound != nullptr; } - const TIntermAggregate *getNode() const { return mNodeFound; } - - private: - TString mFunctionName; - TIntermAggregate *mNodeFound; -}; - -} // anonymous namespace - bool compileTestShader(GLenum type, ShShaderSpec spec, ShShaderOutput output, const std::string &shaderString, ShBuiltInResources *resources, - ShCompileOptions compileOptions, + int compileOptions, std::string *translatedCode, std::string *infoLog) { - sh::TCompiler *translator = sh::ConstructCompiler(type, spec, output); + TCompiler *translator = ConstructCompiler(type, spec, output); if (!translator->Init(*resources)) { SafeDelete(translator); @@ -106,21 +43,21 @@ bool compileTestShader(GLenum type, ShShaderSpec spec, ShShaderOutput output, const std::string &shaderString, - ShCompileOptions compileOptions, + int compileOptions, std::string *translatedCode, std::string *infoLog) { ShBuiltInResources resources; - sh::InitBuiltInResources(&resources); + ShInitBuiltInResources(&resources); return compileTestShader(type, spec, output, shaderString, &resources, compileOptions, translatedCode, infoLog); } MatchOutputCodeTest::MatchOutputCodeTest(GLenum shaderType, - ShCompileOptions defaultCompileOptions, + int defaultCompileOptions, ShShaderOutput outputType) : mShaderType(shaderType), mDefaultCompileOptions(defaultCompileOptions) { - sh::InitBuiltInResources(&mResources); + ShInitBuiltInResources(&mResources); mOutputCode[outputType] = std::string(); } @@ -139,8 +76,7 @@ void MatchOutputCodeTest::compile(const std::string &shaderString) compile(shaderString, mDefaultCompileOptions); } -void MatchOutputCodeTest::compile(const std::string &shaderString, - const ShCompileOptions compileOptions) +void MatchOutputCodeTest::compile(const std::string &shaderString, const int compileOptions) { std::string infoLog; for (auto &code : mOutputCode) @@ -156,7 +92,7 @@ void MatchOutputCodeTest::compile(const std::string &shaderString, bool MatchOutputCodeTest::compileWithSettings(ShShaderOutput output, const std::string &shaderString, - const ShCompileOptions compileOptions, + const int compileOptions, std::string *translatedCode, std::string *infoLog) { @@ -236,21 +172,3 @@ bool MatchOutputCodeTest::notFoundInCode(const char *stringToFind) const } return true; } - -const TIntermSymbol *FindSymbolNode(TIntermNode *root, - const TString &symbolName, - TBasicType basicType) -{ - ShaderVariableFinder finder(symbolName, basicType); - root->traverse(&finder); - return finder.getNode(); -} - -const TIntermAggregate *FindFunctionCallNode(TIntermNode *root, const TString &functionName) -{ - FunctionCallFinder finder(functionName); - root->traverse(&finder); - return finder.getNode(); -} - -} // namespace sh diff --git a/gfx/angle/src/tests/test_utils/compiler_test.h b/gfx/angle/src/tests/test_utils/compiler_test.h index a0dd2d82a..3dd86b43c 100755 --- a/gfx/angle/src/tests/test_utils/compiler_test.h +++ b/gfx/angle/src/tests/test_utils/compiler_test.h @@ -11,21 +11,16 @@ #include <map> -#include "gtest/gtest.h" - #include "angle_gl.h" -#include "compiler/translator/TranslatorESSL.h" +#include "gtest/gtest.h" #include "GLSLANG/ShaderLang.h" -namespace sh -{ - bool compileTestShader(GLenum type, ShShaderSpec spec, ShShaderOutput output, const std::string &shaderString, ShBuiltInResources *resources, - ShCompileOptions compileOptions, + int compileOptions, std::string *translatedCode, std::string *infoLog); @@ -33,16 +28,14 @@ bool compileTestShader(GLenum type, ShShaderSpec spec, ShShaderOutput output, const std::string &shaderString, - ShCompileOptions compileOptions, + int compileOptions, std::string *translatedCode, std::string *infoLog); class MatchOutputCodeTest : public testing::Test { protected: - MatchOutputCodeTest(GLenum shaderType, - ShCompileOptions defaultCompileOptions, - ShShaderOutput outputType); + MatchOutputCodeTest(GLenum shaderType, int defaultCompileOptions, ShShaderOutput outputType); void addOutputType(const ShShaderOutput outputType); @@ -50,7 +43,7 @@ class MatchOutputCodeTest : public testing::Test // Compile functions clear any results from earlier calls to them. void compile(const std::string &shaderString); - void compile(const std::string &shaderString, const ShCompileOptions compileOptions); + void compile(const std::string &shaderString, const int compileOptions); bool foundInESSLCode(const char *stringToFind) const { @@ -81,23 +74,15 @@ class MatchOutputCodeTest : public testing::Test private: bool compileWithSettings(ShShaderOutput output, const std::string &shaderString, - ShCompileOptions compileOptions, + int compileOptions, std::string *translatedCode, std::string *infoLog); GLenum mShaderType; - ShCompileOptions mDefaultCompileOptions; + int mDefaultCompileOptions; ShBuiltInResources mResources; std::map<ShShaderOutput, std::string> mOutputCode; }; -const TIntermSymbol *FindSymbolNode(TIntermNode *root, - const TString &symbolName, - TBasicType basicType); - -// Returns a pointer to a function call node with a mangled name functionName. -const TIntermAggregate *FindFunctionCallNode(TIntermNode *root, const TString &functionName); -} - #endif // TESTS_TEST_UTILS_COMPILER_TEST_H_ diff --git a/gfx/angle/src/tests/test_utils/gl_raii.h b/gfx/angle/src/tests/test_utils/gl_raii.h index b42a56396..9adc0cf02 100755 --- a/gfx/angle/src/tests/test_utils/gl_raii.h +++ b/gfx/angle/src/tests/test_utils/gl_raii.h @@ -46,7 +46,6 @@ using GLBuffer = GLWrapper<glGenBuffers, glDeleteBuffers>; using GLTexture = GLWrapper<glGenTextures, glDeleteTextures>; using GLFramebuffer = GLWrapper<glGenFramebuffers, glDeleteFramebuffers>; using GLRenderbuffer = GLWrapper<glGenRenderbuffers, glDeleteRenderbuffers>; -using GLSampler = GLWrapper<glGenSamplers, glDeleteSamplers>; class GLProgram { |