Cycles: Remove few function arguments needed only for the split kernel
[blender.git] / intern / cycles / kernel / kernels / opencl / kernel_lamp_emission.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_lamp_emission.h"
18
19 __kernel void kernel_ocl_path_trace_lamp_emission(
20         ccl_global char *kg,
21         ccl_constant KernelData *data,
22         ccl_global float3 *throughput_coop,    /* Required for lamp emission */
23         PathRadiance *PathRadiance_coop,       /* Required for lamp emission */
24         ccl_global Ray *Ray_coop,              /* Required for lamp emission */
25         ccl_global PathState *PathState_coop,  /* Required for lamp emission */
26         Intersection *Intersection_coop,       /* Required for lamp emission */
27         ccl_global char *ray_state,            /* Denotes the state of each ray */
28         int sw, int sh,
29         ccl_global int *Queue_data,            /* Memory for queues */
30         ccl_global int *Queue_index,           /* Tracks the number of elements in queues */
31         int queuesize,                         /* Size (capacity) of queues */
32         ccl_global char *use_queues_flag,      /* Used to decide if this kernel should use
33                                                 * queues to fetch ray index
34                                                 */
35         int parallel_samples)                  /* Number of samples to be processed in parallel */
36 {
37         int x = get_global_id(0);
38         int y = get_global_id(1);
39
40         /* We will empty this queue in this kernel. */
41         if(get_global_id(0) == 0 && get_global_id(1) == 0) {
42                 Queue_index[QUEUE_ACTIVE_AND_REGENERATED_RAYS] = 0;
43         }
44         /* Fetch use_queues_flag. */
45         ccl_local char local_use_queues_flag;
46         if(get_local_id(0) == 0 && get_local_id(1) == 0) {
47                 local_use_queues_flag = use_queues_flag[0];
48         }
49         barrier(CLK_LOCAL_MEM_FENCE);
50
51         int ray_index;
52         if(local_use_queues_flag) {
53                 int thread_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
54                 ray_index = get_ray_index(thread_index,
55                                           QUEUE_ACTIVE_AND_REGENERATED_RAYS,
56                                           Queue_data,
57                                           queuesize,
58                                           1);
59                 if(ray_index == QUEUE_EMPTY_SLOT) {
60                         return;
61                 }
62         } else {
63                 if(x < (sw * parallel_samples) && y < sh) {
64                         ray_index = x + y * (sw * parallel_samples);
65                 } else {
66                         return;
67                 }
68         }
69
70         kernel_lamp_emission((KernelGlobals *)kg,
71                              throughput_coop,
72                              PathRadiance_coop,
73                              Ray_coop,
74                              PathState_coop,
75                              Intersection_coop,
76                              ray_state,
77                              sw, sh,
78                              use_queues_flag,
79                              parallel_samples,
80                              ray_index);
81 }