Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_compat_cpu.h
| Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | if(interpolation == INTERPOLATION_CLOSEST) { | ||||
| if(x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) { | if(x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) { | ||||
| return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| /* Fall through. */ | /* Fall through. */ | ||||
| case EXTENSION_EXTEND: | case EXTENSION_EXTEND: | ||||
| ix = wrap_clamp(ix, width); | ix = wrap_clamp(ix, width); | ||||
| iy = wrap_clamp(iy, height); | iy = wrap_clamp(iy, height); | ||||
| break; | break; | ||||
| default: | |||||
| kernel_assert(0); | |||||
| } | } | ||||
| return read(data[ix + iy*width]); | return read(data[ix + iy*width]); | ||||
| } | } | ||||
| else if(interpolation == INTERPOLATION_LINEAR) { | else if(interpolation == INTERPOLATION_LINEAR) { | ||||
| float tx = frac(x*(float)width - 0.5f, &ix); | float tx = frac(x*(float)width - 0.5f, &ix); | ||||
| float ty = frac(y*(float)height - 0.5f, &iy); | float ty = frac(y*(float)height - 0.5f, &iy); | ||||
| switch(extension) { | switch(extension) { | ||||
| Show All 11 Lines | else if(interpolation == INTERPOLATION_LINEAR) { | ||||
| /* Fall through. */ | /* Fall through. */ | ||||
| case EXTENSION_EXTEND: | case EXTENSION_EXTEND: | ||||
| nix = wrap_clamp(ix+1, width); | nix = wrap_clamp(ix+1, width); | ||||
| niy = wrap_clamp(iy+1, height); | niy = wrap_clamp(iy+1, height); | ||||
| ix = wrap_clamp(ix, width); | ix = wrap_clamp(ix, width); | ||||
| iy = wrap_clamp(iy, height); | iy = wrap_clamp(iy, height); | ||||
| break; | break; | ||||
| default: | |||||
| kernel_assert(0); | |||||
| } | } | ||||
| float4 r = (1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width]); | float4 r = (1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width]); | ||||
| r += (1.0f - ty)*tx*read(data[nix + iy*width]); | r += (1.0f - ty)*tx*read(data[nix + iy*width]); | ||||
| r += ty*(1.0f - tx)*read(data[ix + niy*width]); | r += ty*(1.0f - tx)*read(data[ix + niy*width]); | ||||
| r += ty*tx*read(data[nix + niy*width]); | r += ty*tx*read(data[nix + niy*width]); | ||||
| return r; | return r; | ||||
| Show All 30 Lines | else { | ||||
| niy = wrap_clamp(iy+1, height); | niy = wrap_clamp(iy+1, height); | ||||
| nnix = wrap_clamp(ix+2, width); | nnix = wrap_clamp(ix+2, width); | ||||
| nniy = wrap_clamp(iy+2, height); | nniy = wrap_clamp(iy+2, height); | ||||
| ix = wrap_clamp(ix, width); | ix = wrap_clamp(ix, width); | ||||
| iy = wrap_clamp(iy, height); | iy = wrap_clamp(iy, height); | ||||
| break; | break; | ||||
| default: | |||||
| kernel_assert(0); | |||||
| } | } | ||||
| const int xc[4] = {pix, ix, nix, nnix}; | const int xc[4] = {pix, ix, nix, nnix}; | ||||
| const int yc[4] = {width * piy, | const int yc[4] = {width * piy, | ||||
| width * iy, | width * iy, | ||||
| width * niy, | width * niy, | ||||
| width * nniy}; | width * nniy}; | ||||
| float u[4], v[4]; | float u[4], v[4]; | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if(interpolation == INTERPOLATION_CLOSEST) { | ||||
| return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | return make_float4(0.0f, 0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| /* Fall through. */ | /* Fall through. */ | ||||
| case EXTENSION_EXTEND: | case EXTENSION_EXTEND: | ||||
| ix = wrap_clamp(ix, width); | ix = wrap_clamp(ix, width); | ||||
| iy = wrap_clamp(iy, height); | iy = wrap_clamp(iy, height); | ||||
| iz = wrap_clamp(iz, depth); | iz = wrap_clamp(iz, depth); | ||||
| break; | break; | ||||
| default: | |||||
| kernel_assert(0); | |||||
| } | } | ||||
| return read(data[ix + iy*width + iz*width*height]); | return read(data[ix + iy*width + iz*width*height]); | ||||
| } | } | ||||
| else if(interpolation == INTERPOLATION_LINEAR) { | else if(interpolation == INTERPOLATION_LINEAR) { | ||||
| float tx = frac(x*(float)width - 0.5f, &ix); | float tx = frac(x*(float)width - 0.5f, &ix); | ||||
| float ty = frac(y*(float)height - 0.5f, &iy); | float ty = frac(y*(float)height - 0.5f, &iy); | ||||
| float tz = frac(z*(float)depth - 0.5f, &iz); | float tz = frac(z*(float)depth - 0.5f, &iz); | ||||
| Show All 19 Lines | else if(interpolation == INTERPOLATION_LINEAR) { | ||||
| nix = wrap_clamp(ix+1, width); | nix = wrap_clamp(ix+1, width); | ||||
| niy = wrap_clamp(iy+1, height); | niy = wrap_clamp(iy+1, height); | ||||
| niz = wrap_clamp(iz+1, depth); | niz = wrap_clamp(iz+1, depth); | ||||
| ix = wrap_clamp(ix, width); | ix = wrap_clamp(ix, width); | ||||
| iy = wrap_clamp(iy, height); | iy = wrap_clamp(iy, height); | ||||
| iz = wrap_clamp(iz, depth); | iz = wrap_clamp(iz, depth); | ||||
| break; | break; | ||||
| default: | |||||
| kernel_assert(0); | |||||
| } | } | ||||
| float4 r; | float4 r; | ||||
| r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width + iz*width*height]); | r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width + iz*width*height]); | ||||
| r += (1.0f - tz)*(1.0f - ty)*tx*read(data[nix + iy*width + iz*width*height]); | r += (1.0f - tz)*(1.0f - ty)*tx*read(data[nix + iy*width + iz*width*height]); | ||||
| r += (1.0f - tz)*ty*(1.0f - tx)*read(data[ix + niy*width + iz*width*height]); | r += (1.0f - tz)*ty*(1.0f - tx)*read(data[ix + niy*width + iz*width*height]); | ||||
| r += (1.0f - tz)*ty*tx*read(data[nix + niy*width + iz*width*height]); | r += (1.0f - tz)*ty*tx*read(data[nix + niy*width + iz*width*height]); | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | else { | ||||
| nnix = wrap_clamp(ix+2, width); | nnix = wrap_clamp(ix+2, width); | ||||
| nniy = wrap_clamp(iy+2, height); | nniy = wrap_clamp(iy+2, height); | ||||
| nniz = wrap_clamp(iz+2, depth); | nniz = wrap_clamp(iz+2, depth); | ||||
| ix = wrap_clamp(ix, width); | ix = wrap_clamp(ix, width); | ||||
| iy = wrap_clamp(iy, height); | iy = wrap_clamp(iy, height); | ||||
| iz = wrap_clamp(iz, depth); | iz = wrap_clamp(iz, depth); | ||||
| break; | break; | ||||
| default: | |||||
| kernel_assert(0); | |||||
| } | } | ||||
| const int xc[4] = {pix, ix, nix, nnix}; | const int xc[4] = {pix, ix, nix, nnix}; | ||||
| const int yc[4] = {width * piy, | const int yc[4] = {width * piy, | ||||
| width * iy, | width * iy, | ||||
| width * niy, | width * niy, | ||||
| width * nniy}; | width * nniy}; | ||||
| const int zc[4] = {width * height * piz, | const int zc[4] = {width * height * piz, | ||||
| ▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines | |||||