InfiniteLoop.cpp revision 7d72c9e5ad10e85789a0bc2e63c3f918c609ae49
1#include <thread> 2#include <chrono> 3 4#include <RenderScript.h> 5 6#include "ScriptC_infiniteloop.h" 7 8int main() 9{ 10 static const int size = 64; 11 sp<RS> rs = new RS(); 12 13 rs->init("/data/rscache", RS_INIT_LOW_LATENCY); 14 15 auto e = Element::RGBA_8888(rs); 16 Type::Builder tb(rs, e); 17 tb.setX(size); 18 tb.setY(size); 19 auto t = tb.create(); 20 21 auto a = Allocation::createTyped(rs, t); 22 auto b = Allocation::createTyped(rs, t); 23 24 sp<ScriptC_infiniteloop> s = new ScriptC_infiniteloop(rs); 25 26 // Test is designed to loop forever, waits for two seconds 27 // between each invocation of the kernel 28 bool forever = true; 29 while(forever) 30 { 31 s->forEach_simple_kernel(a, b); 32 std::this_thread::sleep_for(std::chrono::seconds(2)); 33 } 34 35 uint32_t * output = new uint32_t[size*size]; 36 b->copy2DRangeTo(0, 0, size, size, output); 37 delete [] output; 38 39 return 0; 40} 41 42