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