Hide object center and other info when drawing sets
[blender.git] / intern / cycles / kernel / kernels / cpu / kernel.cpp
1 /*
2  * Copyright 2011-2013 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 /* CPU kernel entry points */
18
19 /* On x86-64, we can assume SSE2, so avoid the extra kernel and compile this
20  * one with SSE2 intrinsics.
21  */
22 #if defined(__x86_64__) || defined(_M_X64)
23 #  define __KERNEL_SSE2__
24 #endif
25
26 /* When building kernel for native machine detect kernel features from the flags
27  * set by compiler.
28  */
29 #ifdef WITH_KERNEL_NATIVE
30 #  ifdef __SSE2__
31 #    ifndef __KERNEL_SSE2__
32 #      define __KERNEL_SSE2__
33 #    endif
34 #  endif
35 #  ifdef __SSE3__
36 #    define __KERNEL_SSE3__
37 #  endif
38 #  ifdef __SSSE3__
39 #    define __KERNEL_SSSE3__
40 #  endif
41 #  ifdef __SSE4_1__
42 #    define __KERNEL_SSE41__
43 #  endif
44 #  ifdef __AVX__
45 #    define __KERNEL_SSE__
46 #    define __KERNEL_AVX__
47 #  endif
48 #  ifdef __AVX2__
49 #    define __KERNEL_SSE__
50 #    define __KERNEL_AVX2__
51 #  endif
52 #endif
53
54 /* quiet unused define warnings */
55 #if defined(__KERNEL_SSE2__)
56     /* do nothing */
57 #endif
58
59 #include "kernel/kernel.h"
60 #define KERNEL_ARCH cpu
61 #include "kernel/kernels/cpu/kernel_cpu_impl.h"
62
63 CCL_NAMESPACE_BEGIN
64
65 /* Memory Copy */
66
67 void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t size)
68 {
69         if(strcmp(name, "__data") == 0)
70                 memcpy(&kg->__data, host, size);
71         else
72                 assert(0);
73 }
74
75 void kernel_tex_copy(KernelGlobals *kg,
76                      const char *name,
77                      device_ptr mem,
78                      size_t width,
79                      size_t height,
80                      size_t depth,
81                      InterpolationType interpolation,
82                      ExtensionType extension)
83 {
84         if(0) {
85         }
86
87 #define KERNEL_TEX(type, ttype, tname) \
88         else if(strcmp(name, #tname) == 0) { \
89                 kg->tname.data = (type*)mem; \
90                 kg->tname.width = width; \
91         }
92 #define KERNEL_IMAGE_TEX(type, ttype, tname)
93 #include "kernel/kernel_textures.h"
94
95         else if(strstr(name, "__tex_image_float4")) {
96                 texture_image_float4 *tex = NULL;
97                 int id = atoi(name + strlen("__tex_image_float4_"));
98                 int array_index = kernel_tex_index(id);
99
100                 if(array_index >= 0) {
101                         if(array_index >= kg->texture_float4_images.size()) {
102                                 kg->texture_float4_images.resize(array_index+1);
103                         }
104                         tex = &kg->texture_float4_images[array_index];
105                 }
106
107                 if(tex) {
108                         tex->data = (float4*)mem;
109                         tex->dimensions_set(width, height, depth);
110                         tex->interpolation = interpolation;
111                         tex->extension = extension;
112                 }
113         }
114         else if(strstr(name, "__tex_image_float")) {
115                 texture_image_float *tex = NULL;
116                 int id = atoi(name + strlen("__tex_image_float_"));
117                 int array_index = kernel_tex_index(id);
118                 
119                 if(array_index >= 0) {
120                         if(array_index >= kg->texture_float_images.size()) {
121                                 kg->texture_float_images.resize(array_index+1);
122                         }
123                         tex = &kg->texture_float_images[array_index];
124                 }
125
126                 if(tex) {
127                         tex->data = (float*)mem;
128                         tex->dimensions_set(width, height, depth);
129                         tex->interpolation = interpolation;
130                         tex->extension = extension;
131                 }
132         }
133         else if(strstr(name, "__tex_image_byte4")) {
134                 texture_image_uchar4 *tex = NULL;
135                 int id = atoi(name + strlen("__tex_image_byte4_"));
136                 int array_index = kernel_tex_index(id);
137                 
138                 if(array_index >= 0) {
139                         if(array_index >= kg->texture_byte4_images.size()) {
140                                 kg->texture_byte4_images.resize(array_index+1);
141                         }
142                         tex = &kg->texture_byte4_images[array_index];
143                 }
144
145                 if(tex) {
146                         tex->data = (uchar4*)mem;
147                         tex->dimensions_set(width, height, depth);
148                         tex->interpolation = interpolation;
149                         tex->extension = extension;
150                 }
151         }
152         else if(strstr(name, "__tex_image_byte")) {
153                 texture_image_uchar *tex = NULL;
154                 int id = atoi(name + strlen("__tex_image_byte_"));
155                 int array_index = kernel_tex_index(id);
156                 
157                 if(array_index >= 0) {
158                         if(array_index >= kg->texture_byte_images.size()) {
159                                 kg->texture_byte_images.resize(array_index+1);
160                         }
161                         tex = &kg->texture_byte_images[array_index];
162                 }
163
164                 if(tex) {
165                         tex->data = (uchar*)mem;
166                         tex->dimensions_set(width, height, depth);
167                         tex->interpolation = interpolation;
168                         tex->extension = extension;
169                 }
170         }
171         else if(strstr(name, "__tex_image_half4")) {
172                 texture_image_half4 *tex = NULL;
173                 int id = atoi(name + strlen("__tex_image_half4_"));
174                 int array_index = kernel_tex_index(id);
175                 
176                 if(array_index >= 0) {
177                         if(array_index >= kg->texture_half4_images.size()) {
178                                 kg->texture_half4_images.resize(array_index+1);
179                         }
180                         tex = &kg->texture_half4_images[array_index];
181                 }
182
183                 if(tex) {
184                         tex->data = (half4*)mem;
185                         tex->dimensions_set(width, height, depth);
186                         tex->interpolation = interpolation;
187                         tex->extension = extension;
188                 }
189         }
190         else if(strstr(name, "__tex_image_half")) {
191                 texture_image_half *tex = NULL;
192                 int id = atoi(name + strlen("__tex_image_half_"));
193                 int array_index = kernel_tex_index(id);
194                 
195                 if(array_index >= 0) {
196                         if(array_index >= kg->texture_half_images.size()) {
197                                 kg->texture_half_images.resize(array_index+1);
198                         }
199                         tex = &kg->texture_half_images[array_index];
200                 }
201
202                 if(tex) {
203                         tex->data = (half*)mem;
204                         tex->dimensions_set(width, height, depth);
205                         tex->interpolation = interpolation;
206                         tex->extension = extension;
207                 }
208         }
209         else
210                 assert(0);
211 }
212
213 CCL_NAMESPACE_END