blob: 2d7b04422350049aa8051d7c44f6ee55007724d3 [file] [log] [blame]
robertphillips@google.com0da37192012-03-19 14:42:13 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#include "gl/GrGLInterface.h"
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000011#include "GrDebugGL.h"
12#include "GrShaderObj.h"
13#include "GrProgramObj.h"
14#include "GrBufferObj.h"
15#include "GrTextureUnitObj.h"
16#include "GrTextureObj.h"
17#include "GrFrameBufferObj.h"
18#include "GrRenderBufferObj.h"
bsalomon@google.comecd84842013-03-01 15:36:02 +000019#include "GrVertexArrayObj.h"
robertphillips@google.com670ff9a2012-04-12 19:53:31 +000020#include "SkFloatingPoint.h"
bsalomon@google.com8f943612013-02-26 14:34:43 +000021#include "../GrGLNoOpInterface.h"
robertphillips@google.com0da37192012-03-19 14:42:13 +000022
bsalomon@google.com8f943612013-02-26 14:34:43 +000023namespace { // suppress no previous prototype warning
caryclark@google.comcf6285b2012-06-06 12:09:01 +000024
robertphillips@google.com0da37192012-03-19 14:42:13 +000025////////////////////////////////////////////////////////////////////////////////
robertphillips@google.comf6f123d2012-03-21 17:57:55 +000026GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +000027
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000028 // Ganesh offsets the texture unit indices
29 texture -= GR_GL_TEXTURE0;
30 GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits());
robertphillips@google.com0da37192012-03-19 14:42:13 +000031
32 GrDebugGL::getInstance()->setCurTextureUnit(texture);
33}
34
35////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000036GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000037 GrGLuint shaderID) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000038
rmistry@google.comfbfcd562012-08-23 18:09:54 +000039 GrProgramObj *program = GR_FIND(programID, GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000040 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +000041 GrAlwaysAssert(program);
42
rmistry@google.comfbfcd562012-08-23 18:09:54 +000043 GrShaderObj *shader = GR_FIND(shaderID,
44 GrShaderObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000045 GrDebugGL::kShader_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +000046 GrAlwaysAssert(shader);
47
48 program->AttachShader(shader);
49}
50
robertphillips@google.comebde3e02012-07-13 17:45:17 +000051GrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) {
52}
53
rmistry@google.comfbfcd562012-08-23 18:09:54 +000054GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program,
55 GrGLuint index,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000056 const char* name) {
57}
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000058
59////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000060GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000061 GrGLuint textureID) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000062
63 // we don't use cube maps
rmistry@google.comfbfcd562012-08-23 18:09:54 +000064 GrAlwaysAssert(target == GR_GL_TEXTURE_2D);
robertphillips@google.comebde3e02012-07-13 17:45:17 +000065 // || target == GR_GL_TEXTURE_CUBE_MAP);
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000066
67 // a textureID of 0 is acceptable - it binds to the default texture target
rmistry@google.comfbfcd562012-08-23 18:09:54 +000068 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000069 GrDebugGL::kTexture_ObjTypes);
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000070
71 GrDebugGL::getInstance()->setTexture(texture);
72}
73
robertphillips@google.com0da37192012-03-19 14:42:13 +000074
75////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000076GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target,
77 GrGLsizeiptr size,
78 const GrGLvoid* data,
robertphillips@google.com409566a2012-06-26 20:19:41 +000079 GrGLenum usage) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +000080 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +000081 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +000082 GrAlwaysAssert(size >= 0);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000083 GrAlwaysAssert(GR_GL_STREAM_DRAW == usage ||
84 GR_GL_STATIC_DRAW == usage ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +000085 GR_GL_DYNAMIC_DRAW == usage);
robertphillips@google.com0da37192012-03-19 14:42:13 +000086
87 GrBufferObj *buffer = NULL;
88 switch (target) {
89 case GR_GL_ARRAY_BUFFER:
90 buffer = GrDebugGL::getInstance()->getArrayBuffer();
91 break;
92 case GR_GL_ELEMENT_ARRAY_BUFFER:
93 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
94 break;
95 default:
96 GrCrash("Unexpected target to glBufferData");
97 break;
98 }
99
100 GrAlwaysAssert(buffer);
101 GrAlwaysAssert(buffer->getBound());
102
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000103 buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data));
robertphillips@google.com0da37192012-03-19 14:42:13 +0000104 buffer->setUsage(usage);
105}
106
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000107
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000108GrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000109 GrGLint param) {
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000110
111 switch (pname) {
112 case GR_GL_UNPACK_ROW_LENGTH:
113 GrDebugGL::getInstance()->setUnPackRowLength(param);
114 break;
115 case GR_GL_PACK_ROW_LENGTH:
116 GrDebugGL::getInstance()->setPackRowLength(param);
117 break;
118 case GR_GL_UNPACK_ALIGNMENT:
119 break;
120 case GR_GL_PACK_ALIGNMENT:
121 GrAlwaysAssert(false);
122 break;
123 default:
124 GrAlwaysAssert(false);
125 break;
126 }
127}
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000128
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000129GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
130 GrGLint y,
131 GrGLsizei width,
132 GrGLsizei height,
133 GrGLenum format,
134 GrGLenum type,
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000135 GrGLvoid* pixels) {
136
137 GrGLint pixelsInRow = width;
138 if (0 < GrDebugGL::getInstance()->getPackRowLength()) {
139 pixelsInRow = GrDebugGL::getInstance()->getPackRowLength();
140 }
141
142 GrGLint componentsPerPixel = 0;
143
144 switch (format) {
145 case GR_GL_RGBA:
146 // fallthrough
147 case GR_GL_BGRA:
148 componentsPerPixel = 4;
149 break;
150 case GR_GL_RGB:
151 componentsPerPixel = 3;
152 break;
robertphillips@google.comd32369e2012-05-30 14:46:10 +0000153 case GR_GL_RED:
154 componentsPerPixel = 1;
155 break;
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000156 default:
157 GrAlwaysAssert(false);
158 break;
159 }
160
161 GrGLint alignment = 4; // the pack alignment (one of 1, 2, 4 or 8)
162 // Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT
163
164 GrGLint componentSize = 0; // size (in bytes) of a single component
165
166 switch (type) {
167 case GR_GL_UNSIGNED_BYTE:
168 componentSize = 1;
169 break;
170 default:
171 GrAlwaysAssert(false);
172 break;
173 }
174
175 GrGLint rowStride = 0; // number of components (not bytes) to skip
176 if (componentSize >= alignment) {
177 rowStride = componentsPerPixel * pixelsInRow;
178 } else {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000179 float fTemp =
180 sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow /
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000181 static_cast<float>(alignment));
182 rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize);
183 }
184
185 GrGLchar *scanline = static_cast<GrGLchar *>(pixels);
186 for (int y = 0; y < height; ++y) {
187 memset(scanline, 0, componentsPerPixel * componentSize * width);
188 scanline += rowStride;
189 }
190}
robertphillips@google.com0da37192012-03-19 14:42:13 +0000191
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000192 GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) {
193
194 // A programID of 0 is legal
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000195 GrProgramObj *program = GR_FIND(programID,
196 GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000197 GrDebugGL::kProgram_ObjTypes);
198
199 GrDebugGL::getInstance()->useProgram(program);
200 }
201
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000202 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000203 GrGLuint frameBufferID) {
204
robertphillips@google.com31975cf2013-04-11 23:25:36 +0000205 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target ||
206 GR_GL_READ_FRAMEBUFFER == target ||
207 GR_GL_DRAW_FRAMEBUFFER);
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000208
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000209 // a frameBufferID of 0 is acceptable - it binds to the default
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000210 // frame buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000211 GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID,
212 GrFrameBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000213 GrDebugGL::kFrameBuffer_ObjTypes);
214
215 GrDebugGL::getInstance()->setFrameBuffer(frameBuffer);
216 }
217
bsalomon@google.comecd84842013-03-01 15:36:02 +0000218 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) {
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000219
220 GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
221
222 // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000223 GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID,
224 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000225 GrDebugGL::kRenderBuffer_ObjTypes);
226
227 GrDebugGL::getInstance()->setRenderBuffer(renderBuffer);
228 }
229
bsalomon@google.comecd84842013-03-01 15:36:02 +0000230 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) {
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000231
232 // first potentially unbind the texture
233 // TODO: move this into GrDebugGL as unBindTexture?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000234 for (unsigned int i = 0;
235 i < GrDebugGL::getInstance()->getMaxTextureUnits();
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000236 ++i) {
237 GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i);
238
239 if (pTU->getTexture()) {
240 for (int j = 0; j < n; ++j) {
241
242 if (textures[j] == pTU->getTexture()->getID()) {
243 // this ID is the current texture - revert the binding to 0
244 pTU->setTexture(NULL);
245 }
246 }
247 }
248 }
249
250 // TODO: fuse the following block with DeleteRenderBuffers?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000251 // Open GL will remove a deleted render buffer from the active
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000252 // frame buffer but not from any other frame buffer
253 if (GrDebugGL::getInstance()->getFrameBuffer()) {
254
255 GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer();
256
257 for (int i = 0; i < n; ++i) {
258
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000259 if (NULL != frameBuffer->getColor() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000260 textures[i] == frameBuffer->getColor()->getID()) {
261 frameBuffer->setColor(NULL);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000262 }
263 if (NULL != frameBuffer->getDepth() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000264 textures[i] == frameBuffer->getDepth()->getID()) {
265 frameBuffer->setDepth(NULL);
266 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000267 if (NULL != frameBuffer->getStencil() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000268 textures[i] == frameBuffer->getStencil()->getID()) {
269 frameBuffer->setStencil(NULL);
270 }
271 }
272 }
273
274 // then actually "delete" the buffers
275 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000276 GrTextureObj *buffer = GR_FIND(textures[i],
277 GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000278 GrDebugGL::kTexture_ObjTypes);
279 GrAlwaysAssert(buffer);
280
281 // OpenGL gives no guarantees if a texture is deleted while attached to
282 // something other than the currently bound frame buffer
283 GrAlwaysAssert(!buffer->getBound());
284
285 GrAlwaysAssert(!buffer->getDeleted());
286 buffer->deleteAction();
287 }
288
289 }
290
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000291 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000292 const GrGLuint *frameBuffers) {
293
294 // first potentially unbind the buffers
295 if (GrDebugGL::getInstance()->getFrameBuffer()) {
296 for (int i = 0; i < n; ++i) {
297
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000298 if (frameBuffers[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000299 GrDebugGL::getInstance()->getFrameBuffer()->getID()) {
300 // this ID is the current frame buffer - rebind to the default
301 GrDebugGL::getInstance()->setFrameBuffer(NULL);
302 }
303 }
304 }
305
306 // then actually "delete" the buffers
307 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000308 GrFrameBufferObj *buffer = GR_FIND(frameBuffers[i],
309 GrFrameBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000310 GrDebugGL::kFrameBuffer_ObjTypes);
311 GrAlwaysAssert(buffer);
312
313 GrAlwaysAssert(!buffer->getDeleted());
314 buffer->deleteAction();
315 }
316 }
317
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000318 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteRenderbuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000319 const GrGLuint *renderBuffers) {
320
321 // first potentially unbind the buffers
322 if (GrDebugGL::getInstance()->getRenderBuffer()) {
323 for (int i = 0; i < n; ++i) {
324
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000325 if (renderBuffers[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000326 GrDebugGL::getInstance()->getRenderBuffer()->getID()) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000327 // this ID is the current render buffer - make no
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000328 // render buffer be bound
329 GrDebugGL::getInstance()->setRenderBuffer(NULL);
330 }
331 }
332 }
333
334 // TODO: fuse the following block with DeleteTextures?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000335 // Open GL will remove a deleted render buffer from the active frame
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000336 // buffer but not from any other frame buffer
337 if (GrDebugGL::getInstance()->getFrameBuffer()) {
338
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000339 GrFrameBufferObj *frameBuffer =
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000340 GrDebugGL::getInstance()->getFrameBuffer();
341
342 for (int i = 0; i < n; ++i) {
343
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000344 if (NULL != frameBuffer->getColor() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000345 renderBuffers[i] == frameBuffer->getColor()->getID()) {
346 frameBuffer->setColor(NULL);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000347 }
348 if (NULL != frameBuffer->getDepth() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000349 renderBuffers[i] == frameBuffer->getDepth()->getID()) {
350 frameBuffer->setDepth(NULL);
351 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000352 if (NULL != frameBuffer->getStencil() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000353 renderBuffers[i] == frameBuffer->getStencil()->getID()) {
354 frameBuffer->setStencil(NULL);
355 }
356 }
357 }
358
359 // then actually "delete" the buffers
360 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000361 GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i],
362 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000363 GrDebugGL::kRenderBuffer_ObjTypes);
364 GrAlwaysAssert(buffer);
365
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000366 // OpenGL gives no guarantees if a render buffer is deleted
367 // while attached to something other than the currently
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000368 // bound frame buffer
369 GrAlwaysAssert(!buffer->getColorBound());
370 GrAlwaysAssert(!buffer->getDepthBound());
371 GrAlwaysAssert(!buffer->getStencilBound());
372
373 GrAlwaysAssert(!buffer->getDeleted());
374 buffer->deleteAction();
375 }
376 }
377
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000378 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferRenderbuffer(GrGLenum target,
379 GrGLenum attachment,
380 GrGLenum renderbuffertarget,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000381 GrGLuint renderBufferID) {
382
383 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000384 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
385 GR_GL_DEPTH_ATTACHMENT == attachment ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000386 GR_GL_STENCIL_ATTACHMENT == attachment);
387 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
388
389 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
390 // A render buffer cannot be attached to the default framebuffer
391 GrAlwaysAssert(NULL != framebuffer);
392
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000393 // a renderBufferID of 0 is acceptable - it unbinds the current
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000394 // render buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000395 GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID,
396 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000397 GrDebugGL::kRenderBuffer_ObjTypes);
398
399 switch (attachment) {
400 case GR_GL_COLOR_ATTACHMENT0:
401 framebuffer->setColor(renderbuffer);
402 break;
403 case GR_GL_DEPTH_ATTACHMENT:
404 framebuffer->setDepth(renderbuffer);
405 break;
406 case GR_GL_STENCIL_ATTACHMENT:
407 framebuffer->setStencil(renderbuffer);
408 break;
409 default:
410 GrAlwaysAssert(false);
411 break;
412 };
413
414 }
415
416 ////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000417 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferTexture2D(GrGLenum target,
418 GrGLenum attachment,
419 GrGLenum textarget,
420 GrGLuint textureID,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000421 GrGLint level) {
422
423 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000424 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
425 GR_GL_DEPTH_ATTACHMENT == attachment ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000426 GR_GL_STENCIL_ATTACHMENT == attachment);
427 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
428
429 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
430 // A texture cannot be attached to the default framebuffer
431 GrAlwaysAssert(NULL != framebuffer);
432
433 // A textureID of 0 is allowed - it unbinds the currently bound texture
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000434 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000435 GrDebugGL::kTexture_ObjTypes);
436 if (texture) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000437 // The texture shouldn't be bound to a texture unit - this
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000438 // could lead to a feedback loop
439 GrAlwaysAssert(!texture->getBound());
440 }
441
442 GrAlwaysAssert(0 == level);
443
444 switch (attachment) {
445 case GR_GL_COLOR_ATTACHMENT0:
446 framebuffer->setColor(texture);
447 break;
448 case GR_GL_DEPTH_ATTACHMENT:
449 framebuffer->setDepth(texture);
450 break;
451 case GR_GL_STENCIL_ATTACHMENT:
452 framebuffer->setStencil(texture);
453 break;
454 default:
455 GrAlwaysAssert(false);
456 break;
457 };
458 }
459
robertphillips@google.com0da37192012-03-19 14:42:13 +0000460GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateProgram() {
461
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000462 GrProgramObj *program = GR_CREATE(GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000463 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000464
465 return program->getID();
466}
467
468GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateShader(GrGLenum type) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000469
470 GrAlwaysAssert(GR_GL_VERTEX_SHADER == type ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000471 GR_GL_FRAGMENT_SHADER == type);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000472
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000473 GrShaderObj *shader = GR_CREATE(GrShaderObj, GrDebugGL::kShader_ObjTypes);
474 shader->setType(type);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000475
476 return shader->getID();
477}
478
479GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteProgram(GrGLuint programID) {
480
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000481 GrProgramObj *program = GR_FIND(programID,
482 GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000483 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000484 GrAlwaysAssert(program);
485
robertphillips@google.com0da37192012-03-19 14:42:13 +0000486 if (program->getRefCount()) {
487 // someone is still using this program so we can't delete it here
488 program->setMarkedForDeletion();
489 } else {
490 program->deleteAction();
491 }
492}
493
494GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteShader(GrGLuint shaderID) {
495
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000496 GrShaderObj *shader = GR_FIND(shaderID,
497 GrShaderObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000498 GrDebugGL::kShader_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000499 GrAlwaysAssert(shader);
500
robertphillips@google.com0da37192012-03-19 14:42:13 +0000501 if (shader->getRefCount()) {
502 // someone is still using this shader so we can't delete it here
503 shader->setMarkedForDeletion();
504 } else {
505 shader->deleteAction();
506 }
507}
508
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000509GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type,
510 GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000511 GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000512
513 for (int i = 0; i < n; ++i) {
514 GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type);
515 GrAlwaysAssert(obj);
516 ids[i] = obj->getID();
517 }
518}
519
robertphillips@google.com0da37192012-03-19 14:42:13 +0000520GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000521 debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000522}
523
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000524GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000525 GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000526 debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids);
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000527}
528
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000529GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000530 GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000531 debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids);
532}
533
534GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000535 debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids);
robertphillips@google.com7c959422012-03-22 20:43:56 +0000536}
537
bsalomon@google.comecd84842013-03-01 15:36:02 +0000538GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) {
539 debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids);
540}
robertphillips@google.com0da37192012-03-19 14:42:13 +0000541
bsalomon@google.comecd84842013-03-01 15:36:02 +0000542GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) {
543 for (GrGLsizei i = 0; i < n; ++i) {
544 GrVertexArrayObj* array =
545 GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
546 GrAlwaysAssert(array);
547
548 // Deleting the current vertex array binds object 0
549 if (GrDebugGL::getInstance()->getVertexArray() == array) {
550 GrDebugGL::getInstance()->setVertexArray(NULL);
551 }
552
553 if (array->getRefCount()) {
554 // someone is still using this vertex array so we can't delete it here
555 array->setMarkedForDeletion();
556 } else {
557 array->deleteAction();
558 }
559 }
560}
561
562GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) {
563 GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
bsalomon@google.com6918d482013-03-07 19:09:11 +0000564 GrAlwaysAssert((0 == id) || NULL != array);
bsalomon@google.comecd84842013-03-01 15:36:02 +0000565 GrDebugGL::getInstance()->setVertexArray(array);
566}
567
568GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) {
569 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000570
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000571 GrBufferObj *buffer = GR_FIND(bufferID,
572 GrBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000573 GrDebugGL::kBuffer_ObjTypes);
bsalomon@google.com8f943612013-02-26 14:34:43 +0000574 // 0 is a permissible bufferID - it unbinds the current buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000575
576 switch (target) {
577 case GR_GL_ARRAY_BUFFER:
robertphillips@google.com0da37192012-03-19 14:42:13 +0000578 GrDebugGL::getInstance()->setArrayBuffer(buffer);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000579 break;
580 case GR_GL_ELEMENT_ARRAY_BUFFER:
robertphillips@google.com0da37192012-03-19 14:42:13 +0000581 GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000582 break;
583 default:
584 GrCrash("Unexpected target to glBindBuffer");
585 break;
586 }
587}
588
589// deleting a bound buffer has the side effect of binding 0
bsalomon@google.comecd84842013-03-01 15:36:02 +0000590GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000591 // first potentially unbind the buffers
592 for (int i = 0; i < n; ++i) {
593
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000594 if (GrDebugGL::getInstance()->getArrayBuffer() &&
robertphillips@google.com0da37192012-03-19 14:42:13 +0000595 ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) {
596 // this ID is the current array buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000597 GrDebugGL::getInstance()->setArrayBuffer(NULL);
598 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000599 if (GrDebugGL::getInstance()->getElementArrayBuffer() &&
600 ids[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000601 GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000602 // this ID is the current element array buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000603 GrDebugGL::getInstance()->setElementArrayBuffer(NULL);
604 }
605 }
606
607 // then actually "delete" the buffers
608 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000609 GrBufferObj *buffer = GR_FIND(ids[i],
610 GrBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000611 GrDebugGL::kBuffer_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000612 GrAlwaysAssert(buffer);
613
614 GrAlwaysAssert(!buffer->getDeleted());
615 buffer->deleteAction();
616 }
617}
618
619// map a buffer to the caller's address space
bsalomon@google.comecd84842013-03-01 15:36:02 +0000620GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000621
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000622 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000623 GR_GL_ELEMENT_ARRAY_BUFFER == target);
624 // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000625 GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000626
627 GrBufferObj *buffer = NULL;
628 switch (target) {
629 case GR_GL_ARRAY_BUFFER:
630 buffer = GrDebugGL::getInstance()->getArrayBuffer();
631 break;
632 case GR_GL_ELEMENT_ARRAY_BUFFER:
633 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
634 break;
635 default:
636 GrCrash("Unexpected target to glMapBuffer");
637 break;
638 }
639
640 if (buffer) {
641 GrAlwaysAssert(!buffer->getMapped());
642 buffer->setMapped();
643 return buffer->getDataPtr();
644 }
645
646 GrAlwaysAssert(false);
647 return NULL; // no buffer bound to the target
648}
649
650// remove a buffer from the caller's address space
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000651// TODO: check if the "access" method from "glMapBuffer" was honored
robertphillips@google.com0da37192012-03-19 14:42:13 +0000652GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
653
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000654 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000655 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000656
657 GrBufferObj *buffer = NULL;
658 switch (target) {
659 case GR_GL_ARRAY_BUFFER:
660 buffer = GrDebugGL::getInstance()->getArrayBuffer();
661 break;
662 case GR_GL_ELEMENT_ARRAY_BUFFER:
663 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
664 break;
665 default:
666 GrCrash("Unexpected target to glUnmapBuffer");
667 break;
668 }
669
670 if (buffer) {
671 GrAlwaysAssert(buffer->getMapped());
672 buffer->resetMapped();
673 return GR_GL_TRUE;
674 }
675
676 GrAlwaysAssert(false);
677 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
678}
679
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000680GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
681 GrGLenum value,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000682 GrGLint* params) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000683
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000684 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000685 GR_GL_ELEMENT_ARRAY_BUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000686 GrAlwaysAssert(GR_GL_BUFFER_SIZE == value ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000687 GR_GL_BUFFER_USAGE == value);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000688
689 GrBufferObj *buffer = NULL;
690 switch (target) {
691 case GR_GL_ARRAY_BUFFER:
692 buffer = GrDebugGL::getInstance()->getArrayBuffer();
693 break;
694 case GR_GL_ELEMENT_ARRAY_BUFFER:
695 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000696 break;
robertphillips@google.com0da37192012-03-19 14:42:13 +0000697 }
698
699 GrAlwaysAssert(buffer);
700
701 switch (value) {
702 case GR_GL_BUFFER_MAPPED:
703 *params = GR_GL_FALSE;
704 if (buffer)
705 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
706 break;
707 case GR_GL_BUFFER_SIZE:
708 *params = 0;
709 if (buffer)
710 *params = buffer->getSize();
711 break;
712 case GR_GL_BUFFER_USAGE:
713 *params = GR_GL_STATIC_DRAW;
714 if (buffer)
715 *params = buffer->getUsage();
716 break;
717 default:
718 GrCrash("Unexpected value to glGetBufferParamateriv");
719 break;
720 }
721};
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000722} // end of namespace
723
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000724////////////////////////////////////////////////////////////////////////////////
725struct GrDebugGLInterface : public GrGLInterface {
726
727public:
robertphillips@google.com409566a2012-06-26 20:19:41 +0000728 SK_DECLARE_INST_COUNT(GrDebugGLInterface)
729
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000730 GrDebugGLInterface()
731 : fWrapped(NULL) {
robertphillips@google.com622a1702012-07-31 19:23:02 +0000732 GrDebugGL::staticRef();
733 }
734
735 virtual ~GrDebugGLInterface() {
736 GrDebugGL::staticUnRef();
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000737 }
738
739 void setWrapped(GrGLInterface *interface) {
740 fWrapped.reset(interface);
741 }
742
743 // TODO: there are some issues w/ wrapping another GL interface inside the
744 // debug interface:
745 // Since none of the "gl" methods are member functions they don't get
746 // a "this" pointer through which to access "fWrapped"
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000747 // This could be worked around by having all of them access the
748 // "glInterface" pointer - i.e., treating the debug interface as a
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000749 // true singleton
750 //
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000751 // The problem with this is that we also want to handle OpenGL
752 // contexts. The natural way to do this is to have multiple debug
753 // interfaces. Each of which represents a separate context. The
754 // static ID count would still uniquify IDs across all of them.
755 // The problem then is that we couldn't treat the debug GL
756 // interface as a singleton (since there would be one for each
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000757 // context).
758 //
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000759 // The solution to this is probably to alter SkDebugGlContext's
760 // "makeCurrent" method to make a call like "makeCurrent(this)" to
761 // the debug GL interface (assuming that the application will create
robertphillips@google.com6177e692013-02-28 20:16:25 +0000762 // multiple SkGLContextHelper's) to let it switch between the active
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000763 // context. Everything in the GrDebugGL object would then need to be
764 // moved to a GrContextObj and the GrDebugGL object would just switch
765 // between them. Note that this approach would also require that
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000766 // SkDebugGLContext wrap an arbitrary other context
767 // and then pass the wrapped interface to the debug GL interface.
768
769protected:
770private:
771
772 SkAutoTUnref<GrGLInterface> fWrapped;
773
774 typedef GrGLInterface INHERITED;
775};
776
robertphillips@google.com409566a2012-06-26 20:19:41 +0000777SK_DEFINE_INST_COUNT(GrDebugGLInterface)
778
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000779////////////////////////////////////////////////////////////////////////////////
robertphillips@google.com0da37192012-03-19 14:42:13 +0000780const GrGLInterface* GrGLCreateDebugInterface() {
robertphillips@google.com409566a2012-06-26 20:19:41 +0000781 GrGLInterface* interface = SkNEW(GrDebugGLInterface);
782
783 interface->fBindingsExported = kDesktop_GrGLBinding;
784 interface->fActiveTexture = debugGLActiveTexture;
785 interface->fAttachShader = debugGLAttachShader;
786 interface->fBeginQuery = debugGLBeginQuery;
787 interface->fBindAttribLocation = debugGLBindAttribLocation;
788 interface->fBindBuffer = debugGLBindBuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000789 interface->fBindFragDataLocation = noOpGLBindFragDataLocation;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000790 interface->fBindTexture = debugGLBindTexture;
bsalomon@google.comecd84842013-03-01 15:36:02 +0000791 interface->fBindVertexArray = debugGLBindVertexArray;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000792 interface->fBlendColor = noOpGLBlendColor;
793 interface->fBlendFunc = noOpGLBlendFunc;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000794 interface->fBufferData = debugGLBufferData;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000795 interface->fBufferSubData = noOpGLBufferSubData;
796 interface->fClear = noOpGLClear;
797 interface->fClearColor = noOpGLClearColor;
798 interface->fClearStencil = noOpGLClearStencil;
799 interface->fColorMask = noOpGLColorMask;
800 interface->fCompileShader = noOpGLCompileShader;
801 interface->fCompressedTexImage2D = noOpGLCompressedTexImage2D;
commit-bot@chromium.org98168bb2013-04-11 22:00:34 +0000802 interface->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000803 interface->fCreateProgram = debugGLCreateProgram;
804 interface->fCreateShader = debugGLCreateShader;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000805 interface->fCullFace = noOpGLCullFace;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000806 interface->fDeleteBuffers = debugGLDeleteBuffers;
807 interface->fDeleteProgram = debugGLDeleteProgram;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000808 interface->fDeleteQueries = noOpGLDeleteIds;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000809 interface->fDeleteShader = debugGLDeleteShader;
810 interface->fDeleteTextures = debugGLDeleteTextures;
bsalomon@google.comecd84842013-03-01 15:36:02 +0000811 interface->fDeleteVertexArrays = debugGLDeleteVertexArrays;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000812 interface->fDepthMask = noOpGLDepthMask;
813 interface->fDisable = noOpGLDisable;
814 interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
815 interface->fDrawArrays = noOpGLDrawArrays;
816 interface->fDrawBuffer = noOpGLDrawBuffer;
817 interface->fDrawBuffers = noOpGLDrawBuffers;
818 interface->fDrawElements = noOpGLDrawElements;
819 interface->fEnable = noOpGLEnable;
820 interface->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
821 interface->fEndQuery = noOpGLEndQuery;
822 interface->fFinish = noOpGLFinish;
823 interface->fFlush = noOpGLFlush;
824 interface->fFrontFace = noOpGLFrontFace;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000825 interface->fGenBuffers = debugGLGenBuffers;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000826 interface->fGenQueries = noOpGLGenIds;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000827 interface->fGenTextures = debugGLGenTextures;
828 interface->fGetBufferParameteriv = debugGLGetBufferParameteriv;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000829 interface->fGetError = noOpGLGetError;
830 interface->fGetIntegerv = noOpGLGetIntegerv;
831 interface->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
832 interface->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
833 interface->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
834 interface->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
835 interface->fGetQueryiv = noOpGLGetQueryiv;
836 interface->fGetProgramInfoLog = noOpGLGetInfoLog;
837 interface->fGetProgramiv = noOpGLGetShaderOrProgramiv;
838 interface->fGetShaderInfoLog = noOpGLGetInfoLog;
839 interface->fGetShaderiv = noOpGLGetShaderOrProgramiv;
840 interface->fGetString = noOpGLGetString;
bsalomon@google.com1744f972013-02-26 21:46:32 +0000841 interface->fGetStringi = noOpGLGetStringi;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000842 interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
843 interface->fGetUniformLocation = noOpGLGetUniformLocation;
bsalomon@google.comecd84842013-03-01 15:36:02 +0000844 interface->fGenVertexArrays = debugGLGenVertexArrays;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000845 interface->fLineWidth = noOpGLLineWidth;
846 interface->fLinkProgram = noOpGLLinkProgram;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000847 interface->fPixelStorei = debugGLPixelStorei;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000848 interface->fQueryCounter = noOpGLQueryCounter;
849 interface->fReadBuffer = noOpGLReadBuffer;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000850 interface->fReadPixels = debugGLReadPixels;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000851 interface->fScissor = noOpGLScissor;
852 interface->fShaderSource = noOpGLShaderSource;
853 interface->fStencilFunc = noOpGLStencilFunc;
854 interface->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
855 interface->fStencilMask = noOpGLStencilMask;
856 interface->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
857 interface->fStencilOp = noOpGLStencilOp;
858 interface->fStencilOpSeparate = noOpGLStencilOpSeparate;
859 interface->fTexImage2D = noOpGLTexImage2D;
860 interface->fTexParameteri = noOpGLTexParameteri;
861 interface->fTexParameteriv = noOpGLTexParameteriv;
862 interface->fTexSubImage2D = noOpGLTexSubImage2D;
863 interface->fTexStorage2D = noOpGLTexStorage2D;
864 interface->fUniform1f = noOpGLUniform1f;
865 interface->fUniform1i = noOpGLUniform1i;
866 interface->fUniform1fv = noOpGLUniform1fv;
867 interface->fUniform1iv = noOpGLUniform1iv;
868 interface->fUniform2f = noOpGLUniform2f;
869 interface->fUniform2i = noOpGLUniform2i;
870 interface->fUniform2fv = noOpGLUniform2fv;
871 interface->fUniform2iv = noOpGLUniform2iv;
872 interface->fUniform3f = noOpGLUniform3f;
873 interface->fUniform3i = noOpGLUniform3i;
874 interface->fUniform3fv = noOpGLUniform3fv;
875 interface->fUniform3iv = noOpGLUniform3iv;
876 interface->fUniform4f = noOpGLUniform4f;
877 interface->fUniform4i = noOpGLUniform4i;
878 interface->fUniform4fv = noOpGLUniform4fv;
879 interface->fUniform4iv = noOpGLUniform4iv;
880 interface->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
881 interface->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
882 interface->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000883 interface->fUseProgram = debugGLUseProgram;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000884 interface->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
885 interface->fVertexAttribPointer = noOpGLVertexAttribPointer;
886 interface->fViewport = noOpGLViewport;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000887 interface->fBindFramebuffer = debugGLBindFramebuffer;
888 interface->fBindRenderbuffer = debugGLBindRenderbuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000889 interface->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000890 interface->fDeleteFramebuffers = debugGLDeleteFramebuffers;
891 interface->fDeleteRenderbuffers = debugGLDeleteRenderbuffers;
892 interface->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer;
893 interface->fFramebufferTexture2D = debugGLFramebufferTexture2D;
894 interface->fGenFramebuffers = debugGLGenFramebuffers;
895 interface->fGenRenderbuffers = debugGLGenRenderbuffers;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000896 interface->fGetFramebufferAttachmentParameteriv =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000897 noOpGLGetFramebufferAttachmentParameteriv;
898 interface->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
899 interface->fRenderbufferStorage = noOpGLRenderbufferStorage;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000900 interface->fRenderbufferStorageMultisample =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000901 noOpGLRenderbufferStorageMultisample;
902 interface->fBlitFramebuffer = noOpGLBlitFramebuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000903 interface->fResolveMultisampleFramebuffer =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000904 noOpGLResolveMultisampleFramebuffer;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000905 interface->fMapBuffer = debugGLMapBuffer;
906 interface->fUnmapBuffer = debugGLUnmapBuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000907 interface->fBindFragDataLocationIndexed =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000908 noOpGLBindFragDataLocationIndexed;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000909
910 return interface;
robertphillips@google.com0da37192012-03-19 14:42:13 +0000911}