Blender  V2.93
kernel_indirect_subsurface.h
Go to the documentation of this file.
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 
18 
20 {
21  int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
22  if (thread_index == 0) {
23  /* We will empty both queues in this kernel. */
26  }
27 
28  int ray_index;
30  thread_index,
32  kernel_split_state.queue_data,
33  kernel_split_params.queue_size,
34  1);
35  ray_index = get_ray_index(kg,
36  thread_index,
38  kernel_split_state.queue_data,
39  kernel_split_params.queue_size,
40  1);
41 
42 #ifdef __SUBSURFACE__
43  if (ray_index == QUEUE_EMPTY_SLOT) {
44  return;
45  }
46 
47  ccl_global char *ray_state = kernel_split_state.ray_state;
48  ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
49  PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
50  ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
51  ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
52 
53  if (IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
54  ccl_addr_space SubsurfaceIndirectRays *ss_indirect = &kernel_split_state.ss_rays[ray_index];
55 
56  /* Trace indirect subsurface rays by restarting the loop. this uses less
57  * stack memory than invoking kernel_path_indirect.
58  */
59  if (ss_indirect->num_rays) {
60  kernel_path_subsurface_setup_indirect(kg, ss_indirect, state, ray, L, throughput);
62  }
63  }
64 #endif /* __SUBSURFACE__ */
65 }
66 
#define ccl_global_id(d)
#define ccl_addr_space
#define ccl_global_size(d)
#define ccl_device
#define ccl_global
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN ccl_device void kernel_indirect_subsurface(KernelGlobals *kg)
ccl_device int get_ray_index(KernelGlobals *kg, int thread_index, int queue_number, ccl_global int *queues, int queuesize, int empty_queue)
Definition: kernel_queues.h:53
#define kernel_split_params
#define kernel_split_state
__kernel void ccl_constant KernelData ccl_global void ccl_global char * ray_state
#define IS_STATE(ray_state, ray_index, state)
#define QUEUE_EMPTY_SLOT
#define ASSIGN_RAY_STATE(ray_state, ray_index, state)
@ RAY_UPDATE_BUFFER
@ RAY_REGENERATED
@ QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS
@ QUEUE_ACTIVE_AND_REGENERATED_RAYS
static ulong state[N]
#define L