Start using bcinfo components within librs.
BUG=4942491 Change-Id: I3a46783511c4954bac9eadbbbefe5abf85498c16
This commit is contained in:
@ -19,6 +19,8 @@ package android.renderscript;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
@ -28,6 +30,7 @@ import android.util.Log;
|
|||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RenderScript base master class. An instance of this class creates native
|
* RenderScript base master class. An instance of this class creates native
|
||||||
* worker threads for processing commands from this object. This base class
|
* worker threads for processing commands from this object. This base class
|
||||||
@ -79,26 +82,26 @@ public class RenderScript {
|
|||||||
|
|
||||||
// Methods below are wrapped to protect the non-threadsafe
|
// Methods below are wrapped to protect the non-threadsafe
|
||||||
// lockless fifo.
|
// lockless fifo.
|
||||||
native int rsnContextCreateGL(int dev, int ver,
|
native int rsnContextCreateGL(int dev, int ver, int sdkVer,
|
||||||
int colorMin, int colorPref,
|
int colorMin, int colorPref,
|
||||||
int alphaMin, int alphaPref,
|
int alphaMin, int alphaPref,
|
||||||
int depthMin, int depthPref,
|
int depthMin, int depthPref,
|
||||||
int stencilMin, int stencilPref,
|
int stencilMin, int stencilPref,
|
||||||
int samplesMin, int samplesPref, float samplesQ, int dpi);
|
int samplesMin, int samplesPref, float samplesQ, int dpi);
|
||||||
synchronized int nContextCreateGL(int dev, int ver,
|
synchronized int nContextCreateGL(int dev, int ver, int sdkVer,
|
||||||
int colorMin, int colorPref,
|
int colorMin, int colorPref,
|
||||||
int alphaMin, int alphaPref,
|
int alphaMin, int alphaPref,
|
||||||
int depthMin, int depthPref,
|
int depthMin, int depthPref,
|
||||||
int stencilMin, int stencilPref,
|
int stencilMin, int stencilPref,
|
||||||
int samplesMin, int samplesPref, float samplesQ, int dpi) {
|
int samplesMin, int samplesPref, float samplesQ, int dpi) {
|
||||||
return rsnContextCreateGL(dev, ver, colorMin, colorPref,
|
return rsnContextCreateGL(dev, ver, sdkVer, colorMin, colorPref,
|
||||||
alphaMin, alphaPref, depthMin, depthPref,
|
alphaMin, alphaPref, depthMin, depthPref,
|
||||||
stencilMin, stencilPref,
|
stencilMin, stencilPref,
|
||||||
samplesMin, samplesPref, samplesQ, dpi);
|
samplesMin, samplesPref, samplesQ, dpi);
|
||||||
}
|
}
|
||||||
native int rsnContextCreate(int dev, int ver);
|
native int rsnContextCreate(int dev, int ver, int sdkVer);
|
||||||
synchronized int nContextCreate(int dev, int ver) {
|
synchronized int nContextCreate(int dev, int ver, int sdkVer) {
|
||||||
return rsnContextCreate(dev, ver);
|
return rsnContextCreate(dev, ver, sdkVer);
|
||||||
}
|
}
|
||||||
native void rsnContextDestroy(int con);
|
native void rsnContextDestroy(int con);
|
||||||
synchronized void nContextDestroy() {
|
synchronized void nContextDestroy() {
|
||||||
@ -864,6 +867,16 @@ public class RenderScript {
|
|||||||
return mApplicationContext;
|
return mApplicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getTargetSdkVersion(Context ctx) {
|
||||||
|
try {
|
||||||
|
PackageManager pm = ctx.getPackageManager();
|
||||||
|
ApplicationInfo app = pm.getApplicationInfo(ctx.getPackageName(), 0);
|
||||||
|
return app.targetSdkVersion;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RSDriverException("Error calculating target SDK version for RS.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a basic RenderScript context.
|
* Create a basic RenderScript context.
|
||||||
*
|
*
|
||||||
@ -873,8 +886,10 @@ public class RenderScript {
|
|||||||
public static RenderScript create(Context ctx) {
|
public static RenderScript create(Context ctx) {
|
||||||
RenderScript rs = new RenderScript(ctx);
|
RenderScript rs = new RenderScript(ctx);
|
||||||
|
|
||||||
|
int sdkVersion = getTargetSdkVersion(ctx);
|
||||||
|
|
||||||
rs.mDev = rs.nDeviceCreate();
|
rs.mDev = rs.nDeviceCreate();
|
||||||
rs.mContext = rs.nContextCreate(rs.mDev, 0);
|
rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
|
||||||
if (rs.mContext == 0) {
|
if (rs.mContext == 0) {
|
||||||
throw new RSDriverException("Failed to create RS context.");
|
throw new RSDriverException("Failed to create RS context.");
|
||||||
}
|
}
|
||||||
|
@ -160,11 +160,13 @@ public class RenderScriptGL extends RenderScript {
|
|||||||
super(ctx);
|
super(ctx);
|
||||||
mSurfaceConfig = new SurfaceConfig(sc);
|
mSurfaceConfig = new SurfaceConfig(sc);
|
||||||
|
|
||||||
|
int sdkVersion = getTargetSdkVersion(ctx);
|
||||||
|
|
||||||
mWidth = 0;
|
mWidth = 0;
|
||||||
mHeight = 0;
|
mHeight = 0;
|
||||||
mDev = nDeviceCreate();
|
mDev = nDeviceCreate();
|
||||||
int dpi = ctx.getResources().getDisplayMetrics().densityDpi;
|
int dpi = ctx.getResources().getDisplayMetrics().densityDpi;
|
||||||
mContext = nContextCreateGL(mDev, 0,
|
mContext = nContextCreateGL(mDev, 0, sdkVersion,
|
||||||
mSurfaceConfig.mColorMin, mSurfaceConfig.mColorPref,
|
mSurfaceConfig.mColorMin, mSurfaceConfig.mColorPref,
|
||||||
mSurfaceConfig.mAlphaMin, mSurfaceConfig.mAlphaPref,
|
mSurfaceConfig.mAlphaMin, mSurfaceConfig.mAlphaPref,
|
||||||
mSurfaceConfig.mDepthMin, mSurfaceConfig.mDepthPref,
|
mSurfaceConfig.mDepthMin, mSurfaceConfig.mDepthPref,
|
||||||
|
@ -149,14 +149,14 @@ nDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jint
|
static jint
|
||||||
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver)
|
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer)
|
||||||
{
|
{
|
||||||
LOG_API("nContextCreate");
|
LOG_API("nContextCreate");
|
||||||
return (jint)rsContextCreate((RsDevice)dev, ver);
|
return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint
|
static jint
|
||||||
nContextCreateGL(JNIEnv *_env, jobject _this, jint dev, jint ver,
|
nContextCreateGL(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer,
|
||||||
int colorMin, int colorPref,
|
int colorMin, int colorPref,
|
||||||
int alphaMin, int alphaPref,
|
int alphaMin, int alphaPref,
|
||||||
int depthMin, int depthPref,
|
int depthMin, int depthPref,
|
||||||
@ -176,7 +176,7 @@ nContextCreateGL(JNIEnv *_env, jobject _this, jint dev, jint ver,
|
|||||||
sc.samplesQ = samplesQ;
|
sc.samplesQ = samplesQ;
|
||||||
|
|
||||||
LOG_API("nContextCreateGL");
|
LOG_API("nContextCreateGL");
|
||||||
return (jint)rsContextCreateGL((RsDevice)dev, ver, sc, dpi);
|
return (jint)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1213,8 +1213,8 @@ static JNINativeMethod methods[] = {
|
|||||||
|
|
||||||
|
|
||||||
// All methods below are thread protected in java.
|
// All methods below are thread protected in java.
|
||||||
{"rsnContextCreate", "(II)I", (void*)nContextCreate },
|
{"rsnContextCreate", "(III)I", (void*)nContextCreate },
|
||||||
{"rsnContextCreateGL", "(IIIIIIIIIIIIFI)I", (void*)nContextCreateGL },
|
{"rsnContextCreateGL", "(IIIIIIIIIIIIIFI)I", (void*)nContextCreateGL },
|
||||||
{"rsnContextFinish", "(I)V", (void*)nContextFinish },
|
{"rsnContextFinish", "(I)V", (void*)nContextFinish },
|
||||||
{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority },
|
{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority },
|
||||||
{"rsnContextSetSurface", "(IIILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
{"rsnContextSetSurface", "(IIILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
||||||
|
@ -52,8 +52,8 @@ void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char **
|
|||||||
RsDevice rsDeviceCreate();
|
RsDevice rsDeviceCreate();
|
||||||
void rsDeviceDestroy(RsDevice dev);
|
void rsDeviceDestroy(RsDevice dev);
|
||||||
void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value);
|
void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value);
|
||||||
RsContext rsContextCreate(RsDevice dev, uint32_t version);
|
RsContext rsContextCreate(RsDevice dev, uint32_t version, uint32_t sdkVersion);
|
||||||
RsContext rsContextCreateGL(RsDevice dev, uint32_t version, RsSurfaceConfig sc, uint32_t dpi);
|
RsContext rsContextCreateGL(RsDevice dev, uint32_t version, uint32_t sdkVersion, RsSurfaceConfig sc, uint32_t dpi);
|
||||||
|
|
||||||
#include "rsgApiFuncDecl.h"
|
#include "rsgApiFuncDecl.h"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "rsdBcc.h"
|
#include "rsdBcc.h"
|
||||||
#include "rsdRuntime.h"
|
#include "rsdRuntime.h"
|
||||||
|
|
||||||
#include <bcinfo/bcinfo.h>
|
#include <bcinfo/MetadataExtractor.h>
|
||||||
|
|
||||||
#include "rsContext.h"
|
#include "rsContext.h"
|
||||||
#include "rsScriptC.h"
|
#include "rsScriptC.h"
|
||||||
@ -40,7 +40,7 @@ struct DrvScript {
|
|||||||
|
|
||||||
BCCScriptRef mBccScript;
|
BCCScriptRef mBccScript;
|
||||||
|
|
||||||
struct BCScriptMetadata *mScriptMetadata;
|
bcinfo::MetadataExtractor *ME;
|
||||||
|
|
||||||
InvokeFunc_t *mInvokeFunctions;
|
InvokeFunc_t *mInvokeFunctions;
|
||||||
void ** mFieldAddress;
|
void ** mFieldAddress;
|
||||||
@ -71,7 +71,9 @@ bool rsdScriptInit(const Context *rsc,
|
|||||||
|
|
||||||
pthread_mutex_lock(&rsdgInitMutex);
|
pthread_mutex_lock(&rsdgInitMutex);
|
||||||
char *cachePath = NULL;
|
char *cachePath = NULL;
|
||||||
struct BCScriptMetadata *md = NULL;
|
size_t exportFuncCount = 0;
|
||||||
|
size_t exportVarCount = 0;
|
||||||
|
size_t objectSlotCount = 0;
|
||||||
|
|
||||||
DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
|
DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
|
||||||
if (drv == NULL) {
|
if (drv == NULL) {
|
||||||
@ -84,13 +86,13 @@ bool rsdScriptInit(const Context *rsc,
|
|||||||
drv->mScriptText = bitcode;
|
drv->mScriptText = bitcode;
|
||||||
drv->mScriptTextLength = bitcodeSize;
|
drv->mScriptTextLength = bitcodeSize;
|
||||||
|
|
||||||
md = bcinfoGetScriptMetadata((const char*)drv->mScriptText,
|
|
||||||
drv->mScriptTextLength, 0);
|
drv->ME = new bcinfo::MetadataExtractor((const char*)drv->mScriptText,
|
||||||
if (!md) {
|
drv->mScriptTextLength);
|
||||||
|
if (!drv->ME->extract()) {
|
||||||
LOGE("bcinfo: failed to read script metadata");
|
LOGE("bcinfo: failed to read script metadata");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
drv->mScriptMetadata = md;
|
|
||||||
|
|
||||||
//LOGE("mBccScript %p", script->mBccScript);
|
//LOGE("mBccScript %p", script->mBccScript);
|
||||||
|
|
||||||
@ -122,40 +124,41 @@ bool rsdScriptInit(const Context *rsc,
|
|||||||
drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root"));
|
drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root"));
|
||||||
drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init"));
|
drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init"));
|
||||||
|
|
||||||
if (md->exportFuncCount > 0) {
|
exportFuncCount = drv->ME->getExportFuncCount();
|
||||||
drv->mInvokeFunctions = (InvokeFunc_t*) calloc(md->exportFuncCount,
|
if (exportFuncCount > 0) {
|
||||||
|
drv->mInvokeFunctions = (InvokeFunc_t*) calloc(exportFuncCount,
|
||||||
sizeof(InvokeFunc_t));
|
sizeof(InvokeFunc_t));
|
||||||
bccGetExportFuncList(drv->mBccScript,
|
bccGetExportFuncList(drv->mBccScript, exportFuncCount,
|
||||||
md->exportFuncCount,
|
|
||||||
(void **) drv->mInvokeFunctions);
|
(void **) drv->mInvokeFunctions);
|
||||||
} else {
|
} else {
|
||||||
drv->mInvokeFunctions = NULL;
|
drv->mInvokeFunctions = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->exportVarCount > 0) {
|
exportVarCount = drv->ME->getExportVarCount();
|
||||||
drv->mFieldAddress = (void **) calloc(md->exportVarCount,
|
if (exportVarCount > 0) {
|
||||||
sizeof(void*));
|
drv->mFieldAddress = (void **) calloc(exportVarCount, sizeof(void*));
|
||||||
drv->mFieldIsObject = (bool *) calloc(md->exportVarCount, sizeof(bool));
|
drv->mFieldIsObject = (bool *) calloc(exportVarCount, sizeof(bool));
|
||||||
bccGetExportVarList(drv->mBccScript,
|
bccGetExportVarList(drv->mBccScript, exportVarCount,
|
||||||
md->exportVarCount,
|
|
||||||
(void **) drv->mFieldAddress);
|
(void **) drv->mFieldAddress);
|
||||||
} else {
|
} else {
|
||||||
drv->mFieldAddress = NULL;
|
drv->mFieldAddress = NULL;
|
||||||
drv->mFieldIsObject = NULL;
|
drv->mFieldIsObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->objectSlotCount) {
|
objectSlotCount = drv->ME->getObjectSlotCount();
|
||||||
for (uint32_t ct=0; ct < md->objectSlotCount; ct++) {
|
if (objectSlotCount > 0) {
|
||||||
drv->mFieldIsObject[md->objectSlotList[ct]] = true;
|
const uint32_t *objectSlotList = drv->ME->getObjectSlotList();
|
||||||
|
for (uint32_t ct=0; ct < objectSlotCount; ct++) {
|
||||||
|
drv->mFieldIsObject[objectSlotList[ct]] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy info over to runtime
|
// Copy info over to runtime
|
||||||
script->mHal.info.exportedFunctionCount = md->exportFuncCount;
|
script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount();
|
||||||
script->mHal.info.exportedVariableCount = md->exportVarCount;
|
script->mHal.info.exportedVariableCount = drv->ME->getExportVarCount();
|
||||||
script->mHal.info.exportedPragmaCount = md->pragmaCount;
|
script->mHal.info.exportedPragmaCount = drv->ME->getPragmaCount();
|
||||||
script->mHal.info.exportedPragmaKeyList = md->pragmaKeyList;
|
script->mHal.info.exportedPragmaKeyList = drv->ME->getPragmaKeyList();
|
||||||
script->mHal.info.exportedPragmaValueList = md->pragmaValueList;
|
script->mHal.info.exportedPragmaValueList = drv->ME->getPragmaValueList();
|
||||||
script->mHal.info.root = drv->mRoot;
|
script->mHal.info.root = drv->mRoot;
|
||||||
|
|
||||||
pthread_mutex_unlock(&rsdgInitMutex);
|
pthread_mutex_unlock(&rsdgInitMutex);
|
||||||
@ -164,6 +167,10 @@ bool rsdScriptInit(const Context *rsc,
|
|||||||
error:
|
error:
|
||||||
|
|
||||||
pthread_mutex_unlock(&rsdgInitMutex);
|
pthread_mutex_unlock(&rsdgInitMutex);
|
||||||
|
if (drv->ME) {
|
||||||
|
delete drv->ME;
|
||||||
|
drv->ME = NULL;
|
||||||
|
}
|
||||||
free(drv);
|
free(drv);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -445,10 +452,10 @@ void rsdScriptSetGlobalObj(const Context *dc, const Script *script, uint32_t slo
|
|||||||
|
|
||||||
void rsdScriptDestroy(const Context *dc, Script *script) {
|
void rsdScriptDestroy(const Context *dc, Script *script) {
|
||||||
DrvScript *drv = (DrvScript *)script->mHal.drv;
|
DrvScript *drv = (DrvScript *)script->mHal.drv;
|
||||||
struct BCScriptMetadata *md = drv->mScriptMetadata;
|
|
||||||
|
|
||||||
if (drv->mFieldAddress) {
|
if (drv->mFieldAddress) {
|
||||||
for (size_t ct = 0; ct < md->exportVarCount; ct++) {
|
size_t exportVarCount = drv->ME->getExportVarCount();
|
||||||
|
for (size_t ct = 0; ct < exportVarCount; ct++) {
|
||||||
if (drv->mFieldIsObject[ct]) {
|
if (drv->mFieldIsObject[ct]) {
|
||||||
// The field address can be NULL if the script-side has
|
// The field address can be NULL if the script-side has
|
||||||
// optimized the corresponding global variable away.
|
// optimized the corresponding global variable away.
|
||||||
@ -467,7 +474,8 @@ void rsdScriptDestroy(const Context *dc, Script *script) {
|
|||||||
drv->mInvokeFunctions = NULL;
|
drv->mInvokeFunctions = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bcinfoReleaseScriptMetadata(&drv->mScriptMetadata);
|
delete drv->ME;
|
||||||
|
drv->ME = NULL;
|
||||||
|
|
||||||
free(drv);
|
free(drv);
|
||||||
script->mHal.drv = NULL;
|
script->mHal.drv = NULL;
|
||||||
|
@ -333,6 +333,7 @@ Context::Context() {
|
|||||||
mPaused = false;
|
mPaused = false;
|
||||||
mObjHead = NULL;
|
mObjHead = NULL;
|
||||||
mError = RS_ERROR_NONE;
|
mError = RS_ERROR_NONE;
|
||||||
|
mTargetSdkVersion = 14;
|
||||||
mDPI = 96;
|
mDPI = 96;
|
||||||
mIsContextLite = false;
|
mIsContextLite = false;
|
||||||
}
|
}
|
||||||
@ -678,19 +679,25 @@ void rsi_ContextDeinitToClient(Context *rsc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RsContext rsContextCreate(RsDevice vdev, uint32_t version) {
|
RsContext rsContextCreate(RsDevice vdev, uint32_t version,
|
||||||
|
uint32_t sdkVersion) {
|
||||||
LOGV("rsContextCreate %p", vdev);
|
LOGV("rsContextCreate %p", vdev);
|
||||||
Device * dev = static_cast<Device *>(vdev);
|
Device * dev = static_cast<Device *>(vdev);
|
||||||
Context *rsc = Context::createContext(dev, NULL);
|
Context *rsc = Context::createContext(dev, NULL);
|
||||||
|
if (rsc) {
|
||||||
|
rsc->setTargetSdkVersion(sdkVersion);
|
||||||
|
}
|
||||||
return rsc;
|
return rsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
|
RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
|
||||||
RsSurfaceConfig sc, uint32_t dpi) {
|
uint32_t sdkVersion, RsSurfaceConfig sc,
|
||||||
|
uint32_t dpi) {
|
||||||
LOGV("rsContextCreateGL %p", vdev);
|
LOGV("rsContextCreateGL %p", vdev);
|
||||||
Device * dev = static_cast<Device *>(vdev);
|
Device * dev = static_cast<Device *>(vdev);
|
||||||
Context *rsc = Context::createContext(dev, &sc);
|
Context *rsc = Context::createContext(dev, &sc);
|
||||||
if (rsc) {
|
if (rsc) {
|
||||||
|
rsc->setTargetSdkVersion(sdkVersion);
|
||||||
rsc->setDPI(dpi);
|
rsc->setDPI(dpi);
|
||||||
}
|
}
|
||||||
LOGV("rsContextCreateGL ret %p ", rsc);
|
LOGV("rsContextCreateGL ret %p ", rsc);
|
||||||
|
@ -199,9 +199,13 @@ public:
|
|||||||
uint32_t getDPI() const {return mDPI;}
|
uint32_t getDPI() const {return mDPI;}
|
||||||
void setDPI(uint32_t dpi) {mDPI = dpi;}
|
void setDPI(uint32_t dpi) {mDPI = dpi;}
|
||||||
|
|
||||||
|
uint32_t getTargetSdkVersion() const {return mTargetSdkVersion;}
|
||||||
|
void setTargetSdkVersion(uint32_t sdkVer) {mTargetSdkVersion = sdkVer;}
|
||||||
|
|
||||||
Device *mDev;
|
Device *mDev;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
uint32_t mTargetSdkVersion;
|
||||||
uint32_t mDPI;
|
uint32_t mDPI;
|
||||||
uint32_t mWidth;
|
uint32_t mWidth;
|
||||||
uint32_t mHeight;
|
uint32_t mHeight;
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
#include "utils/Timers.h"
|
#include "utils/Timers.h"
|
||||||
#include "utils/StopWatch.h"
|
#include "utils/StopWatch.h"
|
||||||
|
|
||||||
|
#ifndef ANDROID_RS_SERIALIZE
|
||||||
|
#include <bcinfo/BitcodeTranslator.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
@ -28,9 +32,18 @@ using namespace android::renderscript;
|
|||||||
ScriptC * sc = (ScriptC *) tls->mScript
|
ScriptC * sc = (ScriptC *) tls->mScript
|
||||||
|
|
||||||
ScriptC::ScriptC(Context *rsc) : Script(rsc) {
|
ScriptC::ScriptC(Context *rsc) : Script(rsc) {
|
||||||
|
#ifndef ANDROID_RS_SERIALIZE
|
||||||
|
BT = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptC::~ScriptC() {
|
ScriptC::~ScriptC() {
|
||||||
|
#ifndef ANDROID_RS_SERIALIZE
|
||||||
|
if (BT) {
|
||||||
|
delete BT;
|
||||||
|
BT = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
mRSC->mHal.funcs.script.destroy(mRSC, this);
|
mRSC->mHal.funcs.script.destroy(mRSC, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +194,22 @@ bool ScriptC::runCompiler(Context *rsc,
|
|||||||
size_t bitcodeLen) {
|
size_t bitcodeLen) {
|
||||||
|
|
||||||
//LOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen);
|
//LOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen);
|
||||||
|
#ifndef ANDROID_RS_SERIALIZE
|
||||||
|
uint32_t sdkVersion = rsc->getTargetSdkVersion();
|
||||||
|
if (BT) {
|
||||||
|
delete BT;
|
||||||
|
}
|
||||||
|
BT = new bcinfo::BitcodeTranslator((const char *)bitcode, bitcodeLen,
|
||||||
|
sdkVersion);
|
||||||
|
if (!BT->translate()) {
|
||||||
|
LOGE("Failed to translate bitcode from version: %u", sdkVersion);
|
||||||
|
delete BT;
|
||||||
|
BT = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bitcode = (const uint8_t *) BT->getTranslatedBitcode();
|
||||||
|
bitcodeLen = BT->getTranslatedBitcodeSize();
|
||||||
|
#endif
|
||||||
|
|
||||||
rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0);
|
rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0);
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
#include "RenderScriptEnv.h"
|
#include "RenderScriptEnv.h"
|
||||||
|
|
||||||
|
#ifndef ANDROID_RS_SERIALIZE
|
||||||
|
#include "bcinfo/BitcodeTranslator.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
namespace android {
|
namespace android {
|
||||||
@ -61,6 +64,10 @@ public:
|
|||||||
void setupScript(Context *);
|
void setupScript(Context *);
|
||||||
void setupGLState(Context *);
|
void setupGLState(Context *);
|
||||||
Script * setTLS(Script *);
|
Script * setTLS(Script *);
|
||||||
|
private:
|
||||||
|
#ifndef ANDROID_RS_SERIALIZE
|
||||||
|
bcinfo::BitcodeTranslator *BT;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScriptCState {
|
class ScriptCState {
|
||||||
|
Reference in New Issue
Block a user