Cycles: Add support for single channel float textures on CPU.

Until now, single channel textures were packed into a float4, wasting 3 floats per pixel. Memory usage of such textures is now reduced by 3/4.
Voxel Attributes such as density, flame and heat benefit from this, but also Bumpmaps with one channel.
This commit also includes some cleanup and code deduplication for image loading.

Example Smoke render from Cosmos Laundromat: http://www.pasteall.org/pic/show.php?id=102972
Memory here went down from ~600MB to ~300MB.

Reviewers: #cycles, brecht

Differential Revision: https://developer.blender.org/D1981
This commit is contained in:
Thomas Dinges
2016-05-09 12:51:42 +02:00
parent 544b76ac9c
commit 4a4f043bc4
9 changed files with 235 additions and 97 deletions

View File

@@ -106,10 +106,26 @@ void kernel_tex_copy(KernelGlobals *kg,
tex->extension = extension;
}
}
else if(strstr(name, "__tex_image_float")) {
texture_image_float *tex = NULL;
int id = atoi(name + strlen("__tex_image_float_"));
int array_index = id - TEX_IMAGE_FLOAT_START_CPU;
if(array_index >= 0 && array_index < TEX_NUM_FLOAT_IMAGES_CPU) {
tex = &kg->texture_float_images[array_index];
}
if(tex) {
tex->data = (float*)mem;
tex->dimensions_set(width, height, depth);
tex->interpolation = interpolation;
tex->extension = extension;
}
}
else if(strstr(name, "__tex_image_byte4")) {
texture_image_uchar4 *tex = NULL;
int id = atoi(name + strlen("__tex_image_byte4_"));
int array_index = id - TEX_NUM_FLOAT4_IMAGES_CPU;
int array_index = id - TEX_IMAGE_BYTE4_START_CPU;
if(array_index >= 0 && array_index < TEX_NUM_BYTE4_IMAGES_CPU) {
tex = &kg->texture_byte4_images[array_index];