diff options
-rw-r--r-- | tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java | 12 | ||||
-rw-r--r-- | tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs | 97 |
2 files changed, 50 insertions, 59 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java index d1dd47c6db6a..1d2cdbd27b95 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java @@ -52,13 +52,11 @@ public class ColorCube extends TestBase { for (int z = 0; z < sz; z++) { for (int y = 0; y < sy; y++) { for (int x = 0; x < sx; x++ ) { - - dat[z*sy*sx + y*sx + x] = //0xff000000 | - (((x >> 2) | (x<<3)) << 0) | - (((y >> 2) | (y<<3)) << 8) | - ((z | (z<<4)) << 16); - - + int v = 0xff000000; + v |= (0xff * x / (sx - 1)); + v |= (0xff * y / (sy - 1)) << 8; + v |= (0xff * z / (sz - 1)) << 16; + dat[z*sy*sx + y*sx + x] = v; } } } diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs index 09b3f69a9ad8..5250474988c1 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs @@ -20,78 +20,71 @@ static rs_allocation gCube; -static short4 gDims; -static short4 gFracMask; -static short4 gFracBits; -static short4 gFracShift; -static int4 gFinalShift; -static int4 gFinalAdd; +static int4 gDims; +static int4 gCoordMul; + void setCube(rs_allocation c) { gCube = c; - gDims.x = rsAllocationGetDimX(gCube) - 1; - gDims.y = rsAllocationGetDimY(gCube) - 1; - gDims.z = rsAllocationGetDimZ(gCube) - 1; + gDims.x = rsAllocationGetDimX(gCube); + gDims.y = rsAllocationGetDimY(gCube); + gDims.z = rsAllocationGetDimZ(gCube); gDims.w = 0; - gFracMask = gDims; - gFracBits = (short4)32 - clz(gFracMask); - gFracShift = (short4)8 - gFracBits; + float4 m = (float4)(1.f / 255.f) * convert_float4(gDims - 1); + gCoordMul = convert_int4(m * (float4)0x10000); rsDebug("dims", gDims); - rsDebug("gFracMask", gFracMask); - rsDebug("gFracBits", gFracBits); - - gFinalShift = gFracShift.x + gFracShift.y + gFracShift.z; - gFinalAdd = (((int4)1 << gFinalShift) - (int4)1) >> (int4)1; - - rsDebug("gFinalShift", gFinalShift); - rsDebug("gFinalAdd", gFinalAdd); - + rsDebug("gCoordMul", gCoordMul); } void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) { //rsDebug("root", in); - short4 baseCoord = convert_short4(*in); - short4 coord1 = baseCoord >> gFracShift; - short4 coord2 = min(coord1 + (short4)1, gDims); + int4 baseCoord = convert_int4(*in) * gCoordMul; + int4 coord1 = baseCoord >> (int4)16; + int4 coord2 = min(coord1 + 1, gDims - 1); - short4 weight2 = baseCoord - (coord1 << gFracShift); - short4 weight1 = ((short4)1 << gFracShift) - weight2; + int4 weight2 = baseCoord & 0xffff; + int4 weight1 = (int4)0x10000 - weight2; - ushort4 v000 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord1.z)); - ushort4 v100 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord1.z)); - ushort4 v010 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord1.z)); - ushort4 v110 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord1.z)); - ushort4 v001 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord2.z)); - ushort4 v101 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord2.z)); - ushort4 v011 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord2.z)); - ushort4 v111 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord2.z)); + uint4 v000 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord1.z)); + uint4 v100 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord1.z)); + uint4 v010 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord1.z)); + uint4 v110 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord1.z)); + uint4 v001 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord2.z)); + uint4 v101 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord2.z)); + uint4 v011 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord2.z)); + uint4 v111 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord2.z)); - uint4 yz00 = convert_uint4((v000 * weight1.x) + (v100 * weight2.x)); - uint4 yz10 = convert_uint4((v010 * weight1.x) + (v110 * weight2.x)); - uint4 yz01 = convert_uint4((v001 * weight1.x) + (v101 * weight2.x)); - uint4 yz11 = convert_uint4((v011 * weight1.x) + (v111 * weight2.x)); + uint4 yz00 = ((v000 * weight1.x) + (v100 * weight2.x)) >> (int4)8; + uint4 yz10 = ((v010 * weight1.x) + (v110 * weight2.x)) >> (int4)8; + uint4 yz01 = ((v001 * weight1.x) + (v101 * weight2.x)) >> (int4)8; + uint4 yz11 = ((v011 * weight1.x) + (v111 * weight2.x)) >> (int4)8; - uint4 z0 = (yz00 * weight1.y) + (yz10 * weight2.y); - uint4 z1 = (yz01 * weight1.y) + (yz11 * weight2.y); + uint4 z0 = (yz00 * weight1.y) + (yz10 * weight2.y) >> (int4)16; + uint4 z1 = (yz01 * weight1.y) + (yz11 * weight2.y) >> (int4)16; - uint4 v = (z0 * weight1.z) + (z1 * weight2.z); + uint4 v = (z0 * weight1.z) + (z1 * weight2.z) >> (int4)16; + uint4 v2 = (v + 0x7f) >> (int4)8; + + *out = convert_uchar4(v2); + out->a = 0xff; #if 0 - if (x + y < 100) { - rsDebug("coord1", coord1); - rsDebug("coord2", coord2); - rsDebug("weight1", weight1); - rsDebug("weight2", weight2); - rsDebug("yz00", yz00); - rsDebug("z0", z0); - rsDebug("v", v); + if (in->r != out->r) { + rsDebug("dr", in->r - out->r); + //rsDebug("in", convert_int4(*in)); + //rsDebug("coord1", coord1); + //rsDebug("coord2", coord2); + //rsDebug("weight1", weight1); + //rsDebug("weight2", weight2); + //rsDebug("yz00", yz00); + //rsDebug("z0", z0); + //rsDebug("v", v); + //rsDebug("v2", v2); + //rsDebug("out", convert_int4(*out)); } #endif - - *out = convert_uchar4((v + gFinalAdd) >> gFinalShift); - out->a = 0xff; } |