11f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar#include "RenderScript.h"
21f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
31f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainarusing namespace android;
41f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainarusing namespace RSC;
51f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
61f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainarstatic const uint32_t dimX = 7, dimY = 5, dimZ = 3;
71f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
81f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainarvoid testAllocationCreation(sp<RS> rs, sp<const Element> e, uint32_t nDims) {
91f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    Type::Builder tb(rs, e);
101f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    tb.setX(dimX);
111f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    if (nDims >= 2)
121f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar        tb.setY(dimY);
131f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    if (nDims >= 3)
141f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar        tb.setZ(dimZ);
151f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
161f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<const Type> t = tb.create();
171f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<Allocation> alloc = Allocation::createTyped(rs, t);
181f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar}
191f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
201f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainarint main(int , char** )
211f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar{
221f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<RS> rs = new RS();
231f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
241f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    bool r = rs->init("/system/bin");
251f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
261f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    // Test ability to create 1D, 2D and 3D allocations of f16 scalars and
271f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    // vectors
281f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<const Element> half = Element::F16(rs);
291f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<const Element> half2 = Element::F16_2(rs);
301f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<const Element> half3 = Element::F16_3(rs);
311f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    sp<const Element> half4 = Element::F16_4(rs);
321f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
331f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    for (uint32_t nDims = 1; nDims <= 3; nDims ++) {
341f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar        testAllocationCreation(rs, half, nDims);
351f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar        testAllocationCreation(rs, half2, nDims);
361f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar        testAllocationCreation(rs, half3, nDims);
371f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar        testAllocationCreation(rs, half4, nDims);
381f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    }
391f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar
401f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar    printf("Test successful!");
411f6041ddc7658e252797626faae38db759413edcPirama Arumuga Nainar}
42