[core] remove unused GL_TRACK functions
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
//#define GL_TRACK
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#ifdef GL_TRACK
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#if __APPLE__
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -38,28 +32,6 @@
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
|
||||
#ifdef GL_TRACK
|
||||
typedef void (*GLDEBUGPROC)(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar *message,
|
||||
const void *userParam);
|
||||
|
||||
template <class... Args> void mbx_trapExtension(const char *name, Args... args);
|
||||
|
||||
void mbx_trapExtension(const char *);
|
||||
void mbx_trapExtension(const char *, GLint, const char *);
|
||||
void mbx_trapExtension(const char *, GLsizei, GLuint *);
|
||||
void mbx_trapExtension(const char *, GLsizei, const GLuint *);
|
||||
void mbx_trapExtension(const char *, GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean);
|
||||
void mbx_trapExtension(const char *, GLenum, GLuint, GLsizei, const GLchar *);
|
||||
void mbx_trapExtension(const char *, GLDEBUGPROC, const void *);
|
||||
void mbx_trapExtension(const char *, GLuint, GLuint, GLuint, GLuint, GLint, const char *, const void*);
|
||||
void mbx_trapExtension(const char *name, GLuint array);
|
||||
#endif
|
||||
|
||||
struct Error : std::runtime_error {
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
@@ -78,9 +50,6 @@ public:
|
||||
typedef std::pair<const char *, const char *> Probe;
|
||||
std::vector<Probe> probes;
|
||||
void (*ptr)();
|
||||
#ifdef GL_TRACK
|
||||
const char *foundName;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class>
|
||||
@@ -99,9 +68,6 @@ public:
|
||||
}
|
||||
|
||||
R operator()(Args... args) const {
|
||||
#ifdef GL_TRACK
|
||||
mbx_trapExtension(foundName, args...);
|
||||
#endif
|
||||
return (*reinterpret_cast<R (*)(Args...)>(ptr))(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
@@ -125,41 +91,3 @@ extern ExtensionFunction<void (GLsizei n, GLuint* arrays)>
|
||||
#define glClearDepth glClearDepthf
|
||||
#define glDepthRange glDepthRangef
|
||||
#endif
|
||||
|
||||
#ifdef GL_TRACK
|
||||
#define glBindTexture mbx_glBindTexture
|
||||
#define glDeleteTexture mbx_glDeleteTexture
|
||||
#define glTexImage2D mbx_glTexImage2D
|
||||
#define glClear mbx_glClear
|
||||
#define glShaderSource mbx_glShaderSource
|
||||
#define glBufferData mbx_glBufferData
|
||||
#define glBindBuffer mbx_glBindBuffer
|
||||
#define glDeleteBuffers mbx_glDeleteBuffers
|
||||
|
||||
void mbx_glDeleteBuffers(GLsizei n,
|
||||
const GLuint * buffers);
|
||||
void mbx_glBindBuffer(GLenum target,
|
||||
GLuint buffer);
|
||||
void mbx_glBufferData(GLenum target,
|
||||
GLsizeiptr size,
|
||||
const GLvoid * data,
|
||||
GLenum usage);
|
||||
void mbx_glShaderSource(GLuint shader,
|
||||
GLsizei count,
|
||||
const GLchar * const *string,
|
||||
const GLint *length);
|
||||
void mbx_glClear(GLbitfield mask);
|
||||
void mbx_glBindTexture( GLenum target,
|
||||
GLuint texture);
|
||||
void mbx_glDeleteTextures(GLsizei n,
|
||||
const GLuint * textures);
|
||||
void mbx_glTexImage2D(GLenum target,
|
||||
GLint level,
|
||||
GLint internalformat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLint border,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const GLvoid * data);
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,6 @@ void InitializeExtensions(glProc (*getProcAddress)(const char *)) {
|
||||
for (auto fn : ExtensionFunctionBase::functions()) {
|
||||
for (auto probe : fn->probes) {
|
||||
if (extensions.find(probe.first) != std::string::npos) {
|
||||
#ifdef GL_TRACK
|
||||
fn->foundName = probe.second;
|
||||
#endif
|
||||
fn->ptr = getProcAddress(probe.second);
|
||||
break;
|
||||
}
|
||||
@@ -124,173 +121,3 @@ void checkError(const char* cmd, const char* file, int line) {
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mbgl
|
||||
|
||||
#ifdef GL_TRACK
|
||||
#undef glBindTexture
|
||||
#undef glDeleteTextures
|
||||
#undef glTexImage2D
|
||||
#undef glClear
|
||||
#undef glShaderSource
|
||||
#undef glBufferData
|
||||
#undef glBindBuffer
|
||||
#undef glDeleteBuffers
|
||||
#undef glBufferData
|
||||
static unsigned int currentUsedBytes = 0;
|
||||
static GLint currentBoundTexture = 0;
|
||||
static std::unordered_map<GLint, unsigned int> bindingToSizeMap;
|
||||
|
||||
static GLuint currentArrayBuffer = 0;
|
||||
static GLuint currentElementArrayBuffer = 0;
|
||||
static std::unordered_map<GLint, GLsizeiptr> bufferBindingToSizeMap;
|
||||
static unsigned int currentUsedBufferBytes = 0;
|
||||
static unsigned int largestAmountUsedSoFar = 0;
|
||||
|
||||
static std::unordered_map<GLuint, GLuint> vertexArrayToArrayBufferMap;
|
||||
static GLuint currentVertexArray = 0;
|
||||
|
||||
static std::mutex gDebugMutex;
|
||||
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
void mbx_trapExtension(const char *) { }
|
||||
void mbx_trapExtension(const char *, GLint, const char *) { }
|
||||
void mbx_trapExtension(const char *, GLsizei, GLuint *) { }
|
||||
void mbx_trapExtension(const char *, GLsizei, const GLuint *) { }
|
||||
void mbx_trapExtension(const char *, GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean) { }
|
||||
void mbx_trapExtension(const char *, GLenum, GLuint, GLsizei, const GLchar *) { }
|
||||
void mbx_trapExtension(const char *, GLDEBUGPROC, const void *) { }
|
||||
void mbx_trapExtension(const char *, GLuint, GLuint, GLuint, GLuint, GLint, const char *, const void*) { }
|
||||
|
||||
void mbx_trapExtension(const char *name, GLuint array) {
|
||||
if(strncasecmp(name, "glBindVertexArray", 17) == 0) {
|
||||
currentVertexArray = array;
|
||||
std::cout << name << ": " << array << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mbx_glBindBuffer(GLenum target,
|
||||
GLuint buffer) {
|
||||
std::unique_lock<std::mutex> lock(gDebugMutex);
|
||||
if (target == GL_ARRAY_BUFFER) {
|
||||
currentArrayBuffer = buffer;
|
||||
if (currentVertexArray != 0) {
|
||||
if (vertexArrayToArrayBufferMap.find(currentVertexArray) != vertexArrayToArrayBufferMap.end()) {
|
||||
if (vertexArrayToArrayBufferMap[currentVertexArray] != currentArrayBuffer) {
|
||||
std::cout << "glBindBuffer: ERROR: You are re-binding a VAO to point to a new array buffer. This is almost certainly unintended." << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "glBindBuffer: binding VAO " << currentVertexArray << " to array buffer " << currentArrayBuffer << std::endl;
|
||||
vertexArrayToArrayBufferMap[currentVertexArray] = currentArrayBuffer;
|
||||
}
|
||||
} else if (target == GL_ELEMENT_ARRAY_BUFFER) {
|
||||
currentElementArrayBuffer = buffer;
|
||||
}
|
||||
lock.unlock();
|
||||
glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
void mbx_glDeleteBuffers(GLsizei n,
|
||||
const GLuint * buffers) {
|
||||
std::unique_lock<std::mutex> lock(gDebugMutex);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (bufferBindingToSizeMap.find(buffers[i]) != bufferBindingToSizeMap.end()) {
|
||||
currentUsedBufferBytes -= bufferBindingToSizeMap[buffers[i]];
|
||||
std::cout << "GL glDeleteBuffers: " << buffers[i] << " freeing " << bufferBindingToSizeMap[buffers[i]] << " bytes current total " << currentUsedBufferBytes << "\n";
|
||||
bufferBindingToSizeMap.erase(buffers[i]);
|
||||
}
|
||||
}
|
||||
lock.unlock();
|
||||
glDeleteBuffers(n, buffers);
|
||||
}
|
||||
|
||||
void mbx_glBufferData(GLenum target,
|
||||
GLsizeiptr size,
|
||||
const GLvoid * data,
|
||||
GLenum usage) {
|
||||
std::unique_lock<std::mutex> lock(gDebugMutex);
|
||||
GLuint currentBinding = 0;
|
||||
if (target == GL_ARRAY_BUFFER) {
|
||||
currentBinding = currentArrayBuffer;
|
||||
} else if (target == GL_ELEMENT_ARRAY_BUFFER) {
|
||||
currentBinding = currentElementArrayBuffer;
|
||||
}
|
||||
if (bufferBindingToSizeMap.find(currentBinding) != bufferBindingToSizeMap.end()) {
|
||||
currentUsedBufferBytes -= bufferBindingToSizeMap[currentBinding];
|
||||
std::cout << "GL glBufferData: " << currentBinding << " freeing " << bufferBindingToSizeMap[currentBinding] << " bytes current total " << currentUsedBufferBytes << "\n";
|
||||
}
|
||||
bufferBindingToSizeMap[currentBinding] = size;
|
||||
currentUsedBufferBytes += size;
|
||||
if (currentUsedBufferBytes > largestAmountUsedSoFar) {
|
||||
largestAmountUsedSoFar = currentUsedBufferBytes;
|
||||
}
|
||||
std::cout << "GL glBufferData: " << currentBinding << " using " << bufferBindingToSizeMap[currentBinding] << " bytes current total " << currentUsedBufferBytes << " high water mark " << largestAmountUsedSoFar << "\n";
|
||||
lock.unlock();
|
||||
|
||||
glBufferData(target, size, data, usage);
|
||||
}
|
||||
|
||||
|
||||
void mbx_glShaderSource(GLuint shader,
|
||||
GLsizei count,
|
||||
const GLchar * const *string,
|
||||
const GLint *length) {
|
||||
//std::cout << "Calling glShaderSource: " << *string << std::endl;
|
||||
glShaderSource(shader, count, const_cast<const GLchar **>(string), length);
|
||||
}
|
||||
|
||||
void mbx_glClear(GLbitfield mask) {
|
||||
//std::cout << "Calling glClear" << std::endl;
|
||||
glClear(mask);
|
||||
}
|
||||
|
||||
void mbx_glBindTexture( GLenum target,
|
||||
GLuint texture) {
|
||||
std::unique_lock<std::mutex> lock(gDebugMutex);
|
||||
if (target == GL_TEXTURE_2D) {
|
||||
currentBoundTexture = texture;
|
||||
}
|
||||
lock.unlock();
|
||||
glBindTexture(target, texture);
|
||||
}
|
||||
|
||||
void mbx_glDeleteTextures(GLsizei n,
|
||||
const GLuint * textures) {
|
||||
std::unique_lock<std::mutex> lock(gDebugMutex);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (bindingToSizeMap.find(textures[i]) != bindingToSizeMap.end()) {
|
||||
std::cout << "GL deleteTexture:" << textures[i] << "freeing " << bindingToSizeMap[textures[i]] << " bytes current total " << currentUsedBytes << "\n";
|
||||
currentUsedBytes -= bindingToSizeMap[textures[i]];
|
||||
bindingToSizeMap.erase(textures[i]);
|
||||
}
|
||||
}
|
||||
lock.unlock();
|
||||
glDeleteTextures(n, textures);
|
||||
}
|
||||
|
||||
void mbx_glTexImage2D(GLenum target,
|
||||
GLint level,
|
||||
GLint internalformat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLint border,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const GLvoid * data) {
|
||||
std::unique_lock<std::mutex> lock(gDebugMutex);
|
||||
if (internalformat == GL_RGBA &&
|
||||
type == GL_UNSIGNED_BYTE) {
|
||||
if (bindingToSizeMap.find(currentBoundTexture) != bindingToSizeMap.end()) {
|
||||
currentUsedBytes -= bindingToSizeMap[currentBoundTexture];
|
||||
std::cout << "GL glTexImage2D: " << currentBoundTexture << " freeing " << bindingToSizeMap[currentBoundTexture] << " bytes current total " << currentUsedBytes << "\n";
|
||||
}
|
||||
bindingToSizeMap[currentBoundTexture] = width * height * 4;
|
||||
currentUsedBytes += bindingToSizeMap[currentBoundTexture];
|
||||
std::cout << "GL glTexImage2D: " << currentBoundTexture << " freeing " << bindingToSizeMap[currentBoundTexture] << " bytes current total " << currentUsedBytes << "\n";
|
||||
}
|
||||
lock.unlock();
|
||||
glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user