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-capi-internal.h>
28 #include <dali/public-api/dali-core.h>
29 #include <dali/integration-api/core.h>
30 #include <dali/integration-api/gl-abstraction.h>
31 #include "test-trace-call-stack.h"
36 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
37 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
39 "aPosition", // ATTRIB_POSITION
40 "aNormal", // ATTRIB_NORMAL
41 "aTexCoord", // ATTRIB_TEXCOORD
42 "aColor", // ATTRIB_COLOR
43 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
44 "aBoneIndices" // ATTRIB_BONE_INDICES
47 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
55 void PostRender(unsigned int timeDelta);
59 inline void ActiveTexture( GLenum textureUnit )
61 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
64 inline GLenum GetActiveTextureUnit() const
66 return mActiveTextureUnit + GL_TEXTURE0;
69 inline void AttachShader( GLuint program, GLuint shader )
71 std::stringstream out;
72 out << program << ", " << shader;
73 mShaderTrace.PushCall("AttachShader", out.str());
76 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
80 inline void BindBuffer( GLenum target, GLuint buffer )
84 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
88 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
93 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
94 * @return A vector containing the IDs that were bound.
96 inline const std::vector<GLuint>& GetBoundTextures() const
98 return mBoundTextures;
102 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
103 * @param[in] activeTextureUnit The specific active texture unit.
104 * @return A vector containing the IDs that were bound.
106 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
108 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
112 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
114 inline void ClearBoundTextures()
116 mBoundTextures.clear();
118 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
120 mActiveTextures[ i ].mBoundTextures.clear();
124 inline void BindTexture( GLenum target, GLuint texture )
126 // Record the bound textures for future checks
129 mBoundTextures.push_back( texture );
131 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
133 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
138 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
140 mLastBlendColor.r = red;
141 mLastBlendColor.g = green;
142 mLastBlendColor.b = blue;
143 mLastBlendColor.a = alpha;
146 inline const Vector4& GetLastBlendColor() const
148 return mLastBlendColor;
151 inline void BlendEquation( GLenum mode )
153 mLastBlendEquationRgb = mode;
154 mLastBlendEquationAlpha = mode;
157 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
159 mLastBlendEquationRgb = modeRgb;
160 mLastBlendEquationAlpha = modeAlpha;
163 inline GLenum GetLastBlendEquationRgb() const
165 return mLastBlendEquationRgb;
168 inline GLenum GetLastBlendEquationAlpha() const
170 return mLastBlendEquationAlpha;
173 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
175 mLastBlendFuncSrcRgb = sfactor;
176 mLastBlendFuncDstRgb = dfactor;
177 mLastBlendFuncSrcAlpha = sfactor;
178 mLastBlendFuncDstAlpha = dfactor;
181 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
183 mLastBlendFuncSrcRgb = srcRGB;
184 mLastBlendFuncDstRgb = dstRGB;
185 mLastBlendFuncSrcAlpha = srcAlpha;
186 mLastBlendFuncDstAlpha = dstAlpha;
189 inline GLenum GetLastBlendFuncSrcRgb() const
191 return mLastBlendFuncSrcRgb;
194 inline GLenum GetLastBlendFuncDstRgb() const
196 return mLastBlendFuncDstRgb;
199 inline GLenum GetLastBlendFuncSrcAlpha() const
201 return mLastBlendFuncSrcAlpha;
204 inline GLenum GetLastBlendFuncDstAlpha() const
206 return mLastBlendFuncDstAlpha;
209 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
213 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
217 inline GLenum CheckFramebufferStatus(GLenum target)
219 return mCheckFramebufferStatusResult;
222 inline void Clear(GLbitfield mask)
226 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
230 inline void ClearDepthf(GLclampf depth)
234 inline void ClearStencil(GLint s)
238 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
242 inline void CompileShader(GLuint shader)
244 std::stringstream out;
246 mShaderTrace.PushCall("CompileShader", out.str());
249 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
253 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
257 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
261 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
265 inline GLuint CreateProgram(void)
267 mShaderTrace.PushCall("CreateProgram", "");
269 ++mLastProgramIdUsed;
270 mUniforms[mLastProgramIdUsed] = UniformIDMap();
271 return mLastProgramIdUsed;
274 inline GLuint CreateShader(GLenum type)
276 std::stringstream out;
278 mShaderTrace.PushCall("CreateShader", out.str());
280 return ++mLastShaderIdUsed;
283 inline void CullFace(GLenum mode)
285 std::stringstream out;
287 mCullFaceTrace.PushCall("CullFace", out.str());
290 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
294 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
298 inline void DeleteProgram(GLuint program)
300 std::stringstream out;
302 mShaderTrace.PushCall("DeleteProgram", out.str());
305 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
309 inline void DeleteShader(GLuint shader)
311 std::stringstream out;
313 mShaderTrace.PushCall("DeleteShader", out.str());
316 inline void DeleteTextures(GLsizei n, const GLuint* textures)
318 std::stringstream out;
319 out << n << ", " << textures << " = [" ;
321 for(GLsizei i=0; i<n; i++)
323 out << textures[i] << ", " ;
324 mDeletedTextureIds.push_back(textures[i]);
327 mTextureTrace.PushCall("DeleteTextures", out.str());
330 inline bool CheckNoTexturesDeleted()
332 return mDeletedTextureIds.size() == 0;
335 inline bool CheckTextureDeleted( GLuint textureId )
339 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
341 if(*iter == textureId)
350 inline void ClearDeletedTextures()
352 mDeletedTextureIds.clear();
355 inline void DepthFunc(GLenum func)
359 inline void DepthMask(GLboolean flag)
363 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
367 inline void DetachShader(GLuint program, GLuint shader)
369 std::stringstream out;
370 out << program << ", " << shader;
371 mShaderTrace.PushCall("DetachShader", out.str());
374 inline void Disable(GLenum cap)
376 std::stringstream out;
378 mCullFaceTrace.PushCall("Disable", out.str());
381 inline void DisableVertexAttribArray(GLuint index)
383 SetVertexAttribArray( index, false );
386 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
388 std::stringstream out;
389 out << mode << ", " << first << ", " << count;
390 mDrawTrace.PushCall("DrawArrays", out.str());
393 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
395 std::stringstream out;
396 out << mode << ", " << count << ", " << type << ", indices";
397 mDrawTrace.PushCall("DrawElements", out.str());
400 inline void Enable(GLenum cap)
402 std::stringstream out;
404 mCullFaceTrace.PushCall("Enable", out.str());
407 inline void EnableVertexAttribArray(GLuint index)
409 SetVertexAttribArray( index, true);
412 inline void Finish(void)
416 inline void Flush(void)
420 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
424 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
428 inline void FrontFace(GLenum mode)
432 inline void GenBuffers(GLsizei n, GLuint* buffers)
434 // avoids an assert in GpuBuffers
438 inline void GenerateMipmap(GLenum target)
442 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
446 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
451 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
452 * @param[in] ids A vector containing the next IDs to be generated
454 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
456 mNextTextureIds = ids;
459 inline const std::vector<GLuint>& GetNextTextureIds()
461 return mNextTextureIds;
464 inline void GenTextures(GLsizei n, GLuint* textures)
466 for( int i=0; i<n; ++i )
468 if( !mNextTextureIds.empty() )
470 *(textures+i) = mNextTextureIds[0];
471 mNextTextureIds.erase( mNextTextureIds.begin() );
475 *(textures+i) = ++mLastAutoTextureIdUsed;
480 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
484 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
488 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
492 inline int GetAttribLocation(GLuint program, const char* name)
494 std::string attribName(name);
496 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
498 if( mStdAttribs[i] == attribName )
504 // 0 is a valid location
508 inline void GetBooleanv(GLenum pname, GLboolean* params)
512 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
516 inline GLenum GetError(void)
518 return mGetErrorResult;
521 inline void GetFloatv(GLenum pname, GLfloat* params)
525 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
529 inline void GetIntegerv(GLenum pname, GLint* params)
533 case GL_MAX_TEXTURE_SIZE:
536 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
539 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
540 *params = mNumBinaryFormats;
542 case GL_PROGRAM_BINARY_FORMATS_OES:
543 *params = mBinaryFormats;
548 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
552 *params = mLinkStatus;
554 case GL_PROGRAM_BINARY_LENGTH_OES:
555 *params = mProgramBinaryLength;
560 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
565 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
569 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
572 case GL_COMPILE_STATUS:
573 *params = mCompileStatus;
578 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
582 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
586 inline const GLubyte* GetString(GLenum name)
588 return mGetStringResult;
591 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
595 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
599 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
603 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
607 inline GLint GetUniformLocation(GLuint program, const char* name)
609 ProgramUniformMap::iterator it = mUniforms.find(program);
610 if( it == mUniforms.end() )
612 // Not a valid program ID
613 mGetErrorResult = GL_INVALID_OPERATION;
617 UniformIDMap& uniformIDs = it->second;
618 UniformIDMap::iterator it2 = uniformIDs.find( name );
619 if( it2 == uniformIDs.end() )
621 // Uniform not found, so add it...
622 uniformIDs[name] = ++mLastUniformIdUsed;
623 return mLastUniformIdUsed;
629 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
633 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
637 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
641 inline void Hint(GLenum target, GLenum mode)
645 inline GLboolean IsBuffer(GLuint buffer)
647 return mIsBufferResult;
650 inline GLboolean IsEnabled(GLenum cap)
652 return mIsEnabledResult;
655 inline GLboolean IsFramebuffer(GLuint framebuffer)
657 return mIsFramebufferResult;
660 inline GLboolean IsProgram(GLuint program)
662 return mIsProgramResult;
665 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
667 return mIsRenderbufferResult;
670 inline GLboolean IsShader(GLuint shader)
672 return mIsShaderResult;
675 inline GLboolean IsTexture(GLuint texture)
677 return mIsTextureResult;
680 inline void LineWidth(GLfloat width)
684 inline void LinkProgram(GLuint program)
686 std::stringstream out;
688 mShaderTrace.PushCall("LinkProgram", out.str());
691 inline void PixelStorei(GLenum pname, GLint param)
695 inline void PolygonOffset(GLfloat factor, GLfloat units)
699 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
703 inline void ReleaseShaderCompiler(void)
707 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
711 inline void SampleCoverage(GLclampf value, GLboolean invert)
715 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
719 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
723 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
725 std::string stringBuilder;
726 for(int i = 0; i < count; ++i)
728 stringBuilder += string[i];
730 mShaderSources[shader] = stringBuilder;
731 mLastShaderCompiled = shader;
734 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
736 const std::string shaderSource = mShaderSources[shader];
737 if( static_cast<int>(shaderSource.length()) < bufsize )
739 strcpy(source, shaderSource.c_str());
740 *length = shaderSource.length();
744 *length = bufsize -1;
745 strncpy(source, shaderSource.c_str(), *length);
746 source[*length] = 0x0;
750 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
754 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
758 inline void StencilMask(GLuint mask)
762 inline void StencilMaskSeparate(GLenum face, GLuint mask)
766 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
770 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
774 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
776 std::stringstream out;
777 out << width << ", " << height;
778 mTextureTrace.PushCall("TexImage2D", out.str());
781 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
785 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
789 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
793 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
797 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
799 std::stringstream out;
800 out << xoffset << ", " << yoffset << ", " << width << ", " << height;
801 mTextureTrace.PushCall("TexSubImage2D", out.str());
804 inline void Uniform1f(GLint location, GLfloat x)
806 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
808 mGetErrorResult = GL_INVALID_OPERATION;
812 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
814 for( int i = 0; i < count; ++i )
816 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
818 mGetErrorResult = GL_INVALID_OPERATION;
824 inline void Uniform1i(GLint location, GLint x)
826 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
828 mGetErrorResult = GL_INVALID_OPERATION;
832 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
834 for( int i = 0; i < count; ++i )
836 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
840 mGetErrorResult = GL_INVALID_OPERATION;
846 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
848 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
852 mGetErrorResult = GL_INVALID_OPERATION;
856 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
858 for( int i = 0; i < count; ++i )
860 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
862 Vector2( v[2*i], v[2*i+1] ) ) )
864 mGetErrorResult = GL_INVALID_OPERATION;
870 inline void Uniform2i(GLint location, GLint x, GLint y)
874 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
878 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
880 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
882 Vector3( x, y, z ) ) )
884 mGetErrorResult = GL_INVALID_OPERATION;
888 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
890 for( int i = 0; i < count; ++i )
892 if( ! mProgramUniforms3f.SetUniformValue(
895 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
897 mGetErrorResult = GL_INVALID_OPERATION;
903 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
907 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
911 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
913 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
915 Vector4( x, y, z, w ) ) )
917 mGetErrorResult = GL_INVALID_OPERATION;
921 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
923 for( int i = 0; i < count; ++i )
925 if( ! mProgramUniforms4f.SetUniformValue(
928 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
930 mGetErrorResult = GL_INVALID_OPERATION;
936 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
940 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
944 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
948 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
950 for( int i = 0; i < count; ++i )
952 if( ! mProgramUniformsMat3.SetUniformValue(
955 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
957 mGetErrorResult = GL_INVALID_OPERATION;
963 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
965 for( int i = 0; i < count; ++i )
967 if( ! mProgramUniformsMat4.SetUniformValue(
972 mGetErrorResult = GL_INVALID_OPERATION;
978 inline void UseProgram(GLuint program)
980 mCurrentProgram = program;
983 inline void ValidateProgram(GLuint program)
987 inline void VertexAttrib1f(GLuint indx, GLfloat x)
991 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
995 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
999 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1003 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1007 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1011 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1015 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1019 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1023 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1029 inline void ReadBuffer(GLenum mode)
1033 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1037 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1041 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)
1045 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1049 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1053 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)
1057 inline void GenQueries(GLsizei n, GLuint* ids)
1061 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1065 inline GLboolean IsQuery(GLuint id)
1070 inline void BeginQuery(GLenum target, GLuint id)
1074 inline void EndQuery(GLenum target)
1078 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1082 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1086 inline GLboolean UnmapBuffer(GLenum target)
1091 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1095 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1099 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1103 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1107 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1111 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1115 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1119 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1123 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1127 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1131 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1135 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1140 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1144 inline void BindVertexArray(GLuint array)
1148 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1152 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1156 inline GLboolean IsVertexArray(GLuint array)
1161 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1165 inline void BeginTransformFeedback(GLenum primitiveMode)
1169 inline void EndTransformFeedback(void)
1173 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1177 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1181 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1185 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1189 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1193 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1197 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1201 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1205 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1209 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1213 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1217 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1221 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1226 inline void Uniform1ui(GLint location, GLuint v0)
1230 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1234 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1238 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1242 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1246 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1250 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1254 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1258 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1262 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1266 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1270 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1274 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1279 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1283 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1287 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1291 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1293 return GL_INVALID_INDEX;
1296 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1300 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1304 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1308 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1312 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1316 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1321 inline GLboolean IsSync(GLsync sync)
1326 inline void DeleteSync(GLsync sync)
1330 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1335 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1339 inline void GetInteger64v(GLenum pname, GLint64* params)
1343 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1347 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1351 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1355 inline void GenSamplers(GLsizei count, GLuint* samplers)
1359 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1363 inline GLboolean IsSampler(GLuint sampler)
1368 inline void BindSampler(GLuint unit, GLuint sampler)
1372 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1376 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1380 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1384 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1388 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1392 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1396 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1400 inline void BindTransformFeedback(GLenum target, GLuint id)
1404 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1408 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1412 inline GLboolean IsTransformFeedback(GLuint id)
1417 inline void PauseTransformFeedback(void)
1421 inline void ResumeTransformFeedback(void)
1425 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1429 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1433 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1437 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1441 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1445 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1449 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1453 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1457 public: // TEST FUNCTIONS
1458 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1459 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1460 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1461 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1462 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1463 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1464 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1465 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1466 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1467 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1468 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1469 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1470 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1471 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1472 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1473 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1475 inline bool GetVertexAttribArrayState(GLuint index)
1477 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1482 return mVertexAttribArrayState[ index ];
1484 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1485 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1487 //Methods for CullFace verification
1488 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1489 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1490 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1492 //Methods for Shader verification
1493 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1494 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1495 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1497 //Methods for Texture verification
1498 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1499 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1500 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1502 //Methods for Draw verification
1503 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1504 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1505 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1507 template <typename T>
1508 inline bool CheckUniformValue( const char* name, const T& value ) const
1510 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1511 program_it != mUniforms.end();
1514 const UniformIDMap &uniformIDs = program_it->second;
1516 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1517 if( uniform_it != uniformIDs.end() )
1519 // found one matching uniform name, lets check the value...
1520 GLuint programId = program_it->first;
1521 GLint uniformId = uniform_it->second;
1523 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1524 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1526 // the value matches
1532 fprintf(stderr, "Not found, printing possible values:" );
1533 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1534 program_it != mUniforms.end();
1537 const UniformIDMap &uniformIDs = program_it->second;
1539 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1540 if( uniform_it != uniformIDs.end() )
1542 // found one matching uniform name, lets check the value...
1543 GLuint programId = program_it->first;
1544 GLint uniformId = uniform_it->second;
1546 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1548 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1550 std::stringstream out;
1551 out << uniform_it->first << ": " << origValue;
1552 fprintf(stderr, "%s", out.str().c_str() );
1559 template <typename T>
1560 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1562 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1563 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1566 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1568 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1569 program_it != mUniforms.end();
1572 const UniformIDMap &uniformIDs = program_it->second;
1574 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1575 if( uniform_it != uniformIDs.end() )
1577 programId = program_it->first;
1578 uniformId = uniform_it->second;
1587 inline GLuint GetLastShaderCompiled() const
1589 return mLastShaderCompiled;
1592 inline GLuint GetLastProgramCreated() const
1594 return mLastProgramIdUsed;
1599 ATTRIB_UNKNOWN = -1,
1604 ATTRIB_BONE_WEIGHTS,
1605 ATTRIB_BONE_INDICES,
1611 GLuint mCurrentProgram;
1612 GLuint mCompileStatus;
1614 GLint mGetAttribLocationResult;
1615 GLenum mGetErrorResult;
1616 GLubyte* mGetStringResult;
1617 GLboolean mIsBufferResult;
1618 GLboolean mIsEnabledResult;
1619 GLboolean mIsFramebufferResult;
1620 GLboolean mIsProgramResult;
1621 GLboolean mIsRenderbufferResult;
1622 GLboolean mIsShaderResult;
1623 GLboolean mIsTextureResult;
1624 GLenum mActiveTextureUnit;
1625 GLenum mCheckFramebufferStatusResult;
1626 GLint mNumBinaryFormats;
1627 GLint mBinaryFormats;
1628 GLint mProgramBinaryLength;
1629 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1630 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1631 typedef std::map< GLuint, std::string> ShaderSourceMap;
1632 ShaderSourceMap mShaderSources;
1633 GLuint mLastShaderCompiled;
1635 Vector4 mLastBlendColor;
1636 GLenum mLastBlendEquationRgb;
1637 GLenum mLastBlendEquationAlpha;
1638 GLenum mLastBlendFuncSrcRgb;
1639 GLenum mLastBlendFuncDstRgb;
1640 GLenum mLastBlendFuncSrcAlpha;
1641 GLenum mLastBlendFuncDstAlpha;
1643 // Data for manipulating the IDs returned by GenTextures
1644 GLuint mLastAutoTextureIdUsed;
1645 std::vector<GLuint> mNextTextureIds;
1646 std::vector<GLuint> mDeletedTextureIds;
1647 std::vector<GLuint> mBoundTextures;
1649 struct ActiveTextureType
1651 std::vector<GLuint> mBoundTextures;
1654 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1656 TraceCallStack mCullFaceTrace;
1657 TraceCallStack mShaderTrace;
1658 TraceCallStack mTextureTrace;
1659 TraceCallStack mDrawTrace;
1661 // Shaders & Uniforms
1662 GLuint mLastShaderIdUsed;
1663 GLuint mLastProgramIdUsed;
1664 GLuint mLastUniformIdUsed;
1665 typedef std::map< std::string, GLint > UniformIDMap;
1666 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1667 ProgramUniformMap mUniforms;
1669 template <typename T>
1670 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1673 typedef std::map< GLint, T > UniformValueMap;
1674 typedef std::map< GLuint, UniformValueMap > Map;
1676 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1683 typename Map::iterator it = Map::find( program );
1684 if( it == Map::end() )
1686 // if its the first uniform for this program add it
1687 std::pair< typename Map::iterator, bool > result =
1688 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1692 UniformValueMap& uniforms = it->second;
1693 uniforms[uniform] = value;
1698 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1701 if ( GetUniformValue( program, uniform, uniformValue ) )
1703 return value == uniformValue;
1709 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1716 typename Map::const_iterator it = Map::find( program );
1717 if( it == Map::end() )
1719 // Uniform values always initialised as 0
1724 const UniformValueMap& uniforms = it->second;
1725 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1726 if( it2 == uniforms.end() )
1728 // Uniform values always initialised as 0
1732 value = it2->second;
1739 ProgramUniformValue<int> mProgramUniforms1i;
1740 ProgramUniformValue<float> mProgramUniforms1f;
1741 ProgramUniformValue<Vector2> mProgramUniforms2f;
1742 ProgramUniformValue<Vector3> mProgramUniforms3f;
1743 ProgramUniformValue<Vector4> mProgramUniforms4f;
1744 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1745 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1747 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1749 return mProgramUniforms1i;
1751 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1753 return mProgramUniforms1f;
1755 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1757 return mProgramUniforms2f;
1759 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1761 return mProgramUniforms3f;
1763 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1765 return mProgramUniforms4f;
1767 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1769 return mProgramUniformsMat4;
1771 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1773 return mProgramUniformsMat3;
1775 inline void SetVertexAttribArray(GLuint index, bool state)
1777 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1782 mVertexAttribArrayState[ index ] = state;
1783 mVertexAttribArrayChanged = true;
1788 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
1794 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
1800 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
1802 return Vector2::ZERO;
1806 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
1808 return Vector3::ZERO;
1812 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
1814 return Vector4::ZERO;
1818 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
1824 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
1826 return Matrix3( Matrix() );
1831 bool BlendEnabled(const Dali::TraceCallStack& callStack);
1832 bool BlendDisabled(const Dali::TraceCallStack& callStack);
1837 #endif // __TEST_GL_ES_H__