COREGL_OVERRIDE(fastpath_, glBindFramebuffer);
COREGL_OVERRIDE(fastpath_, glIsFramebuffer);
COREGL_OVERRIDE(fastpath_, glDeleteFramebuffers);
+ COREGL_OVERRIDE(fastpath_, glGetFramebufferAttachmentParameteriv);
COREGL_OVERRIDE(fastpath_, glGenRenderbuffers);
COREGL_OVERRIDE(fastpath_, glBindRenderbuffer);
_COREGL_FASTPATH_FUNC_END();
}
+void
+fastpath_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params)
+{
+ GLint real_obj, fa_type;
+
+ DEFINE_FASTPAH_GL_FUNC();
+ _COREGL_FASTPATH_FUNC_BEGIN();
+ INIT_FASTPATH_GL_FUNC();
+
+ switch (pname)
+ {
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+ params[0] = 0;
+ _orig_fastpath_glGetFramebufferAttachmentParameteriv(target, attachment, pname, &real_obj);
+ _orig_fastpath_glGetFramebufferAttachmentParameteriv(target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &fa_type);
+ switch (fa_type)
+ {
+ case GL_TEXTURE:
+ if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)params) != 1)
+ {
+ params[0] = 0;
+ goto finish;
+ }
+ break;
+ case GL_RENDERBUFFER:
+ if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj, (GLuint *)params) != 1)
+ {
+ params[0] = 0;
+ goto finish;
+ }
+ break;
+ }
+ break;
+ default:
+ _orig_fastpath_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
+ break;
+ }
+
+ goto finish;
+
+finish:
+ _COREGL_FASTPATH_FUNC_END();
+}
+
+
GLboolean
fastpath_glIsTexture(GLuint texture)
{
void (*dl_png_write_end) (png_structp png_ptr,
png_infop info_ptr);
-void
-tracepath_surface_trace_add(const char *desc, GLDisplay dpy, GLContext ctx, GLSurface surf, GLint fbo, GLint tex, GLint rb, GLint tex_w, GLint tex_h, GLint tex_format)
-{
- Surface_Data *std = NULL;
-
- if (trace_surface_flag == 1)
- {
- AST(mutex_lock(&std_access_mutex) == 1);
-
- if (std_table == NULL)
- {
- std_table = (Surface_Data **)calloc(1, sizeof(Surface_Data *) * MAX_TRACE_TABLE_SIZE);
- }
-
- std = (Surface_Data *)_get_trace_data((Trace_Data **)std_table, sizeof(Surface_Data), desc);
-
- AST(std != NULL);
-
- std->display = dpy;
- std->surface = surf;
- std->context = ctx;
- if (fbo >= 0) std->fbo = fbo;
- std->tex = tex;
- std->rb = rb;
- if (tex_w >= 0) std->tex_w = tex_w;
- if (tex_h >= 0) std->tex_h = tex_h;
- if (tex_format >= 0) std->tex_format = tex_format;
-
- AST(mutex_unlock(&std_access_mutex) == 1);
-
- }
-
-}
-
static void
-_dump_surface(int force_output, const char *position, Surface_Data *sdata)
+_dump_surface(int force_output, int type, const char *position, Surface_Data *sdata)
{
static int alldumpcount = 0;
png_struct *png;
png_info *info;
png_byte **rows;
- png_color_16 black;
if (!png_lib_handle ||
dl_png_create_write_struct == NULL ||
else
sprintf(name, "[%d %p-%p] %s %04d (%s).png", getpid(), sdata->display, sdata->context, sdata->trace_data.name, sdata->dump_count, position);
- if (sdata->fbo == 0 && sdata->tex == 0 && sdata->rb == 0)
+ if (!strncmp(sdata->trace_data.name, "EGL", 3) && type != 2)
{ // EGL
if (trace_surface_filter_type != 0 &&
trace_surface_filter_type != 1) return;
return;
}
- TRACE("\E[40;31;1m[[TRACE SURFACE]] : '%s' is dumped (%dx%d).\E[0m\n", name, width, height);
+ if (channel == 3) channel = 4;
+
+ TRACE("\E[40;31;1m[[TRACE SURFACE]] : '%s' is dumped (%dx%dx%d).\E[0m\n", name, width, height, channel);
if (trace_surface_print_only_flag == 1 && force_output == 0)
{
alldumpcount++;
return;
}
- data = (unsigned char *)malloc(width * height * channel * sizeof(unsigned char));
+ data = (unsigned char *)calloc(1, width * height * channel * sizeof(unsigned char));
if (data == NULL)
{
COREGL_ERR("Can't trace surface : Failed to allocate memory");
_orig_tracepath_glBindFramebuffer(GL_FRAMEBUFFER, oldfb);
}
- if (sdata->fbo != 0)
+ if (!strncmp(sdata->trace_data.name, "FBO", 3) && type != 1)
{ // FBO
+ if (sdata->fbo == 0) return;
+
if (trace_surface_filter_type != 0 &&
trace_surface_filter_type != 2) return;
return;
}
- TRACE("\E[40;31;1m[[TRACE SURFACE]] : '%s' is dumped (%dx%d).\E[0m\n", name, width, height);
+ TRACE("\E[40;31;1m[[TRACE SURFACE]] : '%s' is dumped (%dx%dx%d).\E[0m\n", name, width, height, channel);
if (trace_surface_print_only_flag == 1 && force_output == 0)
{
alldumpcount++;
return;
}
- data = (unsigned char *)malloc(width * height * channel * sizeof(unsigned char));
+ if (channel == 3) channel = 4;
+
+ data = (unsigned char *)calloc(1, width * height * channel * sizeof(unsigned char));
if (data == NULL)
{
COREGL_ERR("Can't trace surface : Failed to allocate memory");
}
_orig_tracepath_glBindFramebuffer(GL_FRAMEBUFFER, sdata->fbo);
+ int atttype = _COREGL_INT_INIT_VALUE;
+ _orig_tracepath_glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &atttype);
+ AST(atttype != sdata->tex);
+ int attname = _COREGL_INT_INIT_VALUE;
+ _orig_tracepath_glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &attname);
+ switch (atttype)
+ {
+ case GL_TEXTURE:
+ AST(attname == sdata->tex);
+ break;
+ case GL_RENDERBUFFER:
+ AST(attname == sdata->rb);
+ break;
+ }
+
switch(channel)
{
case 4: _orig_tracepath_glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); break;
case 1: dl_png_set_IHDR(png, info, width, height, 8, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); break;
}
- black.red = 0x00;
- black.green = 0x00;
- black.blue = 0x00;
- dl_png_set_bKGD(png, info, &black);
-
- //dl_png_set_bgr(png);
-
dl_png_write_info(png, info);
dl_png_write_image(png, rows);
}
-
void
-tracepath_surface_trace(int force_output, const char *position)
+tracepath_surface_trace_add(const char *desc, GLDisplay dpy, GLContext ctx, GLSurface surf, GLint fbo, GLint tex, GLint rb, GLint tex_w, GLint tex_h, GLint tex_format, const char *dump)
{
- GLThreadState *tstate = NULL;
- MY_MODULE_TSTATE *tstate_tm = NULL;
- int i;
+ Surface_Data *std = NULL;
- if (trace_surface_flag != 1)
+ if (trace_surface_flag == 1)
{
- goto finish;
+ AST(mutex_lock(&std_access_mutex) == 1);
+
+ if (std_table == NULL)
+ {
+ std_table = (Surface_Data **)calloc(1, sizeof(Surface_Data *) * MAX_TRACE_TABLE_SIZE);
+ }
+
+ std = (Surface_Data *)_get_trace_data((Trace_Data **)std_table, sizeof(Surface_Data), desc);
+
+ AST(std != NULL);
+
+ if (dump != NULL)
+ {
+ _dump_surface(0, 0, dump, std);
+ }
+
+ std->display = dpy;
+ std->surface = surf;
+ std->context = ctx;
+ if (fbo >= 0) std->fbo = fbo;
+ std->tex = tex;
+ std->rb = rb;
+ if (tex_w >= 0) std->tex_w = tex_w;
+ if (tex_h >= 0) std->tex_h = tex_h;
+ if (tex_format >= 0) std->tex_format = tex_format;
+
+ AST(mutex_unlock(&std_access_mutex) == 1);
+
}
- tstate = get_current_thread_state();
+}
- if (tstate == NULL)
- {
- init_new_thread_state();
+void
+tracepath_surface_trace(int force_output, int type, const char *position)
+{
+ int i;
- tstate = get_current_thread_state();
- AST(tstate != NULL);
+ if (trace_surface_flag != 1)
+ {
+ goto finish;
}
- GET_MY_TSTATE(tstate_tm, tstate);
- if (tstate_tm == NULL) return;
+ AST(mutex_lock(&std_access_mutex) == 1);
if (std_table != NULL)
{
+ EGLDisplay olddpy = _orig_tracepath_eglGetCurrentDisplay();
+ EGLContext oldctx = _orig_tracepath_eglGetCurrentContext();
+ EGLSurface oldsurf_read = _orig_tracepath_eglGetCurrentSurface(EGL_READ);
+ EGLSurface oldsurf_draw = _orig_tracepath_eglGetCurrentSurface(EGL_DRAW);
+
for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
{
if (std_table[i] != NULL)
{
if (_orig_tracepath_eglMakeCurrent(current->display, current->surface, current->surface, current->context) == EGL_TRUE)
{
- _dump_surface(force_output, position, current);
+ _dump_surface(force_output, type, position, current);
}
}
}
}
}
-
- _orig_tracepath_eglMakeCurrent(tstate_tm->ctx->dpy, tstate_tm->surf_draw, tstate_tm->surf_read, tstate_tm->ctx->handle);
+ _orig_tracepath_eglMakeCurrent(olddpy, oldsurf_read, oldsurf_draw, oldctx);
}
+ AST(mutex_unlock(&std_access_mutex) == 1);
+
goto finish;
finish:
COREGL_API void
coregl_dump_surface()
{
- _COREGL_TRACE_SURFACE(1, "USER CALL");
+ _COREGL_TRACE_SURFACE(1, 0, "USER CALL");
}
#endif
\r
#ifdef COREGL_TRACEPATH_TRACE_SURFACE_INFO\r
-# define _COREGL_TRACE_SURFACE(force_output, position) \\r
- tracepath_surface_trace(force_output, position);\r
+# define _COREGL_TRACE_SURFACE(force_output, type, position) \\r
+ tracepath_surface_trace(force_output, type, position);\r
#else
-# define _COREGL_TRACE_SURFACE(force_output, position)\r
+# define _COREGL_TRACE_SURFACE(force_output, type, position)\r
#endif
\r
#define _COREGL_TRACEPATH_FUNC_BEGIN() \\r
extern void tracepath_mem_trace_remove(const char *desc, int alloc_size);\r
extern void tracepath_mem_trace_output(int force_output);\r
\r
-extern void tracepath_surface_trace_add(const char *desc, GLDisplay dpy, GLContext ctx, GLSurface surf, GLint fbo, GLint tex, GLint rb, GLint tex_w, GLint tex_h, GLint tex_format);\r
-extern void tracepath_surface_trace(int force_output, const char *position);\r
+extern void tracepath_surface_trace_add(const char *desc, GLDisplay dpy, GLContext ctx, GLSurface surf, GLint fbo, GLint tex, GLint rb, GLint tex_w, GLint tex_h, GLint tex_format, const char *dump);\r
+extern void tracepath_surface_trace(int force_output, int type, const char *position);\r
\r
extern void tracepath_glbuf_clear(Glbuf_Data **glbuf);\r
\r
{
char name[256];
sprintf(name, "EGLSURFACE_%p", surface);
- tracepath_surface_trace_add(name, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ tracepath_surface_trace_add(name, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
}
#endif // COREGL_TRACEPATH_TRACE_SURFACE_INFO
return ret;
_COREGL_TRACEPATH_FUNC_BEGIN();
ret = _orig_tracepath_eglWaitGL();
+
+ _COREGL_TRACE_SURFACE(0, 1, "EGLWAITGL");
+
goto finish;
finish:
{
EGLBoolean ret = EGL_FALSE;
- _COREGL_TRACE_SURFACE(0, "SWAPBUFFERS");
+ _COREGL_TRACE_SURFACE(0, 1, "SWAPBUFFERS");
_COREGL_TRACEPATH_FUNC_BEGIN();
ret = _orig_tracepath_eglSwapBuffers(dpy, surface);
switch (atttype)
{
case GL_TEXTURE:
- //COREGL_LOG("FBO DUMPING BEGIN = (TEX)%d\n", attname);
+ //COREGL_LOG("FBO DUMPING BEGIN = (TEX)0x%X\n", attname);
{
char name[256];
- sprintf(name, "FBOTEX_%d", attname);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, fbname, attname, 0, -1, -1, -1);
+ sprintf(name, "FBOTEX_0x%X", attname);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, fbname, attname, 0, -1, -1, -1, NULL);
}
break;
case GL_RENDERBUFFER:
- //COREGL_LOG("FBO DUMPING BEGIN = (RB)%d\n", attname);
+ //COREGL_LOG("FBO DUMPING BEGIN = (RB)0x%X\n", attname);
{
char name[256];
- sprintf(name, "FBORB_%d", attname);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, fbname, 0, attname, -1, -1, -1);
+ sprintf(name, "FBORB_0x%X", attname);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, fbname, 0, attname, -1, -1, -1, NULL);
}
break;
}
switch (atttype)
{
case GL_TEXTURE:
- //COREGL_LOG("FBO DUMPING END = (TEX)%d\n", attname);
+ //COREGL_LOG("FBO DUMPING END = (TEX)0x%X\n", attname);
{
char name[256];
- sprintf(name, "FBOTEX_%d", attname);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, 0, attname, 0, -1, -1, -1);
+ sprintf(name, "FBOTEX_0x%X", attname);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, 0, attname, 0, -1, -1, -1, NULL);
}
break;
case GL_RENDERBUFFER:
- //COREGL_LOG("FBO DUMPING END = (RB)%d\n", attname);
+ //COREGL_LOG("FBO DUMPING END = (RB)0x%X\n", attname);
{
char name[256];
- sprintf(name, "FBORB_%d", attname);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, 0, 0, attname, -1, -1, -1);
+ sprintf(name, "FBORB_0x%X", attname);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, 0, 0, attname, -1, -1, -1, NULL);
}
break;
}
if (tstate->ctx != NULL)
{
_surface_trace_set(set, fbname, GL_COLOR_ATTACHMENT0, tstate);
- _surface_trace_set(set, fbname, GL_DEPTH_ATTACHMENT, tstate);
- _surface_trace_set(set, fbname, GL_STENCIL_ATTACHMENT, tstate);
+// _surface_trace_set(set, fbname, GL_DEPTH_ATTACHMENT, tstate);
+// _surface_trace_set(set, fbname, GL_STENCIL_ATTACHMENT, tstate);
}
}
}
_COREGL_TRACEPATH_FUNC_BEGIN();
#ifdef COREGL_TRACEPATH_TRACE_SURFACE_INFO
+ GLint oldfb;
+ _orig_tracepath_glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldfb);
+ if (oldfb != 0)
+ {
+ _COREGL_TRACE_SURFACE(0, 2, "GLBINDFBO");
+ }
+
tracepath_fbdump_update(0);
#endif // COREGL_TRACEPATH_TRACE_SURFACE_INFO
if (fbname == 0)
{
char name[256];
- sprintf(name, "EGLSURFACE_%p", _orig_tracepath_eglGetCurrentSurface(EGL_DRAW));
- tracepath_surface_trace_add(name, _orig_tracepath_eglGetCurrentDisplay(), _orig_tracepath_eglGetCurrentContext(), _orig_tracepath_eglGetCurrentSurface(EGL_DRAW), 0, 0, 0, 0, 0, 0);
+ EGLint btype;
+ _orig_tracepath_eglQuerySurface(_orig_tracepath_eglGetCurrentDisplay(), _orig_tracepath_eglGetCurrentSurface(EGL_DRAW), EGL_RENDER_BUFFER, &btype);
+ if (btype == EGL_SINGLE_BUFFER)
+ sprintf(name, "EGLPIXMAP_%p", _orig_tracepath_eglGetCurrentSurface(EGL_DRAW));
+ else
+ sprintf(name, "EGLWINDOW_%p", _orig_tracepath_eglGetCurrentSurface(EGL_DRAW));
+ tracepath_surface_trace_add(name, _orig_tracepath_eglGetCurrentDisplay(), _orig_tracepath_eglGetCurrentContext(), _orig_tracepath_eglGetCurrentSurface(EGL_DRAW), 0, 0, 0, 0, 0, 0, NULL);
}
}
#endif // COREGL_TRACEPATH_TRACE_SURFACE_INFO
if (fbname == 0)
{
char name[256];
- sprintf(name, "EGLSURFACE_%p", _orig_tracepath_eglGetCurrentSurface(EGL_DRAW));
- tracepath_surface_trace_add(name, _orig_tracepath_eglGetCurrentDisplay(), _orig_tracepath_eglGetCurrentContext(), _orig_tracepath_eglGetCurrentSurface(EGL_DRAW), 0, 0, 0, 0, 0, 0);
+ EGLint btype;
+ _orig_tracepath_eglQuerySurface(_orig_tracepath_eglGetCurrentDisplay(), _orig_tracepath_eglGetCurrentSurface(EGL_DRAW), EGL_RENDER_BUFFER, &btype);
+ if (btype == EGL_SINGLE_BUFFER)
+ sprintf(name, "EGLPIXMAP_%p", _orig_tracepath_eglGetCurrentSurface(EGL_DRAW));
+ else
+ sprintf(name, "EGLWINDOW_%p", _orig_tracepath_eglGetCurrentSurface(EGL_DRAW));
+ tracepath_surface_trace_add(name, _orig_tracepath_eglGetCurrentDisplay(), _orig_tracepath_eglGetCurrentContext(), _orig_tracepath_eglGetCurrentSurface(EGL_DRAW), 0, 0, 0, 0, 0, 0, NULL);
}
}
#endif // COREGL_TRACEPATH_TRACE_SURFACE_INFO
_COREGL_TRACEPATH_FUNC_BEGIN();
_orig_tracepath_glFinish();
+ _COREGL_TRACE_SURFACE(0, 0, "GLFINISH");
+
goto finish;
finish:
_COREGL_TRACEPATH_FUNC_BEGIN();
_orig_tracepath_glFlush();
+ _COREGL_TRACE_SURFACE(0, 0, "GLFLUSH");
+
goto finish;
finish:
char name[256];
sprintf(name, "FBORB_%d", objidx);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, -1, 0, objidx, width, height, channel);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, -1, 0, objidx, width, height, channel, NULL);
}
}
}
}
char name[256];
- sprintf(name, "FBOTEX_%d", objidx);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, -1, objidx, 0, width, height, channel);
+ sprintf(name, "FBOTEX_0x%X", objidx);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, -1, objidx, 0, width, height, channel, NULL);
}
}
}
}
char name[256];
- sprintf(name, "FBORB_%d", objidx);
- tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, -1, 0, objidx, width, height, channel);
+ sprintf(name, "FBORB_0x%X", objidx);
+ tracepath_surface_trace_add(name, tstate->ctx->dpy, tstate->ctx->handle, tstate->surf_draw, -1, 0, objidx, width, height, channel, NULL);
}
}
}