Blender
V4.3
intern
cycles
device
cpu
kernel_thread_globals.cpp
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#include "
device/cpu/kernel_thread_globals.h
"
6
7
#include "
kernel/osl/globals.h
"
8
9
#include "util/profiling.h"
10
11
CCL_NAMESPACE_BEGIN
12
13
CPUKernelThreadGlobals::CPUKernelThreadGlobals
(
const
KernelGlobalsCPU
&kernel_globals,
14
void
*osl_globals_memory,
15
Profiler
&cpu_profiler,
16
const
int
thread_index)
17
:
KernelGlobalsCPU
(kernel_globals),
cpu_profiler_
(cpu_profiler)
18
{
19
clear_runtime_pointers
();
20
21
#ifdef WITH_OSL
22
OSLGlobals::thread_init(
this
,
static_cast<
OSLGlobals *
>
(osl_globals_memory), thread_index);
23
#else
24
(void)thread_index;
25
(void)osl_globals_memory;
26
#endif
27
28
#ifdef WITH_PATH_GUIDING
29
opgl_path_segment_storage =
new
openpgl::cpp::PathSegmentStorage();
30
#endif
31
}
32
33
CPUKernelThreadGlobals::CPUKernelThreadGlobals
(
CPUKernelThreadGlobals
&&other) noexcept
34
:
KernelGlobalsCPU
(std::move(other)),
cpu_profiler_
(other.cpu_profiler_)
35
{
36
other.clear_runtime_pointers();
37
}
38
39
CPUKernelThreadGlobals::~CPUKernelThreadGlobals
()
40
{
41
#ifdef WITH_OSL
42
OSLGlobals::thread_free(
this
);
43
#endif
44
45
#ifdef WITH_PATH_GUIDING
46
delete
opgl_path_segment_storage;
47
delete
opgl_surface_sampling_distribution;
48
delete
opgl_volume_sampling_distribution;
49
#endif
50
}
51
52
CPUKernelThreadGlobals
&
CPUKernelThreadGlobals::operator=
(
CPUKernelThreadGlobals
&&other)
53
{
54
if
(
this
== &other) {
55
return
*
this
;
56
}
57
58
*
static_cast<
KernelGlobalsCPU
*
>
(
this
) = *
static_cast<
KernelGlobalsCPU
*
>
(&other);
59
60
other.clear_runtime_pointers();
61
62
return
*
this
;
63
}
64
65
void
CPUKernelThreadGlobals::clear_runtime_pointers
()
66
{
67
#ifdef WITH_OSL
68
osl =
nullptr
;
69
#endif
70
71
#ifdef WITH_PATH_GUIDING
72
opgl_sample_data_storage =
nullptr
;
73
opgl_guiding_field =
nullptr
;
74
75
opgl_path_segment_storage =
nullptr
;
76
opgl_surface_sampling_distribution =
nullptr
;
77
opgl_volume_sampling_distribution =
nullptr
;
78
#endif
79
}
80
81
void
CPUKernelThreadGlobals::start_profiling
()
82
{
83
cpu_profiler_
.add_state(&
profiler
);
84
}
85
86
void
CPUKernelThreadGlobals::stop_profiling
()
87
{
88
cpu_profiler_
.remove_state(&
profiler
);
89
}
90
91
CCL_NAMESPACE_END
CPUKernelThreadGlobals::operator=
CPUKernelThreadGlobals & operator=(const CPUKernelThreadGlobals &other)=delete
CPUKernelThreadGlobals::stop_profiling
void stop_profiling()
Definition
kernel_thread_globals.cpp:86
CPUKernelThreadGlobals::start_profiling
void start_profiling()
Definition
kernel_thread_globals.cpp:81
CPUKernelThreadGlobals::~CPUKernelThreadGlobals
~CPUKernelThreadGlobals()
Definition
kernel_thread_globals.cpp:39
CPUKernelThreadGlobals::cpu_profiler_
Profiler & cpu_profiler_
Definition
kernel_thread_globals.h:43
CPUKernelThreadGlobals::CPUKernelThreadGlobals
CPUKernelThreadGlobals(const KernelGlobalsCPU &kernel_globals, void *osl_globals_memory, Profiler &cpu_profiler, const int thread_index)
Definition
kernel_thread_globals.cpp:13
CPUKernelThreadGlobals::clear_runtime_pointers
void clear_runtime_pointers()
Definition
kernel_thread_globals.cpp:65
Profiler
Definition
util/profiling.h:72
KernelGlobalsCPU
struct KernelGlobalsCPU KernelGlobalsCPU
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
kernel_thread_globals.h
CCL_NAMESPACE_BEGIN
Definition
python.cpp:44
globals.h
KernelGlobalsCPU
Definition
device/cpu/globals.h:40
KernelGlobalsCPU::profiler
ProfilingState profiler
Definition
device/cpu/globals.h:68
Generated on Sat Oct 4 2025 05:32:23 for Blender by
doxygen
1.14.0