IUnityGraphicsMetal.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Unity Native Plugin API copyright © 2015 Unity Technologies ApS
  2. //
  3. // Licensed under the Unity Companion License for Unity - dependent projects--see[Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
  4. //
  5. // Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.Please review the license for details on these and other terms and conditions.
  6. #pragma once
  7. #include "IUnityInterface.h"
  8. #ifndef __OBJC__
  9. #error metal plugin is objc code.
  10. #endif
  11. #ifndef __clang__
  12. #error only clang compiler is supported.
  13. #endif
  14. @class NSBundle;
  15. @protocol MTLDevice;
  16. @protocol MTLCommandBuffer;
  17. @protocol MTLCommandEncoder;
  18. @protocol MTLTexture;
  19. @class MTLRenderPassDescriptor;
  20. UNITY_DECLARE_INTERFACE(IUnityGraphicsMetalV1)
  21. {
  22. NSBundle* (UNITY_INTERFACE_API * MetalBundle)();
  23. id<MTLDevice>(UNITY_INTERFACE_API * MetalDevice)();
  24. id<MTLCommandBuffer>(UNITY_INTERFACE_API * CurrentCommandBuffer)();
  25. // for custom rendering support there are two scenarios:
  26. // you want to use current in-flight MTLCommandEncoder (NB: it might be nil)
  27. id<MTLCommandEncoder>(UNITY_INTERFACE_API * CurrentCommandEncoder)();
  28. // or you might want to create your own encoder.
  29. // In that case you should end unity's encoder before creating your own and end yours before returning control to unity
  30. void(UNITY_INTERFACE_API * EndCurrentCommandEncoder)();
  31. // returns MTLRenderPassDescriptor used to create current MTLCommandEncoder
  32. MTLRenderPassDescriptor* (UNITY_INTERFACE_API * CurrentRenderPassDescriptor)();
  33. // converting trampoline UnityRenderBufferHandle into native RenderBuffer
  34. UnityRenderBuffer(UNITY_INTERFACE_API * RenderBufferFromHandle)(void* bufferHandle);
  35. // access to RenderBuffer's texure
  36. // NB: you pass here *native* RenderBuffer, acquired by calling (C#) RenderBuffer.GetNativeRenderBufferPtr
  37. // AAResolvedTextureFromRenderBuffer will return nil in case of non-AA RenderBuffer or if called for depth RenderBuffer
  38. // StencilTextureFromRenderBuffer will return nil in case of no-stencil RenderBuffer or if called for color RenderBuffer
  39. id<MTLTexture>(UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer buffer);
  40. id<MTLTexture>(UNITY_INTERFACE_API * AAResolvedTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  41. id<MTLTexture>(UNITY_INTERFACE_API * StencilTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  42. };
  43. UNITY_REGISTER_INTERFACE_GUID(0x29F8F3D03833465EULL, 0x92138551C15D823DULL, IUnityGraphicsMetalV1)
  44. // deprecated: please use versioned interface above
  45. UNITY_DECLARE_INTERFACE(IUnityGraphicsMetal)
  46. {
  47. NSBundle* (UNITY_INTERFACE_API * MetalBundle)();
  48. id<MTLDevice>(UNITY_INTERFACE_API * MetalDevice)();
  49. id<MTLCommandBuffer>(UNITY_INTERFACE_API * CurrentCommandBuffer)();
  50. id<MTLCommandEncoder>(UNITY_INTERFACE_API * CurrentCommandEncoder)();
  51. void(UNITY_INTERFACE_API * EndCurrentCommandEncoder)();
  52. MTLRenderPassDescriptor* (UNITY_INTERFACE_API * CurrentRenderPassDescriptor)();
  53. UnityRenderBuffer(UNITY_INTERFACE_API * RenderBufferFromHandle)(void* bufferHandle);
  54. id<MTLTexture>(UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer buffer);
  55. id<MTLTexture>(UNITY_INTERFACE_API * AAResolvedTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  56. id<MTLTexture>(UNITY_INTERFACE_API * StencilTextureFromRenderBuffer)(UnityRenderBuffer buffer);
  57. };
  58. UNITY_REGISTER_INTERFACE_GUID(0x992C8EAEA95811E5ULL, 0x9A62C4B5B9876117ULL, IUnityGraphicsMetal)