]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
got rid of Mod_CheckLoaded, changed how model system restart works to make this work...
[xonotic/darkplaces.git] / gl_rmain.c
index 6a1693e32ba92ffa46fd4b6facee09c0dd95e8ea..b40dea36bce0e7fe6c6848872ed633e43d538ed0 100644 (file)
@@ -30,7 +30,7 @@ mplane_t frustum[5];
 
 matrix4x4_t r_identitymatrix;
 
-int c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights, c_meshs, c_meshelements, c_rt_lights, c_rt_clears, c_rt_scissored, c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris, c_rtcached_shadowmeshes, c_rtcached_shadowtris, c_bloom, c_bloomcopies, c_bloomcopypixels, c_bloomdraws, c_bloomdrawpixels;
+renderstats_t renderstats;
 
 // true during envmap command capture
 qboolean envmap;
@@ -582,7 +582,6 @@ static void R_MarkEntities (void)
                for (i = 0;i < r_refdef.numentities;i++)
                {
                        ent = r_refdef.entities[i];
-                       Mod_CheckLoaded(ent->model);
                        // some of the renderer still relies on origin...
                        Matrix4x4_OriginFromMatrix(&ent->matrix, ent->origin);
                        // some of the renderer still relies on scale...
@@ -600,7 +599,6 @@ static void R_MarkEntities (void)
                for (i = 0;i < r_refdef.numentities;i++)
                {
                        ent = r_refdef.entities[i];
-                       Mod_CheckLoaded(ent->model);
                        // some of the renderer still relies on origin...
                        Matrix4x4_OriginFromMatrix(&ent->matrix, ent->origin);
                        // some of the renderer still relies on scale...
@@ -650,6 +648,7 @@ void R_DrawModels(void)
                ent = r_refdef.entities[i];
                if (ent->visframe == r_framecount)
                {
+                       renderstats.entities++;
                        if (ent->model && ent->model->Draw != NULL)
                                ent->model->Draw(ent);
                        else
@@ -714,7 +713,7 @@ static void R_BlendView(void)
        {
                int screenwidth, screenheight, bloomwidth, bloomheight, x, dobloomblend, range;
                float xoffset, yoffset, r;
-               c_bloom++;
+               renderstats.bloom++;
                // set the (poorly named) screenwidth and screenheight variables to
                // a power of 2 at least as large as the screen, these will define the
                // size of the texture to allocate
@@ -757,8 +756,7 @@ static void R_BlendView(void)
                // copy view into the full resolution screen image texture
                GL_ActiveTexture(0);
                qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
-               c_bloomcopies++;
-               c_bloomcopypixels += r_view_width * r_view_height;
+               renderstats.bloom_copypixels += r_view_width * r_view_height;
                // now scale it down to the bloom size and raise to a power of itself
                // to darken it (this leaves the really bright stuff bright, and
                // everything else becomes very dark)
@@ -767,15 +765,13 @@ static void R_BlendView(void)
                GL_BlendFunc(GL_ONE, GL_ZERO);
                GL_Color(1, 1, 1, 1);
                R_Mesh_Draw(0, 4, 2, polygonelements);
-               c_bloomdraws++;
-               c_bloomdrawpixels += bloomwidth * bloomheight;
+               renderstats.bloom_drawpixels += bloomwidth * bloomheight;
                // render multiple times with a multiply blendfunc to raise to a power
                GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
                for (x = 1;x < r_bloom_power.integer;x++)
                {
                        R_Mesh_Draw(0, 4, 2, polygonelements);
-                       c_bloomdraws++;
-                       c_bloomdrawpixels += bloomwidth * bloomheight;
+                       renderstats.bloom_drawpixels += bloomwidth * bloomheight;
                }
                // we now have a darkened bloom image in the framebuffer, copy it into
                // the bloom image texture for more processing
@@ -786,8 +782,7 @@ static void R_BlendView(void)
                R_Mesh_State(&m);
                GL_ActiveTexture(0);
                qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
-               c_bloomcopies++;
-               c_bloomcopypixels += bloomwidth * bloomheight;
+               renderstats.bloom_copypixels += bloomwidth * bloomheight;
                // blend on at multiple vertical offsets to achieve a vertical blur
                // TODO: do offset blends using GLSL
                range = r_bloom_blur.integer * bloomwidth / 320;
@@ -813,15 +808,13 @@ static void R_BlendView(void)
                                continue;
                        GL_Color(r, r, r, 1);
                        R_Mesh_Draw(0, 4, 2, polygonelements);
-                       c_bloomdraws++;
-                       c_bloomdrawpixels += bloomwidth * bloomheight;
+                       renderstats.bloom_drawpixels += bloomwidth * bloomheight;
                        GL_BlendFunc(GL_ONE, GL_ONE);
                }
                // copy the vertically blurred bloom view to a texture
                GL_ActiveTexture(0);
                qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
-               c_bloomcopies++;
-               c_bloomcopypixels += bloomwidth * bloomheight;
+               renderstats.bloom_copypixels += bloomwidth * bloomheight;
                // blend the vertically blurred image at multiple offsets horizontally
                // to finish the blur effect
                // TODO: do offset blends using GLSL
@@ -848,15 +841,13 @@ static void R_BlendView(void)
                                continue;
                        GL_Color(r, r, r, 1);
                        R_Mesh_Draw(0, 4, 2, polygonelements);
-                       c_bloomdraws++;
-                       c_bloomdrawpixels += bloomwidth * bloomheight;
+                       renderstats.bloom_drawpixels += bloomwidth * bloomheight;
                        GL_BlendFunc(GL_ONE, GL_ONE);
                }
                // copy the blurred bloom view to a texture
                GL_ActiveTexture(0);
                qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
-               c_bloomcopies++;
-               c_bloomcopypixels += bloomwidth * bloomheight;
+               renderstats.bloom_copypixels += bloomwidth * bloomheight;
                // go back to full view area
                qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
                // put the original screen image back in place and blend the bloom
@@ -883,8 +874,7 @@ static void R_BlendView(void)
                GL_BlendFunc(GL_ONE, GL_ZERO);
                GL_Color(1,1,1,1);
                R_Mesh_Draw(0, 4, 2, polygonelements);
-               c_bloomdraws++;
-               c_bloomdrawpixels += r_view_width * r_view_height;
+               renderstats.bloom_drawpixels += r_view_width * r_view_height;
                // now blend on the bloom texture if multipass
                if (dobloomblend)
                {
@@ -896,8 +886,7 @@ static void R_BlendView(void)
                        GL_BlendFunc(GL_ONE, GL_ONE);
                        GL_Color(1,1,1,1);
                        R_Mesh_Draw(0, 4, 2, polygonelements);
-                       c_bloomdraws++;
-                       c_bloomdrawpixels += r_view_width * r_view_height;
+                       renderstats.bloom_drawpixels += r_view_width * r_view_height;
                }
        }
        if (r_refdef.viewblend[3] >= 0.01f)
@@ -1156,7 +1145,7 @@ float nomodelcolor4f[6*4] =
 
 void R_DrawNoModelCallback(const void *calldata1, int calldata2)
 {
-       const entity_render_t *ent = calldata1;
+       const entity_render_t *ent = (entity_render_t *)calldata1;
        int i;
        float f1, f2, *c, diff[3];
        float color4f[6*4];
@@ -1383,8 +1372,6 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
                int s = ent->skinnum;
                if ((unsigned int)s >= (unsigned int)model->numskins)
                        s = 0;
-               if (s >= 1)
-                       c_models++;
                if (model->skinscenes)
                {
                        if (model->skinscenes[s].framecount > 1)
@@ -1753,7 +1740,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text
        rmeshstate_t m;
        if (texture->currentmaterialflags & MATERIALFLAG_NODRAW)
                return;
-       c_faces += texturenumsurfaces;
+       renderstats.entities_surfaces += texturenumsurfaces;
        // FIXME: identify models using a better check than ent->model->brush.shadowmesh
        lightmode = ((ent->effects & EF_FULLBRIGHT) || ent->model->brush.shadowmesh) ? 0 : 2;
        GL_DepthTest(!(texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
@@ -2011,7 +1998,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text
 
 static void RSurfShader_Transparent_Callback(const void *calldata1, int calldata2)
 {
-       const entity_render_t *ent = calldata1;
+       const entity_render_t *ent = (entity_render_t *)calldata1;
        const msurface_t *surface = ent->model->data_surfaces + calldata2;
        vec3_t modelorg;
        texture_t *texture;
@@ -2055,6 +2042,7 @@ extern void R_BuildLightMap(const entity_render_t *ent, msurface_t *surface);
 void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
 {
        int i, j, f, flagsmask;
+       int counttriangles = 0;
        msurface_t *surface, **surfacechain;
        texture_t *t, *texture;
        model_t *model = ent->model;
@@ -2112,6 +2100,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                        R_BuildLightMap(ent, surface);
                                // add face to draw list
                                surfacelist[numsurfacelist++] = surface;
+                               counttriangles += surface->num_triangles;
                                if (numsurfacelist >= maxsurfacelist)
                                {
                                        R_QueueTextureSurfaceList(ent, texture, numsurfacelist, surfacelist, modelorg);
@@ -2142,6 +2131,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                        R_BuildLightMap(ent, surface);
                                // add face to draw list
                                surfacelist[numsurfacelist++] = surface;
+                               counttriangles += surface->num_triangles;
                                if (numsurfacelist >= maxsurfacelist)
                                {
                                        R_QueueTextureSurfaceList(ent, texture, numsurfacelist, surfacelist, modelorg);
@@ -2152,5 +2142,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
        }
        if (numsurfacelist)
                R_QueueTextureSurfaceList(ent, texture, numsurfacelist, surfacelist, modelorg);
+       if (!r_showtrispass)
+               renderstats.entities_triangles += counttriangles;
 }