Merge pull request #34 from lvonasek/feature_opengl_speedup

Opengl speedup
This commit is contained in:
Simon 2022-03-23 20:21:49 +00:00 committed by GitHub
commit 550c25bf71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View file

@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// tr_vbo.c // tr_vbo.c
#include "tr_local.h" #include "tr_local.h"
//#define GL_BUFFER_RECYCLING
void R_VaoPackTangent(int16_t *out, vec4_t v) void R_VaoPackTangent(int16_t *out, vec4_t v)
{ {
@ -391,18 +393,17 @@ void R_BindNullVao(void)
if(glState.currentVao) if(glState.currentVao)
{ {
#ifdef GL_BUFFER_RECYCLING
if (glRefConfig.vertexArrayObject) if (glRefConfig.vertexArrayObject)
{ {
qglBindVertexArray(0); qglBindVertexArray(0);
// why you no save GL_ELEMENT_ARRAY_BUFFER binding, Intel?
if (1) qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
else else
{ {
qglBindBuffer(GL_ARRAY_BUFFER, 0); qglBindBuffer(GL_ARRAY_BUFFER, 0);
qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
#endif
glState.currentVao = NULL; glState.currentVao = NULL;
} }
@ -605,9 +606,6 @@ void RB_UpdateTessVao(unsigned int attribBits)
R_BindVao(tess.vao); R_BindVao(tess.vao);
// orphan old vertex buffer so we don't stall on it
qglBufferData(GL_ARRAY_BUFFER, tess.vao->vertexesSize, NULL, GL_DYNAMIC_DRAW);
// if nothing to set, set everything // if nothing to set, set everything
if(!(attribBits & ATTR_BITS)) if(!(attribBits & ATTR_BITS))
attribBits = ATTR_BITS; attribBits = ATTR_BITS;
@ -653,10 +651,8 @@ void RB_UpdateTessVao(unsigned int attribBits)
} }
} }
// FIXME: This sets a limit of 65536 verts/262144 indexes per static surface #define VAOCACHE_QUEUE_MAX_SURFACES MAX_POLYS
// This is higher than the old vq3 limits but is worth noting #define VAOCACHE_QUEUE_MAX_VERTEXES MAX_POLYVERTS
#define VAOCACHE_QUEUE_MAX_SURFACES (1 << 10)
#define VAOCACHE_QUEUE_MAX_VERTEXES (1 << 16)
#define VAOCACHE_QUEUE_MAX_INDEXES (VAOCACHE_QUEUE_MAX_VERTEXES * 4) #define VAOCACHE_QUEUE_MAX_INDEXES (VAOCACHE_QUEUE_MAX_VERTEXES * 4)
typedef struct queuedSurface_s typedef struct queuedSurface_s
@ -933,15 +929,19 @@ void VaoCache_CheckAdd(qboolean *endSurface, qboolean *recycleVertexBuffer, qboo
void VaoCache_RecycleVertexBuffer(void) void VaoCache_RecycleVertexBuffer(void)
{ {
#ifdef GL_BUFFER_RECYCLING
qglBindBuffer(GL_ARRAY_BUFFER, vc.vao->vertexesVBO); qglBindBuffer(GL_ARRAY_BUFFER, vc.vao->vertexesVBO);
qglBufferData(GL_ARRAY_BUFFER, vc.vao->vertexesSize, NULL, GL_DYNAMIC_DRAW); qglBufferData(GL_ARRAY_BUFFER, vc.vao->vertexesSize, NULL, GL_DYNAMIC_DRAW);
#endif
vc.vertexOffset = 0; vc.vertexOffset = 0;
} }
void VaoCache_RecycleIndexBuffer(void) void VaoCache_RecycleIndexBuffer(void)
{ {
#ifdef GL_BUFFER_RECYCLING
qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesIBO); qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesIBO);
qglBufferData(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesSize, NULL, GL_DYNAMIC_DRAW); qglBufferData(GL_ELEMENT_ARRAY_BUFFER, vc.vao->indexesSize, NULL, GL_DYNAMIC_DRAW);
#endif
vc.indexOffset = 0; vc.indexOffset = 0;
vc.numSurfaces = 0; vc.numSurfaces = 0;
vc.numBatches = 0; vc.numBatches = 0;

View file

@ -20,7 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define ENABLE_GL_DEBUG 1 #define ENABLE_GL_DEBUG 0
#define ENABLE_GL_DEBUG_VERBOSE 0 #define ENABLE_GL_DEBUG_VERBOSE 0
#if ENABLE_GL_DEBUG #if ENABLE_GL_DEBUG
#include <GLES3/gl32.h> #include <GLES3/gl32.h>