am 9f6421a3: Merge "Update RSTest_v14 for stride changes." into jb-mr2-dev

* commit '9f6421a36574b3319d10d700a6e6e506e490ce66':
  Update RSTest_v14 for stride changes.
This commit is contained in:
Stephen Hines
2013-03-12 03:32:45 +00:00
committed by Android Git Automerger
4 changed files with 29 additions and 25 deletions

View File

@@ -39,6 +39,7 @@ public class UT_alloc extends UnitTest {
typeBuilder.setX(X).setY(Y); typeBuilder.setX(X).setY(Y);
Allocation A = Allocation.createTyped(RS, typeBuilder.create()); Allocation A = Allocation.createTyped(RS, typeBuilder.create());
s.bind_a(A); s.bind_a(A);
s.set_aRaw(A);
typeBuilder = new Type.Builder(RS, Element.I32(RS)); typeBuilder = new Type.Builder(RS, Element.I32(RS));
typeBuilder.setX(X).setY(Y).setFaces(true); typeBuilder.setX(X).setY(Y).setFaces(true);
@@ -56,9 +57,10 @@ public class UT_alloc extends UnitTest {
public void run() { public void run() {
RenderScript pRS = RenderScript.create(mCtx); 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); pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s); initializeGlobals(pRS, s);
s.forEach_root(s.get_aRaw());
s.invoke_alloc_test(); s.invoke_alloc_test();
pRS.finish(); pRS.finish();
waitForMessage(); waitForMessage();

View File

@@ -37,17 +37,18 @@ public class UT_foreach extends UnitTest {
s.set_dimY(Y); s.set_dimY(Y);
typeBuilder.setX(X).setY(Y); typeBuilder.setX(X).setY(Y);
A = Allocation.createTyped(RS, typeBuilder.create()); A = Allocation.createTyped(RS, typeBuilder.create());
s.bind_a(A); s.set_aRaw(A);
return; return;
} }
public void run() { public void run() {
RenderScript pRS = RenderScript.create(mCtx); 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); pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s); initializeGlobals(pRS, s);
s.forEach_root(A); s.forEach_root(A);
s.invoke_verify_root();
s.invoke_foreach_test(); s.invoke_foreach_test();
pRS.finish(); pRS.finish();
waitForMessage(); waitForMessage();

View File

@@ -5,39 +5,37 @@ int dimX;
int dimY; int dimY;
int dimZ; int dimZ;
rs_allocation aRaw;
rs_allocation aFaces; rs_allocation aFaces;
rs_allocation aLOD; rs_allocation aLOD;
rs_allocation aFacesLOD; rs_allocation aFacesLOD;
void root(int *o, uint32_t x, uint32_t y) {
*o = x + y * dimX;
}
static bool test_alloc_dims() { static bool test_alloc_dims() {
bool failed = false; bool failed = false;
int i, j; int i, j;
for (j = 0; j < dimY; j++) { _RS_ASSERT(rsAllocationGetDimX(aRaw) == dimX);
for (i = 0; i < dimX; i++) { _RS_ASSERT(rsAllocationGetDimY(aRaw) == dimY);
a[i + j * dimX] = i + j * dimX; _RS_ASSERT(rsAllocationGetDimZ(aRaw) == dimZ);
}
}
rs_allocation alloc = rsGetAllocation(a);
_RS_ASSERT(rsAllocationGetDimX(alloc) == dimX);
_RS_ASSERT(rsAllocationGetDimY(alloc) == dimY);
_RS_ASSERT(rsAllocationGetDimZ(alloc) == dimZ);
// Test 2D addressing // Test 2D addressing
for (j = 0; j < dimY; j++) { for (j = 0; j < dimY; j++) {
for (i = 0; i < dimX; i++) { for (i = 0; i < dimX; i++) {
rsDebug("Verifying ", i + j * dimX); rsDebug("Verifying ", i + j * dimX);
const void *p = rsGetElementAt(alloc, i, j); const void *p = rsGetElementAt(aRaw, i, j);
int val = *(const int *)p; int val = *(const int *)p;
_RS_ASSERT(val == (i + j * dimX)); _RS_ASSERT(val == (i + j * dimX));
} }
} }
// Test 1D addressing // Test 1D addressing
for (i = 0; i < dimX * dimY; i++) { for (i = 0; i < dimX; i++) {
rsDebug("Verifying ", i); rsDebug("Verifying ", i);
const void *p = rsGetElementAt(alloc, i); const void *p = rsGetElementAt(aRaw, i);
int val = *(const int *)p; int val = *(const int *)p;
_RS_ASSERT(val == i); _RS_ASSERT(val == i);
} }
@@ -46,7 +44,7 @@ static bool test_alloc_dims() {
for (j = 0; j < dimY; j++) { for (j = 0; j < dimY; j++) {
for (i = 0; i < dimX; i++) { for (i = 0; i < dimX; i++) {
rsDebug("Verifying ", i + j * dimX); 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; int val = *(const int *)p;
_RS_ASSERT(val == (i + j * dimX)); _RS_ASSERT(val == (i + j * dimX));
} }

View File

@@ -1,37 +1,40 @@
#include "shared.rsh" #include "shared.rsh"
int *a; rs_allocation aRaw;
int dimX; int dimX;
int dimY; int dimY;
static bool failed = false;
void root(int *out, uint32_t x, uint32_t y) { void root(int *out, uint32_t x, uint32_t y) {
*out = x + y * dimX; *out = x + y * dimX;
} }
static bool test_foreach_output() { static bool test_root_output() {
bool failed = false; bool failed = false;
int i, j; int i, j;
for (j = 0; j < dimY; j++) { for (j = 0; j < dimY; j++) {
for (i = 0; i < dimX; i++) { 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) { if (failed) {
rsDebug("test_foreach_output FAILED", 0); rsDebug("test_root_output FAILED", 0);
} }
else { else {
rsDebug("test_foreach_output PASSED", 0); rsDebug("test_root_output PASSED", 0);
} }
return failed; return failed;
} }
void foreach_test() { void verify_root() {
bool failed = false; failed |= test_root_output();
failed |= test_foreach_output(); }
void foreach_test() {
if (failed) { if (failed) {
rsSendToClientBlocking(RS_MSG_TEST_FAILED); rsSendToClientBlocking(RS_MSG_TEST_FAILED);
} }