Cycles Volume Render: support for rendering of homogeneous volume with absorption.
[blender.git] / intern / cycles / kernel / CMakeLists.txt
1
2 set(INC
3         .
4         ../util
5         osl
6         svm
7 )
8
9 set(INC_SYS
10
11 )
12
13 set(SRC
14         kernel.cpp
15         kernel_sse2.cpp
16         kernel_sse3.cpp
17         kernel.cl
18         kernel.cu
19 )
20
21 set(SRC_HEADERS
22         kernel.h
23         kernel_accumulate.h
24         kernel_bvh.h
25         kernel_bvh_subsurface.h
26         kernel_bvh_traversal.h
27         kernel_camera.h
28         kernel_compat_cpu.h
29         kernel_compat_cuda.h
30         kernel_compat_opencl.h
31         kernel_curve.h
32         kernel_differential.h
33         kernel_displace.h
34         kernel_emission.h
35         kernel_film.h
36         kernel_globals.h
37         kernel_jitter.h
38         kernel_light.h
39         kernel_math.h
40         kernel_montecarlo.h
41         kernel_object.h
42         kernel_passes.h
43         kernel_path.h
44         kernel_path_state.h
45         kernel_primitive.h
46         kernel_projection.h
47         kernel_random.h
48         kernel_shader.h
49         kernel_shadow.h
50         kernel_subsurface.h
51         kernel_textures.h
52         kernel_triangle.h
53         kernel_types.h
54         kernel_volume.h
55 )
56
57 set(SRC_CLOSURE_HEADERS
58         closure/bsdf.h
59         closure/bsdf_ashikhmin_velvet.h
60         closure/bsdf_diffuse.h
61         closure/bsdf_diffuse_ramp.h
62         closure/bsdf_microfacet.h
63         closure/bsdf_oren_nayar.h
64         closure/bsdf_phong_ramp.h
65         closure/bsdf_reflection.h
66         closure/bsdf_refraction.h
67         closure/bsdf_toon.h
68         closure/bsdf_transparent.h
69         closure/bsdf_util.h
70         closure/bsdf_ward.h
71         closure/bsdf_westin.h
72         closure/bsdf_hair.h
73         closure/bssrdf.h
74         closure/emissive.h
75         closure/volume.h
76 )
77 set(SRC_SVM_HEADERS
78         svm/svm.h
79         svm/svm_attribute.h
80         svm/svm_blackbody.h
81         svm/svm_camera.h
82         svm/svm_closure.h
83         svm/svm_convert.h
84         svm/svm_checker.h
85         svm/svm_brick.h
86         svm/svm_displace.h
87         svm/svm_fresnel.h
88         svm/svm_wireframe.h
89         svm/svm_wavelength.h
90         svm/svm_gamma.h
91         svm/svm_brightness.h
92         svm/svm_geometry.h
93         svm/svm_gradient.h
94         svm/svm_hsv.h
95         svm/svm_image.h
96         svm/svm_invert.h
97         svm/svm_light_path.h
98         svm/svm_magic.h
99         svm/svm_mapping.h
100         svm/svm_math.h
101         svm/svm_mix.h
102         svm/svm_musgrave.h
103         svm/svm_noise.h
104         svm/svm_noisetex.h
105         svm/svm_normal.h
106         svm/svm_ramp.h
107         svm/svm_sepcomb_rgb.h
108         svm/svm_sepcomb_hsv.h
109         svm/svm_sky.h
110         svm/svm_tex_coord.h
111         svm/svm_texture.h
112         svm/svm_types.h
113         svm/svm_value.h
114         svm/svm_vector_transform.h
115         svm/svm_voronoi.h
116         svm/svm_wave.h
117 )
118
119 set(SRC_UTIL_HEADERS
120         ../util/util_color.h
121         ../util/util_math.h
122         ../util/util_transform.h
123         ../util/util_types.h
124 )
125 # CUDA module
126
127 if(WITH_CYCLES_CUDA_BINARIES)
128         # 32 bit or 64 bit
129         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
130                 set(CUDA_BITS 64)
131         else()
132                 set(CUDA_BITS 32)
133         endif()
134
135         # CUDA version
136         execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT)
137         string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT})
138         string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT})
139         set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
140
141         # warn for other versions
142         if(CUDA_VERSION MATCHES "50")
143         else()
144                 message(WARNING "CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, build may succeed but only CUDA 5.0 is officially supported")
145         endif()
146
147         # build for each arch
148         set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
149         set(cuda_cubins)
150
151         foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
152                 set(cuda_cubin kernel_${arch}.cubin)
153
154                 set(cuda_version_flags "-D__KERNEL_CUDA_VERSION__=${CUDA_VERSION}")
155
156                 # CUDA 5.x build flags for different archs
157                 if(${arch} MATCHES "sm_2[0-9]")
158                         # sm_2x
159                         set(cuda_arch_flags "--maxrregcount=32")
160                 elseif(${arch} MATCHES "sm_3[0-9]")
161                         # sm_3x
162                         set(cuda_arch_flags "--maxrregcount=32")
163                 endif()
164
165                 set(cuda_math_flags "--use_fast_math")
166                 
167                 if(CUDA_VERSION LESS 50 AND ${arch} MATCHES "sm_35")
168                         message(WARNING "Can't build kernel for CUDA sm_35 architecture, skipping")
169                 else()
170                         add_custom_command(
171                                 OUTPUT ${cuda_cubin}
172                                 COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" ${cuda_arch_flags} ${cuda_version_flags} ${cuda_math_flags} -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
173                                 DEPENDS ${cuda_sources})
174
175                         delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
176                         list(APPEND cuda_cubins ${cuda_cubin})
177                 endif()
178         endforeach()
179
180         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
181 endif()
182
183 # OSL module
184
185 if(WITH_CYCLES_OSL)
186         add_subdirectory(osl)
187         add_subdirectory(shaders)
188 endif()
189
190 # CPU module
191
192 include_directories(${INC})
193 include_directories(SYSTEM ${INC_SYS})
194
195 if(WITH_CYCLES_OPTIMIZED_KERNEL)
196         set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
197         set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
198 endif()
199
200 if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41)
201         set_source_files_properties(kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
202         list(APPEND SRC kernel_sse41.cpp)
203 endif()
204
205 add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
206
207 if(WITH_CYCLES_CUDA)
208         add_dependencies(cycles_kernel cycles_kernel_cuda)
209 endif()
210
211 # OpenCL kernel
212
213 #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
214 #add_custom_command(
215 #       OUTPUT ${KERNEL_PREPROCESSED}
216 #       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}
217 #       DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS})
218 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
219 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
220
221 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
222 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
223 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
224 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_CLOSURE_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/closure)
225 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
226 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
227