Cycles: OpenCL split kernel cleanup, move casts from .h files to .cl files
[blender.git] / intern / cycles / kernel / kernels / opencl / kernel_data_init.cl
1 /*
2  * Copyright 2011-2015 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 #include "split/kernel_data_init.h"
18
19 __kernel void kernel_ocl_path_trace_data_init(
20         ccl_global char *kg,
21         ccl_global char *sd,
22         ccl_global char *sd_DL_shadow,
23
24         ccl_global float3 *P_sd,
25         ccl_global float3 *P_sd_DL_shadow,
26
27         ccl_global float3 *N_sd,
28         ccl_global float3 *N_sd_DL_shadow,
29
30         ccl_global float3 *Ng_sd,
31         ccl_global float3 *Ng_sd_DL_shadow,
32
33         ccl_global float3 *I_sd,
34         ccl_global float3 *I_sd_DL_shadow,
35
36         ccl_global int *shader_sd,
37         ccl_global int *shader_sd_DL_shadow,
38
39         ccl_global int *flag_sd,
40         ccl_global int *flag_sd_DL_shadow,
41
42         ccl_global int *prim_sd,
43         ccl_global int *prim_sd_DL_shadow,
44
45         ccl_global int *type_sd,
46         ccl_global int *type_sd_DL_shadow,
47
48         ccl_global float *u_sd,
49         ccl_global float *u_sd_DL_shadow,
50
51         ccl_global float *v_sd,
52         ccl_global float *v_sd_DL_shadow,
53
54         ccl_global int *object_sd,
55         ccl_global int *object_sd_DL_shadow,
56
57         ccl_global float *time_sd,
58         ccl_global float *time_sd_DL_shadow,
59
60         ccl_global float *ray_length_sd,
61         ccl_global float *ray_length_sd_DL_shadow,
62
63         ccl_global int *ray_depth_sd,
64         ccl_global int *ray_depth_sd_DL_shadow,
65
66         ccl_global int *transparent_depth_sd,
67         ccl_global int *transparent_depth_sd_DL_shadow,
68
69         /* Ray differentials. */
70         ccl_global differential3 *dP_sd,
71         ccl_global differential3 *dP_sd_DL_shadow,
72
73         ccl_global differential3 *dI_sd,
74         ccl_global differential3 *dI_sd_DL_shadow,
75
76         ccl_global differential *du_sd,
77         ccl_global differential *du_sd_DL_shadow,
78
79         ccl_global differential *dv_sd,
80         ccl_global differential *dv_sd_DL_shadow,
81
82         /* Dp/Du */
83         ccl_global float3 *dPdu_sd,
84         ccl_global float3 *dPdu_sd_DL_shadow,
85
86         ccl_global float3 *dPdv_sd,
87         ccl_global float3 *dPdv_sd_DL_shadow,
88
89         /* Object motion. */
90         ccl_global Transform *ob_tfm_sd,
91         ccl_global Transform *ob_tfm_sd_DL_shadow,
92
93         ccl_global Transform *ob_itfm_sd,
94         ccl_global Transform *ob_itfm_sd_DL_shadow,
95
96         ShaderClosure *closure_sd,
97         ShaderClosure *closure_sd_DL_shadow,
98
99         ccl_global int *num_closure_sd,
100         ccl_global int *num_closure_sd_DL_shadow,
101
102         ccl_global float *randb_closure_sd,
103         ccl_global float *randb_closure_sd_DL_shadow,
104
105         ccl_global float3 *ray_P_sd,
106         ccl_global float3 *ray_P_sd_DL_shadow,
107
108         ccl_global differential3 *ray_dP_sd,
109         ccl_global differential3 *ray_dP_sd_DL_shadow,
110
111         ccl_constant KernelData *data,
112         ccl_global float *per_sample_output_buffers,
113         ccl_global uint *rng_state,
114         ccl_global uint *rng_coop,                   /* rng array to store rng values for all rays */
115         ccl_global float3 *throughput_coop,          /* throughput array to store throughput values for all rays */
116         ccl_global float *L_transparent_coop,        /* L_transparent array to store L_transparent values for all rays */
117         PathRadiance *PathRadiance_coop,             /* PathRadiance array to store PathRadiance values for all rays */
118         ccl_global Ray *Ray_coop,                    /* Ray array to store Ray information for all rays */
119         ccl_global PathState *PathState_coop,        /* PathState array to store PathState information for all rays */
120         ccl_global char *ray_state,                  /* Stores information on current state of a ray */
121
122 #define KERNEL_TEX(type, ttype, name)                                   \
123         ccl_global type *name,
124 #include "../../kernel_textures.h"
125
126         int start_sample, int sx, int sy, int sw, int sh, int offset, int stride,
127         int rng_state_offset_x,
128         int rng_state_offset_y,
129         int rng_state_stride,
130         ccl_global int *Queue_data,                  /* Memory for queues */
131         ccl_global int *Queue_index,                 /* Tracks the number of elements in queues */
132         int queuesize,                               /* size (capacity) of the queue */
133         ccl_global char *use_queues_flag,            /* flag to decide if scene-intersect kernel should use queues to fetch ray index */
134         ccl_global unsigned int *work_array,         /* work array to store which work each ray belongs to */
135 #ifdef __WORK_STEALING__
136         ccl_global unsigned int *work_pool_wgs,      /* Work pool for each work group */
137         unsigned int num_samples,                    /* Total number of samples per pixel */
138 #endif
139 #ifdef __KERNEL_DEBUG__
140         DebugData *debugdata_coop,
141 #endif
142         int parallel_samples)                        /* Number of samples to be processed in parallel */
143 {
144         kernel_data_init((KernelGlobals *)kg,
145                          (ShaderData *)sd,
146                          (ShaderData *)sd_DL_shadow,
147                          P_sd,
148                          P_sd_DL_shadow,
149                          N_sd,
150                          N_sd_DL_shadow,
151                          Ng_sd,
152                          Ng_sd_DL_shadow,
153                          I_sd,
154                          I_sd_DL_shadow,
155                          shader_sd,
156                          shader_sd_DL_shadow,
157                          flag_sd,
158                          flag_sd_DL_shadow,
159                          prim_sd,
160                          prim_sd_DL_shadow,
161                          type_sd,
162                          type_sd_DL_shadow,
163                          u_sd,
164                          u_sd_DL_shadow,
165                          v_sd,
166                          v_sd_DL_shadow,
167                          object_sd,
168                          object_sd_DL_shadow,
169                          time_sd,
170                          time_sd_DL_shadow,
171                          ray_length_sd,
172                          ray_length_sd_DL_shadow,
173                          ray_depth_sd,
174                          ray_depth_sd_DL_shadow,
175                          transparent_depth_sd,
176                          transparent_depth_sd_DL_shadow,
177
178                          /* Ray differentials. */
179                          dP_sd,
180                          dP_sd_DL_shadow,
181                          dI_sd,
182                          dI_sd_DL_shadow,
183                          du_sd,
184                          du_sd_DL_shadow,
185                          dv_sd,
186                          dv_sd_DL_shadow,
187
188                          /* Dp/Du */
189                          dPdu_sd,
190                          dPdu_sd_DL_shadow,
191                          dPdv_sd,
192                          dPdv_sd_DL_shadow,
193
194                          /* Object motion. */
195                          ob_tfm_sd,
196                          ob_tfm_sd_DL_shadow,
197                          ob_itfm_sd,
198                          ob_itfm_sd_DL_shadow,
199
200                          closure_sd,
201                          closure_sd_DL_shadow,
202                          num_closure_sd,
203                          num_closure_sd_DL_shadow,
204                          randb_closure_sd,
205                          randb_closure_sd_DL_shadow,
206                          ray_P_sd,
207                          ray_P_sd_DL_shadow,
208                          ray_dP_sd,
209                          ray_dP_sd_DL_shadow,
210                          data,
211                          per_sample_output_buffers,
212                          rng_state,
213                          rng_coop,
214                          throughput_coop,
215                          L_transparent_coop,
216                          PathRadiance_coop,
217                          Ray_coop,
218                          PathState_coop,
219                          ray_state,
220
221 #define KERNEL_TEX(type, ttype, name) name,
222 #include "../../kernel_textures.h"
223
224                          start_sample, sx, sy, sw, sh, offset, stride,
225                          rng_state_offset_x,
226                          rng_state_offset_y,
227                          rng_state_stride,
228                          Queue_data,
229                          Queue_index,
230                          queuesize,
231                          use_queues_flag,
232                          work_array,
233 #ifdef __WORK_STEALING__
234                          work_pool_wgs,
235                          num_samples,
236 #endif
237 #ifdef __KERNEL_DEBUG__
238                          debugdata_coop,
239 #endif
240                          parallel_samples);
241 }