Commit graph

627 commits

Author SHA1 Message Date
Ryan C. Gordon
e33a87b4e6 render: Make the GL backends cache and defer more state changes.
--HG--
branch : SDL-ryan-batching-renderer
extra : histedit_source : 9989445300dd74771e6143b70ef194e88d123c18
2018-10-01 22:53:45 -04:00
Ryan C. Gordon
c60a01a082 render: D3D9 doesn't need to check for stream offset support anymore.
We don't use offsets at all now. Too slow.

--HG--
branch : SDL-ryan-batching-renderer
extra : histedit_source : bf5eafc07800e64529ffc423abf3e605aa965264
2018-10-01 13:41:15 -04:00
Ryan C. Gordon
7aab4dc8b9 render: Set the D3D9 stream source once and choose offsets during draw calls.
This is _much_ faster than setting the offsets with SetStreamSource!

--HG--
branch : SDL-ryan-batching-renderer
2018-10-01 11:32:08 -04:00
Ryan C. Gordon
d6753c690b render: Patched to compile.
--HG--
branch : SDL-ryan-batching-renderer
2018-10-01 03:02:54 -04:00
Ryan C. Gordon
8a2013f1c2 render: first shot at moving Direct3D 9 backend to new interface. Untested!
--HG--
branch : SDL-ryan-batching-renderer
2018-10-01 01:23:02 -04:00
Ryan C. Gordon
8e76fc1c37 render: patched to compile on C89 compilers, other untested code fixes.
--HG--
branch : SDL-ryan-batching-renderer
2018-09-29 04:00:38 +00:00
Ryan C. Gordon
454906e0b9 opengles1: set some non-zero drawstate defaults.
--HG--
branch : SDL-ryan-batching-renderer
2018-09-28 19:48:14 -04:00
Ryan C. Gordon
3fb340541a render: moved opengles2 over to new interface.
--HG--
branch : SDL-ryan-batching-renderer
2018-09-28 19:47:44 -04:00
Ryan C. Gordon
1da21e6740 render: Do state cache improvements for GLES1, too.
--HG--
branch : SDL-ryan-batching-renderer
2018-09-25 21:35:09 -04:00
Ryan C. Gordon
e523763256 render: OpenGL renderer now caches some state, to improve non-batching mode.
(other minor bug fixes in here, too)

--HG--
branch : SDL-ryan-batching-renderer
extra : amend_source : 1232922bfab60e6b4f23f1c2a35275716ed273bb
2018-09-25 19:20:31 -04:00
Ryan C. Gordon
6292445c7a render: Move non-batching flushes to different place.
This lets us batch up a few commands that are all related to the same API
call.

--HG--
branch : SDL-ryan-batching-renderer
2018-09-25 17:04:47 -04:00
Ryan C. Gordon
d96daf4a28 render: opengles renderer actually works now. :)
--HG--
branch : SDL-ryan-batching-renderer
2018-09-25 16:17:10 -04:00
Ryan C. Gordon
0675f2fa39 render: First shot at converting opengles renderer to new interfaces.
--HG--
branch : SDL-ryan-batching-renderer
extra : source : db6a2cf729c557a192ec767944bae3168dde3960
2018-09-25 10:41:25 -04:00
Ryan C. Gordon
dbf1408ad8 render: get rid of the predeclared functions in the GL and Metal renderers.
(others to come as I continue to update render backends!)

--HG--
branch : SDL-ryan-batching-renderer
extra : source : 17cc45c0b2e4274617a5ed8ac06f819d3eb40717
2018-09-24 12:30:47 -04:00
Ryan C. Gordon
7b78f799ae render: Make opengl backend take advantage of new high-level features.
--HG--
branch : SDL-ryan-batching-renderer
extra : source : f4665fc62a607285c0c2352dadeb3b290c29d097
2018-09-24 02:08:34 -04:00
Ryan C. Gordon
b8773215d9 render: Add command queue debug logging.
--HG--
branch : SDL-ryan-batching-renderer
extra : source : 7b514b380529e2e8d77cd63eda3fb81cc96d42a9
2018-09-24 02:07:35 -04:00
Ryan C. Gordon
6fdeb95d0c render: Update Metal and GL backends to use new high-level features, etc.
Now nothing is uploaded as dynamic data with Metal's setVertexBytes, etc; it's
all in the one big vertex buffer, now.

--HG--
branch : SDL-ryan-batching-renderer
extra : source : 67011faccbdbdff56162a9eb25a2bc964c064a03
2018-09-23 23:22:56 -04:00
Ryan C. Gordon
b288df490b render: A bunch of high-level improvements.
- high-level filters out duplicate render commands from the queue so
  backends don't have to.
- Setting draw color is now a render command, so backends can put color
  information into the vertex buffer to upload with everything else instead
  of setting it with slower dynamic data later.
- backends can request that they always batch, even for legacy programs,
  since the lowlevel API can deal with it (Metal, and eventually Vulkan
  and such...)
- high-level makes sure the queue has at least one setdrawcolor and
  setviewport command before any draw calls, so the backends don't ever have
  to manage cases where this hasn't been explicitly set yet.
- backends allocating vertex buffer space can specify alignment, and the
  high-level will keep track of gaps in the buffer between the last used
  positions and the aligned data that can be used for later allocations
  (Metal and such need to specify some constant data on 256 byte boundaries,
  but we don't want to waste all that space we had to skip to meet alignment
  requirements).

--HG--
branch : SDL-ryan-batching-renderer
extra : source : a3d62fbb80e46d9d544fa52944c3bac5375b5489
2018-09-23 23:20:40 -04:00
Ryan C. Gordon
c5dd072e01 render: First shot at moving metal backend over to new batching system.
--HG--
branch : SDL-ryan-batching-renderer
extra : source : 5e5ee5e583af6e120a84df5b2b48118bbadd5bb4
2018-09-20 16:40:04 -04:00
Ryan C. Gordon
2316f6a784 render: first shot at reworking opengl backend for new batching system.
--HG--
branch : SDL-ryan-batching-renderer
extra : source : 5208dec7e274c9036cdb7ea205682f82f3ac2f7c
2018-09-20 16:36:54 -04:00
Ryan C. Gordon
e7e52b63c0 render: Move to a batching system for rendering (work in progress).
--HG--
branch : SDL-ryan-batching-renderer
extra : source : 6160933718a85a6c45cf63723b404c49579b44f1
2018-09-20 15:46:02 -04:00
Ryan C. Gordon
8353a58143 gles2: Make render command queue dynamic.
It now uses a growable linked list that keeps a pool of allocated items for
reuse, and reallocs the vertex array as necessary. Testsprite2 can scale to
20,000 (or more!) draws now without drama.

--HG--
branch : SDL-ryan-batching-renderer
extra : source : a4d56fdc03aa55ae4e04dc1bf7091b5dddc95fae
2018-09-09 15:09:38 -04:00
Ryan C. Gordon
cc9ee08b65 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!

--HG--
branch : SDL-ryan-batching-renderer
extra : source : eae4631409c03d3b7ab2e87526193d86ce996ba8
2018-09-08 18:26:11 -04:00
Ryan C. Gordon
411f83f9a0 metal: Make sure layer drawableSize is adjusted on resize.
Fixes Bugzilla #4250.
2018-09-06 00:56:13 -04:00
Ryan C. Gordon
daaa744f78 metal: SDL_UpdateYUVTexture shouldn't swap planes based on format. 2018-09-01 20:47:12 -04:00
Sam Lantinga
b0c85b0612 Fixed compiler warning and use higher precision in angle calculation 2018-08-29 20:23:42 -07:00
Sam Lantinga
1f4205c2fd Fixed Windows build 2018-08-28 16:19:31 -07:00
Andreas Müller
d5e745d62e GLES2: Get sin/cos out of vertex shader
The only place angle is activated and causes effect is RenderCopyEx. All other
methods which use vertex shader, leave angle disabled and cause useless sin/cos
calculation in shader.

To get around shader's interface is changed to a vector that contains results
of sin and cos. To behave properly when disabled, cos value is set with offset
-1.0 making 0.0 default when deactivated.

As nice side effect it simplifies GLES2_UpdateVertexBuffer: All attributes are
vectors now.

Additional background:

* On RaspberryPi it gives a performace win for operations. Tested with
  [1] numbers go down for 5-10% (not easy to estimate due to huge variation).
* SDL_RenderCopyEx was tested with [2]
* It works around left rotated display caused by low accuracy sin implemetation
  in RaspberryPi/VC4 [3]

[1] https://github.com/schnitzeltony/sdl2box
[2] https://github.com/schnitzeltony/sdl2rendercopyex
[3] https://github.com/anholt/mesa/issues/110

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
2018-08-28 12:57:51 -07:00
Ryan C. Gordon
c84533767a gles2: Whoops, overzealous copy/paste on my part. :) 2018-06-25 01:57:28 -04:00
Ryan C. Gordon
94500043c1 Fixed some possible malloc(0) calls reported by static analysis.
--HG--
extra : rebase_source : 8c2181ff55533bc83aab66ac7d7d1bad87cd0e6f
2018-06-24 12:16:58 -04:00
Sam Lantinga
a2da3d641d Fixed race condition where Android touch events could get scaled by a render target's viewport 2018-06-18 13:13:56 -07:00
Ozkan Sezer
b34726884e do the direct3d tap dance for overscan hint only if SDL_VIDEO_RENDER_D3D == 1 2018-05-10 08:25:23 +03:00
Sam Lantinga
40f5b81553 Fixed bug 4134 - Render targets lose scale quality after minimizing a fullscreen window
Olli-Samuli Lehmus

If one creates a window with the SDL_WINDOW_FULLSCREEN_DESKTOP flag, and creates a render target with SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"), and afterwards sets SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"), after minimizing the window, the scale quality hint is lost on the render target. Textures however do keep their interpolation modes.
2018-05-07 19:52:25 -07:00
Ryan C. Gordon
b014335598 Backed out changeset bd976b7b2b43
Apparently this still triggers a compiler warning, have to dig further.
2018-02-21 22:53:52 -05:00
Ryan C. Gordon
7d719ba6da android: apparently they fixed this header at some point. 2018-02-21 22:35:17 -05:00
sezero
d9c8979193 revert the recent typecast assignment changes (see bug #4079)
also change the void* typedefs for the two vulkan function
pointers added in vulkan_internal.h  into generic function
pointer typedefs.
2018-02-12 17:00:00 +03:00
Sam Lantinga
6534481645 Fixed compile warning 2018-02-09 16:31:57 -08:00
Sam Lantinga
e9a1c0c9d0 Fixed ISO C99 compatibility
SDL now builds with gcc 7.2 with the following command line options:
-Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
2018-01-30 18:08:34 -08:00
Sam Lantinga
10167096d7 Added availability check to fix compiler warning for symbol only available on tvOS 11.0 and newer 2018-01-10 10:42:40 -08:00
Alex Szpakowski
35a7e56e2d metal: set max texture size based on device capability. 2018-01-07 22:00:37 -04:00
Alex Szpakowski
eec1fe1f38 metal: Fix pipeline states to use the pixel format of the current render target, instead of a hard-coded format. 2018-01-07 16:57:32 -04:00
Alex Szpakowski
f09c79bde3 metal: Add support for YUV/NV12 texture formats. 2018-01-06 18:54:12 -04:00
Alex Szpakowski
825117dcd7 metal: use a private instead of managed buffer for the renderer's non-changing constant data.
Recommended by Xcode's Metal frame capture analysis.
2018-01-04 22:16:42 -04:00
Alex Szpakowski
b080c63c45 metal: Implement fast hardware clearing when possible, by deferring the start of a render pass until a clear or draw operation happens. 2018-01-04 19:29:33 -04:00
Sam Lantinga
346af016a5 Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Alex Szpakowski
7b8088185d metal: Misc. improvements.
- Use a single buffer for various non-changing constants accessed by the GPU, instead of multiple buffers.
- Do the half-pixel offset for points and lines using a transform matrix so we don't need a malloc when rendering.
- Don't add a half-pixel offset for other primitives and textures. This matches D3D and GL render behaviour.
- Remove the half-texel texture coordinate offset since it's not needed now that there's no more half-pixel position offset when rendering a texture.
- Don't try to set texture usage on iOS 8 since it doesn't exist there.
2018-01-03 00:43:01 -04:00
Alex Szpakowski
a879f3978e metal and moltenvk: fix highdpi. 2018-01-02 21:44:28 -04:00
Sam Lantinga
70e42bafac Fixed direction of y adjustment for new orthographic projection in the metal renderer 2018-01-02 14:32:15 -08:00
Sam Lantinga
088a7a4bc1 Fixed metal renderer pixel centers when drawing 2018-01-02 14:11:10 -08:00
Alex Szpakowski
70b738ba02 metal: Fix a typo preventing iOS compilation... 2018-01-01 23:06:08 -04:00