Merge "Add support for mixed 32/64 APKs using RenderScript."
This commit is contained in:
@ -232,12 +232,20 @@ public class FieldPacker {
|
|||||||
|
|
||||||
public void addObj(BaseObj obj) {
|
public void addObj(BaseObj obj) {
|
||||||
if (obj != null) {
|
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));
|
addI32((int)obj.getID(null));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (RenderScript.sPointerSize == 8) {
|
||||||
|
addI64(0);
|
||||||
} else {
|
} else {
|
||||||
addI32(0);
|
addI32(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addF32(Float2 v) {
|
public void addF32(Float2 v) {
|
||||||
addF32(v.x);
|
addF32(v.x);
|
||||||
|
@ -67,6 +67,12 @@ public class RenderScript {
|
|||||||
static Method registerNativeAllocation;
|
static Method registerNativeAllocation;
|
||||||
static Method registerNativeFree;
|
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 {
|
static {
|
||||||
sInitialized = false;
|
sInitialized = false;
|
||||||
if (!SystemProperties.getBoolean("config.disable_renderscript", false)) {
|
if (!SystemProperties.getBoolean("config.disable_renderscript", false)) {
|
||||||
@ -84,6 +90,7 @@ public class RenderScript {
|
|||||||
System.loadLibrary("rs_jni");
|
System.loadLibrary("rs_jni");
|
||||||
_nInit();
|
_nInit();
|
||||||
sInitialized = true;
|
sInitialized = true;
|
||||||
|
sPointerSize = rsnSystemGetPointerSize();
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
Log.e(LOG_TAG, "Error loading RS jni library: " + e);
|
Log.e(LOG_TAG, "Error loading RS jni library: " + e);
|
||||||
throw new RSRuntimeException("Error loading RS jni library: " + e);
|
throw new RSRuntimeException("Error loading RS jni library: " + e);
|
||||||
|
@ -73,6 +73,26 @@ public class ScriptC extends Script {
|
|||||||
setID(id);
|
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.
|
* 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);
|
// Log.v(TAG, "Create script for resource = " + resName);
|
||||||
return rs.nScriptCCreate(resName, mCachePath, pgm, pgmLength);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1576,6 +1576,12 @@ nMeshGetIndices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _
|
|||||||
free(prims);
|
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 },
|
{"rsnMeshGetVertices", "(JJ[JI)V", (void*)nMeshGetVertices },
|
||||||
{"rsnMeshGetIndices", "(JJ[J[II)V", (void*)nMeshGetIndices },
|
{"rsnMeshGetIndices", "(JJ[J[II)V", (void*)nMeshGetIndices },
|
||||||
|
|
||||||
|
{"rsnSystemGetPointerSize", "()I", (void*)nSystemGetPointerSize },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int registerFuncs(JNIEnv *_env)
|
static int registerFuncs(JNIEnv *_env)
|
||||||
|
Reference in New Issue
Block a user