GLES2: Only use VBOs for Emscripten (for now).
authorRyan C. Gordon <icculus@icculus.org>
Fri, 26 Dec 2014 22:30:19 -0500
changeset 92991d3bee66d518
parent 9298 98279bdf2230
child 9300 0293f45e4814
GLES2: Only use VBOs for Emscripten (for now).

This is causing a regression on actual iOS hardware, which we should revisit
after 2.0.4 ships.
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Fri Dec 26 20:11:28 2014 +0100
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Fri Dec 26 22:30:19 2014 -0500
     1.3 @@ -28,7 +28,20 @@
     1.4  #include "../../video/SDL_blit.h"
     1.5  #include "SDL_shaders_gles2.h"
     1.6  
     1.7 -/* To prevent unnecessary window recreation, 
     1.8 +/* !!! FIXME: Emscripten makes these into WebGL calls, and WebGL doesn't offer
     1.9 +   !!! FIXME:  client-side arrays (without an Emscripten compatibility hack,
    1.10 +   !!! FIXME:  at least), but the current VBO code here is dramatically
    1.11 +   !!! FIXME:  slower on actual iOS devices, even though the iOS Simulator
    1.12 +   !!! FIXME:  is okay. Some time after 2.0.4 ships, we should revisit this,
    1.13 +   !!! FIXME:  fix the performance bottleneck, and make everything use VBOs.
    1.14 +*/
    1.15 +#ifdef __EMSCRIPTEN__
    1.16 +#define SDL_GLES2_USE_VBOS 1
    1.17 +#else
    1.18 +#define SDL_GLES2_USE_VBOS 0
    1.19 +#endif
    1.20 +
    1.21 +/* To prevent unnecessary window recreation,
    1.22   * these should match the defaults selected in SDL_GL_ResetAttributes 
    1.23   */
    1.24  #define RENDERER_CONTEXT_MAJOR 2
    1.25 @@ -181,8 +194,10 @@
    1.26      GLES2_ProgramCacheEntry *current_program;
    1.27      Uint8 clear_r, clear_g, clear_b, clear_a;
    1.28  
    1.29 +#if SDL_GLES2_USE_VBOS
    1.30      GLuint vertex_buffers[4];
    1.31      GLsizeiptr vertex_buffer_size[4];
    1.32 +#endif
    1.33  } GLES2_DriverContext;
    1.34  
    1.35  #define GLES2_MAX_CACHED_PROGRAMS 8
    1.36 @@ -1393,10 +1408,10 @@
    1.37                           const void *vertexData, size_t dataSizeInBytes)
    1.38  {
    1.39      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
    1.40 -#if 0
    1.41 +
    1.42 +#if !SDL_GLES2_USE_VBOS
    1.43      data->glVertexAttribPointer(attr, attr == GLES2_ATTRIBUTE_ANGLE ? 1 : 2, GL_FLOAT, GL_FALSE, 0, vertexData);
    1.44  #else
    1.45 -
    1.46      if (!data->vertex_buffers[attr])
    1.47          data->glGenBuffers(1, &data->vertex_buffers[attr]);
    1.48  
    1.49 @@ -1411,6 +1426,7 @@
    1.50  
    1.51      data->glVertexAttribPointer(attr, attr == GLES2_ATTRIBUTE_ANGLE ? 1 : 2, GL_FLOAT, GL_FALSE, 0, 0);
    1.52  #endif
    1.53 +
    1.54      return 0;
    1.55  }
    1.56