mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
gles2: Major renderer optimization. Work in progress!
This moves all the rendering to a command list that is flushed to the GL as necessary, making most common activities upload a single vertex buffer per frame and dramatically reducing state changes. In pathological cases, like Emscripten running on iOS's Safari, performance can go from a dozen draw calls killing your performance to 1000 draw calls running smoothly. This is work in progress, and not ready to ship. Among other things, it has a hardcoded array that isn't checked for overflow. But the basic idea is sound!
This commit is contained in:
parent
7ed7cb5e65
commit
0d3275297d
@ -75,6 +75,7 @@ SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
|
||||
SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
|
||||
SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glDeleteBuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum))
|
||||
SDL_PROC(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -69,13 +69,13 @@ static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
|
||||
static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor *= u_modulation; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
@ -83,7 +83,7 @@ static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
|
||||
static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
@ -92,7 +92,7 @@ static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.r = abgr.b; \
|
||||
gl_FragColor.b = abgr.r; \
|
||||
gl_FragColor *= u_modulation; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
@ -100,7 +100,7 @@ static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
@ -110,7 +110,7 @@ static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
gl_FragColor.r = abgr.b; \
|
||||
gl_FragColor.b = abgr.r; \
|
||||
gl_FragColor.a = 1.0; \
|
||||
gl_FragColor *= u_modulation; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
@ -118,7 +118,7 @@ static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
@ -126,7 +126,7 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.a = 1.0; \
|
||||
gl_FragColor *= u_modulation; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
@ -163,7 +163,7 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
"uniform sampler2D u_texture;\n" \
|
||||
"uniform sampler2D u_texture_u;\n" \
|
||||
"uniform sampler2D u_texture_v;\n" \
|
||||
"uniform vec4 u_modulation;\n" \
|
||||
"uniform vec4 u_color;\n" \
|
||||
"varying vec2 v_texCoord;\n" \
|
||||
"\n" \
|
||||
|
||||
@ -185,7 +185,7 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1);\n" \
|
||||
" gl_FragColor *= u_modulation;\n" \
|
||||
" gl_FragColor *= u_color;\n" \
|
||||
"}" \
|
||||
|
||||
#define NV12_SHADER_BODY \
|
||||
@ -205,7 +205,7 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1);\n" \
|
||||
" gl_FragColor *= u_modulation;\n" \
|
||||
" gl_FragColor *= u_color;\n" \
|
||||
"}" \
|
||||
|
||||
#define NV21_SHADER_BODY \
|
||||
@ -225,7 +225,7 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1);\n" \
|
||||
" gl_FragColor *= u_modulation;\n" \
|
||||
" gl_FragColor *= u_color;\n" \
|
||||
"}" \
|
||||
|
||||
/* YUV to ABGR conversion */
|
||||
@ -284,13 +284,13 @@ static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \
|
||||
#extension GL_OES_EGL_image_external : require\n\
|
||||
precision mediump float; \
|
||||
uniform samplerExternalOES u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor *= u_modulation; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user