UnityMetalSupport.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. // we allow to build with sdk 9.0 (and run on ios7) so we need to take an extra care about Metal support
  3. // it is expected to substitute Metal.h so only 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. // everything below is to allow compilation of the code that uses metal interfaces for simulator
  14. // as protocols declarations should be available even if we do not call functions themselves
  15. #if !(TARGET_IPHONE_SIMULATOR && defined(__IPHONE_11_0)) && !(TARGET_TVOS_SIMULATOR && defined(__TVOS_11_0))
  16. typedef NSUInteger MTLPixelFormat;
  17. enum
  18. {
  19. MTLPixelFormatBGRA8Unorm,
  20. MTLPixelFormatBGRA8Unorm_sRGB,
  21. };
  22. #endif
  23. @interface CAMetalLayer : CALayer
  24. @property (readwrite) BOOL framebufferOnly;
  25. @property (readwrite) CGSize drawableSize;
  26. @property BOOL presentsWithTransaction;
  27. @property (readwrite, retain) id<MTLDevice> device;
  28. @property (readwrite) MTLPixelFormat pixelFormat;
  29. @property (readonly) id<MTLTexture> texture;
  30. - (id<CAMetalDrawable>)newDrawable;
  31. - (id<CAMetalDrawable>)nextDrawable;
  32. @end
  33. @protocol MTLDrawable
  34. @end
  35. @protocol CAMetalDrawable<MTLDrawable>
  36. @property (readonly) id<MTLTexture> texture;
  37. @end
  38. @protocol MTLDevice
  39. - (id<MTLCommandQueue>)newCommandQueue;
  40. - (BOOL)supportsTextureSampleCount:(NSUInteger)sampleCount;
  41. @end
  42. @protocol MTLCommandBuffer
  43. - (void)presentDrawable:(id<MTLDrawable>)drawable;
  44. @end
  45. #endif