Cycles: Remove sum_all_radiance kernel
[blender-staging.git] / intern / cycles / kernel / CMakeLists.txt
1 remove_extra_strict_flags()
2
3 set(INC
4         .
5         ../util
6         osl
7         svm
8 )
9
10 set(INC_SYS
11
12 )
13
14 set(SRC
15         kernels/cpu/kernel.cpp
16         kernels/cpu/kernel_split.cpp
17         kernels/opencl/kernel.cl
18         kernels/opencl/kernel_data_init.cl
19         kernels/opencl/kernel_path_init.cl
20         kernels/opencl/kernel_queue_enqueue.cl
21         kernels/opencl/kernel_scene_intersect.cl
22         kernels/opencl/kernel_lamp_emission.cl
23         kernels/opencl/kernel_background_buffer_update.cl
24         kernels/opencl/kernel_shader_eval.cl
25         kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl
26         kernels/opencl/kernel_direct_lighting.cl
27         kernels/opencl/kernel_shadow_blocked.cl
28         kernels/opencl/kernel_next_iteration_setup.cl
29         kernels/cuda/kernel.cu
30         kernels/cuda/kernel_split.cu
31 )
32
33 set(SRC_BVH_HEADERS
34         bvh/bvh.h
35         bvh/bvh_nodes.h
36         bvh/bvh_shadow_all.h
37         bvh/bvh_subsurface.h
38         bvh/bvh_traversal.h
39         bvh/bvh_types.h
40         bvh/bvh_volume.h
41         bvh/bvh_volume_all.h
42         bvh/qbvh_nodes.h
43         bvh/qbvh_shadow_all.h
44         bvh/qbvh_subsurface.h
45         bvh/qbvh_traversal.h
46         bvh/qbvh_volume.h
47         bvh/qbvh_volume_all.h
48 )
49
50 set(SRC_HEADERS
51         kernel_accumulate.h
52         kernel_bake.h
53         kernel_camera.h
54         kernel_compat_cpu.h
55         kernel_compat_cuda.h
56         kernel_compat_opencl.h
57         kernel_debug.h
58         kernel_differential.h
59         kernel_emission.h
60         kernel_film.h
61         kernel_globals.h
62         kernel_image_opencl.h
63         kernel_jitter.h
64         kernel_light.h
65         kernel_math.h
66         kernel_montecarlo.h
67         kernel_passes.h
68         kernel_path.h
69         kernel_path_branched.h
70         kernel_path_common.h
71         kernel_path_state.h
72         kernel_path_surface.h
73         kernel_path_volume.h
74         kernel_projection.h
75         kernel_queues.h
76         kernel_random.h
77         kernel_shader.h
78         kernel_shadow.h
79         kernel_subsurface.h
80         kernel_textures.h
81         kernel_types.h
82         kernel_volume.h
83         kernel_work_stealing.h
84 )
85
86 set(SRC_KERNELS_CPU_HEADERS
87         kernel.h
88         kernels/cpu/kernel_cpu.h
89         kernels/cpu/kernel_cpu_impl.h
90         kernels/cpu/kernel_cpu_image.h
91 )
92
93 set(SRC_KERNELS_CUDA_HEADERS
94         kernels/cuda/kernel_config.h
95 )
96
97 set(SRC_CLOSURE_HEADERS
98         closure/alloc.h
99         closure/bsdf.h
100         closure/bsdf_ashikhmin_velvet.h
101         closure/bsdf_diffuse.h
102         closure/bsdf_diffuse_ramp.h
103         closure/bsdf_microfacet.h
104         closure/bsdf_microfacet_multi.h
105         closure/bsdf_microfacet_multi_impl.h
106         closure/bsdf_oren_nayar.h
107         closure/bsdf_phong_ramp.h
108         closure/bsdf_reflection.h
109         closure/bsdf_refraction.h
110         closure/bsdf_toon.h
111         closure/bsdf_transparent.h
112         closure/bsdf_util.h
113         closure/bsdf_ashikhmin_shirley.h
114         closure/bsdf_hair.h
115         closure/bssrdf.h
116         closure/emissive.h
117         closure/volume.h
118 )
119
120 set(SRC_SVM_HEADERS
121         svm/svm.h
122         svm/svm_attribute.h
123         svm/svm_blackbody.h
124         svm/svm_bump.h
125         svm/svm_camera.h
126         svm/svm_closure.h
127         svm/svm_convert.h
128         svm/svm_checker.h
129         svm/svm_color_util.h
130         svm/svm_brick.h
131         svm/svm_displace.h
132         svm/svm_fresnel.h
133         svm/svm_wireframe.h
134         svm/svm_wavelength.h
135         svm/svm_gamma.h
136         svm/svm_brightness.h
137         svm/svm_geometry.h
138         svm/svm_gradient.h
139         svm/svm_hsv.h
140         svm/svm_image.h
141         svm/svm_invert.h
142         svm/svm_light_path.h
143         svm/svm_magic.h
144         svm/svm_mapping.h
145         svm/svm_math.h
146         svm/svm_math_util.h
147         svm/svm_mix.h
148         svm/svm_musgrave.h
149         svm/svm_noise.h
150         svm/svm_noisetex.h
151         svm/svm_normal.h
152         svm/svm_ramp.h
153         svm/svm_ramp_util.h
154         svm/svm_sepcomb_hsv.h
155         svm/svm_sepcomb_vector.h
156         svm/svm_sky.h
157         svm/svm_tex_coord.h
158         svm/svm_texture.h
159         svm/svm_types.h
160         svm/svm_value.h
161         svm/svm_vector_transform.h
162         svm/svm_voronoi.h
163         svm/svm_voxel.h
164         svm/svm_wave.h
165 )
166
167 set(SRC_GEOM_HEADERS
168         geom/geom.h
169         geom/geom_attribute.h
170         geom/geom_curve.h
171         geom/geom_motion_curve.h
172         geom/geom_motion_triangle.h
173         geom/geom_motion_triangle_intersect.h
174         geom/geom_motion_triangle_shader.h
175         geom/geom_object.h
176         geom/geom_patch.h
177         geom/geom_primitive.h
178         geom/geom_subd_triangle.h
179         geom/geom_triangle.h
180         geom/geom_triangle_intersect.h
181         geom/geom_volume.h
182 )
183
184 set(SRC_UTIL_HEADERS
185         ../util/util_atomic.h
186         ../util/util_color.h
187         ../util/util_half.h
188         ../util/util_hash.h
189         ../util/util_math.h
190         ../util/util_math_fast.h
191         ../util/util_static_assert.h
192         ../util/util_transform.h
193         ../util/util_texture.h
194         ../util/util_types.h
195 )
196
197 set(SRC_SPLIT_HEADERS
198         split/kernel_background_buffer_update.h
199         split/kernel_data_init.h
200         split/kernel_direct_lighting.h
201         split/kernel_holdout_emission_blurring_pathtermination_ao.h
202         split/kernel_lamp_emission.h
203         split/kernel_next_iteration_setup.h
204         split/kernel_path_init.h
205         split/kernel_queue_enqueue.h
206         split/kernel_scene_intersect.h
207         split/kernel_shader_eval.h
208         split/kernel_shadow_blocked.h
209         split/kernel_split_common.h
210         split/kernel_split_data.h
211 )
212
213 # CUDA module
214
215 if(WITH_CYCLES_CUDA_BINARIES)
216         # 32 bit or 64 bit
217         if(CUDA_64_BIT_DEVICE_CODE)
218                 set(CUDA_BITS 64)
219         else()
220                 set(CUDA_BITS 32)
221         endif()
222
223         # CUDA version
224         execute_process(COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT)
225         string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${NVCC_OUT}")
226         string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${NVCC_OUT}")
227         set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
228
229         # warn for other versions
230         if(CUDA_VERSION MATCHES "80")
231         else()
232                 message(WARNING
233                         "CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, "
234                         "build may succeed but only CUDA 8.0 is officially supported")
235         endif()
236
237         # build for each arch
238         set(cuda_sources kernels/cuda/kernel.cu kernels/cuda/kernel_split.cu
239                 ${SRC_HEADERS}
240                 ${SRC_KERNELS_CUDA_HEADERS}
241                 ${SRC_BVH_HEADERS}
242                 ${SRC_SVM_HEADERS}
243                 ${SRC_GEOM_HEADERS}
244                 ${SRC_CLOSURE_HEADERS}
245                 ${SRC_UTIL_HEADERS}
246         )
247         set(cuda_cubins)
248
249         macro(CYCLES_CUDA_KERNEL_ADD arch split experimental)
250                 if(${split})
251                         set(cuda_extra_flags "-D__SPLIT__")
252                         set(cuda_cubin kernel_split)
253                 else()
254                         set(cuda_extra_flags "")
255                         set(cuda_cubin kernel)
256                 endif()
257
258                 if(${experimental})
259                         set(cuda_extra_flags ${cuda_extra_flags} -D__KERNEL_EXPERIMENTAL__)
260                         set(cuda_cubin ${cuda_cubin}_experimental)
261                 endif()
262
263                 set(cuda_cubin ${cuda_cubin}_${arch}.cubin)
264
265                 if(WITH_CYCLES_DEBUG)
266                         set(cuda_debug_flags "-D__KERNEL_DEBUG__")
267                 else()
268                         set(cuda_debug_flags "")
269                 endif()
270
271                 set(cuda_nvcc_command ${CUDA_NVCC_EXECUTABLE})
272                 set(cuda_nvcc_version ${CUDA_VERSION})
273
274                 set(cuda_version_flags "-D__KERNEL_CUDA_VERSION__=${cuda_nvcc_version}")
275                 set(cuda_math_flags "--use_fast_math")
276
277                 if(split)
278                         set(cuda_kernel_src "/kernels/cuda/kernel_split.cu")
279                 else()
280                         set(cuda_kernel_src "/kernels/cuda/kernel.cu")
281                 endif()
282
283                 add_custom_command(
284                         OUTPUT ${cuda_cubin}
285                         COMMAND ${cuda_nvcc_command}
286                                         -arch=${arch}
287                                         ${CUDA_NVCC_FLAGS}
288                                         -m${CUDA_BITS}
289                                         --cubin ${CMAKE_CURRENT_SOURCE_DIR}${cuda_kernel_src}
290                                         -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin}
291                                         --ptxas-options="-v"
292                                         ${cuda_arch_flags}
293                                         ${cuda_version_flags}
294                                         ${cuda_math_flags}
295                                         ${cuda_extra_flags}
296                                         ${cuda_debug_flags}
297                                         -I${CMAKE_CURRENT_SOURCE_DIR}/../util
298                                         -I${CMAKE_CURRENT_SOURCE_DIR}/svm
299                                         -DCCL_NAMESPACE_BEGIN=
300                                         -DCCL_NAMESPACE_END=
301                                         -DNVCC
302                         DEPENDS ${cuda_sources})
303
304                 delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
305                 list(APPEND cuda_cubins ${cuda_cubin})
306
307                 unset(cuda_extra_flags)
308                 unset(cuda_debug_flags)
309
310                 unset(cuda_nvcc_command)
311                 unset(cuda_nvcc_version)
312         endmacro()
313
314         foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
315                 # Compile regular kernel
316                 CYCLES_CUDA_KERNEL_ADD(${arch} FALSE FALSE)
317
318                 if(WITH_CYCLES_CUDA_SPLIT_KERNEL_BINARIES)
319                         # Compile split kernel
320                         CYCLES_CUDA_KERNEL_ADD(${arch} TRUE FALSE)
321                 endif()
322         endforeach()
323
324         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
325 endif()
326
327 # OSL module
328
329 if(WITH_CYCLES_OSL)
330         add_subdirectory(osl)
331         add_subdirectory(shaders)
332 endif()
333
334 # CPU module
335
336 include_directories(${INC})
337 include_directories(SYSTEM ${INC_SYS})
338
339 if(CXX_HAS_SSE)
340         list(APPEND SRC
341                 kernels/cpu/kernel_sse2.cpp
342                 kernels/cpu/kernel_sse3.cpp
343                 kernels/cpu/kernel_sse41.cpp
344                 kernels/cpu/kernel_split_sse2.cpp
345                 kernels/cpu/kernel_split_sse3.cpp
346                 kernels/cpu/kernel_split_sse41.cpp
347         )
348
349         set_source_files_properties(kernels/cpu/kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
350         set_source_files_properties(kernels/cpu/kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
351         set_source_files_properties(kernels/cpu/kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
352         set_source_files_properties(kernels/cpu/kernel_split_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
353         set_source_files_properties(kernels/cpu/kernel_split_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
354         set_source_files_properties(kernels/cpu/kernel_split_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
355 endif()
356
357 if(CXX_HAS_AVX)
358         list(APPEND SRC
359                 kernels/cpu/kernel_avx.cpp
360                 kernels/cpu/kernel_split_avx.cpp
361         )
362         set_source_files_properties(kernels/cpu/kernel_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
363         set_source_files_properties(kernels/cpu/kernel_split_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
364 endif()
365
366 if(CXX_HAS_AVX2)
367         list(APPEND SRC
368                 kernels/cpu/kernel_avx2.cpp
369                 kernels/cpu/kernel_split_avx2.cpp
370         )
371         set_source_files_properties(kernels/cpu/kernel_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
372         set_source_files_properties(kernels/cpu/kernel_split_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
373 endif()
374
375 add_library(cycles_kernel
376         ${SRC}
377         ${SRC_HEADERS}
378         ${SRC_KERNELS_CPU_HEADERS}
379         ${SRC_KERNELS_CUDA_HEADERS}
380         ${SRC_BVH_HEADERS}
381         ${SRC_CLOSURE_HEADERS}
382         ${SRC_SVM_HEADERS}
383         ${SRC_GEOM_HEADERS}
384         ${SRC_SPLIT_HEADERS}
385 )
386
387 if(WITH_CYCLES_CUDA)
388         add_dependencies(cycles_kernel cycles_kernel_cuda)
389 endif()
390
391 # OpenCL kernel
392
393 #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
394 #add_custom_command(
395 #       OUTPUT ${KERNEL_PREPROCESSED}
396 #       COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -o ${KERNEL_PREPROCESSED}
397 #       DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS})
398 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
399 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
400
401 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
402 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_data_init.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
403 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_path_init.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
404 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_queue_enqueue.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
405 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_scene_intersect.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
406 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_lamp_emission.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
407 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_background_buffer_update.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
408 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_shader_eval.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
409 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
410 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_direct_lighting.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
411 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_shadow_blocked.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
412 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_next_iteration_setup.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
413 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/cuda/kernel.cu" ${CYCLES_INSTALL_PATH}/kernel/kernels/cuda)
414 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/cuda/kernel_split.cu" ${CYCLES_INSTALL_PATH}/kernel/kernels/cuda)
415 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
416 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_KERNELS_CUDA_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/kernels/cuda)
417 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_BVH_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/bvh)
418 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_CLOSURE_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/closure)
419 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
420 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_GEOM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/geom)
421 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
422 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SPLIT_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/split)
423