Commit Graph

552 Commits

Author SHA1 Message Date
Sylvain
49369142bd
Fixed bug #4625: with integer scale, viewport (as reported by SDL_RenderGetViewport) becomes -2147483648x-2147483648
0 isn't valid scale. Min integer scale is 1.0f
2021-11-21 17:40:48 +01:00
Sam Lantinga
9ec2b35147 Fixed the GLES2 shader count to be in sync with the enum 2021-11-15 13:45:53 -08:00
Sylvain
d4df5d33c5
GLES2: prevent batching if blend mode changes (see bug #4964) 2021-11-15 09:43:44 +01:00
Sylvain
92f2fdfc84
GLES2: batch non joined lines (see #4964) 2021-11-15 09:36:18 +01:00
Sylvain
17f156fae5
Fixed bug #4964 - opengles2 & batching = conjoined lines
put back the initial switch case because groups of joined lines cannot be batched.
2021-11-15 09:08:09 +01:00
Sylvain
d8888e468e
Fixed bug #4964 - opengles2 & batching = conjoined lines 2021-11-15 08:37:49 +01:00
Sam Lantinga
c55ab9631f Added a hint for alternate OpenGL NV12 data format 2021-11-13 22:21:57 -08:00
Sylvain
70c8d20a46
Revert previous commit a50ca98e2b (see bug #4625) 2021-11-13 15:04:19 +01:00
Sylvain
a50ca98e2b
Fixed bug #4625 - SDL_RenderSetLogicalSize issues
viewport becomes -2147483648x-2147483648 when logical_w/h is greater than window size.
division should be done with floats
2021-11-13 14:48:36 +01:00
Misa
3bf7994fe2 Add and use SDL_FALLTHROUGH for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-12 07:26:14 +03:00
Sam Lantinga
abc12a832c Revert "Add and use SDL_FALLTHROUGH for fallthroughs"
This reverts commit 66a08aa391.

This causes problems with older compilers:
https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
2021-11-11 15:58:44 -08:00
Misa
66a08aa391 Add and use SDL_FALLTHROUGH for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-11 07:23:25 -08:00
Sam Lantinga
6c4b4ee7a6 Don't assert on API parameters
This causes lots of spam in test automation and it's not clear it's useful to developers. If we need this level of validation, we should add a log category for it.
2021-11-10 09:41:43 -08:00
Sam Lantinga
3a31a45028 End the scene before resetting the D3D device, since we'll start with BeginScene after that.
If we don't do this, we'll end up with unbalanced Begin/End scene pairs which causes D3DERR_INVALIDCALL in the present.

Fixes https://github.com/libsdl-org/SDL/issues/4933
2021-11-10 05:24:31 -08:00
Eric Wasylishen
0d98793693
testwm2: Fix video modes menu hit detection when highdpi or logical size used (#4936)
* SDLTest_CommonDrawWindowInfo: log SDL_RenderGetScale, SDL_RenderGetLogicalSize

* testwm2: fix video modes menu hit detection in High DPI cases

- also when logical size is specified, e.g.
  `--logical 640x480 --resizable --allow-highdpi`

* add function to determine logical coordinates of renderer point when given window point

* change since to the targeted milestone

* fix typo

* rename for consistency

* Change logical coordinate type to float, since we can render with floating point precision.

* add function to convert logical to window coordinates

* testwm2: use new SDL_RenderWindowToLogical

* SDL_render.c: alternate SDL_RenderWindowToLogical/SDL_RenderLogicalToWindow

Co-authored-by: John Blat <johnblat64@protonmail.com>
Co-authored-by: John Blat <47202511+johnblat64@users.noreply.github.com>
2021-11-09 21:03:42 -08:00
Ryan C. Gordon
04f42e0468 metal: Deal better with -[CAMetalLayer nextDrawable] returning nil.
Fixes #4863.
2021-11-09 12:03:12 -05:00
Sam Lantinga
637bcd0b72 Fixed build warnings 2021-11-07 11:19:07 -08:00
Ivan Epifanov
848d7b1254 Vita: Implement command batching 2021-11-02 13:43:22 -07:00
Ivan Epifanov
3f7a94fc94 Vita: Remove FillRects 2021-11-02 13:43:22 -07:00
Northfear
fba82ad1cb Remove sceGxmFinish from RenderPresent on Vita. Make sure that rendering is finished on render texture during locking 2021-10-31 09:17:13 -04:00
Sylvain
4960cc3dcb
Fixed a few warnings 2021-10-25 16:18:40 +02:00
Sylvain
b793394590
SDL_Renderer: make clear that we use render geometry for fillrect/copy/copyex when there is no specific back-end implementation (currently software, PSP, directfb) 2021-10-25 13:46:40 +02:00
Ozkan Sezer
b3f9d8f38d remove unused local vars after the latest commits. 2021-10-25 07:05:50 +03:00
Sylvain
502e9c3b45 SDL_Renderer simplifications:
- Factorize PrepQueueCmdDraw{,DrawTexture,Solid) into one single function
- Change SDL_Texture/Renderer r,g,b,a Uint8 into an SDL_Color, so that it can be passed directly to RenderGeometry
- Don't automatically queue a SET_DRAW_COLOR cmd for RenderGeometry (and update GLES2 renderer)
2021-10-24 22:27:56 -04:00
Sylvain
79732c9d1e Remove FillRects from back-end, where RenderGeometry can be used 2021-10-24 22:27:56 -04:00
Sylvain
f02ad2820f Remove FillRects from back-end, where RenderGeometry can be used 2021-10-24 22:27:56 -04:00
Sylvain
70b10c753d Use correct indices when using RenderGeometry / FillRects 2021-10-24 22:27:56 -04:00
Sylvain
16beed9aeb Less code since color is constant when done with triangles 2021-10-24 22:27:56 -04:00
Sylvain
99a346439c OpenGLES2: LINES and POINTS successive commands are combined into a single draw call
(using the same case for DRAW_GEOMETRY)
2021-10-24 22:27:56 -04:00
Sylvain
f0cdc1d0f6 OpenGLES2: remove FillRects, since it's can be done with RenderGeometry 2021-10-24 22:27:56 -04:00
Sylvain
37c39d5cb4 Use geometry to implement FillRects 2021-10-24 22:27:56 -04:00
Sylvain
b0eef52fe1 GLES2 batching: probably need to check for blendMode changes 2021-10-24 22:27:56 -04:00
Sylvain
c27e1249e1 Remove SDL_HAVE_RENDER_GEOMETRY define 2021-10-24 22:27:56 -04:00
Sylvain
77026f673b Metal: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
0e5160a056 VITA: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
73f4ab4c13 Direct3D11: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
ab758398af Direct3D: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
1fe7e3616b OpenGL: a few opengl functions become unused 2021-10-24 22:27:56 -04:00
Sylvain
88548070a5 OpenGLES: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
d192515428 OpenGL: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
b92056bbea OpenGLES2: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
76f9fb96d9 Use RenderGeometry to implement RenderCopy and RenderCopyEx at higher level 2021-10-24 22:27:56 -04:00
Ryan C. Gordon
08797adaef opengles2: Attempt to batch RenderCopy calls into a single glDrawArrays call. 2021-10-24 22:27:56 -04:00
Sam Lantinga
b360965d0d Added a hint for alternate OpenGL NV12 data format 2021-10-21 20:48:05 -07:00
Sam Lantinga
a34fe8161f Added the ability to bind NV12 textures in the OpenGL renderer 2021-10-21 12:28:35 -07:00
Sylvain
f080273acd
PSP: add implementation for RenderGeometry 2021-10-04 22:01:11 +02:00
Sylvain
dd9b2daf8d
PSP: fixed build 2021-10-04 21:56:42 +02:00
Sylvain
77acd44f28
DirectFB: fixed creation of palette textures 2021-10-01 22:30:51 +02:00
Ryan C. Gordon
114d1d46ac
direct3d: Remove unnecessary render target support check.
Direct3D 9 dictates that caps.NumSimultaneousRTs must always be at least 1,
which is to say that Direct3D 9 level hardware must always support render
targets.

(caps.NumSimultaneousRTs is meant to show if you can draw to multiple render
targets in a single draw call.)

We had already hardcoded SDL_RENDERER_TARGETTEXTURE as available earlier in
the function anyhow.

Fixes #4781.
2021-09-27 23:18:25 -04:00
Northfear
14f225198d Use SDL_calloc for allocation of gxm_texture 2021-09-26 14:16:35 -07:00