From ab2e285e252663c0b7ab9128eb5ef753419f276e Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 5 Aug 2018 21:29:44 +0000 Subject: [PATCH] Fix UI corruption caused by poor handling of missing VBO with firstvertex > 0. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12450 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gl_rmain.c b/gl_rmain.c index fafb9d73..b9cde18c 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -7458,6 +7458,7 @@ float RSurf_FogVertex(const float *v) void RSurf_UploadBuffersForBatch(void) { // upload buffer data for generated vertex data (dynamicvertex case) or index data (copytriangles case) and models that lack it to begin with (e.g. DrawQ_FlushUI) + // note that if rsurface.batchvertex3f_vertexbuffer is NULL, dynamicvertex is forced as we don't account for the proper base vertex here. if (rsurface.batchvertex3f && !rsurface.batchvertex3f_vertexbuffer) rsurface.batchvertex3f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f, R_BUFFERDATA_VERTEX, &rsurface.batchvertex3f_bufferoffset); if (rsurface.batchsvector3f && !rsurface.batchsvector3f_vertexbuffer) @@ -7570,6 +7571,14 @@ void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const // check if any dynamic vertex processing must occur dynamicvertex = false; + // we must use vertexbuffers for rendering, we can upload vertex buffers + // easily enough but if the basevertex is non-zero it becomes more + // difficult, so force dynamicvertex path in that case - it's suboptimal + // but the most optimal case is to have the geometry sources provide their + // own anyway. + if (!rsurface.modelvertex3f_vertexbuffer && firstvertex != 0) + dynamicvertex = true; + // a cvar to force the dynamic vertex path to be taken, for debugging if (r_batch_debugdynamicvertexpath.integer) { -- 2.39.2