diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2025-05-11 18:36:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-11 18:36:20 +0200 |
| commit | 04124988e8b4a9cdfc5995388ebfaad0005b4b31 (patch) | |
| tree | b603b13ebf4d21d5c72ad774db630523e1eb65ed /src/render/Shader.hpp | |
| parent | 390a357859e702b6416194291e0eb168270d50ac (diff) | |
opengl: optimize shaders and reduce unneeded drawcalls (#10364)
* opengl: remove unnecessery glflush calls
glflushing forces the driver to break batching and issue commands
prematurely and prevents optimisations like command reordering and
merging.
many glFunctions already internally glflushes and eglsync creation still
has a glflush at end render. so lets reduce the overhead of these calls.
* opengl: reduce glUseProgram calls
apitrace shows cases where the same program gets called multiple times,
add a helper function that keeps track of current program and only call
it once on same program. reduces slight overhead.
* opengl: use more efficient vertex array object
use a more modern vertex array object approach with the shaders, makes
it a onetime setup on shader creation instead of once per drawcall, also
should make the driver not have to revalidate the vertex format on each
call.
Diffstat (limited to 'src/render/Shader.hpp')
| -rw-r--r-- | src/render/Shader.hpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/render/Shader.hpp b/src/render/Shader.hpp index d23d2d5a..7bed9041 100644 --- a/src/render/Shader.hpp +++ b/src/render/Shader.hpp @@ -32,6 +32,10 @@ struct SShader { GLint discardAlpha = -1; GLfloat discardAlphaValue = -1; + GLuint shaderVao = 0; + GLuint shaderVboPos = 0; + GLuint shaderVboUv = 0; + GLint topLeft = -1; GLint bottomRight = -1; GLint fullSize = -1; @@ -76,5 +80,6 @@ struct SShader { GLint brightness = -1; GLint noise = -1; + void createVao(); void destroy(); }; |
