rtcore_device.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "rtcore_common.h"
  5. RTC_NAMESPACE_BEGIN
  6. /* Opaque device type */
  7. typedef struct RTCDeviceTy* RTCDevice;
  8. typedef struct RTCSceneTy* RTCScene;
  9. /* Creates a new Embree device. */
  10. RTC_API RTCDevice rtcNewDevice(const char* config);
  11. #if defined(EMBREE_SYCL_SUPPORT) && defined(SYCL_LANGUAGE_VERSION)
  12. /*
  13. Creates a new Embree SYCL device. It will internally select the first SYCL device of
  14. the SYCL context as the default device for memory allocations. You can set a specific
  15. SYCL device that's part of the SYCL context by calling rtcSetDeviceSYCLDevice.
  16. */
  17. RTC_API_EXTERN_C RTCDevice rtcNewSYCLDevice(sycl::context context, const char* config);
  18. /* Checks if SYCL device is supported by Embree. */
  19. RTC_API bool rtcIsSYCLDeviceSupported(const sycl::device sycl_device);
  20. /* SYCL selector for Embree supported devices */
  21. RTC_API int rtcSYCLDeviceSelector(const sycl::device sycl_device);
  22. /* Set the SYCL device to be used to allocate data */
  23. RTC_API void rtcSetDeviceSYCLDevice(RTCDevice device, const sycl::device sycl_device);
  24. /* rtcCommitSceneWithQueue is asynchronous, user has to call queue.wait()
  25. for synchronization. rtcCommitScene is blocking. */
  26. RTC_API_CPP sycl::event rtcCommitSceneWithQueue(RTCScene scene, sycl::queue queue);
  27. #endif
  28. /* Retains the Embree device (increments the reference count). */
  29. RTC_API void rtcRetainDevice(RTCDevice device);
  30. /* Releases an Embree device (decrements the reference count). */
  31. RTC_API void rtcReleaseDevice(RTCDevice device);
  32. /* Device properties */
  33. enum RTCDeviceProperty
  34. {
  35. RTC_DEVICE_PROPERTY_VERSION = 0,
  36. RTC_DEVICE_PROPERTY_VERSION_MAJOR = 1,
  37. RTC_DEVICE_PROPERTY_VERSION_MINOR = 2,
  38. RTC_DEVICE_PROPERTY_VERSION_PATCH = 3,
  39. RTC_DEVICE_PROPERTY_NATIVE_RAY4_SUPPORTED = 32,
  40. RTC_DEVICE_PROPERTY_NATIVE_RAY8_SUPPORTED = 33,
  41. RTC_DEVICE_PROPERTY_NATIVE_RAY16_SUPPORTED = 34,
  42. RTC_DEVICE_PROPERTY_BACKFACE_CULLING_SPHERES_ENABLED = 62,
  43. RTC_DEVICE_PROPERTY_BACKFACE_CULLING_CURVES_ENABLED = 63,
  44. RTC_DEVICE_PROPERTY_RAY_MASK_SUPPORTED = 64,
  45. RTC_DEVICE_PROPERTY_BACKFACE_CULLING_ENABLED = 65,
  46. RTC_DEVICE_PROPERTY_FILTER_FUNCTION_SUPPORTED = 66,
  47. RTC_DEVICE_PROPERTY_IGNORE_INVALID_RAYS_ENABLED = 67,
  48. RTC_DEVICE_PROPERTY_COMPACT_POLYS_ENABLED = 68,
  49. RTC_DEVICE_PROPERTY_TRIANGLE_GEOMETRY_SUPPORTED = 96,
  50. RTC_DEVICE_PROPERTY_QUAD_GEOMETRY_SUPPORTED = 97,
  51. RTC_DEVICE_PROPERTY_SUBDIVISION_GEOMETRY_SUPPORTED = 98,
  52. RTC_DEVICE_PROPERTY_CURVE_GEOMETRY_SUPPORTED = 99,
  53. RTC_DEVICE_PROPERTY_USER_GEOMETRY_SUPPORTED = 100,
  54. RTC_DEVICE_PROPERTY_POINT_GEOMETRY_SUPPORTED = 101,
  55. RTC_DEVICE_PROPERTY_TASKING_SYSTEM = 128,
  56. RTC_DEVICE_PROPERTY_JOIN_COMMIT_SUPPORTED = 129,
  57. RTC_DEVICE_PROPERTY_PARALLEL_COMMIT_SUPPORTED = 130,
  58. RTC_DEVICE_PROPERTY_CPU_DEVICE = 140,
  59. RTC_DEVICE_PROPERTY_SYCL_DEVICE = 141
  60. };
  61. /* Gets a device property. */
  62. RTC_API ssize_t rtcGetDeviceProperty(RTCDevice device, enum RTCDeviceProperty prop);
  63. /* Sets a device property. */
  64. RTC_API void rtcSetDeviceProperty(RTCDevice device, const enum RTCDeviceProperty prop, ssize_t value);
  65. /* Error codes */
  66. enum RTCError
  67. {
  68. RTC_ERROR_NONE = 0,
  69. RTC_ERROR_UNKNOWN = 1,
  70. RTC_ERROR_INVALID_ARGUMENT = 2,
  71. RTC_ERROR_INVALID_OPERATION = 3,
  72. RTC_ERROR_OUT_OF_MEMORY = 4,
  73. RTC_ERROR_UNSUPPORTED_CPU = 5,
  74. RTC_ERROR_CANCELLED = 6,
  75. RTC_ERROR_LEVEL_ZERO_RAYTRACING_SUPPORT_MISSING = 7,
  76. };
  77. /* Returns the string representation for the error code. For example, for RTC_ERROR_UNKNOWN the string "RTC_ERROR_UNKNOWN" will be returned. */
  78. RTC_API const char* rtcGetErrorString(enum RTCError error);
  79. /* Returns the error code. */
  80. RTC_API enum RTCError rtcGetDeviceError(RTCDevice device);
  81. /* Returns a message corresponding to the last error code (returned by rtcGetDeviceError) which provides details about the error that happened.
  82. The same message will be written to console when verbosity is > 0 or when an error callback function is set for the device.
  83. However, when device creation itself fails this is the only way to get additional information about the error. */
  84. RTC_API const char* rtcGetDeviceLastErrorMessage(RTCDevice device);
  85. /* Error callback function */
  86. typedef void (*RTCErrorFunction)(void* userPtr, enum RTCError code, const char* str);
  87. /* Sets the error callback function. */
  88. RTC_API void rtcSetDeviceErrorFunction(RTCDevice device, RTCErrorFunction error, void* userPtr);
  89. /* Memory monitor callback function */
  90. typedef bool (*RTCMemoryMonitorFunction)(void* ptr, ssize_t bytes, bool post);
  91. /* Sets the memory monitor callback function. */
  92. RTC_API void rtcSetDeviceMemoryMonitorFunction(RTCDevice device, RTCMemoryMonitorFunction memoryMonitor, void* userPtr);
  93. RTC_NAMESPACE_END