Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 065149f1 authored by Stephen Hines's avatar Stephen Hines
Browse files

Updated RSTest to test primitive type assignments.

Change-Id: I6c377cfdc647806d9362effc4c1715638dcf5bfb
parent 6f1e9618
Loading
Loading
Loading
Loading
+7 −19
Original line number Diff line number Diff line
@@ -38,33 +38,21 @@ public class RSTestCore {
        return true;
    }

    //private ScriptC_Fountain mScript;
    private boolean rs_primitives_test() {
        ScriptC_primitives s = new ScriptC_primitives(mRS, mRes, R.raw.primitives, true);
        s.invoke_rs_primitives_test(0, 0);
        return true;
    }

    public void init(RenderScriptGL rs, Resources res, int width, int height) {
        mRS = rs;
        mRes = res;

        mRootScript = new ScriptC_test_root(mRS, mRes, R.raw.test_root, true);

        rs_primitives_test();
        fp_mad();


        /*
        ProgramFragment.Builder pfb = new ProgramFragment.Builder(rs);
        pfb.setVaryingColor(true);
        rs.contextBindProgramFragment(pfb.create());

        ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);

        Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
        smb.addVertexAllocation(points.getAllocation());
        smb.addIndexType(Primitive.POINT);
        Mesh sm = smb.create();

        mScript = new ScriptC_Fountain(mRS, mRes, R.raw.fountain, true);
        mScript.set_partMesh(sm);
        mScript.bind_point(points);
        mRS.contextBindRootScript(mScript);
        */
    }

    public void newTouchPosition(float x, float y, float pressure, int id) {
+42 −0
Original line number Diff line number Diff line
#include "shared.rsh"

#pragma rs export_func(rs_primitives_test)

// Testing primitive types
static float floatTest = 1.0;
static double doubleTest = 2.05;
static char charTest = -8;
static short shortTest = -16;
static int intTest = -32;
static uchar ucharTest = 8;
static ushort ushortTest = 16;
static uint uintTest = 32;

static void test_primitive_types(uint32_t index) {
    bool failed = false;
    start();

    _RS_ASSERT(floatTest == 1.0);
    _RS_ASSERT(doubleTest == 2.05);
    _RS_ASSERT(charTest == -8);
    _RS_ASSERT(shortTest == -16);
    _RS_ASSERT(intTest == -32);
    _RS_ASSERT(ucharTest == 8);
    _RS_ASSERT(ushortTest == 16);
    _RS_ASSERT(uintTest == 32);

    float time = end(index);
    if (failed) {
        rsDebug("test_primitives FAILED ", time);
    }
    else {
        rsDebug("test_primitives PASSED ", time);
    }
}


void rs_primitives_test(uint32_t index, int test_num) {
    test_primitive_types(index);
}

+10 −0
Original line number Diff line number Diff line
@@ -23,3 +23,13 @@ static float end(uint32_t idx) {
    return ((float)t) / 1000.f;
}

#define _RS_ASSERT(b) \
do { \
    rsDebug("Checking " #b, ((int) (b))); \
    if (!(b)) { \
        failed = true; \
        rsDebug(#b " FAILED", 0); \
    } \
\
} while (0)