Cycles: Remove sum_all_radiance kernel
[blender-staging.git] / intern / cycles / kernel / kernels / cuda / kernel_split.cu
1 /*
2  * Copyright 2011-2016 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
17 /* CUDA split kernel entry points */
18
19 #ifdef __CUDA_ARCH__
20
21 #define __SPLIT_KERNEL__
22
23 #include "../../kernel_compat_cuda.h"
24 #include "kernel_config.h"
25
26 #include "../../split/kernel_split_common.h"
27 #include "../../split/kernel_data_init.h"
28 #include "../../split/kernel_path_init.h"
29 #include "../../split/kernel_scene_intersect.h"
30 #include "../../split/kernel_lamp_emission.h"
31 #include "../../split/kernel_queue_enqueue.h"
32 #include "../../split/kernel_background_buffer_update.h"
33 #include "../../split/kernel_shader_eval.h"
34 #include "../../split/kernel_holdout_emission_blurring_pathtermination_ao.h"
35 #include "../../split/kernel_direct_lighting.h"
36 #include "../../split/kernel_shadow_blocked.h"
37 #include "../../split/kernel_next_iteration_setup.h"
38
39 #include "../../kernel_film.h"
40
41 /* kernels */
42 extern "C" __global__ void
43 CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
44 kernel_cuda_path_trace_data_init(
45         ccl_global void *split_data_buffer,
46         int num_elements,
47         ccl_global char *ray_state,
48         ccl_global uint *rng_state,
49         int start_sample,
50         int end_sample,
51         int sx, int sy, int sw, int sh, int offset, int stride,
52         ccl_global int *Queue_index,
53         int queuesize,
54         ccl_global char *use_queues_flag,
55         ccl_global unsigned int *work_pool_wgs,
56         unsigned int num_samples,
57         ccl_global float *buffer)
58 {
59         kernel_data_init(NULL,
60                          NULL,
61                          split_data_buffer,
62                          num_elements,
63                          ray_state,
64                          rng_state,
65                          start_sample,
66                          end_sample,
67                          sx, sy, sw, sh, offset, stride,
68                          Queue_index,
69                          queuesize,
70                          use_queues_flag,
71                          work_pool_wgs,
72                          num_samples,
73                          buffer);
74 }
75
76 #define DEFINE_SPLIT_KERNEL_FUNCTION(name) \
77         extern "C" __global__ void \
78         CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) \
79         kernel_cuda_##name() \
80         { \
81                 kernel_##name(NULL); \
82         }
83
84 DEFINE_SPLIT_KERNEL_FUNCTION(path_init)
85 DEFINE_SPLIT_KERNEL_FUNCTION(scene_intersect)
86 DEFINE_SPLIT_KERNEL_FUNCTION(lamp_emission)
87 DEFINE_SPLIT_KERNEL_FUNCTION(queue_enqueue)
88 DEFINE_SPLIT_KERNEL_FUNCTION(background_buffer_update)
89 DEFINE_SPLIT_KERNEL_FUNCTION(shader_eval)
90 DEFINE_SPLIT_KERNEL_FUNCTION(holdout_emission_blurring_pathtermination_ao)
91 DEFINE_SPLIT_KERNEL_FUNCTION(direct_lighting)
92 DEFINE_SPLIT_KERNEL_FUNCTION(shadow_blocked)
93 DEFINE_SPLIT_KERNEL_FUNCTION(next_iteration_setup)
94
95 extern "C" __global__ void
96 CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
97 kernel_cuda_convert_to_byte(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)
98 {
99         int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
100         int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
101
102         if(x < sx + sw && y < sy + sh)
103                 kernel_film_convert_to_byte(NULL, rgba, buffer, sample_scale, x, y, offset, stride);
104 }
105
106 extern "C" __global__ void
107 CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
108 kernel_cuda_convert_to_half_float(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)
109 {
110         int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
111         int y = sy + blockDim.y*blockIdx.y + threadIdx.y;
112
113         if(x < sx + sw && y < sy + sh)
114                 kernel_film_convert_to_half_float(NULL, rgba, buffer, sample_scale, x, y, offset, stride);
115 }
116
117 #endif
118