src/render/metal/SDL_render_metal.m


Log

Author Commit Date CI Message
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 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.
Alex Szpakowski f9cd7650 2018-01-02T21:44:28 metal and moltenvk: fix highdpi.
Sam Lantinga b3b5c473 2018-01-02T14:32:15 Fixed direction of y adjustment for new orthographic projection in the metal renderer
Sam Lantinga fa86807c 2018-01-02T14:11:10 Fixed metal renderer pixel centers when drawing
Alex Szpakowski 07f08b47 2018-01-01T23:06:08 metal: Fix a typo preventing iOS compilation...
Alex Szpakowski 1cc66033 2018-01-01T23:03:50 metal: Clean up manual reference counting. Fixes some memory leaks.
Alex Szpakowski a452a084 2018-01-01T19:40:29 iOS: fix build
Alex Szpakowski 639ea9fd 2018-01-01T19:37:16 metal: Use sampler state objects instead of shader-declared samplers for linear vs nearest filtering. This avoids a ton of shader duplication once multiple shaders that use samplers are added (e.g. the currently missing YUV shaders).
Alex Szpakowski cf45cf70 2018-01-01T18:06:27 metal: Add support for custom blend modes.
Alex Szpakowski 85470a2f 2017-12-31T21:06:16 metal: implement SDL_RenderCopyEx, and fix a memory leak in SDL_CreateTexture.
Alex Szpakowski 047d387b 2017-12-31T15:30:08 metal: Use the existing cocoa code for creating a Metal view on macOS. Fixes the renderer size when the window is resized.
Alex Szpakowski 42b19c97 2017-12-30T22:39:55 metal: Respect the vsync flag on macOS 10.13+.
Alex Szpakowski e24dc905 2017-12-30T20:32:22 metal: use a projection matrix instead of manually transforming vertices into clip space on the CPU.
Alex Szpakowski 49df65c2 2017-12-30T18:48:07 metal: only 4 (instead of 5) vertices are needed to draw rectangles and textures, and only 3 (instead of 5) vertices are needed to cover the screen for the 'full-screen quad' when clearing.
Sam Lantinga 7ac46a74 2017-12-11T11:34:53 The newer compilers generate the property boilerplate automatically
Sam Lantinga 358e4d9c 2017-12-11T11:02:51 Fixed Mac OS X build
Sam Lantinga c2cc9c16 2017-12-09T19:48:38 Backed out using pixel texture coordinates, it had weird visual side effects
Sam Lantinga 8aad4923 2017-12-09T19:41:08 Fixed normalized coordinates when the viewport is set
Sam Lantinga 441d3095 2017-12-09T15:00:41 Added support for linear sampling and pixel coordinates in the metal renderer
Sam Lantinga f55c9988 2017-12-09T12:58:41 Fixed pixel positioning and size for the Metal renderer
Ryan C. Gordon 7dac177c 2017-12-09T03:28:23 metal: fixed render target support.
Ryan C. Gordon 85d12d8f 2017-12-09T03:27:52 metal: Added some comments and FIXMEs.
Ryan C. Gordon 686fc093 2017-12-08T18:26:26 metal: Cleaned up some reference count politics.
Sam Lantinga cf3d4503 2017-12-08T14:30:10 Added SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder()
Sam Lantinga c403c0fa 2017-12-08T13:20:20 Fixed Metal renderer memory leak
Sam Lantinga b733dcc2 2017-12-08T12:02:23 Minor cleanup
Sam Lantinga 5182c23c 2017-12-08T11:35:19 Fixed minor memory leak in the Metal renderer
Ryan C. Gordon 81a33985 2017-12-08T14:03:36 metal: Don't check if Metal is available if targeting modern macOS versions.
Sam Lantinga dc04f290 2017-12-08T08:58:02 Defer getting the next drawable until we actually start rendering This works better for games where there may be a bunch of simulation logic that needs to be run before the next rendering pass, and prevents blocking if the next drawable is busy.
Sam Lantinga 104decd1 2017-12-07T18:08:51 Fixed runtime errors on iOS
Sam Lantinga ba9c336e 2017-12-07T17:47:01 Fixed building for simulators or older iOS SDKs
Sam Lantinga 6deb1e75 2017-12-07T17:12:03 Fixed compiling Metal renderer on iOS
Sam Lantinga b2859af6 2017-12-07T16:08:09 Enable building the Metal renderer by default, and weak link the Metal framework so the SDL library is safe to use on older Macs Also generate iOS versions of the Metal shaders
Ryan C. Gordon 2a2c8d42 2016-04-21T03:16:44 Initial shot at a renderer target for Apple's Metal API. This isn't complete, but is enough to run testsprite2. It's currently Mac-only; with a little work to figure out how to properly glue in a Metal layer to a UIView, this will likely work on iOS, too. This is only wired up to the configure script right now, and disabled by default. CMake and Xcode still need their bits filled in as appropriate.