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 );
137 std::stringstream out;
138 out << target << ", " << texture;
139 mTextureTrace.PushCall("BindTexture", out.str());
142 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
144 mLastBlendColor.r = red;
145 mLastBlendColor.g = green;
146 mLastBlendColor.b = blue;
147 mLastBlendColor.a = alpha;
150 inline const Vector4& GetLastBlendColor() const
152 return mLastBlendColor;
155 inline void BlendEquation( GLenum mode )
157 mLastBlendEquationRgb = mode;
158 mLastBlendEquationAlpha = mode;
161 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
163 mLastBlendEquationRgb = modeRgb;
164 mLastBlendEquationAlpha = modeAlpha;
167 inline GLenum GetLastBlendEquationRgb() const
169 return mLastBlendEquationRgb;
172 inline GLenum GetLastBlendEquationAlpha() const
174 return mLastBlendEquationAlpha;
177 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
179 mLastBlendFuncSrcRgb = sfactor;
180 mLastBlendFuncDstRgb = dfactor;
181 mLastBlendFuncSrcAlpha = sfactor;
182 mLastBlendFuncDstAlpha = dfactor;
185 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
187 mLastBlendFuncSrcRgb = srcRGB;
188 mLastBlendFuncDstRgb = dstRGB;
189 mLastBlendFuncSrcAlpha = srcAlpha;
190 mLastBlendFuncDstAlpha = dstAlpha;
193 inline GLenum GetLastBlendFuncSrcRgb() const
195 return mLastBlendFuncSrcRgb;
198 inline GLenum GetLastBlendFuncDstRgb() const
200 return mLastBlendFuncDstRgb;
203 inline GLenum GetLastBlendFuncSrcAlpha() const
205 return mLastBlendFuncSrcAlpha;
208 inline GLenum GetLastBlendFuncDstAlpha() const
210 return mLastBlendFuncDstAlpha;
213 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
217 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
221 inline GLenum CheckFramebufferStatus(GLenum target)
223 return mCheckFramebufferStatusResult;
226 inline void Clear(GLbitfield mask)
230 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
234 inline void ClearDepthf(GLclampf depth)
238 inline void ClearStencil(GLint s)
242 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
246 inline void CompileShader(GLuint shader)
248 std::stringstream out;
250 mShaderTrace.PushCall("CompileShader", out.str());
253 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
257 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
261 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
265 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
269 inline GLuint CreateProgram(void)
271 mShaderTrace.PushCall("CreateProgram", "");
273 ++mLastProgramIdUsed;
274 mUniforms[mLastProgramIdUsed] = UniformIDMap();
275 return mLastProgramIdUsed;
278 inline GLuint CreateShader(GLenum type)
280 std::stringstream out;
282 mShaderTrace.PushCall("CreateShader", out.str());
284 return ++mLastShaderIdUsed;
287 inline void CullFace(GLenum mode)
289 std::stringstream out;
291 mCullFaceTrace.PushCall("CullFace", out.str());
294 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
298 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
302 inline void DeleteProgram(GLuint program)
304 std::stringstream out;
306 mShaderTrace.PushCall("DeleteProgram", out.str());
309 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
313 inline void DeleteShader(GLuint shader)
315 std::stringstream out;
317 mShaderTrace.PushCall("DeleteShader", out.str());
320 inline void DeleteTextures(GLsizei n, const GLuint* textures)
322 std::stringstream out;
323 out << n << ", " << textures << " = [" ;
325 for(GLsizei i=0; i<n; i++)
327 out << textures[i] << ", " ;
328 mDeletedTextureIds.push_back(textures[i]);
331 mTextureTrace.PushCall("DeleteTextures", out.str());
334 inline bool CheckNoTexturesDeleted()
336 return mDeletedTextureIds.size() == 0;
339 inline bool CheckTextureDeleted( GLuint textureId )
343 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
345 if(*iter == textureId)
354 inline void ClearDeletedTextures()
356 mDeletedTextureIds.clear();
359 inline void DepthFunc(GLenum func)
363 inline void DepthMask(GLboolean flag)
367 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
371 inline void DetachShader(GLuint program, GLuint shader)
373 std::stringstream out;
374 out << program << ", " << shader;
375 mShaderTrace.PushCall("DetachShader", out.str());
378 inline void Disable(GLenum cap)
380 std::stringstream out;
382 mCullFaceTrace.PushCall("Disable", out.str());
385 inline void DisableVertexAttribArray(GLuint index)
387 SetVertexAttribArray( index, false );
390 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
392 std::stringstream out;
393 out << mode << ", " << first << ", " << count;
394 mDrawTrace.PushCall("DrawArrays", out.str());
397 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
399 std::stringstream out;
400 out << mode << ", " << count << ", " << type << ", indices";
401 mDrawTrace.PushCall("DrawElements", out.str());
404 inline void Enable(GLenum cap)
406 std::stringstream out;
408 mCullFaceTrace.PushCall("Enable", out.str());
411 inline void EnableVertexAttribArray(GLuint index)
413 SetVertexAttribArray( index, true);
416 inline void Finish(void)
420 inline void Flush(void)
424 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
428 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
432 inline void FrontFace(GLenum mode)
436 inline void GenBuffers(GLsizei n, GLuint* buffers)
438 // avoids an assert in GpuBuffers
442 inline void GenerateMipmap(GLenum target)
446 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
450 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
455 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
456 * @param[in] ids A vector containing the next IDs to be generated
458 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
460 mNextTextureIds = ids;
463 inline const std::vector<GLuint>& GetNextTextureIds()
465 return mNextTextureIds;
468 inline void GenTextures(GLsizei n, GLuint* textures)
470 for( int i=0; i<n; ++i )
472 if( !mNextTextureIds.empty() )
474 *(textures+i) = mNextTextureIds[0];
475 mNextTextureIds.erase( mNextTextureIds.begin() );
479 *(textures+i) = ++mLastAutoTextureIdUsed;
483 std::stringstream out;
484 for(int i=0; i<n; i++)
492 mTextureTrace.PushCall("GenTexture", out.str());
495 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
499 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
503 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
507 inline int GetAttribLocation(GLuint program, const char* name)
509 std::string attribName(name);
511 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
513 if( mStdAttribs[i] == attribName )
519 // 0 is a valid location
523 inline void GetBooleanv(GLenum pname, GLboolean* params)
527 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
531 inline GLenum GetError(void)
533 return mGetErrorResult;
536 inline void GetFloatv(GLenum pname, GLfloat* params)
540 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
544 inline void GetIntegerv(GLenum pname, GLint* params)
548 case GL_MAX_TEXTURE_SIZE:
551 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
554 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
555 *params = mNumBinaryFormats;
557 case GL_PROGRAM_BINARY_FORMATS_OES:
558 *params = mBinaryFormats;
563 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
567 *params = mLinkStatus;
569 case GL_PROGRAM_BINARY_LENGTH_OES:
570 *params = mProgramBinaryLength;
575 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
580 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
584 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
587 case GL_COMPILE_STATUS:
588 *params = mCompileStatus;
593 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
597 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
601 inline const GLubyte* GetString(GLenum name)
603 return mGetStringResult;
606 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
610 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
614 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
618 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
622 inline GLint GetUniformLocation(GLuint program, const char* name)
624 ProgramUniformMap::iterator it = mUniforms.find(program);
625 if( it == mUniforms.end() )
627 // Not a valid program ID
628 mGetErrorResult = GL_INVALID_OPERATION;
632 UniformIDMap& uniformIDs = it->second;
633 UniformIDMap::iterator it2 = uniformIDs.find( name );
634 if( it2 == uniformIDs.end() )
636 // Uniform not found, so add it...
637 uniformIDs[name] = ++mLastUniformIdUsed;
638 return mLastUniformIdUsed;
644 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
648 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
652 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
656 inline void Hint(GLenum target, GLenum mode)
660 inline GLboolean IsBuffer(GLuint buffer)
662 return mIsBufferResult;
665 inline GLboolean IsEnabled(GLenum cap)
667 return mIsEnabledResult;
670 inline GLboolean IsFramebuffer(GLuint framebuffer)
672 return mIsFramebufferResult;
675 inline GLboolean IsProgram(GLuint program)
677 return mIsProgramResult;
680 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
682 return mIsRenderbufferResult;
685 inline GLboolean IsShader(GLuint shader)
687 return mIsShaderResult;
690 inline GLboolean IsTexture(GLuint texture)
692 return mIsTextureResult;
695 inline void LineWidth(GLfloat width)
699 inline void LinkProgram(GLuint program)
701 std::stringstream out;
703 mShaderTrace.PushCall("LinkProgram", out.str());
706 inline void PixelStorei(GLenum pname, GLint param)
710 inline void PolygonOffset(GLfloat factor, GLfloat units)
714 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
718 inline void ReleaseShaderCompiler(void)
722 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
726 inline void SampleCoverage(GLclampf value, GLboolean invert)
730 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
734 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
738 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
740 std::string stringBuilder;
741 for(int i = 0; i < count; ++i)
743 stringBuilder += string[i];
745 mShaderSources[shader] = stringBuilder;
746 mLastShaderCompiled = shader;
749 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
751 const std::string shaderSource = mShaderSources[shader];
752 if( static_cast<int>(shaderSource.length()) < bufsize )
754 strcpy(source, shaderSource.c_str());
755 *length = shaderSource.length();
759 *length = bufsize -1;
760 strncpy(source, shaderSource.c_str(), *length);
761 source[*length] = 0x0;
765 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
769 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
773 inline void StencilMask(GLuint mask)
777 inline void StencilMaskSeparate(GLenum face, GLuint mask)
781 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
785 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
789 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
791 std::stringstream out;
792 out << width << ", " << height;
793 mTextureTrace.PushCall("TexImage2D", out.str());
796 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
800 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
804 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
808 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
812 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
814 std::stringstream out;
815 out << xoffset << ", " << yoffset << ", " << width << ", " << height;
816 mTextureTrace.PushCall("TexSubImage2D", out.str());
819 inline void Uniform1f(GLint location, GLfloat x)
821 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
823 mGetErrorResult = GL_INVALID_OPERATION;
827 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
829 for( int i = 0; i < count; ++i )
831 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
833 mGetErrorResult = GL_INVALID_OPERATION;
839 inline void Uniform1i(GLint location, GLint x)
841 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
843 mGetErrorResult = GL_INVALID_OPERATION;
847 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
849 for( int i = 0; i < count; ++i )
851 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
855 mGetErrorResult = GL_INVALID_OPERATION;
861 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
863 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
867 mGetErrorResult = GL_INVALID_OPERATION;
871 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
873 for( int i = 0; i < count; ++i )
875 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
877 Vector2( v[2*i], v[2*i+1] ) ) )
879 mGetErrorResult = GL_INVALID_OPERATION;
885 inline void Uniform2i(GLint location, GLint x, GLint y)
889 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
893 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
895 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
897 Vector3( x, y, z ) ) )
899 mGetErrorResult = GL_INVALID_OPERATION;
903 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
905 for( int i = 0; i < count; ++i )
907 if( ! mProgramUniforms3f.SetUniformValue(
910 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
912 mGetErrorResult = GL_INVALID_OPERATION;
918 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
922 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
926 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
928 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
930 Vector4( x, y, z, w ) ) )
932 mGetErrorResult = GL_INVALID_OPERATION;
936 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
938 for( int i = 0; i < count; ++i )
940 if( ! mProgramUniforms4f.SetUniformValue(
943 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
945 mGetErrorResult = GL_INVALID_OPERATION;
951 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
955 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
959 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
963 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
965 for( int i = 0; i < count; ++i )
967 if( ! mProgramUniformsMat3.SetUniformValue(
970 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
972 mGetErrorResult = GL_INVALID_OPERATION;
978 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
980 for( int i = 0; i < count; ++i )
982 if( ! mProgramUniformsMat4.SetUniformValue(
987 mGetErrorResult = GL_INVALID_OPERATION;
993 inline void UseProgram(GLuint program)
995 mCurrentProgram = program;
998 inline void ValidateProgram(GLuint program)
1002 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1006 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1010 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1014 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1018 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1022 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1026 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1030 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1034 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1038 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1044 inline void ReadBuffer(GLenum mode)
1048 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1052 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1056 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)
1060 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1064 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1068 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)
1072 inline void GenQueries(GLsizei n, GLuint* ids)
1076 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1080 inline GLboolean IsQuery(GLuint id)
1085 inline void BeginQuery(GLenum target, GLuint id)
1089 inline void EndQuery(GLenum target)
1093 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1097 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1101 inline GLboolean UnmapBuffer(GLenum target)
1106 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1110 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1114 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1118 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1122 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1126 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1130 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1134 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1138 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1142 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1146 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1150 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1155 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1159 inline void BindVertexArray(GLuint array)
1163 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1167 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1171 inline GLboolean IsVertexArray(GLuint array)
1176 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1180 inline void BeginTransformFeedback(GLenum primitiveMode)
1184 inline void EndTransformFeedback(void)
1188 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1192 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1196 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1200 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1204 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1208 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1212 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1216 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1220 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1224 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1228 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1232 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1236 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1241 inline void Uniform1ui(GLint location, GLuint v0)
1245 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1249 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1253 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1257 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1261 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1265 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1269 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1273 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1277 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1281 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1285 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1289 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1294 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1298 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1302 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1306 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1308 return GL_INVALID_INDEX;
1311 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1315 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1319 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1323 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1327 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1331 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1336 inline GLboolean IsSync(GLsync sync)
1341 inline void DeleteSync(GLsync sync)
1345 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1350 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1354 inline void GetInteger64v(GLenum pname, GLint64* params)
1358 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1362 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1366 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1370 inline void GenSamplers(GLsizei count, GLuint* samplers)
1374 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1378 inline GLboolean IsSampler(GLuint sampler)
1383 inline void BindSampler(GLuint unit, GLuint sampler)
1387 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1391 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1395 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1399 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1403 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1407 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1411 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1415 inline void BindTransformFeedback(GLenum target, GLuint id)
1419 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1423 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1427 inline GLboolean IsTransformFeedback(GLuint id)
1432 inline void PauseTransformFeedback(void)
1436 inline void ResumeTransformFeedback(void)
1440 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1444 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1448 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1452 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1456 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1460 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1464 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1468 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1472 public: // TEST FUNCTIONS
1473 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1474 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1475 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1476 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1477 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1478 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1479 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1480 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1481 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1482 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1483 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1484 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1485 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1486 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1487 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1488 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1490 inline bool GetVertexAttribArrayState(GLuint index)
1492 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1497 return mVertexAttribArrayState[ index ];
1499 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1500 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1502 //Methods for CullFace verification
1503 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1504 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1505 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1507 //Methods for Shader verification
1508 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1509 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1510 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1512 //Methods for Texture verification
1513 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1514 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1515 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1517 //Methods for Draw verification
1518 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1519 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1520 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1522 template <typename T>
1523 inline bool CheckUniformValue( const char* name, const T& value ) const
1525 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1526 program_it != mUniforms.end();
1529 const UniformIDMap &uniformIDs = program_it->second;
1531 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1532 if( uniform_it != uniformIDs.end() )
1534 // found one matching uniform name, lets check the value...
1535 GLuint programId = program_it->first;
1536 GLint uniformId = uniform_it->second;
1538 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1539 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1541 // the value matches
1547 fprintf(stderr, "Not found, printing possible values:" );
1548 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1549 program_it != mUniforms.end();
1552 const UniformIDMap &uniformIDs = program_it->second;
1554 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1555 if( uniform_it != uniformIDs.end() )
1557 // found one matching uniform name, lets check the value...
1558 GLuint programId = program_it->first;
1559 GLint uniformId = uniform_it->second;
1561 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1563 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1565 std::stringstream out;
1566 out << uniform_it->first << ": " << origValue;
1567 fprintf(stderr, "%s", out.str().c_str() );
1574 template <typename T>
1575 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1577 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1578 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1581 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1583 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1584 program_it != mUniforms.end();
1587 const UniformIDMap &uniformIDs = program_it->second;
1589 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1590 if( uniform_it != uniformIDs.end() )
1592 programId = program_it->first;
1593 uniformId = uniform_it->second;
1602 inline GLuint GetLastShaderCompiled() const
1604 return mLastShaderCompiled;
1607 inline GLuint GetLastProgramCreated() const
1609 return mLastProgramIdUsed;
1614 ATTRIB_UNKNOWN = -1,
1619 ATTRIB_BONE_WEIGHTS,
1620 ATTRIB_BONE_INDICES,
1626 GLuint mCurrentProgram;
1627 GLuint mCompileStatus;
1629 GLint mGetAttribLocationResult;
1630 GLenum mGetErrorResult;
1631 GLubyte* mGetStringResult;
1632 GLboolean mIsBufferResult;
1633 GLboolean mIsEnabledResult;
1634 GLboolean mIsFramebufferResult;
1635 GLboolean mIsProgramResult;
1636 GLboolean mIsRenderbufferResult;
1637 GLboolean mIsShaderResult;
1638 GLboolean mIsTextureResult;
1639 GLenum mActiveTextureUnit;
1640 GLenum mCheckFramebufferStatusResult;
1641 GLint mNumBinaryFormats;
1642 GLint mBinaryFormats;
1643 GLint mProgramBinaryLength;
1644 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1645 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1646 typedef std::map< GLuint, std::string> ShaderSourceMap;
1647 ShaderSourceMap mShaderSources;
1648 GLuint mLastShaderCompiled;
1650 Vector4 mLastBlendColor;
1651 GLenum mLastBlendEquationRgb;
1652 GLenum mLastBlendEquationAlpha;
1653 GLenum mLastBlendFuncSrcRgb;
1654 GLenum mLastBlendFuncDstRgb;
1655 GLenum mLastBlendFuncSrcAlpha;
1656 GLenum mLastBlendFuncDstAlpha;
1658 // Data for manipulating the IDs returned by GenTextures
1659 GLuint mLastAutoTextureIdUsed;
1660 std::vector<GLuint> mNextTextureIds;
1661 std::vector<GLuint> mDeletedTextureIds;
1662 std::vector<GLuint> mBoundTextures;
1664 struct ActiveTextureType
1666 std::vector<GLuint> mBoundTextures;
1669 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1671 TraceCallStack mCullFaceTrace;
1672 TraceCallStack mShaderTrace;
1673 TraceCallStack mTextureTrace;
1674 TraceCallStack mDrawTrace;
1676 // Shaders & Uniforms
1677 GLuint mLastShaderIdUsed;
1678 GLuint mLastProgramIdUsed;
1679 GLuint mLastUniformIdUsed;
1680 typedef std::map< std::string, GLint > UniformIDMap;
1681 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1682 ProgramUniformMap mUniforms;
1684 template <typename T>
1685 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1688 typedef std::map< GLint, T > UniformValueMap;
1689 typedef std::map< GLuint, UniformValueMap > Map;
1691 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1698 typename Map::iterator it = Map::find( program );
1699 if( it == Map::end() )
1701 // if its the first uniform for this program add it
1702 std::pair< typename Map::iterator, bool > result =
1703 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1707 UniformValueMap& uniforms = it->second;
1708 uniforms[uniform] = value;
1713 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1716 if ( GetUniformValue( program, uniform, uniformValue ) )
1718 return value == uniformValue;
1724 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1731 typename Map::const_iterator it = Map::find( program );
1732 if( it == Map::end() )
1734 // Uniform values always initialised as 0
1739 const UniformValueMap& uniforms = it->second;
1740 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1741 if( it2 == uniforms.end() )
1743 // Uniform values always initialised as 0
1747 value = it2->second;
1754 ProgramUniformValue<int> mProgramUniforms1i;
1755 ProgramUniformValue<float> mProgramUniforms1f;
1756 ProgramUniformValue<Vector2> mProgramUniforms2f;
1757 ProgramUniformValue<Vector3> mProgramUniforms3f;
1758 ProgramUniformValue<Vector4> mProgramUniforms4f;
1759 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1760 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1762 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1764 return mProgramUniforms1i;
1766 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1768 return mProgramUniforms1f;
1770 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1772 return mProgramUniforms2f;
1774 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1776 return mProgramUniforms3f;
1778 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1780 return mProgramUniforms4f;
1782 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1784 return mProgramUniformsMat4;
1786 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1788 return mProgramUniformsMat3;
1790 inline void SetVertexAttribArray(GLuint index, bool state)
1792 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1797 mVertexAttribArrayState[ index ] = state;
1798 mVertexAttribArrayChanged = true;
1803 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
1809 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
1815 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
1817 return Vector2::ZERO;
1821 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
1823 return Vector3::ZERO;
1827 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
1829 return Vector4::ZERO;
1833 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
1839 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
1841 return Matrix3( Matrix() );
1846 bool BlendEnabled(const Dali::TraceCallStack& callStack);
1847 bool BlendDisabled(const Dali::TraceCallStack& callStack);
1852 #endif // __TEST_GL_ES_H__