Commit Graph

238 Commits

Author SHA1 Message Date
Ozkan Sezer
0d79a8a1b2 fix build using Watcom :
./src/render/SDL_render.c(2168): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2168): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2175): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2175): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant

./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
2018-11-01 20:04:24 +03:00
Ryan C. Gordon
4659e73892 merge fallout: Patched to compile, fixed some compiler warnings, etc. 2018-11-01 12:31:45 -04:00
Ryan C. Gordon
62494a2e27 Merge SDL-ryan-batching-renderer branch to default. 2018-10-31 15:03:41 -04:00
Ryan C. Gordon
8340b0f0e2 render: Add floating point versions of various draw APIs. 2018-10-23 01:34:03 -04:00
Cameron Gutman
329f2eb99e Fix crash when GL_LoadFunctions()/GLES2_LoadFunctions() fails
https://bugzilla.libsdl.org/show_bug.cgi?id=4350

We can't safely call GL_DestroyRenderer() until GL_LoadFunctions()
succeeds because we will be missing functions that we try to use
when activating the renderer for destruction if we have an GL context.
2018-10-31 20:17:53 -07:00
Sam Lantinga
da56cefa8b Fixed bug 4188 - Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
Sylvain

Re-opening this issue.

It fixes the test-case, but it introduces a regression with another bug (bug #4313).

So here's a new patch that activate cropping of the source surface to solve the issue.
It also reverts the wrong changeset.
It prevents unneeded colorkey error message.
2018-10-30 07:00:03 -07:00
Micha? Janiszewski
91820998fc Add and update include guards
Include guards in most changed files were missing, I added them keeping
the same style as other SDL files. In some cases I moved the include
guards around to be the first thing the header has to take advantage of
any possible improvements compiler may have for inclusion guards.
2018-10-28 21:36:48 +01:00
Ryan C. Gordon
b262b0ebc9 Small stack allocations fall back to malloc if they're unexpectedly large. 2018-10-22 20:50:32 -04:00
Ryan C. Gordon
eedf2c965d opengles2: Fixed several incorrect things. 2018-10-06 17:08:04 -04:00
Ryan C. Gordon
6ecd0b2c35 opengles2: removed useless memcpy. 2018-10-04 21:10:42 -04:00
Ryan C. Gordon
ef3d970ace opengles2: Fixed incorrect cliprect state. 2018-10-04 20:22:28 -04:00
Ryan C. Gordon
208c4b0361 metal: CopyEx transform matrix must be aligned for constant buffer access. 2018-10-04 20:21:58 -04:00
Ryan C. Gordon
638d624f5a metal: Don't try to create a zero-byte vertex buffer.
(Which will cause a crash in Metal, or an assert in the validation layer.)
2018-10-04 20:21:23 -04:00
Ryan C. Gordon
1ecf4dfc5f render: Added SDL_RenderFlush(). 2018-10-04 16:34:44 -04:00
Ryan C. Gordon
09140bd8bc render: Move PSP backend to new interface.
I have no idea if this works (or if it ever worked, having now examined this
code), as I have no way to compile or test this.

If it's broken, send patches.  :)
2018-10-04 16:11:43 -04:00
Ryan C. Gordon
9fedff997b render: moved software renderer to new interface. 2018-10-03 23:37:29 -04:00
Ryan C. Gordon
bd08a4e6b1 render: D3D11 now cycles through 8 vertex buffers.
This means it doesn't have to block while the current frame finishes using the
vertex buffer; it just moves on to the next, probably-not-in-use buffer.
2018-10-03 19:05:20 -04:00
Ryan C. Gordon
a9094a21a8 render: D3D11 renderer patched to compile. 2018-10-03 18:23:53 -04:00
Ryan C. Gordon
6e6f7382a7 render: first (untested!) shot at converting D3D11 renderer to new interfaces.
Probably doesn't even compile yet.
2018-10-03 00:52:37 -04:00
Ryan C. Gordon
0c2e10dce4 render: Make the GL backends cache and defer more state changes. 2018-10-01 22:53:45 -04:00
Ryan C. Gordon
fcb4681336 render: D3D9 doesn't need to check for stream offset support anymore.
We don't use offsets at all now. Too slow.
2018-10-01 13:41:15 -04:00
Ryan C. Gordon
709f5ee417 render: Set the D3D9 stream source once and choose offsets during draw calls.
This is _much_ faster than setting the offsets with SetStreamSource!
2018-10-01 11:32:08 -04:00
Ryan C. Gordon
9870746bd9 render: Patched to compile. 2018-10-01 03:02:54 -04:00
Ryan C. Gordon
5e644cfdfb render: first shot at moving Direct3D 9 backend to new interface. Untested! 2018-10-01 01:23:02 -04:00
Ryan C. Gordon
fdc52a65dd render: patched to compile on C89 compilers, other untested code fixes. 2018-09-29 04:00:38 +00:00
Ryan C. Gordon
daad53af13 opengles1: set some non-zero drawstate defaults. 2018-09-28 19:48:14 -04:00
Ryan C. Gordon
c20a858da5 render: moved opengles2 over to new interface. 2018-09-28 19:47:44 -04:00
Ryan C. Gordon
0d588cc4c9 render: Do state cache improvements for GLES1, too. 2018-09-25 21:35:09 -04:00
Ryan C. Gordon
d04e55240e render: OpenGL renderer now caches some state, to improve non-batching mode.
(other minor bug fixes in here, too)
2018-09-25 19:20:31 -04:00
Ryan C. Gordon
06461bba73 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.
2018-09-25 17:04:47 -04:00
Ryan C. Gordon
43f15e05dd render: opengles renderer actually works now. :) 2018-09-25 16:17:10 -04:00
Ryan C. Gordon
b2db99cb9f render: First shot at converting opengles renderer to new interfaces. 2018-09-25 10:41:25 -04:00
Ryan C. Gordon
c01da21756 render: get rid of the predeclared functions in the GL and Metal renderers.
(others to come as I continue to update render backends!)
2018-09-24 12:30:47 -04:00
Ryan C. Gordon
051d1cfcd1 render: Make opengl backend take advantage of new high-level features. 2018-09-24 02:08:34 -04:00
Ryan C. Gordon
8ac5c00a43 render: Add command queue debug logging. 2018-09-24 02:07:35 -04:00
Ryan C. Gordon
2241b33f55 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.
2018-09-23 23:22:56 -04:00
Ryan C. Gordon
cc56de44a4 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).
2018-09-23 23:20:40 -04:00
Ryan C. Gordon
8955fb9b31 render: First shot at moving metal backend over to new batching system. 2018-09-20 16:40:04 -04:00
Ryan C. Gordon
55cb9966db render: first shot at reworking opengl backend for new batching system. 2018-09-20 16:36:54 -04:00
Ryan C. Gordon
5fb67f9f55 render: Move to a batching system for rendering (work in progress). 2018-09-20 15:46:02 -04:00
Ryan C. Gordon
a2f7af9a47 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.
2018-09-09 15:09:38 -04:00
Ryan C. Gordon
0d3275297d 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!
2018-09-08 18:26:11 -04:00
Ryan C. Gordon
264b81b481 metal: Make sure layer drawableSize is adjusted on resize.
Fixes Bugzilla #4250.
2018-09-06 00:56:13 -04:00
Ryan C. Gordon
3634e563c4 metal: SDL_UpdateYUVTexture shouldn't swap planes based on format. 2018-09-01 20:47:12 -04:00
Sam Lantinga
90a5607d32 Fixed compiler warning and use higher precision in angle calculation 2018-08-29 20:23:42 -07:00
Sam Lantinga
92396f7d74 Fixed Windows build 2018-08-28 16:19:31 -07:00
Andreas M?ller
87bc1fb552 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
Alex Szpakowski
8c41e2624e metal: Fix SDL_RenderReadPixels to wait for the GPU to finish rendering to the active texture before reading its pixels. 2018-10-13 03:36:42 -03:00
Alex Szpakowski
d9094421e1 metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250. 2018-10-12 17:55:42 -03:00
Sam Lantinga
82c2f04e61 Fixed bug 4188 - Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
duckgrease

SDL_RenderCopyEx blits wrong image (in some cases it's bunch of alternating horizontal lines, some cases it's image from the wrong coordinate, and in some cases it's just a bunch of garbled pixels), when the following conditions are met:
- Use software renderer.
- Enable either horizontal or vertical flip.
- source and destination rectangles must have same width and height, and must be smaller than the size of the texture.
- source rectangle's X and Y coordinates must be 0.
2018-10-09 17:41:40 -07:00