1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
3 * ------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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.
21 * \brief GL Rendering Context.
22 *//*--------------------------------------------------------------------*/
24 #include "sglrGLContext.hpp"
25 #include "sglrShaderProgram.hpp"
26 #include "gluPixelTransfer.hpp"
27 #include "gluTexture.hpp"
28 #include "gluCallLogWrapper.hpp"
29 #include "gluStrUtil.hpp"
30 #include "glwFunctions.hpp"
31 #include "glwEnums.hpp"
40 using tcu::TextureFormat;
42 GLContext::GLContext (const glu::RenderContext& context, tcu::TestLog& log, deUint32 logFlags, const tcu::IVec4& baseViewport)
43 : Context (context.getType())
46 , m_logFlags (logFlags)
47 , m_baseViewport (baseViewport)
48 , m_curViewport (0, 0, m_baseViewport.z(), m_baseViewport.w())
49 , m_curScissor (0, 0, m_baseViewport.z(), m_baseViewport.w())
50 , m_readFramebufferBinding (0)
51 , m_drawFramebufferBinding (0)
54 const glw::Functions& gl = m_context.getFunctions();
57 m_wrapper = new glu::CallLogWrapper(gl, log);
58 m_wrapper->enableLogging((logFlags & GLCONTEXT_LOG_CALLS) != 0);
60 // Setup base viewport. This offset is active when default framebuffer is active.
61 // \note Calls related to setting up base viewport are not included in log.
62 gl.viewport(baseViewport.x(), baseViewport.y(), baseViewport.z(), baseViewport.w());
65 GLContext::~GLContext (void)
67 const glw::Functions& gl = m_context.getFunctions();
69 // Clean up all still alive objects
70 for (std::set<deUint32>::const_iterator i = m_allocatedFbos.begin();
71 i != m_allocatedFbos.end(); i++)
74 gl.deleteFramebuffers(1, &fbo);
77 for (std::set<deUint32>::const_iterator i = m_allocatedRbos.begin();
78 i != m_allocatedRbos.end(); i++)
81 gl.deleteRenderbuffers(1, &rbo);
84 for (std::set<deUint32>::const_iterator i = m_allocatedTextures.begin();
85 i != m_allocatedTextures.end(); i++)
88 gl.deleteTextures(1, &tex);
91 for (std::set<deUint32>::const_iterator i = m_allocatedBuffers.begin();
92 i != m_allocatedBuffers.end(); i++)
95 gl.deleteBuffers(1, &buf);
98 for (std::set<deUint32>::const_iterator i = m_allocatedVaos.begin();
99 i != m_allocatedVaos.end(); i++)
102 gl.deleteVertexArrays(1, &vao);
105 for (std::vector<glu::ShaderProgram*>::iterator i = m_programs.begin();
106 i != m_programs.end(); i++)
116 void GLContext::enableLogging (deUint32 logFlags)
118 m_logFlags = logFlags;
119 m_wrapper->enableLogging((logFlags & GLCONTEXT_LOG_CALLS) != 0);
122 tcu::IVec2 GLContext::getDrawOffset (void) const
124 if (m_drawFramebufferBinding)
125 return tcu::IVec2(0, 0);
127 return tcu::IVec2(m_baseViewport.x(), m_baseViewport.y());
130 tcu::IVec2 GLContext::getReadOffset (void) const
132 if (m_readFramebufferBinding)
133 return tcu::IVec2(0, 0);
135 return tcu::IVec2(m_baseViewport.x(), m_baseViewport.y());
138 int GLContext::getWidth (void) const
140 return m_baseViewport.z();
143 int GLContext::getHeight (void) const
145 return m_baseViewport.w();
148 void GLContext::activeTexture (deUint32 texture)
150 m_wrapper->glActiveTexture(texture);
153 void GLContext::texParameteri (deUint32 target, deUint32 pname, int value)
155 m_wrapper->glTexParameteri(target, pname, value);
158 deUint32 GLContext::checkFramebufferStatus(deUint32 target)
160 return m_wrapper->glCheckFramebufferStatus(target);
163 void GLContext::viewport (int x, int y, int width, int height)
165 m_curViewport = tcu::IVec4(x, y, width, height);
166 tcu::IVec2 offset = getDrawOffset();
168 // \note For clarity don't add the offset to log
169 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
170 m_log << TestLog::Message << "glViewport(" << x << ", " << y << ", " << width << ", " << height << ");" << TestLog::EndMessage;
171 m_context.getFunctions().viewport(x+offset.x(), y+offset.y(), width, height);
174 void GLContext::bindTexture (deUint32 target, deUint32 texture)
176 m_allocatedTextures.insert(texture);
177 m_wrapper->glBindTexture(target, texture);
180 void GLContext::genTextures (int numTextures, deUint32* textures)
182 m_wrapper->glGenTextures(numTextures, textures);
184 m_allocatedTextures.insert(textures, textures+numTextures);
187 void GLContext::deleteTextures (int numTextures, const deUint32* textures)
189 for (int i = 0; i < numTextures; i++)
190 m_allocatedTextures.erase(textures[i]);
191 m_wrapper->glDeleteTextures(numTextures, textures);
194 void GLContext::bindFramebuffer (deUint32 target, deUint32 framebuffer)
196 // \todo [2011-10-13 pyry] This is a bit of a hack since test cases assumes 0 default fbo.
197 deUint32 defaultFbo = m_context.getDefaultFramebuffer();
198 TCU_CHECK(framebuffer == 0 || framebuffer != defaultFbo);
200 bool isValidTarget = target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER;
202 if (isValidTarget && framebuffer != 0)
203 m_allocatedFbos.insert(framebuffer);
206 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER)
207 m_readFramebufferBinding = framebuffer;
209 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER)
210 m_drawFramebufferBinding = framebuffer;
212 if (framebuffer == 0) // Redirect 0 to platform-defined default framebuffer.
213 m_wrapper->glBindFramebuffer(target, defaultFbo);
215 m_wrapper->glBindFramebuffer(target, framebuffer);
217 // Update viewport and scissor if we updated draw framebuffer binding \note Not logged for clarity
218 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER)
220 tcu::IVec2 offset = getDrawOffset();
221 m_context.getFunctions().viewport(m_curViewport.x()+offset.x(), m_curViewport.y()+offset.y(), m_curViewport.z(), m_curViewport.w());
222 m_context.getFunctions().scissor(m_curScissor.x()+offset.x(), m_curScissor.y()+offset.y(), m_curScissor.z(), m_curScissor.w());
226 void GLContext::genFramebuffers (int numFramebuffers, deUint32* framebuffers)
228 m_wrapper->glGenFramebuffers(numFramebuffers, framebuffers);
229 if (numFramebuffers > 0)
230 m_allocatedFbos.insert(framebuffers, framebuffers+numFramebuffers);
233 void GLContext::deleteFramebuffers (int numFramebuffers, const deUint32* framebuffers)
235 for (int i = 0; i < numFramebuffers; i++)
236 m_allocatedFbos.erase(framebuffers[i]);
237 m_wrapper->glDeleteFramebuffers(numFramebuffers, framebuffers);
240 void GLContext::bindRenderbuffer (deUint32 target, deUint32 renderbuffer)
242 m_allocatedRbos.insert(renderbuffer);
243 m_wrapper->glBindRenderbuffer(target, renderbuffer);
246 void GLContext::genRenderbuffers (int numRenderbuffers, deUint32* renderbuffers)
248 m_wrapper->glGenRenderbuffers(numRenderbuffers, renderbuffers);
249 if (numRenderbuffers > 0)
250 m_allocatedRbos.insert(renderbuffers, renderbuffers+numRenderbuffers);
253 void GLContext::deleteRenderbuffers (int numRenderbuffers, const deUint32* renderbuffers)
255 for (int i = 0; i < numRenderbuffers; i++)
256 m_allocatedRbos.erase(renderbuffers[i]);
257 m_wrapper->glDeleteRenderbuffers(numRenderbuffers, renderbuffers);
260 void GLContext::pixelStorei (deUint32 pname, int param)
262 m_wrapper->glPixelStorei(pname, param);
265 void GLContext::texImage1D (deUint32 target, int level, deUint32 internalFormat, int width, int border, deUint32 format, deUint32 type, const void* data)
267 m_wrapper->glTexImage1D(target, level, internalFormat, width, border, format, type, data);
270 void GLContext::texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height, int border, deUint32 format, deUint32 type, const void* data)
272 m_wrapper->glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
275 void GLContext::texImage3D (deUint32 target, int level, deUint32 internalFormat, int width, int height, int depth, int border, deUint32 format, deUint32 type, const void* data)
277 m_wrapper->glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
280 void GLContext::texSubImage1D (deUint32 target, int level, int xoffset, int width, deUint32 format, deUint32 type, const void* data)
282 m_wrapper->glTexSubImage1D(target, level, xoffset, width, format, type, data);
285 void GLContext::texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int width, int height, deUint32 format, deUint32 type, const void* data)
287 m_wrapper->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
290 void GLContext::texSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, deUint32 format, deUint32 type, const void* data)
292 m_wrapper->glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
295 void GLContext::copyTexImage1D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int border)
298 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
299 m_log << TestLog::Message << "glCopyTexImage1D("
300 << glu::getTextureTargetStr(target) << ", "
302 << glu::getPixelFormatStr(internalFormat) << ", "
303 << x << ", " << y << ", "
304 << width << ", " << border << ")"
305 << TestLog::EndMessage;
307 tcu::IVec2 offset = getReadOffset();
308 m_context.getFunctions().copyTexImage1D(target, level, internalFormat, offset.x()+x, offset.y()+y, width, border);
311 void GLContext::copyTexImage2D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int height, int border)
314 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
315 m_log << TestLog::Message << "glCopyTexImage2D("
316 << glu::getTextureTargetStr(target) << ", "
318 << glu::getPixelFormatStr(internalFormat) << ", "
319 << x << ", " << y << ", "
320 << width << ", " << height
321 << ", " << border << ")"
322 << TestLog::EndMessage;
324 tcu::IVec2 offset = getReadOffset();
325 m_context.getFunctions().copyTexImage2D(target, level, internalFormat, offset.x()+x, offset.y()+y, width, height, border);
328 void GLContext::copyTexSubImage1D (deUint32 target, int level, int xoffset, int x, int y, int width)
330 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
331 m_log << TestLog::Message << "glCopyTexSubImage1D("
332 << glu::getTextureTargetStr(target) << ", "
335 << x << ", " << y << ", "
337 << TestLog::EndMessage;
339 tcu::IVec2 offset = getReadOffset();
340 m_context.getFunctions().copyTexSubImage1D(target, level, xoffset, offset.x()+x, offset.y()+y, width);
343 void GLContext::copyTexSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int x, int y, int width, int height)
345 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
346 m_log << TestLog::Message << "glCopyTexSubImage2D("
347 << glu::getTextureTargetStr(target) << ", "
349 << ", " << xoffset << ", " << yoffset << ", "
350 << x << ", " << y << ", "
351 << width << ", " << height << ")"
352 << TestLog::EndMessage;
354 tcu::IVec2 offset = getReadOffset();
355 m_context.getFunctions().copyTexSubImage2D(target, level, xoffset, yoffset, offset.x()+x, offset.y()+y, width, height);
358 void GLContext::copyTexSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height)
360 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
361 m_log << TestLog::Message << "glCopyTexSubImage3D("
362 << glu::getTextureTargetStr(target) << ", "
364 << ", " << xoffset << ", " << yoffset << ", " << zoffset << ", "
365 << x << ", " << y << ", "
366 << width << ", " << height << ")"
367 << TestLog::EndMessage;
369 tcu::IVec2 offset = getReadOffset();
370 m_context.getFunctions().copyTexSubImage3D(target, level, xoffset, yoffset, zoffset, offset.x()+x, offset.y()+y, width, height);
373 void GLContext::texStorage2D (deUint32 target, int levels, deUint32 internalFormat, int width, int height)
375 m_wrapper->glTexStorage2D(target, levels, internalFormat, width, height);
378 void GLContext::texStorage3D (deUint32 target, int levels, deUint32 internalFormat, int width, int height, int depth)
380 m_wrapper->glTexStorage3D(target, levels, internalFormat, width, height, depth);
383 void GLContext::framebufferTexture2D (deUint32 target, deUint32 attachment, deUint32 textarget, deUint32 texture, int level)
385 m_wrapper->glFramebufferTexture2D(target, attachment, textarget, texture, level);
388 void GLContext::framebufferTextureLayer (deUint32 target, deUint32 attachment, deUint32 texture, int level, int layer)
390 m_wrapper->glFramebufferTextureLayer(target, attachment, texture, level, layer);
393 void GLContext::framebufferRenderbuffer (deUint32 target, deUint32 attachment, deUint32 renderbuffertarget, deUint32 renderbuffer)
395 m_wrapper->glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
398 void GLContext::getFramebufferAttachmentParameteriv (deUint32 target, deUint32 attachment, deUint32 pname, int* params)
400 m_wrapper->glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
403 void GLContext::renderbufferStorage (deUint32 target, deUint32 internalformat, int width, int height)
405 m_wrapper->glRenderbufferStorage(target, internalformat, width, height);
408 void GLContext::renderbufferStorageMultisample (deUint32 target, int samples, deUint32 internalFormat, int width, int height)
410 m_wrapper->glRenderbufferStorageMultisample(target, samples, internalFormat, width, height);
413 void GLContext::bindBuffer (deUint32 target, deUint32 buffer)
415 m_allocatedBuffers.insert(buffer);
416 m_wrapper->glBindBuffer(target, buffer);
419 void GLContext::genBuffers (int numBuffers, deUint32* buffers)
421 m_wrapper->glGenBuffers(numBuffers, buffers);
423 m_allocatedBuffers.insert(buffers, buffers+numBuffers);
426 void GLContext::deleteBuffers (int numBuffers, const deUint32* buffers)
428 m_wrapper->glDeleteBuffers(numBuffers, buffers);
429 for (int i = 0; i < numBuffers; i++)
430 m_allocatedBuffers.erase(buffers[i]);
433 void GLContext::bufferData (deUint32 target, deIntptr size, const void* data, deUint32 usage)
435 m_wrapper->glBufferData(target, (glw::GLsizeiptr)size, data, usage);
438 void GLContext::bufferSubData (deUint32 target, deIntptr offset, deIntptr size, const void* data)
440 m_wrapper->glBufferSubData(target, (glw::GLintptr)offset, (glw::GLsizeiptr)size, data);
443 void GLContext::clearColor (float red, float green, float blue, float alpha)
445 m_wrapper->glClearColor(red, green, blue, alpha);
448 void GLContext::clearDepthf (float depth)
450 m_wrapper->glClearDepthf(depth);
453 void GLContext::clearStencil (int stencil)
455 m_wrapper->glClearStencil(stencil);
458 void GLContext::clear (deUint32 buffers)
460 m_wrapper->glClear(buffers);
463 void GLContext::clearBufferiv (deUint32 buffer, int drawbuffer, const int* value)
465 m_wrapper->glClearBufferiv(buffer, drawbuffer, value);
468 void GLContext::clearBufferfv (deUint32 buffer, int drawbuffer, const float* value)
470 m_wrapper->glClearBufferfv(buffer, drawbuffer, value);
473 void GLContext::clearBufferuiv (deUint32 buffer, int drawbuffer, const deUint32* value)
475 m_wrapper->glClearBufferuiv(buffer, drawbuffer, value);
478 void GLContext::clearBufferfi (deUint32 buffer, int drawbuffer, float depth, int stencil)
480 m_wrapper->glClearBufferfi(buffer, drawbuffer, depth, stencil);
483 void GLContext::scissor (int x, int y, int width, int height)
485 m_curScissor = tcu::IVec4(x, y, width, height);
487 // \note For clarity don't add the offset to log
488 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
489 m_log << TestLog::Message << "glScissor(" << x << ", " << y << ", " << width << ", " << height << ");" << TestLog::EndMessage;
491 tcu::IVec2 offset = getDrawOffset();
492 m_context.getFunctions().scissor(offset.x()+x, offset.y()+y, width, height);
495 void GLContext::enable (deUint32 cap)
497 m_wrapper->glEnable(cap);
500 void GLContext::disable (deUint32 cap)
502 m_wrapper->glDisable(cap);
505 void GLContext::stencilFunc (deUint32 func, int ref, deUint32 mask)
507 m_wrapper->glStencilFunc(func, ref, mask);
510 void GLContext::stencilOp (deUint32 sfail, deUint32 dpfail, deUint32 dppass)
512 m_wrapper->glStencilOp(sfail, dpfail, dppass);
515 void GLContext::depthFunc (deUint32 func)
517 m_wrapper->glDepthFunc(func);
520 void GLContext::depthRangef (float n, float f)
522 m_wrapper->glDepthRangef(n, f);
525 void GLContext::depthRange (double n, double f)
527 m_wrapper->glDepthRange(n, f);
530 void GLContext::polygonOffset (float factor, float units)
532 m_wrapper->glPolygonOffset(factor, units);
535 void GLContext::provokingVertex (deUint32 convention)
537 m_wrapper->glProvokingVertex(convention);
540 void GLContext::primitiveRestartIndex (deUint32 index)
542 m_wrapper->glPrimitiveRestartIndex(index);
545 void GLContext::stencilFuncSeparate (deUint32 face, deUint32 func, int ref, deUint32 mask)
547 m_wrapper->glStencilFuncSeparate(face, func, ref, mask);
550 void GLContext::stencilOpSeparate (deUint32 face, deUint32 sfail, deUint32 dpfail, deUint32 dppass)
552 m_wrapper->glStencilOpSeparate(face, sfail, dpfail, dppass);
555 void GLContext::blendEquation (deUint32 mode)
557 m_wrapper->glBlendEquation(mode);
560 void GLContext::blendEquationSeparate (deUint32 modeRGB, deUint32 modeAlpha)
562 m_wrapper->glBlendEquationSeparate(modeRGB, modeAlpha);
565 void GLContext::blendFunc (deUint32 src, deUint32 dst)
567 m_wrapper->glBlendFunc(src, dst);
570 void GLContext::blendFuncSeparate (deUint32 srcRGB, deUint32 dstRGB, deUint32 srcAlpha, deUint32 dstAlpha)
572 m_wrapper->glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
575 void GLContext::blendColor (float red, float green, float blue, float alpha)
577 m_wrapper->glBlendColor(red, green, blue, alpha);
580 void GLContext::colorMask (deBool r, deBool g, deBool b, deBool a)
582 m_wrapper->glColorMask(r, g, b, a);
585 void GLContext::depthMask (deBool mask)
587 m_wrapper->glDepthMask(mask);
590 void GLContext::stencilMask (deUint32 mask)
592 m_wrapper->glStencilMask(mask);
595 void GLContext::stencilMaskSeparate (deUint32 face, deUint32 mask)
597 m_wrapper->glStencilMaskSeparate(face, mask);
600 void GLContext::blitFramebuffer (int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, deUint32 mask, deUint32 filter)
602 tcu::IVec2 drawOffset = getDrawOffset();
603 tcu::IVec2 readOffset = getReadOffset();
605 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
606 m_log << TestLog::Message << "glBlitFramebuffer("
607 << srcX0 << ", " << srcY0 << ", " << srcX1 << ", " << srcY1 << ", "
608 << dstX0 << ", " << dstY0 << ", " << dstX1 << ", " << dstY1 << ", "
609 << glu::getBufferMaskStr(mask) << ", "
610 << glu::getTextureFilterStr(filter) << ")"
611 << TestLog::EndMessage;
613 m_context.getFunctions().blitFramebuffer(readOffset.x()+srcX0, readOffset.y()+srcY0, readOffset.x()+srcX1, readOffset.y()+srcY1,
614 drawOffset.x()+dstX0, drawOffset.y()+dstY0, drawOffset.x()+dstX1, drawOffset.y()+dstY1,
618 void GLContext::invalidateSubFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments, int x, int y, int width, int height)
620 tcu::IVec2 drawOffset = getDrawOffset();
622 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
623 m_log << TestLog::Message << "glInvalidateSubFramebuffer("
624 << glu::getFramebufferTargetStr(target) << ", " << numAttachments << ", "
625 << glu::getInvalidateAttachmentStr(attachments, numAttachments) << ", "
626 << x << ", " << y << ", " << width << ", " << height << ")"
627 << TestLog::EndMessage;
629 m_context.getFunctions().invalidateSubFramebuffer(target, numAttachments, attachments, x+drawOffset.x(), y+drawOffset.y(), width, height);
632 void GLContext::invalidateFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments)
634 m_wrapper->glInvalidateFramebuffer(target, numAttachments, attachments);
637 void GLContext::bindVertexArray (deUint32 array)
639 m_wrapper->glBindVertexArray(array);
642 void GLContext::genVertexArrays (int numArrays, deUint32* vertexArrays)
644 m_wrapper->glGenVertexArrays(numArrays, vertexArrays);
646 m_allocatedVaos.insert(vertexArrays, vertexArrays+numArrays);
649 void GLContext::deleteVertexArrays (int numArrays, const deUint32* vertexArrays)
651 for (int i = 0; i < numArrays; i++)
652 m_allocatedVaos.erase(vertexArrays[i]);
653 m_wrapper->glDeleteVertexArrays(numArrays, vertexArrays);
656 void GLContext::vertexAttribPointer (deUint32 index, int size, deUint32 type, deBool normalized, int stride, const void *pointer)
658 m_wrapper->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
661 void GLContext::vertexAttribIPointer (deUint32 index, int size, deUint32 type, int stride, const void *pointer)
663 m_wrapper->glVertexAttribIPointer(index, size, type, stride, pointer);
666 void GLContext::enableVertexAttribArray (deUint32 index)
668 m_wrapper->glEnableVertexAttribArray(index);
671 void GLContext::disableVertexAttribArray (deUint32 index)
673 m_wrapper->glDisableVertexAttribArray(index);
676 void GLContext::vertexAttribDivisor (deUint32 index, deUint32 divisor)
678 m_wrapper->glVertexAttribDivisor(index, divisor);
681 void GLContext::vertexAttrib1f (deUint32 index, float x)
683 m_wrapper->glVertexAttrib1f(index, x);
686 void GLContext::vertexAttrib2f (deUint32 index, float x, float y)
688 m_wrapper->glVertexAttrib2f(index, x, y);
691 void GLContext::vertexAttrib3f (deUint32 index, float x, float y, float z)
693 m_wrapper->glVertexAttrib3f(index, x, y, z);
696 void GLContext::vertexAttrib4f (deUint32 index, float x, float y, float z, float w)
698 m_wrapper->glVertexAttrib4f(index, x, y, z, w);
701 void GLContext::vertexAttribI4i (deUint32 index, deInt32 x, deInt32 y, deInt32 z, deInt32 w)
703 m_wrapper->glVertexAttribI4i(index, x, y, z, w);
706 void GLContext::vertexAttribI4ui (deUint32 index, deUint32 x, deUint32 y, deUint32 z, deUint32 w)
708 m_wrapper->glVertexAttribI4ui(index, x, y, z, w);
711 deInt32 GLContext::getAttribLocation (deUint32 program, const char *name)
713 return m_wrapper->glGetAttribLocation(program, name);
716 void GLContext::uniform1f (deInt32 location, float v0)
718 m_wrapper->glUniform1f(location, v0);
721 void GLContext::uniform1i (deInt32 location, deInt32 v0)
723 m_wrapper->glUniform1i(location, v0);
726 void GLContext::uniform1fv (deInt32 location, deInt32 count, const float* value)
728 m_wrapper->glUniform1fv(location, count, value);
731 void GLContext::uniform2fv (deInt32 location, deInt32 count, const float* value)
733 m_wrapper->glUniform2fv(location, count, value);
736 void GLContext::uniform3fv (deInt32 location, deInt32 count, const float* value)
738 m_wrapper->glUniform3fv(location, count, value);
741 void GLContext::uniform4fv (deInt32 location, deInt32 count, const float* value)
743 m_wrapper->glUniform4fv(location, count, value);
746 void GLContext::uniform1iv (deInt32 location, deInt32 count, const deInt32* value)
748 m_wrapper->glUniform1iv(location, count, value);
751 void GLContext::uniform2iv (deInt32 location, deInt32 count, const deInt32* value)
753 m_wrapper->glUniform2iv(location, count, value);
756 void GLContext::uniform3iv (deInt32 location, deInt32 count, const deInt32* value)
758 m_wrapper->glUniform3iv(location, count, value);
761 void GLContext::uniform4iv (deInt32 location, deInt32 count, const deInt32* value)
763 m_wrapper->glUniform4iv(location, count, value);
766 void GLContext::uniformMatrix3fv (deInt32 location, deInt32 count, deInt32 transpose, const float *value)
768 m_wrapper->glUniformMatrix3fv(location, count, transpose, value);
771 void GLContext::uniformMatrix4fv (deInt32 location, deInt32 count, deInt32 transpose, const float *value)
773 m_wrapper->glUniformMatrix4fv(location, count, transpose, value);
775 deInt32 GLContext::getUniformLocation (deUint32 program, const char *name)
777 return m_wrapper->glGetUniformLocation(program, name);
780 void GLContext::lineWidth (float w)
782 m_wrapper->glLineWidth(w);
785 void GLContext::drawArrays (deUint32 mode, int first, int count)
787 m_wrapper->glDrawArrays(mode, first, count);
790 void GLContext::drawArraysInstanced (deUint32 mode, int first, int count, int instanceCount)
792 m_wrapper->glDrawArraysInstanced(mode, first, count, instanceCount);
795 void GLContext::drawElements (deUint32 mode, int count, deUint32 type, const void *indices)
797 m_wrapper->glDrawElements(mode, count, type, indices);
800 void GLContext::drawElementsInstanced (deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount)
802 m_wrapper->glDrawElementsInstanced(mode, count, type, indices, instanceCount);
805 void GLContext::drawElementsBaseVertex (deUint32 mode, int count, deUint32 type, const void *indices, int baseVertex)
807 m_wrapper->glDrawElementsBaseVertex(mode, count, type, indices, baseVertex);
810 void GLContext::drawElementsInstancedBaseVertex (deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount, int baseVertex)
812 m_wrapper->glDrawElementsInstancedBaseVertex(mode, count, type, indices, instanceCount, baseVertex);
815 void GLContext::drawRangeElements (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices)
817 m_wrapper->glDrawRangeElements(mode, start, end, count, type, indices);
820 void GLContext::drawRangeElementsBaseVertex (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices, int baseVertex)
822 m_wrapper->glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices, baseVertex);
825 void GLContext::drawArraysIndirect (deUint32 mode, const void *indirect)
827 m_wrapper->glDrawArraysIndirect(mode, indirect);
830 void GLContext::drawElementsIndirect (deUint32 mode, deUint32 type, const void *indirect)
832 m_wrapper->glDrawElementsIndirect(mode, type, indirect);
835 void GLContext::multiDrawArrays (deUint32 mode, const int* first, const int* count, int primCount)
837 m_wrapper->glMultiDrawArrays(mode, first, count, primCount);
840 void GLContext::multiDrawElements (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount)
842 m_wrapper->glMultiDrawElements(mode, count, type, indices, primCount);
845 void GLContext::multiDrawElementsBaseVertex (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount, const int* baseVertex)
847 m_wrapper->glMultiDrawElementsBaseVertex(mode, count, type, indices, primCount, baseVertex);
850 deUint32 GLContext::createProgram (ShaderProgram* shader)
852 m_programs.reserve(m_programs.size()+1);
854 glu::ShaderProgram* program = DE_NULL;
856 if (!shader->m_hasGeometryShader)
857 program = new glu::ShaderProgram(m_context, glu::makeVtxFragSources(shader->m_vertSrc, shader->m_fragSrc));
859 program = new glu::ShaderProgram(m_context,
860 glu::ProgramSources() << glu::VertexSource(shader->m_vertSrc)
861 << glu::FragmentSource(shader->m_fragSrc)
862 << glu::GeometrySource(shader->m_geomSrc));
864 if (!program->isOk())
868 TCU_FAIL("Compile failed");
871 if ((m_logFlags & GLCONTEXT_LOG_PROGRAMS) != 0)
874 m_programs.push_back(program);
875 return program->getProgram();
878 void GLContext::deleteProgram (deUint32 program)
880 for (std::vector<glu::ShaderProgram*>::iterator i = m_programs.begin(); i != m_programs.end(); i++)
882 if ((*i)->getProgram() == program)
890 DE_ASSERT(!"invalid delete");
893 void GLContext::useProgram (deUint32 program)
895 m_wrapper->glUseProgram(program);
898 void GLContext::readPixels (int x, int y, int width, int height, deUint32 format, deUint32 type, void* data)
901 if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
902 m_log << TestLog::Message << "glReadPixels("
903 << x << ", " << y << ", " << width << ", " << height << ", "
904 << glu::getPixelFormatStr(format) << ", "
905 << glu::getTypeStr(type) << ", " << data << ")"
906 << TestLog::EndMessage;
908 tcu::IVec2 offset = getReadOffset();
909 m_context.getFunctions().readPixels(x+offset.x(), y+offset.y(), width, height, format, type, data);
912 deUint32 GLContext::getError (void)
914 return m_wrapper->glGetError();
917 void GLContext::finish (void)
919 m_wrapper->glFinish();
922 void GLContext::getIntegerv (deUint32 pname, int* params)
924 m_wrapper->glGetIntegerv(pname, params);
927 const char* GLContext::getString (deUint32 pname)
929 return (const char*)m_wrapper->glGetString(pname);