summaryrefslogtreecommitdiff
path: root/tests/cppbasic/compute.cpp
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2012-11-06 14:38:06 -0800
committerTim Murray <timmurray@google.com>2012-11-06 14:39:16 -0800
commit943eb670c86242755f5af7460d46578243e0401e (patch)
tree2eef4d8b945b2f589e7b07da77d147ce1ae6e036 /tests/cppbasic/compute.cpp
parent7e0acabf072cda5bdff63e502c1e8e4c2727676b (diff)
Add latency test and rearrange tests directory.
Change-Id: I209b879350769a8e264c2afb67bdb7359c6894a0
Diffstat (limited to 'tests/cppbasic/compute.cpp')
-rw-r--r--tests/cppbasic/compute.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/cppbasic/compute.cpp b/tests/cppbasic/compute.cpp
new file mode 100644
index 00000000..fef116fb
--- /dev/null
+++ b/tests/cppbasic/compute.cpp
@@ -0,0 +1,57 @@
+
+#include "RenderScript.h"
+
+#include "ScriptC_mono.h"
+
+using namespace android;
+using namespace renderscriptCpp;
+
+int main(int argc, char** argv)
+{
+
+ sp<RS> rs = new RS();
+ printf("New RS %p\n", rs.get());
+
+ bool r = rs->init();
+ printf("Init returned %i\n", r);
+
+ sp<const Element> e = Element::RGBA_8888(rs);
+ printf("Element %p\n", e.get());
+
+ Type::Builder tb(rs, e);
+ tb.setX(128);
+ tb.setY(128);
+ sp<const Type> t = tb.create();
+ printf("Type %p\n", t.get());
+
+
+ sp<Allocation> a1 = Allocation::createSized(rs, e, 1000);
+ printf("Allocation %p\n", a1.get());
+
+ sp<Allocation> ain = Allocation::createTyped(rs, t);
+ sp<Allocation> aout = Allocation::createTyped(rs, t);
+ printf("Allocation %p %p\n", ain.get(), aout.get());
+
+ sp<ScriptC_mono> sc = new ScriptC_mono(rs, NULL, 0);
+ printf("new script\n");
+
+ uint32_t *buf = new uint32_t[t->getCount()];
+ for (uint32_t ct=0; ct < t->getCount(); ct++) {
+ buf[ct] = ct | (ct << 16);
+ }
+ //ain->copy1DRangeFrom(0, 128*128, (int32_t *)buf, 128*128*4);
+ ain->copy1DRangeFromUnchecked(0, t->getCount(), buf, t->getCount()*4);
+
+ sc->forEach_root(ain, aout);
+ printf("for each done\n");
+
+ printf("Deleting stuff\n");
+ sc.clear();
+ t.clear();
+ a1.clear();
+ e.clear();
+ ain.clear();
+ aout.clear();
+ // delete rs;
+ printf("Delete OK\n");
+}