[Bf-blender-cvs] [cf1ecb86a94] cycles_texture_cache: Merge branch 'master' of git.blender.org:blender into cycles_texture_cache
Stefan Werner
noreply at git.blender.org
Tue Jun 19 13:35:40 CEST 2018
Commit: cf1ecb86a947e85958c4c77c9afb4cb87c3e23bb
Author: Stefan Werner
Date: Tue Jun 19 13:34:50 2018 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rBcf1ecb86a947e85958c4c77c9afb4cb87c3e23bb
Merge branch 'master' of git.blender.org:blender into cycles_texture_cache
===================================================================
===================================================================
diff --cc intern/cycles/graph/node_type.h
index 035c41cbc2b,15d34a79bb8..389be50aea2
--- a/intern/cycles/graph/node_type.h
+++ b/intern/cycles/graph/node_type.h
@@@ -73,14 -73,13 +73,15 @@@ struct SocketTyp
INTERNAL = (1 << 2) | (1 << 3),
LINK_TEXTURE_GENERATED = (1 << 4),
- LINK_TEXTURE_UV = (1 << 5),
- LINK_INCOMING = (1 << 6),
- LINK_NORMAL = (1 << 7),
- LINK_POSITION = (1 << 8),
- LINK_TANGENT = (1 << 9),
- LINK_TEXTURE_DX = (1 << 10),
- LINK_TEXTURE_DY = (1 << 11),
- DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11)
+ LINK_TEXTURE_NORMAL = (1 << 5),
+ LINK_TEXTURE_UV = (1 << 6),
+ LINK_INCOMING = (1 << 7),
+ LINK_NORMAL = (1 << 8),
+ LINK_POSITION = (1 << 9),
+ LINK_TANGENT = (1 << 10),
- DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)
++ LINK_TEXTURE_DX = (1 << 11),
++ LINK_TEXTURE_DY = (1 << 12),
++ DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12)
};
ustring name;
diff --cc intern/cycles/render/image.h
index b61c3578ddb,4fd09adaa64..c900b5d1f0b
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@@ -136,15 -136,10 +138,11 @@@ private
int animation_frame;
vector<Image*> images[IMAGE_DATA_NUM_TYPES];
- void *osl_texture_system;
+ void *oiio_texture_system;
+ bool pack_images;
bool file_load_image_generic(Image *img,
- ImageInput **in,
- int &width,
- int &height,
- int &depth,
- int &components);
+ ImageInput **in);
template<TypeDesc::BASETYPE FileFormat,
typename StorageType,
diff --cc intern/cycles/render/shader.cpp
index 69a58cd1cc4,46e7d1b1d7b..9b5705d0a75
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@@ -31,8 -31,10 +31,12 @@@
#include "util/util_foreach.h"
+#include "kernel/kernel_oiio_globals.h"
+#include <OpenImageIO/texture.h>
+ #ifdef WITH_OCIO
+ # include <OpenColorIO/OpenColorIO.h>
+ namespace OCIO = OCIO_NAMESPACE;
+ #endif
CCL_NAMESPACE_BEGIN
@@@ -441,28 -471,12 +479,26 @@@ void ShaderManager::device_update_commo
Scene *scene,
Progress& /*progress*/)
{
- dscene->shader_flag.free();
+ dscene->shaders.free();
-
+ if(scene->shaders.size() == 0)
+ return;
++
+ if(device->info.type == DEVICE_CPU && (scene->params.shadingsystem == SHADINGSYSTEM_OSL || scene->params.texture_cache_size > 0)) {
+ /* set texture system */
+ scene->image_manager->set_oiio_texture_system((void*)ts);
+ OIIOGlobals *oiio_globals = (OIIOGlobals*)device->oiio_memory();
+ if(oiio_globals) {
+ /* update attributes from scene parms */
+ ts->attribute("autotile", scene->params.texture_auto_tile ? scene->params.texture_tile_size : 0);
+ ts->attribute("automip", scene->params.texture_auto_mip ? 1 : 0);
+ ts->attribute("accept_unmipped", scene->params.texture_accept_unmipped ? 1 : 0);
+ ts->attribute("accept_untiled", scene->params.texture_accept_untiled ? 1 : 0);
+ ts->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)
- return;
- uint shader_flag_size = scene->shaders.size()*SHADER_SIZE;
- uint *shader_flag = dscene->shader_flag.alloc(shader_flag_size);
- uint i = 0;
+ KernelShader *kshader = dscene->shaders.alloc(scene->shaders.size());
bool has_volumes = false;
bool has_transparent_shadow = false;
@@@ -667,21 -690,10 +712,26 @@@ void ShaderManager::free_memory(
beckmann_table.free_memory();
}
+void ShaderManager::texture_system_init()
+{
+ ts = TextureSystem::create(true);
+ ts->attribute("gray_to_rgb", 1);
+}
+
+void ShaderManager::texture_system_free()
+{
+ std::cout << ts->getstats(2) << std::endl;
+ ts->reset_stats();
+ ts->invalidate_all(true);
+ ts->clear();
+ TextureSystem::destroy(ts);
+ ts = NULL;
+}
+
+ float ShaderManager::linear_rgb_to_gray(float3 c)
+ {
+ return dot(c, rgb_to_y);
+ }
+
CCL_NAMESPACE_END
diff --cc intern/cycles/render/shader.h
index 9c6773c4abc,0353da90013..4467ae60e04
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@@ -213,13 -214,10 +215,18 @@@ protected
thread_spin_lock attribute_lock_;
+ void texture_system_init();
+ void texture_system_free();
+
+ OIIO::TextureSystem *ts;
+ static OIIO::TextureSystem *ts_shared;
+ static thread_mutex ts_shared_mutex;
+ static int ts_shared_users;
++
+ float3 xyz_to_r;
+ float3 xyz_to_g;
+ float3 xyz_to_b;
+ float3 rgb_to_y;
};
CCL_NAMESPACE_END
More information about the Bf-blender-cvs
mailing list