From 56554bdf9b456b4d4f967003cece5dad40bc3df2 Mon Sep 17 00:00:00 2001 From: David Fumanal Date: Tue, 7 Jul 2015 14:08:32 +0100 Subject: [PATCH] Automated test fix for framebuffer creation Change-Id: I8a16311b3bb98cb3813da3f6f2d9693f98ffe09a --- .../dali-test-suite-utils/test-gl-abstraction.cpp | 12 ++- .../dali-test-suite-utils/test-gl-abstraction.h | 112 ++++++++++++++++++++- 2 files changed, 119 insertions(+), 5 deletions(-) diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp index 49a49c5..97a5a06 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp @@ -46,9 +46,15 @@ void TestGlAbstraction::Initialize() mVertexAttribArrayChanged = false; mCheckFramebufferStatusResult = 0; - mNumBinaryFormats = 1; - mBinaryFormats = 1; + mFramebufferStatus = 0; + mFramebufferColorAttached = 0; + mFramebufferDepthAttached = 0; + mFramebufferStencilAttached = 0; + + mNumBinaryFormats = 0; + mBinaryFormats = 0; mProgramBinaryLength = 0; + mGetProgramBinaryCalled = false; mLastAutoTextureIdUsed = 0; @@ -56,6 +62,8 @@ void TestGlAbstraction::Initialize() mLastProgramIdUsed = 0; mLastUniformIdUsed = 0; mLastShaderCompiled = 0; + mLastClearBitMask = 0; + mClearCount = 0; mLastBlendEquationRgb = 0; mLastBlendEquationAlpha = 0; 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 b13fa59..7ca22a5 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 @@ -85,6 +85,8 @@ public: inline void BindFramebuffer( GLenum target, GLuint framebuffer ) { + //Add 010 bit; + mFramebufferStatus |= 2; } inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) @@ -214,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) @@ -425,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) @@ -447,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; + } } /** @@ -491,7 +546,7 @@ public: out << ", "; } } - mTextureTrace.PushCall("GenTexture", out.str()); + mTextureTrace.PushCall("GenTextures", out.str()); } inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) @@ -1462,6 +1517,7 @@ public: inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) { + mGetProgramBinaryCalled = true; } inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) @@ -1548,6 +1604,30 @@ public: // TEST FUNCTIONS inline TraceCallStack& GetDrawTrace() { return mDrawTrace; } 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 { for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); @@ -1572,7 +1652,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 ) @@ -1592,7 +1672,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() ); } } } @@ -1637,6 +1717,11 @@ public: // TEST FUNCTIONS return mLastProgramIdUsed; } + inline GLbitfield GetLastClearMask() const + { + return mLastClearBitMask; + } + enum AttribType { ATTRIB_UNKNOWN = -1, @@ -1662,9 +1747,23 @@ public: // TEST FUNCTIONS // 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; @@ -1678,14 +1777,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; -- 2.7.4