Commit graph

696 commits

Author SHA1 Message Date
Sam Lantinga
4ad10528f2 Fixed bug 4469 - make SDL_CreateTextureFromSurface pick a more appropriate format
Sylvain

Currently SDL_CreateTextureFromSurface picks first valid format, and do a conversion.

    format = renderer->info.texture_formats[0];
    for (i = 0; i < renderer->info.num_texture_formats; ++i) {
        if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) &&
            SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
            format = renderer->info.texture_formats[i];
            break;

It could try to find a better format, for instance :

 if SDL_Surface has no Amask, but a colorkey :
   if surface fmt is RGB888, try to pick ARGB8888 renderer fmt
   if surface fmt is BGR888, try to pick ABGR8888 renderer fmt
 else
   try to pick the same renderer format as surface fmt

if no format has been picked, use the fallback.


I think it goes with bug 4290 fastpath BlitNtoN
when you expand a surface with pixel format of size 24 to 32, there is a fast path possible.


So with this issue:

- if you have a surface with colorkey (RGB or BGR, not palette), it takes a renderer format where the conversion is faster.
  (it avoids, if possible, RGB -> ABGR which means switching RGB to BGR)

- if you have a surface ABGR format, it try to take the ABGR from the renderer.
  (it avoids, if possible, ABGR -> ARGB, which means switch RGB to BGR)
2019-05-19 12:04:06 -07:00
Sam Lantinga
322af82c04 Fixed bug 4025 - SDL_Renderer OpenGL : add support for textures ABGR, RGB, BGR
Sylvain

OpenGLES2 SDL renderer has support for textures ARGB, ABGR, RGB and BGR, whereas OpenGL SDL renderer only had ARGB.

If you think it's worth adding it, here's a patch. I quickly tried and it worked, but there may be missing things or corner case.
2019-05-19 11:01:36 -07:00
Sylvain Becker
9e9ef0bf36 Fixed bug 4582 - Maximize/Resize not working on Windows 10
When viewport is set, projectionAndView changes, but ID3D11DeviceContext_UpdateSubresource was not called.
2019-04-08 13:43:48 +02:00
Ryan C. Gordon
abdc48613d opengles2: Fix static analysis warning.
Not clear if this could ever dereference NULL in real life, but better safe
than sorry!
2019-03-21 10:39:49 -04:00
Sam Lantinga
2085fa0bd7 Fixed Windows RT build 2019-03-19 16:52:09 -07:00
Sylvain Becker
d12de4fc50 Fixed bug 4542 - Image flipped vertically when rendering on texture
Have to recompute  viewport because projection/glOrtho is different
wether rendering is on target texture or not
2019-03-12 07:59:53 +01:00
Ryan C. Gordon
3fa93ed3dc opengles2: patched to compile. 2019-02-04 23:35:18 -05:00
Ryan C. Gordon
32548976b8 opengles2: keep cached texturing state correct. 2019-02-04 23:32:28 -05:00
Ryan C. Gordon
bccc72020f opengles1: keep cached texturing state correct. 2019-02-04 23:24:10 -05:00
Ryan C. Gordon
b11d50936e render: Fix OpenGL draw state cache for various points of texture binding. 2019-02-04 18:55:39 -05:00
Sylvain Becker
4deb7ba850 Fixed bug 3657 - Color-key doesn't work when an alpha channel is present
When surface format is the same as renderer format, it still needs an
intermediate conversion to transform colorkey to alpha.
2019-01-19 16:47:43 +01:00
Sylvain Becker
c8cb2daffe Fixed bug 4453 - GLES / GLES2: first white renderer clear cmd is drawn as black 2019-01-12 13:34:03 +01:00
Sam Lantinga
af32a2f4cd Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sylvain Becker
15b1ff73c6 PSP renderer: use colors from 'draw' union (very likely, but un-tested) 2018-12-29 17:59:34 +01:00
Sylvain Becker
5cc44ad65c opengles 1: same fix as in bug #4433 2018-12-29 16:37:44 +01:00
Sylvain Becker
428e686eb6 opengles 1: use color from 'draw' union in SetDrawState() 2018-12-29 16:34:50 +01:00
Alex Szpakowski
15167c21db render: Fix internal state getting out of sync when destroying a texture that was just rendered and then creating a new one, in the GL and GLES2 backends. Fixes bug #4433. 2018-12-21 20:53:31 -04:00
Ryan C. Gordon
48cef1d6ac render: Prefer the Metal renderer over OpenGL.
This is the best option for macOS and iOS, the only platforms with Metal.

Pre-Metal versions of these platforms will fall back to OpenGL (ES), as
appropriate.

Huge thanks to Alexander Szpakowski, who worked incredibly hard to get the
Metal renderer to such a high-quality state!
2018-12-19 18:10:02 -05:00
Alex Szpakowski
6415608dec metal: Implement SDL_LockTexture for YUV formats. 2018-12-19 18:27:21 -04:00
Alex Szpakowski
bb030d3919 metal: Implement SDL_LockTexture for non-YUV textures. 2018-12-18 14:23:05 -04:00
Sylvain Becker
e473386e11 Fixed bug 4425 - promote to alpha format, palette surface with alpha values.
SDL_CreateTextureFromSurface() forgets to choose a texture format with alpha for
surfaces that have palettes with alpha values.
2018-12-15 14:50:12 +01:00
Sylvain Becker
a34c583513 opengles2: fix prototype of glDeleteBuffers 2018-12-06 10:24:44 +01:00
Sylvain Becker
c98ec32e0e Fix warnings detected on Android build 2018-12-06 09:22:00 +01:00
Sylvain Becker
56c63a1dac Warnings: fix a documentation warning and missing prototypes 2018-12-05 16:13:12 +01:00
Ryan C. Gordon
620f5429c4 direct3d: be more aggressive about resetting invalidated cached state.
Fixes Bugzilla #4402.
2018-12-03 09:26:05 -05:00
Ryan C. Gordon
0cf5b6222c render: fix some static analysis warnings. 2018-12-03 02:06:17 -05:00
Ryan C. Gordon
4c72dd1b02 direct3d: Make sure streaming textures update before being used for drawing.
Fixes Bugzilla #4402.
2018-12-03 01:58:23 -05:00
Ryan C. Gordon
a9b658ab1c Patched to compile on C89 compilers. 2018-12-02 21:57:33 -05:00
Ryan C. Gordon
e7b0e3e1b5 direct3d: Release and NULL out vertex buffers on reset.
Otherwise they are irretrievably lost on window resize, etc, which makes
rendering freeze and other disasters.

Fixes Bugzilla #4358.
2018-12-02 20:55:57 -05:00
Alex Szpakowski
f8efb8361a metal: use a staging texture in SDL_UpdateTexture, to make sure it doesn't stomp texture data being drawn in a previous frame on the GPU. 2018-11-25 22:13:09 -04:00
Alex Szpakowski
eaa6a12822 metal: Fix an incorrect division. 2018-11-21 23:46:37 -04:00
Alex Szpakowski
52adb7e81e metal: SDL_RenderFillRects uses one draw call per 16k rectangles (within the given FillRects call), instead of one draw call per rectangle. Reduces CPU usage when drawing many rectangles.
--HG--
extra : amend_source : 1b39afd4eaa31c151f607e4685f079a46fa6238c
2018-11-21 23:37:23 -04:00
Ryan C. Gordon
7ce155694c opengles: Fixed compiler warnings.
--HG--
extra : rebase_source : aef63cc80f39c9351ca39fe0c24e4f4e78bbf5d1
2018-11-17 16:24:52 -05:00
Sam Lantinga
e1d71b88e1 Back out change initializing renderer blend mode incorrectly. 2018-11-17 12:12:29 -08:00
Ryan C. Gordon
b13e7d9f99 direct3d11: Fixed missing rendering of solid primitives.
Fixes Bugzilla #4388.
2018-11-17 14:39:42 -05:00
Ryan C. Gordon
5186bd4a84 Fixed a few compiler warnings. 2018-11-17 14:37:51 -05:00
Sam Lantinga
f1b7d53e6c The default draw blendmode is SDL_BLENDMODE_NONE 2018-11-17 00:58:45 -08:00
Ryan C. Gordon
8cac51aa90 software: fix blits with color mods that change during a command queue run.
--HG--
extra : rebase_source : f1b4087bb0bbf8955a9d418158b28b066ae79402
2018-11-14 22:38:58 -05:00
Alex Szpakowski
afbbecdd0a metal: SDL_RenderReadPixels on macOS synchronizes the render target's texture data if it's managed, before reading from it. 2018-11-04 14:31:56 -04:00
Alex Szpakowski
f6643dadd7 metal: fix the SDL_RENDERER_PRESENTVSYNC flag not being set on the renderer info on macOS, when vsync is used. 2018-11-04 12:31:02 -04:00
Alex Szpakowski
e82b90e740 metal: fix the size of the buffer used for constant data. 2018-11-04 12:24:05 -04:00
Alex Szpakowski
dbdf655d67 metal: avoid an extra buffer allocation and GPU data copy in RunCommandQueue, it's not needed. Improves overall performance. 2018-11-01 20:24:21 -03:00
Alex Szpakowski
f2a29eea94 metal: remove an obsolete section of a constant buffer. 2018-11-01 19:49:01 -03:00
Ozkan Sezer
eb11815341 fix build using Watcom :
./src/render/SDL_render.c(2168): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2168): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2175): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2175): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant

./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
2018-11-01 20:04:24 +03:00
Ryan C. Gordon
2b3489261e merge fallout: Patched to compile, fixed some compiler warnings, etc.
--HG--
extra : amend_source : db5107c02c210087f25dea7f0407d09be10e24ba
2018-11-01 12:31:45 -04:00
Ryan C. Gordon
9f99a9c642 Merge SDL-ryan-batching-renderer branch to default.
--HG--
extra : rebase_source : 83b86d35497a01be6f48055490580bbba19ccc7a
extra : amend_source : faae1a04859499ede43aba3ba50fc4f62b5afbcb
2018-10-31 15:03:41 -04:00
Ryan C. Gordon
538f2f7649 render: Add floating point versions of various draw APIs.
--HG--
branch : SDL-ryan-batching-renderer
2018-10-23 01:34:03 -04:00
Cameron Gutman
030c9068a7 Fix crash when GL_LoadFunctions()/GLES2_LoadFunctions() fails
https://bugzilla.libsdl.org/show_bug.cgi?id=4350

We can't safely call GL_DestroyRenderer() until GL_LoadFunctions()
succeeds because we will be missing functions that we try to use
when activating the renderer for destruction if we have an GL context.
2018-10-31 20:17:53 -07:00
Sam Lantinga
8561b13616 Fixed bug 4188 - Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
Sylvain

Re-opening this issue.

It fixes the test-case, but it introduces a regression with another bug (bug #4313).

So here's a new patch that activate cropping of the source surface to solve the issue.
It also reverts the wrong changeset.
It prevents unneeded colorkey error message.
2018-10-30 07:00:03 -07:00
Michał Janiszewski
fee5c91f4a Add and update include guards
Include guards in most changed files were missing, I added them keeping
the same style as other SDL files. In some cases I moved the include
guards around to be the first thing the header has to take advantage of
any possible improvements compiler may have for inclusion guards.
2018-10-28 21:36:48 +01:00