Commit Graph

476 Commits

Author SHA1 Message Date
Sylvain
eff840bb9b Add OpenGLES implementation 2021-08-19 00:10:59 +02:00
Sylvain
32e7910135 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain
6e47f53869 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain
4869a3d294 Add Direct3D9 implementation (not tested) 2021-08-19 00:10:59 +02:00
Sylvain
4ba3763897 Save and restore SDL renderer state after transforming triangles to rect 2021-08-19 00:10:59 +02:00
Sylvain
cd0663e053 Fix declaration-after-statement and remove tabs 2021-08-19 00:10:59 +02:00
Sylvain Becker
cd4663dfcb Update D3D11 for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain Becker
9f59170743 Update METAL backend for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
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