Cycles OSL minor optimizations: recycle shading context, don't do memory
[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_optimized.cpp
16         kernel.cl
17         kernel.cu
18 )
19
20 set(SRC_HEADERS
21         kernel.h
22         kernel_accumulate.h
23         kernel_attribute.h
24         kernel_bvh.h
25         kernel_camera.h
26         kernel_compat_cpu.h
27         kernel_compat_cuda.h
28         kernel_compat_opencl.h
29         kernel_differential.h
30         kernel_displace.h
31         kernel_emission.h
32         kernel_film.h
33         kernel_globals.h
34         kernel_light.h
35         kernel_math.h
36         kernel_montecarlo.h
37         kernel_object.h
38         kernel_passes.h
39         kernel_path.h
40         kernel_projection.h
41         kernel_random.h
42         kernel_shader.h
43         kernel_textures.h
44         kernel_triangle.h
45         kernel_types.h
46 )
47
48 set(SRC_CLOSURE_HEADERS
49         closure/bsdf.h
50         closure/bsdf_ashikhmin_velvet.h
51         closure/bsdf_diffuse.h
52         closure/bsdf_diffuse_ramp.h
53         closure/bsdf_microfacet.h
54         closure/bsdf_oren_nayar.h
55         closure/bsdf_phong_ramp.h
56         closure/bsdf_reflection.h
57         closure/bsdf_refraction.h
58         closure/bsdf_transparent.h
59         closure/bsdf_util.h
60         closure/bsdf_ward.h
61         closure/bsdf_westin.h
62         closure/emissive.h
63         closure/volume.h
64 )
65 set(SRC_SVM_HEADERS
66         svm/svm.h
67         svm/svm_attribute.h
68         svm/svm_camera.h
69         svm/svm_closure.h
70         svm/svm_convert.h
71         svm/svm_checker.h
72         svm/svm_brick.h
73         svm/svm_displace.h
74         svm/svm_fresnel.h
75         svm/svm_gamma.h
76         svm/svm_brightness.h
77         svm/svm_geometry.h
78         svm/svm_gradient.h
79         svm/svm_hsv.h
80         svm/svm_image.h
81         svm/svm_invert.h
82         svm/svm_light_path.h
83         svm/svm_magic.h
84         svm/svm_mapping.h
85         svm/svm_math.h
86         svm/svm_mix.h
87         svm/svm_musgrave.h
88         svm/svm_noise.h
89         svm/svm_noisetex.h
90         svm/svm_normal.h
91         svm/svm_ramp.h
92         svm/svm_sepcomb_rgb.h
93         svm/svm_sky.h
94         svm/svm_tex_coord.h
95         svm/svm_texture.h
96         svm/svm_types.h
97         svm/svm_value.h
98         svm/svm_voronoi.h
99         svm/svm_wave.h
100 )
101
102 set(SRC_UTIL_HEADERS
103         ../util/util_color.h
104         ../util/util_math.h
105         ../util/util_transform.h
106         ../util/util_types.h
107 )
108 # CUDA module
109
110 if(WITH_CYCLES_CUDA_BINARIES)
111         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
112                 set(CUDA_BITS 64)
113         else()
114                 set(CUDA_BITS 32)
115         endif()
116
117         set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
118         set(cuda_cubins)
119
120         foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
121                 set(cuda_cubin kernel_${arch}.cubin)
122
123                 add_custom_command(
124                         OUTPUT ${cuda_cubin}
125                         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" --maxrregcount=24 --opencc-options -OPT:Olimit=0 -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
126                         DEPENDS ${cuda_sources})
127
128                 delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
129                 list(APPEND cuda_cubins ${cuda_cubin})
130         endforeach()
131
132         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
133 endif()
134
135 # OSL module
136
137 if(WITH_CYCLES_OSL)
138         add_subdirectory(osl)
139         add_subdirectory(shaders)
140 endif()
141
142 # CPU module
143
144 include_directories(${INC})
145 include_directories(SYSTEM ${INC_SYS})
146
147 add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
148
149 if(WITH_CYCLES_OPTIMIZED_KERNEL)
150         set_source_files_properties(kernel_optimized.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_OPTIMIZED_KERNEL_FLAGS}")
151 endif()
152
153 if(WITH_CYCLES_CUDA)
154         add_dependencies(cycles_kernel cycles_kernel_cuda)
155 endif()
156
157 # OpenCL kernel
158
159 #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
160 #add_custom_command(
161 #       OUTPUT ${KERNEL_PREPROCESSED}
162 #       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}
163 #       DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS})
164 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
165 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
166
167 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
168 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
169 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
170 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_CLOSURE_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/closure)
171 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
172 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
173