Skip to content

Commit

Permalink
Metal compile fixes when compiling with MacOS SDK 14 (Xcode 15)
Browse files Browse the repository at this point in the history
Update wrapped protocols to match MacOS SDK 14 declarations
  • Loading branch information
Zorro666 committed Sep 30, 2023
1 parent f36d8a3 commit a60412d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 6 deletions.
39 changes: 34 additions & 5 deletions renderdoc/driver/metal/metal_device_bridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ - (void)forwardInvocation:(NSInvocation *)invocation
}

// MTLDevice : based on the protocol defined in
// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h
// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h

- (NSString *)name
{
Expand All @@ -78,6 +78,13 @@ - (uint64_t)registryID API_AVAILABLE(macos(10.13), ios(11.0))
return self.real.registryID;
}

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (MTLArchitecture *)architecture API_AVAILABLE(macos(14.0), ios(17.0))
{
return self.real.architecture;
}
#endif

- (MTLSize)maxThreadsPerThreadgroup API_AVAILABLE(macos(10.11), ios(9.0))
{
return self.real.maxThreadsPerThreadgroup;
Expand All @@ -103,8 +110,7 @@ - (BOOL)hasUnifiedMemory API_AVAILABLE(macos(10.15), ios(13.0))
return self.real.hasUnifiedMemory;
}

- (uint64_t)recommendedMaxWorkingSetSize API_AVAILABLE(macos(10.12), macCatalyst(13.0))
API_UNAVAILABLE(ios)
- (uint64_t)recommendedMaxWorkingSetSize API_AVAILABLE(macos(10.12), macCatalyst(13.0), ios(16.0))
{
return self.real.recommendedMaxWorkingSetSize;
}
Expand Down Expand Up @@ -648,7 +654,8 @@ - (uint32_t)peerCount API_AVAILABLE(macos(10.15))API_UNAVAILABLE(ios)
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (nullable id<MTLIOFileHandle>)newIOHandleWithURL:(NSURL *)url
error:(NSError **)error
API_AVAILABLE(macos(13.0), ios(16.0))
API_DEPRECATED_WITH_REPLACEMENT("Use newIOFileHandleWithURL:error: instead", macos(13.0, 14.0),
ios(16.0, 17.0))
{
METAL_NOT_HOOKED();
return [self.real newIOHandleWithURL:url error:error];
Expand All @@ -669,13 +676,35 @@ - (uint32_t)peerCount API_AVAILABLE(macos(10.15))API_UNAVAILABLE(ios)
- (nullable id<MTLIOFileHandle>)newIOHandleWithURL:(NSURL *)url
compressionMethod:(MTLIOCompressionMethod)compressionMethod
error:(NSError **)error
API_AVAILABLE(macos(13.0), ios(16.0))
API_DEPRECATED_WITH_REPLACEMENT("Use newIOFileHandleWithURL:compressionMethod:error: instead",
macos(13.0, 14.0), ios(16.0, 17.0))
{
METAL_NOT_HOOKED();
return [self.real newIOHandleWithURL:url compressionMethod:compressionMethod error:error];
}
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (nullable id<MTLIOFileHandle>)newIOFileHandleWithURL:(NSURL *)url
error:(NSError **)error
API_AVAILABLE(macos(14.0), ios(17.0))
{
METAL_NOT_HOOKED();
return [self.real newIOFileHandleWithURL:url error:error];
}
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (nullable id<MTLIOFileHandle>)newIOFileHandleWithURL:(NSURL *)url
compressionMethod:(MTLIOCompressionMethod)compressionMethod
error:(NSError **)error
API_AVAILABLE(macos(14.0), ios(17.0))
{
METAL_NOT_HOOKED();
return [self.real newIOFileHandleWithURL:url compressionMethod:compressionMethod error:error];
}
#endif

- (MTLSize)sparseTileSizeWithTextureType:(MTLTextureType)textureType
pixelFormat:(MTLPixelFormat)pixelFormat
sampleCount:(NSUInteger)sampleCount
Expand Down
48 changes: 47 additions & 1 deletion renderdoc/driver/metal/metal_render_command_encoder_bridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ - (void)popDebugGroup
}

// MTLRenderCommandEncoder : based on the protocol defined in
// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderCommandEncoder.h
// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderCommandEncoder.h

- (void)setRenderPipelineState:(id<MTLRenderPipelineState>)pipelineState
{
Expand Down Expand Up @@ -141,6 +141,52 @@ - (void)setVertexBuffers:(const id<MTLBuffer> __nullable[__nonnull])buffers
return [self.real setVertexBuffers:buffers offsets:offsets withRange:range];
}

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (void)setVertexBuffer:(nullable id<MTLBuffer>)buffer
offset:(NSUInteger)offset
attributeStride:(NSUInteger)stride
atIndex:(NSUInteger)index API_AVAILABLE(macos(14.0), ios(17.0))
{
METAL_NOT_HOOKED();
return [self.real setVertexBuffer:buffer offset:offset attributeStride:stride atIndex:index];
}
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (void)setVertexBuffers:(id<MTLBuffer> const __nullable[__nonnull])buffers
offsets:(NSUInteger const[__nonnull])offsets
attributeStrides:(NSUInteger const[__nonnull])strides
withRange:(NSRange)range API_AVAILABLE(macos(14.0), ios(17.0))
{
METAL_NOT_HOOKED();
return [self.real setVertexBuffers:buffers
offsets:offsets
attributeStrides:strides
withRange:range];
}
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (void)setVertexBufferOffset:(NSUInteger)offset
attributeStride:(NSUInteger)stride
atIndex:(NSUInteger)index API_AVAILABLE(macos(14.0), ios(17.0))
{
METAL_NOT_HOOKED();
return [self.real setVertexBufferOffset:offset attributeStride:stride atIndex:index];
}
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_14_0
- (void)setVertexBytes:(void const *)bytes
length:(NSUInteger)length
attributeStride:(NSUInteger)stride
atIndex:(NSUInteger)index API_AVAILABLE(macos(14.0), ios(17.0))
{
METAL_NOT_HOOKED();
return [self.real setVertexBytes:bytes length:length attributeStride:stride atIndex:index];
}
#endif

- (void)setVertexTexture:(nullable id<MTLTexture>)texture atIndex:(NSUInteger)index
{
METAL_NOT_HOOKED();
Expand Down
4 changes: 4 additions & 0 deletions renderdoc/driver/metal/metal_types_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ inline WrappedMTLResource *GetWrapped(id<MTLResource> objC)
#ifndef __MAC_13_3
#define __MAC_13_3 130300
#endif

#ifndef __MAC_14_0
#define __MAC_14_0 140000
#endif

0 comments on commit a60412d

Please sign in to comment.