Commit Graph

518 Commits

Author SHA1 Message Date
Sylvain
61d9e9164f For the software renderer, try to reinterpret triangles as SDL_Rect
With Dear ImGui + software renderer, it draws:
- by default at 250 fps
- drops to 70 fps if you show the color picker
- drops to 10 fps if put the color picker fullscreen
2021-08-19 00:10:59 +02:00
Sylvain
cc37c38e30 Add SDL_RenderGeometry based on SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain
e481261173 Move to SDL_RenderGeometryRaw prototype with separate xy/uv/color pointer parameters 2021-08-19 00:10:59 +02:00
Sylvain
111c70e141 Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles 2021-08-19 00:10:59 +02:00
Sylvain
f73c1eff10 Use normalized texture coordinates 2021-08-19 00:10:59 +02:00
Sylvain
5828cc415a Update METAL backend: fix a typo in drawline 2021-08-19 00:10:59 +02:00
Sylvain Becker
9a8a8e65b8 Update SDL_render_d3d11.c
Fix D3D11 compilation
2021-08-19 00:10:59 +02:00
Sylvain Becker
121114d061 Update METAL compiled shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker
2d01573bb9 Add METAL shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker
1e77dae7b7 Add METAL implementation 2021-08-19 00:10:59 +02:00
Sylvain
1ebef0732a Add D3D11 implementation (not yet tested) 2021-08-19 00:10:59 +02:00
Sylvain
3ee511d71c Add software renderer implementation 2021-08-19 00:10:59 +02:00
Sylvain
37f78fc1cc Add OpenGL implementation 2021-08-19 00:10:59 +02:00
Sylvain
faded41ab1 Add OpenGLES2 implementation 2021-08-19 00:10:59 +02:00
Sylvain
6e26d320c6 Add sysrender interface 2021-08-19 00:10:59 +02:00
Sylvain
53a2608bd2 Renderer opengles2: turn color Uniform into Attribute.
all attributes are copied interleaved (based on rmg-nik initial patch+
+ minor clean up of data structure
+ add check for colorswap
2021-08-19 00:10:59 +02:00
Sam Lantinga
f5794f9eeb Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate a user-specified pointer with an SDL texture 2021-08-10 15:17:59 -07:00
Sam Lantinga
fcfd19db86 Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer
This fixes https://github.com/libsdl-org/SDL/issues/4612
2021-08-10 12:02:59 -07:00
Sam Lantinga
a91ab883e9 Fixed building on Windows with cmake, ninja, and clang 2021-08-06 12:28:24 -07:00
Ryan C. Gordon
5fc13fcb21 direct3d: Commit viewport state before clearing, attempt 2.
This reintroduces the fix from 0e16ee8330, but just marks
the viewport state as dirty after a clear that needs to expand the
viewport to fill the render target, as we'll need to also reset
the orthographic projection state elsewhere, and that won't
happen if we clear the dirty flag here.

Fixes #4210.
(again.)
(...sorry...!)
2021-08-04 07:00:17 -04:00
David Gow
4077f7a2d9 Update the Renderer dpi_scale on SIZE_CHANGED event (fix #4580)
The Renderer logical scaling code scales mouse coordinates, and needs to
take the window DPI into account on HIGHDPI windows. However, the
variable which tracks this, renderer->dpi_scale, is set once when the
renderer is created, and then not updated. In the event that the window
is moved to another screen, or the screen DPI otherwise changes, this
will be outdates, and potentially the coordinates will be all wrong.

So let's update the dpi_scale on the SIZE_CHANGED event: it's at least a
possibility that this will be issued on some OSes when DPI changes, and
it's otherwise already handled by SDL_Renderer's event filter.
2021-08-03 09:30:43 -07:00
Sam Lantinga
9d64e6b442 Revert "direct3d: Commit dirty viewport state before clearing."
This reverts commit 0e16ee8330.
2021-08-03 00:29:33 -07:00
Ryan C. Gordon
0e16ee8330 direct3d: Commit dirty viewport state before clearing.
Otherwise you might have set the viewport to the full size of
the render target in SDL's API but this change hasn't been
transmitted to Direct3D yet by the time we attempt to clear.

Fixes #4210.
2021-08-03 02:32:56 -04:00
David Gow
8f06a629aa render: Fix -Wmaybe-uninitialized warning in RenderDrawLinesWithRects{,F}
The RenderDrawLinesWithRects and RenderDrawLinesWithRectsF functions can
sometimes call QueueCmdFillRects() with the data pointed to by frects
uninitialised. This can occur if none of the lines can be replaced with
rects, in which case the frects array is empty, and nrects is 0.

gcc 10.3.0 will detect this possibility, and print a warning like:
/home/david/Development/SDL/src/render/SDL_render.c: In function 'RenderDrawLinesWithRectsF':
/home/david/Development/SDL/src/render/SDL_render.c:2725:15: warning: '<unknown>' may be used uninitialized [-Wmaybe-uninitialized]
 2725 |     retval += QueueCmdFillRects(renderer, frects, nrects);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david/Development/SDL/src/render/SDL_render.c:499:1: note: by argument 2 of type 'const SDL_FRect *' to 'QueueCmdFillRects' declared here
  499 | QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int count)
      | ^~~~~~~~~~~~~~~~~

This is harmless, because when this is uninitialised, nrects is always
0, so QueueCmdFillRects() does nothing anyway. We therefore can work
around this by only calling QueueCmdFillRects() when nrects is nonzero.
Somewhat impressively, gcc recognises that this is now safe.
2021-07-30 10:53:49 -04:00
Ryan C. Gordon
585c11c5ae
direct3d: Fix possibly-incorrect scissor test when clearing.
Thanks to @JayFoxRox who did the detective work on this!

Fixes #3357.
2021-07-30 00:33:15 -04:00
Jessica Clarke
8f38ba4d68 Fix casts that should be using uintptr_t
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

On most systems (anything with a flat memory hierarchy rather than using
segment-based addressing), size_t and uintptr_t are the same type.
However, on CHERI, size_t is just an integer offset, whereas uintptr_t
is still a capability as described above. Casting a pointer to size_t
will strip the metadata and validity tag, and casting from size_t to a
pointer will result in a null-derived capability whose validity tag is
not set, and thus cannot be dereferenced without faulting.

The audio and cursor casts were harmless as they intend to stuff an
integer into a pointer, but using uintptr_t is the idiomatic way to do
that and silences our compiler warnings (which our build tool makes
fatal by default as they often indicate real problems). The iconv and
egl casts were true positives as SDL_iconv_t and iconv_t are pointer
types, as is NativeDisplayType on most OSes, so this would have trapped
at run time when using the round-tripped pointers. The gles2 casts were
also harmless; the OpenGL API defines this argument to be a pointer type
(and uses the argument name "pointer"), but it in fact represents an
integer offset, so like audio and cursor the additional idiomatic cast
is needed to silence the warning.
2021-07-29 14:42:15 -07:00
Ivan Epifanov
f806064e7e Remove 'support' for rgb/bgr textures, that was causing issues with them 2021-07-19 10:14:13 -04:00
Ivan Epifanov
817976da69 VITA: Rewrite and fix RenderCopyEx rotation 2021-07-13 08:45:33 -07:00
Ivan Epifanov
3b6e999244 Vita: remove unused variable and allow Razor perf analysis 2021-07-01 15:14:49 -07:00
Ivan Epifanov
b55ee12f69 Vita: fix clip rectangle 2021-07-01 15:14:49 -07:00
Ivan Epifanov
e41d3e617e VIta: fix render clearing 2021-07-01 15:14:49 -07:00
Ivan Epifanov
6b12280510 Vita: proper syntax 2021-07-01 15:14:49 -07:00
Ivan Epifanov
32deb6f70c Vita: fix point size 2021-07-01 15:14:49 -07:00
Ivan Epifanov
8da0dd17a1 Oops. Renderer already queues viewport change 2021-06-15 08:58:53 -07:00
Ivan Epifanov
1fc519880d Reset/re-apply viewport on frame start/target change. Fixes SDL_RenderSetLogicalSize on PSVita 2021-06-15 08:58:53 -07:00
Ivan Epifanov
a4442476df Cleanup dead and duplicate code 2021-06-11 13:21:07 -04:00
Ivan Epifanov
dd2a285825 Remove leftovers 2021-06-11 13:21:07 -04:00
Ivan Epifanov
ca969eb2be Remove gles2 vita render 2021-04-24 14:13:09 -07:00
Sylvain
e87c7940f5
Fixed bug 3829 - Don't FOURCC format for target textures
FOURCC isn't supported by renderer back-ends for target access
So use a correct format and fallback to with native/yuv path
2021-04-13 14:42:38 +02:00
Ryan C. Gordon
57c2a4566f
render: draw when hidden, except on iOS and Android.
Fixes #2979.
2021-04-02 14:01:41 -04:00
Vanfanel
e14fb54e3f [KMSDRM] Undo SDL_CreateRenderer() modifications aimed at create opengles2 when KMSDRM is in use because it's a harmful solution. 2021-03-16 11:07:54 -07:00
Vanfanel
108bb5aabe [KMSDRM] Modify SDL_CreateRenderer() to create an opengles2 renderer when the KMSDRM backend is being used and no renderer name has been specified. 2021-03-15 18:47:22 -07:00
Ivan Epifanov
e58a955e68 Deprecate dolcesdk 2021-03-08 09:07:12 -08:00
uyjulian
c8abc88cd0 Add support for message box 2021-03-08 09:07:12 -08:00
José Cadete
91fe2b67f5 Allow larger texture sizes 2021-03-08 09:07:12 -08:00
José Cadete
739f4e1eb2 Only call sceGxmFinish when vsync is on
Also fix oversight with supported textures
2021-03-08 09:07:12 -08:00
José Cadete
ddfe7200e2 Rendering improvements
- Improve performance for unbatched rendering
- Support direct texture access
2021-03-08 09:07:12 -08:00
Ivan Epifanov
c7cec2c792 Add more texture formats 2021-03-08 09:07:12 -08:00
Ivan Epifanov
7d89f09f74 ISO C90 fixes 2021-03-08 09:07:12 -08:00
Ivan Epifanov
0da35d3daf IME support with gxm backend 2021-03-08 09:07:12 -08:00
Ivan Epifanov
47c6270ece Fix a bug in vitagles2 renderer 2021-03-08 09:07:12 -08:00
Ivan Epifanov
639323ea0d Fixed gxm render flags 2021-03-08 09:07:12 -08:00
Ivan Epifanov
05e5a7cb05 Oops 2021-03-08 09:07:12 -08:00
Ivan Epifanov
a86ba3916e Add SDL_RenderReadPixels 2021-03-08 09:07:12 -08:00
Ivan Epifanov
f623211eea remove sceGxmFinish on render swap 2021-03-08 09:07:12 -08:00
Ivan Epifanov
0b45529e24 Add viewport support 2021-03-08 09:07:12 -08:00
Ivan Epifanov
2209b71789 Refactor render state 2021-03-08 09:07:12 -08:00
Ivan Epifanov
333d5e11e1 Add drawstate cache 2021-03-08 09:07:12 -08:00
Ivan Epifanov
56bde0f633 Rename memory functions to avoid clash with vita2d 2021-03-08 09:07:12 -08:00
Ivan Epifanov
94d7737bef Texture render target 2021-03-08 09:07:12 -08:00
Ivan Epifanov
63e223fa50 Set initial blend mode 2021-03-08 09:07:12 -08:00
Ivan Epifanov
6c3bf56503 Unified build with both renderers 2021-03-08 09:07:12 -08:00
Ivan Epifanov
0131105408 Fix render name 2021-03-08 09:07:12 -08:00
Ivan Epifanov
6ba8497518 Remove vita2d render, add raw gxm render 2021-03-08 09:07:12 -08:00
Ivan Epifanov
ef0bbfd6c6 Include anf fix vita2d renderer 2021-03-08 09:07:12 -08:00
Ivan Epifanov
dbb730d395 Separate vita piglet renderer. Add proper render initialization and window re-creation. 2021-03-08 09:07:12 -08:00
Ivan Epifanov
d75ea51ac0 Fix texture shaders 2021-03-08 09:07:12 -08:00
Ivan Epifanov
2e3dd0a668 Remove debug log 2021-03-08 09:07:12 -08:00
Ivan Epifanov
8003623061 Cg shaders for vita gles2 2021-03-08 09:07:12 -08:00
Ozkan Sezer
0ed1713128 update SDL_COMPOSE_ERROR macro for windows clang-cl
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:27:47 +03:00
Ozkan Sezer
f2a2d0c696 SDL_render_d3d.c: fix build with SDL_LEAN_AND_MEAN 2021-02-15 22:56:20 +03:00
Alex Szpakowski
9b9d0d484d mac/iOS: allow Metal in windows created without an explicit backend
Fixes SDL_CreateWindowAndRenderer (and similar situations) not choosing a Metal backend. See #3991.

Passing an explicit backend into CreateWindow, eg SDL_WINDOW_OPENGL or SDL_WINDOW_METAL, will still prevent the window from being used with other backend types.
2021-02-15 08:43:53 -08:00
Sam Lantinga
69e9b2acee Fixed bug 5471 - Creating a fullscreen desktop window goes windowed temporarily
This is caused by the Metal renderer recreating the window because by default we create an OpenGL window on macOS.

It turns out that at least on macOS 10.15, a window that has been initialized for OpenGL can also be used with Metal. So we'll skip recreating the window in that case.
2021-02-10 10:22:19 -05:00
Sylvain Becker
dc0ec827aa Remove old YUV fixme 2021-02-10 10:22:18 -05:00
Sam Lantinga
1e5f0073c6 Fixed building with mingw64 2021-02-10 10:22:17 -05:00
Sylvain Becker
70b353d1a5 SDL_Update{YUV,NV}Texture: also intersect rect with texture dimension 2021-02-10 10:22:17 -05:00
Sylvain Becker
13626c3681 SDL_UpdateTexture: intersect update rect with texture dimension
- fix crash with software renderer
- fix non texture update with opengl/gles2
2021-02-10 10:22:17 -05:00
Sam Lantinga
de85d61256 Fixed bug 5497 - SDL_COMPOSE_ERROR is wrong
UMU

#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str

I think SDL_STRINGIFY_ARG should be removed.

#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str

(verified with Visual Studio 2019)
2021-02-10 10:22:16 -05:00
Sylvain Becker
f40551c5f6 GLES2 SDL_Renderer: remove old ZUNE_HD defines and simplify shader cache 2021-02-10 10:22:16 -05:00
Ryan C. Gordon
b99543b682 opengl: More work on making line drawing match software renderer. 2021-01-11 20:40:11 -05:00
Sylvain Becker
958e5d5b34 SDL_UpdateNVTexture: fixed pitch/bpp for GLES2 (bug #5430) 2021-01-11 10:01:24 +01:00
Sylvain Becker
b94718e0a7 SDL_UpdateNVTexture: for D3D11, same notation as SDL_UpdateTexture (bug #5430) 2021-01-09 21:22:21 +01:00
Sylvain Becker
57a5c45372 Fix D3D11 UpdateTextureNV in non fullscreen (bug #5430) 2021-01-05 22:06:51 +01:00
Sylvain Becker
fc61ecb25c Fix software UpdateNVTexture non fullscreen (bug #5430) 2021-01-05 21:54:03 +01:00
Sylvain Becker
204ef3b509 Fix D3D11 UpdateNVTexture (bug #5430) 2021-01-05 20:38:31 +01:00
Sylvain Becker
c0df40e003 Add more SDL_HAVE_YUV defines 2021-01-05 17:39:48 +01:00
Sylvain Becker
b032504162 Fix unused variable warning on METAL (see bug #5430) 2021-01-05 12:36:34 +01:00
Sylvain Becker
c1eb9ecf99 Add SDL_UpdateNVTexture for META (bug #5430)
(not tested)
2021-01-05 12:29:43 +01:00
Sylvain Becker
73d93dbc38 Fix compilation on Window10 (see bug #5430) 2021-01-05 12:20:02 +01:00
Sylvain Becker
df6b813108 Fix compilation (implicit declaration of function) (see bug #5430) 2021-01-05 12:16:32 +01:00
Sylvain Becker
d1f031c8ee Add SDL_UpdateNVTexture for d3d11 (bug #5430)
(not tested)
2021-01-05 12:08:16 +01:00
Sylvain Becker
f5eba2ccd6 Fixed invalid read in yuv_rgb_sse() (see bug #5430) 2021-01-05 12:00:54 +01:00
Sylvain Becker
be4cfd51c3 Add SDL_UpdateNVTexture() to update NV12/21 Texture (bug #5430)
for renderer software, opengl, and opengles2
2021-01-05 11:56:22 +01:00
Sam Lantinga
393c8c1f16 Fixed bug 5440 - MacCatalyst build failures
C.W. Betts

I tested building commit http://hg.libsdl.org/SDL/rev/7adf3fdc19f3 on Mac Catalyst and found some issues:

* MTLFeatureSet_iOS_* enums aren't available under Mac Catalyst.
* OpenGL ES is unavailable under Mac Catalyst.
* Some Metal features are available under Catalyst but not iOS, such as displaySyncEnabled.
* Set Metal as the default renderer on Mac Catalyst

Attaching a patch that will make SDL2 build for Mac Catalyst.
2021-01-03 10:32:55 -08:00
Sam Lantinga
9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sylvain Becker
3edf337d66 Simplify RenderGetViewportSize 2021-01-02 17:29:34 +01:00
Sylvain Becker
2af765da11 SDL_RenderGetViewportF: only need the size of viewport (see bug #5424) 2021-01-02 17:18:13 +01:00
Sylvain Becker
41597249e8 SDL_RenderGetViewportF: remove debug messages 2021-01-02 16:15:22 +01:00
Sylvain Becker
8c48c4238a Add SDL_RenderGetViewportF: fix lost of precision while scaling (see bug #5424) 2021-01-02 16:12:30 +01:00
Sam Lantinga
223af86c62 Added SDL_RenderGetD3D11Device() to get access to the device associated with the D3D11 renderer 2021-01-01 11:12:30 -08:00