Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-04-28 16:15:15 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-04-28 16:15:15 +0300
commitf8d0b27d9d426c9998f8422cefac72584506a348 (patch)
treef8c7dfeac6eb8aaf2053c394fb156a28f023ef47 /intern
parent407fd66d0a2e62eece8c03a2403d1288abbfd9be (diff)
Cycles: Simplify code around maximum OpenCL info size allocation
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/render/image.cpp23
-rw-r--r--intern/cycles/render/image.h1
2 files changed, 15 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. */
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 0d457c144fe..5550d019868 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -134,6 +134,7 @@ private:
int texture_limit,
device_vector<DeviceType>& tex_img);
+ int max_flattened_slot(ImageDataType type);
int type_index_to_flattened_slot(int slot, ImageDataType type);
int flattened_slot_to_type_index(int flat_slot, ImageDataType *type);
string name_from_type(int type);