IUnityGraphics.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // Has to match the GfxDeviceRenderer enum
  9. typedef enum UnityGfxRenderer
  10. {
  11. //kUnityGfxRendererOpenGL = 0, // Legacy OpenGL, removed
  12. //kUnityGfxRendererD3D9 = 1, // Direct3D 9, removed
  13. kUnityGfxRendererD3D11 = 2, // Direct3D 11
  14. kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
  15. kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0
  16. kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
  17. //kUnityGfxRendererGXM = 12, // PlayStation Vita, removed
  18. kUnityGfxRendererPS4 = 13, // PlayStation 4
  19. kUnityGfxRendererXboxOne = 14, // Xbox One
  20. kUnityGfxRendererMetal = 16, // iOS Metal
  21. kUnityGfxRendererOpenGLCore = 17, // OpenGL core
  22. kUnityGfxRendererD3D12 = 18, // Direct3D 12
  23. kUnityGfxRendererVulkan = 21, // Vulkan
  24. kUnityGfxRendererNvn = 22, // Nintendo Switch NVN API
  25. kUnityGfxRendererXboxOneD3D12 = 23, // MS XboxOne Direct3D 12
  26. kUnityGfxRendererGameCoreXboxOne = 24, // GameCore Xbox One
  27. kUnityGfxRendererGameCoreXboxSeries = 25, // GameCore XboxSeries
  28. kUnityGfxRendererPS5 = 26, // PS5
  29. kUnityGfxRendererPS5NGGC = 27 // PS5 NGGC
  30. } UnityGfxRenderer;
  31. typedef enum UnityGfxDeviceEventType
  32. {
  33. kUnityGfxDeviceEventInitialize = 0,
  34. kUnityGfxDeviceEventShutdown = 1,
  35. kUnityGfxDeviceEventBeforeReset = 2,
  36. kUnityGfxDeviceEventAfterReset = 3,
  37. } UnityGfxDeviceEventType;
  38. typedef void (UNITY_INTERFACE_API * IUnityGraphicsDeviceEventCallback)(UnityGfxDeviceEventType eventType);
  39. // Should only be used on the rendering thread unless noted otherwise.
  40. UNITY_DECLARE_INTERFACE(IUnityGraphics)
  41. {
  42. UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)(); // Thread safe
  43. // This callback will be called when graphics device is created, destroyed, reset, etc.
  44. // It is possible to miss the kUnityGfxDeviceEventInitialize event in case plugin is loaded at a later time,
  45. // when the graphics device is already created.
  46. void(UNITY_INTERFACE_API * RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  47. void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  48. int(UNITY_INTERFACE_API * ReserveEventIDRange)(int count); // reserves 'count' event IDs. Plugins should use the result as a base index when issuing events back and forth to avoid event id clashes.
  49. };
  50. UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL, 0x8C5AD4926EB17B11ULL, IUnityGraphics)
  51. // Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can callback into native plugins.
  52. // Provide them with an address to a function of this signature.
  53. typedef void (UNITY_INTERFACE_API * UnityRenderingEvent)(int eventId);
  54. typedef void (UNITY_INTERFACE_API * UnityRenderingEventAndData)(int eventId, void* data);