| 1 | // Copyright 2009-2021 Intel Corporation |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "default.h" |
| 7 | #include "state.h" |
| 8 | #include "accel.h" |
| 9 | |
| 10 | namespace embree |
| 11 | { |
| 12 | class BVH4Factory; |
| 13 | class BVH8Factory; |
| 14 | |
| 15 | class Device : public State, public MemoryMonitorInterface |
| 16 | { |
| 17 | ALIGNED_CLASS_(16); |
| 18 | |
| 19 | public: |
| 20 | |
| 21 | /*! Device construction */ |
| 22 | Device (const char* cfg); |
| 23 | |
| 24 | /*! Device destruction */ |
| 25 | virtual ~Device (); |
| 26 | |
| 27 | /*! prints info about the device */ |
| 28 | void print(); |
| 29 | |
| 30 | /*! sets the error code */ |
| 31 | void setDeviceErrorCode(RTCError error); |
| 32 | |
| 33 | /*! returns and clears the error code */ |
| 34 | RTCError getDeviceErrorCode(); |
| 35 | |
| 36 | /*! sets the error code */ |
| 37 | static void setThreadErrorCode(RTCError error); |
| 38 | |
| 39 | /*! returns and clears the error code */ |
| 40 | static RTCError getThreadErrorCode(); |
| 41 | |
| 42 | /*! processes error codes, do not call directly */ |
| 43 | static void process_error(Device* device, RTCError error, const char* str); |
| 44 | |
| 45 | /*! invokes the memory monitor callback */ |
| 46 | void memoryMonitor(ssize_t bytes, bool post); |
| 47 | |
| 48 | /*! sets the size of the software cache. */ |
| 49 | void setCacheSize(size_t bytes); |
| 50 | |
| 51 | /*! sets a property */ |
| 52 | void setProperty(const RTCDeviceProperty prop, ssize_t val); |
| 53 | |
| 54 | /*! gets a property */ |
| 55 | ssize_t getProperty(const RTCDeviceProperty prop); |
| 56 | |
| 57 | private: |
| 58 | |
| 59 | /*! initializes the tasking system */ |
| 60 | void initTaskingSystem(size_t numThreads); |
| 61 | |
| 62 | /*! shuts down the tasking system */ |
| 63 | void exitTaskingSystem(); |
| 64 | |
| 65 | /*! some variables that can be set via rtcSetParameter1i for debugging purposes */ |
| 66 | public: |
| 67 | static ssize_t debug_int0; |
| 68 | static ssize_t debug_int1; |
| 69 | static ssize_t debug_int2; |
| 70 | static ssize_t debug_int3; |
| 71 | |
| 72 | public: |
| 73 | std::unique_ptr<BVH4Factory> bvh4_factory; |
| 74 | #if defined(EMBREE_TARGET_SIMD8) |
| 75 | std::unique_ptr<BVH8Factory> bvh8_factory; |
| 76 | #endif |
| 77 | |
| 78 | #if USE_TASK_ARENA |
| 79 | std::unique_ptr<tbb::task_arena> arena; |
| 80 | #endif |
| 81 | |
| 82 | /* ray streams filter */ |
| 83 | RayStreamFilterFuncs rayStreamFilters; |
| 84 | }; |
| 85 | } |
| 86 | |