Commit Graph

748 Commits

Author SHA1 Message Date
Ryan C. Gordon
5d850766a5 opengl: Build out full GL_LINES and respect the diamond-exit rule.
Likewise for the GLES1 and GLES2 renderers.

This solves the missing pixel at the end of a line and removes all the
heuristics for various platforms/drivers. It's possible we could still use
GL_LINE_STRIP with this and save some vertex buffer space, assuming this
doesn't upset some driver somewhere, but this seems to be a clean fix that
makes the GL renderers match the software renderer output.

Diamond-exit rule explanation:
http://graphics-software-engineer.blogspot.com/2012/04/rasterization-rules.html

Fixes Bugzilla #3182.
2020-02-10 12:53:54 -05:00
Sam Lantinga
4947946285 The scissor rect needs to be updated when the viewport changes in the Metal renderer 2020-02-10 09:42:53 -08:00
Sam Lantinga
e12ce6595d Fixed build warnings on Android 2020-02-01 09:23:04 -08:00
Sam Lantinga
698cde1a8b Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds
Protected more code with #ifdefs to reduce the size of minimal shared library builds
2020-01-23 01:00:52 -08:00
Sylvain Becker
a992fe0007 A few #defines to reduce SDL2 footprint.
Only applied when library is statically linked
2020-01-21 21:33:40 +01:00
Sam Lantinga
89be0e49c6 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
42d4027b9b Fixed bug 4903 - Lack of color multiply with alpha (SDL_BLENDMODE_MOD + SDL_BLENDMODE_BLEND) blending mode for all renderers
Konrad

This kind of blending is rather quite useful and in my opinion should be available for all renderers. I do need it myself, but since I didn't want to use a custom blending mode which is supported only by certain renderers (e.g. not in software which is quite important for me) I did write implementation of SDL_BLENDMODE_MUL for all renderers altogether.

SDL_BLENDMODE_MUL implements following equation:

dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
dstA = (srcA * dstA) + (dstA * (1-srcA))

Background:

https://i.imgur.com/UsYhydP.png

Blended texture:

https://i.imgur.com/0juXQcV.png

Result for SDL_BLENDMODE_MOD:

https://i.imgur.com/wgNSgUl.png

Result for SDL_BLENDMODE_MUL:

https://i.imgur.com/Veokzim.png

I think I did cover all possibilities within included patch, but I didn't write any tests for SDL_BLENDMODE_MUL, so it would be lovely if someone could do it.
2020-01-16 08:52:59 -08:00
Ozkan Sezer
e9446554d8 Fix build error in SDL_render_metal.m (bug #4916.)
Patch provided by Konrad. Error was introduced by commit 35f99d918ca2 for bug #4914.
2019-12-23 19:55:10 +03:00
Sylvain Becker
1c9a2440ff SDL_ScaleMode: fix compilation GLES renderer 2019-12-23 16:47:00 +01:00
Ryan C. Gordon
04e6c1cdd2 direct3d11: Always set vertex buffers when updating them (thanks, Konrad!).
Fixes Bugzilla #4913.
2019-12-22 20:48:43 -05:00
Sam Lantinga
083a8faa77 Fixed bug 4914 - Expose SDL_ScaleMode and add SDL_SetTextureScaleMode/SDL_GetTextureScaleMode
Konrad

This was something rather trivial to add, but asked at least several times before (I did google about it as well).

It should be possible to dynamically change scaling mode of the texture. It is actually trivial task, but until now it was only possible with a hint before creating a texture.

I needed it for my game as well, so I took the liberty of writing it myself.

This patch adds following functions:

SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode);
SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode);

That way you can change texture scaling on the fly.
2019-12-22 13:39:44 -08:00
Ryan C. Gordon
3b75300ca2 direct3d11: Fixed incorrect texture coordinates (thanks, Martin!).
Fixes Bugzilla #4860.
2019-12-03 03:07:34 -05:00
Sylvain Becker
85cb0d3d61 SDL_render_gles2: remove ineffective widening cast
warning: either cast from 'int' to 'size_t' (aka 'unsigned long') is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
2019-10-30 16:45:53 +01:00
Sylvain Becker
36cca1d180 Readability: remove redundant return, continue, enum declaration 2019-10-30 15:36:17 +01:00
Alex Szpakowski
6f44302fe8 macOS Fix potential memory leaks in the Metal renderer caught by clang's static analyzer. 2019-10-26 14:39:50 -03:00
Ryan C. Gordon
e2e0748cfe d3d11: Don't fail if there's no vertex data to upload (thanks, Martin!).
Fixes Bugzilla #4832.
2019-10-26 12:56:18 -04:00
Alex Szpakowski
373d67b24c metal: Fix compilation when using older Apple SDKs (bug #4828). 2019-10-17 18:48:58 -03:00
Sylvain Becker
672c1b5202 Fixed race condition when scaling Touch events, and changing the renderer
target.
Always read the output size of the main renderer.
(similar to bug 2107)
2019-10-14 16:40:46 +02:00
Sylvain Becker
9580e564c2 Fixed bug 4825 - SDL Renderer OpenGL: Buffer overflow (SDL_RENDERCMD_DRAW_LINES) 2019-10-13 20:52:52 +02:00
Sylvain Becker
93eef619ea SDL_LockTextureToSurface: robustness of locked region compared to texture size 2019-10-01 09:26:30 +02:00
Sylvain Becker
634ae03efb Added a helper function SDL_LockTextureToSurface()
Similar to SDL_LockTexture(), except the locked area is exposed as a SDL surface.
2019-09-30 20:58:44 +02:00
Ryan C. Gordon
123d506254 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
56752d2226 d3d11: Fixed VB state, avoiding unnecessary recreation (Thanks, Alex!).
Fixes Bugzilla #4779.
2019-09-01 22:41:44 -04:00
Alex Szpakowski
333739eb02 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
225bac198c metal renderer: optimize SDL_RenderFillRect slightly. 2019-08-18 10:38:32 -03:00
Alex Szpakowski
ffd955faf1 render: fix colors not being set properly after the previous change 2019-08-18 09:35:11 -03:00
Alex Szpakowski
fcbcdb56fc render: avoid a couple redundant memcmp calls in all drawing functions. Improves performance slightly. 2019-08-17 22:26:33 -03:00
Alex Szpakowski
a7fc7f2f01 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
4806fd2326 metal renderer: more closely match buffer data alignment requirements from the metal specification. 2019-08-17 01:09:30 -03:00
Alex Szpakowski
58f5d312f3 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
5e0bbbca54 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
c7bb69b363 metal: Update compiled shaders based on compilation script changes 2019-08-16 22:13:30 -03:00
Alex Szpakowski
b99bcb45b5 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
74249a6d05 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
379eb4adfa 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
dc794bedf2 Add an "error" label in SDL_CreateRenderer (no op) 2019-06-28 16:14:50 +02:00
Ryan C. Gordon
98fba377ef 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
9d146fcbc2 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
3b0639ca7e 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
f56e16c87d 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/45b56ed51919/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
756526a7d9 Android: resize with software rendering, reverted again (Bug 4669) 2019-06-18 18:53:58 +02:00
Sylvain Becker
c15d530a13 Android: try to fix resize with software rendering (bug 4669) 2019-06-18 18:40:40 +02:00
Sylvain Becker
93cf468756 Android: revert commit SW_GetOutputSize, again (Bug 4669) 2019-06-18 18:22:18 +02:00
Sylvain Becker
3f591fa6dc Android: prevent using SW_GetOutputSize with software renderer (Bug 4669) 2019-06-18 10:41:11 +02:00
Sam Lantinga
7739392c5b Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta 2019-06-14 13:56:42 -07:00
Ryan C. Gordon
2cab37bb4b software: Fixed compiler warning and dos2unix'd the endlines. 2019-06-11 15:06:35 -04:00
Ryan C. Gordon
8d3646604b software: Correctly track viewport and cliprect.
Fixes Bugzilla #4457.
2019-06-11 14:09:53 -04:00
Ryan C. Gordon
ac3dae1fbd direct3d: Use D3DPOOL_MANAGED for vertex buffers.
Fixes Bugzilla #4537.
2019-06-11 13:02:56 -04:00
Ryan C. Gordon
4a5112ca53 direct3d: Fixed SDL_RenderSetClipRect usage.
Fixes Bugzilla #4459.
2019-06-11 10:12:47 -04:00
Ryan C. Gordon
e4272c78f4 direct3d: don't dereference bogus pointer if current texture was destroyed.
Fixes Bugzilla #4460.
2019-06-11 09:29:48 -04:00