Cycles: Remove few function arguments needed only for the split kernel
[blender.git] / intern / cycles / kernel / kernels / opencl / kernel_direct_lighting.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_direct_lighting.h"
18
19 __kernel void kernel_ocl_path_trace_direct_lighting(
20         ccl_global char *kg,
21         ccl_constant KernelData *data,
22         ccl_global char *sd,                    /* Required for direct lighting */
23         ccl_global uint *rng_coop,              /* Required for direct lighting */
24         ccl_global PathState *PathState_coop,   /* Required for direct lighting */
25         ccl_global int *ISLamp_coop,            /* Required for direct lighting */
26         ccl_global Ray *LightRay_coop,          /* Required for direct lighting */
27         ccl_global BsdfEval *BSDFEval_coop,     /* Required for direct lighting */
28         ccl_global char *ray_state,             /* Denotes the state of each ray */
29         ccl_global int *Queue_data,             /* Queue memory */
30         ccl_global int *Queue_index,            /* Tracks the number of elements in each queue */
31         int queuesize)                          /* Size (capacity) of each queue */
32 {
33         ccl_local unsigned int local_queue_atomics;
34         if(get_local_id(0) == 0 && get_local_id(1) == 0) {
35                 local_queue_atomics = 0;
36         }
37         barrier(CLK_LOCAL_MEM_FENCE);
38
39         char enqueue_flag = 0;
40         int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
41         ray_index = get_ray_index(ray_index,
42                                   QUEUE_ACTIVE_AND_REGENERATED_RAYS,
43                                   Queue_data,
44                                   queuesize,
45                                   0);
46
47 #ifdef __COMPUTE_DEVICE_GPU__
48         /* If we are executing on a GPU device, we exit all threads that are not
49          * required.
50          *
51          * If we are executing on a CPU device, then we need to keep all threads
52          * active since we have barrier() calls later in the kernel. CPU devices,
53          * expect all threads to execute barrier statement.
54          */
55         if(ray_index == QUEUE_EMPTY_SLOT) {
56                 return;
57         }
58 #endif
59
60 #ifndef __COMPUTE_DEVICE_GPU__
61         if(ray_index != QUEUE_EMPTY_SLOT) {
62 #endif
63                 enqueue_flag = kernel_direct_lighting((KernelGlobals *)kg,
64                                                       (ShaderData *)sd,
65                                                       rng_coop,
66                                                       PathState_coop,
67                                                       ISLamp_coop,
68                                                       LightRay_coop,
69                                                       BSDFEval_coop,
70                                                       ray_state,
71                                                       ray_index);
72
73 #ifndef __COMPUTE_DEVICE_GPU__
74         }
75 #endif
76
77 #ifdef __EMISSION__
78         /* Enqueue RAY_SHADOW_RAY_CAST_DL rays. */
79         enqueue_ray_index_local(ray_index,
80                                 QUEUE_SHADOW_RAY_CAST_DL_RAYS,
81                                 enqueue_flag,
82                                 queuesize,
83                                 &local_queue_atomics,
84                                 Queue_data,
85                                 Queue_index);
86 #endif
87 }