UnityMetalSupport.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. // we are still allowing to build with older sdk and run on simulator without metal support (pre MacOS 10.15)
  3. // it is expected to substitute Metal.h so we assume this is used only with objc
  4. #ifdef __cplusplus
  5. extern "C" typedef MTLDeviceRef (*MTLCreateSystemDefaultDeviceFunc)();
  6. #else
  7. typedef MTLDeviceRef (*MTLCreateSystemDefaultDeviceFunc)();
  8. #endif
  9. #if UNITY_CAN_USE_METAL
  10. #import <Metal/Metal.h>
  11. #import <QuartzCore/CAMetalLayer.h>
  12. #else
  13. // even if we cant use metal, we should be able to build it still: we need protocol declarations
  14. @interface CAMetalLayer : CALayer
  15. @property (readwrite) BOOL framebufferOnly;
  16. @property (readwrite) CGSize drawableSize;
  17. @property BOOL presentsWithTransaction;
  18. @property (readwrite, retain) id<MTLDevice> device;
  19. @property (readwrite) MTLPixelFormat pixelFormat;
  20. @property (readonly) id<MTLTexture> texture;
  21. - (id<CAMetalDrawable>)newDrawable;
  22. - (id<CAMetalDrawable>)nextDrawable;
  23. @end
  24. @protocol MTLDrawable
  25. @end
  26. @protocol CAMetalDrawable<MTLDrawable>
  27. @property (readonly) id<MTLTexture> texture;
  28. @end
  29. @protocol MTLDevice
  30. - (id<MTLCommandQueue>)newCommandQueue;
  31. - (id<MTLCommandQueue>)newCommandQueueWithMaxCommandBufferCount:(NSUInteger)maxCommandBufferCount;
  32. - (BOOL)supportsTextureSampleCount:(NSUInteger)sampleCount;
  33. @end
  34. @protocol MTLCommandBuffer
  35. - (void)presentDrawable:(id<MTLDrawable>)drawable;
  36. @end
  37. #endif