Guard Metal APIs newer than MacOS SDK 12.0

macos(13.0) guarded using #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
macos(12.5) guarded using #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_5
This commit is contained in:
Jake Turner
2023-01-07 07:18:39 +00:00
committed by Baldur Karlsson
parent aaa12d3fb7
commit 70df111a5e
7 changed files with 94 additions and 2 deletions
@@ -186,9 +186,11 @@
return [self.real newRemoteBufferViewForDevice:device];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (uint64_t)gpuAddress API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.gpuAddress;
}
#endif
@end
@@ -265,12 +265,14 @@
return [self.real accelerationStructureCommandEncoder];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (id<MTLAccelerationStructureCommandEncoder>)accelerationStructureCommandEncoderWithDescriptor:
(MTLAccelerationStructurePassDescriptor *)descriptor API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real accelerationStructureCommandEncoderWithDescriptor:descriptor];
}
#endif
- (void)pushDebugGroup:(NSString *)string API_AVAILABLE(macos(10.13), ios(11.0))
{
@@ -526,6 +526,7 @@ newRenderPipelineStateWithTileDescriptor:(MTLTileRenderPipelineDescriptor *)desc
completionHandler:completionHandler];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (nullable id<MTLRenderPipelineState>)
newRenderPipelineStateWithMeshDescriptor:(MTLMeshRenderPipelineDescriptor *)descriptor
options:(MTLPipelineOption)options
@@ -539,7 +540,9 @@ newRenderPipelineStateWithMeshDescriptor:(MTLMeshRenderPipelineDescriptor *)desc
reflection:reflection
error:error];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)newRenderPipelineStateWithMeshDescriptor:(MTLMeshRenderPipelineDescriptor *)descriptor
options:(MTLPipelineOption)options
completionHandler:
@@ -551,6 +554,7 @@ newRenderPipelineStateWithMeshDescriptor:(MTLMeshRenderPipelineDescriptor *)desc
options:options
completionHandler:completionHandler];
}
#endif
- (NSUInteger)maxThreadgroupMemoryLength API_AVAILABLE(macos(10.13), ios(11.0))
{
@@ -641,6 +645,7 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
return self.real.peerCount;
}
#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))
@@ -648,7 +653,9 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
METAL_NOT_HOOKED();
return [self.real newIOHandleWithURL:url error:error];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (nullable id<MTLIOCommandQueue>)newIOCommandQueueWithDescriptor:(MTLIOCommandQueueDescriptor *)descriptor
error:(NSError **)error
API_AVAILABLE(macos(13.0), ios(16.0))
@@ -656,7 +663,9 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
METAL_NOT_HOOKED();
return [self.real newIOCommandQueueWithDescriptor:descriptor error:error];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (nullable id<MTLIOFileHandle>)newIOHandleWithURL:(NSURL *)url
compressionMethod:(MTLIOCompressionMethod)compressionMethod
error:(NSError **)error
@@ -665,6 +674,7 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
METAL_NOT_HOOKED();
return [self.real newIOHandleWithURL:url compressionMethod:compressionMethod error:error];
}
#endif
- (MTLSize)sparseTileSizeWithTextureType:(MTLTextureType)textureType
pixelFormat:(MTLPixelFormat)pixelFormat
@@ -710,13 +720,16 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
numRegions:numRegions];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (NSUInteger)sparseTileSizeInBytesForSparsePageSize:(MTLSparsePageSize)sparsePageSize
API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real sparseTileSizeInBytesForSparsePageSize:sparsePageSize];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (MTLSize)sparseTileSizeWithTextureType:(MTLTextureType)textureType
pixelFormat:(MTLPixelFormat)pixelFormat
sampleCount:(NSUInteger)sampleCount
@@ -729,6 +742,7 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
sampleCount:sampleCount
sparsePageSize:sparsePageSize];
}
#endif
- (NSUInteger)maxBufferLength API_AVAILABLE(macos(10.14), ios(12.0))
{
@@ -756,12 +770,14 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
return [self.real sampleTimestamps:cpuTimestamp gpuTimestamp:gpuTimestamp];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (id<MTLArgumentEncoder>)newArgumentEncoderWithBufferBinding:(id<MTLBufferBinding>)bufferBinding
API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real newArgumentEncoderWithBufferBinding:bufferBinding];
}
#endif
- (BOOL)supportsCounterSampling:(MTLCounterSamplingPoint)samplingPoint
API_AVAILABLE(macos(11.0), ios(14.0))
@@ -835,19 +851,23 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des
return [self.real newAccelerationStructureWithDescriptor:descriptor];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (MTLSizeAndAlign)heapAccelerationStructureSizeAndAlignWithSize:(NSUInteger)size
API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real heapAccelerationStructureSizeAndAlignWithSize:size];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (MTLSizeAndAlign)heapAccelerationStructureSizeAndAlignWithDescriptor:
(MTLAccelerationStructureDescriptor *)descriptor API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real heapAccelerationStructureSizeAndAlignWithDescriptor:descriptor];
}
#endif
- (BOOL)supportsFunctionPointers API_AVAILABLE(macos(11.0), ios(14.0))
{
@@ -491,6 +491,7 @@
return [self.real setStencilStoreActionOptions:storeActionOptions];
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectBytes:(const void *)bytes
length:(NSUInteger)length
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
@@ -498,7 +499,9 @@
METAL_NOT_HOOKED();
return [self.real setObjectBytes:bytes length:length atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectBuffer:(nullable id<MTLBuffer>)buffer
offset:(NSUInteger)offset
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
@@ -506,14 +509,18 @@
METAL_NOT_HOOKED();
return [self.real setObjectBuffer:buffer offset:offset atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectBufferOffset:(NSUInteger)offset
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setObjectBufferOffset:offset atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectBuffers:(const id<MTLBuffer> __nullable[__nonnull])buffers
offsets:(const NSUInteger[__nonnull])offsets
withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0))
@@ -521,35 +528,45 @@
METAL_NOT_HOOKED();
return [self.real setObjectBuffers:buffers offsets:offsets withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectTexture:(nullable id<MTLTexture>)texture
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setObjectTexture:texture atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectTextures:(const id<MTLTexture> __nullable[__nonnull])textures
withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setObjectTextures:textures withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectSamplerState:(nullable id<MTLSamplerState>)sampler
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setObjectSamplerState:sampler atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectSamplerStates:(const id<MTLSamplerState> __nullable[__nonnull])samplers
withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setObjectSamplerStates:samplers withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectSamplerState:(nullable id<MTLSamplerState>)sampler
lodMinClamp:(float)lodMinClamp
lodMaxClamp:(float)lodMaxClamp
@@ -561,7 +578,9 @@
lodMaxClamp:lodMaxClamp
atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectSamplerStates:(const id<MTLSamplerState> __nullable[__nonnull])samplers
lodMinClamps:(const float[__nonnull])lodMinClamps
lodMaxClamps:(const float[__nonnull])lodMaxClamps
@@ -573,14 +592,18 @@
lodMaxClamps:lodMaxClamps
withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setObjectThreadgroupMemoryLength:(NSUInteger)length
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setObjectThreadgroupMemoryLength:length atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshBytes:(const void *)bytes
length:(NSUInteger)length
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
@@ -588,7 +611,9 @@
METAL_NOT_HOOKED();
return [self.real setMeshBytes:bytes length:length atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshBuffer:(nullable id<MTLBuffer>)buffer
offset:(NSUInteger)offset
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
@@ -596,14 +621,18 @@
METAL_NOT_HOOKED();
return [self.real setMeshBuffer:buffer offset:offset atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshBufferOffset:(NSUInteger)offset
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setMeshBufferOffset:offset atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshBuffers:(const id<MTLBuffer> __nullable[__nonnull])buffers
offsets:(const NSUInteger[__nonnull])offsets
withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0))
@@ -611,35 +640,45 @@
METAL_NOT_HOOKED();
return [self.real setMeshBuffers:buffers offsets:offsets withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshTexture:(nullable id<MTLTexture>)texture
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setMeshTexture:texture atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshTextures:(const id<MTLTexture> __nullable[__nonnull])textures
withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setMeshTextures:textures withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshSamplerState:(nullable id<MTLSamplerState>)sampler
atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setMeshSamplerState:sampler atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshSamplerStates:(const id<MTLSamplerState> __nullable[__nonnull])samplers
withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0))
{
METAL_NOT_HOOKED();
return [self.real setMeshSamplerStates:samplers withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshSamplerState:(nullable id<MTLSamplerState>)sampler
lodMinClamp:(float)lodMinClamp
lodMaxClamp:(float)lodMaxClamp
@@ -651,7 +690,9 @@
lodMaxClamp:lodMaxClamp
atIndex:index];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)setMeshSamplerStates:(const id<MTLSamplerState> __nullable[__nonnull])samplers
lodMinClamps:(const float[__nonnull])lodMinClamps
lodMaxClamps:(const float[__nonnull])lodMaxClamps
@@ -663,7 +704,9 @@
lodMaxClamps:lodMaxClamps
withRange:range];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)drawMeshThreadgroups:(MTLSize)threadgroupsPerGrid
threadsPerObjectThreadgroup:(MTLSize)threadsPerObjectThreadgroup
threadsPerMeshThreadgroup:(MTLSize)threadsPerMeshThreadgroup
@@ -674,7 +717,9 @@
threadsPerObjectThreadgroup:threadsPerObjectThreadgroup
threadsPerMeshThreadgroup:threadsPerMeshThreadgroup];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)drawMeshThreads:(MTLSize)threadsPerGrid
threadsPerObjectThreadgroup:(MTLSize)threadsPerObjectThreadgroup
threadsPerMeshThreadgroup:(MTLSize)threadsPerMeshThreadgroup
@@ -685,7 +730,9 @@
threadsPerObjectThreadgroup:threadsPerObjectThreadgroup
threadsPerMeshThreadgroup:threadsPerMeshThreadgroup];
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (void)drawMeshThreadgroupsWithIndirectBuffer:(id<MTLBuffer>)indirectBuffer
indirectBufferOffset:(NSUInteger)indirectBufferOffset
threadsPerObjectThreadgroup:(MTLSize)threadsPerObjectThreadgroup
@@ -698,6 +745,7 @@
threadsPerObjectThreadgroup:threadsPerObjectThreadgroup
threadsPerMeshThreadgroup:threadsPerMeshThreadgroup];
}
#endif
- (void)drawPrimitives:(MTLPrimitiveType)primitiveType
vertexStart:(NSUInteger)vertexStart
@@ -104,35 +104,47 @@
return self.real.supportIndirectCommandBuffers;
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (NSUInteger)maxTotalThreadsPerObjectThreadgroup API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.maxTotalThreadsPerObjectThreadgroup;
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (NSUInteger)maxTotalThreadsPerMeshThreadgroup API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.maxTotalThreadsPerMeshThreadgroup;
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (NSUInteger)objectThreadExecutionWidth API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.objectThreadExecutionWidth;
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (NSUInteger)meshThreadExecutionWidth API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.meshThreadExecutionWidth;
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (NSUInteger)maxTotalThreadgroupsPerMeshGrid API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.maxTotalThreadgroupsPerMeshGrid;
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (MTLResourceID)gpuResourceID API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.gpuResourceID;
}
#endif
- (nullable id<MTLFunctionHandle>)functionHandleWithFunction:(id<MTLFunction>)function
stage:(MTLRenderStages)stage
@@ -260,15 +260,19 @@
return self.real.allowGPUOptimizedContents;
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_5
- (MTLTextureCompressionType)compressionType API_AVAILABLE(macos(12.5), ios(15.0))
{
return self.real.compressionType;
}
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_13_0
- (MTLResourceID)gpuResourceID API_AVAILABLE(macos(13.0), ios(16.0))
{
return self.real.gpuResourceID;
}
#endif
- (void)getBytes:(void *)pixelBytes
bytesPerRow:(NSUInteger)bytesPerRow
+6 -2
View File
@@ -56,6 +56,10 @@ inline WrappedMTLResource *GetWrapped(id<MTLResource> objC)
}
// Define Mac SDK versions when compiling with earlier SDKs
#ifndef __MAC_12_0
#define __MAC_12_0 120000
#ifndef __MAC_12_5
#define __MAC_12_5 120500
#endif
#ifndef __MAC_13_0
#define __MAC_13_0 130000
#endif