[Bf-blender-cvs] [8946dc52edd] cycles_texture_cache: Cycles: a handful of fixes for texture caching

Stefan Werner noreply at git.blender.org
Mon Nov 27 20:40:07 CET 2017


Commit: 8946dc52edd1a120b81c889a555aa0a86375c13e
Author: Stefan Werner
Date:   Thu May 4 15:01:23 2017 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB8946dc52edd1a120b81c889a555aa0a86375c13e

Cycles: a handful of fixes for texture caching

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

M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/device/device_cpu.cpp
M	intern/cycles/render/image.cpp
M	intern/cycles/render/shader.cpp

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

diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index bdc40b5c0e8..b25a0a3005d 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -669,9 +669,9 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
 	params.use_qbvh = DebugFlags().cpu.qbvh;
 
 	params.texture_cache_size = RNA_int_get(&cscene, "texture_cache_size");
-	params.texture_auto_convert = RNA_int_get(&cscene, "texture_auto_convert");
-	params.texture_accept_unmipped = RNA_int_get(&cscene, "texture_accept_unmipped");
-	params.texture_accept_untiled = RNA_int_get(&cscene, "texture_accept_untiled");
+	params.texture_auto_convert = RNA_boolean_get(&cscene, "texture_auto_convert");
+	params.texture_accept_unmipped = RNA_boolean_get(&cscene, "texture_accept_unmipped");
+	params.texture_accept_untiled = RNA_boolean_get(&cscene, "texture_accept_untiled");
 	params.texture_tile_size = RNA_int_get(&cscene, "texture_tile_size");
 	params.texture_auto_mip = RNA_int_get(&cscene, "texture_auto_mip");
 	params.texture_auto_tile = RNA_int_get(&cscene, "texture_auto_tile");
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index a7708ba2a62..624ac8f5ada 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -239,11 +239,7 @@ public:
 #ifdef WITH_OSL
 		kernel_globals.osl = &osl_globals;
 #endif
-		oiio_globals.tex_sys = TextureSystem::create();
-		oiio_globals.tex_sys->attribute("max_memory_MB", 1024.0f);
-		oiio_globals.tex_sys->attribute("autotile", 64);
-		oiio_globals.tex_sys->attribute("automip", 64);
-		oiio_globals.tex_sys->attribute("gray_to_rgb", 1);
+		oiio_globals.tex_sys = NULL;
 		kernel_globals.oiio = &oiio_globals;
 		
 		use_split_kernel = DebugFlags().cpu.split_kernel;
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 3faeaaf1be0..a52e58d42d7 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -701,7 +701,10 @@ void ImageManager::device_load_image(Device *device,
 		return;
 
 	Image *img = images[type][slot];
-
+	if(!img) {
+		return;
+	}
+	
 	if(oiio_texture_system && !img->builtin_data) {
 		if(scene->params.texture_auto_convert) {
 			make_tx(img, progress);
@@ -713,14 +716,14 @@ void ImageManager::device_load_image(Device *device,
 				oiio->tex_paths.resize(flat_slot+1);
 			}
 			OIIO::TextureSystem *tex_sys = (OIIO::TextureSystem*)oiio_texture_system;
-			OIIO::TextureSystem::TextureHandle *handle = tex_sys->get_texture_handle(OIIO::ustring(images[type][slot]->filename.c_str()));
+			OIIO::TextureSystem::TextureHandle *handle = tex_sys->get_texture_handle(OIIO::ustring(img->filename.c_str()));
 			oiio->tex_paths[flat_slot] = handle;
 		}
 		img->need_load = false;
 		return;
 	}
 
-	string filename = path_filename(images[type][slot]->filename);
+	string filename = path_filename(img->filename);
 	progress->set_status("Updating Images", "Loading " + filename);
 
 	const int texture_limit = scene->params.texture_limit;
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 73bff944c96..b94ca1fb82d 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -31,6 +31,7 @@
 
 #include "util/util_foreach.h"
 
+#include "kernel/kernel_oiio_globals.h"
 #include <OpenImageIO/texture.h>
 
 CCL_NAMESPACE_BEGIN
@@ -428,12 +429,16 @@ void ShaderManager::device_update_common(Device *device,
 	if(scene->params.shadingsystem == SHADINGSYSTEM_OSL || scene->params.texture_cache_size > 0) {
 		/* set texture system */
 		scene->image_manager->set_oiio_texture_system((void*)ts);
-		/* update attributes from scene parms */
-		ts_shared->attribute("autotile", scene->params.texture_auto_tile ? scene->params.texture_tile_size : 0);
-		ts_shared->attribute("automip", scene->params.texture_auto_mip ? 1 : 0);
-		ts_shared->attribute("accept_unmipped", scene->params.texture_accept_unmipped ? 1 : 0);
-		ts_shared->attribute("accept_untiled", scene->params.texture_accept_untiled ? 1 : 0);
-		ts_shared->attribute("max_memory_MB", scene->params.texture_cache_size > 0 ? (float)scene->params.texture_cache_size : 16384.0f);
+		OIIOGlobals *oiio_globals = (OIIOGlobals*)device->oiio_memory();
+		if(oiio_globals) {
+			/* update attributes from scene parms */
+			ts_shared->attribute("autotile", scene->params.texture_auto_tile ? scene->params.texture_tile_size : 0);
+			ts_shared->attribute("automip", scene->params.texture_auto_mip ? 1 : 0);
+			ts_shared->attribute("accept_unmipped", scene->params.texture_accept_unmipped ? 1 : 0);
+			ts_shared->attribute("accept_untiled", scene->params.texture_accept_untiled ? 1 : 0);
+			ts_shared->attribute("max_memory_MB", scene->params.texture_cache_size > 0 ? (float)scene->params.texture_cache_size : 16384.0f);
+			oiio_globals->tex_sys = ts;
+		}
 	}
 	
 	if(scene->shaders.size() == 0)
@@ -644,7 +649,6 @@ void ShaderManager::free_memory()
 	beckmann_table.free_memory();
 }
 
-
 void ShaderManager::texture_system_init()
 {
 	/* create texture system, shared between different renders to reduce memory usage */
@@ -673,6 +677,7 @@ void ShaderManager::texture_system_free()
 	
 	if(ts_shared_users == 0) {
 		ts_shared->invalidate_all(true);
+		std::cout << ts_shared->getstats() << std::endl;
 		TextureSystem::destroy(ts_shared);
 		ts_shared = NULL;
 	}



More information about the Bf-blender-cvs mailing list