Blender V5.0
cpu/device_impl.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7/* So ImathMath is included before our kernel_cpu_compat. */
8#ifdef WITH_OSL
9# include <cstdint> /* Needed before `sdlexec.h` for `int32_t` with GCC 15.1. */
10/* So no context pollution happens from indirectly included windows.h */
11# ifdef _WIN32
12# include "util/windows.h"
13# endif
14# include <OSL/oslexec.h>
15#endif
16
17#ifdef WITH_EMBREE
18# include <embree4/rtcore.h>
19#endif
20
21#include "device/cpu/kernel.h"
22#include "device/device.h"
23#include "device/memory.h"
24
25// clang-format off
27#include "kernel/globals.h"
28
29#include "kernel/osl/globals.h"
30// clang-format on
31
32#include "util/guiding.h" // IWYU pragma: keep
33#include "util/unique_ptr.h"
34
36
37class CPUDevice : public Device {
38 public:
40
43
44#ifdef WITH_OSL
45 OSLGlobals osl_globals;
46#endif
47#ifdef WITH_EMBREE
48# if RTC_VERSION >= 40400
49 RTCTraversable embree_traversable = nullptr;
50# else
51 RTCScene embree_traversable = nullptr;
52# endif
53 RTCDevice embree_device;
54#endif
55#if defined(WITH_PATH_GUIDING)
56 mutable unique_ptr<openpgl::cpp::Device> guiding_device;
57#endif
58
59 CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool headless_);
60 ~CPUDevice() override;
61
62 BVHLayoutMask get_bvh_layout_mask(uint /*kernel_features*/) const override;
63
64 /* Returns true if the texture info was copied to the device (meaning, some more
65 * re-initialization might be needed). */
66 bool load_texture_info();
67
68 void mem_alloc(device_memory &mem) override;
69 void mem_copy_to(device_memory &mem) override;
70 void mem_move_to_host(device_memory &mem) override;
71 void mem_copy_from(
72 device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override;
73 void mem_zero(device_memory &mem) override;
74 void mem_free(device_memory &mem) override;
75 device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t /*size*/) override;
76
77 void const_copy_to(const char *name, void *host, const size_t size) override;
78
79 void global_alloc(device_memory &mem);
80 void global_free(device_memory &mem);
81
82 void tex_alloc(device_texture &mem);
83 void tex_free(device_texture &mem);
84
85 void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
86
87 void *get_guiding_device() const override;
88
90 vector<ThreadKernelGlobalsCPU> &kernel_thread_globals) override;
91 OSLGlobals *get_cpu_osl_memory() override;
92
93 protected:
94 bool load_kernels(uint /*kernel_features*/) override;
95};
96
unsigned int uint
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
Definition bvh/bvh.h:67
bool load_kernels(uint) override
bool need_texture_info
CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool headless_)
device_ptr mem_alloc_sub_ptr(device_memory &mem, const size_t offset, size_t) override
bool load_texture_info()
void mem_free(device_memory &mem) override
void mem_alloc(device_memory &mem) override
void tex_alloc(device_texture &mem)
BVHLayoutMask get_bvh_layout_mask(uint) const override
void tex_free(device_texture &mem)
void const_copy_to(const char *name, void *host, const size_t size) override
void global_alloc(device_memory &mem)
~CPUDevice() override
void mem_copy_from(device_memory &mem, const size_t y, size_t w, const size_t h, size_t elem) override
void mem_move_to_host(device_memory &mem) override
device_vector< TextureInfo > texture_info
void mem_zero(device_memory &mem) override
KernelGlobalsCPU kernel_globals
void * get_guiding_device() const override
void build_bvh(BVH *bvh, Progress &progress, bool refit) override
OSLGlobals * get_cpu_osl_memory() override
void mem_copy_to(device_memory &mem) override
void get_cpu_kernel_thread_globals(vector< ThreadKernelGlobalsCPU > &kernel_thread_globals) override
void global_free(device_memory &mem)
Device(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool headless_)
friend class device_memory
#define CCL_NAMESPACE_END
#define RTCTraversable
int BVHLayoutMask
Definition params.h:50
const char * name
uint64_t device_ptr
Definition types_base.h:44