blob: ab3501c14b83b54f6cefa205d33814916e047663 [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"
robertphillips@google.com670ff9a2012-04-12 19:53:31 +000019#include "SkFloatingPoint.h"
bsalomon@google.com8f943612013-02-26 14:34:43 +000020#include "../GrGLNoOpInterface.h"
robertphillips@google.com0da37192012-03-19 14:42:13 +000021
bsalomon@google.com8f943612013-02-26 14:34:43 +000022namespace { // suppress no previous prototype warning
caryclark@google.comcf6285b2012-06-06 12:09:01 +000023
robertphillips@google.com0da37192012-03-19 14:42:13 +000024////////////////////////////////////////////////////////////////////////////////
robertphillips@google.comf6f123d2012-03-21 17:57:55 +000025GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +000026
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000027 // Ganesh offsets the texture unit indices
28 texture -= GR_GL_TEXTURE0;
29 GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits());
robertphillips@google.com0da37192012-03-19 14:42:13 +000030
31 GrDebugGL::getInstance()->setCurTextureUnit(texture);
32}
33
34////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000035GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000036 GrGLuint shaderID) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000037
rmistry@google.comfbfcd562012-08-23 18:09:54 +000038 GrProgramObj *program = GR_FIND(programID, GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000039 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +000040 GrAlwaysAssert(program);
41
rmistry@google.comfbfcd562012-08-23 18:09:54 +000042 GrShaderObj *shader = GR_FIND(shaderID,
43 GrShaderObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000044 GrDebugGL::kShader_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +000045 GrAlwaysAssert(shader);
46
47 program->AttachShader(shader);
48}
49
robertphillips@google.comebde3e02012-07-13 17:45:17 +000050GrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) {
51}
52
rmistry@google.comfbfcd562012-08-23 18:09:54 +000053GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program,
54 GrGLuint index,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000055 const char* name) {
56}
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000057
58////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000059GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000060 GrGLuint textureID) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000061
62 // we don't use cube maps
rmistry@google.comfbfcd562012-08-23 18:09:54 +000063 GrAlwaysAssert(target == GR_GL_TEXTURE_2D);
robertphillips@google.comebde3e02012-07-13 17:45:17 +000064 // || target == GR_GL_TEXTURE_CUBE_MAP);
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000065
66 // a textureID of 0 is acceptable - it binds to the default texture target
rmistry@google.comfbfcd562012-08-23 18:09:54 +000067 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000068 GrDebugGL::kTexture_ObjTypes);
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000069
70 GrDebugGL::getInstance()->setTexture(texture);
71}
72
robertphillips@google.com0da37192012-03-19 14:42:13 +000073
74////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000075GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target,
76 GrGLsizeiptr size,
77 const GrGLvoid* data,
robertphillips@google.com409566a2012-06-26 20:19:41 +000078 GrGLenum usage) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +000079 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +000080 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +000081 GrAlwaysAssert(size >= 0);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000082 GrAlwaysAssert(GR_GL_STREAM_DRAW == usage ||
83 GR_GL_STATIC_DRAW == usage ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +000084 GR_GL_DYNAMIC_DRAW == usage);
robertphillips@google.com0da37192012-03-19 14:42:13 +000085
86 GrBufferObj *buffer = NULL;
87 switch (target) {
88 case GR_GL_ARRAY_BUFFER:
89 buffer = GrDebugGL::getInstance()->getArrayBuffer();
90 break;
91 case GR_GL_ELEMENT_ARRAY_BUFFER:
92 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
93 break;
94 default:
95 GrCrash("Unexpected target to glBufferData");
96 break;
97 }
98
99 GrAlwaysAssert(buffer);
100 GrAlwaysAssert(buffer->getBound());
101
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000102 buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data));
robertphillips@google.com0da37192012-03-19 14:42:13 +0000103 buffer->setUsage(usage);
104}
105
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000106
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000107GrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000108 GrGLint param) {
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000109
110 switch (pname) {
111 case GR_GL_UNPACK_ROW_LENGTH:
112 GrDebugGL::getInstance()->setUnPackRowLength(param);
113 break;
114 case GR_GL_PACK_ROW_LENGTH:
115 GrDebugGL::getInstance()->setPackRowLength(param);
116 break;
117 case GR_GL_UNPACK_ALIGNMENT:
118 break;
119 case GR_GL_PACK_ALIGNMENT:
120 GrAlwaysAssert(false);
121 break;
122 default:
123 GrAlwaysAssert(false);
124 break;
125 }
126}
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000127
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000128GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
129 GrGLint y,
130 GrGLsizei width,
131 GrGLsizei height,
132 GrGLenum format,
133 GrGLenum type,
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000134 GrGLvoid* pixels) {
135
136 GrGLint pixelsInRow = width;
137 if (0 < GrDebugGL::getInstance()->getPackRowLength()) {
138 pixelsInRow = GrDebugGL::getInstance()->getPackRowLength();
139 }
140
141 GrGLint componentsPerPixel = 0;
142
143 switch (format) {
144 case GR_GL_RGBA:
145 // fallthrough
146 case GR_GL_BGRA:
147 componentsPerPixel = 4;
148 break;
149 case GR_GL_RGB:
150 componentsPerPixel = 3;
151 break;
robertphillips@google.comd32369e2012-05-30 14:46:10 +0000152 case GR_GL_RED:
153 componentsPerPixel = 1;
154 break;
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000155 default:
156 GrAlwaysAssert(false);
157 break;
158 }
159
160 GrGLint alignment = 4; // the pack alignment (one of 1, 2, 4 or 8)
161 // Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT
162
163 GrGLint componentSize = 0; // size (in bytes) of a single component
164
165 switch (type) {
166 case GR_GL_UNSIGNED_BYTE:
167 componentSize = 1;
168 break;
169 default:
170 GrAlwaysAssert(false);
171 break;
172 }
173
174 GrGLint rowStride = 0; // number of components (not bytes) to skip
175 if (componentSize >= alignment) {
176 rowStride = componentsPerPixel * pixelsInRow;
177 } else {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000178 float fTemp =
179 sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow /
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000180 static_cast<float>(alignment));
181 rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize);
182 }
183
184 GrGLchar *scanline = static_cast<GrGLchar *>(pixels);
185 for (int y = 0; y < height; ++y) {
186 memset(scanline, 0, componentsPerPixel * componentSize * width);
187 scanline += rowStride;
188 }
189}
robertphillips@google.com0da37192012-03-19 14:42:13 +0000190
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000191 GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) {
192
193 // A programID of 0 is legal
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000194 GrProgramObj *program = GR_FIND(programID,
195 GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000196 GrDebugGL::kProgram_ObjTypes);
197
198 GrDebugGL::getInstance()->useProgram(program);
199 }
200
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000201 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000202 GrGLuint frameBufferID) {
203
204 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
205
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000206 // a frameBufferID of 0 is acceptable - it binds to the default
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000207 // frame buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000208 GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID,
209 GrFrameBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000210 GrDebugGL::kFrameBuffer_ObjTypes);
211
212 GrDebugGL::getInstance()->setFrameBuffer(frameBuffer);
213 }
214
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000215 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000216 GrGLuint renderBufferID) {
217
218 GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
219
220 // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000221 GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID,
222 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000223 GrDebugGL::kRenderBuffer_ObjTypes);
224
225 GrDebugGL::getInstance()->setRenderBuffer(renderBuffer);
226 }
227
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000228 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000229 const GrGLuint* textures) {
230
231 // first potentially unbind the texture
232 // TODO: move this into GrDebugGL as unBindTexture?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000233 for (unsigned int i = 0;
234 i < GrDebugGL::getInstance()->getMaxTextureUnits();
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000235 ++i) {
236 GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i);
237
238 if (pTU->getTexture()) {
239 for (int j = 0; j < n; ++j) {
240
241 if (textures[j] == pTU->getTexture()->getID()) {
242 // this ID is the current texture - revert the binding to 0
243 pTU->setTexture(NULL);
244 }
245 }
246 }
247 }
248
249 // TODO: fuse the following block with DeleteRenderBuffers?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000250 // Open GL will remove a deleted render buffer from the active
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000251 // frame buffer but not from any other frame buffer
252 if (GrDebugGL::getInstance()->getFrameBuffer()) {
253
254 GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer();
255
256 for (int i = 0; i < n; ++i) {
257
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000258 if (NULL != frameBuffer->getColor() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000259 textures[i] == frameBuffer->getColor()->getID()) {
260 frameBuffer->setColor(NULL);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000261 }
262 if (NULL != frameBuffer->getDepth() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000263 textures[i] == frameBuffer->getDepth()->getID()) {
264 frameBuffer->setDepth(NULL);
265 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000266 if (NULL != frameBuffer->getStencil() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000267 textures[i] == frameBuffer->getStencil()->getID()) {
268 frameBuffer->setStencil(NULL);
269 }
270 }
271 }
272
273 // then actually "delete" the buffers
274 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000275 GrTextureObj *buffer = GR_FIND(textures[i],
276 GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000277 GrDebugGL::kTexture_ObjTypes);
278 GrAlwaysAssert(buffer);
279
280 // OpenGL gives no guarantees if a texture is deleted while attached to
281 // something other than the currently bound frame buffer
282 GrAlwaysAssert(!buffer->getBound());
283
284 GrAlwaysAssert(!buffer->getDeleted());
285 buffer->deleteAction();
286 }
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) {
521
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000522 debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000523}
524
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000525GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000526 GrGLuint* ids) {
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000527
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000528 debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids);
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000529}
530
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000531GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000532 GrGLuint* ids) {
robertphillips@google.com7c959422012-03-22 20:43:56 +0000533
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000534 debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids);
535}
536
537GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) {
538
539 debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids);
robertphillips@google.com7c959422012-03-22 20:43:56 +0000540}
541
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000542GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000543 GrGLuint bufferID) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000544
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000545 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000546 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000547
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000548 GrBufferObj *buffer = GR_FIND(bufferID,
549 GrBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000550 GrDebugGL::kBuffer_ObjTypes);
bsalomon@google.com8f943612013-02-26 14:34:43 +0000551 // 0 is a permissible bufferID - it unbinds the current buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000552
553 switch (target) {
554 case GR_GL_ARRAY_BUFFER:
robertphillips@google.com0da37192012-03-19 14:42:13 +0000555 GrDebugGL::getInstance()->setArrayBuffer(buffer);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000556 break;
557 case GR_GL_ELEMENT_ARRAY_BUFFER:
robertphillips@google.com0da37192012-03-19 14:42:13 +0000558 GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000559 break;
560 default:
561 GrCrash("Unexpected target to glBindBuffer");
562 break;
563 }
564}
565
566// deleting a bound buffer has the side effect of binding 0
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000567GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000568 const GrGLuint* ids) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000569 // first potentially unbind the buffers
570 for (int i = 0; i < n; ++i) {
571
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000572 if (GrDebugGL::getInstance()->getArrayBuffer() &&
robertphillips@google.com0da37192012-03-19 14:42:13 +0000573 ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) {
574 // this ID is the current array buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000575 GrDebugGL::getInstance()->setArrayBuffer(NULL);
576 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000577 if (GrDebugGL::getInstance()->getElementArrayBuffer() &&
578 ids[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000579 GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000580 // this ID is the current element array buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000581 GrDebugGL::getInstance()->setElementArrayBuffer(NULL);
582 }
583 }
584
585 // then actually "delete" the buffers
586 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000587 GrBufferObj *buffer = GR_FIND(ids[i],
588 GrBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000589 GrDebugGL::kBuffer_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000590 GrAlwaysAssert(buffer);
591
592 GrAlwaysAssert(!buffer->getDeleted());
593 buffer->deleteAction();
594 }
595}
596
597// map a buffer to the caller's address space
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000598GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000599 GrGLenum access) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000600
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000601 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000602 GR_GL_ELEMENT_ARRAY_BUFFER == target);
603 // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000604 GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000605
606 GrBufferObj *buffer = NULL;
607 switch (target) {
608 case GR_GL_ARRAY_BUFFER:
609 buffer = GrDebugGL::getInstance()->getArrayBuffer();
610 break;
611 case GR_GL_ELEMENT_ARRAY_BUFFER:
612 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
613 break;
614 default:
615 GrCrash("Unexpected target to glMapBuffer");
616 break;
617 }
618
619 if (buffer) {
620 GrAlwaysAssert(!buffer->getMapped());
621 buffer->setMapped();
622 return buffer->getDataPtr();
623 }
624
625 GrAlwaysAssert(false);
626 return NULL; // no buffer bound to the target
627}
628
629// remove a buffer from the caller's address space
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000630// TODO: check if the "access" method from "glMapBuffer" was honored
robertphillips@google.com0da37192012-03-19 14:42:13 +0000631GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
632
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000633 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000634 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000635
636 GrBufferObj *buffer = NULL;
637 switch (target) {
638 case GR_GL_ARRAY_BUFFER:
639 buffer = GrDebugGL::getInstance()->getArrayBuffer();
640 break;
641 case GR_GL_ELEMENT_ARRAY_BUFFER:
642 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
643 break;
644 default:
645 GrCrash("Unexpected target to glUnmapBuffer");
646 break;
647 }
648
649 if (buffer) {
650 GrAlwaysAssert(buffer->getMapped());
651 buffer->resetMapped();
652 return GR_GL_TRUE;
653 }
654
655 GrAlwaysAssert(false);
656 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
657}
658
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000659GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
660 GrGLenum value,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000661 GrGLint* params) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000662
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000663 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000664 GR_GL_ELEMENT_ARRAY_BUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000665 GrAlwaysAssert(GR_GL_BUFFER_SIZE == value ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000666 GR_GL_BUFFER_USAGE == value);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000667
668 GrBufferObj *buffer = NULL;
669 switch (target) {
670 case GR_GL_ARRAY_BUFFER:
671 buffer = GrDebugGL::getInstance()->getArrayBuffer();
672 break;
673 case GR_GL_ELEMENT_ARRAY_BUFFER:
674 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000675 break;
robertphillips@google.com0da37192012-03-19 14:42:13 +0000676 }
677
678 GrAlwaysAssert(buffer);
679
680 switch (value) {
681 case GR_GL_BUFFER_MAPPED:
682 *params = GR_GL_FALSE;
683 if (buffer)
684 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
685 break;
686 case GR_GL_BUFFER_SIZE:
687 *params = 0;
688 if (buffer)
689 *params = buffer->getSize();
690 break;
691 case GR_GL_BUFFER_USAGE:
692 *params = GR_GL_STATIC_DRAW;
693 if (buffer)
694 *params = buffer->getUsage();
695 break;
696 default:
697 GrCrash("Unexpected value to glGetBufferParamateriv");
698 break;
699 }
700};
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000701} // end of namespace
702
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000703////////////////////////////////////////////////////////////////////////////////
704struct GrDebugGLInterface : public GrGLInterface {
705
706public:
robertphillips@google.com409566a2012-06-26 20:19:41 +0000707 SK_DECLARE_INST_COUNT(GrDebugGLInterface)
708
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000709 GrDebugGLInterface()
710 : fWrapped(NULL) {
robertphillips@google.com622a1702012-07-31 19:23:02 +0000711 GrDebugGL::staticRef();
712 }
713
714 virtual ~GrDebugGLInterface() {
715 GrDebugGL::staticUnRef();
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000716 }
717
718 void setWrapped(GrGLInterface *interface) {
719 fWrapped.reset(interface);
720 }
721
722 // TODO: there are some issues w/ wrapping another GL interface inside the
723 // debug interface:
724 // Since none of the "gl" methods are member functions they don't get
725 // a "this" pointer through which to access "fWrapped"
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000726 // This could be worked around by having all of them access the
727 // "glInterface" pointer - i.e., treating the debug interface as a
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000728 // true singleton
729 //
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000730 // The problem with this is that we also want to handle OpenGL
731 // contexts. The natural way to do this is to have multiple debug
732 // interfaces. Each of which represents a separate context. The
733 // static ID count would still uniquify IDs across all of them.
734 // The problem then is that we couldn't treat the debug GL
735 // interface as a singleton (since there would be one for each
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000736 // context).
737 //
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000738 // The solution to this is probably to alter SkDebugGlContext's
739 // "makeCurrent" method to make a call like "makeCurrent(this)" to
740 // the debug GL interface (assuming that the application will create
741 // multiple SkGLContext's) to let it switch between the active
742 // context. Everything in the GrDebugGL object would then need to be
743 // moved to a GrContextObj and the GrDebugGL object would just switch
744 // between them. Note that this approach would also require that
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000745 // SkDebugGLContext wrap an arbitrary other context
746 // and then pass the wrapped interface to the debug GL interface.
747
748protected:
749private:
750
751 SkAutoTUnref<GrGLInterface> fWrapped;
752
753 typedef GrGLInterface INHERITED;
754};
755
robertphillips@google.com409566a2012-06-26 20:19:41 +0000756SK_DEFINE_INST_COUNT(GrDebugGLInterface)
757
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000758////////////////////////////////////////////////////////////////////////////////
robertphillips@google.com0da37192012-03-19 14:42:13 +0000759const GrGLInterface* GrGLCreateDebugInterface() {
robertphillips@google.com409566a2012-06-26 20:19:41 +0000760 GrGLInterface* interface = SkNEW(GrDebugGLInterface);
761
762 interface->fBindingsExported = kDesktop_GrGLBinding;
763 interface->fActiveTexture = debugGLActiveTexture;
764 interface->fAttachShader = debugGLAttachShader;
765 interface->fBeginQuery = debugGLBeginQuery;
766 interface->fBindAttribLocation = debugGLBindAttribLocation;
767 interface->fBindBuffer = debugGLBindBuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000768 interface->fBindFragDataLocation = noOpGLBindFragDataLocation;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000769 interface->fBindTexture = debugGLBindTexture;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000770 interface->fBlendColor = noOpGLBlendColor;
771 interface->fBlendFunc = noOpGLBlendFunc;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000772 interface->fBufferData = debugGLBufferData;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000773 interface->fBufferSubData = noOpGLBufferSubData;
774 interface->fClear = noOpGLClear;
775 interface->fClearColor = noOpGLClearColor;
776 interface->fClearStencil = noOpGLClearStencil;
777 interface->fColorMask = noOpGLColorMask;
778 interface->fCompileShader = noOpGLCompileShader;
779 interface->fCompressedTexImage2D = noOpGLCompressedTexImage2D;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000780 interface->fCreateProgram = debugGLCreateProgram;
781 interface->fCreateShader = debugGLCreateShader;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000782 interface->fCullFace = noOpGLCullFace;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000783 interface->fDeleteBuffers = debugGLDeleteBuffers;
784 interface->fDeleteProgram = debugGLDeleteProgram;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000785 interface->fDeleteQueries = noOpGLDeleteIds;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000786 interface->fDeleteShader = debugGLDeleteShader;
787 interface->fDeleteTextures = debugGLDeleteTextures;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000788 interface->fDepthMask = noOpGLDepthMask;
789 interface->fDisable = noOpGLDisable;
790 interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
791 interface->fDrawArrays = noOpGLDrawArrays;
792 interface->fDrawBuffer = noOpGLDrawBuffer;
793 interface->fDrawBuffers = noOpGLDrawBuffers;
794 interface->fDrawElements = noOpGLDrawElements;
795 interface->fEnable = noOpGLEnable;
796 interface->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
797 interface->fEndQuery = noOpGLEndQuery;
798 interface->fFinish = noOpGLFinish;
799 interface->fFlush = noOpGLFlush;
800 interface->fFrontFace = noOpGLFrontFace;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000801 interface->fGenBuffers = debugGLGenBuffers;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000802 interface->fGenQueries = noOpGLGenIds;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000803 interface->fGenTextures = debugGLGenTextures;
804 interface->fGetBufferParameteriv = debugGLGetBufferParameteriv;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000805 interface->fGetError = noOpGLGetError;
806 interface->fGetIntegerv = noOpGLGetIntegerv;
807 interface->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
808 interface->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
809 interface->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
810 interface->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
811 interface->fGetQueryiv = noOpGLGetQueryiv;
812 interface->fGetProgramInfoLog = noOpGLGetInfoLog;
813 interface->fGetProgramiv = noOpGLGetShaderOrProgramiv;
814 interface->fGetShaderInfoLog = noOpGLGetInfoLog;
815 interface->fGetShaderiv = noOpGLGetShaderOrProgramiv;
816 interface->fGetString = noOpGLGetString;
bsalomon@google.com1744f972013-02-26 21:46:32 +0000817 interface->fGetStringi = noOpGLGetStringi;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000818 interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
819 interface->fGetUniformLocation = noOpGLGetUniformLocation;
820 interface->fLineWidth = noOpGLLineWidth;
821 interface->fLinkProgram = noOpGLLinkProgram;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000822 interface->fPixelStorei = debugGLPixelStorei;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000823 interface->fQueryCounter = noOpGLQueryCounter;
824 interface->fReadBuffer = noOpGLReadBuffer;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000825 interface->fReadPixels = debugGLReadPixels;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000826 interface->fScissor = noOpGLScissor;
827 interface->fShaderSource = noOpGLShaderSource;
828 interface->fStencilFunc = noOpGLStencilFunc;
829 interface->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
830 interface->fStencilMask = noOpGLStencilMask;
831 interface->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
832 interface->fStencilOp = noOpGLStencilOp;
833 interface->fStencilOpSeparate = noOpGLStencilOpSeparate;
834 interface->fTexImage2D = noOpGLTexImage2D;
835 interface->fTexParameteri = noOpGLTexParameteri;
836 interface->fTexParameteriv = noOpGLTexParameteriv;
837 interface->fTexSubImage2D = noOpGLTexSubImage2D;
838 interface->fTexStorage2D = noOpGLTexStorage2D;
839 interface->fUniform1f = noOpGLUniform1f;
840 interface->fUniform1i = noOpGLUniform1i;
841 interface->fUniform1fv = noOpGLUniform1fv;
842 interface->fUniform1iv = noOpGLUniform1iv;
843 interface->fUniform2f = noOpGLUniform2f;
844 interface->fUniform2i = noOpGLUniform2i;
845 interface->fUniform2fv = noOpGLUniform2fv;
846 interface->fUniform2iv = noOpGLUniform2iv;
847 interface->fUniform3f = noOpGLUniform3f;
848 interface->fUniform3i = noOpGLUniform3i;
849 interface->fUniform3fv = noOpGLUniform3fv;
850 interface->fUniform3iv = noOpGLUniform3iv;
851 interface->fUniform4f = noOpGLUniform4f;
852 interface->fUniform4i = noOpGLUniform4i;
853 interface->fUniform4fv = noOpGLUniform4fv;
854 interface->fUniform4iv = noOpGLUniform4iv;
855 interface->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
856 interface->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
857 interface->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000858 interface->fUseProgram = debugGLUseProgram;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000859 interface->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
860 interface->fVertexAttribPointer = noOpGLVertexAttribPointer;
861 interface->fViewport = noOpGLViewport;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000862 interface->fBindFramebuffer = debugGLBindFramebuffer;
863 interface->fBindRenderbuffer = debugGLBindRenderbuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000864 interface->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000865 interface->fDeleteFramebuffers = debugGLDeleteFramebuffers;
866 interface->fDeleteRenderbuffers = debugGLDeleteRenderbuffers;
867 interface->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer;
868 interface->fFramebufferTexture2D = debugGLFramebufferTexture2D;
869 interface->fGenFramebuffers = debugGLGenFramebuffers;
870 interface->fGenRenderbuffers = debugGLGenRenderbuffers;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000871 interface->fGetFramebufferAttachmentParameteriv =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000872 noOpGLGetFramebufferAttachmentParameteriv;
873 interface->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
874 interface->fRenderbufferStorage = noOpGLRenderbufferStorage;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000875 interface->fRenderbufferStorageMultisample =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000876 noOpGLRenderbufferStorageMultisample;
877 interface->fBlitFramebuffer = noOpGLBlitFramebuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000878 interface->fResolveMultisampleFramebuffer =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000879 noOpGLResolveMultisampleFramebuffer;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000880 interface->fMapBuffer = debugGLMapBuffer;
881 interface->fUnmapBuffer = debugGLUnmapBuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000882 interface->fBindFragDataLocationIndexed =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000883 noOpGLBindFragDataLocationIndexed;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000884
885 return interface;
robertphillips@google.com0da37192012-03-19 14:42:13 +0000886}