diff options
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java | 57 | ||||
-rw-r--r-- | libs/rs/java/tests/src/com/android/rs/test/UnitTest.java | 20 | ||||
-rw-r--r-- | libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs | 2 | ||||
-rw-r--r-- | libs/rs/java/tests/src/com/android/rs/test/primitives.rs | 4 | ||||
-rw-r--r-- | libs/rs/java/tests/src/com/android/rs/test/rslist.rs | 21 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 17 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 2 | ||||
-rw-r--r-- | libs/rs/rsScriptC.cpp | 10 |
8 files changed, 100 insertions, 33 deletions
diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java index cd8f814..dbc9133 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java @@ -40,6 +40,8 @@ public class RSTestCore { private ScriptC_rslist mScript; private ArrayList<UnitTest> unitTests; + private ListIterator<UnitTest> test_iter; + private UnitTest activeTest; public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; @@ -54,9 +56,13 @@ public class RSTestCore { unitTests.add(new UT_primitives(this, mRes)); unitTests.add(new UT_fp_mad(this, mRes)); /* - unitTests.add(new UnitTest("<Pass>", 1)); + unitTests.add(new UnitTest(null, "<Pass>", 1)); unitTests.add(new UnitTest()); - unitTests.add(new UnitTest("<Fail>", -1)); + unitTests.add(new UnitTest(null, "<Fail>", -1)); + + for (int i = 0; i < 20; i++) { + unitTests.add(new UnitTest(null, "<Pass>", 1)); + } */ UnitTest [] uta = new UnitTest[unitTests.size()]; @@ -71,19 +77,6 @@ public class RSTestCore { uta[i].setItem(listElem); } - /* Run the actual unit tests */ - ListIterator<UnitTest> test_iter = unitTests.listIterator(); - while (test_iter.hasNext()) { - UnitTest t = test_iter.next(); - t.start(); - /* - try { - t.join(); - } catch (InterruptedException e) { - } - */ - } - mListAllocs.copyAll(); mScript.bind_gList(mListAllocs); @@ -92,10 +85,40 @@ public class RSTestCore { mScript.set_gFont(mFont); mRS.contextBindRootScript(mScript); - mRS.finish(); + + test_iter = unitTests.listIterator(); + refreshTestResults(); /* Kick off the first test */ + } + + static int count = 0; + public void checkAndRunNextTest() { + if (activeTest != null) { + if (!activeTest.isAlive()) { + /* Properly clean up on our last test */ + try { + activeTest.join(); + } + catch (InterruptedException e) { + } + activeTest = null; + } + } + + if (activeTest == null) { + if (test_iter.hasNext()) { + activeTest = test_iter.next(); + activeTest.start(); + /* This routine will only get called once when a new test + * should start running. The message handler in UnitTest.java + * ensures this. */ + } + } + count++; } public void refreshTestResults() { + checkAndRunNextTest(); + if (mListAllocs != null && mScript != null && mRS != null) { mListAllocs.copyAll(); @@ -111,6 +134,7 @@ public class RSTestCore { mScript.set_gDY(0.0f); mLastX = x; mLastY = y; + refreshTestResults(); } public void onActionMove(int x, int y) { @@ -125,5 +149,6 @@ public class RSTestCore { mLastX = x; mLastY = y; + refreshTestResults(); } } diff --git a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java index d98b763..5eb0d67 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java +++ b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java @@ -16,6 +16,7 @@ package com.android.rs.test; import android.renderscript.RenderScript.RSMessage; +import android.util.Log; public class UnitTest extends Thread { public String name; @@ -27,11 +28,15 @@ public class UnitTest extends Thread { public static final int RS_MSG_TEST_PASSED = 100; public static final int RS_MSG_TEST_FAILED = 101; + private static int numTests = 0; + public int testID; + protected UnitTest(RSTestCore rstc, String n, int initResult) { super(); mRSTC = rstc; name = n; result = initResult; + testID = numTests++; } protected UnitTest(RSTestCore rstc, String n) { @@ -56,12 +61,20 @@ public class UnitTest extends Thread { result = -1; break; default: - break; + android.util.Log.v("RenderScript", "Unit test got unexpected message"); + return; } if (mItem != null) { mItem.result = result; - mRSTC.refreshTestResults(); + try { + mRSTC.refreshTestResults(); + } + catch (IllegalStateException e) { + /* Ignore the case where our message receiver has been + disconnected. This happens when we leave the application + before it finishes running all of the unit tests. */ + } } } }; @@ -72,6 +85,9 @@ public class UnitTest extends Thread { public void run() { /* This method needs to be implemented for each subclass */ + if (mRSTC != null) { + mRSTC.refreshTestResults(); + } } } diff --git a/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs b/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs index eb82e56..dfd77e6 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/fp_mad.rs @@ -170,7 +170,7 @@ void fp_mad_test(uint32_t index, int test_num) { // TODO Actually verify test result accuracy rsDebug("fp_mad_test PASSED", 0); - rsSendToClient(RS_MSG_TEST_PASSED); + rsSendToClientBlocking(RS_MSG_TEST_PASSED); } diff --git a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs index 2ba5d52..5312bcc 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs @@ -42,10 +42,10 @@ void primitives_test(uint32_t index, int test_num) { failed |= test_primitive_types(index); if (failed) { - rsSendToClient(RS_MSG_TEST_FAILED); + rsSendToClientBlocking(RS_MSG_TEST_FAILED); } else { - rsSendToClient(RS_MSG_TEST_PASSED); + rsSendToClientBlocking(RS_MSG_TEST_PASSED); } } diff --git a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs index 72d1850..a5f0f6b 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/rslist.rs +++ b/libs/rs/java/tests/src/com/android/rs/test/rslist.rs @@ -56,6 +56,27 @@ int root(int launchID) { int height = rsgGetHeight(); int itemHeight = 80; + int totalItemHeight = itemHeight * allocSize; + + /* Prevent scrolling above the top of the list */ + int firstItem = height - totalItemHeight; + if (firstItem < 0) { + firstItem = 0; + } + + /* Prevent scrolling past the last line of the list */ + int lastItem = -1 * (totalItemHeight - height); + if (lastItem > 0) { + lastItem = 0; + } + + if (textPos > firstItem) { + textPos = firstItem; + } + else if (textPos < lastItem) { + textPos = lastItem; + } + int currentYPos = itemHeight + textPos; for(int i = 0; i < allocSize; i ++) { diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 3681bc2..a7f380f 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -33,6 +33,8 @@ #include <GLES2/gl2ext.h> #include <cutils/sched_policy.h> +#include <sys/syscall.h> +#include <string.h> using namespace android; using namespace android::renderscript; @@ -371,11 +373,15 @@ void * Context::helperThreadProc(void *vrsc) rsc->mWorkers.mLaunchSignals[idx].init(); rsc->mWorkers.mNativeThreadId[idx] = gettid(); - //cpu_set_t cpset[16]; - //int ret = sched_getaffinity(rsc->mWorkers.mNativeThreadId[idx], sizeof(cpset), &cpset); - //LOGE("ret = %i", ret); - -//sched_setaffinity +#if 0 + typedef struct {uint64_t bits[1024 / 64]; } cpu_set_t; + cpu_set_t cpuset; + memset(&cpuset, 0, sizeof(cpuset)); + cpuset.bits[idx / 64] |= 1ULL << (idx % 64); + int ret = syscall(241, rsc->mWorkers.mNativeThreadId[idx], + sizeof(cpuset), &cpuset); + LOGE("SETAFFINITY ret = %i %s", ret, EGLUtils::strerror(ret)); +#endif setpriority(PRIO_PROCESS, rsc->mWorkers.mNativeThreadId[idx], rsc->mThreadPriority); while(rsc->mRunning) { @@ -490,6 +496,7 @@ Context::Context(Device *dev, bool isGraphics, bool useDepth) usleep(100); } + mWorkers.mCompleteSignal.init(); mWorkers.mRunningCount = 0; mWorkers.mLaunchCount = 0; for (uint32_t ct=0; ct < mWorkers.mCount; ct++) { diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index bce9c13..b85d2a8 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -174,7 +174,7 @@ public: uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;} void launchThreads(WorkerCallback_t cbk, void *data); - uint32_t getWorkerPoolSize() const {return (uint32_t)mWorkers.mRunningCount;} + uint32_t getWorkerPoolSize() const {return (uint32_t)mWorkers.mCount;} protected: Device *mDev; diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index f905492..e9621b9 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -201,7 +201,7 @@ static void wc_xy(void *usr, uint32_t idx) } //LOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd); - + //LOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut); for (uint32_t y = yStart; y < yEnd; y++) { uint32_t offset = mtls->dimX * y; uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * offset); @@ -296,14 +296,12 @@ void ScriptC::runForEach(Context *rsc, mtls.eStrideOut = aout->getType()->getElementSizeBytes(); } - - if ((rsc->getWorkerPoolSize() > 1) && mEnviroment.mIsThreadable && - ((mtls.dimY * mtls.dimZ * mtls.dimArray) > 1)) { + if ((rsc->getWorkerPoolSize() > 1) && mEnviroment.mIsThreadable && (mtls.dimY > 1)) { //LOGE("launch 1"); rsc->launchThreads(wc_xy, &mtls); - //LOGE("launch 2"); } else { + //LOGE("launch 3"); for (uint32_t ar = mtls.arrayStart; ar < mtls.arrayEnd; ar++) { for (uint32_t z = mtls.zStart; z < mtls.zEnd; z++) { for (uint32_t y = mtls.yStart; y < mtls.yEnd; y++) { @@ -380,11 +378,11 @@ static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name) if (sym) { return sym->mPtr; } - s->mEnviroment.mIsThreadable = false; sym = ScriptCState::lookupSymbolCL(name); if (sym) { return sym->mPtr; } + s->mEnviroment.mIsThreadable = false; sym = ScriptCState::lookupSymbolGL(name); if (sym) { return sym->mPtr; |