X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-adaptor%2Fdali-test-suite-utils%2Ftest-gl-abstraction.h;h=8408b10b978b9c0f6b57ff16a9bbb58801329dcb;hb=4d39084cee39fd81526a2bb6894333b0d9ac001d;hp=fcc734aa436ffce6a359eba1eeda3bca3b8a9a57;hpb=ca814b1aabaa38d1a748114dfa326c7eafc7d282;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h index fcc734a..8408b10 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-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) 2017 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,15 +21,19 @@ // EXTERNAL INCLUDES #include #include +#include #include +#include +#include // for strcmp +#include // INTERNAL INCLUDES -#include - +#include #include #include #include -#include "test-trace-call-stack.h" +#include +#include namespace Dali { @@ -53,7 +57,7 @@ public: void Initialize(); void PreRender(); - void PostRender(unsigned int timeDelta); + void PostRender(); /* OpenGL ES 2.0 */ @@ -71,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 ) @@ -84,6 +92,8 @@ public: inline void BindFramebuffer( GLenum target, GLuint framebuffer ) { + //Add 010 bit; + mFramebufferStatus |= 2; } inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) @@ -137,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) @@ -213,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) @@ -238,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 { @@ -770,73 +990,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; } @@ -1522,6 +1916,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(); } @@ -1542,6 +1941,45 @@ 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 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 + { + 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 { @@ -1567,7 +2005,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 ) @@ -1587,7 +2025,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() ); } } } @@ -1620,8 +2058,6 @@ public: // TEST FUNCTIONS return false; } - - inline GLuint GetLastShaderCompiled() const { return mLastShaderCompiled; @@ -1632,6 +2068,11 @@ public: // TEST FUNCTIONS return mLastProgramIdUsed; } + inline GLbitfield GetLastClearMask() const + { + return mLastClearBitMask; + } + enum AttribType { ATTRIB_UNKNOWN = -1, @@ -1644,11 +2085,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; @@ -1661,14 +2141,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; @@ -1678,8 +2165,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; @@ -1692,10 +2182,14 @@ private: ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ]; TraceCallStack mCullFaceTrace; + TraceCallStack mEnableDisableTrace; TraceCallStack mShaderTrace; TraceCallStack mTextureTrace; TraceCallStack mTexParamaterTrace; TraceCallStack mDrawTrace; + TraceCallStack mDepthFunctionTrace; + TraceCallStack mStencilFunctionTrace; + TraceCallStack mSetUniformTrace; // Shaders & Uniforms GLuint mLastShaderIdUsed; @@ -1739,7 +2233,7 @@ private: T uniformValue; if ( GetUniformValue( program, uniform, uniformValue ) ) { - return value == uniformValue; + return CompareType(value, uniformValue, Math::MACHINE_EPSILON_10); } return false; @@ -1821,6 +2315,9 @@ private: mVertexAttribArrayState[ index ] = state; mVertexAttribArrayChanged = true; } + + ScissorParams mScissorParams; + ColorMaskParams mColorMaskParams; }; template <> @@ -1871,6 +2368,4 @@ bool BlendEnabled(const Dali::TraceCallStack& callStack); bool BlendDisabled(const Dali::TraceCallStack& callStack); - - -#endif // __TEST_GL_ES_H__ +#endif // TEST_GL_ABSTRACTION_H