Commit: a63208823c8426b76270393f9217d3cf3ef66d0b
Author: Patrick Mours
Date:   Tue Nov 10 18:28:14 2020 +0100
Branches: master
https://developer.blender.org/rBa63208823c8426b76270393f9217d3cf3ef66d0b

Fix NanoVDB compile errors with recent NanoVDB versions

There were some changes to the NanoVDB API that broke the way Cycles was 
previously using it.
With these changes it compiles successfully again and also still compiles with 
the NanoVDB revision
that is currently part of the Blender dependencies. Ref T81454.

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

M       intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
M       intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h

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

diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h 
b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
index aaf58cbd0ab..44c658d4cab 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
+++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
@@ -478,7 +478,7 @@ template<typename T> struct TextureInterpolator {
 #ifdef WITH_NANOVDB
 template<typename T> struct NanoVDBInterpolator {
 
-  typedef nanovdb::ReadAccessor<nanovdb::NanoRoot<T>> ReadAccessorT;
+  typedef typename nanovdb::NanoGrid<T>::AccessorType AccessorType;
 
   static ccl_always_inline float4 read(float r)
   {
@@ -490,16 +490,22 @@ template<typename T> struct NanoVDBInterpolator {
     return make_float4(r[0], r[1], r[2], 1.0f);
   }
 
-  static ccl_always_inline float4 interp_3d_closest(ReadAccessorT acc, float 
x, float y, float z)
+  static ccl_always_inline float4 interp_3d_closest(const AccessorType &acc,
+                                                    float x,
+                                                    float y,
+                                                    float z)
   {
     const nanovdb::Vec3f xyz(x, y, z);
-    return read(nanovdb::NearestNeighborSampler<ReadAccessorT, 
false>(acc)(xyz));
+    return read(nanovdb::SampleFromVoxels<AccessorType, 0, false>(acc)(xyz));
   }
 
-  static ccl_always_inline float4 interp_3d_linear(ReadAccessorT acc, float x, 
float y, float z)
+  static ccl_always_inline float4 interp_3d_linear(const AccessorType &acc,
+                                                   float x,
+                                                   float y,
+                                                   float z)
   {
     const nanovdb::Vec3f xyz(x - 0.5f, y - 0.5f, z - 0.5f);
-    return read(nanovdb::TrilinearSampler<ReadAccessorT, false>(acc)(xyz));
+    return read(nanovdb::SampleFromVoxels<AccessorType, 1, false>(acc)(xyz));
   }
 
 #  if defined(__GNUC__) || defined(__clang__)
@@ -508,7 +514,7 @@ template<typename T> struct NanoVDBInterpolator {
   static ccl_never_inline
 #  endif
       float4
-      interp_3d_cubic(ReadAccessorT acc, float x, float y, float z)
+      interp_3d_cubic(const AccessorType &acc, float x, float y, float z)
   {
     int ix, iy, iz;
     int nix, niy, niz;
@@ -561,15 +567,15 @@ template<typename T> struct NanoVDBInterpolator {
     using namespace nanovdb;
 
     NanoGrid<T> *const grid = (NanoGrid<T> *)info.data;
-    const NanoRoot<T> &root = grid->tree().root();
+    AccessorType acc = grid->getAccessor();
 
     switch ((interp == INTERPOLATION_NONE) ? info.interpolation : interp) {
       case INTERPOLATION_CLOSEST:
-        return interp_3d_closest(root, x, y, z);
+        return interp_3d_closest(acc, x, y, z);
       case INTERPOLATION_LINEAR:
-        return interp_3d_linear(root, x, y, z);
+        return interp_3d_linear(acc, x, y, z);
       default:
-        return interp_3d_cubic(root, x, y, z);
+        return interp_3d_cubic(acc, x, y, z);
     }
   }
 };
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h 
b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
index b8aaacba960..001bc652810 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
@@ -159,18 +159,18 @@ ccl_device_inline T kernel_tex_image_interp_nanovdb(
     const TextureInfo &info, float x, float y, float z, uint interpolation)
 {
   using namespace nanovdb;
-  typedef ReadAccessor<NanoRoot<T>> ReadAccessorT;
 
   NanoGrid<T> *const grid = (NanoGrid<T> *)info.data;
-  const NanoRoot<T> &root = grid->tree().root();
+  typedef typename nanovdb::NanoGrid<T>::AccessorType AccessorType;
+  AccessorType acc = grid->getAccessor();
 
   switch (interpolation) {
     case INTERPOLATION_CLOSEST:
-      return NearestNeighborSampler<ReadAccessorT, false>(root)(Vec3f(x, y, 
z));
+      return SampleFromVoxels<AccessorType, 0, false>(acc)(Vec3f(x, y, z));
     case INTERPOLATION_LINEAR:
-      return TrilinearSampler<ReadAccessorT, false>(root)(Vec3f(x - 0.5f, y - 
0.5f, z - 0.5f));
+      return SampleFromVoxels<AccessorType, 1, false>(acc)(Vec3f(x - 0.5f, y - 
0.5f, z - 0.5f));
     default:
-      TrilinearSampler<ReadAccessorT, false> s(root);
+      SampleFromVoxels<AccessorType, 1, false> s(acc);
       return kernel_tex_image_interp_tricubic_nanovdb<T>(s, x - 0.5f, y - 
0.5f, z - 0.5f);
   }
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to