diff options
author | Geraldine Chua <chua.gsk@gmail.com> | 2018-06-08 13:11:03 +0300 |
---|---|---|
committer | Geraldine Chua <chua.gsk@gmail.com> | 2018-06-08 13:11:03 +0300 |
commit | 22f243d379ffd1bd7101dd1955b2efe0062ed651 (patch) | |
tree | ce353b3e52add8b44da06345f802875f56594a5a /intern/cycles/kernel | |
parent | 75bff3c0137e18a00bc9318549e6c3da8b7ae5ac (diff) |
Reduce sparse grid memory usage and minor fixes.
Sparse grids originally padded out an image to dimensions divisible by
TILE_SIZE, which resulted in many empty voxels in large volumes. Now,
border tiles are taken into account when calculating voxel indexes.
Aside from that, made some other minor fixes throughout the files.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h index 93aa6117f58..7513efc6b15 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h +++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h @@ -77,16 +77,23 @@ template<typename T> struct TextureInterpolator { static ccl_always_inline float4 read(const T *data, const int *offsets, int x, int y, int z, + int width, int height, int depth, int tiw, int tih, int tid) { - int index = compute_index(offsets, x, y, z, tiw, tih, tid); + int index = compute_index(offsets, x, y, z, + width, height, depth, tiw, tih, tid); return index < 0 ? make_float4(0.0f) : read(data[index]); } static ccl_always_inline float4 read(const T *data, const int *offsets, int idx, int width, int height, int depth) { - int index = compute_index(offsets, idx, width, height, depth); + int3 c = compute_coordinates(idx, width, height, depth); + int index = compute_index(offsets, c.x, c.y, c.z, + width, height, depth, + get_tile_res(width), + get_tile_res(height), + get_tile_res(depth)); return index < 0 ? make_float4(0.0f) : read(data[index]); } @@ -300,8 +307,8 @@ template<typename T> struct TextureInterpolator { const int *ofs = (const int*)info.offsets; if(ofs) { - return read(data, ofs, ix, iy, iz, get_tile_res(width), - get_tile_res(height), get_tile_res(depth)); + return read(data, ofs, ix, iy, iz, width, height, depth, + get_tile_res(width), get_tile_res(height), get_tile_res(depth)); } return read(data[compute_index(ix, iy, iz, width, height, depth)]); } @@ -361,14 +368,14 @@ template<typename T> struct TextureInterpolator { !tile_is_active(ofs, nix, niy, niz, tiw, tih, tid)) { return make_float4(0.0f); } - r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx) * read(data, ofs, ix, iy, iz, tiw, tih, tid); - r += (1.0f - tz)*(1.0f - ty)*tx * read(data, ofs, nix, iy, iz, tiw, tih, tid); - r += (1.0f - tz)*ty*(1.0f - tx) * read(data, ofs, ix, niy, iz, tiw, tih, tid); - r += (1.0f - tz)*ty*tx * read(data, ofs, nix, niy, iz, tiw, tih, tid); - r += tz*(1.0f - ty)*(1.0f - tx) * read(data, ofs, ix, iy, niz, tiw, tih, tid); - r += tz*(1.0f - ty)*tx * read(data, ofs, nix, iy, niz, tiw, tih, tid); - r += tz*ty*(1.0f - tx) * read(data, ofs, ix, niy, niz, tiw, tih, tid); - r += tz*ty*tx * read(data, ofs, nix, niy, niz, tiw, tih, tid); + r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx) * read(data, ofs, ix, iy, iz, width, height, depth, tiw, tih, tid); + r += (1.0f - tz)*(1.0f - ty)*tx * read(data, ofs, nix, iy, iz, width, height, depth, tiw, tih, tid); + r += (1.0f - tz)*ty*(1.0f - tx) * read(data, ofs, ix, niy, iz, width, height, depth, tiw, tih, tid); + r += (1.0f - tz)*ty*tx * read(data, ofs, nix, niy, iz, width, height, depth, tiw, tih, tid); + r += tz*(1.0f - ty)*(1.0f - tx) * read(data, ofs, ix, iy, niz, width, height, depth, tiw, tih, tid); + r += tz*(1.0f - ty)*tx * read(data, ofs, nix, iy, niz, width, height, depth, tiw, tih, tid); + r += tz*ty*(1.0f - tx) * read(data, ofs, ix, niy, niz, width, height, depth, tiw, tih, tid); + r += tz*ty*tx * read(data, ofs, nix, niy, niz, width, height, depth, tiw, tih, tid); } else { r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx) * read(data[compute_index(ix, iy, iz, width, height, depth)]); |