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
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
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
Ozkan Sezer
ef3ca2cc46
Fix build error in SDL_render_metal.m (bug #4916.)
...
Patch provided by Konrad. Error was introduced by commit 522164980828 for bug #4914 .
2019-12-23 19:55:10 +03:00
Sam Lantinga
5e19e66c73
Fixed bug 4914 - Expose SDL_ScaleMode and add SDL_SetTextureScaleMode/SDL_GetTextureScaleMode
...
Konrad
This was something rather trivial to add, but asked at least several times before (I did google about it as well).
It should be possible to dynamically change scaling mode of the texture. It is actually trivial task, but until now it was only possible with a hint before creating a texture.
I needed it for my game as well, so I took the liberty of writing it myself.
This patch adds following functions:
SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode);
SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode);
That way you can change texture scaling on the fly.
2019-12-22 13:39:44 -08:00
Alex Szpakowski
a9b867ab07
macOS Fix potential memory leaks in the Metal renderer caught by clang's static analyzer.
2019-10-26 14:39:50 -03:00
Alex Szpakowski
216f5b98ac
metal: Fix compilation when using older Apple SDKs (bug #4828 ).
2019-10-17 18:48:58 -03:00
Alex Szpakowski
bfdb0e9743
metal renderer: optimize SDL_RenderFillRect slightly.
2019-08-18 10:38:32 -03:00
Alex Szpakowski
e8278d0d5b
metal renderer: use vertex attributes instead of indexing into a buffer with the vertex id in the shader. Allows for more flexibility with vertex setup in the future.
...
Also optimize vertex buffer binding slightly.
2019-08-17 16:53:08 -03:00
Alex Szpakowski
55a46abf0a
metal renderer: more closely match buffer data alignment requirements from the metal specification.
2019-08-17 01:09:30 -03:00
Alex Szpakowski
e5acccc7c3
metal renderer: use the device address space instead of the constant address space for colors.
...
It doesn't negatively impact GPU performance in my tests, and it removes the need for 256 byte memory alignment of color data on macOS.
2019-08-17 00:37:22 -03:00
Alex Szpakowski
3fb5cabe5e
metal: Update compiled shaders based on compilation script changes
2019-08-16 22:13:30 -03:00
Alex Szpakowski
9e57e3e595
metal: Update shader compilation script with fixes for newer xcode versions and for running on older platforms
2019-08-16 22:11:50 -03:00
Alex Szpakowski
aebaa316c7
Add public APIs for creating a Metal view attached to an SDL window. Add SDL_metal.h.
2019-08-05 12:35:32 -03:00
Sam Lantinga
1213fe79d8
Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta
2019-06-14 13:56:42 -07:00
Sam Lantinga
5e13087b0f
Updated copyright for 2019
2019-01-04 22:01:14 -08:00
Alex Szpakowski
c7db6ade7d
metal: Implement SDL_LockTexture for YUV formats.
2018-12-19 18:27:21 -04:00
Alex Szpakowski
ce8c716ada
metal: Implement SDL_LockTexture for non-YUV textures.
2018-12-18 14:23:05 -04:00
Alex Szpakowski
37b1f989ce
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
872936a485
metal: Fix an incorrect division.
2018-11-21 23:46:37 -04:00
Alex Szpakowski
4a58722b9f
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.
2018-11-21 23:37:23 -04:00
Alex Szpakowski
244b79e194
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
c9fed27289
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
c2bba9e448
metal: fix the size of the buffer used for constant data.
2018-11-04 12:24:05 -04:00
Alex Szpakowski
457390fcf8
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
4e86dfd8d1
metal: remove an obsolete section of a constant buffer.
2018-11-01 19:49:01 -03:00
Ryan C. Gordon
4659e73892
merge fallout: Patched to compile, fixed some compiler warnings, etc.
2018-11-01 12:31:45 -04:00
Ryan C. Gordon
62494a2e27
Merge SDL-ryan-batching-renderer branch to default.
2018-10-31 15:03:41 -04:00
Ryan C. Gordon
208c4b0361
metal: CopyEx transform matrix must be aligned for constant buffer access.
2018-10-04 20:21:58 -04:00
Ryan C. Gordon
638d624f5a
metal: Don't try to create a zero-byte vertex buffer.
...
(Which will cause a crash in Metal, or an assert in the validation layer.)
2018-10-04 20:21:23 -04:00
Ryan C. Gordon
c01da21756
render: get rid of the predeclared functions in the GL and Metal renderers.
...
(others to come as I continue to update render backends!)
2018-09-24 12:30:47 -04:00
Ryan C. Gordon
2241b33f55
render: Update Metal and GL backends to use new high-level features, etc.
...
Now nothing is uploaded as dynamic data with Metal's setVertexBytes, etc; it's
all in the one big vertex buffer, now.
2018-09-23 23:22:56 -04:00
Ryan C. Gordon
8955fb9b31
render: First shot at moving metal backend over to new batching system.
2018-09-20 16:40:04 -04:00
Ryan C. Gordon
264b81b481
metal: Make sure layer drawableSize is adjusted on resize.
...
Fixes Bugzilla #4250 .
2018-09-06 00:56:13 -04:00
Ryan C. Gordon
3634e563c4
metal: SDL_UpdateYUVTexture shouldn't swap planes based on format.
2018-09-01 20:47:12 -04:00
Alex Szpakowski
8c41e2624e
metal: Fix SDL_RenderReadPixels to wait for the GPU to finish rendering to the active texture before reading its pixels.
2018-10-13 03:36:42 -03:00
Alex Szpakowski
d9094421e1
metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250 .
2018-10-12 17:55:42 -03:00
Sam Lantinga
eb14b635cd
Fixed bug 4134 - Render targets lose scale quality after minimizing a fullscreen window
...
Olli-Samuli Lehmus
If one creates a window with the SDL_WINDOW_FULLSCREEN_DESKTOP flag, and creates a render target with SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"), and afterwards sets SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"), after minimizing the window, the scale quality hint is lost on the render target. Textures however do keep their interpolation modes.
2018-05-07 19:52:25 -07:00
Sam Lantinga
72d4507918
Added availability check to fix compiler warning for symbol only available on tvOS 11.0 and newer
2018-01-10 10:42:40 -08:00
Alex Szpakowski
7d5437bb31
metal: set max texture size based on device capability.
2018-01-07 22:00:37 -04:00
Alex Szpakowski
a8c0532c08
metal: Fix pipeline states to use the pixel format of the current render target, instead of a hard-coded format.
2018-01-07 16:57:32 -04:00
Alex Szpakowski
740a90af37
metal: Add support for YUV/NV12 texture formats.
2018-01-06 18:54:12 -04:00
Alex Szpakowski
9a8683b275
metal: use a private instead of managed buffer for the renderer's non-changing constant data.
...
Recommended by Xcode's Metal frame capture analysis.
2018-01-04 22:16:42 -04:00
Alex Szpakowski
990ebba55a
metal: Implement fast hardware clearing when possible, by deferring the start of a render pass until a clear or draw operation happens.
2018-01-04 19:29:33 -04:00
Sam Lantinga
e3cc5b2c6b
Updated copyright for 2018
2018-01-03 10:03:25 -08:00
Alex Szpakowski
888198ee31
metal: Misc. improvements.
...
- Use a single buffer for various non-changing constants accessed by the GPU, instead of multiple buffers.
- Do the half-pixel offset for points and lines using a transform matrix so we don't need a malloc when rendering.
- Don't add a half-pixel offset for other primitives and textures. This matches D3D and GL render behaviour.
- Remove the half-texel texture coordinate offset since it's not needed now that there's no more half-pixel position offset when rendering a texture.
- Don't try to set texture usage on iOS 8 since it doesn't exist there.
2018-01-03 00:43:01 -04:00
Alex Szpakowski
f9cd765020
metal and moltenvk: fix highdpi.
2018-01-02 21:44:28 -04:00
Sam Lantinga
b3b5c47366
Fixed direction of y adjustment for new orthographic projection in the metal renderer
2018-01-02 14:32:15 -08:00
Sam Lantinga
fa86807ceb
Fixed metal renderer pixel centers when drawing
2018-01-02 14:11:10 -08:00