Blender  V3.3
kernel/osl/shader.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __OSL_SHADER_H__
5 #define __OSL_SHADER_H__
6 
7 #ifdef WITH_OSL
8 
9 /* OSL Shader Engine
10  *
11  * Holds all variables to execute and use OSL shaders from the kernel. These
12  * are initialized externally by OSLShaderManager before rendering starts.
13  *
14  * Before/after a thread starts rendering, thread_init/thread_free must be
15  * called, which will store any per thread OSL state in thread local storage.
16  * This means no thread state must be passed along in the kernel itself.
17  */
18 
19 # include "kernel/types.h"
20 
22 
23 class Scene;
24 
25 struct ShaderClosure;
26 struct ShaderData;
27 struct IntegratorStateCPU;
28 struct differential3;
29 struct KernelGlobalsCPU;
30 
31 struct OSLGlobals;
32 struct OSLShadingSystem;
33 
34 class OSLShader {
35  public:
36  /* init */
37  static void register_closures(OSLShadingSystem *ss);
38 
39  /* per thread data */
40  static void thread_init(KernelGlobalsCPU *kg, OSLGlobals *osl_globals);
41  static void thread_free(KernelGlobalsCPU *kg);
42 
43  /* eval */
44  static void eval_surface(const KernelGlobalsCPU *kg,
45  const void *state,
46  ShaderData *sd,
47  uint32_t path_flag);
48  static void eval_background(const KernelGlobalsCPU *kg,
49  const void *state,
50  ShaderData *sd,
51  uint32_t path_flag);
52  static void eval_volume(const KernelGlobalsCPU *kg,
53  const void *state,
54  ShaderData *sd,
55  uint32_t path_flag);
56  static void eval_displacement(const KernelGlobalsCPU *kg, const void *state, ShaderData *sd);
57 
58  /* attributes */
59  static int find_attribute(const KernelGlobalsCPU *kg,
60  const ShaderData *sd,
61  uint id,
62  AttributeDescriptor *desc);
63 };
64 
66 
67 #endif
68 
69 #endif /* __OSL_SHADER_H__ */
unsigned int uint
Definition: BLI_sys_types.h:67
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
const int state
ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals kg, ccl_private const ShaderData *sd, uint id)
ShaderData
Definition: kernel/types.h:925
ShaderClosure
Definition: kernel/types.h:726
unsigned int uint32_t
Definition: stdint.h:80
static void eval_displacement(SubdivDisplacement *displacement, const int ptex_face_index, const float u, const float v, const float dPdu[3], const float dPdv[3], float r_D[3])