IUnityGraphicsMetal.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include "IUnityInterface.h"
  3. #ifndef __OBJC__
  4. #error metal plugin is objc code.
  5. #endif
  6. #ifndef __clang__
  7. #error only clang compiler is supported.
  8. #endif
  9. @class NSBundle;
  10. @protocol MTLDevice;
  11. @protocol MTLCommandBuffer;
  12. @protocol MTLCommandEncoder;
  13. @protocol MTLTexture;
  14. @class MTLRenderPassDescriptor;
  15. UNITY_DECLARE_INTERFACE(IUnityGraphicsMetalV1)
  16. {
  17. NSBundle* (UNITY_INTERFACE_API * MetalBundle)();
  18. id<MTLDevice>(UNITY_INTERFACE_API * MetalDevice)();
  19. id<MTLCommandBuffer>(UNITY_INTERFACE_API * CurrentCommandBuffer)();
  20. // for custom rendering support there are two scenarios:
  21. // you want to use current in-flight MTLCommandEncoder (NB: it might be nil)
  22. id<MTLCommandEncoder>(UNITY_INTERFACE_API * CurrentCommandEncoder)();
  23. // or you might want to create your own encoder.
  24. // In that case you should end unity's encoder before creating your own and end yours before returning control to unity
  25. void(UNITY_INTERFACE_API * EndCurrentCommandEncoder)();
  26. // returns MTLRenderPassDescriptor used to create current MTLCommandEncoder
  27. MTLRenderPassDescriptor* (UNITY_INTERFACE_API * CurrentRenderPassDescriptor)();
  28. // converting trampoline UnityRenderBufferHandle into native RenderBuffer
  29. UnityRenderBuffer(UNITY_INTERFACE_API * RenderBufferFromHandle)(void* bufferHandle);
  30. // access to RenderBuffer's texure
  31. // NB: you pass here *native* RenderBuffer, acquired by calling (C#) RenderBuffer.GetNativeRenderBufferPtr
  32. // AAResolvedTextureFromRenderBuffer will return nil in case of non-AA RenderBuffer or if called for depth RenderBuffer
  33. // StencilTextureFromRenderBuffer will return nil in case of no-stencil RenderBuffer or if called for color RenderBuffer
  34. id<MTLTexture>(UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer buffer);
  35. id<MTLTexture>(UNITY_INTERFACE_API * AAResolvedTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  36. id<MTLTexture>(UNITY_INTERFACE_API * StencilTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  37. };
  38. UNITY_REGISTER_INTERFACE_GUID(0x29F8F3D03833465EULL, 0x92138551C15D823DULL, IUnityGraphicsMetalV1)
  39. // deprecated: please use versioned interface above
  40. UNITY_DECLARE_INTERFACE(IUnityGraphicsMetal)
  41. {
  42. NSBundle* (UNITY_INTERFACE_API * MetalBundle)();
  43. id<MTLDevice>(UNITY_INTERFACE_API * MetalDevice)();
  44. id<MTLCommandBuffer>(UNITY_INTERFACE_API * CurrentCommandBuffer)();
  45. id<MTLCommandEncoder>(UNITY_INTERFACE_API * CurrentCommandEncoder)();
  46. void(UNITY_INTERFACE_API * EndCurrentCommandEncoder)();
  47. MTLRenderPassDescriptor* (UNITY_INTERFACE_API * CurrentRenderPassDescriptor)();
  48. UnityRenderBuffer(UNITY_INTERFACE_API * RenderBufferFromHandle)(void* bufferHandle);
  49. id<MTLTexture>(UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer buffer);
  50. id<MTLTexture>(UNITY_INTERFACE_API * AAResolvedTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  51. id<MTLTexture>(UNITY_INTERFACE_API * StencilTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  52. };
  53. UNITY_REGISTER_INTERFACE_GUID(0x992C8EAEA95811E5ULL, 0x9A62C4B5B9876117ULL, IUnityGraphicsMetal)