Test the full cross product of uchar for ColorMatrix
Change-Id: I331011cc84a47589dbcf6ee75fef61c31f17f5e1
diff --git a/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs b/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs
index 6a13fe1..30b40c4 100644
--- a/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs
+++ b/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs
@@ -65,7 +65,7 @@
u.x = rsGetElementAt_uchar(in, x, y);
break;
}
- pin = convert_float4(u) * (1.f / 255.f);
+ pin = rsUnpackColor8888(u);
}
pin = rsMatrixMultiply(&m, pin);
@@ -88,7 +88,7 @@
}
}
- if (dtout == RS_TYPE_FLOAT_32) {
+ if (dtout == RS_TYPE_UNSIGNED_8) {
uchar4 u = rsPackColorTo8888(pin);
switch(vsout) {
case 4:
diff --git a/tests/src/android/renderscript/cts/verify.rs b/tests/src/android/renderscript/cts/verify.rs
index d100eb4..85deb31 100644
--- a/tests/src/android/renderscript/cts/verify.rs
+++ b/tests/src/android/renderscript/cts/verify.rs
@@ -216,33 +216,42 @@
}
}
-void verify(rs_allocation in1, rs_allocation in2, int etype)
+void verify(rs_allocation in1, rs_allocation in2)
{
- switch(etype) {
- case 0:
- verify_uchar4(in1, in2);
- break;
- case 1:
- verify_uchar3(in1, in2);
- break;
- case 2:
- verify_uchar2(in1, in2);
- break;
- case 3:
- verify_uchar(in1, in2);
- break;
- case 4:
- verify_float4(in1, in2);
- break;
- case 5:
- verify_float3(in1, in2);
- break;
- case 6:
- verify_float2(in1, in2);
- break;
- case 7:
- verify_float(in1, in2);
- break;
+ rs_element e = rsAllocationGetElement(in1);
+ rs_data_type dt = rsElementGetDataType(e);
+ uint32_t vs = rsElementGetVectorSize(e);
+
+ if (dt == RS_TYPE_UNSIGNED_8) {
+ switch(vs) {
+ case 4:
+ verify_uchar4(in1, in2);
+ break;
+ case 3:
+ verify_uchar3(in1, in2);
+ break;
+ case 2:
+ verify_uchar2(in1, in2);
+ break;
+ case 1:
+ verify_uchar(in1, in2);
+ break;
+ }
+ } else {
+ switch(vs) {
+ case 4:
+ verify_float4(in1, in2);
+ break;
+ case 3:
+ verify_float3(in1, in2);
+ break;
+ case 2:
+ verify_float2(in1, in2);
+ break;
+ case 1:
+ verify_float(in1, in2);
+ break;
+ }
}
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
index 179f2eb..8e43aeb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
@@ -59,19 +59,6 @@
return e;
}
- protected int getVerifyEnum(Element.DataType dt, int vecSize) {
- if (dt == Element.DataType.FLOAT_32) {
- return 8 - vecSize;
- }
-
- // U8
- return 4 - vecSize;
- }
-
- protected int getVerifyEnum(Element e) {
- return getVerifyEnum(e.getDataType(), e.getVectorSize());
- }
-
protected void makeSource(int w, int h, Element e) {
System.gc();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
index 0c44e34..20ee2e6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
@@ -51,20 +51,52 @@
mSr.invoke_reference(mat, add, mAllocSrc, mAllocRef);
android.util.Log.e("RSI test", "test ColorMatrix U8_" + vsIn + " 1 " + w + ", " + h);
- mVerify.invoke_verify(mAllocRef, mAllocDst, getVerifyEnum(eout));
+ mVerify.invoke_verify(mAllocRef, mAllocDst);
mRS.finish();
}
- public void test_U8_4() {
+ public void test_U8_U8() {
Float4 add = new Float4();
Matrix4f mat = new Matrix4f();
+ java.util.Random r = new java.util.Random(100);
- subtest(100, 100, mat, add,
- Element.DataType.UNSIGNED_8, 4,
- Element.DataType.UNSIGNED_8, 4);
- checkError();
+ for (int t=0; t < 1; t++) {
+ float f[] = mat.getArray();
+ for (int i=0; i < f.length; i++) {
+ f[i] = 0.f;
+ }
+
+
+ switch (t) {
+ case 0:
+ mat.loadIdentity();
+ break;
+ case 1:
+ mat.set(0, 0, 1.f);
+ mat.set(0, 1, 1.f);
+ mat.set(0, 2, 1.f);
+ break;
+ case 2:
+ for (int i=0; i < f.length; i++) {
+ if (r.nextFloat() > 0.2f) {
+ f[i] = 10.f * r.nextFloat();
+ }
+ }
+
+ }
+
+ for (int i=1; i <= 4; i++) {
+ for (int j=1; j <=4; j++) {
+ subtest(100, 100, mat, add,
+ Element.DataType.UNSIGNED_8, i,
+ Element.DataType.UNSIGNED_8, j);
+ checkError();
+ }
+ }
+ }
}
+
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
index 11a70c3..7354db5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
@@ -74,7 +74,7 @@
}
android.util.Log.e("RSI test", "test convolve U8_" + vecSize + " 1 " + w + ", " + h);
- mVerify.invoke_verify(mAllocRef, mAllocDst, getVerifyEnum(e));
+ mVerify.invoke_verify(mAllocRef, mAllocDst);
si.setCoefficients(cf2);
sr.set_gCoeffs(cf2);
@@ -111,7 +111,7 @@
}
}
android.util.Log.e("RSI test", "test convolve U8_" + vecSize + " 2 " + w + ", " + h);
- mVerify.invoke_verify(mAllocRef, mAllocDst, getVerifyEnum(e));
+ mVerify.invoke_verify(mAllocRef, mAllocDst);
mRS.finish();
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
index 69ab17a..ebdf501 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
@@ -63,7 +63,7 @@
}
android.util.Log.e("RSI test", name + " " + e.getVectorSize() + " " + num + " " + w + ", " + h);
- mVerify.invoke_verify(mAllocRef, mAllocDst, getVerifyEnum(e));
+ mVerify.invoke_verify(mAllocRef, mAllocDst);
mRS.finish();
}