Blender  V2.93
kernel_shader_setup.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 
19 /* This kernel sets up the ShaderData structure from the values computed
20  * by the previous kernels.
21  *
22  * It also identifies the rays of state RAY_TO_REGENERATE and enqueues them
23  * in QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue.
24  */
25 ccl_device void kernel_shader_setup(KernelGlobals *kg,
26  ccl_local_param unsigned int *local_queue_atomics)
27 {
28  /* Enqueue RAY_TO_REGENERATE rays into QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. */
29  if (ccl_local_id(0) == 0 && ccl_local_id(1) == 0) {
30  *local_queue_atomics = 0;
31  }
33 
34  int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
36  if (ray_index < queue_index) {
37  ray_index = get_ray_index(kg,
38  ray_index,
40  kernel_split_state.queue_data,
41  kernel_split_params.queue_size,
42  0);
43  }
44  else {
45  ray_index = QUEUE_EMPTY_SLOT;
46  }
47 
48  char enqueue_flag = (IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) ? 1 :
49  0;
50  enqueue_ray_index_local(ray_index,
52  enqueue_flag,
53  kernel_split_params.queue_size,
54  local_queue_atomics,
55  kernel_split_state.queue_data,
56  kernel_split_params.queue_index);
57 
58  /* Continue on with shader evaluation. */
59  if (IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
60  Intersection isect = kernel_split_state.isect[ray_index];
61  Ray ray = kernel_split_state.ray[ray_index];
62  ShaderData *sd = kernel_split_sd(sd, ray_index);
63 
64  shader_setup_from_ray(kg, sd, &isect, &ray);
65 
66 #ifdef __VOLUME__
67  if (sd->flag & SD_HAS_ONLY_VOLUME) {
69  }
70 #endif
71  }
72 }
73 
#define ccl_global_id(d)
#define ccl_global_size(d)
#define ccl_local_param
#define ccl_device
ccl_device_inline uint ccl_local_id(uint d)
#define CCL_NAMESPACE_END
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_device void enqueue_ray_index_local(int ray_index, int queue_number, char enqueue_flag, int queuesize, ccl_local_param unsigned int *local_queue_atomics, ccl_global int *Queue_data, ccl_global int *Queue_index)
Definition: kernel_queues.h:71
CCL_NAMESPACE_BEGIN ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
Definition: kernel_shader.h:59
CCL_NAMESPACE_BEGIN ccl_device void kernel_shader_setup(KernelGlobals *kg, ccl_local_param unsigned int *local_queue_atomics)
#define kernel_split_params
#define kernel_split_sd(sd, ray_index)
#define kernel_split_state
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int * queue_index
@ SD_HAS_ONLY_VOLUME
Definition: kernel_types.h:875
#define IS_STATE(ray_state, ray_index, state)
ShaderData
#define QUEUE_EMPTY_SLOT
#define ASSIGN_RAY_STATE(ray_state, ray_index, state)
@ RAY_ACTIVE
@ RAY_HAS_ONLY_VOLUME
@ RAY_TO_REGENERATE
@ QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS
@ QUEUE_ACTIVE_AND_REGENERATED_RAYS
#define CCL_LOCAL_MEM_FENCE
Definition: util_atomic.h:32
#define ccl_barrier(flags)
Definition: util_atomic.h:33