Blender  V3.3
cpu/device_impl.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
6 /* So ImathMath is included before our kernel_cpu_compat. */
7 #ifdef WITH_OSL
8 /* So no context pollution happens from indirectly included windows.h */
9 # include "util/windows.h"
10 # include <OSL/oslexec.h>
11 #endif
12 
13 #ifdef WITH_EMBREE
14 # include <embree3/rtcore.h>
15 #endif
16 
17 #include "device/cpu/kernel.h"
18 #include "device/device.h"
19 #include "device/memory.h"
20 
21 // clang-format off
25 
26 #include "kernel/osl/shader.h"
27 #include "kernel/osl/globals.h"
28 // clang-format on
29 
31 
32 class CPUDevice : public Device {
33  public:
35 
38 
39 #ifdef WITH_OSL
40  OSLGlobals osl_globals;
41 #endif
42 #ifdef WITH_EMBREE
43  RTCScene embree_scene = NULL;
44  RTCDevice embree_device;
45 #endif
46 
47  CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_);
48  ~CPUDevice();
49 
50  virtual BVHLayoutMask get_bvh_layout_mask() const override;
51 
52  /* Returns true if the texture info was copied to the device (meaning, some more
53  * re-initialization might be needed). */
54  bool load_texture_info();
55 
56  virtual void mem_alloc(device_memory &mem) override;
57  virtual void mem_copy_to(device_memory &mem) override;
58  virtual void mem_copy_from(
59  device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
60  virtual void mem_zero(device_memory &mem) override;
61  virtual void mem_free(device_memory &mem) override;
63  size_t offset,
64  size_t /*size*/) override;
65 
66  virtual void const_copy_to(const char *name, void *host, size_t size) override;
67 
68  void global_alloc(device_memory &mem);
69  void global_free(device_memory &mem);
70 
71  void tex_alloc(device_texture &mem);
72  void tex_free(device_texture &mem);
73 
74  void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
75 
76  virtual void get_cpu_kernel_thread_globals(
77  vector<CPUKernelThreadGlobals> &kernel_thread_globals) override;
78  virtual void *get_cpu_osl_memory() override;
79 
80  protected:
81  virtual bool load_kernels(uint /*kernel_features*/) override;
82 };
83 
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
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:63
virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override
virtual bool load_kernels(uint) override
virtual BVHLayoutMask get_bvh_layout_mask() const override
bool need_texture_info
bool load_texture_info()
virtual void mem_free(device_memory &mem) override
virtual void const_copy_to(const char *name, void *host, size_t size) override
virtual void mem_alloc(device_memory &mem) override
virtual void * get_cpu_osl_memory() override
void tex_alloc(device_texture &mem)
virtual device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t) override
void tex_free(device_texture &mem)
void global_alloc(device_memory &mem)
device_vector< TextureInfo > texture_info
virtual void mem_zero(device_memory &mem) override
KernelGlobalsCPU kernel_globals
virtual void get_cpu_kernel_thread_globals(vector< CPUKernelThreadGlobals > &kernel_thread_globals) override
void build_bvh(BVH *bvh, Progress &progress, bool refit) override
virtual void mem_copy_to(device_memory &mem) override
CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_)
void global_free(device_memory &mem)
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
int BVHLayoutMask
Definition: params.h:47
uint64_t device_ptr
Definition: util/types.h:43