Blender  V2.93
kernel_scene_intersect.h
Go to the documentation of this file.
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 
18 
19 /* This kernel takes care of scene_intersect function.
20  *
21  * This kernel changes the ray_state of RAY_REGENERATED rays to RAY_ACTIVE.
22  * This kernel processes rays of ray state RAY_ACTIVE
23  * This kernel determines the rays that have hit the background and changes
24  * their ray state to RAY_HIT_BACKGROUND.
25  */
26 ccl_device void kernel_scene_intersect(KernelGlobals *kg)
27 {
28  /* Fetch use_queues_flag */
29  char local_use_queues_flag = *kernel_split_params.use_queues_flag;
31 
32  int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
33  if (local_use_queues_flag) {
34  ray_index = get_ray_index(kg,
35  ray_index,
37  kernel_split_state.queue_data,
38  kernel_split_params.queue_size,
39  0);
40 
41  if (ray_index == QUEUE_EMPTY_SLOT) {
42  return;
43  }
44  }
45 
46  /* All regenerated rays become active here */
47  if (IS_STATE(kernel_split_state.ray_state, ray_index, RAY_REGENERATED)) {
48 #ifdef __BRANCHED_PATH__
49  if (kernel_split_state.branched_state[ray_index].waiting_on_shared_samples) {
50  kernel_split_path_end(kg, ray_index);
51  }
52  else
53 #endif /* __BRANCHED_PATH__ */
54  {
55  ASSIGN_RAY_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE);
56  }
57  }
58 
59  if (!IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
60  return;
61  }
62 
63  ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
64  Ray ray = kernel_split_state.ray[ray_index];
65  PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
66 
67  Intersection isect;
68  bool hit = kernel_path_scene_intersect(kg, state, &ray, &isect, L);
69  kernel_split_state.isect[ray_index] = isect;
70 
71  if (!hit) {
72  /* Change the state of rays that hit the background;
73  * These rays undergo special processing in the
74  * background_bufferUpdate kernel.
75  */
77  }
78 }
79 
#define ccl_global_id(d)
#define ccl_global_size(d)
#define ccl_device
#define ccl_global
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN ccl_device_forceinline bool kernel_path_scene_intersect(KernelGlobals *kg, ccl_addr_space PathState *state, Ray *ray, Intersection *isect, PathRadiance *L)
Definition: kernel_path.h:57
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
CCL_NAMESPACE_BEGIN ccl_device void kernel_scene_intersect(KernelGlobals *kg)
CCL_NAMESPACE_BEGIN ccl_device_inline void kernel_split_path_end(KernelGlobals *kg, int ray_index)
#define kernel_split_params
#define kernel_split_state
#define IS_STATE(ray_state, ray_index, state)
#define QUEUE_EMPTY_SLOT
#define ASSIGN_RAY_STATE(ray_state, ray_index, state)
@ RAY_HIT_BACKGROUND
@ RAY_ACTIVE
@ RAY_REGENERATED
@ QUEUE_ACTIVE_AND_REGENERATED_RAYS
static ulong state[N]
#define L
#define CCL_LOCAL_MEM_FENCE
Definition: util_atomic.h:32
#define ccl_barrier(flags)
Definition: util_atomic.h:33