robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1 | |
| 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.com | dd743fe | 2012-04-05 14:40:53 +0000 | [diff] [blame] | 11 | #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.com | 670ff9a | 2012-04-12 19:53:31 +0000 | [diff] [blame] | 19 | #include "SkFloatingPoint.h" |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 20 | |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 21 | // the OpenGLES 2.0 spec says this must be >= 128 |
| 22 | static const GrGLint kDefaultMaxVertexUniformVectors = 128; |
| 23 | |
| 24 | // the OpenGLES 2.0 spec says this must be >=16 |
| 25 | static const GrGLint kDefaultMaxFragmentUniformVectors = 16; |
| 26 | |
| 27 | // the OpenGLES 2.0 spec says this must be >= 8 |
| 28 | static const GrGLint kDefaultMaxVertexAttribs = 8; |
| 29 | |
| 30 | // the OpenGLES 2.0 spec says this must be >= 8 |
| 31 | static const GrGLint kDefaultMaxVaryingVectors = 8; |
| 32 | |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 33 | namespace { // suppress no previsous prototype warning |
| 34 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 35 | //////////////////////////////////////////////////////////////////////////////// |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 36 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 37 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 38 | // Ganesh offsets the texture unit indices |
| 39 | texture -= GR_GL_TEXTURE0; |
| 40 | GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits()); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 41 | |
| 42 | GrDebugGL::getInstance()->setCurTextureUnit(texture); |
| 43 | } |
| 44 | |
| 45 | //////////////////////////////////////////////////////////////////////////////// |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 46 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 47 | GrGLuint shaderID) { |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 48 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 49 | GrProgramObj *program = GR_FIND(programID, GrProgramObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 50 | GrDebugGL::kProgram_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 51 | GrAlwaysAssert(program); |
| 52 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 53 | GrShaderObj *shader = GR_FIND(shaderID, |
| 54 | GrShaderObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 55 | GrDebugGL::kShader_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 56 | GrAlwaysAssert(shader); |
| 57 | |
| 58 | program->AttachShader(shader); |
| 59 | } |
| 60 | |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 61 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) { |
| 62 | } |
| 63 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 64 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program, |
| 65 | GrGLuint index, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 66 | const char* name) { |
| 67 | } |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 68 | |
| 69 | //////////////////////////////////////////////////////////////////////////////// |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 70 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 71 | GrGLuint textureID) { |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 72 | |
| 73 | // we don't use cube maps |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 74 | GrAlwaysAssert(target == GR_GL_TEXTURE_2D); |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 75 | // || target == GR_GL_TEXTURE_CUBE_MAP); |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 76 | |
| 77 | // a textureID of 0 is acceptable - it binds to the default texture target |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 78 | GrTextureObj *texture = GR_FIND(textureID, GrTextureObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 79 | GrDebugGL::kTexture_ObjTypes); |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 80 | |
| 81 | GrDebugGL::getInstance()->setTexture(texture); |
| 82 | } |
| 83 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 84 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBlendColor(GrGLclampf red, |
| 85 | GrGLclampf green, |
| 86 | GrGLclampf blue, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 87 | GrGLclampf alpha) { |
| 88 | } |
| 89 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 90 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFragDataLocation(GrGLuint program, |
| 91 | GrGLuint colorNumber, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 92 | const GrGLchar* name) { |
| 93 | } |
| 94 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 95 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBlendFunc(GrGLenum sfactor, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 96 | GrGLenum dfactor) { |
| 97 | } |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 98 | |
| 99 | //////////////////////////////////////////////////////////////////////////////// |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 100 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target, |
| 101 | GrGLsizeiptr size, |
| 102 | const GrGLvoid* data, |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 103 | GrGLenum usage) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 104 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 105 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 106 | GrAlwaysAssert(size >= 0); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 107 | GrAlwaysAssert(GR_GL_STREAM_DRAW == usage || |
| 108 | GR_GL_STATIC_DRAW == usage || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 109 | GR_GL_DYNAMIC_DRAW == usage); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 110 | |
| 111 | GrBufferObj *buffer = NULL; |
| 112 | switch (target) { |
| 113 | case GR_GL_ARRAY_BUFFER: |
| 114 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
| 115 | break; |
| 116 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
| 117 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
| 118 | break; |
| 119 | default: |
| 120 | GrCrash("Unexpected target to glBufferData"); |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | GrAlwaysAssert(buffer); |
| 125 | GrAlwaysAssert(buffer->getBound()); |
| 126 | |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 127 | buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data)); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 128 | buffer->setUsage(usage); |
| 129 | } |
| 130 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 131 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferSubData(GrGLenum target, |
| 132 | GrGLintptr offset, |
| 133 | GrGLsizeiptr size, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 134 | const GrGLvoid* data) { |
| 135 | } |
| 136 | |
| 137 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLClear(GrGLbitfield mask) { |
| 138 | } |
| 139 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 140 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLClearColor(GrGLclampf red, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 141 | GrGLclampf green, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 142 | GrGLclampf blue, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 143 | GrGLclampf alpha) { |
| 144 | } |
| 145 | |
| 146 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLClearStencil(GrGLint s) { |
| 147 | } |
| 148 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 149 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLColorMask(GrGLboolean red, |
| 150 | GrGLboolean green, |
| 151 | GrGLboolean blue, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 152 | GrGLboolean alpha) { |
| 153 | } |
| 154 | |
| 155 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLCompileShader(GrGLuint shader) { |
| 156 | } |
| 157 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 158 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLCompressedTexImage2D(GrGLenum target, |
| 159 | GrGLint level, |
| 160 | GrGLenum internalformat, |
| 161 | GrGLsizei width, |
| 162 | GrGLsizei height, |
| 163 | GrGLint border, |
| 164 | GrGLsizei imageSize, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 165 | const GrGLvoid* data) { |
| 166 | } |
| 167 | |
| 168 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLCullFace(GrGLenum mode) { |
| 169 | } |
| 170 | |
| 171 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDepthMask(GrGLboolean flag) { |
| 172 | } |
| 173 | |
| 174 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDisable(GrGLenum cap) { |
| 175 | } |
| 176 | |
| 177 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDisableVertexAttribArray(GrGLuint index) { |
| 178 | } |
| 179 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 180 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDrawArrays(GrGLenum mode, |
| 181 | GrGLint first, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 182 | GrGLsizei count) { |
| 183 | } |
| 184 | |
| 185 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDrawBuffer(GrGLenum mode) { |
| 186 | } |
| 187 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 188 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDrawBuffers(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 189 | const GrGLenum* bufs) { |
| 190 | } |
| 191 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 192 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDrawElements(GrGLenum mode, |
| 193 | GrGLsizei count, |
| 194 | GrGLenum type, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 195 | const GrGLvoid* indices) { |
| 196 | } |
| 197 | |
| 198 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLEnable(GrGLenum cap) { |
| 199 | } |
| 200 | |
| 201 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLEnableVertexAttribArray(GrGLuint index) { |
| 202 | } |
| 203 | |
| 204 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLEndQuery(GrGLenum target) { |
| 205 | } |
| 206 | |
| 207 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFinish() { |
| 208 | } |
| 209 | |
| 210 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFlush() { |
| 211 | } |
| 212 | |
| 213 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFrontFace(GrGLenum mode) { |
| 214 | } |
| 215 | |
| 216 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLLineWidth(GrGLfloat width) { |
| 217 | } |
| 218 | |
| 219 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLLinkProgram(GrGLuint program) { |
| 220 | } |
| 221 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 222 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 223 | GrGLint param) { |
robertphillips@google.com | 670ff9a | 2012-04-12 19:53:31 +0000 | [diff] [blame] | 224 | |
| 225 | switch (pname) { |
| 226 | case GR_GL_UNPACK_ROW_LENGTH: |
| 227 | GrDebugGL::getInstance()->setUnPackRowLength(param); |
| 228 | break; |
| 229 | case GR_GL_PACK_ROW_LENGTH: |
| 230 | GrDebugGL::getInstance()->setPackRowLength(param); |
| 231 | break; |
| 232 | case GR_GL_UNPACK_ALIGNMENT: |
| 233 | break; |
| 234 | case GR_GL_PACK_ALIGNMENT: |
| 235 | GrAlwaysAssert(false); |
| 236 | break; |
| 237 | default: |
| 238 | GrAlwaysAssert(false); |
| 239 | break; |
| 240 | } |
| 241 | } |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 242 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 243 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLQueryCounter(GrGLuint id, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 244 | GrGLenum target) { |
| 245 | } |
| 246 | |
| 247 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadBuffer(GrGLenum src) { |
| 248 | } |
| 249 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 250 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x, |
| 251 | GrGLint y, |
| 252 | GrGLsizei width, |
| 253 | GrGLsizei height, |
| 254 | GrGLenum format, |
| 255 | GrGLenum type, |
robertphillips@google.com | 670ff9a | 2012-04-12 19:53:31 +0000 | [diff] [blame] | 256 | GrGLvoid* pixels) { |
| 257 | |
| 258 | GrGLint pixelsInRow = width; |
| 259 | if (0 < GrDebugGL::getInstance()->getPackRowLength()) { |
| 260 | pixelsInRow = GrDebugGL::getInstance()->getPackRowLength(); |
| 261 | } |
| 262 | |
| 263 | GrGLint componentsPerPixel = 0; |
| 264 | |
| 265 | switch (format) { |
| 266 | case GR_GL_RGBA: |
| 267 | // fallthrough |
| 268 | case GR_GL_BGRA: |
| 269 | componentsPerPixel = 4; |
| 270 | break; |
| 271 | case GR_GL_RGB: |
| 272 | componentsPerPixel = 3; |
| 273 | break; |
robertphillips@google.com | d32369e | 2012-05-30 14:46:10 +0000 | [diff] [blame] | 274 | case GR_GL_RED: |
| 275 | componentsPerPixel = 1; |
| 276 | break; |
robertphillips@google.com | 670ff9a | 2012-04-12 19:53:31 +0000 | [diff] [blame] | 277 | default: |
| 278 | GrAlwaysAssert(false); |
| 279 | break; |
| 280 | } |
| 281 | |
| 282 | GrGLint alignment = 4; // the pack alignment (one of 1, 2, 4 or 8) |
| 283 | // Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT |
| 284 | |
| 285 | GrGLint componentSize = 0; // size (in bytes) of a single component |
| 286 | |
| 287 | switch (type) { |
| 288 | case GR_GL_UNSIGNED_BYTE: |
| 289 | componentSize = 1; |
| 290 | break; |
| 291 | default: |
| 292 | GrAlwaysAssert(false); |
| 293 | break; |
| 294 | } |
| 295 | |
| 296 | GrGLint rowStride = 0; // number of components (not bytes) to skip |
| 297 | if (componentSize >= alignment) { |
| 298 | rowStride = componentsPerPixel * pixelsInRow; |
| 299 | } else { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 300 | float fTemp = |
| 301 | sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow / |
robertphillips@google.com | 670ff9a | 2012-04-12 19:53:31 +0000 | [diff] [blame] | 302 | static_cast<float>(alignment)); |
| 303 | rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize); |
| 304 | } |
| 305 | |
| 306 | GrGLchar *scanline = static_cast<GrGLchar *>(pixels); |
| 307 | for (int y = 0; y < height; ++y) { |
| 308 | memset(scanline, 0, componentsPerPixel * componentSize * width); |
| 309 | scanline += rowStride; |
| 310 | } |
| 311 | } |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 312 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 313 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLScissor(GrGLint x, |
| 314 | GrGLint y, |
| 315 | GrGLsizei width, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 316 | GrGLsizei height) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 317 | } |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 318 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 319 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLShaderSource(GrGLuint shader, |
| 320 | GrGLsizei count, |
senorblanco@chromium.org | e0d44ff | 2012-11-19 20:43:10 +0000 | [diff] [blame] | 321 | #if GR_USE_NEW_GL_SHADER_SOURCE_SIGNATURE |
| 322 | const char* const * str, |
| 323 | #else |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 324 | const char** str, |
senorblanco@chromium.org | e0d44ff | 2012-11-19 20:43:10 +0000 | [diff] [blame] | 325 | #endif |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 326 | const GrGLint* length) { |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 327 | } |
| 328 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 329 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLStencilFunc(GrGLenum func, |
| 330 | GrGLint ref, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 331 | GrGLuint mask) { |
robertphillips@google.com | 7c95942 | 2012-03-22 20:43:56 +0000 | [diff] [blame] | 332 | } |
| 333 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 334 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLStencilFuncSeparate(GrGLenum face, |
| 335 | GrGLenum func, |
| 336 | GrGLint ref, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 337 | GrGLuint mask) { |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 338 | } |
| 339 | |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 340 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLStencilMask(GrGLuint mask) { |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 341 | } |
| 342 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 343 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLStencilMaskSeparate(GrGLenum face, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 344 | GrGLuint mask) { |
robertphillips@google.com | 7c95942 | 2012-03-22 20:43:56 +0000 | [diff] [blame] | 345 | } |
| 346 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 347 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLStencilOp(GrGLenum fail, |
| 348 | GrGLenum zfail, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 349 | GrGLenum zpass) { |
robertphillips@google.com | 7c95942 | 2012-03-22 20:43:56 +0000 | [diff] [blame] | 350 | } |
| 351 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 352 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLStencilOpSeparate(GrGLenum face, |
| 353 | GrGLenum fail, |
| 354 | GrGLenum zfail, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 355 | GrGLenum zpass) { |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 356 | } |
| 357 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 358 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLTexImage2D(GrGLenum target, |
| 359 | GrGLint level, |
| 360 | GrGLint internalformat, |
| 361 | GrGLsizei width, |
| 362 | GrGLsizei height, |
| 363 | GrGLint border, |
| 364 | GrGLenum format, |
| 365 | GrGLenum type, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 366 | const GrGLvoid* pixels) { |
| 367 | } |
| 368 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 369 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLTexParameteri(GrGLenum target, |
| 370 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 371 | GrGLint param) { |
| 372 | } |
| 373 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 374 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLTexParameteriv(GrGLenum target, |
| 375 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 376 | const GrGLint* params) { |
| 377 | } |
| 378 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 379 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLTexStorage2D(GrGLenum target, |
| 380 | GrGLsizei levels, |
| 381 | GrGLenum internalformat, |
| 382 | GrGLsizei width, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 383 | GrGLsizei height) { |
| 384 | } |
| 385 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 386 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLTexSubImage2D(GrGLenum target, |
| 387 | GrGLint level, |
| 388 | GrGLint xoffset, |
| 389 | GrGLint yoffset, |
| 390 | GrGLsizei width, |
| 391 | GrGLsizei height, |
| 392 | GrGLenum format, |
| 393 | GrGLenum type, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 394 | const GrGLvoid* pixels) { |
| 395 | } |
| 396 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 397 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform1f(GrGLint location, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 398 | GrGLfloat v0) { |
| 399 | } |
| 400 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 401 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform1i(GrGLint location, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 402 | GrGLint v0) { |
| 403 | } |
| 404 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 405 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform1fv(GrGLint location, |
| 406 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 407 | const GrGLfloat* v) { |
| 408 | } |
| 409 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 410 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform1iv(GrGLint location, |
| 411 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 412 | const GrGLint* v) { |
| 413 | } |
| 414 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 415 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform2f(GrGLint location, |
| 416 | GrGLfloat v0, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 417 | GrGLfloat v1) { |
| 418 | } |
| 419 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 420 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform2i(GrGLint location, |
| 421 | GrGLint v0, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 422 | GrGLint v1) { |
| 423 | } |
| 424 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 425 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform2fv(GrGLint location, |
| 426 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 427 | const GrGLfloat* v) { |
| 428 | } |
| 429 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 430 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform2iv(GrGLint location, |
| 431 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 432 | const GrGLint* v) { |
| 433 | } |
| 434 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 435 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform3f(GrGLint location, |
| 436 | GrGLfloat v0, |
| 437 | GrGLfloat v1, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 438 | GrGLfloat v2) { |
| 439 | } |
| 440 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 441 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform3i(GrGLint location, |
| 442 | GrGLint v0, |
| 443 | GrGLint v1, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 444 | GrGLint v2) { |
| 445 | } |
| 446 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 447 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform3fv(GrGLint location, |
| 448 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 449 | const GrGLfloat* v) { |
| 450 | } |
| 451 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 452 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform3iv(GrGLint location, |
| 453 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 454 | const GrGLint* v) { |
| 455 | } |
| 456 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 457 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform4f(GrGLint location, |
| 458 | GrGLfloat v0, |
| 459 | GrGLfloat v1, |
| 460 | GrGLfloat v2, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 461 | GrGLfloat v3) { |
| 462 | } |
| 463 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 464 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform4i(GrGLint location, |
| 465 | GrGLint v0, |
| 466 | GrGLint v1, |
| 467 | GrGLint v2, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 468 | GrGLint v3) { |
| 469 | } |
| 470 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 471 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform4fv(GrGLint location, |
| 472 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 473 | const GrGLfloat* v) { |
| 474 | } |
| 475 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 476 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniform4iv(GrGLint location, |
| 477 | GrGLsizei count, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 478 | const GrGLint* v) { |
| 479 | } |
| 480 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 481 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniformMatrix2fv(GrGLint location, |
| 482 | GrGLsizei count, |
| 483 | GrGLboolean transpose, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 484 | const GrGLfloat* value) { |
| 485 | } |
| 486 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 487 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniformMatrix3fv(GrGLint location, |
| 488 | GrGLsizei count, |
| 489 | GrGLboolean transpose, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 490 | const GrGLfloat* value) { |
| 491 | } |
| 492 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 493 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUniformMatrix4fv(GrGLint location, |
| 494 | GrGLsizei count, |
| 495 | GrGLboolean transpose, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 496 | const GrGLfloat* value) { |
| 497 | } |
| 498 | |
| 499 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) { |
| 500 | |
| 501 | // A programID of 0 is legal |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 502 | GrProgramObj *program = GR_FIND(programID, |
| 503 | GrProgramObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 504 | GrDebugGL::kProgram_ObjTypes); |
| 505 | |
| 506 | GrDebugGL::getInstance()->useProgram(program); |
| 507 | } |
| 508 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 509 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLVertexAttrib4fv(GrGLuint indx, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 510 | const GrGLfloat* values) { |
| 511 | } |
| 512 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 513 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLVertexAttribPointer(GrGLuint indx, |
| 514 | GrGLint size, |
| 515 | GrGLenum type, |
| 516 | GrGLboolean normalized, |
| 517 | GrGLsizei stride, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 518 | const GrGLvoid* ptr) { |
| 519 | } |
| 520 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 521 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLViewport(GrGLint x, |
| 522 | GrGLint y, |
| 523 | GrGLsizei width, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 524 | GrGLsizei height) { |
| 525 | } |
| 526 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 527 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 528 | GrGLuint frameBufferID) { |
| 529 | |
| 530 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
| 531 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 532 | // a frameBufferID of 0 is acceptable - it binds to the default |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 533 | // frame buffer |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 534 | GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID, |
| 535 | GrFrameBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 536 | GrDebugGL::kFrameBuffer_ObjTypes); |
| 537 | |
| 538 | GrDebugGL::getInstance()->setFrameBuffer(frameBuffer); |
| 539 | } |
| 540 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 541 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 542 | GrGLuint renderBufferID) { |
| 543 | |
| 544 | GrAlwaysAssert(GR_GL_RENDERBUFFER == target); |
| 545 | |
| 546 | // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 547 | GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID, |
| 548 | GrRenderBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 549 | GrDebugGL::kRenderBuffer_ObjTypes); |
| 550 | |
| 551 | GrDebugGL::getInstance()->setRenderBuffer(renderBuffer); |
| 552 | } |
| 553 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 554 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 555 | const GrGLuint* textures) { |
| 556 | |
| 557 | // first potentially unbind the texture |
| 558 | // TODO: move this into GrDebugGL as unBindTexture? |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 559 | for (unsigned int i = 0; |
| 560 | i < GrDebugGL::getInstance()->getMaxTextureUnits(); |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 561 | ++i) { |
| 562 | GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i); |
| 563 | |
| 564 | if (pTU->getTexture()) { |
| 565 | for (int j = 0; j < n; ++j) { |
| 566 | |
| 567 | if (textures[j] == pTU->getTexture()->getID()) { |
| 568 | // this ID is the current texture - revert the binding to 0 |
| 569 | pTU->setTexture(NULL); |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | // TODO: fuse the following block with DeleteRenderBuffers? |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 576 | // Open GL will remove a deleted render buffer from the active |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 577 | // frame buffer but not from any other frame buffer |
| 578 | if (GrDebugGL::getInstance()->getFrameBuffer()) { |
| 579 | |
| 580 | GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer(); |
| 581 | |
| 582 | for (int i = 0; i < n; ++i) { |
| 583 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 584 | if (NULL != frameBuffer->getColor() && |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 585 | textures[i] == frameBuffer->getColor()->getID()) { |
| 586 | frameBuffer->setColor(NULL); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 587 | } |
| 588 | if (NULL != frameBuffer->getDepth() && |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 589 | textures[i] == frameBuffer->getDepth()->getID()) { |
| 590 | frameBuffer->setDepth(NULL); |
| 591 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 592 | if (NULL != frameBuffer->getStencil() && |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 593 | textures[i] == frameBuffer->getStencil()->getID()) { |
| 594 | frameBuffer->setStencil(NULL); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | // then actually "delete" the buffers |
| 600 | for (int i = 0; i < n; ++i) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 601 | GrTextureObj *buffer = GR_FIND(textures[i], |
| 602 | GrTextureObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 603 | GrDebugGL::kTexture_ObjTypes); |
| 604 | GrAlwaysAssert(buffer); |
| 605 | |
| 606 | // OpenGL gives no guarantees if a texture is deleted while attached to |
| 607 | // something other than the currently bound frame buffer |
| 608 | GrAlwaysAssert(!buffer->getBound()); |
| 609 | |
| 610 | GrAlwaysAssert(!buffer->getDeleted()); |
| 611 | buffer->deleteAction(); |
| 612 | } |
| 613 | |
| 614 | } |
| 615 | |
| 616 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 617 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 618 | const GrGLuint *frameBuffers) { |
| 619 | |
| 620 | // first potentially unbind the buffers |
| 621 | if (GrDebugGL::getInstance()->getFrameBuffer()) { |
| 622 | for (int i = 0; i < n; ++i) { |
| 623 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 624 | if (frameBuffers[i] == |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 625 | GrDebugGL::getInstance()->getFrameBuffer()->getID()) { |
| 626 | // this ID is the current frame buffer - rebind to the default |
| 627 | GrDebugGL::getInstance()->setFrameBuffer(NULL); |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | // then actually "delete" the buffers |
| 633 | for (int i = 0; i < n; ++i) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 634 | GrFrameBufferObj *buffer = GR_FIND(frameBuffers[i], |
| 635 | GrFrameBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 636 | GrDebugGL::kFrameBuffer_ObjTypes); |
| 637 | GrAlwaysAssert(buffer); |
| 638 | |
| 639 | GrAlwaysAssert(!buffer->getDeleted()); |
| 640 | buffer->deleteAction(); |
| 641 | } |
| 642 | } |
| 643 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 644 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteRenderbuffers(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 645 | const GrGLuint *renderBuffers) { |
| 646 | |
| 647 | // first potentially unbind the buffers |
| 648 | if (GrDebugGL::getInstance()->getRenderBuffer()) { |
| 649 | for (int i = 0; i < n; ++i) { |
| 650 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 651 | if (renderBuffers[i] == |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 652 | GrDebugGL::getInstance()->getRenderBuffer()->getID()) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 653 | // this ID is the current render buffer - make no |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 654 | // render buffer be bound |
| 655 | GrDebugGL::getInstance()->setRenderBuffer(NULL); |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | // TODO: fuse the following block with DeleteTextures? |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 661 | // Open GL will remove a deleted render buffer from the active frame |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 662 | // buffer but not from any other frame buffer |
| 663 | if (GrDebugGL::getInstance()->getFrameBuffer()) { |
| 664 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 665 | GrFrameBufferObj *frameBuffer = |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 666 | GrDebugGL::getInstance()->getFrameBuffer(); |
| 667 | |
| 668 | for (int i = 0; i < n; ++i) { |
| 669 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 670 | if (NULL != frameBuffer->getColor() && |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 671 | renderBuffers[i] == frameBuffer->getColor()->getID()) { |
| 672 | frameBuffer->setColor(NULL); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 673 | } |
| 674 | if (NULL != frameBuffer->getDepth() && |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 675 | renderBuffers[i] == frameBuffer->getDepth()->getID()) { |
| 676 | frameBuffer->setDepth(NULL); |
| 677 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 678 | if (NULL != frameBuffer->getStencil() && |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 679 | renderBuffers[i] == frameBuffer->getStencil()->getID()) { |
| 680 | frameBuffer->setStencil(NULL); |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | // then actually "delete" the buffers |
| 686 | for (int i = 0; i < n; ++i) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 687 | GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i], |
| 688 | GrRenderBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 689 | GrDebugGL::kRenderBuffer_ObjTypes); |
| 690 | GrAlwaysAssert(buffer); |
| 691 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 692 | // OpenGL gives no guarantees if a render buffer is deleted |
| 693 | // while attached to something other than the currently |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 694 | // bound frame buffer |
| 695 | GrAlwaysAssert(!buffer->getColorBound()); |
| 696 | GrAlwaysAssert(!buffer->getDepthBound()); |
| 697 | GrAlwaysAssert(!buffer->getStencilBound()); |
| 698 | |
| 699 | GrAlwaysAssert(!buffer->getDeleted()); |
| 700 | buffer->deleteAction(); |
| 701 | } |
| 702 | } |
| 703 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 704 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferRenderbuffer(GrGLenum target, |
| 705 | GrGLenum attachment, |
| 706 | GrGLenum renderbuffertarget, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 707 | GrGLuint renderBufferID) { |
| 708 | |
| 709 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 710 | GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || |
| 711 | GR_GL_DEPTH_ATTACHMENT == attachment || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 712 | GR_GL_STENCIL_ATTACHMENT == attachment); |
| 713 | GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget); |
| 714 | |
| 715 | GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer(); |
| 716 | // A render buffer cannot be attached to the default framebuffer |
| 717 | GrAlwaysAssert(NULL != framebuffer); |
| 718 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 719 | // a renderBufferID of 0 is acceptable - it unbinds the current |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 720 | // render buffer |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 721 | GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID, |
| 722 | GrRenderBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 723 | GrDebugGL::kRenderBuffer_ObjTypes); |
| 724 | |
| 725 | switch (attachment) { |
| 726 | case GR_GL_COLOR_ATTACHMENT0: |
| 727 | framebuffer->setColor(renderbuffer); |
| 728 | break; |
| 729 | case GR_GL_DEPTH_ATTACHMENT: |
| 730 | framebuffer->setDepth(renderbuffer); |
| 731 | break; |
| 732 | case GR_GL_STENCIL_ATTACHMENT: |
| 733 | framebuffer->setStencil(renderbuffer); |
| 734 | break; |
| 735 | default: |
| 736 | GrAlwaysAssert(false); |
| 737 | break; |
| 738 | }; |
| 739 | |
| 740 | } |
| 741 | |
| 742 | //////////////////////////////////////////////////////////////////////////////// |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 743 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferTexture2D(GrGLenum target, |
| 744 | GrGLenum attachment, |
| 745 | GrGLenum textarget, |
| 746 | GrGLuint textureID, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 747 | GrGLint level) { |
| 748 | |
| 749 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 750 | GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || |
| 751 | GR_GL_DEPTH_ATTACHMENT == attachment || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 752 | GR_GL_STENCIL_ATTACHMENT == attachment); |
| 753 | GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget); |
| 754 | |
| 755 | GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer(); |
| 756 | // A texture cannot be attached to the default framebuffer |
| 757 | GrAlwaysAssert(NULL != framebuffer); |
| 758 | |
| 759 | // A textureID of 0 is allowed - it unbinds the currently bound texture |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 760 | GrTextureObj *texture = GR_FIND(textureID, GrTextureObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 761 | GrDebugGL::kTexture_ObjTypes); |
| 762 | if (texture) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 763 | // The texture shouldn't be bound to a texture unit - this |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 764 | // could lead to a feedback loop |
| 765 | GrAlwaysAssert(!texture->getBound()); |
| 766 | } |
| 767 | |
| 768 | GrAlwaysAssert(0 == level); |
| 769 | |
| 770 | switch (attachment) { |
| 771 | case GR_GL_COLOR_ATTACHMENT0: |
| 772 | framebuffer->setColor(texture); |
| 773 | break; |
| 774 | case GR_GL_DEPTH_ATTACHMENT: |
| 775 | framebuffer->setDepth(texture); |
| 776 | break; |
| 777 | case GR_GL_STENCIL_ATTACHMENT: |
| 778 | framebuffer->setStencil(texture); |
| 779 | break; |
| 780 | default: |
| 781 | GrAlwaysAssert(false); |
| 782 | break; |
| 783 | }; |
| 784 | } |
| 785 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 786 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetFramebufferAttachmentParameteriv(GrGLenum target, |
| 787 | GrGLenum attachment, |
| 788 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 789 | GrGLint* params) { |
| 790 | } |
| 791 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 792 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetRenderbufferParameteriv(GrGLenum target, |
| 793 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 794 | GrGLint* params) { |
| 795 | } |
| 796 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 797 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLRenderbufferStorage(GrGLenum target, |
| 798 | GrGLenum internalformat, |
| 799 | GrGLsizei width, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 800 | GrGLsizei height) { |
| 801 | } |
| 802 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 803 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLRenderbufferStorageMultisample(GrGLenum target, |
| 804 | GrGLsizei samples, |
| 805 | GrGLenum internalformat, |
| 806 | GrGLsizei width, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 807 | GrGLsizei height) { |
| 808 | } |
| 809 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 810 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBlitFramebuffer(GrGLint srcX0, |
| 811 | GrGLint srcY0, |
| 812 | GrGLint srcX1, |
| 813 | GrGLint srcY1, |
| 814 | GrGLint dstX0, |
| 815 | GrGLint dstY0, |
| 816 | GrGLint dstX1, |
| 817 | GrGLint dstY1, |
| 818 | GrGLbitfield mask, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 819 | GrGLenum filter) { |
| 820 | } |
| 821 | |
| 822 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLResolveMultisampleFramebuffer() { |
| 823 | } |
| 824 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 825 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFragDataLocationIndexed(GrGLuint program, |
| 826 | GrGLuint colorNumber, |
| 827 | GrGLuint index, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 828 | const GrGLchar * name) { |
| 829 | } |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 830 | |
| 831 | GrGLenum GR_GL_FUNCTION_TYPE debugGLCheckFramebufferStatus(GrGLenum target) { |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 832 | |
| 833 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
| 834 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 835 | return GR_GL_FRAMEBUFFER_COMPLETE; |
| 836 | } |
| 837 | |
| 838 | GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateProgram() { |
| 839 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 840 | GrProgramObj *program = GR_CREATE(GrProgramObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 841 | GrDebugGL::kProgram_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 842 | |
| 843 | return program->getID(); |
| 844 | } |
| 845 | |
| 846 | GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateShader(GrGLenum type) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 847 | |
| 848 | GrAlwaysAssert(GR_GL_VERTEX_SHADER == type || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 849 | GR_GL_FRAGMENT_SHADER == type); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 850 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 851 | GrShaderObj *shader = GR_CREATE(GrShaderObj, GrDebugGL::kShader_ObjTypes); |
| 852 | shader->setType(type); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 853 | |
| 854 | return shader->getID(); |
| 855 | } |
| 856 | |
| 857 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteProgram(GrGLuint programID) { |
| 858 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 859 | GrProgramObj *program = GR_FIND(programID, |
| 860 | GrProgramObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 861 | GrDebugGL::kProgram_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 862 | GrAlwaysAssert(program); |
| 863 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 864 | if (program->getRefCount()) { |
| 865 | // someone is still using this program so we can't delete it here |
| 866 | program->setMarkedForDeletion(); |
| 867 | } else { |
| 868 | program->deleteAction(); |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteShader(GrGLuint shaderID) { |
| 873 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 874 | GrShaderObj *shader = GR_FIND(shaderID, |
| 875 | GrShaderObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 876 | GrDebugGL::kShader_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 877 | GrAlwaysAssert(shader); |
| 878 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 879 | if (shader->getRefCount()) { |
| 880 | // someone is still using this shader so we can't delete it here |
| 881 | shader->setMarkedForDeletion(); |
| 882 | } else { |
| 883 | shader->deleteAction(); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | // same function used for all glGen*(GLsize i, GLuint*) functions |
| 888 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenIds(GrGLsizei n, GrGLuint* ids) { |
| 889 | static int gCurrID = 1; |
| 890 | for (int i = 0; i < n; ++i) { |
| 891 | ids[i] = ++gCurrID; |
| 892 | } |
| 893 | } |
| 894 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 895 | GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type, |
| 896 | GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 897 | GrGLuint* ids) { |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 898 | |
| 899 | for (int i = 0; i < n; ++i) { |
| 900 | GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type); |
| 901 | GrAlwaysAssert(obj); |
| 902 | ids[i] = obj->getID(); |
| 903 | } |
| 904 | } |
| 905 | |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 906 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) { |
| 907 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 908 | debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 909 | } |
| 910 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 911 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 912 | GrGLuint* ids) { |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 913 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 914 | debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids); |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 915 | } |
| 916 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 917 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 918 | GrGLuint* ids) { |
robertphillips@google.com | 7c95942 | 2012-03-22 20:43:56 +0000 | [diff] [blame] | 919 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 920 | debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids); |
| 921 | } |
| 922 | |
| 923 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) { |
| 924 | |
| 925 | debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids); |
robertphillips@google.com | 7c95942 | 2012-03-22 20:43:56 +0000 | [diff] [blame] | 926 | } |
| 927 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 928 | // same delete function for all glDelete*(GLsize i, const GLuint*) except |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 929 | // buffers |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 930 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteIds(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 931 | const GrGLuint* ids) { |
| 932 | } |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 933 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 934 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 935 | GrGLuint bufferID) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 936 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 937 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 938 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 939 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 940 | GrBufferObj *buffer = GR_FIND(bufferID, |
| 941 | GrBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 942 | GrDebugGL::kBuffer_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 943 | // 0 is a permissable bufferID - it unbinds the current buffer |
| 944 | |
| 945 | switch (target) { |
| 946 | case GR_GL_ARRAY_BUFFER: |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 947 | GrDebugGL::getInstance()->setArrayBuffer(buffer); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 948 | break; |
| 949 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 950 | GrDebugGL::getInstance()->setElementArrayBuffer(buffer); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 951 | break; |
| 952 | default: |
| 953 | GrCrash("Unexpected target to glBindBuffer"); |
| 954 | break; |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | // deleting a bound buffer has the side effect of binding 0 |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 959 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 960 | const GrGLuint* ids) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 961 | // first potentially unbind the buffers |
| 962 | for (int i = 0; i < n; ++i) { |
| 963 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 964 | if (GrDebugGL::getInstance()->getArrayBuffer() && |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 965 | ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) { |
| 966 | // this ID is the current array buffer |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 967 | GrDebugGL::getInstance()->setArrayBuffer(NULL); |
| 968 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 969 | if (GrDebugGL::getInstance()->getElementArrayBuffer() && |
| 970 | ids[i] == |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 971 | GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 972 | // this ID is the current element array buffer |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 973 | GrDebugGL::getInstance()->setElementArrayBuffer(NULL); |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | // then actually "delete" the buffers |
| 978 | for (int i = 0; i < n; ++i) { |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 979 | GrBufferObj *buffer = GR_FIND(ids[i], |
| 980 | GrBufferObj, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 981 | GrDebugGL::kBuffer_ObjTypes); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 982 | GrAlwaysAssert(buffer); |
| 983 | |
| 984 | GrAlwaysAssert(!buffer->getDeleted()); |
| 985 | buffer->deleteAction(); |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | // map a buffer to the caller's address space |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 990 | GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 991 | GrGLenum access) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 992 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 993 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 994 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
| 995 | // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 996 | GrAlwaysAssert(GR_GL_WRITE_ONLY == access); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 997 | |
| 998 | GrBufferObj *buffer = NULL; |
| 999 | switch (target) { |
| 1000 | case GR_GL_ARRAY_BUFFER: |
| 1001 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
| 1002 | break; |
| 1003 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
| 1004 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
| 1005 | break; |
| 1006 | default: |
| 1007 | GrCrash("Unexpected target to glMapBuffer"); |
| 1008 | break; |
| 1009 | } |
| 1010 | |
| 1011 | if (buffer) { |
| 1012 | GrAlwaysAssert(!buffer->getMapped()); |
| 1013 | buffer->setMapped(); |
| 1014 | return buffer->getDataPtr(); |
| 1015 | } |
| 1016 | |
| 1017 | GrAlwaysAssert(false); |
| 1018 | return NULL; // no buffer bound to the target |
| 1019 | } |
| 1020 | |
| 1021 | // remove a buffer from the caller's address space |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1022 | // TODO: check if the "access" method from "glMapBuffer" was honored |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1023 | GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) { |
| 1024 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1025 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1026 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1027 | |
| 1028 | GrBufferObj *buffer = NULL; |
| 1029 | switch (target) { |
| 1030 | case GR_GL_ARRAY_BUFFER: |
| 1031 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
| 1032 | break; |
| 1033 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
| 1034 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
| 1035 | break; |
| 1036 | default: |
| 1037 | GrCrash("Unexpected target to glUnmapBuffer"); |
| 1038 | break; |
| 1039 | } |
| 1040 | |
| 1041 | if (buffer) { |
| 1042 | GrAlwaysAssert(buffer->getMapped()); |
| 1043 | buffer->resetMapped(); |
| 1044 | return GR_GL_TRUE; |
| 1045 | } |
| 1046 | |
| 1047 | GrAlwaysAssert(false); |
| 1048 | return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; |
| 1049 | } |
| 1050 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1051 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target, |
| 1052 | GrGLenum value, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1053 | GrGLint* params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1054 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1055 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1056 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1057 | GrAlwaysAssert(GR_GL_BUFFER_SIZE == value || |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1058 | GR_GL_BUFFER_USAGE == value); |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1059 | |
| 1060 | GrBufferObj *buffer = NULL; |
| 1061 | switch (target) { |
| 1062 | case GR_GL_ARRAY_BUFFER: |
| 1063 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
| 1064 | break; |
| 1065 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
| 1066 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1067 | break; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | GrAlwaysAssert(buffer); |
| 1071 | |
| 1072 | switch (value) { |
| 1073 | case GR_GL_BUFFER_MAPPED: |
| 1074 | *params = GR_GL_FALSE; |
| 1075 | if (buffer) |
| 1076 | *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE; |
| 1077 | break; |
| 1078 | case GR_GL_BUFFER_SIZE: |
| 1079 | *params = 0; |
| 1080 | if (buffer) |
| 1081 | *params = buffer->getSize(); |
| 1082 | break; |
| 1083 | case GR_GL_BUFFER_USAGE: |
| 1084 | *params = GR_GL_STATIC_DRAW; |
| 1085 | if (buffer) |
| 1086 | *params = buffer->getUsage(); |
| 1087 | break; |
| 1088 | default: |
| 1089 | GrCrash("Unexpected value to glGetBufferParamateriv"); |
| 1090 | break; |
| 1091 | } |
| 1092 | }; |
| 1093 | |
| 1094 | GrGLenum GR_GL_FUNCTION_TYPE debugGLGetError() { |
| 1095 | return GR_GL_NO_ERROR; |
| 1096 | } |
| 1097 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1098 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetIntegerv(GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1099 | GrGLint* params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1100 | // TODO: remove from Ganesh the #defines for gets we don't use. |
| 1101 | // We would like to minimize gets overall due to performance issues |
| 1102 | switch (pname) { |
| 1103 | case GR_GL_STENCIL_BITS: |
| 1104 | *params = 8; |
| 1105 | break; |
| 1106 | case GR_GL_SAMPLES: |
| 1107 | *params = 1; |
| 1108 | break; |
| 1109 | case GR_GL_FRAMEBUFFER_BINDING: |
| 1110 | *params = 0; |
| 1111 | break; |
| 1112 | case GR_GL_VIEWPORT: |
| 1113 | params[0] = 0; |
| 1114 | params[1] = 0; |
| 1115 | params[2] = 800; |
| 1116 | params[3] = 600; |
| 1117 | break; |
| 1118 | case GR_GL_MAX_TEXTURE_IMAGE_UNITS: |
| 1119 | *params = 8; |
| 1120 | break; |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 1121 | case GR_GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 1122 | *params = kDefaultMaxVertexUniformVectors; |
| 1123 | break; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1124 | case GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 1125 | *params = kDefaultMaxFragmentUniformVectors; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1126 | break; |
| 1127 | case GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 1128 | *params = 16 * 4; |
| 1129 | break; |
| 1130 | case GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 1131 | *params = 0; |
| 1132 | break; |
| 1133 | case GR_GL_COMPRESSED_TEXTURE_FORMATS: |
| 1134 | break; |
| 1135 | case GR_GL_MAX_TEXTURE_SIZE: |
| 1136 | *params = 8192; |
| 1137 | break; |
| 1138 | case GR_GL_MAX_RENDERBUFFER_SIZE: |
| 1139 | *params = 8192; |
| 1140 | break; |
| 1141 | case GR_GL_MAX_SAMPLES: |
| 1142 | *params = 32; |
| 1143 | break; |
| 1144 | case GR_GL_MAX_VERTEX_ATTRIBS: |
robertphillips@google.com | f6f123d | 2012-03-21 17:57:55 +0000 | [diff] [blame] | 1145 | *params = kDefaultMaxVertexAttribs; |
| 1146 | break; |
| 1147 | case GR_GL_MAX_VARYING_VECTORS: |
| 1148 | *params = kDefaultMaxVaryingVectors; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1149 | break; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1150 | default: |
| 1151 | GrCrash("Unexpected pname to GetIntegerv"); |
| 1152 | } |
| 1153 | } |
| 1154 | // used for both the program and shader info logs |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1155 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetInfoLog(GrGLuint program, |
| 1156 | GrGLsizei bufsize, |
| 1157 | GrGLsizei* length, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1158 | char* infolog) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1159 | if (length) { |
| 1160 | *length = 0; |
| 1161 | } |
| 1162 | if (bufsize > 0) { |
| 1163 | *infolog = 0; |
| 1164 | } |
| 1165 | } |
| 1166 | |
| 1167 | // used for both the program and shader params |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1168 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetShaderOrProgramiv(GrGLuint program, |
| 1169 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1170 | GrGLint* params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1171 | switch (pname) { |
| 1172 | case GR_GL_LINK_STATUS: // fallthru |
| 1173 | case GR_GL_COMPILE_STATUS: |
| 1174 | *params = GR_GL_TRUE; |
| 1175 | break; |
| 1176 | case GR_GL_INFO_LOG_LENGTH: |
| 1177 | *params = 0; |
| 1178 | break; |
| 1179 | // we don't expect any other pnames |
| 1180 | default: |
| 1181 | GrCrash("Unexpected pname to GetProgramiv"); |
| 1182 | break; |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | namespace { |
| 1187 | template <typename T> |
| 1188 | void query_result(GrGLenum GLtarget, GrGLenum pname, T *params) { |
| 1189 | switch (pname) { |
| 1190 | case GR_GL_QUERY_RESULT_AVAILABLE: |
| 1191 | *params = GR_GL_TRUE; |
| 1192 | break; |
| 1193 | case GR_GL_QUERY_RESULT: |
| 1194 | *params = 0; |
| 1195 | break; |
| 1196 | default: |
| 1197 | GrCrash("Unexpected pname passed to GetQueryObject."); |
| 1198 | break; |
| 1199 | } |
| 1200 | } |
| 1201 | } |
| 1202 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1203 | // Queries on the null GL just don't do anything at all. We could potentially |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1204 | // make the timers work. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1205 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetQueryiv(GrGLenum GLtarget, |
| 1206 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1207 | GrGLint *params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1208 | switch (pname) { |
| 1209 | case GR_GL_CURRENT_QUERY: |
| 1210 | *params = 0; |
| 1211 | break; |
| 1212 | case GR_GL_QUERY_COUNTER_BITS: |
| 1213 | *params = 32; |
| 1214 | break; |
| 1215 | default: |
| 1216 | GrCrash("Unexpected pname passed GetQueryiv."); |
| 1217 | } |
| 1218 | } |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1219 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1220 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetQueryObjecti64v(GrGLuint id, |
| 1221 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1222 | GrGLint64 *params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1223 | query_result(id, pname, params); |
| 1224 | } |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1225 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1226 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetQueryObjectiv(GrGLuint id, |
| 1227 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1228 | GrGLint *params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1229 | query_result(id, pname, params); |
| 1230 | } |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1231 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1232 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetQueryObjectui64v(GrGLuint id, |
| 1233 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1234 | GrGLuint64 *params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1235 | query_result(id, pname, params); |
| 1236 | } |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1237 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1238 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetQueryObjectuiv(GrGLuint id, |
| 1239 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1240 | GrGLuint *params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1241 | query_result(id, pname, params); |
| 1242 | } |
| 1243 | |
| 1244 | const GrGLubyte* GR_GL_FUNCTION_TYPE debugGLGetString(GrGLenum name) { |
| 1245 | switch (name) { |
| 1246 | case GR_GL_EXTENSIONS: |
| 1247 | return (const GrGLubyte*)"GL_ARB_framebuffer_object GL_ARB_blend_func_extended GL_ARB_timer_query GL_ARB_draw_buffers GL_ARB_occlusion_query GL_EXT_blend_color GL_EXT_stencil_wrap"; |
| 1248 | case GR_GL_VERSION: |
bsalomon@google.com | c345c42 | 2012-06-15 14:16:00 +0000 | [diff] [blame] | 1249 | return (const GrGLubyte*)"4.0 Debug GL"; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1250 | case GR_GL_SHADING_LANGUAGE_VERSION: |
bsalomon@google.com | c345c42 | 2012-06-15 14:16:00 +0000 | [diff] [blame] | 1251 | return (const GrGLubyte*)"4.20.8 Debug GLSL"; |
| 1252 | case GR_GL_VENDOR: |
| 1253 | return (const GrGLubyte*)"Debug Vendor"; |
| 1254 | case GR_GL_RENDERER: |
| 1255 | return (const GrGLubyte*)"The Debug (Non-)Renderer"; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1256 | default: |
| 1257 | GrCrash("Unexpected name to GetString"); |
| 1258 | return NULL; |
| 1259 | } |
| 1260 | } |
| 1261 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1262 | // we used to use this to query stuff about externally created textures, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1263 | // now we just require clients to tell us everything about the texture. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1264 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetTexLevelParameteriv(GrGLenum target, |
| 1265 | GrGLint level, |
| 1266 | GrGLenum pname, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1267 | GrGLint* params) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1268 | GrCrash("Should never query texture parameters."); |
| 1269 | } |
| 1270 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1271 | GrGLint GR_GL_FUNCTION_TYPE debugGLGetUniformLocation(GrGLuint program, |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1272 | const char* name) { |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1273 | static int gUniLocation = 0; |
| 1274 | return ++gUniLocation; |
| 1275 | } |
| 1276 | |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 1277 | } // end of namespace |
| 1278 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1279 | //////////////////////////////////////////////////////////////////////////////// |
| 1280 | struct GrDebugGLInterface : public GrGLInterface { |
| 1281 | |
| 1282 | public: |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1283 | SK_DECLARE_INST_COUNT(GrDebugGLInterface) |
| 1284 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1285 | GrDebugGLInterface() |
| 1286 | : fWrapped(NULL) { |
robertphillips@google.com | 622a170 | 2012-07-31 19:23:02 +0000 | [diff] [blame] | 1287 | GrDebugGL::staticRef(); |
| 1288 | } |
| 1289 | |
| 1290 | virtual ~GrDebugGLInterface() { |
| 1291 | GrDebugGL::staticUnRef(); |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | void setWrapped(GrGLInterface *interface) { |
| 1295 | fWrapped.reset(interface); |
| 1296 | } |
| 1297 | |
| 1298 | // TODO: there are some issues w/ wrapping another GL interface inside the |
| 1299 | // debug interface: |
| 1300 | // Since none of the "gl" methods are member functions they don't get |
| 1301 | // a "this" pointer through which to access "fWrapped" |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1302 | // This could be worked around by having all of them access the |
| 1303 | // "glInterface" pointer - i.e., treating the debug interface as a |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1304 | // true singleton |
| 1305 | // |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1306 | // The problem with this is that we also want to handle OpenGL |
| 1307 | // contexts. The natural way to do this is to have multiple debug |
| 1308 | // interfaces. Each of which represents a separate context. The |
| 1309 | // static ID count would still uniquify IDs across all of them. |
| 1310 | // The problem then is that we couldn't treat the debug GL |
| 1311 | // interface as a singleton (since there would be one for each |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1312 | // context). |
| 1313 | // |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1314 | // The solution to this is probably to alter SkDebugGlContext's |
| 1315 | // "makeCurrent" method to make a call like "makeCurrent(this)" to |
| 1316 | // the debug GL interface (assuming that the application will create |
| 1317 | // multiple SkGLContext's) to let it switch between the active |
| 1318 | // context. Everything in the GrDebugGL object would then need to be |
| 1319 | // moved to a GrContextObj and the GrDebugGL object would just switch |
| 1320 | // between them. Note that this approach would also require that |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1321 | // SkDebugGLContext wrap an arbitrary other context |
| 1322 | // and then pass the wrapped interface to the debug GL interface. |
| 1323 | |
| 1324 | protected: |
| 1325 | private: |
| 1326 | |
| 1327 | SkAutoTUnref<GrGLInterface> fWrapped; |
| 1328 | |
| 1329 | typedef GrGLInterface INHERITED; |
| 1330 | }; |
| 1331 | |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1332 | SK_DEFINE_INST_COUNT(GrDebugGLInterface) |
| 1333 | |
robertphillips@google.com | ba0cc3e | 2012-03-26 17:58:35 +0000 | [diff] [blame] | 1334 | //////////////////////////////////////////////////////////////////////////////// |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1335 | const GrGLInterface* GrGLCreateDebugInterface() { |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1336 | GrGLInterface* interface = SkNEW(GrDebugGLInterface); |
| 1337 | |
| 1338 | interface->fBindingsExported = kDesktop_GrGLBinding; |
| 1339 | interface->fActiveTexture = debugGLActiveTexture; |
| 1340 | interface->fAttachShader = debugGLAttachShader; |
| 1341 | interface->fBeginQuery = debugGLBeginQuery; |
| 1342 | interface->fBindAttribLocation = debugGLBindAttribLocation; |
| 1343 | interface->fBindBuffer = debugGLBindBuffer; |
| 1344 | interface->fBindFragDataLocation = debugGLBindFragDataLocation; |
| 1345 | interface->fBindTexture = debugGLBindTexture; |
| 1346 | interface->fBlendColor = debugGLBlendColor; |
| 1347 | interface->fBlendFunc = debugGLBlendFunc; |
| 1348 | interface->fBufferData = debugGLBufferData; |
| 1349 | interface->fBufferSubData = debugGLBufferSubData; |
| 1350 | interface->fClear = debugGLClear; |
| 1351 | interface->fClearColor = debugGLClearColor; |
| 1352 | interface->fClearStencil = debugGLClearStencil; |
| 1353 | interface->fColorMask = debugGLColorMask; |
| 1354 | interface->fCompileShader = debugGLCompileShader; |
| 1355 | interface->fCompressedTexImage2D = debugGLCompressedTexImage2D; |
| 1356 | interface->fCreateProgram = debugGLCreateProgram; |
| 1357 | interface->fCreateShader = debugGLCreateShader; |
| 1358 | interface->fCullFace = debugGLCullFace; |
| 1359 | interface->fDeleteBuffers = debugGLDeleteBuffers; |
| 1360 | interface->fDeleteProgram = debugGLDeleteProgram; |
| 1361 | interface->fDeleteQueries = debugGLDeleteIds; |
| 1362 | interface->fDeleteShader = debugGLDeleteShader; |
| 1363 | interface->fDeleteTextures = debugGLDeleteTextures; |
| 1364 | interface->fDepthMask = debugGLDepthMask; |
| 1365 | interface->fDisable = debugGLDisable; |
| 1366 | interface->fDisableVertexAttribArray = debugGLDisableVertexAttribArray; |
| 1367 | interface->fDrawArrays = debugGLDrawArrays; |
| 1368 | interface->fDrawBuffer = debugGLDrawBuffer; |
| 1369 | interface->fDrawBuffers = debugGLDrawBuffers; |
| 1370 | interface->fDrawElements = debugGLDrawElements; |
| 1371 | interface->fEnable = debugGLEnable; |
| 1372 | interface->fEnableVertexAttribArray = debugGLEnableVertexAttribArray; |
| 1373 | interface->fEndQuery = debugGLEndQuery; |
| 1374 | interface->fFinish = debugGLFinish; |
| 1375 | interface->fFlush = debugGLFlush; |
| 1376 | interface->fFrontFace = debugGLFrontFace; |
| 1377 | interface->fGenBuffers = debugGLGenBuffers; |
| 1378 | interface->fGenQueries = debugGLGenIds; |
| 1379 | interface->fGenTextures = debugGLGenTextures; |
| 1380 | interface->fGetBufferParameteriv = debugGLGetBufferParameteriv; |
| 1381 | interface->fGetError = debugGLGetError; |
| 1382 | interface->fGetIntegerv = debugGLGetIntegerv; |
| 1383 | interface->fGetQueryObjecti64v = debugGLGetQueryObjecti64v; |
| 1384 | interface->fGetQueryObjectiv = debugGLGetQueryObjectiv; |
| 1385 | interface->fGetQueryObjectui64v = debugGLGetQueryObjectui64v; |
| 1386 | interface->fGetQueryObjectuiv = debugGLGetQueryObjectuiv; |
| 1387 | interface->fGetQueryiv = debugGLGetQueryiv; |
| 1388 | interface->fGetProgramInfoLog = debugGLGetInfoLog; |
| 1389 | interface->fGetProgramiv = debugGLGetShaderOrProgramiv; |
| 1390 | interface->fGetShaderInfoLog = debugGLGetInfoLog; |
| 1391 | interface->fGetShaderiv = debugGLGetShaderOrProgramiv; |
| 1392 | interface->fGetString = debugGLGetString; |
| 1393 | interface->fGetTexLevelParameteriv = debugGLGetTexLevelParameteriv; |
| 1394 | interface->fGetUniformLocation = debugGLGetUniformLocation; |
| 1395 | interface->fLineWidth = debugGLLineWidth; |
| 1396 | interface->fLinkProgram = debugGLLinkProgram; |
| 1397 | interface->fPixelStorei = debugGLPixelStorei; |
| 1398 | interface->fQueryCounter = debugGLQueryCounter; |
| 1399 | interface->fReadBuffer = debugGLReadBuffer; |
| 1400 | interface->fReadPixels = debugGLReadPixels; |
| 1401 | interface->fScissor = debugGLScissor; |
| 1402 | interface->fShaderSource = debugGLShaderSource; |
| 1403 | interface->fStencilFunc = debugGLStencilFunc; |
| 1404 | interface->fStencilFuncSeparate = debugGLStencilFuncSeparate; |
| 1405 | interface->fStencilMask = debugGLStencilMask; |
| 1406 | interface->fStencilMaskSeparate = debugGLStencilMaskSeparate; |
| 1407 | interface->fStencilOp = debugGLStencilOp; |
| 1408 | interface->fStencilOpSeparate = debugGLStencilOpSeparate; |
| 1409 | interface->fTexImage2D = debugGLTexImage2D; |
| 1410 | interface->fTexParameteri = debugGLTexParameteri; |
| 1411 | interface->fTexParameteriv = debugGLTexParameteriv; |
| 1412 | interface->fTexSubImage2D = debugGLTexSubImage2D; |
| 1413 | interface->fTexStorage2D = debugGLTexStorage2D; |
| 1414 | interface->fUniform1f = debugGLUniform1f; |
| 1415 | interface->fUniform1i = debugGLUniform1i; |
| 1416 | interface->fUniform1fv = debugGLUniform1fv; |
| 1417 | interface->fUniform1iv = debugGLUniform1iv; |
| 1418 | interface->fUniform2f = debugGLUniform2f; |
| 1419 | interface->fUniform2i = debugGLUniform2i; |
| 1420 | interface->fUniform2fv = debugGLUniform2fv; |
| 1421 | interface->fUniform2iv = debugGLUniform2iv; |
| 1422 | interface->fUniform3f = debugGLUniform3f; |
| 1423 | interface->fUniform3i = debugGLUniform3i; |
| 1424 | interface->fUniform3fv = debugGLUniform3fv; |
| 1425 | interface->fUniform3iv = debugGLUniform3iv; |
| 1426 | interface->fUniform4f = debugGLUniform4f; |
| 1427 | interface->fUniform4i = debugGLUniform4i; |
| 1428 | interface->fUniform4fv = debugGLUniform4fv; |
| 1429 | interface->fUniform4iv = debugGLUniform4iv; |
| 1430 | interface->fUniformMatrix2fv = debugGLUniformMatrix2fv; |
| 1431 | interface->fUniformMatrix3fv = debugGLUniformMatrix3fv; |
| 1432 | interface->fUniformMatrix4fv = debugGLUniformMatrix4fv; |
| 1433 | interface->fUseProgram = debugGLUseProgram; |
| 1434 | interface->fVertexAttrib4fv = debugGLVertexAttrib4fv; |
| 1435 | interface->fVertexAttribPointer = debugGLVertexAttribPointer; |
| 1436 | interface->fViewport = debugGLViewport; |
| 1437 | interface->fBindFramebuffer = debugGLBindFramebuffer; |
| 1438 | interface->fBindRenderbuffer = debugGLBindRenderbuffer; |
| 1439 | interface->fCheckFramebufferStatus = debugGLCheckFramebufferStatus; |
| 1440 | interface->fDeleteFramebuffers = debugGLDeleteFramebuffers; |
| 1441 | interface->fDeleteRenderbuffers = debugGLDeleteRenderbuffers; |
| 1442 | interface->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer; |
| 1443 | interface->fFramebufferTexture2D = debugGLFramebufferTexture2D; |
| 1444 | interface->fGenFramebuffers = debugGLGenFramebuffers; |
| 1445 | interface->fGenRenderbuffers = debugGLGenRenderbuffers; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1446 | interface->fGetFramebufferAttachmentParameteriv = |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1447 | debugGLGetFramebufferAttachmentParameteriv; |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1448 | interface->fGetRenderbufferParameteriv = debugGLGetRenderbufferParameteriv; |
| 1449 | interface->fRenderbufferStorage = debugGLRenderbufferStorage; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1450 | interface->fRenderbufferStorageMultisample = |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1451 | debugGLRenderbufferStorageMultisample; |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1452 | interface->fBlitFramebuffer = debugGLBlitFramebuffer; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1453 | interface->fResolveMultisampleFramebuffer = |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1454 | debugGLResolveMultisampleFramebuffer; |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1455 | interface->fMapBuffer = debugGLMapBuffer; |
| 1456 | interface->fUnmapBuffer = debugGLUnmapBuffer; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 1457 | interface->fBindFragDataLocationIndexed = |
robertphillips@google.com | ebde3e0 | 2012-07-13 17:45:17 +0000 | [diff] [blame] | 1458 | debugGLBindFragDataLocationIndexed; |
robertphillips@google.com | 409566a | 2012-06-26 20:19:41 +0000 | [diff] [blame] | 1459 | |
| 1460 | return interface; |
robertphillips@google.com | 0da3719 | 2012-03-19 14:42:13 +0000 | [diff] [blame] | 1461 | } |