Merge "Update RSTest_v14 for stride changes." into jb-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9f6421a365
@@ -39,6 +39,7 @@ public class UT_alloc extends UnitTest {
|
||||
typeBuilder.setX(X).setY(Y);
|
||||
Allocation A = Allocation.createTyped(RS, typeBuilder.create());
|
||||
s.bind_a(A);
|
||||
s.set_aRaw(A);
|
||||
|
||||
typeBuilder = new Type.Builder(RS, Element.I32(RS));
|
||||
typeBuilder.setX(X).setY(Y).setFaces(true);
|
||||
@@ -56,9 +57,10 @@ public class UT_alloc extends UnitTest {
|
||||
|
||||
public void run() {
|
||||
RenderScript pRS = RenderScript.create(mCtx);
|
||||
ScriptC_alloc s = new ScriptC_alloc(pRS, mRes, R.raw.alloc);
|
||||
ScriptC_alloc s = new ScriptC_alloc(pRS);
|
||||
pRS.setMessageHandler(mRsMessage);
|
||||
initializeGlobals(pRS, s);
|
||||
s.forEach_root(s.get_aRaw());
|
||||
s.invoke_alloc_test();
|
||||
pRS.finish();
|
||||
waitForMessage();
|
||||
|
||||
@@ -37,17 +37,18 @@ public class UT_foreach extends UnitTest {
|
||||
s.set_dimY(Y);
|
||||
typeBuilder.setX(X).setY(Y);
|
||||
A = Allocation.createTyped(RS, typeBuilder.create());
|
||||
s.bind_a(A);
|
||||
s.set_aRaw(A);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
RenderScript pRS = RenderScript.create(mCtx);
|
||||
ScriptC_foreach s = new ScriptC_foreach(pRS, mRes, R.raw.foreach);
|
||||
ScriptC_foreach s = new ScriptC_foreach(pRS);
|
||||
pRS.setMessageHandler(mRsMessage);
|
||||
initializeGlobals(pRS, s);
|
||||
s.forEach_root(A);
|
||||
s.invoke_verify_root();
|
||||
s.invoke_foreach_test();
|
||||
pRS.finish();
|
||||
waitForMessage();
|
||||
|
||||
@@ -5,39 +5,37 @@ int dimX;
|
||||
int dimY;
|
||||
int dimZ;
|
||||
|
||||
rs_allocation aRaw;
|
||||
rs_allocation aFaces;
|
||||
rs_allocation aLOD;
|
||||
rs_allocation aFacesLOD;
|
||||
|
||||
void root(int *o, uint32_t x, uint32_t y) {
|
||||
*o = x + y * dimX;
|
||||
}
|
||||
|
||||
static bool test_alloc_dims() {
|
||||
bool failed = false;
|
||||
int i, j;
|
||||
|
||||
for (j = 0; j < dimY; j++) {
|
||||
for (i = 0; i < dimX; i++) {
|
||||
a[i + j * dimX] = i + j * dimX;
|
||||
}
|
||||
}
|
||||
|
||||
rs_allocation alloc = rsGetAllocation(a);
|
||||
_RS_ASSERT(rsAllocationGetDimX(alloc) == dimX);
|
||||
_RS_ASSERT(rsAllocationGetDimY(alloc) == dimY);
|
||||
_RS_ASSERT(rsAllocationGetDimZ(alloc) == dimZ);
|
||||
_RS_ASSERT(rsAllocationGetDimX(aRaw) == dimX);
|
||||
_RS_ASSERT(rsAllocationGetDimY(aRaw) == dimY);
|
||||
_RS_ASSERT(rsAllocationGetDimZ(aRaw) == dimZ);
|
||||
|
||||
// Test 2D addressing
|
||||
for (j = 0; j < dimY; j++) {
|
||||
for (i = 0; i < dimX; i++) {
|
||||
rsDebug("Verifying ", i + j * dimX);
|
||||
const void *p = rsGetElementAt(alloc, i, j);
|
||||
const void *p = rsGetElementAt(aRaw, i, j);
|
||||
int val = *(const int *)p;
|
||||
_RS_ASSERT(val == (i + j * dimX));
|
||||
}
|
||||
}
|
||||
|
||||
// Test 1D addressing
|
||||
for (i = 0; i < dimX * dimY; i++) {
|
||||
for (i = 0; i < dimX; i++) {
|
||||
rsDebug("Verifying ", i);
|
||||
const void *p = rsGetElementAt(alloc, i);
|
||||
const void *p = rsGetElementAt(aRaw, i);
|
||||
int val = *(const int *)p;
|
||||
_RS_ASSERT(val == i);
|
||||
}
|
||||
@@ -46,7 +44,7 @@ static bool test_alloc_dims() {
|
||||
for (j = 0; j < dimY; j++) {
|
||||
for (i = 0; i < dimX; i++) {
|
||||
rsDebug("Verifying ", i + j * dimX);
|
||||
const void *p = rsGetElementAt(alloc, i, j, 0);
|
||||
const void *p = rsGetElementAt(aRaw, i, j, 0);
|
||||
int val = *(const int *)p;
|
||||
_RS_ASSERT(val == (i + j * dimX));
|
||||
}
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
#include "shared.rsh"
|
||||
|
||||
int *a;
|
||||
rs_allocation aRaw;
|
||||
int dimX;
|
||||
int dimY;
|
||||
static bool failed = false;
|
||||
|
||||
void root(int *out, uint32_t x, uint32_t y) {
|
||||
*out = x + y * dimX;
|
||||
}
|
||||
|
||||
static bool test_foreach_output() {
|
||||
static bool test_root_output() {
|
||||
bool failed = false;
|
||||
int i, j;
|
||||
|
||||
for (j = 0; j < dimY; j++) {
|
||||
for (i = 0; i < dimX; i++) {
|
||||
_RS_ASSERT(a[i + j * dimX] == (i + j * dimX));
|
||||
int v = rsGetElementAt_int(aRaw, i, j);
|
||||
_RS_ASSERT(v == (i + j * dimX));
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
rsDebug("test_foreach_output FAILED", 0);
|
||||
rsDebug("test_root_output FAILED", 0);
|
||||
}
|
||||
else {
|
||||
rsDebug("test_foreach_output PASSED", 0);
|
||||
rsDebug("test_root_output PASSED", 0);
|
||||
}
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
void foreach_test() {
|
||||
bool failed = false;
|
||||
failed |= test_foreach_output();
|
||||
void verify_root() {
|
||||
failed |= test_root_output();
|
||||
}
|
||||
|
||||
void foreach_test() {
|
||||
if (failed) {
|
||||
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user