Fix bug in modf library function (plus typos).
Change-Id: I643c905e2e3e2dcf7a61f1d027b749d9a0d6e542
This commit is contained in:
@@ -68,6 +68,7 @@ public class RSTestCore {
|
|||||||
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
|
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
|
||||||
unitTests.add(new UT_rstime(this, mRes, mCtx));
|
unitTests.add(new UT_rstime(this, mRes, mCtx));
|
||||||
unitTests.add(new UT_rstypes(this, mRes, mCtx));
|
unitTests.add(new UT_rstypes(this, mRes, mCtx));
|
||||||
|
unitTests.add(new UT_math(this, mRes, mCtx));
|
||||||
unitTests.add(new UT_fp_mad(this, mRes, mCtx));
|
unitTests.add(new UT_fp_mad(this, mRes, mCtx));
|
||||||
/*
|
/*
|
||||||
unitTests.add(new UnitTest(null, "<Pass>", 1));
|
unitTests.add(new UnitTest(null, "<Pass>", 1));
|
||||||
|
|||||||
40
libs/rs/java/tests/src/com/android/rs/test/UT_math.java
Normal file
40
libs/rs/java/tests/src/com/android/rs/test/UT_math.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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.test;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.renderscript.*;
|
||||||
|
|
||||||
|
public class UT_math extends UnitTest {
|
||||||
|
private Resources mRes;
|
||||||
|
|
||||||
|
protected UT_math(RSTestCore rstc, Resources res, Context ctx) {
|
||||||
|
super(rstc, "Math", ctx);
|
||||||
|
mRes = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
RenderScript pRS = RenderScript.create(mCtx);
|
||||||
|
ScriptC_math s = new ScriptC_math(pRS, mRes, R.raw.math);
|
||||||
|
pRS.setMessageHandler(mRsMessage);
|
||||||
|
s.invoke_math_test(0, 0);
|
||||||
|
pRS.finish();
|
||||||
|
waitForMessage();
|
||||||
|
pRS.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
65
libs/rs/java/tests/src/com/android/rs/test/math.rs
Normal file
65
libs/rs/java/tests/src/com/android/rs/test/math.rs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#include "shared.rsh"
|
||||||
|
|
||||||
|
// Testing math library
|
||||||
|
|
||||||
|
volatile float f1;
|
||||||
|
volatile float2 f2;
|
||||||
|
volatile float3 f3;
|
||||||
|
volatile float4 f4;
|
||||||
|
|
||||||
|
#define TEST_F(fnc, var) \
|
||||||
|
rsDebug("Testing " #fnc, 0); \
|
||||||
|
var##1 = fnc(var##1); \
|
||||||
|
var##2 = fnc(var##2); \
|
||||||
|
var##3 = fnc(var##3); \
|
||||||
|
var##4 = fnc(var##4);
|
||||||
|
|
||||||
|
#define TEST_FP(fnc, var) \
|
||||||
|
rsDebug("Testing " #fnc, 0); \
|
||||||
|
var##1 = fnc(var##1, (float*) &f1); \
|
||||||
|
var##2 = fnc(var##2, (float2*) &f2); \
|
||||||
|
var##3 = fnc(var##3, (float3*) &f3); \
|
||||||
|
var##4 = fnc(var##4, (float4*) &f4);
|
||||||
|
|
||||||
|
#define TEST_F2(fnc, var) \
|
||||||
|
rsDebug("Testing " #fnc, 0); \
|
||||||
|
var##1 = fnc(var##1, var##1); \
|
||||||
|
var##2 = fnc(var##2, var##2); \
|
||||||
|
var##3 = fnc(var##3, var##3); \
|
||||||
|
var##4 = fnc(var##4, var##4);
|
||||||
|
|
||||||
|
static bool test_math(uint32_t index) {
|
||||||
|
bool failed = false;
|
||||||
|
start();
|
||||||
|
|
||||||
|
TEST_F(cos, f);
|
||||||
|
TEST_FP(modf, f);
|
||||||
|
TEST_F2(pow, f);
|
||||||
|
TEST_F(sin, f);
|
||||||
|
TEST_F(sqrt, f);
|
||||||
|
|
||||||
|
|
||||||
|
float time = end(index);
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
rsDebug("test_math FAILED", time);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rsDebug("test_math PASSED", time);
|
||||||
|
}
|
||||||
|
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void math_test(uint32_t index, int test_num) {
|
||||||
|
bool failed = false;
|
||||||
|
failed |= test_math(index);
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ static ScriptCState::SymbolTable_t gSyms[] = {
|
|||||||
{ "_Z5log1pf", (void *)&log1pf, true },
|
{ "_Z5log1pf", (void *)&log1pf, true },
|
||||||
//{ "logb", (void *)&, true },
|
//{ "logb", (void *)&, true },
|
||||||
//{ "mad", (void *)&, true },
|
//{ "mad", (void *)&, true },
|
||||||
{ "modf", (void *)&modff, true },
|
{ "_Z4modffPf", (void *)&modff, true },
|
||||||
//{ "nan", (void *)&, true },
|
//{ "nan", (void *)&, true },
|
||||||
{ "_Z9nextafterff", (void *)&nextafterf, true },
|
{ "_Z9nextafterff", (void *)&nextafterf, true },
|
||||||
{ "_Z3powff", (void *)&powf, true },
|
{ "_Z3powff", (void *)&powf, true },
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ _RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2) { \
|
|||||||
r.x = fnc(v1.x, v2.x); \
|
r.x = fnc(v1.x, v2.x); \
|
||||||
r.y = fnc(v1.y, v2.y); \
|
r.y = fnc(v1.y, v2.y); \
|
||||||
r.z = fnc(v1.z, v2.z); \
|
r.z = fnc(v1.z, v2.z); \
|
||||||
r.w = fnc(v1.w, v2.z); \
|
r.w = fnc(v1.w, v2.w); \
|
||||||
return r; \
|
return r; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +136,40 @@ _RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float v2) { \
|
|||||||
return r; \
|
return r; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DEF_FUNC_2P(fnc) \
|
||||||
|
_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, float2 *v2) { \
|
||||||
|
float2 r; \
|
||||||
|
float q; \
|
||||||
|
r.x = fnc(v1.x, &q); \
|
||||||
|
v2->x = q; \
|
||||||
|
r.y = fnc(v1.y, &q); \
|
||||||
|
v2->y = q; \
|
||||||
|
return r; \
|
||||||
|
} \
|
||||||
|
_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, float3 *v2) { \
|
||||||
|
float3 r; \
|
||||||
|
float q; \
|
||||||
|
r.x = fnc(v1.x, &q); \
|
||||||
|
v2->x = q; \
|
||||||
|
r.y = fnc(v1.y, &q); \
|
||||||
|
v2->y = q; \
|
||||||
|
r.z = fnc(v1.z, &q); \
|
||||||
|
v2->z = q; \
|
||||||
|
return r; \
|
||||||
|
} \
|
||||||
|
_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float4 *v2) { \
|
||||||
|
float4 r; \
|
||||||
|
float q; \
|
||||||
|
r.x = fnc(v1.x, &q); \
|
||||||
|
v2->x = q; \
|
||||||
|
r.y = fnc(v1.y, &q); \
|
||||||
|
v2->y = q; \
|
||||||
|
r.z = fnc(v1.z, &q); \
|
||||||
|
v2->z = q; \
|
||||||
|
r.w = fnc(v1.w, &q); \
|
||||||
|
v2->w = q; \
|
||||||
|
return r; \
|
||||||
|
}
|
||||||
|
|
||||||
extern float __attribute__((overloadable)) acos(float);
|
extern float __attribute__((overloadable)) acos(float);
|
||||||
DEF_FUNC_1(acos)
|
DEF_FUNC_1(acos)
|
||||||
@@ -333,9 +367,7 @@ extern float3 __attribute__((overloadable)) mad(float3, float3, float3);
|
|||||||
extern float4 __attribute__((overloadable)) mad(float4, float4, float4);
|
extern float4 __attribute__((overloadable)) mad(float4, float4, float4);
|
||||||
|
|
||||||
extern float __attribute__((overloadable)) modf(float, float *);
|
extern float __attribute__((overloadable)) modf(float, float *);
|
||||||
extern float2 __attribute__((overloadable)) modf(float2, float2 *);
|
DEF_FUNC_2P(modf);
|
||||||
extern float3 __attribute__((overloadable)) modf(float3, float3 *);
|
|
||||||
extern float4 __attribute__((overloadable)) modf(float4, float4 *);
|
|
||||||
|
|
||||||
//extern float __attribute__((overloadable)) nan(uint);
|
//extern float __attribute__((overloadable)) nan(uint);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user