Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernels/cpu/kernel.cpp
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | else if(strcmp(name, #tname) == 0) { \ | ||||
| kg->tname.width = width; \ | kg->tname.width = width; \ | ||||
| } | } | ||||
| #define KERNEL_IMAGE_TEX(type, ttype, tname) | #define KERNEL_IMAGE_TEX(type, ttype, tname) | ||||
| #include "kernel/kernel_textures.h" | #include "kernel/kernel_textures.h" | ||||
| else if(strstr(name, "__tex_image_float4")) { | else if(strstr(name, "__tex_image_float4")) { | ||||
| texture_image_float4 *tex = NULL; | texture_image_float4 *tex = NULL; | ||||
| int id = atoi(name + strlen("__tex_image_float4_")); | int id = atoi(name + strlen("__tex_image_float4_")); | ||||
| int array_index = id; | int array_index = kernel_tex_index(id); | ||||
| if(array_index >= 0 && array_index < TEX_NUM_FLOAT4_CPU) { | if(array_index >= 0) { | ||||
| if(array_index >= kg->texture_float4_images.size()) { | |||||
sergey: Code style, no space after keyword. I would also suggest always use braces, even for single… | |||||
| kg->texture_float4_images.resize(array_index+1); | |||||
| } | |||||
| tex = &kg->texture_float4_images[array_index]; | tex = &kg->texture_float4_images[array_index]; | ||||
| } | } | ||||
| if(tex) { | if(tex) { | ||||
| tex->data = (float4*)mem; | tex->data = (float4*)mem; | ||||
| tex->dimensions_set(width, height, depth); | tex->dimensions_set(width, height, depth); | ||||
| tex->interpolation = interpolation; | tex->interpolation = interpolation; | ||||
| tex->extension = extension; | tex->extension = extension; | ||||
| } | } | ||||
| } | } | ||||
| else if(strstr(name, "__tex_image_float")) { | else if(strstr(name, "__tex_image_float")) { | ||||
| texture_image_float *tex = NULL; | texture_image_float *tex = NULL; | ||||
| int id = atoi(name + strlen("__tex_image_float_")); | int id = atoi(name + strlen("__tex_image_float_")); | ||||
| int array_index = id - TEX_START_FLOAT_CPU; | int array_index = kernel_tex_index(id); | ||||
| if(array_index >= 0 && array_index < TEX_NUM_FLOAT_CPU) { | if(array_index >= 0) { | ||||
| if(array_index >= kg->texture_float_images.size()) { | |||||
| kg->texture_float_images.resize(array_index+1); | |||||
| } | |||||
| tex = &kg->texture_float_images[array_index]; | tex = &kg->texture_float_images[array_index]; | ||||
| } | } | ||||
| if(tex) { | if(tex) { | ||||
| tex->data = (float*)mem; | tex->data = (float*)mem; | ||||
| tex->dimensions_set(width, height, depth); | tex->dimensions_set(width, height, depth); | ||||
| tex->interpolation = interpolation; | tex->interpolation = interpolation; | ||||
| tex->extension = extension; | tex->extension = extension; | ||||
| } | } | ||||
| } | } | ||||
| else if(strstr(name, "__tex_image_byte4")) { | else if(strstr(name, "__tex_image_byte4")) { | ||||
| texture_image_uchar4 *tex = NULL; | texture_image_uchar4 *tex = NULL; | ||||
| int id = atoi(name + strlen("__tex_image_byte4_")); | int id = atoi(name + strlen("__tex_image_byte4_")); | ||||
| int array_index = id - TEX_START_BYTE4_CPU; | int array_index = kernel_tex_index(id); | ||||
| if(array_index >= 0 && array_index < TEX_NUM_BYTE4_CPU) { | if(array_index >= 0) { | ||||
| if(array_index >= kg->texture_byte4_images.size()) { | |||||
| kg->texture_byte4_images.resize(array_index+1); | |||||
| } | |||||
| tex = &kg->texture_byte4_images[array_index]; | tex = &kg->texture_byte4_images[array_index]; | ||||
| } | } | ||||
| if(tex) { | if(tex) { | ||||
| tex->data = (uchar4*)mem; | tex->data = (uchar4*)mem; | ||||
| tex->dimensions_set(width, height, depth); | tex->dimensions_set(width, height, depth); | ||||
| tex->interpolation = interpolation; | tex->interpolation = interpolation; | ||||
| tex->extension = extension; | tex->extension = extension; | ||||
| } | } | ||||
| } | } | ||||
| else if(strstr(name, "__tex_image_byte")) { | else if(strstr(name, "__tex_image_byte")) { | ||||
| texture_image_uchar *tex = NULL; | texture_image_uchar *tex = NULL; | ||||
| int id = atoi(name + strlen("__tex_image_byte_")); | int id = atoi(name + strlen("__tex_image_byte_")); | ||||
| int array_index = id - TEX_START_BYTE_CPU; | int array_index = kernel_tex_index(id); | ||||
| if(array_index >= 0 && array_index < TEX_NUM_BYTE_CPU) { | if(array_index >= 0) { | ||||
| if(array_index >= kg->texture_byte_images.size()) { | |||||
| kg->texture_byte_images.resize(array_index+1); | |||||
| } | |||||
| tex = &kg->texture_byte_images[array_index]; | tex = &kg->texture_byte_images[array_index]; | ||||
| } | } | ||||
| if(tex) { | if(tex) { | ||||
| tex->data = (uchar*)mem; | tex->data = (uchar*)mem; | ||||
| tex->dimensions_set(width, height, depth); | tex->dimensions_set(width, height, depth); | ||||
| tex->interpolation = interpolation; | tex->interpolation = interpolation; | ||||
| tex->extension = extension; | tex->extension = extension; | ||||
| } | } | ||||
| } | } | ||||
| else if(strstr(name, "__tex_image_half4")) { | else if(strstr(name, "__tex_image_half4")) { | ||||
| texture_image_half4 *tex = NULL; | texture_image_half4 *tex = NULL; | ||||
| int id = atoi(name + strlen("__tex_image_half4_")); | int id = atoi(name + strlen("__tex_image_half4_")); | ||||
| int array_index = id - TEX_START_HALF4_CPU; | int array_index = kernel_tex_index(id); | ||||
| if(array_index >= 0 && array_index < TEX_NUM_HALF4_CPU) { | if(array_index >= 0) { | ||||
| if(array_index >= kg->texture_half4_images.size()) { | |||||
| kg->texture_half4_images.resize(array_index+1); | |||||
| } | |||||
| tex = &kg->texture_half4_images[array_index]; | tex = &kg->texture_half4_images[array_index]; | ||||
| } | } | ||||
| if(tex) { | if(tex) { | ||||
| tex->data = (half4*)mem; | tex->data = (half4*)mem; | ||||
| tex->dimensions_set(width, height, depth); | tex->dimensions_set(width, height, depth); | ||||
| tex->interpolation = interpolation; | tex->interpolation = interpolation; | ||||
| tex->extension = extension; | tex->extension = extension; | ||||
| } | } | ||||
| } | } | ||||
| else if(strstr(name, "__tex_image_half")) { | else if(strstr(name, "__tex_image_half")) { | ||||
| texture_image_half *tex = NULL; | texture_image_half *tex = NULL; | ||||
| int id = atoi(name + strlen("__tex_image_half_")); | int id = atoi(name + strlen("__tex_image_half_")); | ||||
| int array_index = id - TEX_START_HALF_CPU; | int array_index = kernel_tex_index(id); | ||||
| if(array_index >= 0 && array_index < TEX_NUM_HALF_CPU) { | if(array_index >= 0) { | ||||
| if(array_index >= kg->texture_half_images.size()) { | |||||
| kg->texture_half_images.resize(array_index+1); | |||||
| } | |||||
| tex = &kg->texture_half_images[array_index]; | tex = &kg->texture_half_images[array_index]; | ||||
| } | } | ||||
| if(tex) { | if(tex) { | ||||
| tex->data = (half*)mem; | tex->data = (half*)mem; | ||||
| tex->dimensions_set(width, height, depth); | tex->dimensions_set(width, height, depth); | ||||
| tex->interpolation = interpolation; | tex->interpolation = interpolation; | ||||
| tex->extension = extension; | tex->extension = extension; | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| assert(0); | assert(0); | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
Code style, no space after keyword. I would also suggest always use braces, even for single line bodies. Makes code more explicit and avoids noise in the future.
Same applies to the cases below.