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=1613bb527d4293adead73e42a5d4335348adab89;hp=c17fa22ce7b554ce91035a8e4cdbad1970f56184;hb=5a2a5883422f4d114902ac57d57d7d1e973fbb2e;hpb=2371e4316b4b890bfec856a99344b50b08f3c920 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 c17fa22..1613bb5 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) 2016 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. @@ -21,14 +21,19 @@ // EXTERNAL INCLUDES #include #include +#include #include +#include +#include // for strcmp +#include // INTERNAL INCLUDES -#include #include #include #include -#include "test-trace-call-stack.h" +#include +#include +#include namespace Dali { @@ -52,7 +57,7 @@ public: void Initialize(); void PreRender(); - void PostRender(unsigned int timeDelta); + void PostRender(); /* OpenGL ES 2.0 */ @@ -70,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 ) @@ -83,6 +92,8 @@ public: inline void BindFramebuffer( GLenum target, GLuint framebuffer ) { + //Add 010 bit; + mFramebufferStatus |= 2; } inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) @@ -133,6 +144,15 @@ public: mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture ); } } + + std::stringstream out; + out << target << ", " << texture; + + 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) @@ -208,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) @@ -233,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 { @@ -747,58 +972,167 @@ public: } } + inline std::string GetShaderSource(GLuint shader) + { + return mShaderSources[shader]; + } + 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<<", "< + inline bool GetUniformValue( const char* name, T& value ) const + { + for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); + program_it != mUniforms.end(); + ++program_it ) + { + const UniformIDMap &uniformIDs = program_it->second; + + UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); + if( uniform_it != uniformIDs.end() ) + { + // found one matching uniform name, lets check the value... + GLuint programId = program_it->first; + GLint uniformId = uniform_it->second; + + const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( value ); + return mProgramUniforms.GetUniformValue( programId, uniformId, value ); + } + } + return false; + } + + template inline bool CheckUniformValue( const char* name, const T& value ) const { @@ -1529,7 +1908,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 ) @@ -1549,7 +1928,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() ); } } } @@ -1582,8 +1961,6 @@ public: // TEST FUNCTIONS return false; } - - inline GLuint GetLastShaderCompiled() const { return mLastShaderCompiled; @@ -1594,6 +1971,11 @@ public: // TEST FUNCTIONS return mLastProgramIdUsed; } + inline GLbitfield GetLastClearMask() const + { + return mLastClearBitMask; + } + enum AttribType { ATTRIB_UNKNOWN = -1, @@ -1606,11 +1988,50 @@ public: // TEST FUNCTIONS ATTRIB_TYPE_LAST }; + struct ScissorParams + { + GLint x; + GLint y; + GLsizei width; + GLsizei height; + + ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { } + }; + + // 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; @@ -1623,14 +2044,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; @@ -1640,6 +2068,8 @@ private: GLenum mLastBlendFuncSrcAlpha; GLenum mLastBlendFuncDstAlpha; + GLboolean mLastDepthMask; + // Data for manipulating the IDs returned by GenTextures GLuint mLastAutoTextureIdUsed; std::vector mNextTextureIds; @@ -1654,9 +2084,13 @@ private: ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ]; TraceCallStack mCullFaceTrace; + TraceCallStack mEnableDisableTrace; TraceCallStack mShaderTrace; TraceCallStack mTextureTrace; + TraceCallStack mTexParamaterTrace; TraceCallStack mDrawTrace; + TraceCallStack mDepthFunctionTrace; + TraceCallStack mStencilFunctionTrace; // Shaders & Uniforms GLuint mLastShaderIdUsed; @@ -1700,7 +2134,7 @@ private: T uniformValue; if ( GetUniformValue( program, uniform, uniformValue ) ) { - return value == uniformValue; + return CompareType(value, uniformValue, Math::MACHINE_EPSILON_10); } return false; @@ -1744,6 +2178,9 @@ private: ProgramUniformValue mProgramUniformsMat4; ProgramUniformValue mProgramUniformsMat3; + + + inline const ProgramUniformValue& GetProgramUniformsForType( const int ) const { return mProgramUniforms1i; @@ -1782,6 +2219,9 @@ private: mVertexAttribArrayState[ index ] = state; mVertexAttribArrayChanged = true; } + + ScissorParams mScissorParams; + ColorMaskParams mColorMaskParams; }; template <> @@ -1832,6 +2272,4 @@ bool BlendEnabled(const Dali::TraceCallStack& callStack); bool BlendDisabled(const Dali::TraceCallStack& callStack); - - -#endif // __TEST_GL_ES_H__ +#endif // TEST_GL_ABSTRACTION_H