From 010f524039d1780063484288f9a832b473709a6b Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 31 Aug 2010 07:28:24 +0000 Subject: [PATCH] get rid of calculating vertexmesh animcache buffers if we do not need the vertexmesh... fixes performance of steel storm git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10431 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gl_rmain.c b/gl_rmain.c index 52e68fac..9ea8719f 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -7761,14 +7761,52 @@ void R_AnimCache_ClearCache(void) void R_AnimCache_UpdateEntityMeshBuffers(entity_render_t *ent, int numvertices) { int i; + + // identical memory layout, so no need to allocate... + // this also provides the vertexposition structure to everything, e.g. + // depth masked rendering currently uses it even if having separate + // arrays + // NOTE: get rid of this optimization if changing it to e.g. 4f + ent->animcache_vertexposition = (r_vertexposition_t *)ent->animcache_vertex3f; + + // TODO: + // get rid of following uses of VERTEXPOSITION, change to the array: + // R_DrawTextureSurfaceList_Sky if skyrendermasked + // R_DrawSurface_TransparentCallback if r_transparentdepthmasking.integer + // R_DrawTextureSurfaceList_DepthOnly + // R_Q1BSP_DrawShadowMap + + switch(vid.renderpath) + { + case RENDERPATH_GL20: + case RENDERPATH_CGGL: + // need the meshbuffers if !gl_mesh_separatearrays.integer + if (gl_mesh_separatearrays.integer) + return; + break; + case RENDERPATH_D3D9: + case RENDERPATH_D3D10: + case RENDERPATH_D3D11: + // always need the meshbuffers + break; + case RENDERPATH_GL13: + case RENDERPATH_GL11: + // never need the meshbuffers + return; + } + if (!ent->animcache_vertexmesh && ent->animcache_normal3f) ent->animcache_vertexmesh = (r_vertexmesh_t *)R_FrameData_Alloc(sizeof(r_vertexmesh_t)*numvertices); + /* if (!ent->animcache_vertexposition) ent->animcache_vertexposition = (r_vertexposition_t *)R_FrameData_Alloc(sizeof(r_vertexposition_t)*numvertices); + */ if (ent->animcache_vertexposition) { + /* for (i = 0;i < numvertices;i++) VectorCopy(ent->animcache_vertex3f + 3*i, ent->animcache_vertexposition[i].vertex3f); + */ // TODO: upload vertex buffer? } if (ent->animcache_vertexmesh) -- 2.39.2