1 #ifndef __TEST_GL_ABSTRACTION_H__
2 #define __TEST_GL_ABSTRACTION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
27 #include <dali/public-api/dali-core.h>
28 #include <dali/integration-api/core.h>
29 #include <dali/integration-api/gl-abstraction.h>
30 #include "test-trace-call-stack.h"
35 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
36 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
38 "aPosition", // ATTRIB_POSITION
39 "aNormal", // ATTRIB_NORMAL
40 "aTexCoord", // ATTRIB_TEXCOORD
41 "aColor", // ATTRIB_COLOR
42 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
43 "aBoneIndices" // ATTRIB_BONE_INDICES
46 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
54 void PostRender(unsigned int timeDelta);
58 inline void ActiveTexture( GLenum textureUnit )
60 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
63 inline GLenum GetActiveTextureUnit() const
65 return mActiveTextureUnit + GL_TEXTURE0;
68 inline void AttachShader( GLuint program, GLuint shader )
70 std::stringstream out;
71 out << program << ", " << shader;
72 mShaderTrace.PushCall("AttachShader", out.str());
75 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
79 inline void BindBuffer( GLenum target, GLuint buffer )
83 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
87 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
92 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
93 * @return A vector containing the IDs that were bound.
95 inline const std::vector<GLuint>& GetBoundTextures() const
97 return mBoundTextures;
101 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
102 * @param[in] activeTextureUnit The specific active texture unit.
103 * @return A vector containing the IDs that were bound.
105 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
107 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
111 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
113 inline void ClearBoundTextures()
115 mBoundTextures.clear();
117 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
119 mActiveTextures[ i ].mBoundTextures.clear();
123 inline void BindTexture( GLenum target, GLuint texture )
125 // Record the bound textures for future checks
128 mBoundTextures.push_back( texture );
130 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
132 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
137 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
139 mLastBlendColor.r = red;
140 mLastBlendColor.g = green;
141 mLastBlendColor.b = blue;
142 mLastBlendColor.a = alpha;
145 inline const Vector4& GetLastBlendColor() const
147 return mLastBlendColor;
150 inline void BlendEquation( GLenum mode )
152 mLastBlendEquationRgb = mode;
153 mLastBlendEquationAlpha = mode;
156 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
158 mLastBlendEquationRgb = modeRgb;
159 mLastBlendEquationAlpha = modeAlpha;
162 inline GLenum GetLastBlendEquationRgb() const
164 return mLastBlendEquationRgb;
167 inline GLenum GetLastBlendEquationAlpha() const
169 return mLastBlendEquationAlpha;
172 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
174 mLastBlendFuncSrcRgb = sfactor;
175 mLastBlendFuncDstRgb = dfactor;
176 mLastBlendFuncSrcAlpha = sfactor;
177 mLastBlendFuncDstAlpha = dfactor;
180 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
182 mLastBlendFuncSrcRgb = srcRGB;
183 mLastBlendFuncDstRgb = dstRGB;
184 mLastBlendFuncSrcAlpha = srcAlpha;
185 mLastBlendFuncDstAlpha = dstAlpha;
188 inline GLenum GetLastBlendFuncSrcRgb() const
190 return mLastBlendFuncSrcRgb;
193 inline GLenum GetLastBlendFuncDstRgb() const
195 return mLastBlendFuncDstRgb;
198 inline GLenum GetLastBlendFuncSrcAlpha() const
200 return mLastBlendFuncSrcAlpha;
203 inline GLenum GetLastBlendFuncDstAlpha() const
205 return mLastBlendFuncDstAlpha;
208 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
212 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
216 inline GLenum CheckFramebufferStatus(GLenum target)
218 return mCheckFramebufferStatusResult;
221 inline void Clear(GLbitfield mask)
225 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
229 inline void ClearDepthf(GLclampf depth)
233 inline void ClearStencil(GLint s)
237 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
241 inline void CompileShader(GLuint shader)
243 std::stringstream out;
245 mShaderTrace.PushCall("CompileShader", out.str());
248 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
252 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
256 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
260 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
264 inline GLuint CreateProgram(void)
266 mShaderTrace.PushCall("CreateProgram", "");
268 ++mLastProgramIdUsed;
269 mUniforms[mLastProgramIdUsed] = UniformIDMap();
270 return mLastProgramIdUsed;
273 inline GLuint CreateShader(GLenum type)
275 std::stringstream out;
277 mShaderTrace.PushCall("CreateShader", out.str());
279 return ++mLastShaderIdUsed;
282 inline void CullFace(GLenum mode)
284 std::stringstream out;
286 mCullFaceTrace.PushCall("CullFace", out.str());
289 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
293 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
297 inline void DeleteProgram(GLuint program)
299 std::stringstream out;
301 mShaderTrace.PushCall("DeleteProgram", out.str());
304 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
308 inline void DeleteShader(GLuint shader)
310 std::stringstream out;
312 mShaderTrace.PushCall("DeleteShader", out.str());
315 inline void DeleteTextures(GLsizei n, const GLuint* textures)
317 std::stringstream out;
318 out << n << ", " << textures << " = [" ;
320 for(GLsizei i=0; i<n; i++)
322 out << textures[i] << ", " ;
323 mDeletedTextureIds.push_back(textures[i]);
326 mTextureTrace.PushCall("DeleteTextures", out.str());
329 inline bool CheckNoTexturesDeleted()
331 return mDeletedTextureIds.size() == 0;
334 inline bool CheckTextureDeleted( GLuint textureId )
338 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
340 if(*iter == textureId)
349 inline void ClearDeletedTextures()
351 mDeletedTextureIds.clear();
354 inline void DepthFunc(GLenum func)
358 inline void DepthMask(GLboolean flag)
362 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
366 inline void DetachShader(GLuint program, GLuint shader)
368 std::stringstream out;
369 out << program << ", " << shader;
370 mShaderTrace.PushCall("DetachShader", out.str());
373 inline void Disable(GLenum cap)
375 std::stringstream out;
377 mCullFaceTrace.PushCall("Disable", out.str());
380 inline void DisableVertexAttribArray(GLuint index)
382 SetVertexAttribArray( index, false );
385 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
387 std::stringstream out;
388 out << mode << ", " << first << ", " << count;
389 mDrawTrace.PushCall("DrawArrays", out.str());
392 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
394 std::stringstream out;
395 out << mode << ", " << count << ", " << type << ", indices";
396 mDrawTrace.PushCall("DrawElements", out.str());
399 inline void Enable(GLenum cap)
401 std::stringstream out;
403 mCullFaceTrace.PushCall("Enable", out.str());
406 inline void EnableVertexAttribArray(GLuint index)
408 SetVertexAttribArray( index, true);
411 inline void Finish(void)
415 inline void Flush(void)
419 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
423 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
427 inline void FrontFace(GLenum mode)
431 inline void GenBuffers(GLsizei n, GLuint* buffers)
433 // avoids an assert in GpuBuffers
437 inline void GenerateMipmap(GLenum target)
441 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
445 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
450 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
451 * @param[in] ids A vector containing the next IDs to be generated
453 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
455 mNextTextureIds = ids;
458 inline const std::vector<GLuint>& GetNextTextureIds()
460 return mNextTextureIds;
463 inline void GenTextures(GLsizei n, GLuint* textures)
465 for( int i=0; i<n; ++i )
467 if( !mNextTextureIds.empty() )
469 *(textures+i) = mNextTextureIds[0];
470 mNextTextureIds.erase( mNextTextureIds.begin() );
474 *(textures+i) = ++mLastAutoTextureIdUsed;
479 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
483 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
487 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
491 inline int GetAttribLocation(GLuint program, const char* name)
493 std::string attribName(name);
495 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
497 if( mStdAttribs[i] == attribName )
503 // 0 is a valid location
507 inline void GetBooleanv(GLenum pname, GLboolean* params)
511 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
515 inline GLenum GetError(void)
517 return mGetErrorResult;
520 inline void GetFloatv(GLenum pname, GLfloat* params)
524 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
528 inline void GetIntegerv(GLenum pname, GLint* params)
532 case GL_MAX_TEXTURE_SIZE:
535 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
538 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
539 *params = mNumBinaryFormats;
541 case GL_PROGRAM_BINARY_FORMATS_OES:
542 *params = mBinaryFormats;
547 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
551 *params = mLinkStatus;
553 case GL_PROGRAM_BINARY_LENGTH_OES:
554 *params = mProgramBinaryLength;
559 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
564 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
568 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
571 case GL_COMPILE_STATUS:
572 *params = mCompileStatus;
577 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
581 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
585 inline const GLubyte* GetString(GLenum name)
587 return mGetStringResult;
590 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
594 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
598 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
602 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
606 inline GLint GetUniformLocation(GLuint program, const char* name)
608 ProgramUniformMap::iterator it = mUniforms.find(program);
609 if( it == mUniforms.end() )
611 // Not a valid program ID
612 mGetErrorResult = GL_INVALID_OPERATION;
616 UniformIDMap& uniformIDs = it->second;
617 UniformIDMap::iterator it2 = uniformIDs.find( name );
618 if( it2 == uniformIDs.end() )
620 // Uniform not found, so add it...
621 uniformIDs[name] = ++mLastUniformIdUsed;
622 return mLastUniformIdUsed;
628 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
632 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
636 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
640 inline void Hint(GLenum target, GLenum mode)
644 inline GLboolean IsBuffer(GLuint buffer)
646 return mIsBufferResult;
649 inline GLboolean IsEnabled(GLenum cap)
651 return mIsEnabledResult;
654 inline GLboolean IsFramebuffer(GLuint framebuffer)
656 return mIsFramebufferResult;
659 inline GLboolean IsProgram(GLuint program)
661 return mIsProgramResult;
664 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
666 return mIsRenderbufferResult;
669 inline GLboolean IsShader(GLuint shader)
671 return mIsShaderResult;
674 inline GLboolean IsTexture(GLuint texture)
676 return mIsTextureResult;
679 inline void LineWidth(GLfloat width)
683 inline void LinkProgram(GLuint program)
685 std::stringstream out;
687 mShaderTrace.PushCall("LinkProgram", out.str());
690 inline void PixelStorei(GLenum pname, GLint param)
694 inline void PolygonOffset(GLfloat factor, GLfloat units)
698 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
702 inline void ReleaseShaderCompiler(void)
706 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
710 inline void SampleCoverage(GLclampf value, GLboolean invert)
714 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
718 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
722 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
724 std::string stringBuilder;
725 for(int i = 0; i < count; ++i)
727 stringBuilder += string[i];
729 mShaderSources[shader] = stringBuilder;
730 mLastShaderCompiled = shader;
733 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
735 const std::string shaderSource = mShaderSources[shader];
736 if( static_cast<int>(shaderSource.length()) < bufsize )
738 strcpy(source, shaderSource.c_str());
739 *length = shaderSource.length();
743 *length = bufsize -1;
744 strncpy(source, shaderSource.c_str(), *length);
745 source[*length] = 0x0;
749 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
753 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
757 inline void StencilMask(GLuint mask)
761 inline void StencilMaskSeparate(GLenum face, GLuint mask)
765 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
769 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
773 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
775 std::stringstream out;
776 out << width << ", " << height;
777 mTextureTrace.PushCall("TexImage2D", out.str());
780 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
784 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
788 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
792 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
796 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
798 std::stringstream out;
799 out << xoffset << ", " << yoffset << ", " << width << ", " << height;
800 mTextureTrace.PushCall("TexSubImage2D", out.str());
803 inline void Uniform1f(GLint location, GLfloat x)
805 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
807 mGetErrorResult = GL_INVALID_OPERATION;
811 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
813 for( int i = 0; i < count; ++i )
815 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
817 mGetErrorResult = GL_INVALID_OPERATION;
823 inline void Uniform1i(GLint location, GLint x)
825 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
827 mGetErrorResult = GL_INVALID_OPERATION;
831 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
833 for( int i = 0; i < count; ++i )
835 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
839 mGetErrorResult = GL_INVALID_OPERATION;
845 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
847 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
851 mGetErrorResult = GL_INVALID_OPERATION;
855 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
857 for( int i = 0; i < count; ++i )
859 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
861 Vector2( v[2*i], v[2*i+1] ) ) )
863 mGetErrorResult = GL_INVALID_OPERATION;
869 inline void Uniform2i(GLint location, GLint x, GLint y)
873 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
877 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
879 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
881 Vector3( x, y, z ) ) )
883 mGetErrorResult = GL_INVALID_OPERATION;
887 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
889 for( int i = 0; i < count; ++i )
891 if( ! mProgramUniforms3f.SetUniformValue(
894 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
896 mGetErrorResult = GL_INVALID_OPERATION;
902 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
906 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
910 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
912 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
914 Vector4( x, y, z, w ) ) )
916 mGetErrorResult = GL_INVALID_OPERATION;
920 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
922 for( int i = 0; i < count; ++i )
924 if( ! mProgramUniforms4f.SetUniformValue(
927 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
929 mGetErrorResult = GL_INVALID_OPERATION;
935 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
939 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
943 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
947 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
949 for( int i = 0; i < count; ++i )
951 if( ! mProgramUniformsMat3.SetUniformValue(
954 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
956 mGetErrorResult = GL_INVALID_OPERATION;
962 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
964 for( int i = 0; i < count; ++i )
966 if( ! mProgramUniformsMat4.SetUniformValue(
971 mGetErrorResult = GL_INVALID_OPERATION;
977 inline void UseProgram(GLuint program)
979 mCurrentProgram = program;
982 inline void ValidateProgram(GLuint program)
986 inline void VertexAttrib1f(GLuint indx, GLfloat x)
990 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
994 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
998 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1002 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1006 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1010 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1014 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1018 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1022 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1028 inline void ReadBuffer(GLenum mode)
1032 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1036 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1040 inline void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
1044 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1048 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1052 inline void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
1056 inline void GenQueries(GLsizei n, GLuint* ids)
1060 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1064 inline GLboolean IsQuery(GLuint id)
1069 inline void BeginQuery(GLenum target, GLuint id)
1073 inline void EndQuery(GLenum target)
1077 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1081 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1085 inline GLboolean UnmapBuffer(GLenum target)
1090 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1094 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1098 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1102 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1106 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1110 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1114 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1118 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1122 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1126 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1130 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1134 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1139 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1143 inline void BindVertexArray(GLuint array)
1147 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1151 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1155 inline GLboolean IsVertexArray(GLuint array)
1160 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1164 inline void BeginTransformFeedback(GLenum primitiveMode)
1168 inline void EndTransformFeedback(void)
1172 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1176 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1180 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1184 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1188 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1192 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1196 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1200 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1204 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1208 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1212 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1216 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1220 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1225 inline void Uniform1ui(GLint location, GLuint v0)
1229 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1233 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1237 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1241 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1245 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1249 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1253 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1257 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1261 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1265 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1269 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1273 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1278 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1282 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1286 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1290 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1292 return GL_INVALID_INDEX;
1295 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1299 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1303 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1307 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1311 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1315 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1320 inline GLboolean IsSync(GLsync sync)
1325 inline void DeleteSync(GLsync sync)
1329 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1334 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1338 inline void GetInteger64v(GLenum pname, GLint64* params)
1342 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1346 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1350 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1354 inline void GenSamplers(GLsizei count, GLuint* samplers)
1358 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1362 inline GLboolean IsSampler(GLuint sampler)
1367 inline void BindSampler(GLuint unit, GLuint sampler)
1371 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1375 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1379 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1383 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1387 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1391 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1395 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1399 inline void BindTransformFeedback(GLenum target, GLuint id)
1403 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1407 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1411 inline GLboolean IsTransformFeedback(GLuint id)
1416 inline void PauseTransformFeedback(void)
1420 inline void ResumeTransformFeedback(void)
1424 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1428 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1432 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1436 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1440 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1444 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1448 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1452 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1456 public: // TEST FUNCTIONS
1457 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1458 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1459 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1460 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1461 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1462 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1463 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1464 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1465 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1466 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1467 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1468 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1469 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1470 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1471 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1472 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1474 inline bool GetVertexAttribArrayState(GLuint index)
1476 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1481 return mVertexAttribArrayState[ index ];
1483 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1484 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1486 //Methods for CullFace verification
1487 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1488 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1489 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1491 //Methods for Shader verification
1492 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1493 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1494 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1496 //Methods for Texture verification
1497 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1498 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1499 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1501 //Methods for Draw verification
1502 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1503 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1504 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1506 template <typename T>
1507 inline bool CheckUniformValue( const char* name, const T& value ) const
1509 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1510 program_it != mUniforms.end();
1513 const UniformIDMap &uniformIDs = program_it->second;
1515 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1516 if( uniform_it != uniformIDs.end() )
1518 // found one matching uniform name, lets check the value...
1519 GLuint programId = program_it->first;
1520 GLint uniformId = uniform_it->second;
1522 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1523 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1525 // the value matches
1531 fprintf(stderr, "Not found, printing possible values:" );
1532 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1533 program_it != mUniforms.end();
1536 const UniformIDMap &uniformIDs = program_it->second;
1538 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1539 if( uniform_it != uniformIDs.end() )
1541 // found one matching uniform name, lets check the value...
1542 GLuint programId = program_it->first;
1543 GLint uniformId = uniform_it->second;
1545 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1547 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1549 std::stringstream out;
1550 out << uniform_it->first << ": " << origValue;
1551 fprintf(stderr, "%s", out.str().c_str() );
1558 template <typename T>
1559 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1561 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1562 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1565 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1567 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1568 program_it != mUniforms.end();
1571 const UniformIDMap &uniformIDs = program_it->second;
1573 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1574 if( uniform_it != uniformIDs.end() )
1576 programId = program_it->first;
1577 uniformId = uniform_it->second;
1586 inline GLuint GetLastShaderCompiled() const
1588 return mLastShaderCompiled;
1591 inline GLuint GetLastProgramCreated() const
1593 return mLastProgramIdUsed;
1598 ATTRIB_UNKNOWN = -1,
1603 ATTRIB_BONE_WEIGHTS,
1604 ATTRIB_BONE_INDICES,
1610 GLuint mCurrentProgram;
1611 GLuint mCompileStatus;
1613 GLint mGetAttribLocationResult;
1614 GLenum mGetErrorResult;
1615 GLubyte* mGetStringResult;
1616 GLboolean mIsBufferResult;
1617 GLboolean mIsEnabledResult;
1618 GLboolean mIsFramebufferResult;
1619 GLboolean mIsProgramResult;
1620 GLboolean mIsRenderbufferResult;
1621 GLboolean mIsShaderResult;
1622 GLboolean mIsTextureResult;
1623 GLenum mActiveTextureUnit;
1624 GLenum mCheckFramebufferStatusResult;
1625 GLint mNumBinaryFormats;
1626 GLint mBinaryFormats;
1627 GLint mProgramBinaryLength;
1628 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1629 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1630 typedef std::map< GLuint, std::string> ShaderSourceMap;
1631 ShaderSourceMap mShaderSources;
1632 GLuint mLastShaderCompiled;
1634 Vector4 mLastBlendColor;
1635 GLenum mLastBlendEquationRgb;
1636 GLenum mLastBlendEquationAlpha;
1637 GLenum mLastBlendFuncSrcRgb;
1638 GLenum mLastBlendFuncDstRgb;
1639 GLenum mLastBlendFuncSrcAlpha;
1640 GLenum mLastBlendFuncDstAlpha;
1642 // Data for manipulating the IDs returned by GenTextures
1643 GLuint mLastAutoTextureIdUsed;
1644 std::vector<GLuint> mNextTextureIds;
1645 std::vector<GLuint> mDeletedTextureIds;
1646 std::vector<GLuint> mBoundTextures;
1648 struct ActiveTextureType
1650 std::vector<GLuint> mBoundTextures;
1653 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1655 TraceCallStack mCullFaceTrace;
1656 TraceCallStack mShaderTrace;
1657 TraceCallStack mTextureTrace;
1658 TraceCallStack mDrawTrace;
1660 // Shaders & Uniforms
1661 GLuint mLastShaderIdUsed;
1662 GLuint mLastProgramIdUsed;
1663 GLuint mLastUniformIdUsed;
1664 typedef std::map< std::string, GLint > UniformIDMap;
1665 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1666 ProgramUniformMap mUniforms;
1668 template <typename T>
1669 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1672 typedef std::map< GLint, T > UniformValueMap;
1673 typedef std::map< GLuint, UniformValueMap > Map;
1675 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1682 typename Map::iterator it = Map::find( program );
1683 if( it == Map::end() )
1685 // if its the first uniform for this program add it
1686 std::pair< typename Map::iterator, bool > result =
1687 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1691 UniformValueMap& uniforms = it->second;
1692 uniforms[uniform] = value;
1697 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1700 if ( GetUniformValue( program, uniform, uniformValue ) )
1702 return value == uniformValue;
1708 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1715 typename Map::const_iterator it = Map::find( program );
1716 if( it == Map::end() )
1718 // Uniform values always initialised as 0
1723 const UniformValueMap& uniforms = it->second;
1724 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1725 if( it2 == uniforms.end() )
1727 // Uniform values always initialised as 0
1731 value = it2->second;
1738 ProgramUniformValue<int> mProgramUniforms1i;
1739 ProgramUniformValue<float> mProgramUniforms1f;
1740 ProgramUniformValue<Vector2> mProgramUniforms2f;
1741 ProgramUniformValue<Vector3> mProgramUniforms3f;
1742 ProgramUniformValue<Vector4> mProgramUniforms4f;
1743 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1744 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1746 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1748 return mProgramUniforms1i;
1750 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1752 return mProgramUniforms1f;
1754 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1756 return mProgramUniforms2f;
1758 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1760 return mProgramUniforms3f;
1762 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1764 return mProgramUniforms4f;
1766 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1768 return mProgramUniformsMat4;
1770 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1772 return mProgramUniformsMat3;
1774 inline void SetVertexAttribArray(GLuint index, bool state)
1776 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1781 mVertexAttribArrayState[ index ] = state;
1782 mVertexAttribArrayChanged = true;
1787 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
1793 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
1799 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
1801 return Vector2::ZERO;
1805 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
1807 return Vector3::ZERO;
1811 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
1813 return Vector4::ZERO;
1817 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
1823 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
1825 return Matrix3( Matrix() );
1830 bool BlendEnabled(const Dali::TraceCallStack& callStack);
1831 bool BlendDisabled(const Dali::TraceCallStack& callStack);
1836 #endif // __TEST_GL_ES_H__