summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt36
-rwxr-xr-xcore/java/android/util/PropertyValueModel.java143
-rwxr-xr-xcore/java/android/util/ValueModel.java74
-rw-r--r--core/java/android/widget/CheckBox.java23
-rw-r--r--core/java/android/widget/EditText.java23
-rw-r--r--core/java/android/widget/SeekBar.java20
-rwxr-xr-xcore/java/android/widget/ValueEditor.java53
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java73
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java6
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs92
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java495
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs401
12 files changed, 1407 insertions, 32 deletions
diff --git a/api/current.txt b/api/current.txt
index 29e468b39307..fc067747b6c4 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22826,6 +22826,17 @@ package android.util {
method public void set(T, V);
}
+ public class PropertyValueModel extends android.util.ValueModel {
+ method public T get();
+ method public H getHost();
+ method public android.util.Property<H, T> getProperty();
+ method public java.lang.Class<T> getType();
+ method public static android.util.PropertyValueModel<H, T> of(H, android.util.Property<H, T>);
+ method public static android.util.PropertyValueModel<H, T> of(H, java.lang.Class<T>, java.lang.String);
+ method public static android.util.PropertyValueModel of(java.lang.Object, java.lang.String);
+ method public void set(T);
+ }
+
public class SparseArray implements java.lang.Cloneable {
ctor public SparseArray();
ctor public SparseArray(int);
@@ -22974,6 +22985,14 @@ package android.util {
field public int type;
}
+ public abstract class ValueModel {
+ ctor protected ValueModel();
+ method public abstract T get();
+ method public abstract java.lang.Class<T> getType();
+ method public abstract void set(T);
+ field public static final android.util.ValueModel EMPTY;
+ }
+
public class Xml {
method public static android.util.AttributeSet asAttributeSet(org.xmlpull.v1.XmlPullParser);
method public static android.util.Xml.Encoding findEncodingByName(java.lang.String) throws java.io.UnsupportedEncodingException;
@@ -27395,10 +27414,12 @@ package android.widget {
method public abstract void onSelectedDayChange(android.widget.CalendarView, int, int, int);
}
- public class CheckBox extends android.widget.CompoundButton {
+ public class CheckBox extends android.widget.CompoundButton implements android.widget.ValueEditor {
ctor public CheckBox(android.content.Context);
ctor public CheckBox(android.content.Context, android.util.AttributeSet);
ctor public CheckBox(android.content.Context, android.util.AttributeSet, int);
+ method public android.util.ValueModel<java.lang.Boolean> getValueModel();
+ method public void setValueModel(android.util.ValueModel<java.lang.Boolean>);
}
public abstract interface Checkable {
@@ -27571,14 +27592,16 @@ package android.widget {
method public void setSize(int, int);
}
- public class EditText extends android.widget.TextView {
+ public class EditText extends android.widget.TextView implements android.widget.ValueEditor {
ctor public EditText(android.content.Context);
ctor public EditText(android.content.Context, android.util.AttributeSet);
ctor public EditText(android.content.Context, android.util.AttributeSet, int);
method public void extendSelection(int);
+ method public android.util.ValueModel<java.lang.CharSequence> getValueModel();
method public void selectAll();
method public void setSelection(int, int);
method public void setSelection(int);
+ method public void setValueModel(android.util.ValueModel<java.lang.CharSequence>);
}
public abstract interface ExpandableListAdapter {
@@ -28595,11 +28618,13 @@ package android.widget {
method public abstract java.lang.Object[] getSections();
}
- public class SeekBar extends android.widget.AbsSeekBar {
+ public class SeekBar extends android.widget.AbsSeekBar implements android.widget.ValueEditor {
ctor public SeekBar(android.content.Context);
ctor public SeekBar(android.content.Context, android.util.AttributeSet);
ctor public SeekBar(android.content.Context, android.util.AttributeSet, int);
+ method public android.util.ValueModel<java.lang.Integer> getValueModel();
method public void setOnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener);
+ method public void setValueModel(android.util.ValueModel<java.lang.Integer>);
}
public static abstract interface SeekBar.OnSeekBarChangeListener {
@@ -29171,6 +29196,11 @@ package android.widget {
method public android.widget.TextView getText2();
}
+ public abstract interface ValueEditor {
+ method public abstract android.util.ValueModel<T> getValueModel();
+ method public abstract void setValueModel(android.util.ValueModel<T>);
+ }
+
public class VideoView extends android.view.SurfaceView implements android.widget.MediaController.MediaPlayerControl {
ctor public VideoView(android.content.Context);
ctor public VideoView(android.content.Context, android.util.AttributeSet);
diff --git a/core/java/android/util/PropertyValueModel.java b/core/java/android/util/PropertyValueModel.java
new file mode 100755
index 000000000000..eb9c47d0c379
--- /dev/null
+++ b/core/java/android/util/PropertyValueModel.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+/**
+ * A value model for a {@link Property property} of a host object. This class can be used for
+ * both reflective and non-reflective property implementations.
+ *
+ * @param <H> the host type, where the host is the object that holds this property
+ * @param <T> the value type
+ *
+ * @see Property
+ * @see ValueModel
+ */
+public class PropertyValueModel<H, T> extends ValueModel<T> {
+ private final H mHost;
+ private final Property<H, T> mProperty;
+
+ private PropertyValueModel(H host, Property<H, T> property) {
+ mProperty = property;
+ mHost = host;
+ }
+
+ /**
+ * Returns the host.
+ *
+ * @return the host
+ */
+ public H getHost() {
+ return mHost;
+ }
+
+ /**
+ * Returns the property.
+ *
+ * @return the property
+ */
+ public Property<H, T> getProperty() {
+ return mProperty;
+ }
+
+ @Override
+ public Class<T> getType() {
+ return mProperty.getType();
+ }
+
+ @Override
+ public T get() {
+ return mProperty.get(mHost);
+ }
+
+ @Override
+ public void set(T value) {
+ mProperty.set(mHost, value);
+ }
+
+ /**
+ * Return an appropriate PropertyValueModel for this host and property.
+ *
+ * @param host the host
+ * @param property the property
+ * @return the value model
+ */
+ public static <H, T> PropertyValueModel<H, T> of(H host, Property<H, T> property) {
+ return new PropertyValueModel<H, T>(host, property);
+ }
+
+ /**
+ * Return a PropertyValueModel for this {@code host} and a
+ * reflective property, constructed from this {@code propertyType} and {@code propertyName}.
+ *
+ * @param host
+ * @param propertyType the property type
+ * @param propertyName the property name
+ * @return a value model with this host and a reflective property with this type and name
+ *
+ * @see Property#of
+ */
+ public static <H, T> PropertyValueModel<H, T> of(H host, Class<T> propertyType,
+ String propertyName) {
+ return of(host, Property.of((Class<H>) host.getClass(), propertyType, propertyName));
+ }
+
+ private static Class getNullaryMethodReturnType(Class c, String name) {
+ try {
+ return c.getMethod(name).getReturnType();
+ } catch (NoSuchMethodException e) {
+ return null;
+ }
+ }
+
+ private static Class getFieldType(Class c, String name) {
+ try {
+ return c.getField(name).getType();
+ } catch (NoSuchFieldException e) {
+ return null;
+ }
+ }
+
+ private static String capitalize(String name) {
+ if (name.isEmpty()) {
+ return name;
+ }
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ }
+
+ /**
+ * Return a PropertyValueModel for this {@code host} and and {@code propertyName}.
+ *
+ * @param host the host
+ * @param propertyName the property name
+ * @return a value model with this host and a reflective property with this name
+ */
+ public static PropertyValueModel of(Object host, String propertyName) {
+ Class clazz = host.getClass();
+ String suffix = capitalize(propertyName);
+ Class propertyType = getNullaryMethodReturnType(clazz, "get" + suffix);
+ if (propertyType == null) {
+ propertyType = getNullaryMethodReturnType(clazz, "is" + suffix);
+ }
+ if (propertyType == null) {
+ propertyType = getFieldType(clazz, propertyName);
+ }
+ if (propertyType == null) {
+ throw new NoSuchPropertyException(propertyName);
+ }
+ return of(host, propertyType, propertyName);
+ }
+}
diff --git a/core/java/android/util/ValueModel.java b/core/java/android/util/ValueModel.java
new file mode 100755
index 000000000000..4789682ea496
--- /dev/null
+++ b/core/java/android/util/ValueModel.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+/**
+ * A ValueModel is an abstraction for a 'slot' or place in memory in which a value
+ * may be stored and retrieved. A common implementation of ValueModel is a regular property of
+ * an object, whose value may be retrieved by calling the appropriate <em>getter</em>
+ * method and set by calling the corresponding <em>setter</em> method.
+ *
+ * @param <T> the value type
+ *
+ * @see PropertyValueModel
+ */
+public abstract class ValueModel<T> {
+ /**
+ * The empty model should be used in place of {@code null} to indicate that a
+ * model has not been set. The empty model has no value and does nothing when it is set.
+ */
+ public static final ValueModel EMPTY = new ValueModel() {
+ @Override
+ public Class getType() {
+ return Object.class;
+ }
+
+ @Override
+ public Object get() {
+ return null;
+ }
+
+ @Override
+ public void set(Object value) {
+
+ }
+ };
+
+ protected ValueModel() {
+ }
+
+ /**
+ * Returns the type of this property.
+ *
+ * @return the property type
+ */
+ public abstract Class<T> getType();
+
+ /**
+ * Returns the value of this property.
+ *
+ * @return the property value
+ */
+ public abstract T get();
+
+ /**
+ * Sets the value of this property.
+ *
+ * @param value the new value for this property
+ */
+ public abstract void set(T value);
+} \ No newline at end of file
diff --git a/core/java/android/widget/CheckBox.java b/core/java/android/widget/CheckBox.java
index 858c415d0f08..6d292dcafa83 100644
--- a/core/java/android/widget/CheckBox.java
+++ b/core/java/android/widget/CheckBox.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.util.ValueModel;
/**
@@ -55,7 +56,9 @@ import android.view.accessibility.AccessibilityNodeInfo;
* {@link android.R.styleable#View View Attributes}
* </p>
*/
-public class CheckBox extends CompoundButton {
+public class CheckBox extends CompoundButton implements ValueEditor<Boolean> {
+ private ValueModel<Boolean> mValueModel = ValueModel.EMPTY;
+
public CheckBox(Context context) {
this(context, null);
}
@@ -79,4 +82,22 @@ public class CheckBox extends CompoundButton {
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(CheckBox.class.getName());
}
+
+ @Override
+ public ValueModel<Boolean> getValueModel() {
+ return mValueModel;
+ }
+
+ @Override
+ public void setValueModel(ValueModel<Boolean> valueModel) {
+ mValueModel = valueModel;
+ setChecked(mValueModel.get());
+ }
+
+ @Override
+ public boolean performClick() {
+ boolean handled = super.performClick();
+ mValueModel.set(isChecked());
+ return handled;
+ }
}
diff --git a/core/java/android/widget/EditText.java b/core/java/android/widget/EditText.java
index 2fd876822368..8686177c6247 100644
--- a/core/java/android/widget/EditText.java
+++ b/core/java/android/widget/EditText.java
@@ -17,6 +17,7 @@
package android.widget;
import android.content.Context;
+import android.graphics.Rect;
import android.text.Editable;
import android.text.Selection;
import android.text.Spannable;
@@ -24,6 +25,7 @@ import android.text.TextUtils;
import android.text.method.ArrowKeyMovementMethod;
import android.text.method.MovementMethod;
import android.util.AttributeSet;
+import android.util.ValueModel;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -47,7 +49,9 @@ import android.view.accessibility.AccessibilityNodeInfo;
* {@link android.R.styleable#TextView TextView Attributes},
* {@link android.R.styleable#View View Attributes}
*/
-public class EditText extends TextView {
+public class EditText extends TextView implements ValueEditor<CharSequence> {
+ private ValueModel<CharSequence> mValueModel = ValueModel.EMPTY;
+
public EditText(Context context) {
this(context, null);
}
@@ -128,4 +132,21 @@ public class EditText extends TextView {
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(EditText.class.getName());
}
+
+ @Override
+ public ValueModel<CharSequence> getValueModel() {
+ return mValueModel;
+ }
+
+ @Override
+ public void setValueModel(ValueModel<CharSequence> valueModel) {
+ mValueModel = valueModel;
+ setText(mValueModel.get());
+ }
+
+ @Override
+ void sendAfterTextChanged(Editable text) {
+ super.sendAfterTextChanged(text);
+ mValueModel.set(text);
+ }
}
diff --git a/core/java/android/widget/SeekBar.java b/core/java/android/widget/SeekBar.java
index 2737f9414c46..a6486a827af5 100644
--- a/core/java/android/widget/SeekBar.java
+++ b/core/java/android/widget/SeekBar.java
@@ -18,6 +18,7 @@ package android.widget;
import android.content.Context;
import android.util.AttributeSet;
+import android.util.ValueModel;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -33,7 +34,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
*
* @attr ref android.R.styleable#SeekBar_thumb
*/
-public class SeekBar extends AbsSeekBar {
+public class SeekBar extends AbsSeekBar implements ValueEditor<Integer> {
/**
* A callback that notifies clients when the progress level has been
@@ -69,8 +70,9 @@ public class SeekBar extends AbsSeekBar {
void onStopTrackingTouch(SeekBar seekBar);
}
+ private ValueModel<Integer> mValueModel = ValueModel.EMPTY;
private OnSeekBarChangeListener mOnSeekBarChangeListener;
-
+
public SeekBar(Context context) {
this(context, null);
}
@@ -89,9 +91,23 @@ public class SeekBar extends AbsSeekBar {
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onProgressChanged(this, getProgress(), fromUser);
+ if (fromUser) {
+ mValueModel.set(getProgress());
+ }
}
}
+ @Override
+ public ValueModel<Integer> getValueModel() {
+ return mValueModel;
+ }
+
+ @Override
+ public void setValueModel(ValueModel<Integer> valueModel) {
+ mValueModel = valueModel;
+ setProgress(mValueModel.get());
+ }
+
/**
* Sets a listener to receive notifications of changes to the SeekBar's progress level. Also
* provides notifications of when the user starts and stops a touch gesture within the SeekBar.
diff --git a/core/java/android/widget/ValueEditor.java b/core/java/android/widget/ValueEditor.java
new file mode 100755
index 000000000000..2b91abf9b8ff
--- /dev/null
+++ b/core/java/android/widget/ValueEditor.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget;
+
+import android.util.ValueModel;
+
+/**
+ * An interface for editors of simple values. Classes implementing this interface are normally
+ * UI controls (subclasses of {@link android.view.View View}) that can provide a suitable
+ * user interface to display and edit values of the specified type. This interface is
+ * intended to describe editors for simple types, like {@code boolean}, {@code int} or
+ * {@code String}, where the values themselves are immutable.
+ * <p>
+ * For example, {@link android.widget.CheckBox CheckBox} implements
+ * this interface for the Boolean type as it is capable of providing an appropriate
+ * mechanism for displaying and changing the value of a Boolean property.
+ *
+ * @param <T> the value type that this editor supports
+ */
+public interface ValueEditor<T> {
+ /**
+ * Return the last value model that was set. If no value model has been set, the editor
+ * should return the value {@link android.util.ValueModel#EMPTY}.
+ *
+ * @return the value model
+ */
+ public ValueModel<T> getValueModel();
+
+ /**
+ * Sets the value model for this editor. When the value model is set, the editor should
+ * retrieve the value from the value model, using {@link android.util.ValueModel#get()},
+ * and set its internal state accordingly. Likewise, when the editor's internal state changes
+ * it should update the value model by calling {@link android.util.ValueModel#set(T)}
+ * with the appropriate value.
+ *
+ * @param valueModel the new value model for this editor.
+ */
+ public void setValueModel(ValueModel<T> valueModel);
+}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
new file mode 100644
index 000000000000..cd54c2eb5bc1
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Grain.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.rs.image;
+
+import java.lang.Math;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RenderScript;
+import android.renderscript.Script;
+import android.renderscript.ScriptC;
+import android.renderscript.Type;
+import android.util.Log;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+public class Grain extends TestBase {
+ private ScriptC_grain mScript;
+ private Allocation mNoise;
+ private Allocation mNoise2;
+
+
+ public boolean onBar1Setup(SeekBar b, TextView t) {
+ t.setText("Strength");
+ b.setProgress(50);
+ return true;
+ }
+
+ public void onBar1Changed(int progress) {
+ float s = progress / 100.0f;
+ mScript.set_gNoiseStrength(s);
+ }
+
+ public void createTest(android.content.res.Resources res) {
+ int width = mInPixelsAllocation.getType().getX();
+ int height = mInPixelsAllocation.getType().getY();
+
+ Type.Builder tb = new Type.Builder(mRS, Element.U8(mRS));
+ tb.setX(width);
+ tb.setY(height);
+ mNoise = Allocation.createTyped(mRS, tb.create());
+ mNoise2 = Allocation.createTyped(mRS, tb.create());
+
+ mScript = new ScriptC_grain(mRS, res, R.raw.grain);
+ mScript.set_gWidth(width);
+ mScript.set_gHeight(height);
+ mScript.set_gNoiseStrength(0.5f);
+ mScript.set_gBlendSource(mNoise);
+ mScript.set_gNoise(mNoise2);
+ }
+
+ public void runTest() {
+ mScript.forEach_genRand(mNoise);
+ mScript.forEach_blend9(mNoise2);
+ mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
+ }
+
+}
+
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index e085582c3027..3a9838bf790a 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -140,6 +140,9 @@ public class ImageProcessingActivity extends Activity
case 5:
mTest = new Greyscale();
break;
+ case 6:
+ mTest = new Grain();
+ break;
}
mTest.createBaseTest(this, mBitmapIn);
@@ -152,13 +155,14 @@ public class ImageProcessingActivity extends Activity
}
void setupTests() {
- mTestNames = new String[6];
+ mTestNames = new String[7];
mTestNames[0] = "Levels Vec3 Relaxed";
mTestNames[1] = "Levels Vec4 Relaxed";
mTestNames[2] = "Levels Vec3 Full";
mTestNames[3] = "Levels Vec4 Full";
mTestNames[4] = "Blur radius 25";
mTestNames[5] = "Greyscale";
+ mTestNames[6] = "Grain";
mTestSpinner.setAdapter(new ArrayAdapter<String>(
this, R.layout.spinner_layout, mTestNames));
}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
new file mode 100644
index 000000000000..97ae4fb3a38d
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.image)
+#pragma rs_fp_relaxed
+
+void genRand(uchar *out) {
+ *out = (uchar)rsRand(0xff);
+}
+
+/*
+ * Convolution matrix of distance 2 with fixed point of 'kShiftBits' bits
+ * shifted. Thus the sum of this matrix should be 'kShiftValue'. Entries of
+ * small values are not calculated to gain efficiency.
+ * The order ot pixels represented in this matrix is:
+ * 1 2 3
+ * 4 0 5
+ * 6 7 8
+ * and the matrix should be: {230, 56, 114, 56, 114, 114, 56, 114, 56}.
+ * However, since most of the valus are identical, we only use the first three
+ * entries and the entries corresponding to the pixels is:
+ * 1 2 1
+ * 2 0 2
+ * 1 2 1
+ */
+
+int32_t gWidth;
+int32_t gHeight;
+
+rs_allocation gBlendSource;
+void blend9(uchar *out, uint32_t x, uint32_t y) {
+ uint32_t x1 = min(x+1, (uint32_t)gWidth);
+ uint32_t x2 = max(x-1, (uint32_t)0);
+ uint32_t y1 = min(y+1, (uint32_t)gHeight);
+ uint32_t y2 = max(y-1, (uint32_t)0);
+
+ uint p00 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x1, y1))[0];
+ uint p01 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x, y1))[0];
+ uint p02 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x2, y1))[0];
+ uint p10 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x1, y))[0];
+ uint p11 = 230 * ((uchar *)rsGetElementAt(gBlendSource, x, y))[0];
+ uint p12 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x2, y))[0];
+ uint p20 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x1, y2))[0];
+ uint p21 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x, y2))[0];
+ uint p22 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x2, y2))[0];
+
+ p00 += p01;
+ p02 += p10;
+ p11 += p12;
+ p20 += p21;
+
+ p22 += p00;
+ p02 += p11;
+
+ p20 += p22;
+ p20 += p02;
+
+ *out = (uchar)(p20 >> 10);
+}
+
+float gNoiseStrength;
+
+rs_allocation gNoise;
+void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
+ float4 ip = convert_float4(*in);
+ float pnoise = (float) ((uchar *)rsGetElementAt(gNoise, x, y))[0];
+
+ float energy_level = ip.r + ip.g + ip.b;
+ float energy_mask = (28.f - sqrt(energy_level)) * 0.03571f;
+ pnoise = (pnoise - 128.f) * energy_mask;
+
+ ip += pnoise * gNoiseStrength;
+ ip = clamp(ip, 0.f, 255.f);
+
+ uchar4 p = convert_uchar4(ip);
+ p.a = 0xff;
+ *out = p;
+}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
index 32a4bd7f9010..9d94ba58d7ee 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java
@@ -19,19 +19,267 @@ package com.android.rs.test;
import android.content.Context;
import android.content.res.Resources;
import android.renderscript.*;
+import android.util.Log;
+import java.util.Arrays;
import java.util.Random;
public class UT_math_agree extends UnitTest {
private Resources mRes;
+ private Random rand;
protected UT_math_agree(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "Math Agreement", ctx);
mRes = res;
+ rand = new Random();
}
- private void initializeValues(ScriptC_math_agree s) {
- Random rand = new Random();
+ // packing functions
+ private Float2 pack_f2(float[] val) {
+ assert val.length == 2;
+ return new Float2(val[0], val[1]);
+ }
+ private Float3 pack_f3(float[] val) {
+ assert val.length == 3;
+ return new Float3(val[0], val[1], val[2]);
+ }
+ private Float4 pack_f4(float[] val) {
+ assert val.length == 4;
+ return new Float4(val[0], val[1], val[2], val[3]);
+ }
+ private Byte2 pack_b2(byte[] val) {
+ assert val.length == 2;
+ return new Byte2(val[0], val[1]);
+ }
+ private Byte3 pack_b3(byte[] val) {
+ assert val.length == 3;
+ return new Byte3(val[0], val[1], val[2]);
+ }
+ private Byte4 pack_b4(byte[] val) {
+ assert val.length == 4;
+ return new Byte4(val[0], val[1], val[2], val[3]);
+ }
+ private Short2 pack_s2(short[] val) {
+ assert val.length == 2;
+ return new Short2(val[0], val[1]);
+ }
+ private Short3 pack_s3(short[] val) {
+ assert val.length == 3;
+ return new Short3(val[0], val[1], val[2]);
+ }
+ private Short4 pack_s4(short[] val) {
+ assert val.length == 4;
+ return new Short4(val[0], val[1], val[2], val[3]);
+ }
+ private Int2 pack_i2(int[] val) {
+ assert val.length == 2;
+ return new Int2(val[0], val[1]);
+ }
+ private Int3 pack_i3(int[] val) {
+ assert val.length == 3;
+ return new Int3(val[0], val[1], val[2]);
+ }
+ private Int4 pack_i4(int[] val) {
+ assert val.length == 4;
+ return new Int4(val[0], val[1], val[2], val[3]);
+ }
+ private Long2 pack_l2(long[] val) {
+ assert val.length == 2;
+ return new Long2(val[0], val[1]);
+ }
+ private Long3 pack_l3(long[] val) {
+ assert val.length == 3;
+ return new Long3(val[0], val[1], val[2]);
+ }
+ private Long4 pack_l4(long[] val) {
+ assert val.length == 4;
+ return new Long4(val[0], val[1], val[2], val[3]);
+ }
+
+ // random vector generation functions
+ private float[] randvec_float(int dim) {
+ float[] fv = new float[dim];
+ for (int i = 0; i < dim; ++i)
+ fv[i] = rand.nextFloat();
+ return fv;
+ }
+ private byte[] randvec_char(int dim) {
+ byte[] cv = new byte[dim];
+ rand.nextBytes(cv);
+ return cv;
+ }
+ private short[] randvec_uchar(int dim) {
+ short[] ucv = new short[dim];
+ for (int i = 0; i < dim; ++i)
+ ucv[i] = (short)rand.nextInt(0x1 << 8);
+ return ucv;
+ }
+ private short[] randvec_short(int dim) {
+ short[] sv = new short[dim];
+ for (int i = 0; i < dim; ++i)
+ sv[i] = (short)rand.nextInt(0x1 << 16);
+ return sv;
+ }
+ private int[] randvec_ushort(int dim) {
+ int[] usv = new int[dim];
+ for (int i = 0; i < dim; ++i)
+ usv[i] = rand.nextInt(0x1 << 16);
+ return usv;
+ }
+ private int[] randvec_int(int dim) {
+ int[] iv = new int[dim];
+ for (int i = 0; i < dim; ++i)
+ iv[i] = rand.nextInt();
+ return iv;
+ }
+ private long[] randvec_uint(int dim) {
+ long[] uiv = new long[dim];
+ for (int i = 0; i < dim; ++i)
+ uiv[i] = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
+ return uiv;
+ }
+ private long[] randvec_long(int dim) {
+ long[] lv = new long[dim];
+ for (int i = 0; i < dim; ++i)
+ lv[i] = rand.nextLong();
+ return lv;
+ }
+ // TODO: unsigned long generator
+
+ // min reference functions
+ private float min(float v1, float v2) {
+ return v1 < v2 ? v1 : v2;
+ }
+ private float[] min(float[] v1, float[] v2) {
+ assert v1.length == v2.length;
+ float[] rv = new float[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2[i]);
+ return rv;
+ }
+ private byte min(byte v1, byte v2) {
+ return v1 < v2 ? v1 : v2;
+ }
+ private byte[] min(byte[] v1, byte[] v2) {
+ assert v1.length == v2.length;
+ byte[] rv = new byte[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2[i]);
+ return rv;
+ }
+ private short min(short v1, short v2) {
+ return v1 < v2 ? v1 : v2;
+ }
+ private short[] min(short[] v1, short[] v2) {
+ assert v1.length == v2.length;
+ short[] rv = new short[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2[i]);
+ return rv;
+ }
+ private int min(int v1, int v2) {
+ return v1 < v2 ? v1 : v2;
+ }
+ private int[] min(int[] v1, int[] v2) {
+ assert v1.length == v2.length;
+ int[] rv = new int[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2[i]);
+ return rv;
+ }
+ private long min(long v1, long v2) {
+ return v1 < v2 ? v1 : v2;
+ }
+ private long[] min(long[] v1, long[] v2) {
+ assert v1.length == v2.length;
+ long[] rv = new long[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2[i]);
+ return rv;
+ }
+ // TODO: unsigned long version of min
+
+ // max reference functions
+ private float max(float v1, float v2) {
+ return v1 > v2 ? v1 : v2;
+ }
+ private float[] max(float[] v1, float[] v2) {
+ assert v1.length == v2.length;
+ float[] rv = new float[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = max(v1[i], v2[i]);
+ return rv;
+ }
+ private byte max(byte v1, byte v2) {
+ return v1 > v2 ? v1 : v2;
+ }
+ private byte[] max(byte[] v1, byte[] v2) {
+ assert v1.length == v2.length;
+ byte[] rv = new byte[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = max(v1[i], v2[i]);
+ return rv;
+ }
+ private short max(short v1, short v2) {
+ return v1 > v2 ? v1 : v2;
+ }
+ private short[] max(short[] v1, short[] v2) {
+ assert v1.length == v2.length;
+ short[] rv = new short[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = max(v1[i], v2[i]);
+ return rv;
+ }
+ private int max(int v1, int v2) {
+ return v1 > v2 ? v1 : v2;
+ }
+ private int[] max(int[] v1, int[] v2) {
+ assert v1.length == v2.length;
+ int[] rv = new int[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = max(v1[i], v2[i]);
+ return rv;
+ }
+ private long max(long v1, long v2) {
+ return v1 > v2 ? v1 : v2;
+ }
+ private long[] max(long[] v1, long[] v2) {
+ assert v1.length == v2.length;
+ long[] rv = new long[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = max(v1[i], v2[i]);
+ return rv;
+ }
+ // TODO: unsigned long version of max
+ // fmin reference functions
+ private float fmin(float v1, float v2) {
+ return min(v1, v2);
+ }
+ private float[] fmin(float[] v1, float[] v2) {
+ return min(v1, v2);
+ }
+ private float[] fmin(float[] v1, float v2) {
+ float[] rv = new float[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = min(v1[i], v2);
+ return rv;
+ }
+
+ // fmax reference functions
+ private float fmax(float v1, float v2) {
+ return max(v1, v2);
+ }
+ private float[] fmax(float[] v1, float[] v2) {
+ return max(v1, v2);
+ }
+ private float[] fmax(float[] v1, float v2) {
+ float[] rv = new float[v1.length];
+ for (int i = 0; i < v1.length; ++i)
+ rv[i] = max(v1[i], v2);
+ return rv;
+ }
+
+ private void initializeValues(ScriptC_math_agree s) {
float x = rand.nextFloat();
float y = rand.nextFloat();
@@ -41,6 +289,249 @@ public class UT_math_agree extends UnitTest {
s.set_result_sub(x - y);
s.set_result_mul(x * y);
s.set_result_div(x / y);
+
+ // Generate random vectors of all types
+ float rand_f1_0 = rand.nextFloat();
+ float[] rand_f2_0 = randvec_float(2);
+ float[] rand_f3_0 = randvec_float(3);
+ float[] rand_f4_0 = randvec_float(4);
+ float rand_f1_1 = rand.nextFloat();
+ float[] rand_f2_1 = randvec_float(2);
+ float[] rand_f3_1 = randvec_float(3);
+ float[] rand_f4_1 = randvec_float(4);
+ byte rand_sc1_0 = (byte)rand.nextInt(0x1 << 8);
+ byte[] rand_sc2_0 = randvec_char(2);
+ byte[] rand_sc3_0 = randvec_char(3);
+ byte[] rand_sc4_0 = randvec_char(4);
+ byte rand_sc1_1 = (byte)rand.nextInt(0x1 << 8);
+ byte[] rand_sc2_1 = randvec_char(2);
+ byte[] rand_sc3_1 = randvec_char(3);
+ byte[] rand_sc4_1 = randvec_char(4);
+ short rand_ss1_0 = (short)rand.nextInt(0x1 << 16);
+ short[] rand_ss2_0 = randvec_short(2);
+ short[] rand_ss3_0 = randvec_short(3);
+ short[] rand_ss4_0 = randvec_short(4);
+ short rand_ss1_1 = (short)rand.nextInt(0x1 << 16);
+ short[] rand_ss2_1 = randvec_short(2);
+ short[] rand_ss3_1 = randvec_short(3);
+ short[] rand_ss4_1 = randvec_short(4);
+ int rand_si1_0 = rand.nextInt();
+ int[] rand_si2_0 = randvec_int(2);
+ int[] rand_si3_0 = randvec_int(3);
+ int[] rand_si4_0 = randvec_int(4);
+ int rand_si1_1 = rand.nextInt();
+ int[] rand_si2_1 = randvec_int(2);
+ int[] rand_si3_1 = randvec_int(3);
+ int[] rand_si4_1 = randvec_int(4);
+ long rand_sl1_0 = rand.nextLong();
+ long[] rand_sl2_0 = randvec_long(2);
+ long[] rand_sl3_0 = randvec_long(3);
+ long[] rand_sl4_0 = randvec_long(4);
+ long rand_sl1_1 = rand.nextLong();
+ long[] rand_sl2_1 = randvec_long(2);
+ long[] rand_sl3_1 = randvec_long(3);
+ long[] rand_sl4_1 = randvec_long(4);
+ // FIXME: generate unsigned input vectors once bug 6764163 is fixed
+ /*
+ short rand_uc1_0 = (short)rand.nextInt(0x1 << 8);
+ short[] rand_uc2_0 = randvec_uchar(2);
+ short[] rand_uc3_0 = randvec_uchar(3);
+ short[] rand_uc4_0 = randvec_uchar(4);
+ short rand_uc1_1 = (short)rand.nextInt(0x1 << 8);
+ short[] rand_uc2_1 = randvec_uchar(2);
+ short[] rand_uc3_1 = randvec_uchar(3);
+ short[] rand_uc4_1 = randvec_uchar(4);
+ int rand_us1_0 = rand.nextInt(0x1 << 16);
+ int[] rand_us2_0 = randvec_ushort(2);
+ int[] rand_us3_0 = randvec_ushort(3);
+ int[] rand_us4_0 = randvec_ushort(4);
+ int rand_us1_1 = rand.nextInt(0x1 << 16);
+ int[] rand_us2_1 = randvec_ushort(2);
+ int[] rand_us3_1 = randvec_ushort(3);
+ int[] rand_us4_1 = randvec_ushort(4);
+ long rand_ui1_0 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
+ long[] rand_ui2_0 = randvec_uint(2);
+ long[] rand_ui3_0 = randvec_uint(3);
+ long[] rand_ui4_0 = randvec_uint(4);
+ long rand_ui1_1 = (long)rand.nextInt() - (long)Integer.MIN_VALUE;
+ long[] rand_ui2_1 = randvec_uint(2);
+ long[] rand_ui3_1 = randvec_uint(3);
+ long[] rand_ui4_1 = randvec_uint(4);
+ */
+ // TODO: generate unsigned long vectors
+
+ // Set random vectors in renderscript code
+ s.set_rand_f1_0(rand_f1_0);
+ s.set_rand_f2_0(pack_f2(rand_f2_0));
+ s.set_rand_f3_0(pack_f3(rand_f3_0));
+ s.set_rand_f4_0(pack_f4(rand_f4_0));
+ s.set_rand_f1_1(rand_f1_1);
+ s.set_rand_f2_1(pack_f2(rand_f2_1));
+ s.set_rand_f3_1(pack_f3(rand_f3_1));
+ s.set_rand_f4_1(pack_f4(rand_f4_1));
+ s.set_rand_sc1_1(rand_sc1_1);
+ s.set_rand_sc2_1(pack_b2(rand_sc2_1));
+ s.set_rand_sc3_1(pack_b3(rand_sc3_1));
+ s.set_rand_sc4_1(pack_b4(rand_sc4_1));
+ s.set_rand_ss1_0(rand_ss1_0);
+ s.set_rand_ss2_0(pack_s2(rand_ss2_0));
+ s.set_rand_ss3_0(pack_s3(rand_ss3_0));
+ s.set_rand_ss4_0(pack_s4(rand_ss4_0));
+ s.set_rand_ss1_1(rand_ss1_1);
+ s.set_rand_ss2_1(pack_s2(rand_ss2_1));
+ s.set_rand_ss3_1(pack_s3(rand_ss3_1));
+ s.set_rand_ss4_1(pack_s4(rand_ss4_1));
+ s.set_rand_si1_0(rand_si1_0);
+ s.set_rand_si2_0(pack_i2(rand_si2_0));
+ s.set_rand_si3_0(pack_i3(rand_si3_0));
+ s.set_rand_si4_0(pack_i4(rand_si4_0));
+ s.set_rand_si1_1(rand_si1_1);
+ s.set_rand_si2_1(pack_i2(rand_si2_1));
+ s.set_rand_si3_1(pack_i3(rand_si3_1));
+ s.set_rand_si4_1(pack_i4(rand_si4_1));
+ s.set_rand_sl1_0(rand_sl1_0);
+ s.set_rand_sl2_0(pack_l2(rand_sl2_0));
+ s.set_rand_sl3_0(pack_l3(rand_sl3_0));
+ s.set_rand_sl4_0(pack_l4(rand_sl4_0));
+ s.set_rand_sl1_1(rand_sl1_1);
+ s.set_rand_sl2_1(pack_l2(rand_sl2_1));
+ s.set_rand_sl3_1(pack_l3(rand_sl3_1));
+ s.set_rand_sl4_1(pack_l4(rand_sl4_1));
+ // FIXME: set signed char input vectors once bug is fixed
+ /*
+ s.set_rand_sc1_0(rand_sc1_0);
+ s.set_rand_sc2_0(pack_b2(rand_sc2_0));
+ s.set_rand_sc3_0(pack_b3(rand_sc3_0));
+ s.set_rand_sc4_0(pack_b4(rand_sc4_0));
+ */
+ // FIXME: set unsigned input vectors once bug 6764163 is fixed
+ /*
+ s.set_rand_us1_0(rand_us1_0);
+ s.set_rand_us2_0(pack_i2(rand_us2_0));
+ s.set_rand_us3_0(pack_i3(rand_us3_0));
+ s.set_rand_us4_0(pack_i4(rand_us4_0));
+ s.set_rand_us1_1(rand_us1_1);
+ s.set_rand_us2_1(pack_i2(rand_us2_1));
+ s.set_rand_us3_1(pack_i3(rand_us3_1));
+ s.set_rand_us4_1(pack_i4(rand_us4_1));
+ s.set_rand_uc1_0(rand_uc1_0);
+ s.set_rand_uc2_0(pack_s2(rand_uc2_0));
+ s.set_rand_uc3_0(pack_s3(rand_uc3_0));
+ s.set_rand_uc4_0(pack_s4(rand_uc4_0));
+ s.set_rand_uc1_1(rand_uc1_1);
+ s.set_rand_uc2_1(pack_s2(rand_uc2_1));
+ s.set_rand_uc3_1(pack_s3(rand_uc3_1));
+ s.set_rand_uc4_1(pack_s4(rand_uc4_1));
+ s.set_rand_ui1_0(rand_ui1_0);
+ s.set_rand_ui2_0(pack_l2(rand_ui2_0));
+ s.set_rand_ui3_0(pack_l3(rand_ui3_0));
+ s.set_rand_ui4_0(pack_l4(rand_ui4_0));
+ s.set_rand_ui1_1(rand_ui1_1);
+ s.set_rand_ui2_1(pack_l2(rand_ui2_1));
+ s.set_rand_ui3_1(pack_l3(rand_ui3_1));
+ s.set_rand_ui4_1(pack_l4(rand_ui4_1));
+ */
+ // TODO: set unsigned long vectors
+
+ // Set results for min
+ s.set_min_rand_f1_f1(min(rand_f1_0, rand_f1_1));
+ s.set_min_rand_f2_f2(pack_f2(min(rand_f2_0, rand_f2_1)));
+ s.set_min_rand_f3_f3(pack_f3(min(rand_f3_0, rand_f3_1)));
+ s.set_min_rand_f4_f4(pack_f4(min(rand_f4_0, rand_f4_1)));
+ s.set_min_rand_ss1_ss1(min(rand_ss1_0, rand_ss1_1));
+ s.set_min_rand_ss2_ss2(pack_s2(min(rand_ss2_0, rand_ss2_1)));
+ s.set_min_rand_ss3_ss3(pack_s3(min(rand_ss3_0, rand_ss3_1)));
+ s.set_min_rand_ss4_ss4(pack_s4(min(rand_ss4_0, rand_ss4_1)));
+ s.set_min_rand_si1_si1(min(rand_si1_0, rand_si1_1));
+ s.set_min_rand_si2_si2(pack_i2(min(rand_si2_0, rand_si2_1)));
+ s.set_min_rand_si3_si3(pack_i3(min(rand_si3_0, rand_si3_1)));
+ s.set_min_rand_si4_si4(pack_i4(min(rand_si4_0, rand_si4_1)));
+ s.set_min_rand_sl1_sl1(min(rand_sl1_0, rand_sl1_1));
+ s.set_min_rand_sl2_sl2(pack_l2(min(rand_sl2_0, rand_sl2_1)));
+ s.set_min_rand_sl3_sl3(pack_l3(min(rand_sl3_0, rand_sl3_1)));
+ s.set_min_rand_sl4_sl4(pack_l4(min(rand_sl4_0, rand_sl4_1)));
+ // FIXME: set signed char min reference vectors once bug is fixed
+ /*
+ s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1));
+ s.set_min_rand_sc2_sc2(pack_b2(min(rand_sc2_0, rand_sc2_1)));
+ s.set_min_rand_sc3_sc3(pack_b3(min(rand_sc3_0, rand_sc3_1)));
+ s.set_min_rand_sc4_sc4(pack_b4(min(rand_sc4_0, rand_sc4_1)));
+ */
+ // FIXME: set unsigned min reference vectors once bug 6764163 is fixed
+ /*
+ s.set_min_rand_uc1_uc1(min(rand_uc1_0, rand_uc1_1));
+ s.set_min_rand_uc2_uc2(pack_s3(min(rand_uc2_0, rand_uc2_1)));
+ s.set_min_rand_uc3_uc3(pack_s3(min(rand_uc3_0, rand_uc3_1)));
+ s.set_min_rand_uc4_uc4(pack_s4(min(rand_uc4_0, rand_uc4_1)));
+ s.set_min_rand_us1_us1(min(rand_us1_0, rand_us1_1));
+ s.set_min_rand_us2_us2(pack_i2(min(rand_us2_0, rand_us2_1)));
+ s.set_min_rand_us3_us3(pack_i3(min(rand_us3_0, rand_us3_1)));
+ s.set_min_rand_us4_us4(pack_i4(min(rand_us4_0, rand_us4_1)));
+ s.set_min_rand_ui1_ui1(min(rand_ui1_0, rand_ui1_1));
+ s.set_min_rand_ui2_ui2(pack_l2(min(rand_ui2_0, rand_ui2_1)));
+ s.set_min_rand_ui3_ui3(pack_l3(min(rand_ui3_0, rand_ui3_1)));
+ s.set_min_rand_ui4_ui4(pack_l4(min(rand_ui4_0, rand_ui4_1)));
+ */
+ // TODO: set results for unsigned long min
+
+ // Set results for max
+ s.set_max_rand_f1_f1(max(rand_f1_0, rand_f1_1));
+ s.set_max_rand_f2_f2(pack_f2(max(rand_f2_0, rand_f2_1)));
+ s.set_max_rand_f3_f3(pack_f3(max(rand_f3_0, rand_f3_1)));
+ s.set_max_rand_f4_f4(pack_f4(max(rand_f4_0, rand_f4_1)));
+ s.set_max_rand_ss1_ss1(max(rand_ss1_0, rand_ss1_1));
+ s.set_max_rand_ss2_ss2(pack_s2(max(rand_ss2_0, rand_ss2_1)));
+ s.set_max_rand_ss3_ss3(pack_s3(max(rand_ss3_0, rand_ss3_1)));
+ s.set_max_rand_ss4_ss4(pack_s4(max(rand_ss4_0, rand_ss4_1)));
+ s.set_max_rand_si1_si1(max(rand_si1_0, rand_si1_1));
+ s.set_max_rand_si2_si2(pack_i2(max(rand_si2_0, rand_si2_1)));
+ s.set_max_rand_si3_si3(pack_i3(max(rand_si3_0, rand_si3_1)));
+ s.set_max_rand_si4_si4(pack_i4(max(rand_si4_0, rand_si4_1)));
+ s.set_max_rand_sl1_sl1(max(rand_sl1_0, rand_sl1_1));
+ s.set_max_rand_sl2_sl2(pack_l2(max(rand_sl2_0, rand_sl2_1)));
+ s.set_max_rand_sl3_sl3(pack_l3(max(rand_sl3_0, rand_sl3_1)));
+ s.set_max_rand_sl4_sl4(pack_l4(max(rand_sl4_0, rand_sl4_1)));
+ // FIXME: set signed char max reference vectors once bug is fixed
+ /*
+ s.set_max_rand_sc1_sc1(max(rand_sc1_0, rand_sc1_1));
+ s.set_max_rand_sc2_sc2(pack_b2(max(rand_sc2_0, rand_sc2_1)));
+ s.set_max_rand_sc3_sc3(pack_b3(max(rand_sc3_0, rand_sc3_1)));
+ s.set_max_rand_sc4_sc4(pack_b4(max(rand_sc4_0, rand_sc4_1)));
+ */
+ // FIXME: set unsigned max reference vectors once bug 6764163 is fixed
+ /*
+ s.set_max_rand_uc1_uc1(max(rand_uc1_0, rand_uc1_1));
+ s.set_max_rand_uc2_uc2(pack_s3(max(rand_uc2_0, rand_uc2_1)));
+ s.set_max_rand_uc3_uc3(pack_s3(max(rand_uc3_0, rand_uc3_1)));
+ s.set_max_rand_uc4_uc4(pack_s4(max(rand_uc4_0, rand_uc4_1)));
+ s.set_max_rand_us1_us1(max(rand_us1_0, rand_us1_1));
+ s.set_max_rand_us2_us2(pack_i2(max(rand_us2_0, rand_us2_1)));
+ s.set_max_rand_us3_us3(pack_i3(max(rand_us3_0, rand_us3_1)));
+ s.set_max_rand_us4_us4(pack_i4(max(rand_us4_0, rand_us4_1)));
+ s.set_max_rand_ui1_ui1(max(rand_ui1_0, rand_ui1_1));
+ s.set_max_rand_ui2_ui2(pack_l2(max(rand_ui2_0, rand_ui2_1)));
+ s.set_max_rand_ui3_ui3(pack_l3(max(rand_ui3_0, rand_ui3_1)));
+ s.set_max_rand_ui4_ui4(pack_l4(max(rand_ui4_0, rand_ui4_1)));
+ */
+ // TODO: set results for unsigned long max
+
+ // Set results for fmin
+ s.set_fmin_rand_f1_f1(fmin(rand_f1_0, rand_f1_1));
+ s.set_fmin_rand_f2_f2(pack_f2(fmin(rand_f2_0, rand_f2_1)));
+ s.set_fmin_rand_f3_f3(pack_f3(fmin(rand_f3_0, rand_f3_1)));
+ s.set_fmin_rand_f4_f4(pack_f4(fmin(rand_f4_0, rand_f4_1)));
+ s.set_fmin_rand_f2_f1(pack_f2(fmin(rand_f2_0, rand_f1_1)));
+ s.set_fmin_rand_f3_f1(pack_f3(fmin(rand_f3_0, rand_f1_1)));
+ s.set_fmin_rand_f4_f1(pack_f4(fmin(rand_f4_0, rand_f1_1)));
+
+ // Set results for fmax
+ s.set_fmax_rand_f1_f1(fmax(rand_f1_0, rand_f1_1));
+ s.set_fmax_rand_f2_f2(pack_f2(fmax(rand_f2_0, rand_f2_1)));
+ s.set_fmax_rand_f3_f3(pack_f3(fmax(rand_f3_0, rand_f3_1)));
+ s.set_fmax_rand_f4_f4(pack_f4(fmax(rand_f4_0, rand_f4_1)));
+ s.set_fmax_rand_f2_f1(pack_f2(fmax(rand_f2_0, rand_f1_1)));
+ s.set_fmax_rand_f3_f1(pack_f3(fmax(rand_f3_0, rand_f1_1)));
+ s.set_fmax_rand_f4_f1(pack_f4(fmax(rand_f4_0, rand_f1_1)));
}
public void run() {
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
index 953b9de144a2..ac3a3fa9b617 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs
@@ -1,34 +1,391 @@
#include "shared.rsh"
//#pragma rs_fp_relaxed
-float x = 0.0f;
-float y = 0.0f;
-float result_add = 0.0f;
-float result_sub = 0.0f;
-float result_mul = 0.0f;
-float result_div = 0.0f;
-
-#define TEST_OP(op, opName) \
-result = x op y; \
-if (! float_almost_equal(result, result_##opName)) { \
- rsDebug(#opName " did not match!", 0); \
- rsDebug("x = ", x); \
- rsDebug("y = ", y); \
- rsDebug("Result = ", result); \
- rsDebug("Expected = ", result_##opName); \
- rsDebug("Difference = ", result - result_##opName); \
- rsDebug("ULP Difference =", float_dist(result, result_##opName)); \
+volatile float x = 0.0f;
+volatile float y = 0.0f;
+volatile float result_add = 0.0f;
+volatile float result_sub = 0.0f;
+volatile float result_mul = 0.0f;
+volatile float result_div = 0.0f;
+
+#define DECLARE_INPUT_SET(type, abbrev) \
+volatile type rand_##abbrev##1_0, rand_##abbrev##1_1; \
+volatile type##2 rand_##abbrev##2_0, rand_##abbrev##2_1; \
+volatile type##3 rand_##abbrev##3_0, rand_##abbrev##3_1; \
+volatile type##4 rand_##abbrev##4_0, rand_##abbrev##4_1;
+
+#define DECLARE_ALL_INPUT_SETS() \
+DECLARE_INPUT_SET(float, f); \
+DECLARE_INPUT_SET(char, sc); \
+DECLARE_INPUT_SET(uchar, uc); \
+DECLARE_INPUT_SET(short, ss); \
+DECLARE_INPUT_SET(ushort, us); \
+DECLARE_INPUT_SET(int, si); \
+DECLARE_INPUT_SET(uint, ui); \
+DECLARE_INPUT_SET(long, sl); \
+DECLARE_INPUT_SET(ulong, ul);
+
+DECLARE_ALL_INPUT_SETS();
+
+#define DECLARE_REFERENCE_SET_VEC_VEC(type, abbrev, func) \
+volatile type func##_rand_##abbrev##1_##abbrev##1; \
+volatile type##2 func##_rand_##abbrev##2_##abbrev##2; \
+volatile type##3 func##_rand_##abbrev##3_##abbrev##3; \
+volatile type##4 func##_rand_##abbrev##4_##abbrev##4;
+#define DECLARE_REFERENCE_SET_VEC_SCL(type, abbrev, func) \
+volatile type##2 func##_rand_##abbrev##2_##abbrev##1; \
+volatile type##3 func##_rand_##abbrev##3_##abbrev##1; \
+volatile type##4 func##_rand_##abbrev##4_##abbrev##1;
+
+#define DECLARE_ALL_REFERENCE_SETS_VEC_VEC(func) \
+DECLARE_REFERENCE_SET_VEC_VEC(float, f, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(char, sc, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(uchar, uc, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(short, ss, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(ushort, us, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(int, si, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(uint, ui, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(long, sl, func); \
+DECLARE_REFERENCE_SET_VEC_VEC(ulong, ul, func);
+
+DECLARE_ALL_REFERENCE_SETS_VEC_VEC(min);
+DECLARE_ALL_REFERENCE_SETS_VEC_VEC(max);
+DECLARE_REFERENCE_SET_VEC_VEC(float, f, fmin);
+DECLARE_REFERENCE_SET_VEC_SCL(float, f, fmin);
+DECLARE_REFERENCE_SET_VEC_VEC(float, f, fmax);
+DECLARE_REFERENCE_SET_VEC_SCL(float, f, fmax);
+
+static void fail_f1(float v1, float v2, float actual, float expected, char *op_name) {
+ int dist = float_dist(actual, expected);
+ rsDebug("float operation did not match!", op_name);
+ rsDebug("v1", v1);
+ rsDebug("v2", v2);
+ rsDebug("Dalvik result", expected);
+ rsDebug("Renderscript result", actual);
+ rsDebug("ULP difference", dist);
+}
+
+static void fail_f2(float2 v1, float2 v2, float2 actual, float2 expected, char *op_name) {
+ int2 dist;
+ dist.x = float_dist(actual.x, expected.x);
+ dist.y = float_dist(actual.y, expected.y);
+ rsDebug("float2 operation did not match!", op_name);
+ rsDebug("v1.x", v1.x);
+ rsDebug("v1.y", v1.y);
+ rsDebug("v2.x", v2.x);
+ rsDebug("v2.y", v2.y);
+ rsDebug("Dalvik result .x", expected.x);
+ rsDebug("Dalvik result .y", expected.y);
+ rsDebug("Renderscript result .x", actual.x);
+ rsDebug("Renderscript result .y", actual.y);
+ rsDebug("ULP difference .x", dist.x);
+ rsDebug("ULP difference .y", dist.y);
+}
+
+static void fail_f3(float3 v1, float3 v2, float3 actual, float3 expected, char *op_name) {
+ int3 dist;
+ dist.x = float_dist(actual.x, expected.x);
+ dist.y = float_dist(actual.y, expected.y);
+ dist.z = float_dist(actual.z, expected.z);
+ rsDebug("float3 operation did not match!", op_name);
+ rsDebug("v1.x", v1.x);
+ rsDebug("v1.y", v1.y);
+ rsDebug("v1.z", v1.z);
+ rsDebug("v2.x", v2.x);
+ rsDebug("v2.y", v2.y);
+ rsDebug("v2.z", v2.z);
+ rsDebug("Dalvik result .x", expected.x);
+ rsDebug("Dalvik result .y", expected.y);
+ rsDebug("Dalvik result .z", expected.z);
+ rsDebug("Renderscript result .x", actual.x);
+ rsDebug("Renderscript result .y", actual.y);
+ rsDebug("Renderscript result .z", actual.z);
+ rsDebug("ULP difference .x", dist.x);
+ rsDebug("ULP difference .y", dist.y);
+ rsDebug("ULP difference .z", dist.z);
+}
+
+static void fail_f4(float4 v1, float4 v2, float4 actual, float4 expected, char *op_name) {
+ int4 dist;
+ dist.x = float_dist(actual.x, expected.x);
+ dist.y = float_dist(actual.y, expected.y);
+ dist.z = float_dist(actual.z, expected.z);
+ dist.w = float_dist(actual.w, expected.w);
+ rsDebug("float4 operation did not match!", op_name);
+ rsDebug("v1.x", v1.x);
+ rsDebug("v1.y", v1.y);
+ rsDebug("v1.z", v1.z);
+ rsDebug("v1.w", v1.w);
+ rsDebug("v2.x", v2.x);
+ rsDebug("v2.y", v2.y);
+ rsDebug("v2.z", v2.z);
+ rsDebug("v2.w", v2.w);
+ rsDebug("Dalvik result .x", expected.x);
+ rsDebug("Dalvik result .y", expected.y);
+ rsDebug("Dalvik result .z", expected.z);
+ rsDebug("Dalvik result .w", expected.w);
+ rsDebug("Renderscript result .x", actual.x);
+ rsDebug("Renderscript result .y", actual.y);
+ rsDebug("Renderscript result .z", actual.z);
+ rsDebug("Renderscript result .w", actual.w);
+ rsDebug("ULP difference .x", dist.x);
+ rsDebug("ULP difference .y", dist.y);
+ rsDebug("ULP difference .z", dist.z);
+ rsDebug("ULP difference .w", dist.w);
+}
+
+static bool f1_almost_equal(float a, float b) {
+ return float_almost_equal(a, b);
+}
+
+static bool f2_almost_equal(float2 a, float2 b) {
+ return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y);
+}
+
+
+static bool f3_almost_equal(float3 a, float3 b) {
+ return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y)
+ && float_almost_equal(a.z, b.z);
+}
+
+static bool f4_almost_equal(float4 a, float4 b) {
+ return float_almost_equal(a.x, b.x) && float_almost_equal(a.y, b.y)
+ && float_almost_equal(a.z, b.z) && float_almost_equal(a.w, b.w);
+}
+
+#define TEST_BASIC_FLOAT_OP(op, opName) \
+temp_f1 = x op y; \
+if (! float_almost_equal(temp_f1, result_##opName)) { \
+ fail_f1(x, y , temp_f1, result_##opName, #opName); \
+ failed = true; \
+}
+
+#define TEST_FN_FN(func, size) \
+temp_f##size = func(rand_f##size##_0, rand_f##size##_1); \
+if (! f##size##_almost_equal(temp_f##size , func##_rand_f##size##_f##size)) { \
+ fail_f##size (x, y , temp_f##size, func##_rand_f##size##_f##size, #func); \
+ failed = true; \
+}
+#define TEST_FN_F(func, size) \
+temp_f##size = func(rand_f##size##_0, rand_f1_1); \
+if (! f##size##_almost_equal(temp_f##size , func##_rand_f##size##_f1)) { \
+ fail_f##size (x, y , temp_f##size, func##_rand_f##size##_f1 , #func); \
+ failed = true; \
+}
+
+#define TEST_FN_FN_ALL(func) \
+TEST_FN_FN(func, 1) \
+TEST_FN_FN(func, 2) \
+TEST_FN_FN(func, 3) \
+TEST_FN_FN(func, 4)
+#define TEST_FN_F_ALL(func) \
+TEST_FN_F(func, 2) \
+TEST_FN_F(func, 3) \
+TEST_FN_F(func, 4)
+
+#define TEST_VEC1_VEC1(func, type) \
+temp_##type##1 = func( rand_##type##1_0, rand_##type##1_1 ); \
+if (temp_##type##1 != func##_rand_##type##1_##type##1) { \
+ rsDebug(#func " " #type "1 operation did not match!", 0); \
+ rsDebug("v1", rand_##type##1_0); \
+ rsDebug("v2", rand_##type##1_1); \
+ rsDebug("Dalvik result", func##_rand_##type##1_##type##1); \
+ rsDebug("Renderscript result", temp_##type##1); \
+ failed = true; \
+}
+#define TEST_VEC2_VEC2(func, type) \
+temp_##type##2 = func( rand_##type##2_0, rand_##type##2_1 ); \
+if (temp_##type##2 .x != func##_rand_##type##2_##type##2 .x \
+ || temp_##type##2 .y != func##_rand_##type##2_##type##2 .y) { \
+ rsDebug(#func " " #type "2 operation did not match!", 0); \
+ rsDebug("v1.x", rand_##type##2_0 .x); \
+ rsDebug("v1.y", rand_##type##2_0 .y); \
+ rsDebug("v2.x", rand_##type##2_1 .x); \
+ rsDebug("v2.y", rand_##type##2_1 .y); \
+ rsDebug("Dalvik result .x", func##_rand_##type##2_##type##2 .x); \
+ rsDebug("Dalvik result .y", func##_rand_##type##2_##type##2 .y); \
+ rsDebug("Renderscript result .x", temp_##type##2 .x); \
+ rsDebug("Renderscript result .y", temp_##type##2 .y); \
failed = true; \
}
+#define TEST_VEC3_VEC3(func, type) \
+temp_##type##3 = func( rand_##type##3_0, rand_##type##3_1 ); \
+if (temp_##type##3 .x != func##_rand_##type##3_##type##3 .x \
+ || temp_##type##3 .y != func##_rand_##type##3_##type##3 .y \
+ || temp_##type##3 .z != func##_rand_##type##3_##type##3 .z) { \
+ rsDebug(#func " " #type "3 operation did not match!", 0); \
+ rsDebug("v1.x", rand_##type##3_0 .x); \
+ rsDebug("v1.y", rand_##type##3_0 .y); \
+ rsDebug("v1.z", rand_##type##3_0 .z); \
+ rsDebug("v2.x", rand_##type##3_1 .x); \
+ rsDebug("v2.y", rand_##type##3_1 .y); \
+ rsDebug("v2.z", rand_##type##3_1 .z); \
+ rsDebug("Dalvik result .x", func##_rand_##type##3_##type##3 .x); \
+ rsDebug("Dalvik result .y", func##_rand_##type##3_##type##3 .y); \
+ rsDebug("Dalvik result .z", func##_rand_##type##3_##type##3 .z); \
+ rsDebug("Renderscript result .x", temp_##type##3 .x); \
+ rsDebug("Renderscript result .y", temp_##type##3 .y); \
+ rsDebug("Renderscript result .z", temp_##type##3 .z); \
+ failed = true; \
+}
+#define TEST_VEC4_VEC4(func, type) \
+temp_##type##4 = func( rand_##type##4_0, rand_##type##4_1 ); \
+if (temp_##type##4 .x != func##_rand_##type##4_##type##4 .x \
+ || temp_##type##4 .y != func##_rand_##type##4_##type##4 .y \
+ || temp_##type##4 .z != func##_rand_##type##4_##type##4 .z \
+ || temp_##type##4 .w != func##_rand_##type##4_##type##4 .w) { \
+ rsDebug(#func " " #type "4 operation did not match!", 0); \
+ rsDebug("v1.x", rand_##type##4_0 .x); \
+ rsDebug("v1.y", rand_##type##4_0 .y); \
+ rsDebug("v1.z", rand_##type##4_0 .z); \
+ rsDebug("v1.w", rand_##type##4_0 .w); \
+ rsDebug("v2.x", rand_##type##4_1 .x); \
+ rsDebug("v2.y", rand_##type##4_1 .y); \
+ rsDebug("v2.z", rand_##type##4_1 .z); \
+ rsDebug("v2.w", rand_##type##4_1 .w); \
+ rsDebug("Dalvik result .x", func##_rand_##type##4_##type##4 .x); \
+ rsDebug("Dalvik result .y", func##_rand_##type##4_##type##4 .y); \
+ rsDebug("Dalvik result .z", func##_rand_##type##4_##type##4 .z); \
+ rsDebug("Dalvik result .w", func##_rand_##type##4_##type##4 .w); \
+ rsDebug("Renderscript result .x", temp_##type##4 .x); \
+ rsDebug("Renderscript result .y", temp_##type##4 .y); \
+ rsDebug("Renderscript result .z", temp_##type##4 .z); \
+ rsDebug("Renderscript result .w", temp_##type##4 .w); \
+ failed = true; \
+}
+
+#define TEST_SC1_SC1(func) TEST_VEC1_VEC1(func, sc)
+#define TEST_SC2_SC2(func) TEST_VEC2_VEC2(func, sc)
+#define TEST_SC3_SC3(func) TEST_VEC3_VEC3(func, sc)
+#define TEST_SC4_SC4(func) TEST_VEC4_VEC4(func, sc)
+
+#define TEST_UC1_UC1(func) TEST_VEC1_VEC1(func, uc)
+#define TEST_UC2_UC2(func) TEST_VEC2_VEC2(func, uc)
+#define TEST_UC3_UC3(func) TEST_VEC3_VEC3(func, uc)
+#define TEST_UC4_UC4(func) TEST_VEC4_VEC4(func, uc)
+
+#define TEST_SS1_SS1(func) TEST_VEC1_VEC1(func, ss)
+#define TEST_SS2_SS2(func) TEST_VEC2_VEC2(func, ss)
+#define TEST_SS3_SS3(func) TEST_VEC3_VEC3(func, ss)
+#define TEST_SS4_SS4(func) TEST_VEC4_VEC4(func, ss)
+
+#define TEST_US1_US1(func) TEST_VEC1_VEC1(func, us)
+#define TEST_US2_US2(func) TEST_VEC2_VEC2(func, us)
+#define TEST_US3_US3(func) TEST_VEC3_VEC3(func, us)
+#define TEST_US4_US4(func) TEST_VEC4_VEC4(func, us)
+
+#define TEST_SI1_SI1(func) TEST_VEC1_VEC1(func, si)
+#define TEST_SI2_SI2(func) TEST_VEC2_VEC2(func, si)
+#define TEST_SI3_SI3(func) TEST_VEC3_VEC3(func, si)
+#define TEST_SI4_SI4(func) TEST_VEC4_VEC4(func, si)
+
+#define TEST_UI1_UI1(func) TEST_VEC1_VEC1(func, ui)
+#define TEST_UI2_UI2(func) TEST_VEC2_VEC2(func, ui)
+#define TEST_UI3_UI3(func) TEST_VEC3_VEC3(func, ui)
+#define TEST_UI4_UI4(func) TEST_VEC4_VEC4(func, ui)
+
+#define TEST_SL1_SL1(func) TEST_VEC1_VEC1(func, sl)
+#define TEST_SL2_SL2(func) TEST_VEC2_VEC2(func, sl)
+#define TEST_SL3_SL3(func) TEST_VEC3_VEC3(func, sl)
+#define TEST_SL4_SL4(func) TEST_VEC4_VEC4(func, sl)
+
+#define TEST_UL1_UL1(func) TEST_VEC1_VEC1(func, ul)
+#define TEST_UL2_UL2(func) TEST_VEC2_VEC2(func, ul)
+#define TEST_UL3_UL3(func) TEST_VEC3_VEC3(func, ul)
+#define TEST_UL4_UL4(func) TEST_VEC4_VEC4(func, ul)
+
+#define TEST_SC_SC_ALL(func) \
+TEST_SC1_SC1(func) \
+TEST_SC2_SC2(func) \
+TEST_SC3_SC3(func) \
+TEST_SC4_SC4(func)
+#define TEST_UC_UC_ALL(func) \
+TEST_UC1_UC1(func) \
+TEST_UC2_UC2(func) \
+TEST_UC3_UC3(func) \
+TEST_UC4_UC4(func)
+
+#define TEST_SS_SS_ALL(func) \
+TEST_SS1_SS1(func) \
+TEST_SS2_SS2(func) \
+TEST_SS3_SS3(func) \
+TEST_SS4_SS4(func)
+#define TEST_US_US_ALL(func) \
+TEST_US1_US1(func) \
+TEST_US2_US2(func) \
+TEST_US3_US3(func) \
+TEST_US4_US4(func)
+#define TEST_SI_SI_ALL(func) \
+TEST_SI1_SI1(func) \
+TEST_SI2_SI2(func) \
+TEST_SI3_SI3(func) \
+TEST_SI4_SI4(func)
+#define TEST_UI_UI_ALL(func) \
+TEST_UI1_UI1(func) \
+TEST_UI2_UI2(func) \
+TEST_UI3_UI3(func) \
+TEST_UI4_UI4(func)
+#define TEST_SL_SL_ALL(func) \
+TEST_SL1_SL1(func) \
+TEST_SL2_SL2(func) \
+TEST_SL3_SL3(func) \
+TEST_SL4_SL4(func)
+#define TEST_UL_UL_ALL(func) \
+TEST_UL1_UL1(func) \
+TEST_UL2_UL2(func) \
+TEST_UL3_UL3(func) \
+TEST_UL4_UL4(func)
+
+#define TEST_VEC_VEC_ALL(func) \
+TEST_FN_FN_ALL(func) \
+TEST_SS_SS_ALL(func) \
+TEST_SI_SI_ALL(func)
+// FIXME: Add tests back in once bug 6764163 is fixed
+#if 0
+TEST_SC_SC_ALL(func) \
+TEST_US_US_ALL(func) \
+TEST_UC_UC_ALL(func) \
+TEST_UI_UI_ALL(func)
+#endif
+// TODO: add long types to ALL macro
+#if 0
+TEST_SL_SL_ALL(func) \
+TEST_UL_UL_ALL(func)
+#endif
+
+#define DECLARE_TEMP_SET(type, abbrev) \
+volatile type temp_##abbrev##1; \
+volatile type##2 temp_##abbrev##2; \
+volatile type##3 temp_##abbrev##3; \
+volatile type##4 temp_##abbrev##4;
+
+#define DECLARE_ALL_TEMP_SETS() \
+DECLARE_TEMP_SET(float, f); \
+DECLARE_TEMP_SET(char, sc); \
+DECLARE_TEMP_SET(uchar, uc); \
+DECLARE_TEMP_SET(short, ss); \
+DECLARE_TEMP_SET(ushort, us); \
+DECLARE_TEMP_SET(int, si); \
+DECLARE_TEMP_SET(uint, ui); \
+DECLARE_TEMP_SET(long, sl); \
+DECLARE_TEMP_SET(ulong, ul);
static bool test_math_agree() {
bool failed = false;
- float result = 0.0;
- TEST_OP(+, add);
- TEST_OP(-, sub);
- TEST_OP(*, mul);
- TEST_OP(/, div);
+ DECLARE_ALL_TEMP_SETS();
+
+ TEST_BASIC_FLOAT_OP(+, add);
+ TEST_BASIC_FLOAT_OP(-, sub);
+ TEST_BASIC_FLOAT_OP(*, mul);
+ TEST_BASIC_FLOAT_OP(/, div);
+
+ TEST_VEC_VEC_ALL(min);
+ TEST_VEC_VEC_ALL(max);
+ TEST_FN_FN_ALL(fmin);
+ TEST_FN_F_ALL(fmin);
+ TEST_FN_FN_ALL(fmax);
+ TEST_FN_F_ALL(fmax);
if (failed) {
rsDebug("test_math_agree FAILED", 0);