Cycles: Make all #include statements relative to cycles source directory
[blender.git] / intern / cycles / kernel / split / kernel_split_data.h
1 /*
2  * Copyright 2011-2016 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __KERNEL_SPLIT_DATA_H__
18 #define __KERNEL_SPLIT_DATA_H__
19
20 #include "kernel/split/kernel_split_data_types.h"
21 #include "kernel/kernel_globals.h"
22
23 CCL_NAMESPACE_BEGIN
24
25 ccl_device_inline uint64_t split_data_buffer_size(KernelGlobals *kg, size_t num_elements)
26 {
27         (void)kg;  /* Unused on CPU. */
28
29         uint64_t size = 0;
30 #define SPLIT_DATA_ENTRY(type, name, num) + align_up(num_elements * num * sizeof(type), 16)
31         size = size SPLIT_DATA_ENTRIES;
32 #undef SPLIT_DATA_ENTRY
33
34 #ifdef __SUBSURFACE__
35         size += align_up(num_elements * sizeof(SubsurfaceIndirectRays), 16); /* ss_rays */
36 #endif
37
38 #ifdef __VOLUME__
39         size += align_up(2 * num_elements * sizeof(PathState), 16); /* state_shadow */
40 #endif
41
42         return size;
43 }
44
45 ccl_device_inline void split_data_init(KernelGlobals *kg,
46                                        ccl_global SplitData *split_data,
47                                        size_t num_elements,
48                                        ccl_global void *data,
49                                        ccl_global char *ray_state)
50 {
51         (void)kg;  /* Unused on CPU. */
52
53         ccl_global char *p = (ccl_global char*)data;
54
55 #define SPLIT_DATA_ENTRY(type, name, num) \
56         split_data->name = (type*)p; p += align_up(num_elements * num * sizeof(type), 16);
57         SPLIT_DATA_ENTRIES;
58 #undef SPLIT_DATA_ENTRY
59
60 #ifdef __SUBSURFACE__
61         split_data->ss_rays = (ccl_global SubsurfaceIndirectRays*)p;
62         p += align_up(num_elements * sizeof(SubsurfaceIndirectRays), 16);
63 #endif
64
65 #ifdef __VOLUME__
66         split_data->state_shadow = (ccl_global PathState*)p;
67         p += align_up(2 * num_elements * sizeof(PathState), 16);
68 #endif
69
70         split_data->ray_state = ray_state;
71 }
72
73 CCL_NAMESPACE_END
74
75 #endif  /* __KERNEL_SPLIT_DATA_H__ */