src/render/metal


Log

Author Commit Date CI Message
Sam Lantinga 3f1fd5ab 2023-05-23T10:59:03 Updated source to match SDL function prototype style
Sam Lantinga 0d763800 2023-03-09T15:10:00 Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!) (cherry picked from commit c6443d86c92e962683a1efe5f123a144988875b5)
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Sam Lantinga 3bdc6221 2022-12-01T15:11:29 Fixed Apple build after d0bbfdbfb881e5407911d84c12899bd5b442a130
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga 7b100001 2022-11-30T15:51:17 Reverted code formatting for Apple platforms We didn't get the merge right, and rather than tease out exactly what happened, I'm just reverting for now.
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sam Lantinga 70656b13 2022-11-15T10:18:41 Don't recreate the window when creating a Metal renderer on an OpenGL window. It turns out that we can safely create a Metal view on an existing window, and that avoids issues with the window being recreated with the wrong orientation in iOS 16. Fixes https://github.com/libsdl-org/SDL/issues/6289
Sam Lantinga 82b40f09 2022-09-16T09:55:20 Fixed runaway CPU usage in the metal renderer when the window is minimized
Sam Lantinga d744aafb 2022-09-15T01:00:12 Added support for simulated vsync in the renderer This kicks in if the platform doesn't support vsync directly, or if the present fails for some reason (e.g. minimized on some platforms) Fixes https://github.com/libsdl-org/SDL/issues/5134
Sylvain 90a480a1 2022-09-08T05:44:39 Fixed bug #6199 - Broken clip behaviour on a render target (metal)
Pierre Wendling 6c536afd 2022-06-27T15:43:17 Fix C89 declaration for macOS modules. Since Clang 14, `-Wdeclaration-after-statement` is enforced on every standard.
Alex Szpakowski ec8fa577 2022-05-07T21:57:23 macOS: always use Objective-C ARC (automatic ref counting). Change Cocoa SDL_VideoData and SDL_WindowData implementations from C structs to Objective-C objects, since bridging between C and ObjC is easier that way.
Sylvain Becker 3bebdacc 2022-03-15T10:37:17 METAL: clip rect w/h must be <= render pass
Ozkan Sezer bf698689 2022-03-10T01:55:04 reduced a few ifdefs, fixed an unused warning if built w/o SDL_HAVE_YUV.
pionere 3f8b450d 2022-02-05T12:22:34 extend the code hidden by SDL_HAVE_YUV
Sam Lantinga 18e4d9fe 2022-01-08T09:02:25 Re-enable line drawing path in render drivers This is still used for scaled line drawing in RenderDrawLinesWithRects()
Sylvain b88b6b3c 2022-01-07T22:43:12 Remove QueueDrawLines from METAL
Sam Lantinga 4b38d4c9 2022-01-07T12:37:28 Leave the Metal view active on the window when recreating the Metal renderer Fixes https://github.com/libsdl-org/SDL/issues/5140 Also move the metal tag definition to SDL_syswm.h so it can be used by applications
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Alex Szpakowski 3a5e148b 2021-12-14T11:02:07 Renderer backends use SDL_Color instead of int for geometry colors.
Sylvain 2a24418b 2021-11-23T09:44:37 More "Integer overflow generates Illegal instruction under sanitizers" (see bug #4995)
Ryan C. Gordon 04f42e04 2021-11-09T11:50:49 metal: Deal better with -[CAMetalLayer nextDrawable] returning nil. Fixes #4863.
Sam Lantinga 637bcd0b 2021-11-07T11:19:07 Fixed build warnings
Sylvain f02ad282 2021-09-25T11:31:18 Remove FillRects from back-end, where RenderGeometry can be used
Sylvain 77026f67 2021-09-20T17:09:44 Metal: remove RenderCopy and RenderCopyEx from back-end
Misa 4549769d 2021-03-07T15:20:45 Add `SDL_RenderSetVSync()` Currently, if an application wants to toggle VSync, they'd have to tear down the renderer and recreate it. This patch fixes that by letting applications call SDL_RenderSetVSync(). This is the same as the patch in #3673, except it applies to all renderers (including PSP, even thought it seems that the VSync flag is disabled for that renderer). Furthermore, the renderer flags also change as well, which #3673 didn't do. It is also an API instead of using hint callbacks (which could be potentially dangerous). Closes #3673.
Sylvain 54ca1d19 2021-08-27T07:44:03 SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600)
Sylvain a8f89a01 2021-04-23T12:00:14 Change 'size_indice' to 'size_indices'
Sylvain 47db47c1 2021-04-06T21:32:02 Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support
Sylvain Becker c6ceaaeb 2021-04-04T21:32:40 METAL: use Uchar4Normalized format to transfert color as 4 bytes, instead of 4 floats
Sylvain Becker 9f591707 2021-04-01T10:37:45 Update METAL backend for SDL_RenderGeometryRaw
Sylvain f73c1eff 2021-03-17T09:58:49 Use normalized texture coordinates
Sylvain 5828cc41 2021-03-16T21:54:27 Update METAL backend: fix a typo in drawline
Sylvain Becker 121114d0 2021-03-16T15:44:49 Update METAL compiled shaders
Sylvain Becker 2d01573b 2021-03-16T15:44:33 Add METAL shaders
Sylvain Becker 1e77dae7 2021-03-16T15:44:04 Add METAL implementation
Alex Szpakowski 9b9d0d48 2021-02-15T11:49:09 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.
Sam Lantinga 69e9b2ac 2021-02-01T22:35:46 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.
Sylvain Becker c0df40e0 2021-01-05T17:39:48 Add more SDL_HAVE_YUV defines
Sylvain Becker b0325041 2021-01-05T12:36:34 Fix unused variable warning on METAL (see bug #5430)
Sylvain Becker c1eb9ecf 2021-01-05T12:29:43 Add SDL_UpdateNVTexture for META (bug #5430) (not tested)
Sam Lantinga 393c8c1f 2021-01-03T10:32:55 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.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 7fa5e95b 2020-12-09T07:23:47 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).
Sam Lantinga cb361896 2020-12-09T07:16:22 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.
Sylvain Becker 754286c6 2020-12-02T13:45:24 SDL Renderer: specify the correct flag when recreating the window
Ryan C. Gordon 731a5d1c 2020-11-08T03:18:05 metal: Fix line drawing, again.
Ryan C. Gordon ba36eb04 2020-10-21T00:03:33 metal: Make line drawing match software renderer. Partially fixes Bugzilla #2711.
Ryan C. Gordon 061256a3 2020-10-07T14:45:24 metal: Clear the framebuffer if presenting without any other operations.
Ryan C. Gordon b7a4fdd3 2020-07-17T11:16:35 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.
Sam Lantinga 15294e21 2020-05-26T13:54:47 Fixed iOS build
Sam Lantinga f16e6bfa 2020-05-25T14:10:51 Fixed creating a metal renderer without specifying a metal window
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga 13155b35 2020-02-10T09:42:53 The scissor rect needs to be updated when the viewport changes in the Metal renderer
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 981e0d36 2020-01-16T08:52:59 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.
Ozkan Sezer ef3ca2cc 2019-12-23T19:55:10 Fix build error in SDL_render_metal.m (bug #4916.) Patch provided by Konrad. Error was introduced by commit 522164980828 for bug #4914.
Sam Lantinga 5e19e66c 2019-12-22T13:39:44 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.
Alex Szpakowski a9b867ab 2019-10-26T14:39:50 macOS Fix potential memory leaks in the Metal renderer caught by clang's static analyzer.
Alex Szpakowski 216f5b98 2019-10-17T18:48:58 metal: Fix compilation when using older Apple SDKs (bug #4828).
Alex Szpakowski bfdb0e97 2019-08-18T10:38:32 metal renderer: optimize SDL_RenderFillRect slightly.
Alex Szpakowski e8278d0d 2019-08-17T16:53:08 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.
Alex Szpakowski 55a46abf 2019-08-17T01:09:30 metal renderer: more closely match buffer data alignment requirements from the metal specification.
Alex Szpakowski e5acccc7 2019-08-17T00:37:22 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.
Alex Szpakowski 3fb5cabe 2019-08-16T22:13:30 metal: Update compiled shaders based on compilation script changes
Alex Szpakowski 9e57e3e5 2019-08-16T22:11:50 metal: Update shader compilation script with fixes for newer xcode versions and for running on older platforms
Alex Szpakowski aebaa316 2019-08-05T12:35:32 Add public APIs for creating a Metal view attached to an SDL window. Add SDL_metal.h.
Sam Lantinga 1213fe79 2019-06-14T13:56:42 Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Alex Szpakowski c7db6ade 2018-12-19T18:27:21 metal: Implement SDL_LockTexture for YUV formats.
Alex Szpakowski ce8c716a 2018-12-18T14:23:05 metal: Implement SDL_LockTexture for non-YUV textures.
Alex Szpakowski 37b1f989 2018-11-25T22:13:09 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.
Alex Szpakowski 872936a4 2018-11-21T23:46:37 metal: Fix an incorrect division.
Alex Szpakowski 4a58722b 2018-11-21T23:37:23 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.
Alex Szpakowski 244b79e1 2018-11-04T14:31:56 metal: SDL_RenderReadPixels on macOS synchronizes the render target's texture data if it's managed, before reading from it.
Alex Szpakowski c9fed272 2018-11-04T12:31:02 metal: fix the SDL_RENDERER_PRESENTVSYNC flag not being set on the renderer info on macOS, when vsync is used.
Alex Szpakowski c2bba9e4 2018-11-04T12:24:05 metal: fix the size of the buffer used for constant data.
Alex Szpakowski 457390fc 2018-11-01T20:24:21 metal: avoid an extra buffer allocation and GPU data copy in RunCommandQueue, it's not needed. Improves overall performance.
Alex Szpakowski 4e86dfd8 2018-11-01T19:49:01 metal: remove an obsolete section of a constant buffer.
Ryan C. Gordon 4659e738 2018-11-01T12:31:45 merge fallout: Patched to compile, fixed some compiler warnings, etc.
Ryan C. Gordon 62494a2e 2018-10-31T15:03:41 Merge SDL-ryan-batching-renderer branch to default.
Alex Szpakowski 8c41e262 2018-10-13T03:36:42 metal: Fix SDL_RenderReadPixels to wait for the GPU to finish rendering to the active texture before reading its pixels.
Alex Szpakowski d9094421 2018-10-12T17:55:42 metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250.
Ryan C. Gordon 208c4b03 2018-10-04T20:21:58 metal: CopyEx transform matrix must be aligned for constant buffer access.
Ryan C. Gordon 638d624f 2018-10-04T20:21:23 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.)
Ryan C. Gordon c01da217 2018-09-24T12:30:47 render: get rid of the predeclared functions in the GL and Metal renderers. (others to come as I continue to update render backends!)
Ryan C. Gordon 2241b33f 2018-09-23T23:22:56 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.
Ryan C. Gordon 8955fb9b 2018-09-20T16:40:04 render: First shot at moving metal backend over to new batching system.
Ryan C. Gordon 264b81b4 2018-09-06T00:56:13 metal: Make sure layer drawableSize is adjusted on resize. Fixes Bugzilla #4250.
Ryan C. Gordon 3634e563 2018-09-01T20:47:12 metal: SDL_UpdateYUVTexture shouldn't swap planes based on format.
Sam Lantinga eb14b635 2018-05-07T19:52:25 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.
Sam Lantinga 72d45079 2018-01-10T10:42:40 Added availability check to fix compiler warning for symbol only available on tvOS 11.0 and newer
Alex Szpakowski 7d5437bb 2018-01-07T22:00:37 metal: set max texture size based on device capability.
Alex Szpakowski a8c0532c 2018-01-07T16:57:32 metal: Fix pipeline states to use the pixel format of the current render target, instead of a hard-coded format.
Alex Szpakowski 740a90af 2018-01-06T18:54:12 metal: Add support for YUV/NV12 texture formats.
Alex Szpakowski 9a8683b2 2018-01-04T22:16:42 metal: use a private instead of managed buffer for the renderer's non-changing constant data. Recommended by Xcode's Metal frame capture analysis.
Alex Szpakowski 990ebba5 2018-01-04T19:29:33 metal: Implement fast hardware clearing when possible, by deferring the start of a render pass until a clear or draw operation happens.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Alex Szpakowski 888198ee 2018-01-03T00:43:01 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.