[Bf-blender-cvs] [7111a40b4fe] cycles_texture_cache: Merge branch 'master' into cycles_texture_cache
Stefan Werner
noreply at git.blender.org
Mon Jan 4 13:36:27 CET 2021
Commit: 7111a40b4fe6a385a02f3c6b5fe8575ba5b929f9
Author: Stefan Werner
Date: Wed Jul 22 08:11:07 2020 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB7111a40b4fe6a385a02f3c6b5fe8575ba5b929f9
Merge branch 'master' into cycles_texture_cache
===================================================================
===================================================================
diff --cc intern/cycles/blender/blender_sync.cpp
index 352c9b0af1b,d509f2fc786..bf2796bedd9
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@@ -751,41 -767,8 +767,29 @@@ SceneParams BlenderSync::get_scene_para
params.texture_limit = 0;
}
- /* TODO(sergey): Once OSL supports per-microarchitecture optimization get
- * rid of this.
- */
- if (params.shadingsystem == SHADINGSYSTEM_OSL) {
- params.bvh_layout = BVH_LAYOUT_BVH4;
- }
- else {
- params.bvh_layout = DebugFlags().cpu.bvh_layout;
- }
- #ifdef WITH_EMBREE
- params.bvh_layout = RNA_boolean_get(&cscene, "use_bvh_embree") ? BVH_LAYOUT_EMBREE :
- params.bvh_layout;
- #endif
+ params.bvh_layout = DebugFlags().cpu.bvh_layout;
+ params.texture.use_cache = RNA_boolean_get(&cscene, "use_texture_cache");
+ params.texture.cache_size = RNA_int_get(&cscene, "texture_cache_size");
+ 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_boolean_get(&cscene, "texture_auto_mip");
+ params.texture.auto_tile = RNA_boolean_get(&cscene, "texture_auto_tile");
+ params.texture.diffuse_blur = RNA_float_get(&cscene, "texture_blur_diffuse");
+ params.texture.glossy_blur = RNA_float_get(&cscene, "texture_blur_glossy");
+ params.texture.use_custom_cache_path = RNA_boolean_get(&cscene, "use_custom_cache_path");
+ if (params.texture.use_custom_cache_path) {
+ char *path = RNA_string_get_alloc(&cscene, "custom_cache_path", NULL, 0);
+ if (path) {
+ params.texture.custom_cache_path = path;
+ MEM_freeN(path);
+ }
+ }
+ else {
+ params.texture.custom_cache_path.clear();
+ }
params.background = background;
return params;
diff --cc intern/cycles/device/device_cpu.cpp
index 009d6861d32,ee3a3ddea64..ebeb952e619
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@@ -177,7 -178,11 +179,14 @@@ class CPUDevice : public Device
#ifdef WITH_OSL
OSLGlobals osl_globals;
#endif
++
+ OIIOGlobals oiio_globals;
++
+ #ifdef WITH_OPENIMAGEDENOISE
+ oidn::DeviceRef oidn_device;
+ oidn::FilterRef oidn_filter;
+ #endif
+ thread_spin_lock oidn_task_lock;
bool use_split_kernel;
@@@ -337,14 -339,8 +346,14 @@@
~CPUDevice()
{
- task_pool.stop();
+ task_pool.cancel();
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
@@@ -538,31 -523,18 +536,23 @@@
#endif
}
+ void *oiio_memory()
+ {
+ return &oiio_globals;
+ }
+
- void thread_run(DeviceTask *task)
+ void thread_run(DeviceTask &task)
{
- if (task->type == DeviceTask::RENDER)
- thread_render(*task);
- else if (task->type == DeviceTask::SHADER)
- thread_shader(*task);
- else if (task->type == DeviceTask::FILM_CONVERT)
- thread_film_convert(*task);
- else if (task->type == DeviceTask::DENOISE_BUFFER)
- thread_denoise(*task);
+ if (task.type == DeviceTask::RENDER)
+ thread_render(task);
+ else if (task.type == DeviceTask::SHADER)
+ thread_shader(task);
+ else if (task.type == DeviceTask::FILM_CONVERT)
+ thread_film_convert(task);
+ else if (task.type == DeviceTask::DENOISE_BUFFER)
+ thread_denoise(task);
}
- class CPUDeviceTask : public DeviceTask {
- public:
- CPUDeviceTask(CPUDevice *device, DeviceTask &task) : DeviceTask(task)
- {
- run = function_bind(&CPUDevice::thread_run, device, this);
- }
- };
-
bool denoising_non_local_means(device_ptr image_ptr,
device_ptr guide_ptr,
device_ptr variance_ptr,
diff --cc intern/cycles/kernel/geom/geom_curve_intersect.h
index ba514865307,06d2c016f5b..2f0e7a98351
--- a/intern/cycles/kernel/geom/geom_curve_intersect.h
+++ b/intern/cycles/kernel/geom/geom_curve_intersect.h
@@@ -853,13 -773,9 +773,13 @@@ ccl_device_inline void curve_shader_set
# ifdef __DPDU__
/* dPdu/dPdv */
- sd->dPdu = tg;
- sd->dPdv = cross(tg, sd->Ng);
+ sd->dPdu = dPdu;
+ sd->dPdv = cross(dPdu, sd->Ng);
# endif
+# ifdef __DNDU__
+ sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
+ sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
+# endif
if (isect->object != OBJECT_NONE) {
# ifdef __OBJECT_MOTION__
diff --cc intern/cycles/kernel/kernel_shader.h
index a32e8cfc835,e461e1642b6..856931210f3
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@@ -213,16 -176,9 +204,14 @@@ ccl_device_inlin
sd->prim = kernel_tex_fetch(__prim_index, isect->prim);
sd->type = isect->type;
- # ifdef __UV__
sd->u = isect->u;
sd->v = isect->v;
- # endif
+# ifdef __DNDU__
+ sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
+ sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
+# endif
+
/* fetch triangle data */
if (sd->type == PRIMITIVE_TRIANGLE) {
float3 Ng = triangle_normal(kg, sd);
@@@ -262,16 -208,11 +250,15 @@@
/* instance transform */
object_normal_transform_auto(kg, sd, &sd->N);
object_normal_transform_auto(kg, sd, &sd->Ng);
- # ifdef __DPDU__
+ # ifdef __DPDU__
object_dir_transform_auto(kg, sd, &sd->dPdu);
object_dir_transform_auto(kg, sd, &sd->dPdv);
-# endif
+# endif
+# ifdef __DNDU__
+ object_dir_transform(kg, sd, &sd->dNdx);
+ object_dir_transform(kg, sd, &sd->dNdy);
+# endif
}
- # endif
/* backfacing test */
if (backfacing) {
@@@ -397,30 -326,6 +377,29 @@@ ccl_device_inline void shader_setup_fro
object_dir_transform_auto(kg, sd, &sd->dPdu);
object_dir_transform_auto(kg, sd, &sd->dPdv);
}
- # endif
+#endif
+#ifdef __DNDU__
+
+ float3 dNdu, dNdv;
+ triangle_dNdudv(kg, sd->prim, &dNdu, &dNdv);
+ sd->dNdx = dNdu * sd->du.dx + dNdv * sd->dv.dx;
+ sd->dNdy = dNdu * sd->du.dy + dNdv * sd->dv.dy;
+
+# ifdef __INSTANCING__
+ if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
+ object_normal_transform_auto(kg, sd, &sd->dNdx);
+ object_normal_transform_auto(kg, sd, &sd->dNdy);
+ }
+# endif
+#endif
+ }
+ else if (sd->type & PRIMITIVE_LAMP) {
+#ifdef __DPDU__
+ lamp_light_dPdudv(kg, lamp, sd->u, sd->v, &sd->dPdu, &sd->dPdv);
+#endif
+#ifdef __DNDU__
+ sd->dNdx = make_float3(0.0f, 0.0f, 0.0f);
+ sd->dNdy = make_float3(0.0f, 0.0f, 0.0f);
#endif
}
else {
diff --cc intern/cycles/render/scene.h
index 329ca4aeede,67616262c03..04bf77baf2f
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@@ -212,9 -168,10 +212,11 @@@ class SceneParams
bool use_bvh_spatial_split;
bool use_bvh_unaligned_nodes;
int num_bvh_time_steps;
+ int hair_subdivisions;
+ CurveShapeType hair_shape;
bool persistent_data;
int texture_limit;
+ TextureCacheParams texture;
bool background;
@@@ -238,8 -197,14 +242,15 @@@
use_bvh_spatial_split == params.use_bvh_spatial_split &&
use_bvh_unaligned_nodes == params.use_bvh_unaligned_nodes &&
num_bvh_time_steps == params.num_bvh_time_steps &&
- persistent_data == params.persistent_data && texture_limit == params.texture_limit) ||
- texture.modified(params.texture);
+ hair_subdivisions == params.hair_subdivisions && hair_shape == params.hair_shape &&
- persistent_data == params.persistent_data && texture_limit == params.texture_limit);
++ persistent_data == params.persistent_data && texture_limit == params.texture_limit &&
++ texture.modified(params.texture));
+ }
+
+ int curve_subdivisions()
+ {
+ /* Matching the tesselation rate limit in Embree. */
+ return clamp(1 << hair_subdivisions, 1, 16);
}
};
diff --cc intern/cycles/render/shader.cpp
index 47d02d7962e,1120d909e98..f2d14d92d4f
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@@ -33,9 -33,8 +33,10 @@@
#include "util/util_foreach.h"
#include "util/util_murmurhash.h"
+ #include "util/util_task.h"
+#include "kernel/kernel_oiio_globals.h"
+#include <OpenImageIO/texture.h>
#ifdef WITH_OCIO
# include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE;
More information about the Bf-blender-cvs
mailing list