darling-cocotron/QuartzCore/CALayerInternal.h
Ariel Abreu 55bafce1f1
Initial support for Metal layers and drawables
In its current state, I consider this code to be experimental and
unstable. The biggest problem is that there's currently a HUGE memory
leak somewhere (over 2GiB in under 5 seconds at 60fps). I'm committing
what I have now since I don't feel like debugging that right now and it
*does* technically work as-is.

The current approach is not great for performance: first, we render to a Metal/Vulkan
texture in the desired format then blit that to an RGBA Metal/Vulkan
texture shared with
OpenGL. Then, we copy *that* to another OpenGL texture in CAMetalLayer
to use as the content for the layer (we can't keep the drawable's OpenGL
texture, since that has to be recycled). Finally, this is rendered to a
subwindow by CARenderer/CALayerContext. We cannot get rid of the last copy
since we must render to the subwindow somehow and it's the easiest
way to play nice with sublayers. I also don't think we can get rid of the
first copy since OpenGL doesn't support some of Metal/Vulkan's texture
formats; plus, we can't share optimally tiled images between Vulkan and
OpenGL with some vendors' drivers (e.g. AMD).
We *could* get rid of the second copy if we were able to accurately
determine when the content is finally presented; then we could simply
keep the drawable in-use, render it to the subwindow when asked to, and
release it once we know the render is complete.
2023-04-06 10:04:49 -04:00

27 lines
907 B
Objective-C

/*
* This file is part of Darling.
*
* Copyright (C) 2022 Darling developers
*
* Darling is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Darling is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/
#import <QuartzCore/CALayer.h>
@interface CALayer (Internal)
- (void) _setContext: (CALayerContext *) context;
- (NSNumber *) _textureId;
- (void) _setTextureId: (NSNumber *) value;
@end