IUnityGraphics.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "IUnityInterface.h"
  3. typedef enum UnityGfxRenderer
  4. {
  5. //kUnityGfxRendererOpenGL = 0, // Legacy OpenGL, removed
  6. //kUnityGfxRendererD3D9 = 1, // Direct3D 9, removed
  7. kUnityGfxRendererD3D11 = 2, // Direct3D 11
  8. kUnityGfxRendererGCM = 3, // PlayStation 3
  9. kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
  10. kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0
  11. kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
  12. kUnityGfxRendererGXM = 12, // PlayStation Vita
  13. kUnityGfxRendererPS4 = 13, // PlayStation 4
  14. kUnityGfxRendererXboxOne = 14, // Xbox One
  15. kUnityGfxRendererMetal = 16, // iOS Metal
  16. kUnityGfxRendererOpenGLCore = 17, // OpenGL core
  17. kUnityGfxRendererD3D12 = 18, // Direct3D 12
  18. kUnityGfxRendererVulkan = 21, // Vulkan
  19. kUnityGfxRendererNvn = 22, // Nintendo Switch NVN API
  20. kUnityGfxRendererXboxOneD3D12 = 23 // MS XboxOne Direct3D 12
  21. } UnityGfxRenderer;
  22. typedef enum UnityGfxDeviceEventType
  23. {
  24. kUnityGfxDeviceEventInitialize = 0,
  25. kUnityGfxDeviceEventShutdown = 1,
  26. kUnityGfxDeviceEventBeforeReset = 2,
  27. kUnityGfxDeviceEventAfterReset = 3,
  28. } UnityGfxDeviceEventType;
  29. typedef void (UNITY_INTERFACE_API * IUnityGraphicsDeviceEventCallback)(UnityGfxDeviceEventType eventType);
  30. // Should only be used on the rendering thread unless noted otherwise.
  31. UNITY_DECLARE_INTERFACE(IUnityGraphics)
  32. {
  33. UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)(); // Thread safe
  34. // This callback will be called when graphics device is created, destroyed, reset, etc.
  35. // It is possible to miss the kUnityGfxDeviceEventInitialize event in case plugin is loaded at a later time,
  36. // when the graphics device is already created.
  37. void(UNITY_INTERFACE_API * RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  38. void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  39. 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.
  40. };
  41. UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL, 0x8C5AD4926EB17B11ULL, IUnityGraphics)
  42. // Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can callback into native plugins.
  43. // Provide them with an address to a function of this signature.
  44. typedef void (UNITY_INTERFACE_API * UnityRenderingEvent)(int eventId);
  45. typedef void (UNITY_INTERFACE_API * UnityRenderingEventAndData)(int eventId, void* data);