Make Metal an optional part of the build

See the corresponding commit in the main repo
This commit is contained in:
Ariel Abreu 2022-12-31 13:16:50 -05:00
parent 96122cff43
commit c449e7608e
No known key found for this signature in database
GPG Key ID: C06B805216EDEEED
4 changed files with 44 additions and 2 deletions

View File

@ -23,6 +23,9 @@
#import "CAMetalLayerInternal.h"
#import <QuartzCore/CAMetalLayer.h>
#import <Metal/MTLDeviceInternal.h>
#import <Metal/stubs.h>
#if DARLING_METAL_ENABLED
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
@ -825,3 +828,18 @@ static void glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severi
}
@end
#else
@implementation CAMetalDrawableInternal
@dynamic texture;
@dynamic layer;
@dynamic drawableID;
@dynamic presentedTime;
MTL_UNSUPPORTED_CLASS
@end
#endif

View File

@ -23,6 +23,8 @@
#import <OpenGL/gl.h>
#import <OpenGL/OpenGL.h>
#if DARLING_METAL_ENABLED
#include <indium/indium.private.hpp>
@class CAMetalLayerInternal;
@ -102,8 +104,12 @@ public:
void release();
void reset();
};
#endif
@interface CAMetalDrawableInternal : NSObject <CAMetalDrawable, MTLDrawableInternal> {
@interface CAMetalDrawableInternal : NSObject <CAMetalDrawable, MTLDrawableInternal>
#if DARLING_METAL_ENABLED
{
NSUInteger _drawableID;
CFTimeInterval _presentedTime;
std::shared_ptr<CAMetalDrawableActual> _drawable;
@ -114,5 +120,6 @@ public:
- (instancetype)initWithLayer: (CAMetalLayer*)layer
drawable: (std::shared_ptr<CAMetalDrawableActual>)drawable;
#endif
@end

View File

@ -23,6 +23,7 @@
#import <Foundation/NSRaise.h>
#import <Metal/MTLDeviceInternal.h>
#import <QuartzCore/CALayerContext.h>
#import <Metal/stubs.h>
#include <algorithm>
@ -40,6 +41,7 @@ static void reportGLErrors(void) {
@implementation CAMetalLayer
#if DARLING_METAL_ENABLED
// FIXME: this breaks inheritance from CAMetalLayer.
// the problem is that we need some C++ ivars, but we can't put those in the public header
// and this code needs to compile on 32-bit (so it can't use non-fragile ivars).
@ -55,6 +57,7 @@ static void reportGLErrors(void) {
return [super allocWithZone: zone];
}
}
#endif
- (id<MTLDevice>)device
{
@ -204,6 +207,8 @@ static void reportGLErrors(void) {
@implementation CAMetalLayerInternal
#if DARLING_METAL_ENABLED
@synthesize presentsWithTransaction = _presentsWithTransaction;
@synthesize displaySyncEnabled = _displaySyncEnabled;
@synthesize wantsExtendedDynamicRangeContent = _wantsExtendedDynamicRangeContent;
@ -590,4 +595,10 @@ static void reportGLErrors(void) {
}
}
#else
MTL_UNSUPPORTED_CLASS
#endif
@end

View File

@ -75,6 +75,12 @@ generate_sdk_framework(QuartzCore
HEADER "include/QuartzCore"
)
if (BUILD_METAL)
set(QUARTZCORE_LINK_INDIUM_PRIVATE indium_private)
else()
set(QUARTZCORE_LINK_INDIUM_PRIVATE "")
endif()
add_framework(QuartzCore
FAT
CURRENT_VERSION
@ -90,7 +96,7 @@ add_framework(QuartzCore
OpenGL
CoreGraphics
Metal_private
indium_private
${QUARTZCORE_LINK_INDIUM_PRIVATE}
cxx
LINK_FLAGS
" -Wl,-reexport_library,${CMAKE_BINARY_DIR}/src/frameworks/CoreImage/CoreImage \