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=c68573b03af0f01786ab5fac32a829ebbe308c23;hp=516b3661757cd7311a348e8901388e2b9ef3757e;hb=908670e8d7b3447b5201a7f9118cca881cf0a41e;hpb=6e44b7e1d2a1ba9f24fb48751e8969eb63cfa716 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 516b366..c68573b 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 @@ -1,8 +1,8 @@ -#ifndef __TEST_GL_ABSTRACTION_H__ -#define __TEST_GL_ABSTRACTION_H__ +#ifndef TEST_GL_ABSTRACTION_H +#define TEST_GL_ABSTRACTION_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,18 +19,21 @@ */ // EXTERNAL INCLUDES -#include // fprintf #include #include -#include // for strcpy, strncpy +#include #include +#include +#include // for strcmp +#include // INTERNAL INCLUDES #include #include #include #include -#include "test-trace-call-stack.h" +#include +#include namespace Dali { @@ -46,7 +49,7 @@ 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(); @@ -54,7 +57,7 @@ public: void Initialize(); void PreRender(); - void PostRender(unsigned int timeDelta); + void PostRender(); /* OpenGL ES 2.0 */ @@ -72,7 +75,11 @@ public: { std::stringstream out; out << program << ", " << shader; - mShaderTrace.PushCall("AttachShader", out.str()); + + TraceCallStack::NamedParams namedParams; + namedParams["program"] = ToString(program); + namedParams["shader"] = ToString(shader); + mShaderTrace.PushCall("AttachShader", out.str(), namedParams); } inline void BindAttribLocation( GLuint program, GLuint index, const char* name ) @@ -85,6 +92,8 @@ public: inline void BindFramebuffer( GLenum target, GLuint framebuffer ) { + //Add 010 bit; + mFramebufferStatus |= 2; } inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) @@ -138,7 +147,12 @@ public: std::stringstream out; out << target << ", " << texture; - mTextureTrace.PushCall("BindTexture", out.str()); + + TraceCallStack::NamedParams namedParams; + namedParams["target"] = ToString(target); + namedParams["texture"] = ToString(texture); + + mTextureTrace.PushCall("BindTexture", out.str(), namedParams); } inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) @@ -214,19 +228,45 @@ public: inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) { + mBufferDataCalls.push_back(size); } inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + mBufferSubDataCalls.push_back(size); } inline GLenum CheckFramebufferStatus(GLenum target) { + //If it has the three last bits set to 1 - 111, then the three minimum functions to create a + //Framebuffer texture have been called + if( mFramebufferStatus == 7 ) + { + return GL_FRAMEBUFFER_COMPLETE; + } + return mCheckFramebufferStatusResult; } + inline GLenum CheckFramebufferColorAttachment() + { + return mFramebufferColorAttached; + } + + inline GLenum CheckFramebufferDepthAttachment() + { + return mFramebufferDepthAttached; + } + + inline GLenum CheckFramebufferStencilAttachment() + { + return mFramebufferStencilAttached; + } + inline void Clear(GLbitfield mask) { + mClearCount++; + mLastClearBitMask = mask; } inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) @@ -239,25 +279,63 @@ public: inline void ClearStencil(GLint s) { + std::stringstream out; + out << s; + + TraceCallStack::NamedParams namedParams; + namedParams["s"] = ToString( s ); + + mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams ); } inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + mColorMaskParams.red = red; + mColorMaskParams.green = green; + mColorMaskParams.blue = blue; + mColorMaskParams.alpha = alpha; } inline void CompileShader(GLuint shader) { std::stringstream out; out << shader; - mShaderTrace.PushCall("CompileShader", out.str()); + TraceCallStack::NamedParams namedParams; + namedParams["shader"] = ToString(shader); + + 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) { + std::stringstream out; + out << target<<", "<(shaderSource.length()) < bufsize ) + const int shaderSourceLength = static_cast(shaderSource.length()); + if( shaderSourceLength < bufsize ) { - strcpy(source, shaderSource.c_str()); - *length = shaderSource.length(); + strncpy( source, shaderSource.c_str(), shaderSourceLength ); + *length = shaderSourceLength; } else { @@ -775,73 +999,168 @@ public: inline void StencilFunc(GLenum func, GLint ref, GLuint mask) { + std::stringstream out; + out << func << ", " << ref << ", " << mask; + + TraceCallStack::NamedParams namedParams; + namedParams["func"] = ToString( func ); + namedParams["ref"] = ToString( ref ); + namedParams["mask"] = ToString( mask ); + + mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams ); } inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { + std::stringstream out; + out << face << ", " << func << ", " << ref << ", " << mask; + + TraceCallStack::NamedParams namedParams; + namedParams["face"] = ToString( face ); + namedParams["func"] = ToString( func ); + namedParams["ref"] = ToString( ref ); + namedParams["mask"] = ToString( mask ); + + mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams ); } inline void StencilMask(GLuint mask) { + std::stringstream out; + out << mask; + + TraceCallStack::NamedParams namedParams; + namedParams["mask"] = ToString( mask ); + + mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams ); } inline void StencilMaskSeparate(GLenum face, GLuint mask) { + std::stringstream out; + out << face << ", " << mask; + + TraceCallStack::NamedParams namedParams; + namedParams["face"] = ToString( face ); + namedParams["mask"] = ToString( mask ); + + mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams ); } inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + std::stringstream out; + out << fail << ", " << zfail << ", " << zpass; + + TraceCallStack::NamedParams namedParams; + namedParams["fail"] = ToString( fail ); + namedParams["zfail"] = ToString( zfail ); + namedParams["zpass"] = ToString( zpass ); + + mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams ); } inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { + std::stringstream out; + out << face << ", " << fail << ", " << zfail << "," << zpass; + + TraceCallStack::NamedParams namedParams; + namedParams["face"] = ToString( face ); + namedParams["fail"] = ToString( fail ); + namedParams["zfail"] = ToString( zfail ); + namedParams["zpass"] = ToString( zpass ); + + 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) { std::stringstream out; - out << width << ", " << height; - mTextureTrace.PushCall("TexImage2D", out.str()); + 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; } @@ -1527,6 +1925,11 @@ public: // TEST FUNCTIONS inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); } inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; } + //Methods for Enable/Disable call verification + inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); } + inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); } + inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; } + //Methods for Shader verification inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); } inline void ResetShaderCallStack() { mShaderTrace.Reset(); } @@ -1547,6 +1950,26 @@ public: // TEST FUNCTIONS inline void ResetDrawCallStack() { mDrawTrace.Reset(); } inline TraceCallStack& GetDrawTrace() { return mDrawTrace; } + //Methods for Depth function verification + inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); } + inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); } + inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; } + + //Methods for Stencil function verification + inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); } + 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; } + template inline bool GetUniformValue( const char* name, T& value ) const { @@ -1596,7 +2019,7 @@ public: // TEST FUNCTIONS } } - fprintf(stderr, "Not found, printing possible values:" ); + fprintf(stderr, "Not found, printing possible values:\n" ); for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); program_it != mUniforms.end(); ++program_it ) @@ -1616,7 +2039,7 @@ public: // TEST FUNCTIONS { std::stringstream out; out << uniform_it->first << ": " << origValue; - fprintf(stderr, "%s", out.str().c_str() ); + fprintf(stderr, "%s\n", out.str().c_str() ); } } } @@ -1649,8 +2072,6 @@ public: // TEST FUNCTIONS return false; } - - inline GLuint GetLastShaderCompiled() const { return mLastShaderCompiled; @@ -1661,6 +2082,11 @@ public: // TEST FUNCTIONS return mLastProgramIdUsed; } + inline GLbitfield GetLastClearMask() const + { + return mLastClearBitMask; + } + enum AttribType { ATTRIB_UNKNOWN = -1, @@ -1686,10 +2112,37 @@ public: // TEST FUNCTIONS // Methods to check scissor tests inline const ScissorParams& GetScissorParams() const { return mScissorParams; } + struct ColorMaskParams + { + GLboolean red; + GLboolean green; + GLboolean blue; + GLboolean alpha; + + ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { } + }; + + inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; } + + inline unsigned int GetClearCountCalled() const { return mClearCount; } + + inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; } + + typedef std::vector BufferDataCalls; + inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; } + inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); } + + typedef std::vector BufferSubDataCalls; + inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; } + inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); } + private: GLuint mCurrentProgram; GLuint mCompileStatus; + BufferDataCalls mBufferDataCalls; + BufferSubDataCalls mBufferSubDataCalls; GLuint mLinkStatus; + GLint mNumberOfActiveUniforms; GLint mGetAttribLocationResult; GLenum mGetErrorResult; GLubyte* mGetStringResult; @@ -1702,14 +2155,21 @@ private: GLboolean mIsTextureResult; GLenum mActiveTextureUnit; GLenum mCheckFramebufferStatusResult; + GLint mFramebufferStatus; + GLenum mFramebufferColorAttached; + GLenum mFramebufferDepthAttached; + GLenum mFramebufferStencilAttached; GLint mNumBinaryFormats; GLint mBinaryFormats; GLint mProgramBinaryLength; bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE]; bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed + bool mGetProgramBinaryCalled; typedef std::map< GLuint, std::string> ShaderSourceMap; ShaderSourceMap mShaderSources; GLuint mLastShaderCompiled; + GLbitfield mLastClearBitMask; + unsigned int mClearCount; Vector4 mLastBlendColor; GLenum mLastBlendEquationRgb; @@ -1719,8 +2179,11 @@ private: GLenum mLastBlendFuncSrcAlpha; GLenum mLastBlendFuncDstAlpha; + GLboolean mLastDepthMask; + // Data for manipulating the IDs returned by GenTextures GLuint mLastAutoTextureIdUsed; + GLuint mNumGeneratedTextures; std::vector mNextTextureIds; std::vector mDeletedTextureIds; std::vector mBoundTextures; @@ -1733,10 +2196,15 @@ private: ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ]; TraceCallStack mCullFaceTrace; + TraceCallStack mEnableDisableTrace; TraceCallStack mShaderTrace; TraceCallStack mTextureTrace; TraceCallStack mTexParamaterTrace; TraceCallStack mDrawTrace; + TraceCallStack mDepthFunctionTrace; + TraceCallStack mStencilFunctionTrace; + TraceCallStack mScissorTrace; + TraceCallStack mSetUniformTrace; // Shaders & Uniforms GLuint mLastShaderIdUsed; @@ -1780,7 +2248,7 @@ private: T uniformValue; if ( GetUniformValue( program, uniform, uniformValue ) ) { - return value == uniformValue; + return CompareType(value, uniformValue, Math::MACHINE_EPSILON_10); } return false; @@ -1864,6 +2332,7 @@ private: } ScissorParams mScissorParams; + ColorMaskParams mColorMaskParams; }; template <> @@ -1914,6 +2383,4 @@ bool BlendEnabled(const Dali::TraceCallStack& callStack); bool BlendDisabled(const Dali::TraceCallStack& callStack); - - -#endif // __TEST_GL_ES_H__ +#endif // TEST_GL_ABSTRACTION_H