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