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

Commit e688213f authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "Clean up Allocation buffer object api."

parents b89e1429 d1952404
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -102,12 +102,6 @@ public class Allocation extends BaseObj {
        mRS.nAllocationSyncAll(getID(), srcLocation);
    }

    public void uploadToBufferObject() {
        mRS.validate();
        mRS.nAllocationUploadToBufferObject(getID());
    }


    public void copyFrom(BaseObj[] d) {
        mRS.validate();
        if (d.length != mType.getCount()) {
@@ -516,19 +510,6 @@ public class Allocation extends BaseObj {
                                        USAGE_GRAPHICS_TEXTURE);
    }

/*
    static public Allocation createFromBitmapResource(RenderScript rs,
                                                      Resources res,
                                                      int id,
                                                      Element dstFmt,
                                                      boolean genMips) {
        MipmapControl mc = MipmapControl.MIPMAP_NONE;
        if (genMips) {
            mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE;
        }
        return createFromBitmapResource(rs, res, id, mc, USAGE_GRAPHICS_TEXTURE);
    }
*/
    static public Allocation createFromString(RenderScript rs,
                                              String str,
                                              int usage) {
+20 −8
Original line number Diff line number Diff line
@@ -93,20 +93,23 @@ public class Mesh extends BaseObj {

    public static class Builder {
        RenderScript mRS;
        int mUsage;

        class Entry {
            Type t;
            Element e;
            int size;
            Primitive prim;
            int usage;
        }

        int mVertexTypeCount;
        Entry[] mVertexTypes;
        Vector mIndexTypes;

        public Builder(RenderScript rs) {
        public Builder(RenderScript rs, int usage) {
            mRS = rs;
            mUsage = usage;
            mVertexTypeCount = 0;
            mVertexTypes = new Entry[16];
            mIndexTypes = new Vector();
@@ -190,10 +193,10 @@ public class Mesh extends BaseObj {
                Allocation alloc = null;
                Entry entry = (Entry)b.mIndexTypes.elementAt(ct);
                if (entry.t != null) {
                    alloc = Allocation.createTyped(rs, entry.t);
                    alloc = Allocation.createTyped(rs, entry.t, b.mUsage);
                }
                else if(entry.e != null) {
                    alloc = Allocation.createSized(rs, entry.e, entry.size);
                    alloc = Allocation.createSized(rs, entry.e, entry.size, b.mUsage);
                }
                int allocID = (alloc == null) ? 0 : alloc.getID();
                rs.nMeshBindIndex(id, allocID, entry.prim.mID, ct);
@@ -205,9 +208,9 @@ public class Mesh extends BaseObj {
                Allocation alloc = null;
                Entry entry = b.mVertexTypes[ct];
                if (entry.t != null) {
                    alloc = Allocation.createTyped(rs, entry.t);
                    alloc = Allocation.createTyped(rs, entry.t, b.mUsage);
                } else if(entry.e != null) {
                    alloc = Allocation.createSized(rs, entry.e, entry.size);
                    alloc = Allocation.createSized(rs, entry.e, entry.size, b.mUsage);
                }
                rs.nMeshBindVertex(id, alloc.getID(), ct);
                newMesh.mVertexBuffers[ct] = alloc;
@@ -460,7 +463,12 @@ public class Mesh extends BaseObj {
            }
            mElement = b.create();

            Builder smb = new Builder(mRS);
            int usage = Allocation.USAGE_SCRIPT;
            if (uploadToBufferObject) {
                usage |= Allocation.USAGE_GRAPHICS_VERTEX;
            }

            Builder smb = new Builder(mRS, usage);
            smb.addVertexType(mElement, mVtxCount / floatCount);
            smb.addIndexType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE);

@@ -468,11 +476,15 @@ public class Mesh extends BaseObj {

            sm.getVertexAllocation(0).copyFrom(mVtxData);
            if(uploadToBufferObject) {
                sm.getVertexAllocation(0).uploadToBufferObject();
                if (uploadToBufferObject) {
                    sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
                }
            }

            sm.getIndexAllocation(0).copyFrom(mIndexData);
            sm.getIndexAllocation(0).uploadToBufferObject();
            if (uploadToBufferObject) {
                sm.getIndexAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
            }

            return sm;
        }
+0 −22
Original line number Diff line number Diff line
@@ -287,24 +287,6 @@ static void SC_allocationSyncAll2(RsAllocation va, RsAllocationUsageType source)
    static_cast<Allocation *>(va)->syncAll(rsc, source);
}

static void SC_uploadToTexture2(RsAllocation va, uint32_t baseMipLevel) {
    CHECK_OBJ(va);
    GET_TLS();
    rsi_AllocationUploadToTexture(rsc, va, false, baseMipLevel);
}

static void SC_uploadToTexture(RsAllocation va) {
    CHECK_OBJ(va);
    GET_TLS();
    rsi_AllocationUploadToTexture(rsc, va, false, 0);
}

static void SC_uploadToBufferObject(RsAllocation va) {
    CHECK_OBJ(va);
    GET_TLS();
    rsi_AllocationUploadToBufferObject(rsc, va);
}

static void SC_ClearColor(float r, float g, float b, float a) {
    GET_TLS();
    rsc->setupProgramStore();
@@ -439,10 +421,6 @@ static ScriptCState::SymbolTable_t gSyms[] = {

    { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_allocationSyncAll, false },

    { "_Z18rsgUploadToTexture13rs_allocationj", (void *)&SC_uploadToTexture2, false },
    { "_Z18rsgUploadToTexture13rs_allocation", (void *)&SC_uploadToTexture, false },
    { "_Z23rsgUploadToBufferObject13rs_allocation", (void *)&SC_uploadToBufferObject, false },

    { "_Z11rsgDrawRectfffff", (void *)&SC_drawRect, false },
    { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_drawQuad, false },
    { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_drawQuadTexCoords, false },
+0 −7
Original line number Diff line number Diff line
@@ -37,13 +37,6 @@ extern uint __attribute__((overloadable))
extern void __attribute__((overloadable))
    rsgAllocationSyncAll(rs_allocation);

extern void __attribute__((overloadable))
    rsgUploadToTexture(rs_allocation);
extern void __attribute__((overloadable))
    rsgUploadToTexture(rs_allocation, uint mipLevel);
extern void __attribute__((overloadable))
    rsgUploadToBufferObject(rs_allocation);

extern void __attribute__((overloadable))
    rsgDrawRect(float x1, float y1, float x2, float y2, float z);
extern void __attribute__((overloadable))