Commit Graph

476 Commits

Author SHA1 Message Date
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
Sam Lantinga
5f0b2a7f54 Fixed resource leak with D3D11 NV12 textures 2021-01-01 11:12:22 -08:00
Sylvain Becker
590a5469ed Fixed bug 5424 - Renderer doesn't use entirely the viewport when scaling is used
Viewport/Clip dimensions are calculated usingg SDL_ceil whereas all renders use SDL_floor
2020-12-30 16:12:14 +01:00
Sylvain Becker
5dabc4d72f Revert changeset 14590 544ac819e8b3 , does not fully fix 2020-12-28 18:17:25 +01:00
Sylvain Becker
9efdafd43d SDL_RenderCopy: scale before doing intersection
this prevents drawing 1 pixel outside the screen, in letterbox mode
2020-12-28 18:07:03 +01:00
Sylvain Becker
f9b5f6cc0f Forward scale mode to SW renderer (Bug 5313) 2020-12-27 20:28:24 +01:00
Sam Lantinga
7fa5e95b62 Fixed bug 5213 - Add support to metal in iOS/tvOS simulator
Vincent Hamm

Xcode11 and ios13 added support for metal simulator.
Here is a quick and dirty patch to enable it. Pretty early and only tested on a few samples for now. Required mostly to enable metal support on correct version of ios, generate simulator compatible shaders and enforce buffer alignments on simulator (same as osx).
2020-12-09 07:23:47 -08:00
Sam Lantinga
cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Sam Lantinga
88cb4962cd Fixed bug 5291 - SDL_SetRenderTarget unnecessarily changes target when current target is the native texture of the passed in texture 2020-12-09 06:42:31 -08:00
Sylvain Becker
754286c61c SDL Renderer: specify the correct flag when recreating the window 2020-12-02 13:45:24 +01:00
Ryan C. Gordon
0e4ce84801 opengl: Make diagonal lines match the software renderer.
OpenGL leaves the final line segment open, SDL's software renderer does not,
so we need a tiny bit of trigonometry here to move one more pixel in the right
direction.
2020-11-08 20:57:17 -05:00
Ryan C. Gordon
da49f79500 opengles: use glDrawArrays() correctly with GL_LINE_STRIP. 2020-11-08 19:56:12 -05:00
Ryan C. Gordon
93a2c58c7e opengl: Use GL_LINE_STRIP instead of breaking down into seperate GL_LINES.
Surely GL drivers have improved in the last seven years. I hope...?
2020-11-08 12:37:09 -05:00
Ryan C. Gordon
731a5d1c53 metal: Fix line drawing, again. 2020-11-08 03:18:05 -05:00
Ryan C. Gordon
ba36eb0437 metal: Make line drawing match software renderer.
Partially fixes Bugzilla #2711.
2020-10-21 00:03:33 -04:00
Ryan C. Gordon
c33f808354 render: Restoring line rendering fixes that were previously put on hold.
(Backed out hg changeset 7a4240daba46)
2020-10-20 11:12:49 -04:00
Ryan C. Gordon
061256a3b3 metal: Clear the framebuffer if presenting without any other operations. 2020-10-07 14:45:24 -04:00
Ryan C. Gordon
a720d1a294 render: fixes to how we convert touch events for logical scaling.
We now handle HiDPI correctly, and touches are clamped to the viewport. So
if you are rendering to a logical 640x480 in a 720p window, and touch the
letterboxing at point (640,700), it will report the touch at (0.5,1.0) instead
of outside the documented range.
2020-08-09 00:55:39 -04:00
Ryan C. Gordon
b7a4fdd318 metal: Make sure we have a command buffer available before trying to present.
This fixes a case where you render to the backbuffer, then render to a render
target, set the current target back to the backbuffer, and then present
without drawing anything else; in this circumstance, the Present command
would never happen.

Fixes Bugzilla #5011.
2020-07-17 11:16:35 -04:00
Sam Lantinga
15294e2121 Fixed iOS build 2020-05-26 13:54:47 -07:00
Sam Lantinga
f16e6bfa8e Fixed creating a metal renderer without specifying a metal window 2020-05-25 14:10:51 -07:00
Sylvain Becker
39690a0478 Fix static analysis warning in SDL_render.c 2020-05-15 21:33:47 +02:00
Ryan C. Gordon
a96d8a4355 render: Fixed compiler warning about implicit cast. 2020-04-13 22:05:36 -04:00
hmk
0918903f3c render: add a hint for toggling relative scaling
Fixes Bugzilla #4811.
2019-09-30 22:54:16 +03:00
hmk
aa188048f1 render: Scale relative mouse motion better for logical sizing
From hmk:

"When scaling is enabled (e.g. via SDL_RenderSetLogicalSize, size not equal
to window size), mouse motion events are also scaled.  Small motions are
rounded up (SDL_max() when the value after scaling is less than 1), while
larger motions are truncated by the floating point -> integer conversion.

https://hg.libsdl.org/SDL/file/b18197f9bf9d/src/render/SDL_render.c#l658

The end result feels something like mouse reverse mouse acceleration + angle
snapping at low speeds, but less consistent (amount of truncation & rounding
depends on how fast the mouse is moved) and potentially much worse if the
scaling factor is large.  This pretty much makes it useless for anything
where you need precise mouse aiming (think of games).  I suspect this is why
aiming gets so terrible in some games that let you use scaling to reduce the
render resolution (e.g. Ion Fury).

With 4x4 scaling, I can reproduce a situation where it takes three fast flicks
of the mouse across the pad to undo one slow sweep across the pad.  In other
words, extreme reverse acceleration.  This does not happen when scaling is
disabled.

Furthermore, any game that uses relative mouse motion events for 3D camera
rotation probably wants the raw mouse deltas and not a value that depends on
scaling and resolution and rounding and truncation.  Ideal camera rotation
just takes mouse input, multiplies it by sensitivity, and adds it to the
angle-in-radians or whatever measure is used for yaw & pitch.  Pixels and
screen resolution or window dimensions should not be a part of the equation
at all, even if it could be implemented without rounding errors.

[...]

This [patch] completely eliminates angle snapping for me, and makes
sensitivity consistent.  In other words, it's completely usable for, say,
aiming in a first person shooter."

Partially fixes Bugzilla #4811.
2020-04-10 12:23:08 -04:00
Sam Lantinga
b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
Sam Lantinga
d4b561f472 Fixed bug 5015 - SDL_RenderReadPixels on DirectX 11.1 backend seems to be broken
Konrad

It appears that I cannot use SDL_RenderReadPixels on a bound framebuffer (SDL_Texture set as render target) as it simply results in gibberish data. However, drawing that framebuffer into the default target (window surface) does render it correctly. Other backends (OpenGL, software, Direct3D) do work fine.

It looks to me like D3D11_RenderReadPixels just gets the general backbuffer and not the current render target and its backbuffer.

Here is the patch which actually fetches the current render target and its underlying ID3D11Resource which is ID3D11Texture2D.
2020-04-05 08:58:47 -07:00
Ryan C. Gordon
19a5f4ab5d opengl: Don't enable/disable texturing except when actually rendering.
Otherwise our cached state goes out of sync when updating a texture. Since
these state changes aren't necessary, they were removed instead of updating
the cached state.

Fixes Bugzilla #4998.
2020-03-22 14:32:47 -04:00
Sylvain Becker
e6189f4046 Fix warnining implicit declaration of SDL_DetectPalette (Thanks meyraud705) 2020-03-17 15:47:30 +01:00
Sylvain Becker
838bbf1f7a Fixed bug 5037 - Regression 2.0.12 Alpha value of 0 on palette may become opaque
(see also bug 3827)
2020-03-17 09:35:42 +01:00
Sam Lantinga
c8c05a9fc3 Fixed bug 4991 - Pixel shader problem when recreating a texture for direct3d renderer
cmediaplayer

Hi, i already mentioned in the SDL discourse a bug that recreating of a texture occours pixel shader problem on direct3d renderer. There is no problem for direct3d11. You can see the issue by using my app named C Media Player which is available for Windows for free using my web site www.cmediaplayer.com. Just follow the steps:

*Open a media file
*When playing the file change the scale quality under the video menu.
*You will see the problem.
2020-03-08 19:23:21 -07:00
Sam Lantinga
367a356132 Don't release the backbuffer on error, we didn't acquire it. 2020-03-08 18:56:07 -07:00
Cameron Gutman
e152a3cedb direct3d: Don't attempt to create zero sized vertex buffer 2020-03-07 13:59:42 -08:00
Sylvain Becker
9a7c2b2246 Fixed bug 4999 - Palette surface always promoted to alpha (Thanks Cameron Gutman!)
MSVC Static analysis: Incorrect alpha_value check in SDL_render.c
(see also bug 4425)
2020-02-23 09:59:52 +01:00
Ryan C. Gordon
93b26f172c opengl: Backed out hg changeset 94f9f40a957f
This is the OpenGL line drawing fix for Bugzilla #3182, but there's some
disagreement about what the renderers should do here, so I'm backing this out
until after 2.0.12 ships, and then we'll reevaluate all the renderer backends
to decide what's correct, and make them all work the same.
2020-02-17 16:15:04 -05:00
Sam Lantinga
6ec14b7fda Fixed iOS and Android build 2020-02-11 16:23:43 -08:00
Ryan C. Gordon
ed10d9473f 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
13155b35b4 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
b5849daf3e Fixed build warnings on Android 2020-02-01 09:23:04 -08:00
Sam Lantinga
b5e3d264f2 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
7df22cf2c2 A few #defines to reduce SDL2 footprint.
Only applied when library is statically linked
2020-01-21 21:33:40 +01:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
981e0d367c 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