Path: blob/master/thirdparty/embree/kernels/common/state.h
9905 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#pragma once45#include "default.h"67namespace embree8{9/* mutex to make printing to cout thread safe */10extern MutexSys g_printMutex;11struct RTCErrorMessage12{13RTCErrorMessage(RTCError error, std::string const& msg)14: error(error), msg(msg) {}1516RTCError error;17std::string msg;18};1920struct State : public RefCount21{22public:23/*! state construction */24State ();2526/*! state destruction */27~State();2829/*! verifies that state is correct */30void verify();3132/*! parses state from a configuration file */33bool parseFile(const FileName& fileName);3435/*! parses the state from a string */36void parseString(const char* cfg);3738/*! parses the state from a stream */39void parse(Ref<TokenStream> cin);4041/*! prints the state */42void print();4344/*! checks if verbosity level is at least N */45bool verbosity(size_t N);4647/*! checks if some particular ISA is enabled */48bool hasISA(const int isa);4950/*! check whether selected ISA is supported by the HW */51bool checkISASupport();5253public:54std::string tri_accel; //!< acceleration structure to use for triangles55std::string tri_builder; //!< builder to use for triangles56std::string tri_traverser; //!< traverser to use for triangles5758public:59std::string tri_accel_mb; //!< acceleration structure to use for motion blur triangles60std::string tri_builder_mb; //!< builder to use for motion blur triangles61std::string tri_traverser_mb; //!< traverser to use for triangles6263public:64std::string quad_accel; //!< acceleration structure to use for quads65std::string quad_builder; //!< builder to use for quads66std::string quad_traverser; //!< traverser to use for quads6768public:69std::string quad_accel_mb; //!< acceleration structure to use for motion blur quads70std::string quad_builder_mb; //!< builder to use for motion blur quads71std::string quad_traverser_mb; //!< traverser to use for motion blur quads7273public:74std::string line_accel; //!< acceleration structure to use for line segments75std::string line_builder; //!< builder to use for line segments76std::string line_traverser; //!< traverser to use for line segments7778public:79std::string line_accel_mb; //!< acceleration structure to use for motion blur line segments80std::string line_builder_mb; //!< builder to use for motion blur line segments81std::string line_traverser_mb; //!< traverser to use for motion blur line segments8283public:84std::string hair_accel; //!< hair acceleration structure to use85std::string hair_builder; //!< builder to use for hair86std::string hair_traverser; //!< traverser to use for hair8788public:89std::string hair_accel_mb; //!< acceleration structure to use for motion blur hair90std::string hair_builder_mb; //!< builder to use for motion blur hair91std::string hair_traverser_mb; //!< traverser to use for motion blur hair9293public:94std::string object_accel; //!< acceleration structure for user geometries95std::string object_builder; //!< builder for user geometries96int object_accel_min_leaf_size; //!< minimum leaf size for object acceleration structure97int object_accel_max_leaf_size; //!< maximum leaf size for object acceleration structure9899public:100std::string object_accel_mb; //!< acceleration structure for user geometries101std::string object_builder_mb; //!< builder for user geometries102int object_accel_mb_min_leaf_size; //!< minimum leaf size for mblur object acceleration structure103int object_accel_mb_max_leaf_size; //!< maximum leaf size for mblur object acceleration structure104105public:106std::string subdiv_accel; //!< acceleration structure to use for subdivision surfaces107std::string subdiv_accel_mb; //!< acceleration structure to use for subdivision surfaces108109public:110std::string grid_accel; //!< acceleration structure to use for grids111std::string grid_builder; //!< builder for grids112std::string grid_accel_mb; //!< acceleration structure to use for motion blur grids113std::string grid_builder_mb; //!< builder for motion blur grids114115public:116float max_spatial_split_replications; //!< maximally replications*N many primitives in accel for spatial splits117bool useSpatialPreSplits; //!< use spatial pre-splits instead of the full spatial split builder118size_t tessellation_cache_size; //!< size of the shared tessellation cache119size_t max_triangles_per_leaf;120121public:122size_t instancing_open_min; //!< instancing opens tree to minimally that number of subtrees123size_t instancing_block_size; //!< instancing opens tree up to average block size of primitives124float instancing_open_factor; //!< instancing opens tree up to x times the number of instances125size_t instancing_open_max_depth; //!< maximum open depth for geometries126size_t instancing_open_max; //!< instancing opens tree to maximally that number of subtrees127128public:129bool float_exceptions; //!< enable floating point exceptions130int quality_flags;131int scene_flags;132size_t verbose; //!< verbosity of output133size_t benchmark; //!< true134135public:136size_t numThreads; //!< number of threads to use in builders137size_t numUserThreads; //!< number of user provided threads to use in builders138bool set_affinity; //!< sets affinity for worker threads139bool start_threads; //!< true when threads should be started at device creation time140int enabled_cpu_features; //!< CPU ISA features to use141int enabled_builder_cpu_features; //!< CPU ISA features to use for builders only142enum FREQUENCY_LEVEL {143FREQUENCY_SIMD128,144FREQUENCY_SIMD256,145FREQUENCY_SIMD512146} frequency_level; //!< frequency level the app wants to run on (default is SIMD256)147bool enable_selockmemoryprivilege; //!< configures the SeLockMemoryPrivilege under Windows to enable huge pages148bool hugepages; //!< true if huge pages should get used149bool hugepages_success; //!< status for enabling huge pages150151public:152size_t alloc_main_block_size; //!< main allocation block size (shared between threads)153int alloc_num_main_slots; //!< number of such shared blocks to be used to allocate154size_t alloc_thread_block_size; //!< size of thread local allocator block size155int alloc_single_thread_alloc; //!< in single mode nodes and leaves use same thread local allocator156157public:158159/*! checks if we can use AVX */160bool canUseAVX() {161return hasISA(AVX) && frequency_level != FREQUENCY_SIMD128;162}163164/*! checks if we can use AVX2 */165bool canUseAVX2() {166return hasISA(AVX2) && frequency_level != FREQUENCY_SIMD128;167}168169struct ErrorHandler170{171public:172ErrorHandler();173~ErrorHandler();174RTCErrorMessage* error();175176public:177tls_t thread_error;178std::vector<RTCErrorMessage*> thread_errors;179MutexSys errors_mutex;180};181ErrorHandler errorHandler;182static ErrorHandler g_errorHandler;183184public:185void setErrorFunction(RTCErrorFunction fptr, void* uptr)186{187error_function = fptr;188error_function_userptr = uptr;189}190191RTCErrorFunction error_function;192void* error_function_userptr;193194public:195void setMemoryMonitorFunction(RTCMemoryMonitorFunction fptr, void* uptr)196{197memory_monitor_function = fptr;198memory_monitor_userptr = uptr;199}200201RTCMemoryMonitorFunction memory_monitor_function;202void* memory_monitor_userptr;203};204}205206207