X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-gl-abstraction.h;h=6fc704972218b8f6d39a174bb11adafb6274d508;hp=9bed832bc2005f5a181f02e46d79ca57279b0419;hb=3fea156f024c5b2909e6a6aa9daaffd3767d7108;hpb=f871dce5373ce3d4f414963a68505eefc0d49cd2 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h index 9bed832..6fc7049 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h @@ -2,7 +2,7 @@ #define TEST_GL_ABSTRACTION_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,13 +25,16 @@ #include #include #include // for strcmp +#include // INTERNAL INCLUDES #include +#include #include #include #include -#include "test-trace-call-stack.h" +#include +#include namespace Dali { @@ -47,19 +50,23 @@ static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] = "aBoneIndices" // ATTRIB_BONE_INDICES }; -class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction +class DALI_CORE_API TestGlAbstraction: public Dali::Integration::GlAbstraction { public: TestGlAbstraction(); - ~TestGlAbstraction(); + ~TestGlAbstraction() override; void Initialize(); - void PreRender(); - void PostRender(); + void PreRender() override; + void PostRender() override; + + bool IsSurfacelessContextSupported() const override; + + bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const override; /* OpenGL ES 2.0 */ - inline void ActiveTexture( GLenum textureUnit ) + inline void ActiveTexture( GLenum textureUnit ) override { mActiveTextureUnit = textureUnit - GL_TEXTURE0; } @@ -69,7 +76,7 @@ public: return mActiveTextureUnit + GL_TEXTURE0; } - inline void AttachShader( GLuint program, GLuint shader ) + inline void AttachShader( GLuint program, GLuint shader ) override { std::stringstream out; out << program << ", " << shader; @@ -80,21 +87,21 @@ public: mShaderTrace.PushCall("AttachShader", out.str(), namedParams); } - inline void BindAttribLocation( GLuint program, GLuint index, const char* name ) + inline void BindAttribLocation( GLuint program, GLuint index, const char* name ) override { } - inline void BindBuffer( GLenum target, GLuint buffer ) + inline void BindBuffer( GLenum target, GLuint buffer ) override { } - inline void BindFramebuffer( GLenum target, GLuint framebuffer ) + inline void BindFramebuffer( GLenum target, GLuint framebuffer ) override { //Add 010 bit; mFramebufferStatus |= 2; } - inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) + inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) override { } @@ -130,7 +137,7 @@ public: } } - inline void BindTexture( GLenum target, GLuint texture ) + inline void BindTexture( GLenum target, GLuint texture ) override { // Record the bound textures for future checks if( texture ) @@ -153,7 +160,7 @@ public: mTextureTrace.PushCall("BindTexture", out.str(), namedParams); } - inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) + inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override { mLastBlendColor.r = red; mLastBlendColor.g = green; @@ -166,13 +173,13 @@ public: return mLastBlendColor; } - inline void BlendEquation( GLenum mode ) + inline void BlendEquation( GLenum mode ) override { mLastBlendEquationRgb = mode; mLastBlendEquationAlpha = mode; } - inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha ) + inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha ) override { mLastBlendEquationRgb = modeRgb; mLastBlendEquationAlpha = modeAlpha; @@ -188,7 +195,7 @@ public: return mLastBlendEquationAlpha; } - inline void BlendFunc(GLenum sfactor, GLenum dfactor) + inline void BlendFunc(GLenum sfactor, GLenum dfactor) override { mLastBlendFuncSrcRgb = sfactor; mLastBlendFuncDstRgb = dfactor; @@ -196,7 +203,7 @@ public: mLastBlendFuncDstAlpha = dfactor; } - inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) + inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) override { mLastBlendFuncSrcRgb = srcRGB; mLastBlendFuncDstRgb = dstRGB; @@ -224,17 +231,17 @@ public: return mLastBlendFuncDstAlpha; } - inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) + inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) override { mBufferDataCalls.push_back(size); } - inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) + inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) override { mBufferSubDataCalls.push_back(size); } - inline GLenum CheckFramebufferStatus(GLenum target) + inline GLenum CheckFramebufferStatus(GLenum target) override { //If it has the three last bits set to 1 - 111, then the three minimum functions to create a //Framebuffer texture have been called @@ -246,9 +253,9 @@ public: return mCheckFramebufferStatusResult; } - inline GLenum CheckFramebufferColorAttachment() + inline GLuint CheckFramebufferColorAttachmentCount() { - return mFramebufferColorAttached; + return mFramebufferColorAttachmentCount; } inline GLenum CheckFramebufferDepthAttachment() @@ -261,21 +268,30 @@ public: return mFramebufferStencilAttached; } - inline void Clear(GLbitfield mask) + inline void Clear(GLbitfield mask) override { mClearCount++; mLastClearBitMask = mask; } - inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) + inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override { + mLastClearColor.r = red; + mLastClearColor.g = green; + mLastClearColor.b = blue; + mLastClearColor.a = alpha; } - inline void ClearDepthf(GLclampf depth) + inline const Vector4& GetLastClearColor() const { + return mLastClearColor; } - inline void ClearStencil(GLint s) + inline void ClearDepthf(GLclampf depth) override + { + } + + inline void ClearStencil(GLint s) override { std::stringstream out; out << s; @@ -286,7 +302,7 @@ public: mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams ); } - inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) + inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) override { mColorMaskParams.red = red; mColorMaskParams.green = green; @@ -294,7 +310,7 @@ public: mColorMaskParams.alpha = alpha; } - inline void CompileShader(GLuint shader) + inline void CompileShader(GLuint shader) override { std::stringstream out; out << shader; @@ -304,7 +320,7 @@ public: mShaderTrace.PushCall("CompileShader", out.str(), namedParams); } - inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) + inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) override { std::stringstream out; out << target<<", "<= GL_COLOR_ATTACHMENT0) && (attachment < GL_COLOR_ATTACHMENT0 + Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS)) { - mFramebufferColorAttached = true; + uint8_t mask = 1 << (attachment - GL_COLOR_ATTACHMENT0); + if ((mFrameBufferColorStatus & mask) == 0) + { + mFrameBufferColorStatus |= mask; + ++mFramebufferColorAttachmentCount; + } } } - inline void FrontFace(GLenum mode) + inline void FrontFace(GLenum mode) override { } - inline void GenBuffers(GLsizei n, GLuint* buffers) + inline void GenBuffers(GLsizei n, GLuint* buffers) override { // avoids an assert in GpuBuffers *buffers = 1u; } - inline void GenerateMipmap(GLenum target) + inline void GenerateMipmap(GLenum target) override { std::stringstream out; out<second; } - inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) + inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) override { } - inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) + inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) override { } - inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) + inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) override { } - inline void Hint(GLenum target, GLenum mode) + inline void Hint(GLenum target, GLenum mode) override { } - inline GLboolean IsBuffer(GLuint buffer) + inline GLboolean IsBuffer(GLuint buffer) override { return mIsBufferResult; } - inline GLboolean IsEnabled(GLenum cap) + inline GLboolean IsEnabled(GLenum cap) override { return mIsEnabledResult; } - inline GLboolean IsFramebuffer(GLuint framebuffer) + inline GLboolean IsFramebuffer(GLuint framebuffer) override { return mIsFramebufferResult; } - inline GLboolean IsProgram(GLuint program) + inline GLboolean IsProgram(GLuint program) override { return mIsProgramResult; } - inline GLboolean IsRenderbuffer(GLuint renderbuffer) + inline GLboolean IsRenderbuffer(GLuint renderbuffer) override { return mIsRenderbufferResult; } - inline GLboolean IsShader(GLuint shader) + inline GLboolean IsShader(GLuint shader) override { return mIsShaderResult; } - inline GLboolean IsTexture(GLuint texture) + inline GLboolean IsTexture(GLuint texture) override { return mIsTextureResult; } - inline void LineWidth(GLfloat width) + inline void LineWidth(GLfloat width) override { } - inline void LinkProgram(GLuint program) + inline void LinkProgram(GLuint program) override { std::stringstream out; out << program; @@ -906,43 +939,52 @@ public: GetUniformLocation(program, "sGloss"); } - inline void PixelStorei(GLenum pname, GLint param) + inline void PixelStorei(GLenum pname, GLint param) override { } - inline void PolygonOffset(GLfloat factor, GLfloat units) + inline void PolygonOffset(GLfloat factor, GLfloat units) override { } - inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) + inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) override { } - inline void ReleaseShaderCompiler(void) + inline void ReleaseShaderCompiler(void) override { } - inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) override { } - inline void SampleCoverage(GLclampf value, GLboolean invert) + inline void SampleCoverage(GLclampf value, GLboolean invert) override { } - inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) + inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override { mScissorParams.x = x; mScissorParams.y = y; mScissorParams.width = width; mScissorParams.height = height; + + std::stringstream out; + out << x << ", " << y << ", " << width << ", " << height; + TraceCallStack::NamedParams namedParams; + namedParams["x"] = ToString( x ); + namedParams["y"] = ToString( y ); + namedParams["width"] = ToString( width ); + namedParams["height"] = ToString( height ); + mScissorTrace.PushCall( "Scissor", out.str(), namedParams ); } - inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) + inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) override { } - inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) + inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) override { std::string stringBuilder; for(int i = 0; i < count; ++i) @@ -953,7 +995,7 @@ public: mLastShaderCompiled = shader; } - inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) + inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) override { const std::string shaderSource = mShaderSources[shader]; const int shaderSourceLength = static_cast(shaderSource.length()); @@ -975,7 +1017,7 @@ public: return mShaderSources[shader]; } - inline void StencilFunc(GLenum func, GLint ref, GLuint mask) + inline void StencilFunc(GLenum func, GLint ref, GLuint mask) override { std::stringstream out; out << func << ", " << ref << ", " << mask; @@ -988,7 +1030,7 @@ public: mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams ); } - inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) + inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) override { std::stringstream out; out << face << ", " << func << ", " << ref << ", " << mask; @@ -1002,7 +1044,7 @@ public: mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams ); } - inline void StencilMask(GLuint mask) + inline void StencilMask(GLuint mask) override { std::stringstream out; out << mask; @@ -1013,7 +1055,7 @@ public: mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams ); } - inline void StencilMaskSeparate(GLenum face, GLuint mask) + inline void StencilMaskSeparate(GLenum face, GLuint mask) override { std::stringstream out; out << face << ", " << mask; @@ -1025,7 +1067,7 @@ public: mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams ); } - inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) + inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) override { std::stringstream out; out << fail << ", " << zfail << ", " << zpass; @@ -1038,7 +1080,7 @@ public: mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams ); } - inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) + inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) override { std::stringstream out; out << face << ", " << fail << ", " << zfail << "," << zpass; @@ -1052,7 +1094,7 @@ public: mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams ); } - inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) + inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) override { std::stringstream out; out << target<<", "<second == location ) + { + name = it->first; + matched = true; + break; + } + } + + if ( matched ) + { + mSetUniformTrace.PushCall( name, value ); + } + } + + public: // TEST FUNCTIONS inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; } inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; } @@ -1857,6 +1984,21 @@ public: // TEST FUNCTIONS inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); } inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; } + //Methods for Scissor verification + inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); } + inline void ResetScissorCallStack() { mScissorTrace.Reset(); } + inline TraceCallStack& GetScissorTrace() { return mScissorTrace; } + + //Methods for Uniform function verification + inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); } + inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); } + inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; } + + //Methods for Viewport verification + inline void EnableViewportCallTrace(bool enable) { mViewportTrace.Enable(enable); } + inline void ResetViewportCallStack() { mViewportTrace.Reset(); } + inline TraceCallStack& GetViewportTrace() { return mViewportTrace; } + template inline bool GetUniformValue( const char* name, T& value ) const { @@ -2043,9 +2185,10 @@ private: GLenum mActiveTextureUnit; GLenum mCheckFramebufferStatusResult; GLint mFramebufferStatus; - GLenum mFramebufferColorAttached; GLenum mFramebufferDepthAttached; GLenum mFramebufferStencilAttached; + GLuint mFramebufferColorAttachmentCount; + GLuint mFrameBufferColorStatus; GLint mNumBinaryFormats; GLint mBinaryFormats; GLint mProgramBinaryLength; @@ -2056,6 +2199,7 @@ private: ShaderSourceMap mShaderSources; GLuint mLastShaderCompiled; GLbitfield mLastClearBitMask; + Vector4 mLastClearColor; unsigned int mClearCount; Vector4 mLastBlendColor; @@ -2070,6 +2214,7 @@ private: // Data for manipulating the IDs returned by GenTextures GLuint mLastAutoTextureIdUsed; + GLuint mNumGeneratedTextures; std::vector mNextTextureIds; std::vector mDeletedTextureIds; std::vector mBoundTextures; @@ -2089,6 +2234,9 @@ private: TraceCallStack mDrawTrace; TraceCallStack mDepthFunctionTrace; TraceCallStack mStencilFunctionTrace; + TraceCallStack mScissorTrace; + TraceCallStack mSetUniformTrace; + TraceCallStack mViewportTrace; // Shaders & Uniforms GLuint mLastShaderIdUsed; @@ -2132,7 +2280,7 @@ private: T uniformValue; if ( GetUniformValue( program, uniform, uniformValue ) ) { - return value == uniformValue; + return CompareType(value, uniformValue, Math::MACHINE_EPSILON_10); } return false;