Fix for Cycles (CUDA) compilation (again ...). Moved the AttributeStandard enum typed...
[blender.git] / intern / cycles / render / scene.h
1 /*
2  * Copyright 2011, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18
19 #ifndef __SCENE_H__
20 #define __SCENE_H__
21
22 #include "image.h"
23
24 #include "device_memory.h"
25
26 #include "kernel_types.h"
27
28 #include "util_attribute.h"
29 #include "util_param.h"
30 #include "util_string.h"
31 #include "util_thread.h"
32 #include "util_types.h"
33 #include "util_vector.h"
34
35 CCL_NAMESPACE_BEGIN
36
37 class AttributeRequestSet;
38 class Background;
39 class Camera;
40 class Device;
41 class DeviceInfo;
42 class Film;
43 class Filter;
44 class Integrator;
45 class Light;
46 class LightManager;
47 class Mesh;
48 class MeshManager;
49 class Object;
50 class ObjectManager;
51 class ParticleSystemManager;
52 class ParticleSystem;
53 class Shader;
54 class ShaderManager;
55 class Progress;
56
57 /* Scene Device Data */
58
59 class DeviceScene {
60 public:
61         /* BVH */
62         device_vector<float4> bvh_nodes;
63         device_vector<uint> object_node;
64         device_vector<float4> tri_woop;
65         device_vector<uint> prim_visibility;
66         device_vector<uint> prim_index;
67         device_vector<uint> prim_object;
68
69         /* mesh */
70         device_vector<float4> tri_normal;
71         device_vector<float4> tri_vnormal;
72         device_vector<float4> tri_vindex;
73         device_vector<float4> tri_verts;
74
75         /* objects */
76         device_vector<float4> objects;
77
78         /* attributes */
79         device_vector<uint4> attributes_map;
80         device_vector<float> attributes_float;
81         device_vector<float4> attributes_float3;
82
83         /* lights */
84         device_vector<float4> light_distribution;
85         device_vector<float4> light_data;
86         device_vector<float2> light_background_marginal_cdf;
87         device_vector<float2> light_background_conditional_cdf;
88
89         /* particles */
90         device_vector<float4> particles;
91
92         /* shaders */
93         device_vector<uint4> svm_nodes;
94         device_vector<uint> shader_flag;
95         device_vector<uint> object_flag;
96
97         /* filter */
98         device_vector<float> filter_table;
99
100         /* integrator */
101         device_vector<uint> sobol_directions;
102
103         /* images */
104         device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES];
105         device_vector<float4> tex_float_image[TEX_EXTENDED_NUM_FLOAT_IMAGES];
106
107         /* opencl images */
108         device_vector<uchar4> tex_image_packed;
109         device_vector<uint4> tex_image_packed_info;
110
111         KernelData data;
112 };
113
114 /* Scene Parameters */
115
116 class SceneParams {
117 public:
118         enum { OSL, SVM } shadingsystem;
119         enum BVHType { BVH_DYNAMIC, BVH_STATIC } bvh_type;
120         bool use_bvh_cache;
121         bool use_bvh_spatial_split;
122         bool use_qbvh;
123
124         SceneParams()
125         {
126                 shadingsystem = SVM;
127                 bvh_type = BVH_DYNAMIC;
128                 use_bvh_cache = false;
129                 use_bvh_spatial_split = false;
130 #ifdef __QBVH__
131                 use_qbvh = true;
132 #else
133                 use_qbvh = false;
134 #endif
135         }
136
137         bool modified(const SceneParams& params)
138         { return !(shadingsystem == params.shadingsystem
139                 && bvh_type == params.bvh_type
140                 && use_bvh_cache == params.use_bvh_cache
141                 && use_bvh_spatial_split == params.use_bvh_spatial_split
142                 && use_qbvh == params.use_qbvh); }
143 };
144
145 /* Scene */
146
147 class Scene {
148 public:
149         /* data */
150         Camera *camera;
151         Filter *filter;
152         Film *film;
153         Background *background;
154         Integrator *integrator;
155
156         /* data lists */
157         vector<Object*> objects;
158         vector<Mesh*> meshes;
159         vector<Shader*> shaders;
160         vector<Light*> lights;
161         vector<ParticleSystem*> particle_systems;
162
163         /* data managers */
164         ImageManager *image_manager;
165         LightManager *light_manager;
166         ShaderManager *shader_manager;
167         MeshManager *mesh_manager;
168         ObjectManager *object_manager;
169         ParticleSystemManager *particle_system_manager;
170
171         /* default shaders */
172         int default_surface;
173         int default_light;
174         int default_background;
175         int default_holdout;
176         int default_empty;
177
178         /* device */
179         Device *device;
180         DeviceScene dscene;
181
182         /* parameters */
183         SceneParams params;
184
185         /* mutex must be locked manually by callers */
186         thread_mutex mutex;
187
188         Scene(const SceneParams& params, const DeviceInfo& device_info);
189         ~Scene();
190
191         void device_update(Device *device, Progress& progress);
192
193         bool need_global_attribute(AttributeStandard std);
194         void need_global_attributes(AttributeRequestSet& attributes);
195
196         enum MotionType { MOTION_NONE = 0, MOTION_PASS, MOTION_BLUR };
197         MotionType need_motion();
198
199         bool need_update();
200         bool need_reset();
201 };
202
203 CCL_NAMESPACE_END
204
205 #endif /*  __SCENE_H__ */
206