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

Stefan Werner noreply at git.blender.org
Fri Jun 7 08:48:32 CEST 2019


Commit: 267038756bde2843941d8c1639f92ccf3fa29ec1
Author: Stefan Werner
Date:   Wed May 8 14:36:43 2019 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB267038756bde2843941d8c1639f92ccf3fa29ec1

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

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



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

diff --cc intern/cycles/blender/addon/ui.py
index c89bea2987e,0845f567056..136f79d89a1
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@@ -2167,9 -2130,6 +2164,7 @@@ classes = 
      CYCLES_RENDER_PT_performance_acceleration_structure,
      CYCLES_RENDER_PT_performance_final_render,
      CYCLES_RENDER_PT_performance_viewport,
 +    CYCLES_RENDER_PT_texture_cache,
-     CYCLES_RENDER_PT_filter,
-     CYCLES_RENDER_PT_override,
      CYCLES_RENDER_PT_passes,
      CYCLES_RENDER_PT_passes_data,
      CYCLES_RENDER_PT_passes_light,
diff --cc intern/cycles/blender/blender_python.cpp
index c35780e55a4,ffd1c70a4e4..c75906b38cf
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@@ -631,22 -631,6 +631,21 @@@ static PyObject *osl_compile_func(PyObj
  }
  #endif
  
 +static PyObject *oiio_make_tx(PyObject * /*self*/, PyObject *args)
 +{
-   const char *inputfile = NULL, *outputfile = NULL;
-   int srgb = 1;
++  const char *inputfile = NULL, *outputfile = NULL, *colorspace = NULL;
 +  int extension = EXTENSION_CLIP;
 +
-   if (!PyArg_ParseTuple(args, "sspi", &inputfile, &outputfile, &srgb, &extension))
++  if (!PyArg_ParseTuple(args, "sssi", &inputfile, &outputfile, &colorspace, &extension))
 +    return NULL;
 +
 +  /* return */
-   if (!ImageManager::make_tx(inputfile, outputfile, srgb, (ExtensionType)extension))
++  if (!ImageManager::make_tx(inputfile, outputfile, ustring(colorspace), (ExtensionType)extension))
 +    Py_RETURN_FALSE;
 +
 +  Py_RETURN_TRUE;
 +}
 +
  static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
  {
    string system_info = Device::device_capabilities();
diff --cc intern/cycles/device/device_cpu.cpp
index 2e24afa18d4,5d279ebb965..39279259d92
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@@ -166,9 -166,8 +167,9 @@@ class CPUDevice : public Device 
    bool need_texture_info;
  
  #ifdef WITH_OSL
-   OSLGlobals osl_globals;
+   OSLGlobals *osl_globals;
  #endif
 +  OIIOGlobals oiio_globals;
  
    bool use_split_kernel;
  
@@@ -284,11 -283,10 +285,13 @@@
      }
  
  #ifdef WITH_OSL
-     kernel_globals.osl = &osl_globals;
+     /* Must use aligned malloc due to concurrent hash map. */
+     osl_globals = util_aligned_new<OSLGlobals>();
+     kernel_globals.osl = osl_globals;
  #endif
 +    oiio_globals.tex_sys = NULL;
 +    kernel_globals.oiio = &oiio_globals;
 +
      use_split_kernel = DebugFlags().cpu.split_kernel;
      if (use_split_kernel) {
        VLOG(1) << "Will be using split kernel.";
@@@ -322,14 -320,11 +325,17 @@@
  
    ~CPUDevice()
    {
+ #ifdef WITH_OSL
+     util_aligned_delete(osl_globals);
+ #endif
      task_pool.stop();
      texture_info.free();
 +    if (oiio_globals.tex_sys) {
 +      VLOG(1) << oiio_globals.tex_sys->getstats();
 +      oiio_globals.tex_sys->reset_stats();
 +      TextureSystem::destroy(oiio_globals.tex_sys);
 +    }
 +    kernel_globals.oiio = NULL;
    }
  
    virtual bool show_samples() const
@@@ -997,15 -987,8 +1003,15 @@@
      KernelGlobals kg = kernel_globals;
  
  #ifdef WITH_OSL
-     OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
+     OSLShader::thread_init(&kg, &kernel_globals, osl_globals);
  #endif
 +    if (kg.oiio && kg.oiio->tex_sys) {
 +      kg.oiio_tdata = kg.oiio->tex_sys->get_perthread_info();
 +    }
 +    else {
 +      kg.oiio_tdata = NULL;
 +    }
 +
      for (int sample = 0; sample < task.num_samples; sample++) {
        for (int x = task.shader_x; x < task.shader_x + task.shader_w; x++)
          shader_kernel()(&kg,
@@@ -1076,12 -1059,8 +1082,12 @@@
      kg.decoupled_volume_steps_index = 0;
      kg.coverage_asset = kg.coverage_object = kg.coverage_material = NULL;
  #ifdef WITH_OSL
-     OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
+     OSLShader::thread_init(&kg, &kernel_globals, osl_globals);
  #endif
 +    if (kg.oiio && kg.oiio->tex_sys) {
 +      kg.oiio_tdata = kg.oiio->tex_sys->get_perthread_info();
 +    }
 +
      return kg;
    }
  
diff --cc intern/cycles/kernel/closure/bsdf_hair.h
index 817b57817a8,4b6f5b3b439..47d0cc12eed
--- a/intern/cycles/kernel/closure/bsdf_hair.h
+++ b/intern/cycles/kernel/closure/bsdf_hair.h
@@@ -224,12 -224,10 +224,12 @@@ ccl_device int bsdf_hair_reflection_sam
    fast_sincosf(phi, &sinphi, &cosphi);
    *omega_in = (cosphi * costheta_i) * locy - (sinphi * costheta_i) * locx + (sintheta_i)*Tg;
  
-   //differentials - TODO: find a better approximation for the reflective bounce
+   // differentials - TODO: find a better approximation for the reflective bounce
  #ifdef __RAY_DIFFERENTIALS__
 -  *domega_in_dx = 2 * dot(locy, dIdx) * locy - dIdx;
 -  *domega_in_dy = 2 * dot(locy, dIdy) * locy - dIdy;
 +  *domega_in_dx = 2.0f * dot(locy, dIdx) * locy - dIdx;
 +  *domega_in_dy = 2.0f * dot(locy, dIdy) * locy - dIdy;
 +  *domega_in_dx *= 10.0f;
 +  *domega_in_dy *= 10.0f;
  #endif
  
    *pdf = fabsf(phi_pdf * theta_pdf);
diff --cc intern/cycles/render/image.cpp
index 3aea2d99912,9f2a5e57d42..c6d7af010bb
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@@ -1098,81 -1062,6 +1149,87 @@@ void ImageManager::device_free(Device *
    }
  }
  
 +bool ImageManager::make_tx(const string &filename,
 +                           const string &outputfilename,
-                            bool srgb,
++                           const ustring &colorspace,
 +                           ExtensionType extension)
 +{
 +  ImageSpec config;
 +  config.attribute("maketx:filtername", "lanczos3");
 +  config.attribute("maketx:opaque_detect", 1);
 +  config.attribute("maketx:highlightcomp", 1);
 +  config.attribute("maketx:oiio_options", 1);
 +  config.attribute("maketx:updatemode", 1);
 +
 +  switch (extension) {
 +    case EXTENSION_CLIP:
 +      config.attribute("maketx:wrap", "black");
 +      break;
 +    case EXTENSION_REPEAT:
 +      config.attribute("maketx:wrap", "periodic");
 +      break;
 +    case EXTENSION_EXTEND:
 +      config.attribute("maketx:wrap", "clamp");
 +      break;
 +    default:
 +      assert(0);
 +      break;
 +  }
 +
 +  /* Convert textures to linear color space before mip mapping. */
-   if (srgb) {
-     config.attribute("maketx:incolorspace", "sRGB");
++  if (colorspace != u_colorspace_raw) {
++    if (colorspace == u_colorspace_srgb || colorspace.empty()) {
++      config.attribute("maketx:incolorspace", "sRGB");
++    }
++    else {
++      config.attribute("maketx:incolorspace", colorspace.c_str());
++    }
 +    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,
 +                          const char *cache_path)
 +{
 +  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 (cache_path) {
 +    string filename = path_filename(tx_name);
 +    tx_name = path_join(string(cache_path), filename);
 +  }
 +  if (path_exists(tx_name)) {
 +    image->filename = tx_name;
 +    return true;
 +  }
 +
 +  if (auto_convert) {
 +    progress->set_status("Updating Images", "Converting " + image->filename);
 +
-     bool ok = make_tx(image->filename, tx_name, image->srgb, image->extension);
++//    ustring colorspace = image->metadata.compress_as_srgb ? ustring("sRGB") : image->colorspace;
++    bool ok = make_tx(image->filename, tx_name, image->metadata.colorspace, image->extension);
 +    if (ok) {
 +      image->filename = tx_name;
 +      return true;
 +    }
 +  }
 +  return false;
 +}
 +
  void ImageManager::collect_statistics(RenderStats *stats)
  {
    for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
diff --cc intern/cycles/render/image.h
index 22a5b73b304,e8ed657ee10..7e61a65fae1
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@@ -137,11 -159,6 +161,11 @@@ class ImageManager 
      int users;
    };
  
 +  static bool make_tx(const string &filename,
 +                      const string &outputfilename,
-                       bool srgb,
++                      const ustring &colorspace,
 +                      ExtensionType extension);
 +
   private:
    int tex_num_images[IMAGE_DATA_NUM_TYPES];
    int max_num_images;
diff --cc intern/cycles/render/nodes.cpp
index 4b05912f946,6e86643cc2b..cc0b5091e1b
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@@ -318,30 -314,22 +318,29 @@@ void ImageTextureNode::compile(SVMCompi
      int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
  
      if (projection != NODE_IMAGE_PROJ_BOX) {
 -      compiler.add_node(NODE_TEX_IMAGE,
 -                        slot,
 -                        compiler.encode_uchar4(vector_offset,
 -                                               compiler.stack_assign_if_linked(color_out),
 -                                               compiler.stack_assign_if_linked(alpha_out),
 -                                               compress_as_srgb),
 -                        projection);
 +      compiler.add_node(
 +          NODE_TEX_IMAGE,
 +          slot,
 +          compiler.encode_uchar4(vector_offset,
 +                                 compiler.stack_assign_if_linked(color_out),
 +                                 compiler.stack_assign_if_linked(alpha_out),
-                                  srgb),
++                                 compress_as_srgb),
 +          compiler.encode_uchar4(
 +              projection, compiler.stack_assign(vector_dx), compiler.stack_assign(vector_dy), 0));
      }
      else {
 +      /* Blend is a float between 0 and 1. Convert to 16 bit unsigned int to make room for vector_dx and vector_dy. */
 +      uint blend = clamp((uint)(projection_blend * 65535.0f), 0, 0xffff);
        compiler.add_node(NODE_TEX_IMAGE_BOX,
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list