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=dea1c9078ca1983aff2314e282dac575bbbc2754;hp=efd8a5b8e21db56e84b5dadf46208cb3519e2896;hb=75fdb5f9730fa6f6723c517691c9778fb646d082;hpb=d585c0f0d53c488eb5026d2e9c49e90698b20181 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 efd8a5b..dea1c90 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 @@ -22,11 +22,14 @@ #include #include #include +#include +#include // for strcmp // INTERNAL INCLUDES #include #include #include +#include #include "test-trace-call-stack.h" namespace Dali @@ -51,7 +54,7 @@ public: void Initialize(); void PreRender(); - void PostRender(unsigned int timeDelta); + void PostRender(); /* OpenGL ES 2.0 */ @@ -82,6 +85,8 @@ public: inline void BindFramebuffer( GLenum target, GLuint framebuffer ) { + //Add 010 bit; + mFramebufferStatus |= 2; } inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) @@ -132,6 +137,10 @@ public: mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture ); } } + + std::stringstream out; + out << target << ", " << texture; + mTextureTrace.PushCall("BindTexture", out.str()); } inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) @@ -207,19 +216,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) @@ -374,7 +409,7 @@ public: { std::stringstream out; out << cap; - mCullFaceTrace.PushCall("Disable", out.str()); + mEnableDisableTrace.PushCall("Disable", out.str()); } inline void DisableVertexAttribArray(GLuint index) @@ -400,7 +435,7 @@ public: { std::stringstream out; out << cap; - mCullFaceTrace.PushCall("Enable", out.str()); + mEnableDisableTrace.PushCall("Enable", out.str()); } inline void EnableVertexAttribArray(GLuint index) @@ -418,10 +453,26 @@ public: inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { + if (attachment == GL_DEPTH_ATTACHMENT) + { + mFramebufferDepthAttached = true; + } + else if (attachment == GL_STENCIL_ATTACHMENT) + { + mFramebufferStencilAttached = true; + } } inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { + //Add 100 bit; + mFramebufferStatus |= 4; + + //We check 4 attachment colors + if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4)) + { + mFramebufferColorAttached = true; + } } inline void FrontFace(GLenum mode) @@ -440,10 +491,21 @@ public: inline void GenFramebuffers(GLsizei n, GLuint* framebuffers) { + for( int i = 0; i < n; i++ ) + { + framebuffers[i] = i + 1; + } + + //Add 001 bit, this function needs to be called the first one in the chain + mFramebufferStatus = 1; } inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) { + for( int i = 0; i < n; i++ ) + { + renderbuffers[i] = i + 1; + } } /** @@ -474,6 +536,17 @@ public: *(textures+i) = ++mLastAutoTextureIdUsed; } } + + std::stringstream out; + for(int i=0; i + 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 { for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); @@ -1528,7 +1657,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 ) @@ -1548,7 +1677,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() ); } } } @@ -1581,8 +1710,6 @@ public: // TEST FUNCTIONS return false; } - - inline GLuint GetLastShaderCompiled() const { return mLastShaderCompiled; @@ -1593,6 +1720,11 @@ public: // TEST FUNCTIONS return mLastProgramIdUsed; } + inline GLbitfield GetLastClearMask() const + { + return mLastClearBitMask; + } + enum AttribType { ATTRIB_UNKNOWN = -1, @@ -1605,10 +1737,36 @@ 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; } + + inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; } + + inline unsigned int GetClearCountCalled() const { return mClearCount; } + + 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 mGetAttribLocationResult; GLenum mGetErrorResult; @@ -1622,14 +1780,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; @@ -1653,8 +1818,10 @@ private: ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ]; TraceCallStack mCullFaceTrace; + TraceCallStack mEnableDisableTrace; TraceCallStack mShaderTrace; TraceCallStack mTextureTrace; + TraceCallStack mTexParamaterTrace; TraceCallStack mDrawTrace; // Shaders & Uniforms @@ -1781,6 +1948,8 @@ private: mVertexAttribArrayState[ index ] = state; mVertexAttribArrayChanged = true; } + + ScissorParams mScissorParams; }; template <>