2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "gl/GrGLInterface.h"
|
2012-04-05 14:40:53 +00:00
|
|
|
#include "GrDebugGL.h"
|
|
|
|
#include "GrShaderObj.h"
|
|
|
|
#include "GrProgramObj.h"
|
|
|
|
#include "GrBufferObj.h"
|
|
|
|
#include "GrTextureUnitObj.h"
|
|
|
|
#include "GrTextureObj.h"
|
|
|
|
#include "GrFrameBufferObj.h"
|
|
|
|
#include "GrRenderBufferObj.h"
|
2013-03-01 15:36:02 +00:00
|
|
|
#include "GrVertexArrayObj.h"
|
2012-04-12 19:53:31 +00:00
|
|
|
#include "SkFloatingPoint.h"
|
2013-02-26 14:34:43 +00:00
|
|
|
#include "../GrGLNoOpInterface.h"
|
2012-03-19 14:42:13 +00:00
|
|
|
|
2013-02-26 14:34:43 +00:00
|
|
|
namespace { // suppress no previous prototype warning
|
2012-06-06 12:09:01 +00:00
|
|
|
|
2012-03-19 14:42:13 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-21 17:57:55 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) {
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
// Ganesh offsets the texture unit indices
|
|
|
|
texture -= GR_GL_TEXTURE0;
|
|
|
|
GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits());
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
GrDebugGL::getInstance()->setCurTextureUnit(texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint shaderID) {
|
2012-03-26 17:58:35 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrProgramObj *program = GR_FIND(programID, GrProgramObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kProgram_ObjTypes);
|
2012-03-19 14:42:13 +00:00
|
|
|
GrAlwaysAssert(program);
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrShaderObj *shader = GR_FIND(shaderID,
|
|
|
|
GrShaderObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kShader_ObjTypes);
|
2012-03-19 14:42:13 +00:00
|
|
|
GrAlwaysAssert(shader);
|
|
|
|
|
|
|
|
program->AttachShader(shader);
|
|
|
|
}
|
|
|
|
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) {
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program,
|
|
|
|
GrGLuint index,
|
2012-07-13 17:45:17 +00:00
|
|
|
const char* name) {
|
|
|
|
}
|
2012-03-26 17:58:35 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint textureID) {
|
2012-03-26 17:58:35 +00:00
|
|
|
|
|
|
|
// we don't use cube maps
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(target == GR_GL_TEXTURE_2D);
|
2012-07-13 17:45:17 +00:00
|
|
|
// || target == GR_GL_TEXTURE_CUBE_MAP);
|
2012-03-26 17:58:35 +00:00
|
|
|
|
|
|
|
// a textureID of 0 is acceptable - it binds to the default texture target
|
2012-08-23 18:09:54 +00:00
|
|
|
GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kTexture_ObjTypes);
|
2012-03-26 17:58:35 +00:00
|
|
|
|
|
|
|
GrDebugGL::getInstance()->setTexture(texture);
|
|
|
|
}
|
|
|
|
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target,
|
|
|
|
GrGLsizeiptr size,
|
|
|
|
const GrGLvoid* data,
|
2012-06-26 20:19:41 +00:00
|
|
|
GrGLenum usage) {
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_ELEMENT_ARRAY_BUFFER == target);
|
2012-03-19 14:42:13 +00:00
|
|
|
GrAlwaysAssert(size >= 0);
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_STREAM_DRAW == usage ||
|
|
|
|
GR_GL_STATIC_DRAW == usage ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_DYNAMIC_DRAW == usage);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
GrBufferObj *buffer = NULL;
|
|
|
|
switch (target) {
|
|
|
|
case GR_GL_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getArrayBuffer();
|
|
|
|
break;
|
|
|
|
case GR_GL_ELEMENT_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrCrash("Unexpected target to glBufferData");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GrAlwaysAssert(buffer);
|
|
|
|
GrAlwaysAssert(buffer->getBound());
|
|
|
|
|
2012-03-21 17:57:55 +00:00
|
|
|
buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data));
|
2012-03-19 14:42:13 +00:00
|
|
|
buffer->setUsage(usage);
|
|
|
|
}
|
|
|
|
|
2012-07-13 17:45:17 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLint param) {
|
2012-04-12 19:53:31 +00:00
|
|
|
|
|
|
|
switch (pname) {
|
|
|
|
case GR_GL_UNPACK_ROW_LENGTH:
|
|
|
|
GrDebugGL::getInstance()->setUnPackRowLength(param);
|
|
|
|
break;
|
|
|
|
case GR_GL_PACK_ROW_LENGTH:
|
|
|
|
GrDebugGL::getInstance()->setPackRowLength(param);
|
|
|
|
break;
|
|
|
|
case GR_GL_UNPACK_ALIGNMENT:
|
|
|
|
break;
|
|
|
|
case GR_GL_PACK_ALIGNMENT:
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-07-13 17:45:17 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
|
|
|
|
GrGLint y,
|
|
|
|
GrGLsizei width,
|
|
|
|
GrGLsizei height,
|
|
|
|
GrGLenum format,
|
|
|
|
GrGLenum type,
|
2012-04-12 19:53:31 +00:00
|
|
|
GrGLvoid* pixels) {
|
|
|
|
|
|
|
|
GrGLint pixelsInRow = width;
|
|
|
|
if (0 < GrDebugGL::getInstance()->getPackRowLength()) {
|
|
|
|
pixelsInRow = GrDebugGL::getInstance()->getPackRowLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLint componentsPerPixel = 0;
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case GR_GL_RGBA:
|
|
|
|
// fallthrough
|
|
|
|
case GR_GL_BGRA:
|
|
|
|
componentsPerPixel = 4;
|
|
|
|
break;
|
|
|
|
case GR_GL_RGB:
|
|
|
|
componentsPerPixel = 3;
|
|
|
|
break;
|
2012-05-30 14:46:10 +00:00
|
|
|
case GR_GL_RED:
|
|
|
|
componentsPerPixel = 1;
|
|
|
|
break;
|
2012-04-12 19:53:31 +00:00
|
|
|
default:
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLint alignment = 4; // the pack alignment (one of 1, 2, 4 or 8)
|
|
|
|
// Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT
|
|
|
|
|
|
|
|
GrGLint componentSize = 0; // size (in bytes) of a single component
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case GR_GL_UNSIGNED_BYTE:
|
|
|
|
componentSize = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLint rowStride = 0; // number of components (not bytes) to skip
|
|
|
|
if (componentSize >= alignment) {
|
|
|
|
rowStride = componentsPerPixel * pixelsInRow;
|
|
|
|
} else {
|
2012-08-23 18:09:54 +00:00
|
|
|
float fTemp =
|
|
|
|
sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow /
|
2012-04-12 19:53:31 +00:00
|
|
|
static_cast<float>(alignment));
|
|
|
|
rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLchar *scanline = static_cast<GrGLchar *>(pixels);
|
|
|
|
for (int y = 0; y < height; ++y) {
|
|
|
|
memset(scanline, 0, componentsPerPixel * componentSize * width);
|
|
|
|
scanline += rowStride;
|
|
|
|
}
|
|
|
|
}
|
2012-03-21 17:57:55 +00:00
|
|
|
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) {
|
|
|
|
|
|
|
|
// A programID of 0 is legal
|
2012-08-23 18:09:54 +00:00
|
|
|
GrProgramObj *program = GR_FIND(programID,
|
|
|
|
GrProgramObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kProgram_ObjTypes);
|
|
|
|
|
|
|
|
GrDebugGL::getInstance()->useProgram(program);
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint frameBufferID) {
|
|
|
|
|
2013-04-11 23:25:36 +00:00
|
|
|
GrAlwaysAssert(GR_GL_FRAMEBUFFER == target ||
|
|
|
|
GR_GL_READ_FRAMEBUFFER == target ||
|
|
|
|
GR_GL_DRAW_FRAMEBUFFER);
|
2012-07-13 17:45:17 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
// a frameBufferID of 0 is acceptable - it binds to the default
|
2012-07-13 17:45:17 +00:00
|
|
|
// frame buffer
|
2012-08-23 18:09:54 +00:00
|
|
|
GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID,
|
|
|
|
GrFrameBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kFrameBuffer_ObjTypes);
|
|
|
|
|
|
|
|
GrDebugGL::getInstance()->setFrameBuffer(frameBuffer);
|
|
|
|
}
|
|
|
|
|
2013-03-01 15:36:02 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) {
|
2012-07-13 17:45:17 +00:00
|
|
|
|
|
|
|
GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
|
|
|
|
|
|
|
|
// a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
|
2012-08-23 18:09:54 +00:00
|
|
|
GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID,
|
|
|
|
GrRenderBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kRenderBuffer_ObjTypes);
|
|
|
|
|
|
|
|
GrDebugGL::getInstance()->setRenderBuffer(renderBuffer);
|
|
|
|
}
|
|
|
|
|
2013-03-01 15:36:02 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) {
|
2012-07-13 17:45:17 +00:00
|
|
|
|
|
|
|
// first potentially unbind the texture
|
|
|
|
// TODO: move this into GrDebugGL as unBindTexture?
|
2012-08-23 18:09:54 +00:00
|
|
|
for (unsigned int i = 0;
|
|
|
|
i < GrDebugGL::getInstance()->getMaxTextureUnits();
|
2012-07-13 17:45:17 +00:00
|
|
|
++i) {
|
|
|
|
GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i);
|
|
|
|
|
|
|
|
if (pTU->getTexture()) {
|
|
|
|
for (int j = 0; j < n; ++j) {
|
|
|
|
|
|
|
|
if (textures[j] == pTU->getTexture()->getID()) {
|
|
|
|
// this ID is the current texture - revert the binding to 0
|
|
|
|
pTU->setTexture(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: fuse the following block with DeleteRenderBuffers?
|
2012-08-23 18:09:54 +00:00
|
|
|
// Open GL will remove a deleted render buffer from the active
|
2012-07-13 17:45:17 +00:00
|
|
|
// frame buffer but not from any other frame buffer
|
|
|
|
if (GrDebugGL::getInstance()->getFrameBuffer()) {
|
|
|
|
|
|
|
|
GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer();
|
|
|
|
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
if (NULL != frameBuffer->getColor() &&
|
2012-07-13 17:45:17 +00:00
|
|
|
textures[i] == frameBuffer->getColor()->getID()) {
|
|
|
|
frameBuffer->setColor(NULL);
|
2012-08-23 18:09:54 +00:00
|
|
|
}
|
|
|
|
if (NULL != frameBuffer->getDepth() &&
|
2012-07-13 17:45:17 +00:00
|
|
|
textures[i] == frameBuffer->getDepth()->getID()) {
|
|
|
|
frameBuffer->setDepth(NULL);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
if (NULL != frameBuffer->getStencil() &&
|
2012-07-13 17:45:17 +00:00
|
|
|
textures[i] == frameBuffer->getStencil()->getID()) {
|
|
|
|
frameBuffer->setStencil(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then actually "delete" the buffers
|
|
|
|
for (int i = 0; i < n; ++i) {
|
2012-08-23 18:09:54 +00:00
|
|
|
GrTextureObj *buffer = GR_FIND(textures[i],
|
|
|
|
GrTextureObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kTexture_ObjTypes);
|
|
|
|
GrAlwaysAssert(buffer);
|
|
|
|
|
|
|
|
// OpenGL gives no guarantees if a texture is deleted while attached to
|
|
|
|
// something other than the currently bound frame buffer
|
|
|
|
GrAlwaysAssert(!buffer->getBound());
|
|
|
|
|
|
|
|
GrAlwaysAssert(!buffer->getDeleted());
|
|
|
|
buffer->deleteAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n,
|
2012-07-13 17:45:17 +00:00
|
|
|
const GrGLuint *frameBuffers) {
|
|
|
|
|
|
|
|
// first potentially unbind the buffers
|
|
|
|
if (GrDebugGL::getInstance()->getFrameBuffer()) {
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
if (frameBuffers[i] ==
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::getInstance()->getFrameBuffer()->getID()) {
|
|
|
|
// this ID is the current frame buffer - rebind to the default
|
|
|
|
GrDebugGL::getInstance()->setFrameBuffer(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then actually "delete" the buffers
|
|
|
|
for (int i = 0; i < n; ++i) {
|
2012-08-23 18:09:54 +00:00
|
|
|
GrFrameBufferObj *buffer = GR_FIND(frameBuffers[i],
|
|
|
|
GrFrameBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kFrameBuffer_ObjTypes);
|
|
|
|
GrAlwaysAssert(buffer);
|
|
|
|
|
|
|
|
GrAlwaysAssert(!buffer->getDeleted());
|
|
|
|
buffer->deleteAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteRenderbuffers(GrGLsizei n,
|
2012-07-13 17:45:17 +00:00
|
|
|
const GrGLuint *renderBuffers) {
|
|
|
|
|
|
|
|
// first potentially unbind the buffers
|
|
|
|
if (GrDebugGL::getInstance()->getRenderBuffer()) {
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
if (renderBuffers[i] ==
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::getInstance()->getRenderBuffer()->getID()) {
|
2012-08-23 18:09:54 +00:00
|
|
|
// this ID is the current render buffer - make no
|
2012-07-13 17:45:17 +00:00
|
|
|
// render buffer be bound
|
|
|
|
GrDebugGL::getInstance()->setRenderBuffer(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: fuse the following block with DeleteTextures?
|
2012-08-23 18:09:54 +00:00
|
|
|
// Open GL will remove a deleted render buffer from the active frame
|
2012-07-13 17:45:17 +00:00
|
|
|
// buffer but not from any other frame buffer
|
|
|
|
if (GrDebugGL::getInstance()->getFrameBuffer()) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrFrameBufferObj *frameBuffer =
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::getInstance()->getFrameBuffer();
|
|
|
|
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
if (NULL != frameBuffer->getColor() &&
|
2012-07-13 17:45:17 +00:00
|
|
|
renderBuffers[i] == frameBuffer->getColor()->getID()) {
|
|
|
|
frameBuffer->setColor(NULL);
|
2012-08-23 18:09:54 +00:00
|
|
|
}
|
|
|
|
if (NULL != frameBuffer->getDepth() &&
|
2012-07-13 17:45:17 +00:00
|
|
|
renderBuffers[i] == frameBuffer->getDepth()->getID()) {
|
|
|
|
frameBuffer->setDepth(NULL);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
if (NULL != frameBuffer->getStencil() &&
|
2012-07-13 17:45:17 +00:00
|
|
|
renderBuffers[i] == frameBuffer->getStencil()->getID()) {
|
|
|
|
frameBuffer->setStencil(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then actually "delete" the buffers
|
|
|
|
for (int i = 0; i < n; ++i) {
|
2012-08-23 18:09:54 +00:00
|
|
|
GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i],
|
|
|
|
GrRenderBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kRenderBuffer_ObjTypes);
|
|
|
|
GrAlwaysAssert(buffer);
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
// OpenGL gives no guarantees if a render buffer is deleted
|
|
|
|
// while attached to something other than the currently
|
2012-07-13 17:45:17 +00:00
|
|
|
// bound frame buffer
|
|
|
|
GrAlwaysAssert(!buffer->getColorBound());
|
|
|
|
GrAlwaysAssert(!buffer->getDepthBound());
|
2013-06-03 20:09:08 +00:00
|
|
|
// However, at GrContext destroy time we release all GrRsources and so stencil buffers
|
|
|
|
// may get deleted before FBOs that refer to them.
|
|
|
|
//GrAlwaysAssert(!buffer->getStencilBound());
|
2012-07-13 17:45:17 +00:00
|
|
|
|
|
|
|
GrAlwaysAssert(!buffer->getDeleted());
|
|
|
|
buffer->deleteAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferRenderbuffer(GrGLenum target,
|
|
|
|
GrGLenum attachment,
|
|
|
|
GrGLenum renderbuffertarget,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint renderBufferID) {
|
|
|
|
|
|
|
|
GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
|
|
|
|
GR_GL_DEPTH_ATTACHMENT == attachment ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_STENCIL_ATTACHMENT == attachment);
|
|
|
|
GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
|
|
|
|
|
|
|
|
GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
|
|
|
|
// A render buffer cannot be attached to the default framebuffer
|
|
|
|
GrAlwaysAssert(NULL != framebuffer);
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
// a renderBufferID of 0 is acceptable - it unbinds the current
|
2012-07-13 17:45:17 +00:00
|
|
|
// render buffer
|
2012-08-23 18:09:54 +00:00
|
|
|
GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID,
|
|
|
|
GrRenderBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kRenderBuffer_ObjTypes);
|
|
|
|
|
|
|
|
switch (attachment) {
|
|
|
|
case GR_GL_COLOR_ATTACHMENT0:
|
|
|
|
framebuffer->setColor(renderbuffer);
|
|
|
|
break;
|
|
|
|
case GR_GL_DEPTH_ATTACHMENT:
|
|
|
|
framebuffer->setDepth(renderbuffer);
|
|
|
|
break;
|
|
|
|
case GR_GL_STENCIL_ATTACHMENT:
|
|
|
|
framebuffer->setStencil(renderbuffer);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferTexture2D(GrGLenum target,
|
|
|
|
GrGLenum attachment,
|
|
|
|
GrGLenum textarget,
|
|
|
|
GrGLuint textureID,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLint level) {
|
|
|
|
|
|
|
|
GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
|
|
|
|
GR_GL_DEPTH_ATTACHMENT == attachment ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_STENCIL_ATTACHMENT == attachment);
|
|
|
|
GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
|
|
|
|
|
|
|
|
GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
|
|
|
|
// A texture cannot be attached to the default framebuffer
|
|
|
|
GrAlwaysAssert(NULL != framebuffer);
|
|
|
|
|
|
|
|
// A textureID of 0 is allowed - it unbinds the currently bound texture
|
2012-08-23 18:09:54 +00:00
|
|
|
GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kTexture_ObjTypes);
|
|
|
|
if (texture) {
|
2012-08-23 18:09:54 +00:00
|
|
|
// The texture shouldn't be bound to a texture unit - this
|
2012-07-13 17:45:17 +00:00
|
|
|
// could lead to a feedback loop
|
|
|
|
GrAlwaysAssert(!texture->getBound());
|
|
|
|
}
|
|
|
|
|
|
|
|
GrAlwaysAssert(0 == level);
|
|
|
|
|
|
|
|
switch (attachment) {
|
|
|
|
case GR_GL_COLOR_ATTACHMENT0:
|
|
|
|
framebuffer->setColor(texture);
|
|
|
|
break;
|
|
|
|
case GR_GL_DEPTH_ATTACHMENT:
|
|
|
|
framebuffer->setDepth(texture);
|
|
|
|
break;
|
|
|
|
case GR_GL_STENCIL_ATTACHMENT:
|
|
|
|
framebuffer->setStencil(texture);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-03-19 14:42:13 +00:00
|
|
|
GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateProgram() {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrProgramObj *program = GR_CREATE(GrProgramObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kProgram_ObjTypes);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
return program->getID();
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateShader(GrGLenum type) {
|
2012-08-23 18:09:54 +00:00
|
|
|
|
|
|
|
GrAlwaysAssert(GR_GL_VERTEX_SHADER == type ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_FRAGMENT_SHADER == type);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
GrShaderObj *shader = GR_CREATE(GrShaderObj, GrDebugGL::kShader_ObjTypes);
|
|
|
|
shader->setType(type);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
return shader->getID();
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteProgram(GrGLuint programID) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrProgramObj *program = GR_FIND(programID,
|
|
|
|
GrProgramObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kProgram_ObjTypes);
|
2012-03-19 14:42:13 +00:00
|
|
|
GrAlwaysAssert(program);
|
|
|
|
|
|
|
|
if (program->getRefCount()) {
|
|
|
|
// someone is still using this program so we can't delete it here
|
|
|
|
program->setMarkedForDeletion();
|
|
|
|
} else {
|
|
|
|
program->deleteAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteShader(GrGLuint shaderID) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrShaderObj *shader = GR_FIND(shaderID,
|
|
|
|
GrShaderObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kShader_ObjTypes);
|
2012-03-19 14:42:13 +00:00
|
|
|
GrAlwaysAssert(shader);
|
|
|
|
|
|
|
|
if (shader->getRefCount()) {
|
|
|
|
// someone is still using this shader so we can't delete it here
|
|
|
|
shader->setMarkedForDeletion();
|
|
|
|
} else {
|
|
|
|
shader->deleteAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type,
|
|
|
|
GrGLsizei n,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint* ids) {
|
2012-03-19 14:42:13 +00:00
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type);
|
|
|
|
GrAlwaysAssert(obj);
|
|
|
|
ids[i] = obj->getID();
|
2012-03-19 14:42:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
|
|
|
|
debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids);
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint* ids) {
|
2012-03-26 17:58:35 +00:00
|
|
|
debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids);
|
2012-03-21 17:57:55 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLuint* ids) {
|
2012-03-26 17:58:35 +00:00
|
|
|
debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) {
|
2013-03-01 15:32:49 +00:00
|
|
|
debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids);
|
2013-03-01 14:37:18 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 15:36:02 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) {
|
|
|
|
debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids);
|
|
|
|
}
|
2013-03-01 14:37:18 +00:00
|
|
|
|
2013-03-01 15:36:02 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) {
|
|
|
|
for (GrGLsizei i = 0; i < n; ++i) {
|
|
|
|
GrVertexArrayObj* array =
|
|
|
|
GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
|
|
|
|
GrAlwaysAssert(array);
|
|
|
|
|
|
|
|
// Deleting the current vertex array binds object 0
|
|
|
|
if (GrDebugGL::getInstance()->getVertexArray() == array) {
|
|
|
|
GrDebugGL::getInstance()->setVertexArray(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array->getRefCount()) {
|
|
|
|
// someone is still using this vertex array so we can't delete it here
|
|
|
|
array->setMarkedForDeletion();
|
|
|
|
} else {
|
|
|
|
array->deleteAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) {
|
|
|
|
GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
|
2013-03-07 19:09:11 +00:00
|
|
|
GrAlwaysAssert((0 == id) || NULL != array);
|
2013-03-01 15:36:02 +00:00
|
|
|
GrDebugGL::getInstance()->setVertexArray(array);
|
|
|
|
}
|
|
|
|
|
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) {
|
|
|
|
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrBufferObj *buffer = GR_FIND(bufferID,
|
|
|
|
GrBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kBuffer_ObjTypes);
|
2013-02-26 14:34:43 +00:00
|
|
|
// 0 is a permissible bufferID - it unbinds the current buffer
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
switch (target) {
|
|
|
|
case GR_GL_ARRAY_BUFFER:
|
|
|
|
GrDebugGL::getInstance()->setArrayBuffer(buffer);
|
|
|
|
break;
|
|
|
|
case GR_GL_ELEMENT_ARRAY_BUFFER:
|
|
|
|
GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrCrash("Unexpected target to glBindBuffer");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// deleting a bound buffer has the side effect of binding 0
|
2013-03-01 15:36:02 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) {
|
2012-03-19 14:42:13 +00:00
|
|
|
// first potentially unbind the buffers
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
if (GrDebugGL::getInstance()->getArrayBuffer() &&
|
2012-03-19 14:42:13 +00:00
|
|
|
ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) {
|
|
|
|
// this ID is the current array buffer
|
|
|
|
GrDebugGL::getInstance()->setArrayBuffer(NULL);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
if (GrDebugGL::getInstance()->getElementArrayBuffer() &&
|
|
|
|
ids[i] ==
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) {
|
2012-03-19 14:42:13 +00:00
|
|
|
// this ID is the current element array buffer
|
|
|
|
GrDebugGL::getInstance()->setElementArrayBuffer(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then actually "delete" the buffers
|
|
|
|
for (int i = 0; i < n; ++i) {
|
2012-08-23 18:09:54 +00:00
|
|
|
GrBufferObj *buffer = GR_FIND(ids[i],
|
|
|
|
GrBufferObj,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrDebugGL::kBuffer_ObjTypes);
|
2012-03-19 14:42:13 +00:00
|
|
|
GrAlwaysAssert(buffer);
|
|
|
|
|
|
|
|
GrAlwaysAssert(!buffer->getDeleted());
|
|
|
|
buffer->deleteAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// map a buffer to the caller's address space
|
2013-03-01 15:36:02 +00:00
|
|
|
GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
|
2012-03-19 14:42:13 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_ELEMENT_ARRAY_BUFFER == target);
|
|
|
|
// GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access);
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
GrBufferObj *buffer = NULL;
|
|
|
|
switch (target) {
|
|
|
|
case GR_GL_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getArrayBuffer();
|
|
|
|
break;
|
|
|
|
case GR_GL_ELEMENT_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrCrash("Unexpected target to glMapBuffer");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer) {
|
|
|
|
GrAlwaysAssert(!buffer->getMapped());
|
|
|
|
buffer->setMapped();
|
|
|
|
return buffer->getDataPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
return NULL; // no buffer bound to the target
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove a buffer from the caller's address space
|
2012-08-23 18:09:54 +00:00
|
|
|
// TODO: check if the "access" method from "glMapBuffer" was honored
|
2012-03-19 14:42:13 +00:00
|
|
|
GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_ELEMENT_ARRAY_BUFFER == target);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
GrBufferObj *buffer = NULL;
|
|
|
|
switch (target) {
|
|
|
|
case GR_GL_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getArrayBuffer();
|
|
|
|
break;
|
|
|
|
case GR_GL_ELEMENT_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrCrash("Unexpected target to glUnmapBuffer");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer) {
|
|
|
|
GrAlwaysAssert(buffer->getMapped());
|
|
|
|
buffer->resetMapped();
|
|
|
|
return GR_GL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GrAlwaysAssert(false);
|
|
|
|
return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
|
|
|
|
GrGLenum value,
|
2012-07-13 17:45:17 +00:00
|
|
|
GrGLint* params) {
|
2012-03-19 14:42:13 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_ELEMENT_ARRAY_BUFFER == target);
|
2012-08-23 18:09:54 +00:00
|
|
|
GrAlwaysAssert(GR_GL_BUFFER_SIZE == value ||
|
2012-07-13 17:45:17 +00:00
|
|
|
GR_GL_BUFFER_USAGE == value);
|
2012-03-19 14:42:13 +00:00
|
|
|
|
|
|
|
GrBufferObj *buffer = NULL;
|
|
|
|
switch (target) {
|
|
|
|
case GR_GL_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getArrayBuffer();
|
|
|
|
break;
|
|
|
|
case GR_GL_ELEMENT_ARRAY_BUFFER:
|
|
|
|
buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
|
2012-08-23 18:09:54 +00:00
|
|
|
break;
|
2012-03-19 14:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GrAlwaysAssert(buffer);
|
|
|
|
|
|
|
|
switch (value) {
|
|
|
|
case GR_GL_BUFFER_MAPPED:
|
|
|
|
*params = GR_GL_FALSE;
|
|
|
|
if (buffer)
|
|
|
|
*params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
|
|
|
|
break;
|
|
|
|
case GR_GL_BUFFER_SIZE:
|
|
|
|
*params = 0;
|
|
|
|
if (buffer)
|
|
|
|
*params = buffer->getSize();
|
|
|
|
break;
|
|
|
|
case GR_GL_BUFFER_USAGE:
|
|
|
|
*params = GR_GL_STATIC_DRAW;
|
|
|
|
if (buffer)
|
|
|
|
*params = buffer->getUsage();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GrCrash("Unexpected value to glGetBufferParamateriv");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2012-06-06 12:09:01 +00:00
|
|
|
} // end of namespace
|
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
struct GrDebugGLInterface : public GrGLInterface {
|
|
|
|
|
|
|
|
public:
|
2012-06-26 20:19:41 +00:00
|
|
|
SK_DECLARE_INST_COUNT(GrDebugGLInterface)
|
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
GrDebugGLInterface()
|
|
|
|
: fWrapped(NULL) {
|
2012-07-31 19:23:02 +00:00
|
|
|
GrDebugGL::staticRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~GrDebugGLInterface() {
|
|
|
|
GrDebugGL::staticUnRef();
|
2012-03-26 17:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setWrapped(GrGLInterface *interface) {
|
|
|
|
fWrapped.reset(interface);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: there are some issues w/ wrapping another GL interface inside the
|
|
|
|
// debug interface:
|
|
|
|
// Since none of the "gl" methods are member functions they don't get
|
|
|
|
// a "this" pointer through which to access "fWrapped"
|
2012-08-23 18:09:54 +00:00
|
|
|
// This could be worked around by having all of them access the
|
|
|
|
// "glInterface" pointer - i.e., treating the debug interface as a
|
2012-03-26 17:58:35 +00:00
|
|
|
// true singleton
|
|
|
|
//
|
2012-08-23 18:09:54 +00:00
|
|
|
// The problem with this is that we also want to handle OpenGL
|
|
|
|
// contexts. The natural way to do this is to have multiple debug
|
|
|
|
// interfaces. Each of which represents a separate context. The
|
|
|
|
// static ID count would still uniquify IDs across all of them.
|
|
|
|
// The problem then is that we couldn't treat the debug GL
|
|
|
|
// interface as a singleton (since there would be one for each
|
2012-03-26 17:58:35 +00:00
|
|
|
// context).
|
|
|
|
//
|
2012-08-23 18:09:54 +00:00
|
|
|
// The solution to this is probably to alter SkDebugGlContext's
|
|
|
|
// "makeCurrent" method to make a call like "makeCurrent(this)" to
|
|
|
|
// the debug GL interface (assuming that the application will create
|
2013-02-28 20:16:25 +00:00
|
|
|
// multiple SkGLContextHelper's) to let it switch between the active
|
2012-08-23 18:09:54 +00:00
|
|
|
// context. Everything in the GrDebugGL object would then need to be
|
|
|
|
// moved to a GrContextObj and the GrDebugGL object would just switch
|
|
|
|
// between them. Note that this approach would also require that
|
2012-03-26 17:58:35 +00:00
|
|
|
// SkDebugGLContext wrap an arbitrary other context
|
|
|
|
// and then pass the wrapped interface to the debug GL interface.
|
|
|
|
|
|
|
|
protected:
|
|
|
|
private:
|
|
|
|
|
|
|
|
SkAutoTUnref<GrGLInterface> fWrapped;
|
|
|
|
|
|
|
|
typedef GrGLInterface INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-06-26 20:19:41 +00:00
|
|
|
SK_DEFINE_INST_COUNT(GrDebugGLInterface)
|
|
|
|
|
2012-03-26 17:58:35 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-19 14:42:13 +00:00
|
|
|
const GrGLInterface* GrGLCreateDebugInterface() {
|
2012-06-26 20:19:41 +00:00
|
|
|
GrGLInterface* interface = SkNEW(GrDebugGLInterface);
|
|
|
|
|
|
|
|
interface->fBindingsExported = kDesktop_GrGLBinding;
|
|
|
|
interface->fActiveTexture = debugGLActiveTexture;
|
|
|
|
interface->fAttachShader = debugGLAttachShader;
|
|
|
|
interface->fBeginQuery = debugGLBeginQuery;
|
|
|
|
interface->fBindAttribLocation = debugGLBindAttribLocation;
|
|
|
|
interface->fBindBuffer = debugGLBindBuffer;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fBindFragDataLocation = noOpGLBindFragDataLocation;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fBindTexture = debugGLBindTexture;
|
2013-03-01 15:36:02 +00:00
|
|
|
interface->fBindVertexArray = debugGLBindVertexArray;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fBlendColor = noOpGLBlendColor;
|
|
|
|
interface->fBlendFunc = noOpGLBlendFunc;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fBufferData = debugGLBufferData;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fBufferSubData = noOpGLBufferSubData;
|
|
|
|
interface->fClear = noOpGLClear;
|
|
|
|
interface->fClearColor = noOpGLClearColor;
|
|
|
|
interface->fClearStencil = noOpGLClearStencil;
|
|
|
|
interface->fColorMask = noOpGLColorMask;
|
|
|
|
interface->fCompileShader = noOpGLCompileShader;
|
|
|
|
interface->fCompressedTexImage2D = noOpGLCompressedTexImage2D;
|
2013-04-11 22:00:34 +00:00
|
|
|
interface->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fCreateProgram = debugGLCreateProgram;
|
|
|
|
interface->fCreateShader = debugGLCreateShader;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fCullFace = noOpGLCullFace;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fDeleteBuffers = debugGLDeleteBuffers;
|
|
|
|
interface->fDeleteProgram = debugGLDeleteProgram;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fDeleteQueries = noOpGLDeleteIds;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fDeleteShader = debugGLDeleteShader;
|
|
|
|
interface->fDeleteTextures = debugGLDeleteTextures;
|
2013-03-01 15:36:02 +00:00
|
|
|
interface->fDeleteVertexArrays = debugGLDeleteVertexArrays;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fDepthMask = noOpGLDepthMask;
|
|
|
|
interface->fDisable = noOpGLDisable;
|
|
|
|
interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
|
|
|
|
interface->fDrawArrays = noOpGLDrawArrays;
|
|
|
|
interface->fDrawBuffer = noOpGLDrawBuffer;
|
|
|
|
interface->fDrawBuffers = noOpGLDrawBuffers;
|
|
|
|
interface->fDrawElements = noOpGLDrawElements;
|
|
|
|
interface->fEnable = noOpGLEnable;
|
|
|
|
interface->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
|
|
|
|
interface->fEndQuery = noOpGLEndQuery;
|
|
|
|
interface->fFinish = noOpGLFinish;
|
|
|
|
interface->fFlush = noOpGLFlush;
|
|
|
|
interface->fFrontFace = noOpGLFrontFace;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fGenBuffers = debugGLGenBuffers;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fGenQueries = noOpGLGenIds;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fGenTextures = debugGLGenTextures;
|
|
|
|
interface->fGetBufferParameteriv = debugGLGetBufferParameteriv;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fGetError = noOpGLGetError;
|
|
|
|
interface->fGetIntegerv = noOpGLGetIntegerv;
|
|
|
|
interface->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
|
|
|
|
interface->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
|
|
|
|
interface->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
|
|
|
|
interface->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
|
|
|
|
interface->fGetQueryiv = noOpGLGetQueryiv;
|
|
|
|
interface->fGetProgramInfoLog = noOpGLGetInfoLog;
|
|
|
|
interface->fGetProgramiv = noOpGLGetShaderOrProgramiv;
|
|
|
|
interface->fGetShaderInfoLog = noOpGLGetInfoLog;
|
|
|
|
interface->fGetShaderiv = noOpGLGetShaderOrProgramiv;
|
|
|
|
interface->fGetString = noOpGLGetString;
|
2013-02-26 21:46:32 +00:00
|
|
|
interface->fGetStringi = noOpGLGetStringi;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
|
|
|
|
interface->fGetUniformLocation = noOpGLGetUniformLocation;
|
2013-03-01 15:36:02 +00:00
|
|
|
interface->fGenVertexArrays = debugGLGenVertexArrays;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fLineWidth = noOpGLLineWidth;
|
|
|
|
interface->fLinkProgram = noOpGLLinkProgram;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fPixelStorei = debugGLPixelStorei;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fQueryCounter = noOpGLQueryCounter;
|
|
|
|
interface->fReadBuffer = noOpGLReadBuffer;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fReadPixels = debugGLReadPixels;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fScissor = noOpGLScissor;
|
|
|
|
interface->fShaderSource = noOpGLShaderSource;
|
|
|
|
interface->fStencilFunc = noOpGLStencilFunc;
|
|
|
|
interface->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
|
|
|
|
interface->fStencilMask = noOpGLStencilMask;
|
|
|
|
interface->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
|
|
|
|
interface->fStencilOp = noOpGLStencilOp;
|
|
|
|
interface->fStencilOpSeparate = noOpGLStencilOpSeparate;
|
|
|
|
interface->fTexImage2D = noOpGLTexImage2D;
|
|
|
|
interface->fTexParameteri = noOpGLTexParameteri;
|
|
|
|
interface->fTexParameteriv = noOpGLTexParameteriv;
|
|
|
|
interface->fTexSubImage2D = noOpGLTexSubImage2D;
|
|
|
|
interface->fTexStorage2D = noOpGLTexStorage2D;
|
2013-04-29 16:50:17 +00:00
|
|
|
interface->fDiscardFramebuffer = noOpGLDiscardFramebuffer;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fUniform1f = noOpGLUniform1f;
|
|
|
|
interface->fUniform1i = noOpGLUniform1i;
|
|
|
|
interface->fUniform1fv = noOpGLUniform1fv;
|
|
|
|
interface->fUniform1iv = noOpGLUniform1iv;
|
|
|
|
interface->fUniform2f = noOpGLUniform2f;
|
|
|
|
interface->fUniform2i = noOpGLUniform2i;
|
|
|
|
interface->fUniform2fv = noOpGLUniform2fv;
|
|
|
|
interface->fUniform2iv = noOpGLUniform2iv;
|
|
|
|
interface->fUniform3f = noOpGLUniform3f;
|
|
|
|
interface->fUniform3i = noOpGLUniform3i;
|
|
|
|
interface->fUniform3fv = noOpGLUniform3fv;
|
|
|
|
interface->fUniform3iv = noOpGLUniform3iv;
|
|
|
|
interface->fUniform4f = noOpGLUniform4f;
|
|
|
|
interface->fUniform4i = noOpGLUniform4i;
|
|
|
|
interface->fUniform4fv = noOpGLUniform4fv;
|
|
|
|
interface->fUniform4iv = noOpGLUniform4iv;
|
|
|
|
interface->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
|
|
|
|
interface->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
|
|
|
|
interface->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fUseProgram = debugGLUseProgram;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
|
|
|
|
interface->fVertexAttribPointer = noOpGLVertexAttribPointer;
|
|
|
|
interface->fViewport = noOpGLViewport;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fBindFramebuffer = debugGLBindFramebuffer;
|
|
|
|
interface->fBindRenderbuffer = debugGLBindRenderbuffer;
|
2013-02-26 14:34:43 +00:00
|
|
|
interface->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fDeleteFramebuffers = debugGLDeleteFramebuffers;
|
|
|
|
interface->fDeleteRenderbuffers = debugGLDeleteRenderbuffers;
|
|
|
|
interface->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer;
|
|
|
|
interface->fFramebufferTexture2D = debugGLFramebufferTexture2D;
|
|
|
|
interface->fGenFramebuffers = debugGLGenFramebuffers;
|
|
|
|
interface->fGenRenderbuffers = debugGLGenRenderbuffers;
|
2012-08-23 18:09:54 +00:00
|
|
|
interface->fGetFramebufferAttachmentParameteriv =
|
2013-02-26 14:34:43 +00:00
|
|
|
noOpGLGetFramebufferAttachmentParameteriv;
|
|
|
|
interface->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
|
|
|
|
interface->fRenderbufferStorage = noOpGLRenderbufferStorage;
|
2012-08-23 18:09:54 +00:00
|
|
|
interface->fRenderbufferStorageMultisample =
|
2013-02-26 14:34:43 +00:00
|
|
|
noOpGLRenderbufferStorageMultisample;
|
|
|
|
interface->fBlitFramebuffer = noOpGLBlitFramebuffer;
|
2012-08-23 18:09:54 +00:00
|
|
|
interface->fResolveMultisampleFramebuffer =
|
2013-02-26 14:34:43 +00:00
|
|
|
noOpGLResolveMultisampleFramebuffer;
|
2012-06-26 20:19:41 +00:00
|
|
|
interface->fMapBuffer = debugGLMapBuffer;
|
|
|
|
interface->fUnmapBuffer = debugGLUnmapBuffer;
|
2012-08-23 18:09:54 +00:00
|
|
|
interface->fBindFragDataLocationIndexed =
|
2013-02-26 14:34:43 +00:00
|
|
|
noOpGLBindFragDataLocationIndexed;
|
2012-06-26 20:19:41 +00:00
|
|
|
|
|
|
|
return interface;
|
2012-03-19 14:42:13 +00:00
|
|
|
}
|