Commit Graph

312 Commits

Author SHA1 Message Date
Ryan C. Gordon
847bd8d983 direct3d: Be more aggressive about resetting state when textures go away.
Fixes Bugzilla #4768.
2019-09-02 00:11:58 -04:00
Ryan C. Gordon
a3804ba1da d3d11: Fixed VB state, avoiding unnecessary recreation (Thanks, Alex!).
Fixes Bugzilla #4779.
2019-09-01 22:41:44 -04:00
Alex Szpakowski
0c26373842 gl/gles/gles2 render: fix SDL_RenderClear being affected by the clip rect in some situations. 2019-08-26 18:49:04 -03:00
Alex Szpakowski
bfdb0e9743 metal renderer: optimize SDL_RenderFillRect slightly. 2019-08-18 10:38:32 -03:00
Alex Szpakowski
ff7888e698 render: fix colors not being set properly after the previous change 2019-08-18 09:35:11 -03:00
Alex Szpakowski
1be03b4089 render: avoid a couple redundant memcmp calls in all drawing functions. Improves performance slightly. 2019-08-17 22:26:33 -03:00
Alex Szpakowski
e8278d0d5b metal renderer: use vertex attributes instead of indexing into a buffer with the vertex id in the shader. Allows for more flexibility with vertex setup in the future.
Also optimize vertex buffer binding slightly.
2019-08-17 16:53:08 -03:00
Alex Szpakowski
55a46abf0a metal renderer: more closely match buffer data alignment requirements from the metal specification. 2019-08-17 01:09:30 -03:00
Alex Szpakowski
69c6924ccc render: simplify vertex and uniform data allocation. Improves performance of various SDL_Render functions (bug #4764). 2019-08-17 00:43:44 -03:00
Alex Szpakowski
e5acccc7c3 metal renderer: use the device address space instead of the constant address space for colors.
It doesn't negatively impact GPU performance in my tests, and it removes the need for 256 byte memory alignment of color data on macOS.
2019-08-17 00:37:22 -03:00
Alex Szpakowski
3fb5cabe5e metal: Update compiled shaders based on compilation script changes 2019-08-16 22:13:30 -03:00
Alex Szpakowski
9e57e3e595 metal: Update shader compilation script with fixes for newer xcode versions and for running on older platforms 2019-08-16 22:11:50 -03:00
Alex Szpakowski
aebaa316c7 Add public APIs for creating a Metal view attached to an SDL window. Add SDL_metal.h. 2019-08-05 12:35:32 -03:00
Sylvain Becker
22a2decf64 Android: concurrency issues, make sure Activity is in running State when calling
functions like SDL_CreateWindow, SDL_CreateRenderer, Android_GLES_CreateContext

Bugs 4694, 4681, 4142
2019-06-28 16:38:42 +02:00
Sylvain Becker
cfed0b7738 Add an "error" label in SDL_CreateRenderer (no op) 2019-06-28 16:14:50 +02:00
Ryan C. Gordon
31bb95f11f direct3d: Use D3DPOOL_DEFAULT for vertex buffers after all, release correctly.
Fixes Bugzilla #4679.
Fixes Bugzilla #4537.
2019-06-21 15:07:39 -04:00
Cameron Gutman
e681623cb2 direct3d: Fix dirty textures failing to update
Even if the texture itself has not changed since last time, the data may have
so we must call UpdateDirtyTexture() to handle that possibility.
2019-06-20 19:51:00 -07:00
Ryan C. Gordon
7162649f78 opengl: Be more robust in failing cases.
Load all possible symbols, not just until one fails, in case they get used
during shutdown, etc.

Fixes Bugzilla #4093.
2019-06-18 18:58:39 -04:00
Sam Lantinga
5dcac4ccdf Fixed 4669 - Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes
Sylvain

I think what happening with the software renderer is:

* you're somehow in background (so texture creation is not possible)
* it resizes and wants to push a SDL_WINDOWEVENT_SIZE_CHANGED
It call:
https://hg.libsdl.org/SDL/file/a010811d40dd/src/render/SDL_render.c#l683
* GetOutputSize
* SW_GetOutputSize
* SW_ActivateRenderer
* SDL_GetWindowSurface
* SDL_CreateWindowFramebuffer which is mapped to SDL_CreateWindowTexture
and it ends up re-creating the surface/a texture, while being in background
2019-06-18 10:08:19 -07:00
Sylvain Becker
e96d4760ac Android: resize with software rendering, reverted again (Bug 4669) 2019-06-18 18:53:58 +02:00
Sylvain Becker
12b92260cc Android: try to fix resize with software rendering (bug 4669) 2019-06-18 18:40:40 +02:00
Sylvain Becker
8a20d40d90 Android: revert commit SW_GetOutputSize, again (Bug 4669) 2019-06-18 18:22:18 +02:00
Sylvain Becker
98cc7589b1 Android: prevent using SW_GetOutputSize with software renderer (Bug 4669) 2019-06-18 10:41:11 +02:00
Sam Lantinga
1213fe79d8 Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta 2019-06-14 13:56:42 -07:00
Ryan C. Gordon
3e9bf28413 software: Fixed compiler warning and dos2unix'd the endlines. 2019-06-11 15:06:35 -04:00
Ryan C. Gordon
04fedce0e8 software: Correctly track viewport and cliprect.
Fixes Bugzilla #4457.
2019-06-11 14:09:53 -04:00
Ryan C. Gordon
a2f2b73554 direct3d: Use D3DPOOL_MANAGED for vertex buffers.
Fixes Bugzilla #4537.
2019-06-11 13:02:56 -04:00
Ryan C. Gordon
f7b7a9727b direct3d: Fixed SDL_RenderSetClipRect usage.
Fixes Bugzilla #4459.
2019-06-11 10:12:47 -04:00
Ryan C. Gordon
4f59d372f8 direct3d: don't dereference bogus pointer if current texture was destroyed.
Fixes Bugzilla #4460.
2019-06-11 09:29:48 -04:00
Ryan C. Gordon
a6af0b8291 direct3d: Fixed more compiler warnings on Visual Studio 64-bit builds. 2019-06-11 02:31:57 -04:00
Sam Lantinga
b5e9ebbafa Fixed compiler warning
warning C4018: '<' : signed/unsigned mismatch
2019-06-08 19:12:05 -07:00
Sam Lantinga
41c718db85 Fixed bug 4469 - make SDL_CreateTextureFromSurface pick a more appropriate format
Sylvain

Currently SDL_CreateTextureFromSurface picks first valid format, and do a conversion.

    format = renderer->info.texture_formats[0];
    for (i = 0; i < renderer->info.num_texture_formats; ++i) {
        if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) &&
            SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
            format = renderer->info.texture_formats[i];
            break;

It could try to find a better format, for instance :

 if SDL_Surface has no Amask, but a colorkey :
   if surface fmt is RGB888, try to pick ARGB8888 renderer fmt
   if surface fmt is BGR888, try to pick ABGR8888 renderer fmt
 else
   try to pick the same renderer format as surface fmt

if no format has been picked, use the fallback.


I think it goes with bug 4290 fastpath BlitNtoN
when you expand a surface with pixel format of size 24 to 32, there is a fast path possible.


So with this issue:

- if you have a surface with colorkey (RGB or BGR, not palette), it takes a renderer format where the conversion is faster.
  (it avoids, if possible, RGB -> ABGR which means switching RGB to BGR)

- if you have a surface ABGR format, it try to take the ABGR from the renderer.
  (it avoids, if possible, ABGR -> ARGB, which means switch RGB to BGR)
2019-05-19 12:04:06 -07:00
Sam Lantinga
2ee9b1ddce Fixed bug 4025 - SDL_Renderer OpenGL : add support for textures ABGR, RGB, BGR
Sylvain

OpenGLES2 SDL renderer has support for textures ARGB, ABGR, RGB and BGR, whereas OpenGL SDL renderer only had ARGB.

If you think it's worth adding it, here's a patch. I quickly tried and it worked, but there may be missing things or corner case.
2019-05-19 11:01:36 -07:00
Sylvain Becker
d68e501db4 Fixed bug 4582 - Maximize/Resize not working on Windows 10
When viewport is set, projectionAndView changes, but ID3D11DeviceContext_UpdateSubresource was not called.
2019-04-08 13:43:48 +02:00
Ryan C. Gordon
8ab698af15 opengles2: Fix static analysis warning.
Not clear if this could ever dereference NULL in real life, but better safe
than sorry!
2019-03-21 10:39:49 -04:00
Sam Lantinga
b2e76d860f Fixed Windows RT build 2019-03-19 16:52:09 -07:00
Sylvain Becker
b28e956b8c Fixed bug 4542 - Image flipped vertically when rendering on texture
Have to recompute  viewport because projection/glOrtho is different
wether rendering is on target texture or not
2019-03-12 07:59:53 +01:00
Ryan C. Gordon
40781dfb15 opengles2: patched to compile. 2019-02-04 23:35:18 -05:00
Ryan C. Gordon
b7504f311b opengles2: keep cached texturing state correct. 2019-02-04 23:32:28 -05:00
Ryan C. Gordon
a609c03ac6 opengles1: keep cached texturing state correct. 2019-02-04 23:24:10 -05:00
Ryan C. Gordon
40a52ceef7 render: Fix OpenGL draw state cache for various points of texture binding. 2019-02-04 18:55:39 -05:00
Sylvain Becker
07548602d6 Fixed bug 3657 - Color-key doesn't work when an alpha channel is present
When surface format is the same as renderer format, it still needs an
intermediate conversion to transform colorkey to alpha.
2019-01-19 16:47:43 +01:00
Sylvain Becker
be991f3a78 Fixed bug 4453 - GLES / GLES2: first white renderer clear cmd is drawn as black 2019-01-12 13:34:03 +01:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sylvain Becker
9cdd0dd996 PSP renderer: use colors from 'draw' union (very likely, but un-tested) 2018-12-29 17:59:34 +01:00
Sylvain Becker
ebd9efb361 opengles 1: same fix as in bug #4433 2018-12-29 16:37:44 +01:00
Sylvain Becker
87b7636918 opengles 1: use color from 'draw' union in SetDrawState() 2018-12-29 16:34:50 +01:00
Alex Szpakowski
dc3443602b render: Fix internal state getting out of sync when destroying a texture that was just rendered and then creating a new one, in the GL and GLES2 backends. Fixes bug #4433. 2018-12-21 20:53:31 -04:00
Ryan C. Gordon
0a70590118 render: Prefer the Metal renderer over OpenGL.
This is the best option for macOS and iOS, the only platforms with Metal.

Pre-Metal versions of these platforms will fall back to OpenGL (ES), as
appropriate.

Huge thanks to Alexander Szpakowski, who worked incredibly hard to get the
Metal renderer to such a high-quality state!
2018-12-19 18:10:02 -05:00
Alex Szpakowski
c7db6ade7d metal: Implement SDL_LockTexture for YUV formats. 2018-12-19 18:27:21 -04:00