[Bf-blender-cvs] [98e2135] master: Fix T48380: fix for recent image manager code cleanup.

Brecht Van Lommel noreply at git.blender.org
Sun May 8 21:44:20 CEST 2016


Commit: 98e2135a2d5b6689788870003804f958dea54db7
Author: Brecht Van Lommel
Date:   Sun May 8 21:41:25 2016 +0200
Branches: master
https://developer.blender.org/rB98e2135a2d5b6689788870003804f958dea54db7

Fix T48380: fix for recent image manager code cleanup.

===================================================================

M	intern/cycles/render/image.cpp
M	intern/cycles/render/image.h

===================================================================

diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 7cfa3fd..218779e 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -177,15 +177,15 @@ int ImageManager::type_index_to_flattened_slot(int slot, ImageDataType type)
 		return slot;
 }
 
-int ImageManager::flattened_slot_to_type_index(int slot, ImageDataType *type)
+int ImageManager::flattened_slot_to_type_index(int flat_slot, ImageDataType *type)
 {
-	if(slot >= tex_image_byte_start) {
+	if(flat_slot >= tex_image_byte_start) {
 		*type = IMAGE_DATA_TYPE_BYTE4;
-		return slot - tex_image_byte_start;
+		return flat_slot - tex_image_byte_start;
 	}
 	else {
 		*type = IMAGE_DATA_TYPE_FLOAT4;
-		return slot;
+		return flat_slot;
 	}
 }
 
@@ -285,10 +285,10 @@ int ImageManager::add_image(const string& filename,
 	return type_index_to_flattened_slot(slot, type);
 }
 
-void ImageManager::remove_image(int slot)
+void ImageManager::remove_image(int flat_slot)
 {
 	ImageDataType type;
-	slot = flattened_slot_to_type_index(slot, &type);
+	int slot = flattened_slot_to_type_index(flat_slot, &type);
 
 	Image *image = images[type][slot];
 	assert(image && image->users >= 1);
@@ -655,9 +655,10 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, ImageD
 
 		string name;
 
-		if(slot >= 100) name = string_printf("__tex_image_float4_%d", slot);
-		else if(slot >= 10) name = string_printf("__tex_image_float4_0%d", slot);
-		else name = string_printf("__tex_image_float4_00%d", slot);
+		int flat_slot = type_index_to_flattened_slot(slot, type);
+		if(flat_slot >= 100) name = string_printf("__tex_image_float4_%d", flat_slot);
+		else if(flat_slot >= 10) name = string_printf("__tex_image_float4_0%d", flat_slot);
+		else name = string_printf("__tex_image_float4_00%d", flat_slot);
 
 		if(!pack_images) {
 			thread_scoped_lock device_lock(device_mutex);
@@ -687,9 +688,10 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, ImageD
 
 		string name;
 
-		if(slot >= 100) name = string_printf("__tex_image_byte_%d", slot);
-		else if(slot >= 10) name = string_printf("__tex_image_byte_0%d", slot);
-		else name = string_printf("__tex_image_byte_00%d", slot);
+		int flat_slot = type_index_to_flattened_slot(slot, type);
+		if(flat_slot >= 100) name = string_printf("__tex_image_byte_%d", flat_slot);
+		else if(flat_slot >= 10) name = string_printf("__tex_image_byte_0%d", flat_slot);
+		else name = string_printf("__tex_image_byte_00%d", flat_slot);
 
 		if(!pack_images) {
 			thread_scoped_lock device_lock(device_mutex);
@@ -775,11 +777,11 @@ void ImageManager::device_update(Device *device, DeviceScene *dscene, Progress&
 
 void ImageManager::device_update_slot(Device *device,
                                       DeviceScene *dscene,
-                                      int slot,
+                                      int flat_slot,
                                       Progress *progress)
 {
 	ImageDataType type;
-	slot = flattened_slot_to_type_index(slot, &type);
+	int slot = flattened_slot_to_type_index(flat_slot, &type);
 
 	Image *image = images[type][slot];
 	assert(image != NULL);
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index bda288c..24d6aae 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -51,7 +51,7 @@ public:
 	              InterpolationType interpolation,
 	              ExtensionType extension,
 	              bool use_alpha);
-	void remove_image(int slot);
+	void remove_image(int flat_slot);
 	void remove_image(const string& filename,
 	                  void *builtin_data,
 	                  InterpolationType interpolation,
@@ -63,7 +63,7 @@ public:
 	bool is_float_image(const string& filename, void *builtin_data, bool& is_linear);
 
 	void device_update(Device *device, DeviceScene *dscene, Progress& progress);
-	void device_update_slot(Device *device, DeviceScene *dscene, int slot, Progress *progress);
+	void device_update_slot(Device *device, DeviceScene *dscene, int flat_slot, Progress *progress);
 	void device_free(Device *device, DeviceScene *dscene);
 	void device_free_builtin(Device *device, DeviceScene *dscene);
 
@@ -105,7 +105,7 @@ private:
 	bool file_load_float_image(Image *img, device_vector<float4>& tex_img);
 
 	int type_index_to_flattened_slot(int slot, ImageDataType type);
-	int flattened_slot_to_type_index(int slot, ImageDataType *type);
+	int flattened_slot_to_type_index(int flat_slot, ImageDataType *type);
 	string name_from_type(int type);
 
 	void device_load_image(Device *device, DeviceScene *dscene, ImageDataType type, int slot, Progress *progess);




More information about the Bf-blender-cvs mailing list