Blender  V2.93
kernel_path_init.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 initializes structures needed in path-iteration kernels.
20  * This is the first kernel in ray-tracing logic.
21  *
22  * Ray state of rays outside the tile-boundary will be marked RAY_INACTIVE
23  */
24 ccl_device void kernel_path_init(KernelGlobals *kg)
25 {
26  int ray_index = ccl_global_id(0) + ccl_global_id(1) * ccl_global_size(0);
27 
28  /* This is the first assignment to ray_state;
29  * So we don't use ASSIGN_RAY_STATE macro.
30  */
31  kernel_split_state.ray_state[ray_index] = RAY_ACTIVE;
32 
33  /* Get work. */
35  uint total_work_size = kernel_split_params.total_work_size;
36  uint work_index;
37 
38  if (!get_next_work(kg, work_pools, total_work_size, ray_index, &work_index)) {
39  /* No more work, mark ray as inactive */
40  kernel_split_state.ray_state[ray_index] = RAY_INACTIVE;
41 
42  return;
43  }
44 
46  uint x, y, sample;
47  get_work_pixel(tile, work_index, &x, &y, &sample);
48 
49  /* Store buffer offset for writing to passes. */
50  uint buffer_offset = (tile->offset + x + y * tile->stride) * kernel_data.film.pass_stride;
51  kernel_split_state.buffer_offset[ray_index] = buffer_offset;
52 
53  /* Initialize random numbers and ray. */
54  uint rng_hash;
55  kernel_path_trace_setup(kg, sample, x, y, &rng_hash, &kernel_split_state.ray[ray_index]);
56 
57  if (kernel_split_state.ray[ray_index].t != 0.0f) {
58  /* Initialize throughput, path radiance, Ray, PathState;
59  * These rays proceed with path-iteration.
60  */
61  kernel_split_state.throughput[ray_index] = make_float3(1.0f, 1.0f, 1.0f);
62  path_radiance_init(kg, &kernel_split_state.path_radiance[ray_index]);
64  AS_SHADER_DATA(&kernel_split_state.sd_DL_shadow[ray_index]),
65  &kernel_split_state.path_state[ray_index],
66  rng_hash,
67  sample,
68  &kernel_split_state.ray[ray_index]);
69 #ifdef __SUBSURFACE__
70  kernel_path_subsurface_init_indirect(&kernel_split_state.ss_rays[ray_index]);
71 #endif
72  }
73  else {
75  }
76 }
77 
unsigned int uint
Definition: BLI_sys_types.h:83
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
ccl_device_inline void path_radiance_init(KernelGlobals *kg, PathRadiance *L)
#define kernel_data
#define ccl_global_id(d)
#define ccl_global_size(d)
#define ccl_device
#define ccl_global
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
CCL_NAMESPACE_BEGIN ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg, int sample, int x, int y, uint *rng_hash, ccl_addr_space Ray *ray)
CCL_NAMESPACE_BEGIN ccl_device void kernel_path_init(KernelGlobals *kg)
CCL_NAMESPACE_BEGIN ccl_device_inline void path_state_init(KernelGlobals *kg, ShaderData *stack_sd, ccl_addr_space PathState *state, uint rng_hash, int sample, ccl_addr_space Ray *ray)
#define kernel_split_params
#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 * work_pools
#define AS_SHADER_DATA(shader_data_tiny_storage)
#define ASSIGN_RAY_STATE(ray_state, ray_index, state)
@ RAY_ACTIVE
@ RAY_TO_REGENERATE
@ RAY_INACTIVE
CCL_NAMESPACE_BEGIN ccl_device_inline void get_work_pixel(ccl_global const WorkTile *tile, uint global_work_index, ccl_private uint *x, ccl_private uint *y, ccl_private uint *sample)
static void sample(SocketReader *reader, int x, int y, float color[4])