From aaa12d3fb7f65c75ff4f2853805c7577ddaaf777 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sat, 7 Jan 2023 06:35:06 +0000 Subject: [PATCH] Metal: Compile time support for MacOS SDK 13.1 Changes to Metal protocols to support MacOS SDK 13.1 Removed #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 guards now the CI can compile MacOS SDK12.0 --- renderdoc/driver/metal/metal_buffer_bridge.mm | 7 +- .../metal/metal_command_buffer_bridge.mm | 9 +- renderdoc/driver/metal/metal_device_bridge.mm | 123 +++++++-- .../metal_render_command_encoder_bridge.mm | 252 +++++++++++++++--- .../metal_render_pipeline_state_bridge.mm | 40 ++- .../driver/metal/metal_texture_bridge.mm | 12 +- 6 files changed, 372 insertions(+), 71 deletions(-) diff --git a/renderdoc/driver/metal/metal_buffer_bridge.mm b/renderdoc/driver/metal/metal_buffer_bridge.mm index d445ac442..2cd0cf82b 100644 --- a/renderdoc/driver/metal/metal_buffer_bridge.mm +++ b/renderdoc/driver/metal/metal_buffer_bridge.mm @@ -63,7 +63,7 @@ } // MTLResource : based on the protocol defined in -// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h - (nullable NSString *)label { @@ -186,4 +186,9 @@ return [self.real newRemoteBufferViewForDevice:device]; } +- (uint64_t)gpuAddress API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.gpuAddress; +} + @end diff --git a/renderdoc/driver/metal/metal_command_buffer_bridge.mm b/renderdoc/driver/metal/metal_command_buffer_bridge.mm index bf9b1c984..be0ad8524 100644 --- a/renderdoc/driver/metal/metal_command_buffer_bridge.mm +++ b/renderdoc/driver/metal/metal_command_buffer_bridge.mm @@ -63,7 +63,7 @@ } // MTLCommandBuffer : based on the protocol defined in -// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLCommandBuffer.h +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLCommandBuffer.h - (id)device { @@ -265,6 +265,13 @@ return [self.real accelerationStructureCommandEncoder]; } +- (id)accelerationStructureCommandEncoderWithDescriptor: + (MTLAccelerationStructurePassDescriptor *)descriptor API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real accelerationStructureCommandEncoderWithDescriptor:descriptor]; +} + - (void)pushDebugGroup:(NSString *)string API_AVAILABLE(macos(10.13), ios(11.0)) { METAL_NOT_HOOKED(); diff --git a/renderdoc/driver/metal/metal_device_bridge.mm b/renderdoc/driver/metal/metal_device_bridge.mm index 441ead020..cb1a6e818 100644 --- a/renderdoc/driver/metal/metal_device_bridge.mm +++ b/renderdoc/driver/metal/metal_device_bridge.mm @@ -66,7 +66,7 @@ } // MTLDevice : based on the protocol defined in -// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h - (NSString *)name { @@ -160,11 +160,7 @@ return GetWrapped(self)->supportsQueryTextureLOD(); } -- (BOOL)supportsBCTextureCompression API_AVAILABLE(macos(11.0)) -// It is available for ios in SDK 11.1 and it is marked as unavailable in SDK 12 -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - API_UNAVAILABLE(ios) -#endif // #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 +- (BOOL)supportsBCTextureCompression API_AVAILABLE(macos(11.0))API_UNAVAILABLE(ios) { return GetWrapped(self)->supportsBCTextureCompression(); } @@ -173,12 +169,15 @@ { return GetWrapped(self)->supportsPullModelInterpolation(); } -- (BOOL)areBarycentricCoordsSupported API_AVAILABLE(macos(10.15))API_UNAVAILABLE(ios) + +- (BOOL)areBarycentricCoordsSupported + API_DEPRECATED_WITH_REPLACEMENT("supportsShaderBarycentricCoordinates", macos(10.15, 13.0), + ios(14.0, 16.0))API_UNAVAILABLE(tvos) { return GetWrapped(self)->areBarycentricCoordsSupported(); } -- (BOOL)supportsShaderBarycentricCoordinates API_AVAILABLE(macos(10.15))API_UNAVAILABLE(ios) +- (BOOL)supportsShaderBarycentricCoordinates API_AVAILABLE(macos(10.15), ios(14.0)) { return GetWrapped(self)->supportsShaderBarycentricCoordinates(); } @@ -304,6 +303,7 @@ - (nullable id)newLibraryWithFile:(NSString *)filepath error:(__autoreleasing NSError **)error + API_DEPRECATED("Use -newLibraryWithURL:error: instead", macos(10.11, 13.0), ios(8.0, 16.0)) { METAL_NOT_HOOKED(); return [self.real newLibraryWithFile:filepath error:error]; @@ -341,7 +341,6 @@ [self.real newLibraryWithSource:source options:options completionHandler:completionHandler]; } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (nullable id)newLibraryWithStitchedDescriptor:(MTLStitchedLibraryDescriptor *)descriptor error:(__autoreleasing NSError **)error API_AVAILABLE(macos(12.0), ios(15.0)) @@ -349,9 +348,7 @@ METAL_NOT_HOOKED(); return [self.real newLibraryWithStitchedDescriptor:descriptor error:error]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)newLibraryWithStitchedDescriptor:(MTLStitchedLibraryDescriptor *)descriptor completionHandler:(MTLNewLibraryCompletionHandler)completionHandler API_AVAILABLE(macos(12.0), ios(15.0)) @@ -359,7 +356,6 @@ METAL_NOT_HOOKED(); [self.real newLibraryWithStitchedDescriptor:descriptor completionHandler:completionHandler]; } -#endif - (nullable id) newRenderPipelineStateWithDescriptor:(MTLRenderPipelineDescriptor *)descriptor @@ -475,6 +471,7 @@ newComputePipelineStateWithDescriptor:(MTLComputePipelineDescriptor *)descriptor } - (BOOL)supportsFeatureSet:(MTLFeatureSet)featureSet + API_DEPRECATED("Use supportsFamily instead", macos(10.11, 13.0), ios(8.0, 16.0), tvos(9.0, 16.0)) { return GetWrapped(self)->supportsFeatureSet((MTL::FeatureSet)featureSet); } @@ -529,6 +526,32 @@ newRenderPipelineStateWithTileDescriptor:(MTLTileRenderPipelineDescriptor *)desc completionHandler:completionHandler]; } +- (nullable id) +newRenderPipelineStateWithMeshDescriptor:(MTLMeshRenderPipelineDescriptor *)descriptor + options:(MTLPipelineOption)options + reflection:(MTLAutoreleasedRenderPipelineReflection *__nullable)reflection + error:(__autoreleasing NSError **)error + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real newRenderPipelineStateWithMeshDescriptor:descriptor + options:options + reflection:reflection + error:error]; +} + +- (void)newRenderPipelineStateWithMeshDescriptor:(MTLMeshRenderPipelineDescriptor *)descriptor + options:(MTLPipelineOption)options + completionHandler: + (MTLNewRenderPipelineStateWithReflectionCompletionHandler) + completionHandler API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real newRenderPipelineStateWithMeshDescriptor:descriptor + options:options + completionHandler:completionHandler]; +} + - (NSUInteger)maxThreadgroupMemoryLength API_AVAILABLE(macos(10.13), ios(11.0)) { return self.real.maxThreadgroupMemoryLength; @@ -618,6 +641,31 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des return self.real.peerCount; } +- (nullable id)newIOHandleWithURL:(NSURL *)url + error:(NSError **)error + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real newIOHandleWithURL:url error:error]; +} + +- (nullable id)newIOCommandQueueWithDescriptor:(MTLIOCommandQueueDescriptor *)descriptor + error:(NSError **)error + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real newIOCommandQueueWithDescriptor:descriptor error:error]; +} + +- (nullable id)newIOHandleWithURL:(NSURL *)url + compressionMethod:(MTLIOCompressionMethod)compressionMethod + error:(NSError **)error + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real newIOHandleWithURL:url compressionMethod:compressionMethod error:error]; +} + - (MTLSize)sparseTileSizeWithTextureType:(MTLTextureType)textureType pixelFormat:(MTLPixelFormat)pixelFormat sampleCount:(NSUInteger)sampleCount @@ -662,6 +710,26 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des numRegions:numRegions]; } +- (NSUInteger)sparseTileSizeInBytesForSparsePageSize:(MTLSparsePageSize)sparsePageSize + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real sparseTileSizeInBytesForSparsePageSize:sparsePageSize]; +} + +- (MTLSize)sparseTileSizeWithTextureType:(MTLTextureType)textureType + pixelFormat:(MTLPixelFormat)pixelFormat + sampleCount:(NSUInteger)sampleCount + sparsePageSize:(MTLSparsePageSize)sparsePageSize + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real sparseTileSizeWithTextureType:textureType + pixelFormat:pixelFormat + sampleCount:sampleCount + sparsePageSize:sparsePageSize]; +} + - (NSUInteger)maxBufferLength API_AVAILABLE(macos(10.14), ios(12.0)) { return self.real.maxBufferLength; @@ -688,6 +756,13 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des return [self.real sampleTimestamps:cpuTimestamp gpuTimestamp:gpuTimestamp]; } +- (id)newArgumentEncoderWithBufferBinding:(id)bufferBinding + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real newArgumentEncoderWithBufferBinding:bufferBinding]; +} + - (BOOL)supportsCounterSampling:(MTLCounterSamplingPoint)samplingPoint API_AVAILABLE(macos(11.0), ios(14.0)) { @@ -705,12 +780,10 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des return GetWrapped(self)->supportsDynamicLibraries(); } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (BOOL)supportsRenderDynamicLibraries API_AVAILABLE(macos(12.0), ios(15.0)) { return GetWrapped(self)->supportsRenderDynamicLibraries(); } -#endif - (nullable id)newDynamicLibrary:(id)library error:(NSError **)error @@ -762,32 +835,38 @@ newIndirectCommandBufferWithDescriptor:(MTLIndirectCommandBufferDescriptor *)des return [self.real newAccelerationStructureWithDescriptor:descriptor]; } +- (MTLSizeAndAlign)heapAccelerationStructureSizeAndAlignWithSize:(NSUInteger)size + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real heapAccelerationStructureSizeAndAlignWithSize:size]; +} + +- (MTLSizeAndAlign)heapAccelerationStructureSizeAndAlignWithDescriptor: + (MTLAccelerationStructureDescriptor *)descriptor API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real heapAccelerationStructureSizeAndAlignWithDescriptor:descriptor]; +} + - (BOOL)supportsFunctionPointers API_AVAILABLE(macos(11.0), ios(14.0)) { return GetWrapped(self)->supportsFunctionPointers(); } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (BOOL)supportsFunctionPointersFromRender API_AVAILABLE(macos(12.0), ios(15.0)) { return GetWrapped(self)->supportsFunctionPointersFromRender(); } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (BOOL)supportsRaytracingFromRender API_AVAILABLE(macos(12.0), ios(15.0)) { return GetWrapped(self)->supportsRaytracingFromRender(); } -#endif -// Treat as if the API is available from SDK 12.0 -// It is marked as available from SDK 11.0, however it was not present in SDK 11.1 MTLDevice.h -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (BOOL)supportsPrimitiveMotionBlur API_AVAILABLE(macos(11.0), ios(14.0)) { return GetWrapped(self)->supportsPrimitiveMotionBlur(); } -#endif @end diff --git a/renderdoc/driver/metal/metal_render_command_encoder_bridge.mm b/renderdoc/driver/metal/metal_render_command_encoder_bridge.mm index f36e4df69..7dbb9f902 100644 --- a/renderdoc/driver/metal/metal_render_command_encoder_bridge.mm +++ b/renderdoc/driver/metal/metal_render_command_encoder_bridge.mm @@ -63,7 +63,7 @@ } // MTLCommandEncoder : based on the protocol defined in -// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLCommandEncoder.h +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLCommandEncoder.h - (id)device { @@ -191,16 +191,13 @@ withRange:range]; } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setVertexVisibleFunctionTable:(nullable id)functionTable atBufferIndex:(NSUInteger)bufferIndex API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); return [self.real setVertexVisibleFunctionTable:functionTable atBufferIndex:bufferIndex]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setVertexVisibleFunctionTables: (const id __nullable[__nonnull])functionTables withBufferRange:(NSRange)range API_AVAILABLE(macos(12.0), ios(15.0)) @@ -208,9 +205,7 @@ METAL_NOT_HOOKED(); return [self.real setVertexVisibleFunctionTables:functionTables withBufferRange:range]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setVertexIntersectionFunctionTable: (nullable id)intersectionFunctionTable atBufferIndex:(NSUInteger)bufferIndex @@ -220,27 +215,22 @@ return [self.real setVertexIntersectionFunctionTable:intersectionFunctionTable atBufferIndex:bufferIndex]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setVertexIntersectionFunctionTables: - (const id __nullable[__nonnull])intersectionFunctionTable + (const id __nullable[__nonnull])intersectionFunctionTables withBufferRange:(NSRange)range API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); - return [self.real setVertexIntersectionFunctionTables:intersectionFunctionTable + return [self.real setVertexIntersectionFunctionTables:intersectionFunctionTables withBufferRange:range]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setVertexAccelerationStructure:(nullable id)accelerationStructure atBufferIndex:(NSUInteger)bufferIndex API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); return [self.real setVertexAccelerationStructure:accelerationStructure atBufferIndex:bufferIndex]; } -#endif - (void)setViewport:(MTLViewport)viewport { @@ -384,16 +374,13 @@ withRange:range]; } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setFragmentVisibleFunctionTable:(nullable id)functionTable atBufferIndex:(NSUInteger)bufferIndex API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); return [self.real setFragmentVisibleFunctionTable:functionTable atBufferIndex:bufferIndex]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setFragmentVisibleFunctionTables: (const id __nullable[__nonnull])functionTables withBufferRange:(NSRange)range API_AVAILABLE(macos(12.0), ios(15.0)) @@ -401,9 +388,7 @@ METAL_NOT_HOOKED(); return [self.real setFragmentVisibleFunctionTables:functionTables withBufferRange:range]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setFragmentIntersectionFunctionTable: (nullable id)intersectionFunctionTable atBufferIndex:(NSUInteger)bufferIndex @@ -413,20 +398,16 @@ return [self.real setFragmentIntersectionFunctionTable:intersectionFunctionTable atBufferIndex:bufferIndex]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setFragmentIntersectionFunctionTables: - (const id __nullable[__nonnull])intersectionFunctionTable + (const id __nullable[__nonnull])intersectionFunctionTables withBufferRange:(NSRange)range API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); - return [self.real setFragmentIntersectionFunctionTables:intersectionFunctionTable + return [self.real setFragmentIntersectionFunctionTables:intersectionFunctionTables withBufferRange:range]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setFragmentAccelerationStructure:(nullable id)accelerationStructure atBufferIndex:(NSUInteger)bufferIndex API_AVAILABLE(macos(12.0), ios(15.0)) @@ -435,7 +416,6 @@ return [self.real setFragmentAccelerationStructure:accelerationStructure atBufferIndex:bufferIndex]; } -#endif - (void)setBlendColorRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha { @@ -511,6 +491,214 @@ return [self.real setStencilStoreActionOptions:storeActionOptions]; } +- (void)setObjectBytes:(const void *)bytes + length:(NSUInteger)length + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectBytes:bytes length:length atIndex:index]; +} + +- (void)setObjectBuffer:(nullable id)buffer + offset:(NSUInteger)offset + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectBuffer:buffer offset:offset atIndex:index]; +} + +- (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]; +} + +- (void)setObjectBuffers:(const id __nullable[__nonnull])buffers + offsets:(const NSUInteger[__nonnull])offsets + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectBuffers:buffers offsets:offsets withRange:range]; +} + +- (void)setObjectTexture:(nullable id)texture + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectTexture:texture atIndex:index]; +} + +- (void)setObjectTextures:(const id __nullable[__nonnull])textures + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectTextures:textures withRange:range]; +} + +- (void)setObjectSamplerState:(nullable id)sampler + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectSamplerState:sampler atIndex:index]; +} + +- (void)setObjectSamplerStates:(const id __nullable[__nonnull])samplers + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectSamplerStates:samplers withRange:range]; +} + +- (void)setObjectSamplerState:(nullable id)sampler + lodMinClamp:(float)lodMinClamp + lodMaxClamp:(float)lodMaxClamp + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectSamplerState:sampler + lodMinClamp:lodMinClamp + lodMaxClamp:lodMaxClamp + atIndex:index]; +} + +- (void)setObjectSamplerStates:(const id __nullable[__nonnull])samplers + lodMinClamps:(const float[__nonnull])lodMinClamps + lodMaxClamps:(const float[__nonnull])lodMaxClamps + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setObjectSamplerStates:samplers + lodMinClamps:lodMinClamps + lodMaxClamps:lodMaxClamps + withRange:range]; +} + +- (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]; +} + +- (void)setMeshBytes:(const void *)bytes + length:(NSUInteger)length + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshBytes:bytes length:length atIndex:index]; +} + +- (void)setMeshBuffer:(nullable id)buffer + offset:(NSUInteger)offset + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshBuffer:buffer offset:offset atIndex:index]; +} + +- (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]; +} + +- (void)setMeshBuffers:(const id __nullable[__nonnull])buffers + offsets:(const NSUInteger[__nonnull])offsets + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshBuffers:buffers offsets:offsets withRange:range]; +} + +- (void)setMeshTexture:(nullable id)texture + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshTexture:texture atIndex:index]; +} + +- (void)setMeshTextures:(const id __nullable[__nonnull])textures + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshTextures:textures withRange:range]; +} + +- (void)setMeshSamplerState:(nullable id)sampler + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshSamplerState:sampler atIndex:index]; +} + +- (void)setMeshSamplerStates:(const id __nullable[__nonnull])samplers + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshSamplerStates:samplers withRange:range]; +} + +- (void)setMeshSamplerState:(nullable id)sampler + lodMinClamp:(float)lodMinClamp + lodMaxClamp:(float)lodMaxClamp + atIndex:(NSUInteger)index API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshSamplerState:sampler + lodMinClamp:lodMinClamp + lodMaxClamp:lodMaxClamp + atIndex:index]; +} + +- (void)setMeshSamplerStates:(const id __nullable[__nonnull])samplers + lodMinClamps:(const float[__nonnull])lodMinClamps + lodMaxClamps:(const float[__nonnull])lodMaxClamps + withRange:(NSRange)range API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real setMeshSamplerStates:samplers + lodMinClamps:lodMinClamps + lodMaxClamps:lodMaxClamps + withRange:range]; +} + +- (void)drawMeshThreadgroups:(MTLSize)threadgroupsPerGrid + threadsPerObjectThreadgroup:(MTLSize)threadsPerObjectThreadgroup + threadsPerMeshThreadgroup:(MTLSize)threadsPerMeshThreadgroup + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real drawMeshThreadgroups:threadgroupsPerGrid + threadsPerObjectThreadgroup:threadsPerObjectThreadgroup + threadsPerMeshThreadgroup:threadsPerMeshThreadgroup]; +} + +- (void)drawMeshThreads:(MTLSize)threadsPerGrid + threadsPerObjectThreadgroup:(MTLSize)threadsPerObjectThreadgroup + threadsPerMeshThreadgroup:(MTLSize)threadsPerMeshThreadgroup + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real drawMeshThreads:threadsPerGrid + threadsPerObjectThreadgroup:threadsPerObjectThreadgroup + threadsPerMeshThreadgroup:threadsPerMeshThreadgroup]; +} + +- (void)drawMeshThreadgroupsWithIndirectBuffer:(id)indirectBuffer + indirectBufferOffset:(NSUInteger)indirectBufferOffset + threadsPerObjectThreadgroup:(MTLSize)threadsPerObjectThreadgroup + threadsPerMeshThreadgroup:(MTLSize)threadsPerMeshThreadgroup + API_AVAILABLE(macos(13.0), ios(16.0)) +{ + METAL_NOT_HOOKED(); + return [self.real drawMeshThreadgroupsWithIndirectBuffer:indirectBuffer + indirectBufferOffset:indirectBufferOffset + threadsPerObjectThreadgroup:threadsPerObjectThreadgroup + threadsPerMeshThreadgroup:threadsPerMeshThreadgroup]; +} + - (void)drawPrimitives:(MTLPrimitiveType)primitiveType vertexStart:(NSUInteger)vertexStart vertexCount:(NSUInteger)vertexCount @@ -829,25 +1017,20 @@ withRange:range]; } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setTileVisibleFunctionTable:(nullable id)functionTable atBufferIndex:(NSUInteger)bufferIndex API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); return [self.real setTileVisibleFunctionTable:functionTable atBufferIndex:bufferIndex]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setTileVisibleFunctionTables:(const id __nullable[__nonnull])functionTables withBufferRange:(NSRange)range API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); return [self.real setTileVisibleFunctionTables:functionTables withBufferRange:range]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setTileIntersectionFunctionTable: (nullable id)intersectionFunctionTable atBufferIndex:(NSUInteger)bufferIndex @@ -857,9 +1040,7 @@ return [self.real setTileIntersectionFunctionTable:intersectionFunctionTable atBufferIndex:bufferIndex]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setTileIntersectionFunctionTables: (const id __nullable[__nonnull])intersectionFunctionTable withBufferRange:(NSRange)range API_AVAILABLE(macos(12.0), ios(15.0)) @@ -868,16 +1049,13 @@ return [self.real setTileIntersectionFunctionTables:intersectionFunctionTable withBufferRange:range]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (void)setTileAccelerationStructure:(nullable id)accelerationStructure atBufferIndex:(NSUInteger)bufferIndex API_AVAILABLE(macos(12.0), ios(15.0)) { METAL_NOT_HOOKED(); return [self.real setTileAccelerationStructure:accelerationStructure atBufferIndex:bufferIndex]; } -#endif - (void)dispatchThreadsPerTile:(MTLSize)threadsPerTile API_AVAILABLE(macos(11.0), macCatalyst(14.0), ios(11.0), tvos(14.5)) @@ -976,7 +1154,7 @@ - (void)memoryBarrierWithScope:(MTLBarrierScope)scope afterStages:(MTLRenderStages)after beforeStages:(MTLRenderStages)before - API_AVAILABLE(macos(10.14), macCatalyst(13.0))API_UNAVAILABLE(ios) + API_AVAILABLE(macos(10.14), macCatalyst(13.0), ios(16.0)) { METAL_NOT_HOOKED(); return [self.real memoryBarrierWithScope:scope afterStages:after beforeStages:before]; @@ -986,7 +1164,7 @@ count:(NSUInteger)count afterStages:(MTLRenderStages)after beforeStages:(MTLRenderStages)before - API_AVAILABLE(macos(10.14), macCatalyst(13.0))API_UNAVAILABLE(ios) + API_AVAILABLE(macos(10.14), macCatalyst(13.0), ios(16.0)) { METAL_NOT_HOOKED(); return [self.real memoryBarrierWithResources:resources diff --git a/renderdoc/driver/metal/metal_render_pipeline_state_bridge.mm b/renderdoc/driver/metal/metal_render_pipeline_state_bridge.mm index 3b94a7c60..70815b227 100644 --- a/renderdoc/driver/metal/metal_render_pipeline_state_bridge.mm +++ b/renderdoc/driver/metal/metal_render_pipeline_state_bridge.mm @@ -63,7 +63,7 @@ } // MTLRenderPipelineState : based on the protocol defined in -// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPipeline.h +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPipeline.h - (nullable NSString *)label { @@ -104,7 +104,36 @@ return self.real.supportIndirectCommandBuffers; } -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 +- (NSUInteger)maxTotalThreadsPerObjectThreadgroup API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.maxTotalThreadsPerObjectThreadgroup; +} + +- (NSUInteger)maxTotalThreadsPerMeshThreadgroup API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.maxTotalThreadsPerMeshThreadgroup; +} + +- (NSUInteger)objectThreadExecutionWidth API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.objectThreadExecutionWidth; +} + +- (NSUInteger)meshThreadExecutionWidth API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.meshThreadExecutionWidth; +} + +- (NSUInteger)maxTotalThreadgroupsPerMeshGrid API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.maxTotalThreadgroupsPerMeshGrid; +} + +- (MTLResourceID)gpuResourceID API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.gpuResourceID; +} + - (nullable id)functionHandleWithFunction:(id)function stage:(MTLRenderStages)stage API_AVAILABLE(macos(12.0), ios(15.0)) @@ -112,9 +141,7 @@ METAL_NOT_HOOKED(); return [self.real functionHandleWithFunction:function stage:stage]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (nullable id)newVisibleFunctionTableWithDescriptor: (MTLVisibleFunctionTableDescriptor *__nonnull)descriptor stage:(MTLRenderStages)stage @@ -123,9 +150,7 @@ METAL_NOT_HOOKED(); return [self.real newVisibleFunctionTableWithDescriptor:descriptor stage:stage]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (nullable id) newIntersectionFunctionTableWithDescriptor:(MTLIntersectionFunctionTableDescriptor *_Nonnull)descriptor stage:(MTLRenderStages)stage @@ -134,9 +159,7 @@ newIntersectionFunctionTableWithDescriptor:(MTLIntersectionFunctionTableDescript METAL_NOT_HOOKED(); return [self.real newIntersectionFunctionTableWithDescriptor:descriptor stage:stage]; } -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0 - (nullable id) newRenderPipelineStateWithAdditionalBinaryFunctions: (nonnull MTLRenderPipelineFunctionsDescriptor *)additionalBinaryFunctions @@ -147,6 +170,5 @@ newRenderPipelineStateWithAdditionalBinaryFunctions: return [self.real newRenderPipelineStateWithAdditionalBinaryFunctions:additionalBinaryFunctions error:error]; } -#endif @end diff --git a/renderdoc/driver/metal/metal_texture_bridge.mm b/renderdoc/driver/metal/metal_texture_bridge.mm index 11f0b5af9..4cb465ad4 100644 --- a/renderdoc/driver/metal/metal_texture_bridge.mm +++ b/renderdoc/driver/metal/metal_texture_bridge.mm @@ -63,7 +63,7 @@ } // MTLResource : based on the protocol defined in -// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h - (nullable NSString *)label { @@ -260,6 +260,16 @@ return self.real.allowGPUOptimizedContents; } +- (MTLTextureCompressionType)compressionType API_AVAILABLE(macos(12.5), ios(15.0)) +{ + return self.real.compressionType; +} + +- (MTLResourceID)gpuResourceID API_AVAILABLE(macos(13.0), ios(16.0)) +{ + return self.real.gpuResourceID; +} + - (void)getBytes:(void *)pixelBytes bytesPerRow:(NSUInteger)bytesPerRow bytesPerImage:(NSUInteger)bytesPerImage