Add GL debugging event annotations for Polymost functions

git-svn-id: https://svn.eduke32.com/eduke32@7681 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/include/polymost.h
#	source/build/src/mdsprite.cpp
#	source/build/src/polymost.cpp
This commit is contained in:
pogokeen 2019-05-25 14:59:09 +00:00 committed by Christoph Oelckers
parent 5cd7f18dab
commit 9b621c0ef2
4 changed files with 59 additions and 0 deletions

View file

@ -36,6 +36,7 @@ extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES];
extern void Polymost_prepare_loadboard(void);
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...);
//void phex(char v, char *s);
void uploadtexture(FHardwareTexture *tex, int32_t doalloc, vec2_t siz, int32_t texfmt, coltype *pic, vec2_t tsiz, int32_t dameth);

View file

@ -1913,6 +1913,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
const uint8_t lpal = ((unsigned)owner < MAXSPRITES) ? sprite[tspr->owner].pal : tspr->pal;
const int32_t sizyrep = tilesiz[tspr->picnum].y*tspr->yrepeat;
polymost_outputGLDebugMessage(3, "polymost_md3draw(m:%p, tspr:%p)", m, tspr);
// if ((tspr->cstat&48) == 32) return 0;
updateanimation((md2model_t *)m, tspr, lpal);

View file

@ -49,6 +49,7 @@ static float dxb1[MAXWALLSB], dxb2[MAXWALLSB];
float shadescale = 1.0f;
int32_t shadescale_unbounded = 0;
int32_t r_polymostDebug = 0;
int32_t r_enablepolymost2 = 0;
int32_t r_pogoDebug = 0;
int32_t r_usenewshading = 4;
@ -229,6 +230,29 @@ int32_t hicprecaching = 0;
hitdata_t polymost_hitdata;
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...)
{
static char msg[8192];
va_list vArgs;
if (!glinfo.debugoutput ||
r_polymostDebug < severity)
{
return;
}
va_start(vArgs, format);
Bvsnprintf(msg, sizeof(msg), format, vArgs);
va_end(vArgs);
glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB,
GL_DEBUG_TYPE_OTHER_ARB,
0,
GL_DEBUG_SEVERITY_HIGH_ARB+severity-1,
-1,
msg);
}
void gltexinvalidate(int32_t dapicnum, int32_t dapalnum, int32_t dameth)
{
const int32_t pic = (dapicnum&(GLTEXCACHEADSIZ-1));
@ -462,6 +486,8 @@ void polymost_disableProgram()
if (videoGetRenderMode() != REND_POLYMOST)
return;
polymost_outputGLDebugMessage(3, "polymost_disableProgram()");
useShaderProgram(0);
}
@ -470,6 +496,8 @@ void polymost_resetProgram()
if (videoGetRenderMode() != REND_POLYMOST)
return;
polymost_outputGLDebugMessage(3, "polymost_resetProgram()");
if (r_enablepolymost2)
useShaderProgram(polymost2BasicShaderProgramID);
else
@ -482,6 +510,8 @@ void polymost_resetProgram()
static void polymost_setCurrentShaderProgram(uint32_t programID)
{
polymost_outputGLDebugMessage(3, "polymost_setCurrentShaderProgram(programID:%u)", programID);
polymost1CurrentShaderProgramID = programID;
useShaderProgram(programID);
@ -2291,6 +2321,8 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
if (skyclamphack) method |= DAMETH_CLAMPED;
polymost_outputGLDebugMessage(3, "polymost_drawpoly(dpxy:%p, n:%d, method_:%X), method: %X", dpxy, n, method_, method);
pthtyp *pth = our_texcache_fetch(method | (videoGetRenderMode() == REND_POLYMOST && r_useindexedcolortextures ? PTH_INDEXED : 0));
if (!pth)
@ -2889,6 +2921,9 @@ static void polymost_domost(float x0, float y0, float x1, float y1, float y0top
{
int const dir = (x0 < x1);
polymost_outputGLDebugMessage(3, "polymost_domost(x0:%f, y0:%f, x1:%f, y1:%f, y0top:%f, y0bot:%f, y1top:%f, y1bot:%f)",
x0, y0, x1, y1, y0top, y0bot, y1top, y1bot);
y0top -= DOMOST_OFFSET;
y1top -= DOMOST_OFFSET;
y0bot += DOMOST_OFFSET;
@ -4130,6 +4165,8 @@ static void polymost_drawalls(int32_t const bunch)
usectortype const * const sec = (usectortype *)&sector[sectnum];
float const fglobalang = fix16_to_float(qglobalang);
polymost_outputGLDebugMessage(3, "polymost_drawalls(bunch:%d)", bunch);
//DRAW WALLS SECTION!
for (bssize_t z=bunchfirst[bunch]; z>=0; z=bunchp2[z])
{
@ -5388,6 +5425,8 @@ void polymost_drawrooms()
{
if (videoGetRenderMode() == REND_CLASSIC) return;
polymost_outputGLDebugMessage(3, "polymost_drawrooms()");
videoBeginDrawing();
frameoffset = frameplace + windowxy1.y*bytesperline + windowxy1.x;
@ -5625,6 +5664,8 @@ void polymost_drawmaskwall(int32_t damaskwallcnt)
auto const nsec = (usectortype *)&sector[wal->nextsector];
polymost_outputGLDebugMessage(3, "polymost_drawmaskwall(damaskwallcnt:%d)", damaskwallcnt);
globalpicnum = wal->overpicnum;
if ((uint32_t)globalpicnum >= MAXTILES)
globalpicnum = 0;
@ -5937,6 +5978,8 @@ void polymost_drawsprite(int32_t snum)
int32_t spritenum = tspr->owner;
polymost_outputGLDebugMessage(3, "polymost_drawsprite(snum:%d)", snum);
DO_TILE_ANIM(tspr->picnum, spritenum + 32768);
globalpicnum = tspr->picnum;
@ -6582,6 +6625,9 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
if (!hud || hud->flags & HUDFLAG_HIDE)
return;
polymost_outputGLDebugMessage(3, "polymost_dorotatespritemodel(sx:%d, sy:%d, z:%d, a:%hd, picnum:%hd, dashade:%hhd, dapalnum:%hhu, dastat:%d, daalpha:%hhu, dablend:%hhu, uniqid:%d)",
sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, uniqid);
float const ogchang = gchang; gchang = 1.f;
float const ogshang = gshang; gshang = 0.f; d = (float) z*(1.0f/(65536.f*16384.f));
float const ogctang = gctang; gctang = (float) sintable[(a+512)&2047]*d;
@ -6804,6 +6850,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
return;
}
polymost_outputGLDebugMessage(3, "polymost_dorotatesprite(sx:%d, sy:%d, z:%d, a:%hd, picnum:%hd, dashade:%hhd, dapalnum:%hhu, dastat:%d, daalpha:%hhu, dablend:%hhu, cx1:%d, cy1:%d, cx2:%d, cy2:%d, uniqid:%d)",
sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, cx1, cy1, cx2, cy2, uniqid);
glViewport(0,0,xdim,ydim); glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@ -7222,6 +7271,8 @@ static void tessectrap(const float *px, const float *py, const int32_t *point2,
void polymost_fillpolygon(int32_t npoints)
{
polymost_outputGLDebugMessage(3, "polymost_fillpolygon(npoints:%d)", npoints);
globvis2 = 0;
polymost_setVisibility(globvis2);
@ -7338,6 +7389,9 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
{
int const arbackcol = (unsigned)backcol < 256 ? backcol : 0;
polymost_outputGLDebugMessage(3, "polymost_printtext256(xpos:%d, ypos:%d, col:%hd, backcol:%hd, name:%p, fontsize:%hhu)",
xpos, ypos, col, backcol, name, fontsize);
// FIXME?
if (col < 0)
col = 0;
@ -7562,6 +7616,7 @@ void polymost_initosdfuncs(void)
{ "r_parallaxskyclamping","enable/disable parallaxed floor/ceiling sky texture clamping", (void *) &r_parallaxskyclamping, CVAR_BOOL, 0, 1 },
{ "r_parallaxskypanning","enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky", (void *) &r_parallaxskypanning, CVAR_BOOL, 0, 1 },
{ "r_polymostDebug","Set the verbosity of Polymost GL debug messages",(void *) &r_polymostDebug, CVAR_INT, 0, 3 },
#ifdef USE_GLEXT
{ "r_detailmapping","enable/disable detail mapping",(void *) &r_detailmapping, CVAR_BOOL, 0, 1 },
{ "r_glowmapping","enable/disable glow mapping",(void *) &r_glowmapping, CVAR_BOOL, 0, 1 },

View file

@ -1021,6 +1021,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
if ((tspr->cstat&48)==32)
return 0;
polymost_outputGLDebugMessage(3, "polymost_voxdraw(m:%p, tspr:%p)", m, tspr);
//updateanimation((md2model *)m,tspr);
vec3f_t m0 = { m->scale, m->scale, m->scale };