1 /*
2 * Copyright 2011-2017 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 CCL_NAMESPACE_BEGIN
18
kernel_indirect_background(KernelGlobals * kg)19 ccl_device void kernel_indirect_background(KernelGlobals *kg)
20 {
21 ccl_global char *ray_state = kernel_split_state.ray_state;
22
23 int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
24 int ray_index;
25
26 if (kernel_data.integrator.ao_bounces != INT_MAX) {
27 ray_index = get_ray_index(kg,
28 thread_index,
29 QUEUE_ACTIVE_AND_REGENERATED_RAYS,
30 kernel_split_state.queue_data,
31 kernel_split_params.queue_size,
32 0);
33
34 if (ray_index != QUEUE_EMPTY_SLOT) {
35 if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
36 ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
37 if (path_state_ao_bounce(kg, state)) {
38 kernel_split_path_end(kg, ray_index);
39 }
40 }
41 }
42 }
43
44 ray_index = get_ray_index(kg,
45 thread_index,
46 QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS,
47 kernel_split_state.queue_data,
48 kernel_split_params.queue_size,
49 0);
50
51 if (ray_index == QUEUE_EMPTY_SLOT) {
52 return;
53 }
54
55 if (IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
56 ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
57 PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
58 ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
59 float3 throughput = kernel_split_state.throughput[ray_index];
60 ShaderData *sd = kernel_split_sd(sd, ray_index);
61 uint buffer_offset = kernel_split_state.buffer_offset[ray_index];
62 ccl_global float *buffer = kernel_split_params.tile.buffer + buffer_offset;
63
64 kernel_path_background(kg, state, ray, throughput, sd, buffer, L);
65 kernel_split_path_end(kg, ray_index);
66 }
67 }
68
69 CCL_NAMESPACE_END
70