Home | History | Annotate | Download | only in cppf16
      1 #include "RenderScript.h"
      2 
      3 using namespace android;
      4 using namespace RSC;
      5 
      6 static const uint32_t dimX = 7, dimY = 5, dimZ = 3;
      7 
      8 void testAllocationCreation(sp<RS> rs, sp<const Element> e, uint32_t nDims) {
      9     Type::Builder tb(rs, e);
     10     tb.setX(dimX);
     11     if (nDims >= 2)
     12         tb.setY(dimY);
     13     if (nDims >= 3)
     14         tb.setZ(dimZ);
     15 
     16     sp<const Type> t = tb.create();
     17     sp<Allocation> alloc = Allocation::createTyped(rs, t);
     18 }
     19 
     20 int main(int , char** )
     21 {
     22     sp<RS> rs = new RS();
     23 
     24     bool r = rs->init("/system/bin");
     25 
     26     // Test ability to create 1D, 2D and 3D allocations of f16 scalars and
     27     // vectors
     28     sp<const Element> half = Element::F16(rs);
     29     sp<const Element> half2 = Element::F16_2(rs);
     30     sp<const Element> half3 = Element::F16_3(rs);
     31     sp<const Element> half4 = Element::F16_4(rs);
     32 
     33     for (uint32_t nDims = 1; nDims <= 3; nDims ++) {
     34         testAllocationCreation(rs, half, nDims);
     35         testAllocationCreation(rs, half2, nDims);
     36         testAllocationCreation(rs, half3, nDims);
     37         testAllocationCreation(rs, half4, nDims);
     38     }
     39 
     40     printf("Test successful!");
     41 }
     42