Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_profiling.h
| Show All 22 Lines | |||||
| #include "util/util_thread.h" | #include "util/util_thread.h" | ||||
| #include "util/util_vector.h" | #include "util/util_vector.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| enum ProfilingEvent : uint32_t { | enum ProfilingEvent : uint32_t { | ||||
| PROFILING_UNKNOWN, | PROFILING_UNKNOWN, | ||||
| PROFILING_RAY_SETUP, | PROFILING_RAY_SETUP, | ||||
| PROFILING_PATH_INTEGRATE, | |||||
| PROFILING_SCENE_INTERSECT, | PROFILING_INTERSECT_CLOSEST, | ||||
| PROFILING_INDIRECT_EMISSION, | PROFILING_INTERSECT_SUBSURFACE, | ||||
| PROFILING_VOLUME, | PROFILING_INTERSECT_SHADOW, | ||||
| PROFILING_SHADER_SETUP, | PROFILING_INTERSECT_VOLUME_STACK, | ||||
| PROFILING_SHADER_EVAL, | |||||
| PROFILING_SHADER_APPLY, | PROFILING_SHADE_SURFACE_SETUP, | ||||
| PROFILING_AO, | PROFILING_SHADE_SURFACE_EVAL, | ||||
| PROFILING_SUBSURFACE, | PROFILING_SHADE_SURFACE_DIRECT_LIGHT, | ||||
| PROFILING_CONNECT_LIGHT, | PROFILING_SHADE_SURFACE_INDIRECT_LIGHT, | ||||
| PROFILING_SURFACE_BOUNCE, | PROFILING_SHADE_SURFACE_AO, | ||||
| PROFILING_WRITE_RESULT, | PROFILING_SHADE_SURFACE_PASSES, | ||||
| PROFILING_INTERSECT, | PROFILING_SHADE_VOLUME_SETUP, | ||||
| PROFILING_INTERSECT_LOCAL, | PROFILING_SHADE_VOLUME_INTEGRATE, | ||||
| PROFILING_INTERSECT_SHADOW_ALL, | PROFILING_SHADE_VOLUME_DIRECT_LIGHT, | ||||
| PROFILING_INTERSECT_VOLUME, | PROFILING_SHADE_VOLUME_INDIRECT_LIGHT, | ||||
| PROFILING_INTERSECT_VOLUME_ALL, | |||||
| PROFILING_SHADE_SHADOW_SETUP, | |||||
| PROFILING_CLOSURE_EVAL, | PROFILING_SHADE_SHADOW_SURFACE, | ||||
| PROFILING_CLOSURE_SAMPLE, | PROFILING_SHADE_SHADOW_VOLUME, | ||||
| PROFILING_CLOSURE_VOLUME_EVAL, | |||||
| PROFILING_CLOSURE_VOLUME_SAMPLE, | PROFILING_SHADE_LIGHT_SETUP, | ||||
| PROFILING_SHADE_LIGHT_EVAL, | |||||
| PROFILING_DENOISING, | |||||
| PROFILING_DENOISING_CONSTRUCT_TRANSFORM, | |||||
| PROFILING_DENOISING_RECONSTRUCT, | |||||
| PROFILING_DENOISING_DIVIDE_SHADOW, | |||||
| PROFILING_DENOISING_NON_LOCAL_MEANS, | |||||
| PROFILING_DENOISING_COMBINE_HALVES, | |||||
| PROFILING_DENOISING_GET_FEATURE, | |||||
| PROFILING_DENOISING_DETECT_OUTLIERS, | |||||
| PROFILING_NUM_EVENTS, | PROFILING_NUM_EVENTS, | ||||
| }; | }; | ||||
| /* Contains the current execution state of a worker thread. | /* Contains the current execution state of a worker thread. | ||||
| * These values are constantly updated by the worker. | * These values are constantly updated by the worker. | ||||
| * Periodically the profiler thread will wake up, read them | * Periodically the profiler thread will wake up, read them | ||||
| * and update its internal counters based on it. | * and update its internal counters based on it. | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| class ProfilingHelper { | class ProfilingHelper { | ||||
| public: | public: | ||||
| ProfilingHelper(ProfilingState *state, ProfilingEvent event) : state(state) | ProfilingHelper(ProfilingState *state, ProfilingEvent event) : state(state) | ||||
| { | { | ||||
| previous_event = state->event; | previous_event = state->event; | ||||
| state->event = event; | state->event = event; | ||||
| } | } | ||||
| ~ProfilingHelper() | |||||
| { | |||||
| state->event = previous_event; | |||||
| } | |||||
| inline void set_event(ProfilingEvent event) | inline void set_event(ProfilingEvent event) | ||||
| { | { | ||||
| state->event = event; | state->event = event; | ||||
| } | } | ||||
| inline void set_shader(int shader) | protected: | ||||
| ProfilingState *state; | |||||
| uint32_t previous_event; | |||||
| }; | |||||
| class ProfilingWithShaderHelper : public ProfilingHelper { | |||||
| public: | |||||
| ProfilingWithShaderHelper(ProfilingState *state, ProfilingEvent event) | |||||
| : ProfilingHelper(state, event) | |||||
| { | { | ||||
| state->shader = shader; | |||||
| if (state->active) { | |||||
| assert(shader < state->shader_hits.size()); | |||||
| state->shader_hits[shader]++; | |||||
| } | } | ||||
| ~ProfilingWithShaderHelper() | |||||
| { | |||||
| state->object = -1; | |||||
| state->shader = -1; | |||||
| } | } | ||||
| inline void set_object(int object) | inline void set_shader(int object, int shader) | ||||
| { | { | ||||
| state->object = object; | |||||
| if (state->active) { | if (state->active) { | ||||
| state->shader = shader; | |||||
| state->object = object; | |||||
| if (shader >= 0) { | |||||
| assert(shader < state->shader_hits.size()); | |||||
| state->shader_hits[shader]++; | |||||
| } | |||||
| if (object >= 0) { | |||||
| assert(object < state->object_hits.size()); | assert(object < state->object_hits.size()); | ||||
| state->object_hits[object]++; | state->object_hits[object]++; | ||||
| } | } | ||||
| } | } | ||||
| ~ProfilingHelper() | |||||
| { | |||||
| state->event = previous_event; | |||||
| } | } | ||||
| private: | |||||
| ProfilingState *state; | |||||
| uint32_t previous_event; | |||||
| }; | }; | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| #endif /* __UTIL_PROFILING_H__ */ | #endif /* __UTIL_PROFILING_H__ */ | ||||