Merge "Test clamp (full and relaxed precision)." into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dcc1996b76
@@ -69,6 +69,8 @@ public class RSTestCore {
|
||||
unitTests.add(new UT_vector(this, mRes, mCtx));
|
||||
unitTests.add(new UT_array_init(this, mRes, mCtx));
|
||||
unitTests.add(new UT_array_alloc(this, mRes, mCtx));
|
||||
unitTests.add(new UT_clamp(this, mRes, mCtx));
|
||||
unitTests.add(new UT_clamp_relaxed(this, mRes, mCtx));
|
||||
unitTests.add(new UT_convert(this, mRes, mCtx));
|
||||
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
|
||||
unitTests.add(new UT_rstime(this, mRes, mCtx));
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
|
||||
public class UT_clamp extends UnitTest {
|
||||
private Resources mRes;
|
||||
|
||||
protected UT_clamp(RSTestCore rstc, Resources res, Context ctx) {
|
||||
super(rstc, "Clamp (Full)", ctx);
|
||||
mRes = res;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
RenderScript pRS = RenderScript.create(mCtx);
|
||||
ScriptC_clamp s = new ScriptC_clamp(pRS, mRes, R.raw.clamp);
|
||||
pRS.setMessageHandler(mRsMessage);
|
||||
s.invoke_clamp_test();
|
||||
pRS.finish();
|
||||
waitForMessage();
|
||||
pRS.destroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
|
||||
public class UT_clamp_relaxed extends UnitTest {
|
||||
private Resources mRes;
|
||||
|
||||
protected UT_clamp_relaxed(RSTestCore rstc, Resources res, Context ctx) {
|
||||
super(rstc, "Clamp (Relaxed)", ctx);
|
||||
mRes = res;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
RenderScript pRS = RenderScript.create(mCtx);
|
||||
ScriptC_clamp_relaxed s =
|
||||
new ScriptC_clamp_relaxed(pRS, mRes, R.raw.clamp_relaxed);
|
||||
pRS.setMessageHandler(mRsMessage);
|
||||
s.invoke_clamp_test();
|
||||
pRS.finish();
|
||||
waitForMessage();
|
||||
pRS.destroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "shared.rsh"
|
||||
|
||||
static bool test_clamp_vector() {
|
||||
bool failed = false;
|
||||
|
||||
float2 src2 = { 2.0f, 2.0f};
|
||||
float2 min2 = { 0.5f, -3.0f};
|
||||
float2 max2 = { 1.0f, 9.0f};
|
||||
|
||||
float2 res2 = clamp(src2, min2, max2);
|
||||
_RS_ASSERT(res2.x == 1.0f);
|
||||
_RS_ASSERT(res2.y == 2.0f);
|
||||
|
||||
|
||||
float3 src3 = { 2.0f, 2.0f, 1.0f};
|
||||
float3 min3 = { 0.5f, -3.0f, 3.0f};
|
||||
float3 max3 = { 1.0f, 9.0f, 4.0f};
|
||||
|
||||
float3 res3 = clamp(src3, min3, max3);
|
||||
_RS_ASSERT(res3.x == 1.0f);
|
||||
_RS_ASSERT(res3.y == 2.0f);
|
||||
_RS_ASSERT(res3.z == 3.0f);
|
||||
|
||||
|
||||
float4 src4 = { 2.0f, 2.0f, 1.0f, 4.0f };
|
||||
float4 min4 = { 0.5f, -3.0f, 3.0f, 4.0f };
|
||||
float4 max4 = { 1.0f, 9.0f, 4.0f, 4.0f };
|
||||
|
||||
float4 res4 = clamp(src4, min4, max4);
|
||||
_RS_ASSERT(res4.x == 1.0f);
|
||||
_RS_ASSERT(res4.y == 2.0f);
|
||||
_RS_ASSERT(res4.z == 3.0f);
|
||||
_RS_ASSERT(res4.w == 4.0f);
|
||||
|
||||
if (failed) {
|
||||
rsDebug("test_clamp_vector FAILED", 0);
|
||||
}
|
||||
else {
|
||||
rsDebug("test_clamp_vector PASSED", 0);
|
||||
}
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
void clamp_test() {
|
||||
bool failed = false;
|
||||
failed |= test_clamp_vector();
|
||||
|
||||
if (failed) {
|
||||
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
|
||||
}
|
||||
else {
|
||||
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "clamp.rs"
|
||||
#pragma rs_fp_relaxed
|
||||
Reference in New Issue
Block a user