From 58ec4585483b36354e814171c95f61d3caf9ffb0 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 29 Jul 2018 23:20:37 +0000 Subject: [PATCH] Remove some old fixed-function state tracking that wasn't needed. Add gl_debug implementation which was forgotten in previous change. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12444 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_backend.c | 71 +++++++++++++++++++++------------------------------- gl_backend.h | 7 +----- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/gl_backend.c b/gl_backend.c index 52e392dc..bc13cd7a 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -200,12 +200,6 @@ typedef struct gltextureunit_s rtexture_t *texture; int t2d, t3d, tcubemap; int arrayenabled; - int rgbscale, alphascale; - int combine; - int combinergb, combinealpha; - // texmatrixenabled exists only to avoid unnecessary texmatrix compares - int texmatrixenabled; - matrix4x4_t matrix; } gltextureunit_t; @@ -222,13 +216,9 @@ typedef struct gl_state_s int depthfunc; float depthrange[2]; float polygonoffset[2]; - int alphatest; - int alphafunc; - float alphafuncvalue; qboolean alphatocoverage; int scissortest; unsigned int unit; - unsigned int clientunit; gltextureunit_t units[MAX_TEXTUREUNITS]; float color4f[4]; int lockrange_first; @@ -1158,9 +1148,6 @@ static void GL_Backend_ResetState(void) { gl_state.active = true; gl_state.depthtest = true; - gl_state.alphatest = false; - gl_state.alphafunc = GL_GEQUAL; - gl_state.alphafuncvalue = 0.5f; gl_state.alphatocoverage = false; gl_state.blendfunc1 = GL_ONE; gl_state.blendfunc2 = GL_ZERO; @@ -1181,6 +1168,25 @@ static void GL_Backend_ResetState(void) { case RENDERPATH_GL32: case RENDERPATH_GLES2: + // set up debug output early + if (vid.support.arb_debug_output) + { + GLuint unused = 0; + CHECKGLERROR + if (gl_debug.integer >= 1) + qglEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + if (gl_debug.integer >= 3) + qglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, &unused, gl_debug.integer >= 3 ? GL_TRUE : GL_FALSE); + else if (gl_debug.integer >= 1) + { + qglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, &unused, gl_debug.integer >= 3 ? GL_TRUE : GL_FALSE); + qglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM_ARB, 0, &unused, gl_debug.integer >= 2 ? GL_TRUE : GL_FALSE); + qglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH_ARB, 0, &unused, gl_debug.integer >= 1 ? GL_TRUE : GL_FALSE); + } + else + qglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, &unused, GL_FALSE); + qglDebugMessageCallbackARB(GL_DebugOutputCallback, NULL); + } CHECKGLERROR qglColorMask(1, 1, 1, 1);CHECKGLERROR qglBlendFunc(gl_state.blendfunc1, gl_state.blendfunc2);CHECKGLERROR @@ -1198,7 +1204,6 @@ static void GL_Backend_ResetState(void) qglDisableVertexAttribArray(GLSLATTRIB_COLOR); qglVertexAttrib4f(GLSLATTRIB_COLOR, 1, 1, 1, 1); gl_state.unit = MAX_TEXTUREUNITS; - gl_state.clientunit = MAX_TEXTUREUNITS; CHECKGLERROR break; } @@ -2162,8 +2167,6 @@ void R_Mesh_ResetTextureState(void) for (unitnum = 0;unitnum < MAX_TEXTUREUNITS;unitnum++) R_Mesh_TexBind(unitnum, NULL); - for (unitnum = 0;unitnum < MAX_TEXTUREUNITS;unitnum++) - R_Mesh_TexCoordPointer(unitnum, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); } void R_Mesh_PrepareVertices_Vertex3f(int numvertices, const float *vertex3f, const r_meshbuffer_t *vertexbuffer, int bufferoffset) @@ -2171,32 +2174,16 @@ void R_Mesh_PrepareVertices_Vertex3f(int numvertices, const float *vertex3f, con // upload temporary vertexbuffer for this rendering if (!vertexbuffer) vertexbuffer = R_BufferData_Store(numvertices * sizeof(float[3]), (void *)vertex3f, R_BUFFERDATA_VERTEX, &bufferoffset); - if (vertexbuffer) - { - R_Mesh_VertexPointer(3, GL_FLOAT, sizeof(float[3]), vertex3f, vertexbuffer, bufferoffset); - R_Mesh_ColorPointer(4, GL_FLOAT, sizeof(float[4]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(0, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(1, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(2, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(3, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(4, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(5, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(6, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(7, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), NULL, NULL, 0); - } - else - { - R_Mesh_VertexPointer(3, GL_FLOAT, sizeof(float[3]), vertex3f, vertexbuffer, 0); - R_Mesh_ColorPointer(4, GL_FLOAT, sizeof(float[4]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(0, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(1, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(2, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(3, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(4, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(5, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(6, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), NULL, NULL, 0); - R_Mesh_TexCoordPointer(7, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), NULL, NULL, 0); - } + R_Mesh_VertexPointer( 3, GL_FLOAT , sizeof(float[3]) , vertex3f , vertexbuffer , bufferoffset ); + R_Mesh_ColorPointer( 4, GL_FLOAT , sizeof(float[4]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(0, 2, GL_FLOAT , sizeof(float[2]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(1, 3, GL_FLOAT , sizeof(float[3]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(2, 3, GL_FLOAT , sizeof(float[3]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(3, 3, GL_FLOAT , sizeof(float[3]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(4, 2, GL_FLOAT , sizeof(float[2]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(5, 2, GL_FLOAT , sizeof(float[2]) , NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(6, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), NULL , NULL , 0 ); + R_Mesh_TexCoordPointer(7, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), NULL , NULL , 0 ); } void R_Mesh_PrepareVertices_Generic_Arrays(int numvertices, const float *vertex3f, const float *color4f, const float *texcoord2f) diff --git a/gl_backend.h b/gl_backend.h index 2e505cd1..d12ab1c6 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -40,12 +40,10 @@ void GL_DepthRange(float nearfrac, float farfrac); void R_SetStencil(qboolean enable, int writemask, int fail, int zfail, int zpass, int compare, int comparereference, int comparemask); void GL_PolygonOffset(float planeoffset, float depthoffset); void GL_CullFace(int state); -void GL_AlphaTest(int state); void GL_AlphaToCoverage(qboolean state); void GL_ColorMask(int r, int g, int b, int a); void GL_Color(float cr, float cg, float cb, float ca); void GL_ActiveTexture(unsigned int num); -void GL_ClientActiveTexture(unsigned int num); void GL_Scissor(int x, int y, int width, int height); void GL_ScissorTest(int state); void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue); @@ -57,6 +55,7 @@ void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colo unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list); void GL_Backend_FreeProgram(unsigned int prog); +extern cvar_t gl_debug; extern cvar_t gl_paranoid; extern cvar_t gl_printcheckerror; @@ -95,10 +94,6 @@ int R_Mesh_TexBound(unsigned int unitnum, int id); void R_Mesh_CopyToTexture(rtexture_t *tex, int tx, int ty, int sx, int sy, int width, int height); // bind a given texture to a given image unit void R_Mesh_TexBind(unsigned int unitnum, rtexture_t *tex); -// sets the texcoord matrix for a texenv unit, can be NULL or blank (will use identity) -void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix); -// sets the combine state for a texenv unit -void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale); // set up a blank texture state (unbinds all textures, texcoord pointers, and resets combine settings) void R_Mesh_ResetTextureState(void); // before a texture is freed, make sure there are no references to it -- 2.39.2