diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-28 16:15:15 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-04-28 16:15:15 +0300 |
commit | f8d0b27d9d426c9998f8422cefac72584506a348 (patch) | |
tree | f8c7dfeac6eb8aaf2053c394fb156a28f023ef47 /intern/cycles/render/image.cpp | |
parent | 407fd66d0a2e62eece8c03a2403d1288abbfd9be (diff) |
Cycles: Simplify code around maximum OpenCL info size allocation
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r-- | intern/cycles/render/image.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 50bbcbe8f32..04c86732622 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -196,9 +196,18 @@ ImageDataType ImageManager::get_image_metadata(const string& filename, } } +int ImageManager::max_flattened_slot(ImageDataType type) +{ + if(tex_num_images[type] == 0) { + /* No textures for the type, no slots needs allocation. */ + return 0; + } + return type_index_to_flattened_slot(tex_num_images[type], type); +} + /* The lower three bits of a device texture slot number indicate its type. * These functions convert the slot ids from ImageManager "images" ones - * to device ones and vice versa. + * to device ones and vice verse. * * There are special cases for CUDA Fermi, since there we have only 90 image texture * slots available and should keep the flattended numbers in the 0-89 range. @@ -1084,14 +1093,10 @@ void ImageManager::device_pack_images(Device *device, /* TODO(sergey): This will over-allocate a bit, but this is constant memory * so should be fine for a short term. */ - size_t info_size = max4(type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_FLOAT4], - IMAGE_DATA_TYPE_FLOAT4), - type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_BYTE4], - IMAGE_DATA_TYPE_BYTE4), - type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_FLOAT], - IMAGE_DATA_TYPE_FLOAT), - type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_BYTE], - IMAGE_DATA_TYPE_BYTE)); + const size_t info_size = max4(max_flattened_slot(IMAGE_DATA_TYPE_FLOAT4), + max_flattened_slot(IMAGE_DATA_TYPE_BYTE4), + max_flattened_slot(IMAGE_DATA_TYPE_FLOAT), + max_flattened_slot(IMAGE_DATA_TYPE_BYTE)); uint4 *info = dscene->tex_image_packed_info.resize(info_size*2); /* Pack byte4 textures. */ |