]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
batching is gone.
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 25 Aug 2002 12:26:23 +0000 (12:26 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 25 Aug 2002 12:26:23 +0000 (12:26 +0000)
if you forget to call R_Mesh_Render after each mesh the backend system will yell at you.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2284 d7cf8633-e32d-0410-b094-e92efae38249

cl_particles.c
gl_backend.c
gl_models.c
gl_rmain.c
gl_rsurf.c
r_crosshairs.c
r_explosion.c
r_light.c
r_sky.c

index fd4bade23a6e36acde75aeab6cc26c9042d86ab8..15f78ca5657ec58d1727932e94cd1b7894b7d9eb 100644 (file)
@@ -1323,6 +1323,7 @@ void R_DrawParticles (void)
                        m.color[1] = m.color[5] = m.color[9] = m.color[13] = cg * m.colorscale;
                        m.color[2] = m.color[6] = m.color[10] = m.color[14] = cb * m.colorscale;
                        m.color[3] = m.color[7] = m.color[11] = m.color[15] = ca;
+                       R_Mesh_Render();
                }
        }
 }
index e97232342774a13138d7356cc33be87436f9a491..1dff96e7d9ec73b58b9a2725ceca490e3ac5dad1 100644 (file)
@@ -2,7 +2,6 @@
 #include "quakedef.h"
 
 cvar_t gl_mesh_maxtriangles = {0, "gl_mesh_maxtriangles", "1024"};
-cvar_t gl_mesh_batchtriangles = {0, "gl_mesh_batchtriangles", "0"};
 cvar_t gl_mesh_transtriangles = {0, "gl_mesh_transtriangles", "16384"};
 cvar_t gl_mesh_floatcolors = {0, "gl_mesh_floatcolors", "1"};
 cvar_t gl_mesh_drawmode = {CVAR_SAVE, "gl_mesh_drawmode", "3"};
@@ -87,7 +86,6 @@ void SCR_ScreenShot_f (void);
 
 static int max_meshs;
 static int max_transmeshs;
-static int max_batch;
 static int max_verts; // always max_meshs * 3
 static int max_transverts; // always max_transmeshs * 3
 #define TRANSDEPTHRES 4096
@@ -274,13 +272,6 @@ static void gl_backend_bufferchanges(int init)
        if (gl_mesh_transtriangles.integer > 65536)
                Cvar_SetValueQuick(&gl_mesh_transtriangles, 65536);
 
-       if (gl_mesh_batchtriangles.integer < 1)
-               Cvar_SetValueQuick(&gl_mesh_batchtriangles, 1);
-       if (gl_mesh_batchtriangles.integer > gl_mesh_maxtriangles.integer)
-               Cvar_SetValueQuick(&gl_mesh_batchtriangles, gl_mesh_maxtriangles.integer);
-
-       max_batch = gl_mesh_batchtriangles.integer;
-
        if (max_meshs != gl_mesh_maxtriangles.integer || max_transmeshs != gl_mesh_transtriangles.integer)
        {
                max_meshs = gl_mesh_maxtriangles.integer;
@@ -313,7 +304,6 @@ void gl_backend_init(void)
 
        Cvar_RegisterVariable(&gl_mesh_maxtriangles);
        Cvar_RegisterVariable(&gl_mesh_transtriangles);
-       Cvar_RegisterVariable(&gl_mesh_batchtriangles);
        Cvar_RegisterVariable(&gl_mesh_floatcolors);
        Cvar_RegisterVariable(&gl_mesh_drawmode);
        R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
@@ -777,12 +767,8 @@ void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *in
 // renders mesh buffers, called to flush buffers when full
 void R_Mesh_Render(void)
 {
-       int i;
        int k;
-       int indexcount;
-       int firstvert;
        buf_mesh_t *mesh;
-       unsigned int *index;
 
        if (!backendactive)
                Sys_Error("R_Mesh_Render: called when backend is not active\n");
@@ -819,17 +805,7 @@ void R_Mesh_Render(void)
                for (k = 1, mesh = buf_mesh + k;k < currentmesh;k++, mesh++)
                {
                        GL_MeshState(mesh);
-
-                       firstvert = mesh->firstvert;
-                       indexcount = mesh->triangles * 3;
-                       index = (unsigned int *)&buf_tri[mesh->firsttriangle].index[0];
-
-                       // if not using batching, skip the index adjustment
-                       if (firstvert != 0)
-                               for (i = 0;i < indexcount;i++)
-                                       index[i] += firstvert;
-
-                       GL_DrawRangeElements(firstvert, firstvert + mesh->verts, indexcount, index);CHECKGLERROR
+                       GL_DrawRangeElements(mesh->firstvert, mesh->firstvert + mesh->verts, mesh->triangles * 3, buf_tri[mesh->firsttriangle].index);CHECKGLERROR
                }
        }
 
@@ -994,11 +970,9 @@ void R_Mesh_AddTransparent(void)
                }
        }
 
+       R_Mesh_Render();
        for (;transmesh;transmesh = transmesh->chain)
        {
-               if (currentmesh >= max_meshs || currenttriangle + transmesh->triangles > max_batch || currenttriangle + transmesh->triangles > 1024 || currentvertex + transmesh->verts > max_verts)
-                       R_Mesh_Render();
-
                mesh = &buf_mesh[currentmesh++];
                *mesh = *transmesh; // copy mesh properties
 
@@ -1018,6 +992,7 @@ void R_Mesh_AddTransparent(void)
                        currenttriangle++;
                }
                mesh->triangles = currenttriangle - mesh->firsttriangle;
+               R_Mesh_Render();
        }
 
        currenttransmesh = 0;
@@ -1120,8 +1095,11 @@ void R_Mesh_Draw(const rmeshinfo_t *m)
        }
        else
        {
-               if (currentmesh >= max_meshs || (currenttriangle + m->numtriangles) > max_batch || (currentvertex + m->numverts) > max_verts)
+               if (currentmesh)
+               {
                        R_Mesh_Render();
+                       Con_Printf("mesh queue not empty, flushing.\n");
+               }
 
                c_meshs++;
                c_meshtris += m->numtriangles;
@@ -1233,9 +1211,6 @@ void R_Mesh_Draw(const rmeshinfo_t *m)
                else
                        memcpy(&texcoord[j][0].t[0], m->texcoords[j], m->numverts * sizeof(buf_texcoord_t));
        }
-
-       if (currenttriangle >= max_batch)
-               R_Mesh_Render();
 }
 
 // allocates space in geometry buffers, and fills in pointers to the buffers in passsed struct
@@ -1304,8 +1279,11 @@ int R_Mesh_Draw_GetBuffer(rmeshbufferinfo_t *m, int wantoverbright)
        }
        else
        {
-               if (currentmesh >= max_meshs || (currenttriangle + m->numtriangles) > max_batch || (currentvertex + m->numverts) > max_verts)
+               if (currentmesh)
+               {
                        R_Mesh_Render();
+                       Con_Printf("mesh queue not empty, flushing.\n");
+               }
 
                c_meshs++;
                c_meshtris += m->numtriangles;
index e5852f9bad3dcc83feecac18a75a93a266eab1de..47efa6d27a32090b6c7d285f0f8e10dd11c280e5 100644 (file)
@@ -214,6 +214,7 @@ void R_DrawModelMesh(rtexture_t *skin, float *colors, float cred, float cgreen,
 
        c_alias_polys += aliasmeshinfo.numtriangles;
        R_Mesh_Draw(&aliasmeshinfo);
+       R_Mesh_Render();
 
        // leave it in a state for additional passes
        aliasmeshinfo.blendfunc1 = GL_SRC_ALPHA;
@@ -372,6 +373,7 @@ void R_DrawQ1Q2AliasModel (float fog)
 
                c_alias_polys += aliasmeshinfo.numtriangles;
                R_Mesh_Draw(&aliasmeshinfo);
+               R_Mesh_Render();
        }
        else if (currentrenderentity->colormap >= 0 || !skinframe->merged || skinframe->glow || !r_quickmodels.integer)
        {
@@ -494,6 +496,7 @@ void R_DrawQ1Q2AliasModel (float fog)
 
                aliasvert = aliasvertbuf;
                aliasvertcolor = aliasvertcolorbuf;
+               R_Mesh_Render();
        }
 }
 
@@ -798,6 +801,7 @@ void R_DrawZymoticModelMesh(zymtype1header_t *m)
                aliasmeshinfo.index = renderlist;
                c_alias_polys += aliasmeshinfo.numtriangles;
                R_Mesh_Draw(&aliasmeshinfo);
+               R_Mesh_Render();
                renderlist += aliasmeshinfo.numtriangles * 3;
        }
 }
@@ -824,6 +828,7 @@ void R_DrawZymoticModelMeshFog(vec3_t org, zymtype1header_t *m, float fog)
                aliasmeshinfo.index = renderlist;
                c_alias_polys += aliasmeshinfo.numtriangles;
                R_Mesh_Draw(&aliasmeshinfo);
+               R_Mesh_Render();
                renderlist += aliasmeshinfo.numtriangles * 3;
        }
 }
index 226de362d8bcd9e07e3ee494e6431f2b20234a42..ad66314dfc837770525ae4a7e6c9711046df8ca7 100644 (file)
@@ -556,6 +556,7 @@ static void R_BlendView(void)
                m.vertex[8] = m.vertex[0] + vright[0] * r;
                m.vertex[9] = m.vertex[1] + vright[1] * r;
                m.vertex[10] = m.vertex[2] + vright[2] * r;
+               R_Mesh_Render();
        }
 }
 
index 9fe860b5bbe22a69981d80c88e0ae3d0a5586b12..dbe515c44b17e6a67542a0414e1950e6267470b7 100644 (file)
@@ -676,6 +676,7 @@ static void RSurfShader_Sky(msurface_t *firstsurf)
                                        outc[2] = cb;
                                        outc[3] = ca;
                                }
+                               R_Mesh_Render();
                        }
                }
        }
@@ -788,6 +789,7 @@ static void RSurfShader_Water_Pass_Base(msurface_t *surf)
                                                VectorScale(outc, f, outc);
                                        }
                                }
+                               R_Mesh_Render();
                        }
                }
        }
@@ -850,6 +852,7 @@ static void RSurfShader_Water_Pass_Base(msurface_t *surf)
                                        else
                                                VectorScale(outc, cl, outc);
                                }
+                               R_Mesh_Render();
                        }
                }
        }
@@ -896,6 +899,7 @@ static void RSurfShader_Water_Pass_Fog(msurface_t *surf)
                                        outst[1] = v->st[1];
                                }
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1021,6 +1025,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
                                                VectorScale(outc, cl, outc);
                                }
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1079,6 +1084,7 @@ static void RSurfShader_Wall_Pass_BaseFullbright(msurface_t *surf)
                                outst[0] = v->st[0];
                                outst[1] = v->st[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1120,6 +1126,7 @@ static void RSurfShader_Wall_Pass_Glow(msurface_t *surf)
                                outst[0] = v->st[0];
                                outst[1] = v->st[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1156,6 +1163,7 @@ static void RSurfShader_Wall_Pass_Fog(msurface_t *surf)
                                outst[0] = v->st[0];
                                outst[1] = v->st[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1201,6 +1209,7 @@ static void RSurfShader_OpaqueWall_Pass_TripleTexCombine(msurface_t *surf)
                                outab[0] = v->ab[0];
                                outab[1] = v->ab[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1240,6 +1249,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseMTex(msurface_t *surf)
                                outuv[0] = v->uv[0];
                                outuv[1] = v->uv[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1276,6 +1286,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(msurface_t *surf)
                                outst[0] = v->st[0];
                                outst[1] = v->st[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1312,6 +1323,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(msurface_t *surf)
                                outuv[0] = v->uv[0];
                                outuv[1] = v->uv[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1360,6 +1372,7 @@ static void RSurfShader_OpaqueWall_Pass_Light(msurface_t *surf)
                                if (cl != 1)
                                        for (i = 0, outc = m.color;i < m.numverts;i++, outc += 4)
                                                VectorScale(outc, cl, outc);
+                               R_Mesh_Render();
                        }
                }
        }
@@ -1394,6 +1407,7 @@ static void RSurfShader_OpaqueWall_Pass_Fog(msurface_t *surf)
                                VectorSubtract(outv, r_origin, diff);
                                outc[3] = exp(fogdensity/DotProduct(diff, diff));
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1428,6 +1442,7 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(msurface_t *surf)
                                outst[0] = v->ab[0];
                                outst[1] = v->ab[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1462,6 +1477,7 @@ static void RSurfShader_OpaqueWall_Pass_Glow(msurface_t *surf)
                                outst[0] = v->st[0];
                                outst[1] = v->st[1];
                        }
+                       R_Mesh_Render();
                }
        }
 }
@@ -1910,6 +1926,7 @@ void R_DrawPortals(void)
                                                VectorCopy(point[i].position, portalpointbuffer[i]);
                                }
                                R_Mesh_DrawPolygon(&m, portal->numpoints);
+                               R_Mesh_Render();
                        }
                }
        }
index 158734b0f9dab39e783b21de3a55a9fea8c3d0f4..a4466ce3f1e309db707c5fde15296785979a0b73 100644 (file)
@@ -205,6 +205,7 @@ void R_DrawCrosshairSprite(rtexture_t *texture, vec3_t origin, vec_t scale, floa
                m.vertex[12] = origin[0] + vright[0] * scale - vup[0] * scale;
                m.vertex[13] = origin[1] + vright[1] * scale - vup[1] * scale;
                m.vertex[14] = origin[2] + vright[2] * scale - vup[2] * scale;
+               R_Mesh_Render();
        }
 }
 
index 3f8daa4b8007d554510bc0367321687af6f4dc57..507f1f7445844a55f9a820785f795b419d422312 100644 (file)
@@ -238,6 +238,7 @@ void R_DrawExplosion(explosion_t *e)
                                c[3] = 1;
                        }
                }
+               R_Mesh_Render();
        }
 }
 
index da977bf092ce4146d4c984ca5dfd5eab9c8be9ee..e1207de8cd63fc23f6001d51b81b7f6a2f09fe4c 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -193,6 +193,7 @@ void R_DrawCoronas(void)
                                m.vertex[12] = rd->origin[0] + vright[0] * scale - vup[0] * scale;
                                m.vertex[13] = rd->origin[1] + vright[1] * scale - vup[1] * scale;
                                m.vertex[14] = rd->origin[2] + vright[2] * scale - vup[2] * scale;
+                               R_Mesh_Render();
                        }
                }
        }
diff --git a/r_sky.c b/r_sky.c
index 497d7f719b58dd5fd9b5c8127d0afd4a443d94fb..7e2113552672dd7ab15134dee5b00624f8a01e0e 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -182,6 +182,7 @@ static void R_SkyBox(void)
                R_SkyBoxPolyVec(1, 1, 1,  1, -1, -1);
                R_SkyBoxPolyVec(2, 0, 1,  1,  1, -1);
                R_SkyBoxPolyVec(3, 0, 0,  1,  1,  1);
+               R_Mesh_Render();
        }
        m.tex[0] = R_GetTexture(skyboxside[1]); // back
        if (R_Mesh_Draw_GetBuffer(&m, false))
@@ -195,6 +196,7 @@ static void R_SkyBox(void)
                R_SkyBoxPolyVec(1, 1, 1, -1,  1, -1);
                R_SkyBoxPolyVec(2, 0, 1, -1, -1, -1);
                R_SkyBoxPolyVec(3, 0, 0, -1, -1,  1);
+               R_Mesh_Render();
        }
        m.tex[0] = R_GetTexture(skyboxside[0]); // right
        if (R_Mesh_Draw_GetBuffer(&m, false))
@@ -208,6 +210,7 @@ static void R_SkyBox(void)
                R_SkyBoxPolyVec(1, 1, 1,  1,  1, -1);
                R_SkyBoxPolyVec(2, 0, 1, -1,  1, -1);
                R_SkyBoxPolyVec(3, 0, 0, -1,  1,  1);
+               R_Mesh_Render();
        }
        m.tex[0] = R_GetTexture(skyboxside[2]); // left
        if (R_Mesh_Draw_GetBuffer(&m, false))
@@ -221,6 +224,7 @@ static void R_SkyBox(void)
                R_SkyBoxPolyVec(1, 1, 1, -1, -1, -1);
                R_SkyBoxPolyVec(2, 0, 1,  1, -1, -1);
                R_SkyBoxPolyVec(3, 0, 0,  1, -1,  1);
+               R_Mesh_Render();
        }
        m.tex[0] = R_GetTexture(skyboxside[4]); // up
        if (R_Mesh_Draw_GetBuffer(&m, false))
@@ -234,6 +238,7 @@ static void R_SkyBox(void)
                R_SkyBoxPolyVec(1, 1, 1,  1,  1,  1);
                R_SkyBoxPolyVec(2, 0, 1, -1,  1,  1);
                R_SkyBoxPolyVec(3, 0, 0, -1, -1,  1);
+               R_Mesh_Render();
        }
        m.tex[0] = R_GetTexture(skyboxside[5]); // down
        if (R_Mesh_Draw_GetBuffer(&m, false))
@@ -247,6 +252,7 @@ static void R_SkyBox(void)
                R_SkyBoxPolyVec(1, 1, 1,  1, -1, -1);
                R_SkyBoxPolyVec(2, 0, 1, -1, -1, -1);
                R_SkyBoxPolyVec(3, 0, 0, -1,  1, -1);
+               R_Mesh_Render();
        }
 }
 
@@ -345,6 +351,7 @@ static void R_SkySphere(void)
        {
                memcpy(m.index, skysphereindices, m.numtriangles * sizeof(int[3]));
                skyspherearrays(m.vertex, m.texcoords[0], m.color, skysphere, speedscale, m.colorscale);
+               R_Mesh_Render();
        }
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
@@ -353,6 +360,7 @@ static void R_SkySphere(void)
        {
                memcpy(m.index, skysphereindices, m.numtriangles * sizeof(int[3]));
                skyspherearrays(m.vertex, m.texcoords[0], m.color, skysphere, speedscale2, m.colorscale);
+               R_Mesh_Render();
        }
 }