mirror of
https://github.com/MobileGL-Dev/MobileGlues.git
synced 2025-09-17 16:08:17 -04:00
[Feat] (...): Add LOG_CALLED_FUNCS to record gl functions.
Signed-off-by: BZLZHH <admin@bzlzhh.top>
This commit is contained in:
parent
8c1f21d895
commit
a01c41fb17
@ -182,6 +182,7 @@ void glMultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const v
|
||||
//_Thread_local static bool unexpected_error = false;
|
||||
|
||||
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
|
||||
LOG()
|
||||
LOG_D("glDrawElements, mode: %d, count: %d, type: %d, indices: %p", mode, count, type, indices)
|
||||
//LOAD_GLES_FUNC(glGetError)
|
||||
//GLenum pre_err = GLES.glGetError();
|
||||
@ -199,6 +200,8 @@ void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices
|
||||
}
|
||||
|
||||
void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) {
|
||||
|
||||
LOG()
|
||||
LOG_D("glBindImageTexture, unit: %d, texture: %d, level: %d, layered: %d, layer: %d, access: %d, format: %d",
|
||||
unit, texture, level, layered, layer, access, format)
|
||||
//LOAD_GLES_FUNC(glGetError)
|
||||
@ -212,6 +215,7 @@ void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean laye
|
||||
}
|
||||
|
||||
void glUniform1i(GLint location, GLint v0) {
|
||||
LOG()
|
||||
LOG_D("glUniform1i, location: %d, v0: %d", location, v0)
|
||||
//LOAD_GLES_FUNC(glGetError)
|
||||
GLES.glUniform1i(location, v0);
|
||||
@ -224,6 +228,7 @@ void glUniform1i(GLint location, GLint v0) {
|
||||
}
|
||||
|
||||
void glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z) {
|
||||
LOG()
|
||||
LOG_D("glDispatchCompute, num_groups_x: %d, num_groups_y: %d, num_groups_z: %d",
|
||||
num_groups_x, num_groups_y, num_groups_z)
|
||||
//LOAD_GLES_FUNC(glGetError)
|
||||
|
@ -1,7 +1,12 @@
|
||||
//
|
||||
// Created by BZLZHH on 2025/1/26.
|
||||
//
|
||||
|
||||
#include "log.h"
|
||||
#include <unistd.h>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <mutex>
|
||||
|
||||
#include "gl.h"
|
||||
|
||||
@ -1085,4 +1090,30 @@ const char* glEnumToString(GLenum e) {
|
||||
sprintf(str, "0x%x", e);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if LOG_CALLED_FUNCS
|
||||
|
||||
void log_unique_function(const char* func_name) {
|
||||
if (!func_name || strlen(func_name) < 2 || strncmp(func_name, "gl", 2) != 0) {
|
||||
return;
|
||||
}
|
||||
static std::unordered_set<std::string> logged_functions;
|
||||
static std::mutex log_mutex;
|
||||
std::string func_str(func_name);
|
||||
|
||||
std::lock_guard<std::mutex> guard(log_mutex);
|
||||
|
||||
if (logged_functions.find(func_str) != logged_functions.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
static FILE* fp = fopen("/sdcard/MG/glcalls.txt", "a");
|
||||
if (fp) {
|
||||
fprintf(fp, "%s\n", func_name);
|
||||
fflush(fp);
|
||||
}
|
||||
|
||||
logged_functions.insert(func_str);
|
||||
}
|
||||
#endif
|
@ -10,6 +10,8 @@
|
||||
|
||||
#define GLOBAL_DEBUG 0
|
||||
|
||||
#define LOG_CALLED_FUNCS 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -31,6 +33,15 @@ const char *glEnumToString(GLenum e);
|
||||
#define LOG() \
|
||||
perfetto::StaticString _FUNC_NAME_ = __func__; \
|
||||
TRACE_EVENT("glcalls", _FUNC_NAME_);
|
||||
#elif LOG_CALLED_FUNCS
|
||||
#define LOG() \
|
||||
if(DEBUG||GLOBAL_DEBUG) { \
|
||||
__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, "Use function: %s", __FUNCTION__); \
|
||||
printf("Use function: %s\n", __FUNCTION__); \
|
||||
write_log("Use function: %s\n", __FUNCTION__); \
|
||||
} \
|
||||
log_unique_function(__FUNCTION__);
|
||||
void log_unique_function(const char* func_name);
|
||||
#else
|
||||
#define LOG() \
|
||||
if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, "Use function: %s", __FUNCTION__);printf("Use function: %s\n", __FUNCTION__);write_log("Use function: %s\n", __FUNCTION__);}
|
||||
|
@ -89,7 +89,8 @@ static name##_PTR egl_##name = NULL; \
|
||||
|
||||
#define NATIVE_FUNCTION_HEAD(type,name,...) \
|
||||
extern "C" GLAPI GLAPIENTRY type name##ARB(__VA_ARGS__) __attribute__((alias(#name))); \
|
||||
extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) {
|
||||
extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) { \
|
||||
LOG()
|
||||
|
||||
#if GLOBAL_DEBUG
|
||||
#define NATIVE_FUNCTION_END(type,name,...) \
|
||||
@ -123,7 +124,8 @@ extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) {
|
||||
#endif
|
||||
|
||||
#define STUB_FUNCTION_HEAD(type,name,...) \
|
||||
extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) {
|
||||
extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) { \
|
||||
LOG()
|
||||
|
||||
#define STUB_FUNCTION_END(type,name,...) \
|
||||
LOG_W("Stub function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user