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

Commit 1afc29ae authored by Tim Murray's avatar Tim Murray Committed by Gerrit Code Review
Browse files

Merge "Add support for mixed 32/64 APKs using RenderScript."

parents 7e547e0d f0c62b26
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -232,12 +232,20 @@ public class FieldPacker {

    public void addObj(BaseObj obj) {
        if (obj != null) {
            // FIXME: this is fine for 32-bit but needs a path for 64-bit
            if (RenderScript.sPointerSize == 8) {
                addI64(obj.getID(null));
            }
            else {
                addI32((int)obj.getID(null));
            }
        } else {
            if (RenderScript.sPointerSize == 8) {
                addI64(0);
            } else {
                addI32(0);
            }
        }
    }

    public void addF32(Float2 v) {
        addF32(v.x);
+7 −0
Original line number Diff line number Diff line
@@ -67,6 +67,12 @@ public class RenderScript {
    static Method registerNativeAllocation;
    static Method registerNativeFree;

    /*
     * Detect the bitness of the VM to allow FieldPacker to do the right thing.
     */
    static native int rsnSystemGetPointerSize();
    static int sPointerSize;

    static {
        sInitialized = false;
        if (!SystemProperties.getBoolean("config.disable_renderscript", false)) {
@@ -84,6 +90,7 @@ public class RenderScript {
                System.loadLibrary("rs_jni");
                _nInit();
                sInitialized = true;
                sPointerSize = rsnSystemGetPointerSize();
            } catch (UnsatisfiedLinkError e) {
                Log.e(LOG_TAG, "Error loading RS jni library: " + e);
                throw new RSRuntimeException("Error loading RS jni library: " + e);
+33 −0
Original line number Diff line number Diff line
@@ -73,6 +73,26 @@ public class ScriptC extends Script {
        setID(id);
    }

    /**
     * Only intended for use by the generated derived classes.
     *
     * @param rs
     * @hide
     */
    protected ScriptC(RenderScript rs, String resName, byte[] bitcode32, byte[] bitcode64) {
        super(0, rs);
        long id = 0;
        if (RenderScript.sPointerSize == 4) {
            id = internalStringCreate(rs, resName, bitcode32);
        } else {
            id = internalStringCreate(rs, resName, bitcode64);
        }
        if (id == 0) {
            throw new RSRuntimeException("Loading of ScriptC script failed.");
        }
        setID(id);
    }

    /**
     * Name of the file that holds the object cache.
     */
@@ -120,4 +140,17 @@ public class ScriptC extends Script {
        //        Log.v(TAG, "Create script for resource = " + resName);
        return rs.nScriptCCreate(resName, mCachePath, pgm, pgmLength);
    }

    private static synchronized long internalStringCreate(RenderScript rs, String resName, byte[] bitcode) {
        // Create the RS cache path if we haven't done so already.
        if (mCachePath == null) {
            File f = new File(rs.mCacheDir, CACHE_PATH);
            mCachePath = f.getAbsolutePath();
            f.mkdirs();
        }
        //        Log.v(TAG, "Create script for resource = " + resName);
        return rs.nScriptCCreate(resName, mCachePath, bitcode, bitcode.length);
    }


}
+7 −0
Original line number Diff line number Diff line
@@ -1576,6 +1576,12 @@ nMeshGetIndices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _
    free(prims);
}

static jint
nSystemGetPointerSize(JNIEnv *_env, jobject _this) {
    return (jint)sizeof(void*);
}


// ---------------------------------------------------------------------------


@@ -1711,6 +1717,7 @@ static JNINativeMethod methods[] = {
{"rsnMeshGetVertices",               "(JJ[JI)V",                              (void*)nMeshGetVertices },
{"rsnMeshGetIndices",                "(JJ[J[II)V",                            (void*)nMeshGetIndices },

{"rsnSystemGetPointerSize",          "()I",                                   (void*)nSystemGetPointerSize },
};

static int registerFuncs(JNIEnv *_env)