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

Commit 718cd1f3 authored by Jason Sams's avatar Jason Sams
Browse files

Element restructuring. Add support for new basic Element types including the...

Element restructuring.  Add support for new basic Element types including the RS objects and vectors(2-4).  In theory this paves the way for maintaining type info for RS objects, passing elements for GLSL uiforms/attribs/varyings, and supporting nested structures.

This will break some apps, checkings for other projects will follow to unbreak them.
parent ceedafac
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -171,9 +171,10 @@ public class Allocation extends BaseObj {
    public Adapter1D createAdapter1D() {
        mRS.validate();
        int id = mRS.nAdapter1DCreate();
        if (id != 0) {
            mRS.nAdapter1DBindAllocation(id, mID);
        if(id == 0) {
            throw new IllegalStateException("allocation failed.");
        }
        mRS.nAdapter1DBindAllocation(id, mID);
        return new Adapter1D(id, mRS);
    }

@@ -213,9 +214,10 @@ public class Allocation extends BaseObj {
    public Adapter2D createAdapter2D() {
        mRS.validate();
        int id = mRS.nAdapter2DCreate();
        if (id != 0) {
            mRS.nAdapter2DBindAllocation(id, mID);
        if(id == 0) {
            throw new IllegalStateException("allocation failed.");
        }
        mRS.nAdapter2DBindAllocation(id, mID);
        return new Adapter2D(id, mRS);
    }

@@ -258,6 +260,9 @@ public class Allocation extends BaseObj {

        rs.validate();
        int id = rs.nAllocationCreateFromBitmap(dstFmt.mID, genMips, b);
        if(id == 0) {
            throw new IllegalStateException("Load failed.");
        }
        return new Allocation(id, rs, null);
    }

@@ -266,6 +271,9 @@ public class Allocation extends BaseObj {

        rs.validate();
        int id = rs.nAllocationCreateFromBitmapBoxed(dstFmt.mID, genMips, b);
        if(id == 0) {
            throw new IllegalStateException("Load failed.");
        }
        return new Allocation(id, rs, null);
    }

@@ -282,6 +290,9 @@ public class Allocation extends BaseObj {
            int allocationId = rs.nAllocationCreateFromAssetStream(dstFmt.mID, genMips,
                    asset);

            if(allocationId == 0) {
                throw new IllegalStateException("Load failed.");
            }
            return new Allocation(allocationId, rs, null);
        } catch (Exception e) {
            // Ignore
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.util.Log;
class BaseObj {

    BaseObj(RenderScript rs) {
        rs.validate();
        mRS = rs;
        mID = 0;
        mDestroyed = false;
+243 −314

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class ProgramVertex extends Program {
            mProjection = new Matrix();
            mTexture = new Matrix();

            mAlloc = Allocation.createSized(rs, Element.USER_F32(rs), 48);
            mAlloc = Allocation.createSized(rs, Element.createUser(rs, Element.DataType.FLOAT_32), 48);
            mAlloc.subData1D(MODELVIEW_OFFSET, 16, mModel.mMat);
            mAlloc.subData1D(PROJECTION_OFFSET, 16, mProjection.mMat);
            mAlloc.subData1D(TEXTURE_OFFSET, 16, mTexture.mMat);
+11 −9
Original line number Diff line number Diff line
@@ -89,9 +89,9 @@ public class RenderScript {
    native void nObjDestroyOOB(int id);
    native int  nFileOpen(byte[] name);

    native void nElementBegin();
    native void nElementAdd(int kind, int type, boolean norm, int bits, String s);
    native int  nElementCreate();

    native int  nElementCreate(int type, int kind, boolean norm, int vecSize);
    native int  nElementCreate2(int[] elements, String[] names);

    native void nTypeBegin(int elementID);
    native void nTypeAdd(int dim, int val);
@@ -198,14 +198,13 @@ public class RenderScript {
    private Surface mSurface;
    private MessageThread mMessageThread;


    Element mElement_USER_U8;
    Element mElement_USER_I8;
    Element mElement_USER_U16;
    Element mElement_USER_I16;
    Element mElement_USER_U32;
    Element mElement_USER_I32;
    Element mElement_USER_FLOAT;
    Element mElement_USER_F32;

    Element mElement_A_8;
    Element mElement_RGB_565;
@@ -215,9 +214,12 @@ public class RenderScript {
    Element mElement_RGBA_8888;

    Element mElement_INDEX_16;
    Element mElement_XY_F32;
    Element mElement_XYZ_F32;

    Element mElement_POSITION_2;
    Element mElement_POSITION_3;
    Element mElement_TEXTURE_2;
    Element mElement_NORMAL_3;
    Element mElement_COLOR_U8_4;
    Element mElement_COLOR_F32_4;

    ///////////////////////////////////////////////////////////////////////////////////
    //
@@ -303,9 +305,9 @@ public class RenderScript {
            nDeviceSetConfig(mDev, 0, 1);
        }
        mContext = nContextCreate(mDev, 0, useDepth);
        Element.initPredefined(this);
        mMessageThread = new MessageThread(this);
        mMessageThread.start();
        Element.initPredefined(this);
    }

    public void contextSetSurface(int w, int h, Surface sur) {
Loading