render: Added SDL_RenderFlush(). SDL-ryan-batching-renderer
authorRyan C. Gordon <icculus@icculus.org>
Thu, 04 Oct 2018 16:34:44 -0400
branchSDL-ryan-batching-renderer
changeset 12290a82837d659d6
parent 12289 4425d03dffd6
child 12293 d027a83b1386
render: Added SDL_RenderFlush().
include/SDL_render.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/render/SDL_render.c
     1.1 --- a/include/SDL_render.h	Thu Oct 04 16:11:43 2018 -0400
     1.2 +++ b/include/SDL_render.h	Thu Oct 04 16:34:44 2018 -0400
     1.3 @@ -876,6 +876,31 @@
     1.4   */
     1.5  extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
     1.6  
     1.7 +/**
     1.8 + *  \brief Force the rendering context to flush any pending commands to the
     1.9 + *         underlying rendering API.
    1.10 + *
    1.11 + *  You do not need to (and in fact, shouldn't) call this function unless
    1.12 + *  you are planning to call into OpenGL/Direct3D/Metal/whatever directly
    1.13 + *  in addition to using an SDL_Renderer.
    1.14 + *
    1.15 + *  This is for a very-specific case: if you are using SDL's render API,
    1.16 + *  you asked for a specific renderer backend (OpenGL, Direct3D, etc),
    1.17 + *  you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make
    1.18 + *  OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of
    1.19 + *  this applies, you should call SDL_RenderFlush() between calls to SDL's
    1.20 + *  render API and the low-level API you're using in cooperation.
    1.21 + *
    1.22 + *  In all other cases, you can ignore this function. This is only here to
    1.23 + *  get maximum performance out of a specific situation. In all other cases,
    1.24 + *  SDL will do the right thing, perhaps at a performance loss.
    1.25 + *
    1.26 + *  This function is first available in SDL 2.0.10, and is not needed in
    1.27 + *  2.0.9 and earlier, as earlier versions did not queue rendering commands
    1.28 + *  at all, instead flushing them to the OS immediately.
    1.29 + */
    1.30 +extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
    1.31 +
    1.32  
    1.33  /**
    1.34   *  \brief Bind the texture to the current OpenGL/ES/ES2 context for use with
     2.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Thu Oct 04 16:11:43 2018 -0400
     2.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Thu Oct 04 16:34:44 2018 -0400
     2.3 @@ -696,3 +696,4 @@
     2.4  #define SDL_SensorUpdate SDL_SensorUpdate_REAL
     2.5  #define SDL_IsTablet SDL_IsTablet_REAL
     2.6  #define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
     2.7 +#define SDL_RenderFlush SDL_RenderFlush_REAL
     3.1 --- a/src/dynapi/SDL_dynapi_procs.h	Thu Oct 04 16:11:43 2018 -0400
     3.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Thu Oct 04 16:34:44 2018 -0400
     3.3 @@ -738,3 +738,4 @@
     3.4  SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),)
     3.5  SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return)
     3.6  SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return)
     3.7 +SDL_DYNAPI_PROC(int,SDL_RenderFlush,(SDL_Renderer *a),(a),return)
     4.1 --- a/src/render/SDL_render.c	Thu Oct 04 16:11:43 2018 -0400
     4.2 +++ b/src/render/SDL_render.c	Thu Oct 04 16:34:44 2018 -0400
     4.3 @@ -254,6 +254,12 @@
     4.4      return renderer->batching ? 0 : FlushRenderCommands(renderer);
     4.5  }
     4.6  
     4.7 +int
     4.8 +SDL_RenderFlush(SDL_Renderer * renderer)
     4.9 +{
    4.10 +    return FlushRenderCommands(renderer);
    4.11 +}
    4.12 +
    4.13  static SDL_AllocVertGap *
    4.14  AllocateVertexGap(SDL_Renderer *renderer)
    4.15  {