device.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #pragma once
  17. #include "default.h"
  18. #include "state.h"
  19. #include "accel.h"
  20. namespace embree
  21. {
  22. class BVH4Factory;
  23. class BVH8Factory;
  24. class InstanceFactory;
  25. class Device : public State, public MemoryMonitorInterface
  26. {
  27. ALIGNED_CLASS;
  28. public:
  29. /*! Device construction */
  30. Device (const char* cfg, bool singledevice);
  31. /*! Device destruction */
  32. virtual ~Device ();
  33. /*! prints info about the device */
  34. void print();
  35. /*! sets the error code */
  36. void setDeviceErrorCode(RTCError error);
  37. /*! returns and clears the error code */
  38. RTCError getDeviceErrorCode();
  39. /*! sets the error code */
  40. static void setThreadErrorCode(RTCError error);
  41. /*! returns and clears the error code */
  42. static RTCError getThreadErrorCode();
  43. /*! processes error codes, do not call directly */
  44. static void process_error(Device* device, RTCError error, const char* str);
  45. /*! invokes the memory monitor callback */
  46. void memoryMonitor(ssize_t bytes, bool post);
  47. /*! sets the size of the software cache. */
  48. void setCacheSize(size_t bytes);
  49. /*! configures some parameter */
  50. void setParameter1i(const RTCParameter parm, ssize_t val);
  51. /*! returns some configuration */
  52. ssize_t getParameter1i(const RTCParameter parm);
  53. private:
  54. /*! initializes the tasking system */
  55. void initTaskingSystem(size_t numThreads);
  56. /*! shuts down the tasking system */
  57. void exitTaskingSystem();
  58. /*! some variables that can be set via rtcSetParameter1i for debugging purposes */
  59. public:
  60. static ssize_t debug_int0;
  61. static ssize_t debug_int1;
  62. static ssize_t debug_int2;
  63. static ssize_t debug_int3;
  64. public:
  65. bool singledevice; //!< true if this is the device created implicitely through rtcInit
  66. std::unique_ptr<InstanceFactory> instance_factory;
  67. std::unique_ptr<BVH4Factory> bvh4_factory;
  68. #if defined(__TARGET_AVX__)
  69. std::unique_ptr<BVH8Factory> bvh8_factory;
  70. #endif
  71. #if USE_TASK_ARENA
  72. std::unique_ptr<tbb::task_arena> arena;
  73. #endif
  74. /* ray streams filter */
  75. RayStreamFilterFuncs rayStreamFilters;
  76. };
  77. }