2 * Copyright 2011-2015 Blender Foundation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "split/kernel_lamp_emission.h"
19 __kernel void kernel_ocl_path_trace_lamp_emission(
21 ccl_constant KernelData *data,
22 ccl_global char *sd, /* Required for lamp emission */
23 ccl_global float3 *throughput_coop, /* Required for lamp emission */
24 PathRadiance *PathRadiance_coop, /* Required for lamp emission */
25 ccl_global Ray *Ray_coop, /* Required for lamp emission */
26 ccl_global PathState *PathState_coop, /* Required for lamp emission */
27 Intersection *Intersection_coop, /* Required for lamp emission */
28 ccl_global char *ray_state, /* Denotes the state of each ray */
30 ccl_global int *Queue_data, /* Memory for queues */
31 ccl_global int *Queue_index, /* Tracks the number of elements in queues */
32 int queuesize, /* Size (capacity) of queues */
33 ccl_global char *use_queues_flag, /* Used to decide if this kernel should use
34 * queues to fetch ray index
36 int parallel_samples) /* Number of samples to be processed in parallel */
38 int x = get_global_id(0);
39 int y = get_global_id(1);
41 /* We will empty this queue in this kernel. */
42 if(get_global_id(0) == 0 && get_global_id(1) == 0) {
43 Queue_index[QUEUE_ACTIVE_AND_REGENERATED_RAYS] = 0;
45 /* Fetch use_queues_flag. */
46 ccl_local char local_use_queues_flag;
47 if(get_local_id(0) == 0 && get_local_id(1) == 0) {
48 local_use_queues_flag = use_queues_flag[0];
50 barrier(CLK_LOCAL_MEM_FENCE);
53 if(local_use_queues_flag) {
54 int thread_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
55 ray_index = get_ray_index(thread_index,
56 QUEUE_ACTIVE_AND_REGENERATED_RAYS,
60 if(ray_index == QUEUE_EMPTY_SLOT) {
64 if(x < (sw * parallel_samples) && y < sh) {
65 ray_index = x + y * (sw * parallel_samples);
71 kernel_lamp_emission((KernelGlobals *)kg,