9#if !defined __KERNEL_METAL__
25 return (1.0f / 6.0f) * (a * (a * (-a + 3.0f) - 3.0f) + 1.0f);
29 return (1.0f / 6.0f) * (a * a * (3.0f * a - 6.0f) + 4.0f);
33 return (1.0f / 6.0f) * (a * (a * (-3.0f * a + 3.0f) + 3.0f) + 1.0f);
37 return (1.0f / 6.0f) * (a * a * a);
68 x = (x * info.width) - 0.5f;
69 y = (y * info.height) - 0.5f;
79 float x0 = (px +
cubic_h0(fx) + 0.5f) / info.width;
80 float x1 = (px +
cubic_h1(fx) + 0.5f) / info.width;
81 float y0 = (py +
cubic_h0(fy) + 0.5f) / info.height;
82 float y1 = (py +
cubic_h1(fy) + 0.5f) / info.height;
97 x = (x * info.width) - 0.5f;
98 y = (y * info.height) - 0.5f;
99 z = (
z * info.depth) - 0.5f;
116 float x0 = (px +
cubic_h0(fx) + 0.5f) / info.width;
117 float x1 = (px +
cubic_h1(fx) + 0.5f) / info.width;
118 float y0 = (py +
cubic_h0(fy) + 0.5f) / info.height;
119 float y1 = (py +
cubic_h1(fy) + 0.5f) / info.height;
120 float z0 = (pz +
cubic_h0(fz) + 0.5f) / info.depth;
121 float z1 = (pz +
cubic_h1(fz) + 0.5f) / info.depth;
134template<
typename OutT,
typename Acc>
136kernel_tex_image_interp_trilinear_nanovdb(
ccl_private Acc &acc,
float x,
float y,
float z)
139 const float tx =
frac(x - 0.5f, &ix);
140 const float ty =
frac(y - 0.5f, &iy);
141 const float tz =
frac(
z - 0.5f, &iz);
160template<
typename OutT,
typename Acc>
162kernel_tex_image_interp_tricubic_nanovdb(
ccl_private Acc &acc,
float x,
float y,
float z)
167 int nnix, nniy, nniz;
170 const float tx =
frac(x - 0.5f, &ix);
171 const float ty =
frac(y - 0.5f, &iy);
172 const float tz =
frac(
z - 0.5f, &iz);
184 const int xc[4] = {pix, ix, nix, nnix};
185 const int yc[4] = {piy, iy, niy, nniy};
186 const int zc[4] = {piz, iz, niz, nniz};
187 float u[4],
v[4],
w[4];
192# define SET_CUBIC_SPLINE_WEIGHTS(u, t) \
194 u[0] = (((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f); \
195 u[1] = ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f); \
196 u[2] = ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f); \
197 u[3] = (1.0f / 6.0f) * t * t * t; \
201# define DATA(x, y, z) (OutT(acc.getValue(nanovdb::Coord(xc[x], yc[y], zc[z]))))
202# define COL_TERM(col, row) \
203 (v[col] * (u[0] * DATA(0, col, row) + u[1] * DATA(1, col, row) + u[2] * DATA(2, col, row) + \
204 u[3] * DATA(3, col, row)))
205# define ROW_TERM(row) \
206 (w[row] * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
218# undef SET_CUBIC_SPLINE_WEIGHTS
221# if defined(__KERNEL_METAL__)
222template<
typename OutT,
typename T>
223__attribute__((noinline)) OutT kernel_tex_image_interp_nanovdb(
226template<
typename OutT,
typename T>
235 switch (interpolation) {
239 return OutT(acc.getValue(coord));
243 return kernel_tex_image_interp_trilinear_nanovdb<OutT>(acc, x, y,
z);
247 return kernel_tex_image_interp_tricubic_nanovdb<OutT>(acc, x, y,
z);
258 const int texture_type = info.data_type;
293 if (info.use_transform_3d) {
302 const int texture_type = info.data_type;
306 float f = kernel_tex_image_interp_nanovdb<float, float>(info, x, y,
z, interpolation);
310 float3 f = kernel_tex_image_interp_nanovdb<float3, packed_float3>(
311 info, x, y,
z, interpolation);
315 float f = kernel_tex_image_interp_nanovdb<float, nanovdb::FpN>(info, x, y,
z, interpolation);
319 float f = kernel_tex_image_interp_nanovdb<float, nanovdb::Fp16>(info, x, y,
z, interpolation);
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static __attribute__((constructor)) void cpu_check()
#define SET_CUBIC_SPLINE_WEIGHTS(u, t)
ccl_device float cubic_w2(float a)
ccl_device float cubic_h0(float a)
ccl_device float cubic_g0(float a)
ccl_device float cubic_w3(float a)
ccl_device float cubic_w0(float a)
CCL_NAMESPACE_BEGIN ccl_device_inline float frac(float x, ccl_private int *ix)
ccl_device float cubic_w1(float a)
ccl_device_noinline T kernel_tex_image_interp_bicubic(ccl_global const TextureInfo &info, float x, float y)
ccl_device float cubic_g1(float a)
ccl_device float cubic_h1(float a)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, int id, float3 P, InterpolationType interp)
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, float y)
ccl_device_noinline T kernel_tex_image_interp_tricubic(ccl_global const TextureInfo &info, float x, float y, float z)
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj, const float x, const float y)
CUtexObject ccl_gpu_tex_object_3D
#define ccl_device_inline
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj, const float x, const float y, const float z)
#define ccl_device_noinline
#define CCL_NAMESPACE_END
CUtexObject ccl_gpu_tex_object_2D
draw_view in_light_buf[] float
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)
ccl_device_inline int float_to_int(float f)
@ IMAGE_DATA_TYPE_NANOVDB_FP16
@ IMAGE_DATA_TYPE_USHORT4
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT3
@ IMAGE_DATA_TYPE_NANOVDB_FPN