blob: 1a0e7accf2c0f1606bf5d1cd49645f4c6433fa85 [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
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +000035GrGLvoid GR_GL_FUNCTION_TYPE debugGLClientActiveTexture(GrGLenum texture) {
36
37 // Ganesh offsets the texture unit indices
38 texture -= GR_GL_TEXTURE0;
39 GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits());
40}
41
robertphillips@google.com0da37192012-03-19 14:42:13 +000042////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000043GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000044 GrGLuint shaderID) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000045
rmistry@google.comfbfcd562012-08-23 18:09:54 +000046 GrProgramObj *program = GR_FIND(programID, GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000047 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +000048 GrAlwaysAssert(program);
49
rmistry@google.comfbfcd562012-08-23 18:09:54 +000050 GrShaderObj *shader = GR_FIND(shaderID,
51 GrShaderObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000052 GrDebugGL::kShader_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +000053 GrAlwaysAssert(shader);
54
55 program->AttachShader(shader);
56}
57
robertphillips@google.comebde3e02012-07-13 17:45:17 +000058GrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) {
59}
60
rmistry@google.comfbfcd562012-08-23 18:09:54 +000061GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program,
62 GrGLuint index,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000063 const char* name) {
64}
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000065
66////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000067GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000068 GrGLuint textureID) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000069
70 // we don't use cube maps
rmistry@google.comfbfcd562012-08-23 18:09:54 +000071 GrAlwaysAssert(target == GR_GL_TEXTURE_2D);
robertphillips@google.comebde3e02012-07-13 17:45:17 +000072 // || target == GR_GL_TEXTURE_CUBE_MAP);
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000073
74 // a textureID of 0 is acceptable - it binds to the default texture target
rmistry@google.comfbfcd562012-08-23 18:09:54 +000075 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +000076 GrDebugGL::kTexture_ObjTypes);
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +000077
78 GrDebugGL::getInstance()->setTexture(texture);
79}
80
robertphillips@google.com0da37192012-03-19 14:42:13 +000081
82////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +000083GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target,
84 GrGLsizeiptr size,
85 const GrGLvoid* data,
robertphillips@google.com409566a2012-06-26 20:19:41 +000086 GrGLenum usage) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +000087 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +000088 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +000089 GrAlwaysAssert(size >= 0);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000090 GrAlwaysAssert(GR_GL_STREAM_DRAW == usage ||
91 GR_GL_STATIC_DRAW == usage ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +000092 GR_GL_DYNAMIC_DRAW == usage);
robertphillips@google.com0da37192012-03-19 14:42:13 +000093
94 GrBufferObj *buffer = NULL;
95 switch (target) {
96 case GR_GL_ARRAY_BUFFER:
97 buffer = GrDebugGL::getInstance()->getArrayBuffer();
98 break;
99 case GR_GL_ELEMENT_ARRAY_BUFFER:
100 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
101 break;
102 default:
103 GrCrash("Unexpected target to glBufferData");
104 break;
105 }
106
107 GrAlwaysAssert(buffer);
108 GrAlwaysAssert(buffer->getBound());
109
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000110 buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data));
robertphillips@google.com0da37192012-03-19 14:42:13 +0000111 buffer->setUsage(usage);
112}
113
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000114
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000115GrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000116 GrGLint param) {
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000117
118 switch (pname) {
119 case GR_GL_UNPACK_ROW_LENGTH:
120 GrDebugGL::getInstance()->setUnPackRowLength(param);
121 break;
122 case GR_GL_PACK_ROW_LENGTH:
123 GrDebugGL::getInstance()->setPackRowLength(param);
124 break;
125 case GR_GL_UNPACK_ALIGNMENT:
126 break;
127 case GR_GL_PACK_ALIGNMENT:
128 GrAlwaysAssert(false);
129 break;
130 default:
131 GrAlwaysAssert(false);
132 break;
133 }
134}
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000135
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000136GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
137 GrGLint y,
138 GrGLsizei width,
139 GrGLsizei height,
140 GrGLenum format,
141 GrGLenum type,
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000142 GrGLvoid* pixels) {
143
144 GrGLint pixelsInRow = width;
145 if (0 < GrDebugGL::getInstance()->getPackRowLength()) {
146 pixelsInRow = GrDebugGL::getInstance()->getPackRowLength();
147 }
148
149 GrGLint componentsPerPixel = 0;
150
151 switch (format) {
152 case GR_GL_RGBA:
153 // fallthrough
154 case GR_GL_BGRA:
155 componentsPerPixel = 4;
156 break;
157 case GR_GL_RGB:
158 componentsPerPixel = 3;
159 break;
robertphillips@google.comd32369e2012-05-30 14:46:10 +0000160 case GR_GL_RED:
161 componentsPerPixel = 1;
162 break;
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000163 default:
164 GrAlwaysAssert(false);
165 break;
166 }
167
168 GrGLint alignment = 4; // the pack alignment (one of 1, 2, 4 or 8)
169 // Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT
170
171 GrGLint componentSize = 0; // size (in bytes) of a single component
172
173 switch (type) {
174 case GR_GL_UNSIGNED_BYTE:
175 componentSize = 1;
176 break;
177 default:
178 GrAlwaysAssert(false);
179 break;
180 }
181
182 GrGLint rowStride = 0; // number of components (not bytes) to skip
183 if (componentSize >= alignment) {
184 rowStride = componentsPerPixel * pixelsInRow;
185 } else {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000186 float fTemp =
187 sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow /
robertphillips@google.com670ff9a2012-04-12 19:53:31 +0000188 static_cast<float>(alignment));
189 rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize);
190 }
191
192 GrGLchar *scanline = static_cast<GrGLchar *>(pixels);
193 for (int y = 0; y < height; ++y) {
194 memset(scanline, 0, componentsPerPixel * componentSize * width);
195 scanline += rowStride;
196 }
197}
robertphillips@google.com0da37192012-03-19 14:42:13 +0000198
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000199 GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) {
200
201 // A programID of 0 is legal
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000202 GrProgramObj *program = GR_FIND(programID,
203 GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000204 GrDebugGL::kProgram_ObjTypes);
205
206 GrDebugGL::getInstance()->useProgram(program);
207 }
208
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000209 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000210 GrGLuint frameBufferID) {
211
robertphillips@google.com31975cf2013-04-11 23:25:36 +0000212 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target ||
213 GR_GL_READ_FRAMEBUFFER == target ||
214 GR_GL_DRAW_FRAMEBUFFER);
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000215
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000216 // a frameBufferID of 0 is acceptable - it binds to the default
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000217 // frame buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000218 GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID,
219 GrFrameBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000220 GrDebugGL::kFrameBuffer_ObjTypes);
221
222 GrDebugGL::getInstance()->setFrameBuffer(frameBuffer);
223 }
224
bsalomon@google.comecd84842013-03-01 15:36:02 +0000225 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) {
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000226
227 GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
228
229 // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000230 GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID,
231 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000232 GrDebugGL::kRenderBuffer_ObjTypes);
233
234 GrDebugGL::getInstance()->setRenderBuffer(renderBuffer);
235 }
236
bsalomon@google.comecd84842013-03-01 15:36:02 +0000237 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) {
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000238
239 // first potentially unbind the texture
240 // TODO: move this into GrDebugGL as unBindTexture?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000241 for (unsigned int i = 0;
242 i < GrDebugGL::getInstance()->getMaxTextureUnits();
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000243 ++i) {
244 GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i);
245
246 if (pTU->getTexture()) {
247 for (int j = 0; j < n; ++j) {
248
249 if (textures[j] == pTU->getTexture()->getID()) {
250 // this ID is the current texture - revert the binding to 0
251 pTU->setTexture(NULL);
252 }
253 }
254 }
255 }
256
257 // TODO: fuse the following block with DeleteRenderBuffers?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000258 // Open GL will remove a deleted render buffer from the active
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000259 // frame buffer but not from any other frame buffer
260 if (GrDebugGL::getInstance()->getFrameBuffer()) {
261
262 GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer();
263
264 for (int i = 0; i < n; ++i) {
265
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000266 if (NULL != frameBuffer->getColor() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000267 textures[i] == frameBuffer->getColor()->getID()) {
268 frameBuffer->setColor(NULL);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000269 }
270 if (NULL != frameBuffer->getDepth() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000271 textures[i] == frameBuffer->getDepth()->getID()) {
272 frameBuffer->setDepth(NULL);
273 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000274 if (NULL != frameBuffer->getStencil() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000275 textures[i] == frameBuffer->getStencil()->getID()) {
276 frameBuffer->setStencil(NULL);
277 }
278 }
279 }
280
281 // then actually "delete" the buffers
282 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000283 GrTextureObj *buffer = GR_FIND(textures[i],
284 GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000285 GrDebugGL::kTexture_ObjTypes);
286 GrAlwaysAssert(buffer);
287
288 // OpenGL gives no guarantees if a texture is deleted while attached to
289 // something other than the currently bound frame buffer
290 GrAlwaysAssert(!buffer->getBound());
291
292 GrAlwaysAssert(!buffer->getDeleted());
293 buffer->deleteAction();
294 }
295
296 }
297
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000298 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000299 const GrGLuint *frameBuffers) {
300
301 // first potentially unbind the buffers
302 if (GrDebugGL::getInstance()->getFrameBuffer()) {
303 for (int i = 0; i < n; ++i) {
304
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000305 if (frameBuffers[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000306 GrDebugGL::getInstance()->getFrameBuffer()->getID()) {
307 // this ID is the current frame buffer - rebind to the default
308 GrDebugGL::getInstance()->setFrameBuffer(NULL);
309 }
310 }
311 }
312
313 // then actually "delete" the buffers
314 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000315 GrFrameBufferObj *buffer = GR_FIND(frameBuffers[i],
316 GrFrameBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000317 GrDebugGL::kFrameBuffer_ObjTypes);
318 GrAlwaysAssert(buffer);
319
320 GrAlwaysAssert(!buffer->getDeleted());
321 buffer->deleteAction();
322 }
323 }
324
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000325 GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteRenderbuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000326 const GrGLuint *renderBuffers) {
327
328 // first potentially unbind the buffers
329 if (GrDebugGL::getInstance()->getRenderBuffer()) {
330 for (int i = 0; i < n; ++i) {
331
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000332 if (renderBuffers[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000333 GrDebugGL::getInstance()->getRenderBuffer()->getID()) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000334 // this ID is the current render buffer - make no
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000335 // render buffer be bound
336 GrDebugGL::getInstance()->setRenderBuffer(NULL);
337 }
338 }
339 }
340
341 // TODO: fuse the following block with DeleteTextures?
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000342 // Open GL will remove a deleted render buffer from the active frame
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000343 // buffer but not from any other frame buffer
344 if (GrDebugGL::getInstance()->getFrameBuffer()) {
345
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000346 GrFrameBufferObj *frameBuffer =
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000347 GrDebugGL::getInstance()->getFrameBuffer();
348
349 for (int i = 0; i < n; ++i) {
350
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000351 if (NULL != frameBuffer->getColor() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000352 renderBuffers[i] == frameBuffer->getColor()->getID()) {
353 frameBuffer->setColor(NULL);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000354 }
355 if (NULL != frameBuffer->getDepth() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000356 renderBuffers[i] == frameBuffer->getDepth()->getID()) {
357 frameBuffer->setDepth(NULL);
358 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000359 if (NULL != frameBuffer->getStencil() &&
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000360 renderBuffers[i] == frameBuffer->getStencil()->getID()) {
361 frameBuffer->setStencil(NULL);
362 }
363 }
364 }
365
366 // then actually "delete" the buffers
367 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000368 GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i],
369 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000370 GrDebugGL::kRenderBuffer_ObjTypes);
371 GrAlwaysAssert(buffer);
372
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000373 // OpenGL gives no guarantees if a render buffer is deleted
374 // while attached to something other than the currently
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000375 // bound frame buffer
376 GrAlwaysAssert(!buffer->getColorBound());
377 GrAlwaysAssert(!buffer->getDepthBound());
commit-bot@chromium.org1308f6e2013-06-03 20:09:08 +0000378 // However, at GrContext destroy time we release all GrRsources and so stencil buffers
379 // may get deleted before FBOs that refer to them.
380 //GrAlwaysAssert(!buffer->getStencilBound());
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000381
382 GrAlwaysAssert(!buffer->getDeleted());
383 buffer->deleteAction();
384 }
385 }
386
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000387 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferRenderbuffer(GrGLenum target,
388 GrGLenum attachment,
389 GrGLenum renderbuffertarget,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000390 GrGLuint renderBufferID) {
391
392 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000393 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
394 GR_GL_DEPTH_ATTACHMENT == attachment ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000395 GR_GL_STENCIL_ATTACHMENT == attachment);
396 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
397
398 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
399 // A render buffer cannot be attached to the default framebuffer
400 GrAlwaysAssert(NULL != framebuffer);
401
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000402 // a renderBufferID of 0 is acceptable - it unbinds the current
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000403 // render buffer
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000404 GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID,
405 GrRenderBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000406 GrDebugGL::kRenderBuffer_ObjTypes);
407
408 switch (attachment) {
409 case GR_GL_COLOR_ATTACHMENT0:
410 framebuffer->setColor(renderbuffer);
411 break;
412 case GR_GL_DEPTH_ATTACHMENT:
413 framebuffer->setDepth(renderbuffer);
414 break;
415 case GR_GL_STENCIL_ATTACHMENT:
416 framebuffer->setStencil(renderbuffer);
417 break;
418 default:
419 GrAlwaysAssert(false);
420 break;
421 };
422
423 }
424
425 ////////////////////////////////////////////////////////////////////////////////
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000426 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferTexture2D(GrGLenum target,
427 GrGLenum attachment,
428 GrGLenum textarget,
429 GrGLuint textureID,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000430 GrGLint level) {
431
432 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000433 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
434 GR_GL_DEPTH_ATTACHMENT == attachment ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000435 GR_GL_STENCIL_ATTACHMENT == attachment);
436 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
437
438 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
439 // A texture cannot be attached to the default framebuffer
440 GrAlwaysAssert(NULL != framebuffer);
441
442 // A textureID of 0 is allowed - it unbinds the currently bound texture
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000443 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000444 GrDebugGL::kTexture_ObjTypes);
445 if (texture) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000446 // The texture shouldn't be bound to a texture unit - this
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000447 // could lead to a feedback loop
448 GrAlwaysAssert(!texture->getBound());
449 }
450
451 GrAlwaysAssert(0 == level);
452
453 switch (attachment) {
454 case GR_GL_COLOR_ATTACHMENT0:
455 framebuffer->setColor(texture);
456 break;
457 case GR_GL_DEPTH_ATTACHMENT:
458 framebuffer->setDepth(texture);
459 break;
460 case GR_GL_STENCIL_ATTACHMENT:
461 framebuffer->setStencil(texture);
462 break;
463 default:
464 GrAlwaysAssert(false);
465 break;
466 };
467 }
468
robertphillips@google.com0da37192012-03-19 14:42:13 +0000469GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateProgram() {
470
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000471 GrProgramObj *program = GR_CREATE(GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000472 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000473
474 return program->getID();
475}
476
477GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateShader(GrGLenum type) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000478
479 GrAlwaysAssert(GR_GL_VERTEX_SHADER == type ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000480 GR_GL_FRAGMENT_SHADER == type);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000481
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000482 GrShaderObj *shader = GR_CREATE(GrShaderObj, GrDebugGL::kShader_ObjTypes);
483 shader->setType(type);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000484
485 return shader->getID();
486}
487
488GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteProgram(GrGLuint programID) {
489
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000490 GrProgramObj *program = GR_FIND(programID,
491 GrProgramObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000492 GrDebugGL::kProgram_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000493 GrAlwaysAssert(program);
494
robertphillips@google.com0da37192012-03-19 14:42:13 +0000495 if (program->getRefCount()) {
496 // someone is still using this program so we can't delete it here
497 program->setMarkedForDeletion();
498 } else {
499 program->deleteAction();
500 }
501}
502
503GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteShader(GrGLuint shaderID) {
504
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000505 GrShaderObj *shader = GR_FIND(shaderID,
506 GrShaderObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000507 GrDebugGL::kShader_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000508 GrAlwaysAssert(shader);
509
robertphillips@google.com0da37192012-03-19 14:42:13 +0000510 if (shader->getRefCount()) {
511 // someone is still using this shader so we can't delete it here
512 shader->setMarkedForDeletion();
513 } else {
514 shader->deleteAction();
515 }
516}
517
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000518GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type,
519 GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000520 GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000521
522 for (int i = 0; i < n; ++i) {
523 GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type);
524 GrAlwaysAssert(obj);
525 ids[i] = obj->getID();
526 }
527}
528
robertphillips@google.com0da37192012-03-19 14:42:13 +0000529GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000530 debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000531}
532
commit-bot@chromium.orgcffff792013-07-26 16:36:04 +0000533GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenerateMipmap(GrGLenum level) {
534}
535
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000536GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000537 GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000538 debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids);
robertphillips@google.comf6f123d2012-03-21 17:57:55 +0000539}
540
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000541GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000542 GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000543 debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids);
544}
545
546GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) {
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000547 debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids);
robertphillips@google.com7c959422012-03-22 20:43:56 +0000548}
549
bsalomon@google.comecd84842013-03-01 15:36:02 +0000550GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) {
551 debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids);
552}
robertphillips@google.com0da37192012-03-19 14:42:13 +0000553
bsalomon@google.comecd84842013-03-01 15:36:02 +0000554GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) {
555 for (GrGLsizei i = 0; i < n; ++i) {
556 GrVertexArrayObj* array =
557 GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
558 GrAlwaysAssert(array);
559
560 // Deleting the current vertex array binds object 0
561 if (GrDebugGL::getInstance()->getVertexArray() == array) {
562 GrDebugGL::getInstance()->setVertexArray(NULL);
563 }
564
565 if (array->getRefCount()) {
566 // someone is still using this vertex array so we can't delete it here
567 array->setMarkedForDeletion();
568 } else {
569 array->deleteAction();
570 }
571 }
572}
573
574GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) {
575 GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
bsalomon@google.com6918d482013-03-07 19:09:11 +0000576 GrAlwaysAssert((0 == id) || NULL != array);
bsalomon@google.comecd84842013-03-01 15:36:02 +0000577 GrDebugGL::getInstance()->setVertexArray(array);
578}
579
580GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) {
581 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000582
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000583 GrBufferObj *buffer = GR_FIND(bufferID,
584 GrBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000585 GrDebugGL::kBuffer_ObjTypes);
bsalomon@google.com8f943612013-02-26 14:34:43 +0000586 // 0 is a permissible bufferID - it unbinds the current buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000587
588 switch (target) {
589 case GR_GL_ARRAY_BUFFER:
robertphillips@google.com0da37192012-03-19 14:42:13 +0000590 GrDebugGL::getInstance()->setArrayBuffer(buffer);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000591 break;
592 case GR_GL_ELEMENT_ARRAY_BUFFER:
robertphillips@google.com0da37192012-03-19 14:42:13 +0000593 GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000594 break;
595 default:
596 GrCrash("Unexpected target to glBindBuffer");
597 break;
598 }
599}
600
601// deleting a bound buffer has the side effect of binding 0
bsalomon@google.comecd84842013-03-01 15:36:02 +0000602GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000603 // first potentially unbind the buffers
604 for (int i = 0; i < n; ++i) {
605
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000606 if (GrDebugGL::getInstance()->getArrayBuffer() &&
robertphillips@google.com0da37192012-03-19 14:42:13 +0000607 ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) {
608 // this ID is the current array buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000609 GrDebugGL::getInstance()->setArrayBuffer(NULL);
610 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000611 if (GrDebugGL::getInstance()->getElementArrayBuffer() &&
612 ids[i] ==
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000613 GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000614 // this ID is the current element array buffer
robertphillips@google.com0da37192012-03-19 14:42:13 +0000615 GrDebugGL::getInstance()->setElementArrayBuffer(NULL);
616 }
617 }
618
619 // then actually "delete" the buffers
620 for (int i = 0; i < n; ++i) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000621 GrBufferObj *buffer = GR_FIND(ids[i],
622 GrBufferObj,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000623 GrDebugGL::kBuffer_ObjTypes);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000624 GrAlwaysAssert(buffer);
625
626 GrAlwaysAssert(!buffer->getDeleted());
627 buffer->deleteAction();
628 }
629}
630
631// map a buffer to the caller's address space
bsalomon@google.comecd84842013-03-01 15:36:02 +0000632GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000633
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000634 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000635 GR_GL_ELEMENT_ARRAY_BUFFER == target);
636 // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000637 GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000638
639 GrBufferObj *buffer = NULL;
640 switch (target) {
641 case GR_GL_ARRAY_BUFFER:
642 buffer = GrDebugGL::getInstance()->getArrayBuffer();
643 break;
644 case GR_GL_ELEMENT_ARRAY_BUFFER:
645 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
646 break;
647 default:
648 GrCrash("Unexpected target to glMapBuffer");
649 break;
650 }
651
652 if (buffer) {
653 GrAlwaysAssert(!buffer->getMapped());
654 buffer->setMapped();
655 return buffer->getDataPtr();
656 }
657
658 GrAlwaysAssert(false);
659 return NULL; // no buffer bound to the target
660}
661
662// remove a buffer from the caller's address space
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000663// TODO: check if the "access" method from "glMapBuffer" was honored
robertphillips@google.com0da37192012-03-19 14:42:13 +0000664GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
665
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000666 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000667 GR_GL_ELEMENT_ARRAY_BUFFER == target);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000668
669 GrBufferObj *buffer = NULL;
670 switch (target) {
671 case GR_GL_ARRAY_BUFFER:
672 buffer = GrDebugGL::getInstance()->getArrayBuffer();
673 break;
674 case GR_GL_ELEMENT_ARRAY_BUFFER:
675 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
676 break;
677 default:
678 GrCrash("Unexpected target to glUnmapBuffer");
679 break;
680 }
681
682 if (buffer) {
683 GrAlwaysAssert(buffer->getMapped());
684 buffer->resetMapped();
685 return GR_GL_TRUE;
686 }
687
688 GrAlwaysAssert(false);
689 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
690}
691
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000692GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
693 GrGLenum value,
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000694 GrGLint* params) {
robertphillips@google.com0da37192012-03-19 14:42:13 +0000695
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000696 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000697 GR_GL_ELEMENT_ARRAY_BUFFER == target);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000698 GrAlwaysAssert(GR_GL_BUFFER_SIZE == value ||
robertphillips@google.comebde3e02012-07-13 17:45:17 +0000699 GR_GL_BUFFER_USAGE == value);
robertphillips@google.com0da37192012-03-19 14:42:13 +0000700
701 GrBufferObj *buffer = NULL;
702 switch (target) {
703 case GR_GL_ARRAY_BUFFER:
704 buffer = GrDebugGL::getInstance()->getArrayBuffer();
705 break;
706 case GR_GL_ELEMENT_ARRAY_BUFFER:
707 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000708 break;
robertphillips@google.com0da37192012-03-19 14:42:13 +0000709 }
710
711 GrAlwaysAssert(buffer);
712
713 switch (value) {
714 case GR_GL_BUFFER_MAPPED:
715 *params = GR_GL_FALSE;
716 if (buffer)
717 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
718 break;
719 case GR_GL_BUFFER_SIZE:
720 *params = 0;
721 if (buffer)
722 *params = buffer->getSize();
723 break;
724 case GR_GL_BUFFER_USAGE:
725 *params = GR_GL_STATIC_DRAW;
726 if (buffer)
727 *params = buffer->getUsage();
728 break;
729 default:
730 GrCrash("Unexpected value to glGetBufferParamateriv");
731 break;
732 }
733};
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000734} // end of namespace
735
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000736////////////////////////////////////////////////////////////////////////////////
737struct GrDebugGLInterface : public GrGLInterface {
738
739public:
robertphillips@google.com409566a2012-06-26 20:19:41 +0000740 SK_DECLARE_INST_COUNT(GrDebugGLInterface)
741
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000742 GrDebugGLInterface()
743 : fWrapped(NULL) {
robertphillips@google.com622a1702012-07-31 19:23:02 +0000744 GrDebugGL::staticRef();
745 }
746
747 virtual ~GrDebugGLInterface() {
748 GrDebugGL::staticUnRef();
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000749 }
750
751 void setWrapped(GrGLInterface *interface) {
752 fWrapped.reset(interface);
753 }
754
755 // TODO: there are some issues w/ wrapping another GL interface inside the
756 // debug interface:
757 // Since none of the "gl" methods are member functions they don't get
758 // a "this" pointer through which to access "fWrapped"
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000759 // This could be worked around by having all of them access the
760 // "glInterface" pointer - i.e., treating the debug interface as a
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000761 // true singleton
762 //
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000763 // The problem with this is that we also want to handle OpenGL
764 // contexts. The natural way to do this is to have multiple debug
765 // interfaces. Each of which represents a separate context. The
766 // static ID count would still uniquify IDs across all of them.
767 // The problem then is that we couldn't treat the debug GL
768 // interface as a singleton (since there would be one for each
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000769 // context).
770 //
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000771 // The solution to this is probably to alter SkDebugGlContext's
772 // "makeCurrent" method to make a call like "makeCurrent(this)" to
773 // the debug GL interface (assuming that the application will create
robertphillips@google.com6177e692013-02-28 20:16:25 +0000774 // multiple SkGLContextHelper's) to let it switch between the active
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000775 // context. Everything in the GrDebugGL object would then need to be
776 // moved to a GrContextObj and the GrDebugGL object would just switch
777 // between them. Note that this approach would also require that
robertphillips@google.comba0cc3e2012-03-26 17:58:35 +0000778 // SkDebugGLContext wrap an arbitrary other context
779 // and then pass the wrapped interface to the debug GL interface.
780
781protected:
782private:
783
784 SkAutoTUnref<GrGLInterface> fWrapped;
785
786 typedef GrGLInterface INHERITED;
787};
788
789////////////////////////////////////////////////////////////////////////////////
robertphillips@google.com0da37192012-03-19 14:42:13 +0000790const GrGLInterface* GrGLCreateDebugInterface() {
robertphillips@google.com409566a2012-06-26 20:19:41 +0000791 GrGLInterface* interface = SkNEW(GrDebugGLInterface);
792
793 interface->fBindingsExported = kDesktop_GrGLBinding;
794 interface->fActiveTexture = debugGLActiveTexture;
795 interface->fAttachShader = debugGLAttachShader;
796 interface->fBeginQuery = debugGLBeginQuery;
797 interface->fBindAttribLocation = debugGLBindAttribLocation;
798 interface->fBindBuffer = debugGLBindBuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000799 interface->fBindFragDataLocation = noOpGLBindFragDataLocation;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000800 interface->fBindTexture = debugGLBindTexture;
bsalomon@google.comecd84842013-03-01 15:36:02 +0000801 interface->fBindVertexArray = debugGLBindVertexArray;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000802 interface->fBlendColor = noOpGLBlendColor;
803 interface->fBlendFunc = noOpGLBlendFunc;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000804 interface->fBufferData = debugGLBufferData;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000805 interface->fBufferSubData = noOpGLBufferSubData;
806 interface->fClear = noOpGLClear;
807 interface->fClearColor = noOpGLClearColor;
808 interface->fClearStencil = noOpGLClearStencil;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000809 interface->fClientActiveTexture = debugGLClientActiveTexture;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000810 interface->fColorMask = noOpGLColorMask;
811 interface->fCompileShader = noOpGLCompileShader;
812 interface->fCompressedTexImage2D = noOpGLCompressedTexImage2D;
commit-bot@chromium.org98168bb2013-04-11 22:00:34 +0000813 interface->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000814 interface->fCreateProgram = debugGLCreateProgram;
815 interface->fCreateShader = debugGLCreateShader;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000816 interface->fCullFace = noOpGLCullFace;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000817 interface->fDeleteBuffers = debugGLDeleteBuffers;
818 interface->fDeleteProgram = debugGLDeleteProgram;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000819 interface->fDeleteQueries = noOpGLDeleteIds;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000820 interface->fDeleteShader = debugGLDeleteShader;
821 interface->fDeleteTextures = debugGLDeleteTextures;
bsalomon@google.comecd84842013-03-01 15:36:02 +0000822 interface->fDeleteVertexArrays = debugGLDeleteVertexArrays;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000823 interface->fDepthMask = noOpGLDepthMask;
824 interface->fDisable = noOpGLDisable;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000825 interface->fDisableClientState = noOpGLDisableClientState;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000826 interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
827 interface->fDrawArrays = noOpGLDrawArrays;
828 interface->fDrawBuffer = noOpGLDrawBuffer;
829 interface->fDrawBuffers = noOpGLDrawBuffers;
830 interface->fDrawElements = noOpGLDrawElements;
831 interface->fEnable = noOpGLEnable;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000832 interface->fEnableClientState = noOpGLEnableClientState;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000833 interface->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
834 interface->fEndQuery = noOpGLEndQuery;
835 interface->fFinish = noOpGLFinish;
836 interface->fFlush = noOpGLFlush;
837 interface->fFrontFace = noOpGLFrontFace;
commit-bot@chromium.orgcffff792013-07-26 16:36:04 +0000838 interface->fGenerateMipmap = debugGLGenerateMipmap;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000839 interface->fGenBuffers = debugGLGenBuffers;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000840 interface->fGenQueries = noOpGLGenIds;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000841 interface->fGenTextures = debugGLGenTextures;
842 interface->fGetBufferParameteriv = debugGLGetBufferParameteriv;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000843 interface->fGetError = noOpGLGetError;
844 interface->fGetIntegerv = noOpGLGetIntegerv;
845 interface->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
846 interface->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
847 interface->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
848 interface->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
849 interface->fGetQueryiv = noOpGLGetQueryiv;
850 interface->fGetProgramInfoLog = noOpGLGetInfoLog;
851 interface->fGetProgramiv = noOpGLGetShaderOrProgramiv;
852 interface->fGetShaderInfoLog = noOpGLGetInfoLog;
853 interface->fGetShaderiv = noOpGLGetShaderOrProgramiv;
854 interface->fGetString = noOpGLGetString;
bsalomon@google.com1744f972013-02-26 21:46:32 +0000855 interface->fGetStringi = noOpGLGetStringi;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000856 interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
857 interface->fGetUniformLocation = noOpGLGetUniformLocation;
bsalomon@google.comecd84842013-03-01 15:36:02 +0000858 interface->fGenVertexArrays = debugGLGenVertexArrays;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000859 interface->fLoadIdentity = noOpGLLoadIdentity;
860 interface->fLoadMatrixf = noOpGLLoadMatrixf;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000861 interface->fLineWidth = noOpGLLineWidth;
862 interface->fLinkProgram = noOpGLLinkProgram;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000863 interface->fMatrixMode = noOpGLMatrixMode;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000864 interface->fPixelStorei = debugGLPixelStorei;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000865 interface->fQueryCounter = noOpGLQueryCounter;
866 interface->fReadBuffer = noOpGLReadBuffer;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000867 interface->fReadPixels = debugGLReadPixels;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000868 interface->fScissor = noOpGLScissor;
869 interface->fShaderSource = noOpGLShaderSource;
870 interface->fStencilFunc = noOpGLStencilFunc;
871 interface->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
872 interface->fStencilMask = noOpGLStencilMask;
873 interface->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
874 interface->fStencilOp = noOpGLStencilOp;
875 interface->fStencilOpSeparate = noOpGLStencilOpSeparate;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000876 interface->fTexGenf = noOpGLTexGenf;
877 interface->fTexGenfv = noOpGLTexGenfv;
878 interface->fTexGeni = noOpGLTexGeni;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000879 interface->fTexImage2D = noOpGLTexImage2D;
880 interface->fTexParameteri = noOpGLTexParameteri;
881 interface->fTexParameteriv = noOpGLTexParameteriv;
882 interface->fTexSubImage2D = noOpGLTexSubImage2D;
883 interface->fTexStorage2D = noOpGLTexStorage2D;
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000884 interface->fDiscardFramebuffer = noOpGLDiscardFramebuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000885 interface->fUniform1f = noOpGLUniform1f;
886 interface->fUniform1i = noOpGLUniform1i;
887 interface->fUniform1fv = noOpGLUniform1fv;
888 interface->fUniform1iv = noOpGLUniform1iv;
889 interface->fUniform2f = noOpGLUniform2f;
890 interface->fUniform2i = noOpGLUniform2i;
891 interface->fUniform2fv = noOpGLUniform2fv;
892 interface->fUniform2iv = noOpGLUniform2iv;
893 interface->fUniform3f = noOpGLUniform3f;
894 interface->fUniform3i = noOpGLUniform3i;
895 interface->fUniform3fv = noOpGLUniform3fv;
896 interface->fUniform3iv = noOpGLUniform3iv;
897 interface->fUniform4f = noOpGLUniform4f;
898 interface->fUniform4i = noOpGLUniform4i;
899 interface->fUniform4fv = noOpGLUniform4fv;
900 interface->fUniform4iv = noOpGLUniform4iv;
901 interface->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
902 interface->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
903 interface->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000904 interface->fUseProgram = debugGLUseProgram;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000905 interface->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
906 interface->fVertexAttribPointer = noOpGLVertexAttribPointer;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000907 interface->fVertexPointer = noOpGLVertexPointer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000908 interface->fViewport = noOpGLViewport;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000909 interface->fBindFramebuffer = debugGLBindFramebuffer;
910 interface->fBindRenderbuffer = debugGLBindRenderbuffer;
bsalomon@google.com8f943612013-02-26 14:34:43 +0000911 interface->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000912 interface->fDeleteFramebuffers = debugGLDeleteFramebuffers;
913 interface->fDeleteRenderbuffers = debugGLDeleteRenderbuffers;
914 interface->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer;
915 interface->fFramebufferTexture2D = debugGLFramebufferTexture2D;
916 interface->fGenFramebuffers = debugGLGenFramebuffers;
917 interface->fGenRenderbuffers = debugGLGenRenderbuffers;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000918 interface->fGetFramebufferAttachmentParameteriv =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000919 noOpGLGetFramebufferAttachmentParameteriv;
920 interface->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
921 interface->fRenderbufferStorage = noOpGLRenderbufferStorage;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000922 interface->fRenderbufferStorageMultisample =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000923 noOpGLRenderbufferStorageMultisample;
924 interface->fBlitFramebuffer = noOpGLBlitFramebuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000925 interface->fResolveMultisampleFramebuffer =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000926 noOpGLResolveMultisampleFramebuffer;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000927 interface->fMapBuffer = debugGLMapBuffer;
928 interface->fUnmapBuffer = debugGLUnmapBuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000929 interface->fBindFragDataLocationIndexed =
bsalomon@google.com8f943612013-02-26 14:34:43 +0000930 noOpGLBindFragDataLocationIndexed;
robertphillips@google.com409566a2012-06-26 20:19:41 +0000931
932 return interface;
robertphillips@google.com0da37192012-03-19 14:42:13 +0000933}