Skip to content

Commit dfa1046

Browse files
author
Romain Guy
committed
Add call sites for OpenGL's debug label extension
Change-Id: I9c689127e8166cbef92c935f8aa07217ab806dda
1 parent 2d97a70 commit dfa1046

File tree

3 files changed

+53
-22
lines changed

3 files changed

+53
-22
lines changed

libs/hwui/Caches.cpp

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,9 @@ namespace uirenderer {
4848
///////////////////////////////////////////////////////////////////////////////
4949

5050
Caches::Caches(): Singleton<Caches>(), mInitialized(false) {
51-
GLint maxTextureUnits;
52-
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
53-
if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) {
54-
ALOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT);
55-
}
56-
57-
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
58-
59-
if (extensions.hasDebugMarker()) {
60-
eventMark = glInsertEventMarkerEXT;
61-
startMark = glPushGroupMarkerEXT;
62-
endMark = glPopGroupMarkerEXT;
63-
} else {
64-
eventMark = eventMarkNull;
65-
startMark = startMarkNull;
66-
endMark = endMarkNull;
67-
}
68-
6951
init();
52+
initExtensions();
53+
initConstraints();
7054

7155
mDebugLevel = readDebugLevel();
7256
ALOGD("Enabling debug mode %d", mDebugLevel);
@@ -105,6 +89,36 @@ void Caches::init() {
10589
mInitialized = true;
10690
}
10791

92+
void Caches::initExtensions() {
93+
if (extensions.hasDebugMarker()) {
94+
eventMark = glInsertEventMarkerEXT;
95+
startMark = glPushGroupMarkerEXT;
96+
endMark = glPopGroupMarkerEXT;
97+
} else {
98+
eventMark = eventMarkNull;
99+
startMark = startMarkNull;
100+
endMark = endMarkNull;
101+
}
102+
103+
if (extensions.hasDebugLabel()) {
104+
setLabel = glLabelObjectEXT;
105+
getLabel = glGetObjectLabelEXT;
106+
} else {
107+
setLabel = setLabelNull;
108+
getLabel = getLabelNull;
109+
}
110+
}
111+
112+
void Caches::initConstraints() {
113+
GLint maxTextureUnits;
114+
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
115+
if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) {
116+
ALOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT);
117+
}
118+
119+
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
120+
}
121+
108122
void Caches::terminate() {
109123
if (!mInitialized) return;
110124

libs/hwui/Caches.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ANDROID_API Caches: public Singleton<Caches> {
107107
};
108108

109109
/**
110-
* Initializes the cache.
110+
* Initialize caches.
111111
*/
112112
void init();
113113

@@ -247,15 +247,30 @@ class ANDROID_API Caches: public Singleton<Caches> {
247247
GammaFontRenderer fontRenderer;
248248
ResourceCache resourceCache;
249249

250+
// Debug methods
250251
PFNGLINSERTEVENTMARKEREXTPROC eventMark;
251252
PFNGLPUSHGROUPMARKEREXTPROC startMark;
252253
PFNGLPOPGROUPMARKEREXTPROC endMark;
253254

255+
PFNGLLABELOBJECTEXTPROC setLabel;
256+
PFNGLGETOBJECTLABELEXTPROC getLabel;
257+
254258
private:
255-
static void eventMarkNull(GLsizei length, const GLchar *marker) { }
256-
static void startMarkNull(GLsizei length, const GLchar *marker) { }
259+
void initExtensions();
260+
void initConstraints();
261+
262+
static void eventMarkNull(GLsizei length, const GLchar* marker) { }
263+
static void startMarkNull(GLsizei length, const GLchar* marker) { }
257264
static void endMarkNull() { }
258265

266+
static void setLabelNull(GLenum type, uint object, GLsizei length,
267+
const char* label) { }
268+
static void getLabelNull(GLenum type, uint object, GLsizei bufferSize,
269+
GLsizei* length, char* label) {
270+
if (length) *length = 0;
271+
if (label) *label = '\0';
272+
}
273+
259274
GLuint mCurrentBuffer;
260275
GLuint mCurrentIndicesBuffer;
261276
void* mCurrentPositionPointer;

libs/hwui/Extensions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ namespace uirenderer {
4040
#endif
4141

4242
// Vendor strings
43-
4443
#define VENDOR_IMG "Imagination Technologies"
4544

4645
///////////////////////////////////////////////////////////////////////////////
@@ -68,6 +67,7 @@ class Extensions {
6867
mHasFramebufferFetch = hasExtension("GL_NV_shader_framebuffer_fetch");
6968
mHasDiscardFramebuffer = hasExtension("GL_EXT_discard_framebuffer");
7069
mHasDebugMarker = hasExtension("GL_EXT_debug_marker");
70+
mHasDebugLabel = hasExtension("GL_EXT_debug_label");
7171

7272
const char* vendor = (const char*) glGetString(GL_VENDOR);
7373
EXT_LOGD("Vendor: %s", vendor);
@@ -84,6 +84,7 @@ class Extensions {
8484
inline bool needsHighpTexCoords() const { return mNeedsHighpTexCoords; }
8585
inline bool hasDiscardFramebuffer() const { return mHasDiscardFramebuffer; }
8686
inline bool hasDebugMarker() const { return mHasDebugMarker; }
87+
inline bool hasDebugLabel() const { return mHasDebugLabel; }
8788

8889
bool hasExtension(const char* extension) const {
8990
const String8 s(extension);
@@ -104,6 +105,7 @@ class Extensions {
104105
bool mHasFramebufferFetch;
105106
bool mHasDiscardFramebuffer;
106107
bool mHasDebugMarker;
108+
bool mHasDebugLabel;
107109
}; // class Extensions
108110

109111
}; // namespace uirenderer

0 commit comments

Comments
 (0)