[Bf-blender-cvs] [295944b49e4] cycles_texture_cache: Merge branch 'master' of git.blender.org:blender into cycles_texture_cache

Stefan Werner noreply at git.blender.org
Fri Aug 3 06:02:33 CEST 2018


Commit: 295944b49e45e009bd11d36af9b7d670c068ec36
Author: Stefan Werner
Date:   Fri Aug 3 06:02:30 2018 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB295944b49e45e009bd11d36af9b7d670c068ec36

Merge branch 'master' of git.blender.org:blender into cycles_texture_cache

# Conflicts:
#	intern/cycles/render/image.cpp
#	intern/cycles/render/nodes.cpp
#	intern/cycles/render/osl.cpp

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



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

diff --cc intern/cycles/blender/addon/properties.py
index 5c92b9dc9ca,c97d942af9d..62ca4da683f
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@@ -654,65 -655,8 +655,65 @@@ class CyclesRenderSettings(bpy.types.Pr
              default='OFF',
              description="Limit texture size used by final rendering",
              items=enum_texture_limit
-             )
+         )
  
 +        cls.texture_cache_size = IntProperty(
 +            name="Texture Cache Size (MB)",
 +            default=0,
 +            description="The size of the OpenImageIO texture cache in MB. A value of 0 turns off texture caching. Typical values are in the range of 100s of MB",
 +            min=0
 +        )
 +
 +        cls.texture_auto_convert = BoolProperty(
 +            name="Auto Convert Textures",
 +            default=True,
 +            description="Automatically convert textures to .tx files for optimal texture cache performance"
 +        )
 +
 +        cls.texture_accept_unmipped = BoolProperty(
 +            name="Accept Unmipped",
 +            default=True,
 +            description="Texture cached rendering without mip mapping is very expensive. Uncheck to prevent Cycles from using textures that are not mip mapped"
 +        )
 +
 +        cls.texture_accept_untiled = BoolProperty(
 +            name="Accept Untiled",
 +            default=True,
 +            description="Texture cached rendering without tiled textures is very expensive. Uncheck to prevent Cycles from using textures that are not tiled"
 +        )
 +
 +        cls.texture_auto_tile = BoolProperty(
 +            name="Auto Tile",
 +            default=True,
 +            description="On the fly creation of tiled versions of textures that are not tiled. This can increase render time but helps reduce memory usage"
 +        )
 +
 +        cls.texture_auto_mip = BoolProperty(
 +            name="Auto Mip",
 +            default=True,
 +            description="On the fly creation of mip maps of textures that are not mip mapped. This can increase render time but helps reduce memory usage"
 +        )
 + 
 +        cls.texture_tile_size = IntProperty(
 +            name="Tile Size",
 +            default=64,
 +            description="The size of tiles that Cycles uses for auto tiling"
 +        )
 +
 +        cls.texture_blur_diffuse = FloatProperty(
 +            name="Diffuse Blur",
 +            default=0.0156,
 +            description="The amount of texture blur applied to diffuse bounces",
 +            min = 0.0, max = 1.0
 +        )
 +
 +        cls.texture_blur_glossy = FloatProperty(
 +            name="Glossy Blur",
 +            default=0.0,
 +            description="The amount of texture blur applied to diffuse bounces",
 +            min = 0.0, max = 1.0
 +        )
 +
          cls.ao_bounces = IntProperty(
              name="AO Bounces",
              default=0,
diff --cc intern/cycles/device/device.h
index dfc9d366738,2400788c833..753368bbac7
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@@ -293,11 -293,8 +293,11 @@@ public
  
  	/* open shading language, only for CPU device */
  	virtual void *osl_memory() { return NULL; }
 +	
 +	/* open image io, only for CPU device */
 +	virtual void *oiio_memory() { return NULL; }
  
- 	/* load/compile kernels, must be called before adding tasks */ 
+ 	/* load/compile kernels, must be called before adding tasks */
  	virtual bool load_kernels(
  	        const DeviceRequestedFeatures& /*requested_features*/)
  	{ return true; }
diff --cc intern/cycles/kernel/closure/bsdf_phong_ramp.h
index 8c8d4fdffef,91c7803346d..8b550397826
--- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
@@@ -104,12 -104,10 +104,12 @@@ ccl_device int bsdf_phong_ramp_sample(c
  		float3 R = (2 * cosNO) * bsdf->N - I;
  
  #ifdef __RAY_DIFFERENTIALS__
 -		*domega_in_dx = (2 * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
 -		*domega_in_dy = (2 * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
 +		*domega_in_dx = (2.0f * dot(bsdf->N, dIdx)) * bsdf->N - dIdx;
 +		*domega_in_dy = (2.0f * dot(bsdf->N, dIdy)) * bsdf->N - dIdy;
 +		*domega_in_dx *= 10.0f;
 +		*domega_in_dy *= 10.0f;
  #endif
- 		
+ 
  		float3 T, B;
  		make_orthonormals (R, &T, &B);
  		float phi = M_2PI_F * randu;
diff --cc intern/cycles/kernel/closure/bsdf_util.h
index dacc406cdab,b080e025d16..f87b3667431
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@@ -65,16 -62,16 +65,16 @@@ ccl_device float fresnel_dielectric
  		Nn   = -N;
  		*is_inside = true;
  	}
- 	
+ 
  	// compute reflection
 -	*R = (2 * cos)* Nn - I;
 +	*R = (2.0f * cos)* Nn - I;
  #ifdef __RAY_DIFFERENTIALS__
 -	*dRdx = (2 * dot(Nn, dIdx)) * Nn - dIdx;
 -	*dRdy = (2 * dot(Nn, dIdy)) * Nn - dIdy;
 +	*dRdx = (2.0f * dot(Nn, dIdx)) * Nn - dIdx;
 +	*dRdy = (2.0f * dot(Nn, dIdy)) * Nn - dIdy;
  #endif
- 	
+ 
  	float arg = 1 -(neta * neta *(1 -(cos * cos)));
 -	if(arg < 0) {
 +	if(arg < 0.0f) {
  		*T = make_float3(0.0f, 0.0f, 0.0f);
  #ifdef __RAY_DIFFERENTIALS__
  		*dTdx = make_float3(0.0f, 0.0f, 0.0f);
diff --cc intern/cycles/render/image.cpp
index b5450d19936,e6ef19cc3be..e951d0266ea
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@@ -28,21 -29,60 +29,63 @@@
  #include <OSL/oslexec.h>
  #endif
  
 +#include "kernel/kernel_oiio_globals.h"
 +#include <OpenImageIO/imagebufalgo.h>
 +
  CCL_NAMESPACE_BEGIN
  
+ namespace {
+ 
  /* Some helpers to silence warning in templated function. */
- static bool isfinite(uchar /*value*/)
+ bool isfinite(uchar /*value*/)
  {
- 	return false;
+ 	return true;
  }
- static bool isfinite(half /*value*/)
+ bool isfinite(half /*value*/)
  {
- 	return false;
+ 	return true;
+ }
+ bool isfinite(uint16_t  /*value*/)
+ {
+ 	return true;
+ }
+ 
+ /* 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 verse.
+  */
+ int type_index_to_flattened_slot(int slot, ImageDataType type)
+ {
+ 	return (slot << IMAGE_DATA_TYPE_SHIFT) | (type);
+ }
+ 
+ int flattened_slot_to_type_index(int flat_slot, ImageDataType *type)
+ {
+ 	*type = (ImageDataType)(flat_slot & IMAGE_DATA_TYPE_MASK);
+ 	return flat_slot >> IMAGE_DATA_TYPE_SHIFT;
+ }
+ 
+ const char* name_from_type(ImageDataType type)
+ {
+ 	switch(type) {
+ 		case IMAGE_DATA_TYPE_FLOAT4: return "float4";
+ 		case IMAGE_DATA_TYPE_BYTE4: return "byte4";
+ 		case IMAGE_DATA_TYPE_HALF4: return "half4";
+ 		case IMAGE_DATA_TYPE_FLOAT: return "float";
+ 		case IMAGE_DATA_TYPE_BYTE: return "byte";
+ 		case IMAGE_DATA_TYPE_HALF: return "half";
+ 		case IMAGE_DATA_TYPE_USHORT4: return "ushort4";
+ 		case IMAGE_DATA_TYPE_USHORT: return "ushort";
+ 		case IMAGE_DATA_NUM_TYPES:
+ 			assert(!"System enumerator type, should never be used");
+ 			return "";
+ 	}
+ 	assert(!"Unhandled image data type");
+ 	return "";
  }
  
+ }  // namespace
+ 
  ImageManager::ImageManager(const DeviceInfo& info)
  {
  	need_update = true;
@@@ -227,68 -275,6 +284,28 @@@ bool ImageManager::get_image_metadata(c
  	return true;
  }
  
 +const string ImageManager::get_mip_map_path(const string& filename)
 +{
 +	if(!path_exists(filename)) {
 +		return "";
 +	}
 +	
 +	string::size_type idx = filename.rfind('.');
 +	if(idx != string::npos) {
 +		std::string extension = filename.substr(idx+1);
 +		if(extension == "tx") {
 +			return filename;
 +		}
 +	}
 +	
 +	string tx_name = filename.substr(0, idx) + ".tx";
 +	if(path_exists(tx_name)) {
 +		return tx_name;
 +	}
 +
 +	return "";
 +}
 +
- 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 verse.
-  */
- int ImageManager::type_index_to_flattened_slot(int slot, ImageDataType type)
- {
- 	return (slot << IMAGE_DATA_TYPE_SHIFT) | (type);
- }
- 
- int ImageManager::flattened_slot_to_type_index(int flat_slot, ImageDataType *type)
- {
- 	*type = (ImageDataType)(flat_slot & IMAGE_DATA_TYPE_MASK);
- 	return flat_slot >> IMAGE_DATA_TYPE_SHIFT;
- }
- 
- string ImageManager::name_from_type(int type)
- {
- 	if(type == IMAGE_DATA_TYPE_FLOAT4)
- 		return "float4";
- 	else if(type == IMAGE_DATA_TYPE_FLOAT)
- 		return "float";
- 	else if(type == IMAGE_DATA_TYPE_BYTE)
- 		return "byte";
- 	else if(type == IMAGE_DATA_TYPE_HALF4)
- 		return "half4";
- 	else if(type == IMAGE_DATA_TYPE_HALF)
- 		return "half";
- 	else
- 		return "byte4";
- }
- 
  static bool image_equals(ImageManager::Image *image,
                           const string& filename,
                           void *builtin_data,
@@@ -1055,55 -1043,15 +1127,65 @@@ void ImageManager::device_free(Device *
  	}
  }
  
 +bool ImageManager::make_tx(const string &filename, const string &outputfilename, bool srgb)
 +{
 +	ImageSpec config;
 +	config.attribute("maketx:filtername", "lanczos3");
 +	config.attribute("maketx:opaque_detect", 1);
 +	config.attribute("maketx:highlightcomp", 1);
 +	config.attribute("maketx:updatemode", 1);
 +	config.attribute("maketx:oiio_options", 1);
 +	config.attribute("maketx:updatemode", 1);
 +	/* Convert textures to linear color space before mip mapping. */
 +	if(srgb) {
 +		config.attribute("maketx:incolorspace", "sRGB");
 +		config.attribute("maketx:outcolorspace", "linear");
 +	}
 +
 +	return ImageBufAlgo::make_texture(ImageBufAlgo::MakeTxTexture, filename, outputfilename, config);
 +}
 +
 +bool ImageManager::get_tx(Image *image, Progress *progress, bool auto_convert)
 +{
 +	if(!path_exists(image->filename)) {
 +		return false;
 +	}
 +	
 +	string::size_type idx = image->filename.rfind('.');
 +	if(idx != string::npos) {
 +		std::string extension = image->filename.substr(idx+1);
 +		if(extension == "tx") {
 +			return true;
 +		}
 +	}
 +	
 +	string tx_name = image->filename.substr(0, idx) + ".tx";
 +	if(path_exis

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list