Blender  V2.93
kernel_shader_eval.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 evaluates ShaderData structure from the values computed
20  * by the previous kernels.
21  */
22 ccl_device void kernel_shader_eval(KernelGlobals *kg)
23 {
24 
25  int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
26  /* Sorting on cuda split is not implemented */
27 #ifdef __KERNEL_CUDA__
29 #else
31 #endif
32  if (ray_index >= queue_index) {
33  return;
34  }
35  ray_index = get_ray_index(kg,
36  ray_index,
37 #ifdef __KERNEL_CUDA__
39 #else
41 #endif
42  kernel_split_state.queue_data,
43  kernel_split_params.queue_size,
44  0);
45 
46  if (ray_index == QUEUE_EMPTY_SLOT) {
47  return;
48  }
49 
50  ccl_global char *ray_state = kernel_split_state.ray_state;
51  if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
52  ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
53  uint buffer_offset = kernel_split_state.buffer_offset[ray_index];
54  ccl_global float *buffer = kernel_split_params.tile.buffer + buffer_offset;
55 
56  shader_eval_surface(kg, kernel_split_sd(sd, ray_index), state, buffer, state->flag);
57 #ifdef __BRANCHED_PATH__
58  if (kernel_data.integrator.branched) {
59  shader_merge_closures(kernel_split_sd(sd, ray_index));
60  }
61  else
62 #endif
63  {
65  }
66  }
67 }
68 
unsigned int uint
Definition: BLI_sys_types.h:83
#define kernel_data
#define ccl_global_id(d)
#define ccl_global_size(d)
#define ccl_device
#define __KERNEL_CUDA__
#define ccl_global
#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 shader_eval_surface(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state, ccl_global float *buffer, int path_flag)
ccl_device_inline void shader_prepare_closures(ShaderData *sd, ccl_addr_space PathState *state)
CCL_NAMESPACE_BEGIN ccl_device void kernel_shader_eval(KernelGlobals *kg)
#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 ccl_global char ccl_global unsigned int ccl_global float * buffer
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int * queue_index
__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
@ RAY_ACTIVE
@ QUEUE_SHADER_SORTED_RAYS
@ QUEUE_ACTIVE_AND_REGENERATED_RAYS
static ulong state[N]