From a63208823c8426b76270393f9217d3cf3ef66d0b Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Tue, 10 Nov 2020 18:28:14 +0100 Subject: 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. --- .../cycles/kernel/kernels/cpu/kernel_cpu_image.h | 26 +++++++++++++--------- .../cycles/kernel/kernels/cuda/kernel_cuda_image.h | 10 ++++----- 2 files changed, 21 insertions(+), 15 deletions(-) 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 struct TextureInterpolator { #ifdef WITH_NANOVDB template struct NanoVDBInterpolator { - typedef nanovdb::ReadAccessor> ReadAccessorT; + typedef typename nanovdb::NanoGrid::AccessorType AccessorType; static ccl_always_inline float4 read(float r) { @@ -490,16 +490,22 @@ template 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(acc)(xyz)); + return read(nanovdb::SampleFromVoxels(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(acc)(xyz)); + return read(nanovdb::SampleFromVoxels(acc)(xyz)); } # if defined(__GNUC__) || defined(__clang__) @@ -508,7 +514,7 @@ template 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 struct NanoVDBInterpolator { using namespace nanovdb; NanoGrid *const grid = (NanoGrid *)info.data; - const NanoRoot &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> ReadAccessorT; NanoGrid *const grid = (NanoGrid *)info.data; - const NanoRoot &root = grid->tree().root(); + typedef typename nanovdb::NanoGrid::AccessorType AccessorType; + AccessorType acc = grid->getAccessor(); switch (interpolation) { case INTERPOLATION_CLOSEST: - return NearestNeighborSampler(root)(Vec3f(x, y, z)); + return SampleFromVoxels(acc)(Vec3f(x, y, z)); case INTERPOLATION_LINEAR: - return TrilinearSampler(root)(Vec3f(x - 0.5f, y - 0.5f, z - 0.5f)); + return SampleFromVoxels(acc)(Vec3f(x - 0.5f, y - 0.5f, z - 0.5f)); default: - TrilinearSampler s(root); + SampleFromVoxels s(acc); return kernel_tex_image_interp_tricubic_nanovdb(s, x - 0.5f, y - 0.5f, z - 0.5f); } } -- cgit v1.2.3