Merge change 25185 into eclair
* changes: Implement renderscript Invokables.
This commit is contained in:
@@ -140,6 +140,8 @@ public class RenderScript {
|
|||||||
native void nScriptSetTimeZone(int script, byte[] timeZone);
|
native void nScriptSetTimeZone(int script, byte[] timeZone);
|
||||||
native void nScriptSetType(int type, boolean writable, String name, int slot);
|
native void nScriptSetType(int type, boolean writable, String name, int slot);
|
||||||
native void nScriptSetRoot(boolean isRoot);
|
native void nScriptSetRoot(boolean isRoot);
|
||||||
|
native void nScriptSetInvokable(String name, int slot);
|
||||||
|
native void nScriptInvoke(int id, int slot);
|
||||||
|
|
||||||
native void nScriptCBegin();
|
native void nScriptCBegin();
|
||||||
native void nScriptCSetScript(byte[] script, int offset, int length);
|
native void nScriptCSetScript(byte[] script, int offset, int length);
|
||||||
|
|||||||
@@ -25,6 +25,22 @@ public class Script extends BaseObj {
|
|||||||
boolean mIsRoot;
|
boolean mIsRoot;
|
||||||
Type[] mTypes;
|
Type[] mTypes;
|
||||||
boolean[] mWritable;
|
boolean[] mWritable;
|
||||||
|
Invokable[] mInvokables;
|
||||||
|
|
||||||
|
public static class Invokable {
|
||||||
|
RenderScript mRS;
|
||||||
|
Script mScript;
|
||||||
|
int mSlot;
|
||||||
|
String mName;
|
||||||
|
|
||||||
|
Invokable() {
|
||||||
|
mSlot = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
mRS.nScriptInvoke(mScript.mID, mSlot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Script(int id, RenderScript rs) {
|
Script(int id, RenderScript rs) {
|
||||||
super(rs);
|
super(rs);
|
||||||
@@ -61,12 +77,15 @@ public class Script extends BaseObj {
|
|||||||
Type[] mTypes;
|
Type[] mTypes;
|
||||||
String[] mNames;
|
String[] mNames;
|
||||||
boolean[] mWritable;
|
boolean[] mWritable;
|
||||||
|
int mInvokableCount = 0;
|
||||||
|
Invokable[] mInvokables;
|
||||||
|
|
||||||
Builder(RenderScript rs) {
|
Builder(RenderScript rs) {
|
||||||
mRS = rs;
|
mRS = rs;
|
||||||
mTypes = new Type[MAX_SLOT];
|
mTypes = new Type[MAX_SLOT];
|
||||||
mNames = new String[MAX_SLOT];
|
mNames = new String[MAX_SLOT];
|
||||||
mWritable = new boolean[MAX_SLOT];
|
mWritable = new boolean[MAX_SLOT];
|
||||||
|
mInvokables = new Invokable[MAX_SLOT];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type t, int slot) {
|
public void setType(Type t, int slot) {
|
||||||
@@ -79,6 +98,15 @@ public class Script extends BaseObj {
|
|||||||
mNames[slot] = name;
|
mNames[slot] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Invokable addInvokable(String func) {
|
||||||
|
Invokable i = new Invokable();
|
||||||
|
i.mName = func;
|
||||||
|
i.mRS = mRS;
|
||||||
|
i.mSlot = mInvokableCount;
|
||||||
|
mInvokables[mInvokableCount++] = i;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(boolean writable, int slot) {
|
public void setType(boolean writable, int slot) {
|
||||||
mWritable[slot] = writable;
|
mWritable[slot] = writable;
|
||||||
}
|
}
|
||||||
@@ -90,11 +118,20 @@ public class Script extends BaseObj {
|
|||||||
mRS.nScriptSetType(mTypes[ct].mID, mWritable[ct], mNames[ct], ct);
|
mRS.nScriptSetType(mTypes[ct].mID, mWritable[ct], mNames[ct], ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(int ct=0; ct < mInvokableCount; ct++) {
|
||||||
|
mRS.nScriptSetInvokable(mInvokables[ct].mName, ct);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void transferObject(Script s) {
|
void transferObject(Script s) {
|
||||||
s.mIsRoot = mIsRoot;
|
s.mIsRoot = mIsRoot;
|
||||||
s.mTypes = mTypes;
|
s.mTypes = mTypes;
|
||||||
|
s.mInvokables = new Invokable[mInvokableCount];
|
||||||
|
for(int ct=0; ct < mInvokableCount; ct++) {
|
||||||
|
s.mInvokables[ct] = mInvokables[ct];
|
||||||
|
s.mInvokables[ct].mScript = s;
|
||||||
|
}
|
||||||
|
s.mInvokables = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoot(boolean r) {
|
public void setRoot(boolean r) {
|
||||||
|
|||||||
@@ -890,6 +890,29 @@ nScriptSetType(JNIEnv *_env, jobject _this, jint type, jboolean writable, jstrin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nScriptSetInvoke(JNIEnv *_env, jobject _this, jstring _str, jint slot)
|
||||||
|
{
|
||||||
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
|
LOG_API("nScriptSetInvoke, con(%p)", con);
|
||||||
|
const char* n = NULL;
|
||||||
|
if (_str) {
|
||||||
|
n = _env->GetStringUTFChars(_str, NULL);
|
||||||
|
}
|
||||||
|
rsScriptSetInvoke(con, n, slot);
|
||||||
|
if (n) {
|
||||||
|
_env->ReleaseStringUTFChars(_str, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nScriptInvoke(JNIEnv *_env, jobject _this, jint obj, jint slot)
|
||||||
|
{
|
||||||
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
|
LOG_API("nScriptInvoke, con(%p), script(%p)", con, (void *)obj);
|
||||||
|
rsScriptInvoke(con, (RsScript)obj, slot);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nScriptSetRoot(JNIEnv *_env, jobject _this, jboolean isRoot)
|
nScriptSetRoot(JNIEnv *_env, jobject _this, jboolean isRoot)
|
||||||
{
|
{
|
||||||
@@ -1366,6 +1389,8 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone },
|
{"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone },
|
||||||
{"nScriptSetType", "(IZLjava/lang/String;I)V", (void*)nScriptSetType },
|
{"nScriptSetType", "(IZLjava/lang/String;I)V", (void*)nScriptSetType },
|
||||||
{"nScriptSetRoot", "(Z)V", (void*)nScriptSetRoot },
|
{"nScriptSetRoot", "(Z)V", (void*)nScriptSetRoot },
|
||||||
|
{"nScriptSetInvokable", "(Ljava/lang/String;I)V", (void*)nScriptSetInvoke },
|
||||||
|
{"nScriptInvoke", "(II)V", (void*)nScriptInvoke },
|
||||||
|
|
||||||
{"nScriptCBegin", "()V", (void*)nScriptCBegin },
|
{"nScriptCBegin", "()V", (void*)nScriptCBegin },
|
||||||
{"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript },
|
{"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript },
|
||||||
|
|||||||
@@ -297,6 +297,16 @@ ScriptSetType {
|
|||||||
param const char * name
|
param const char * name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptSetInvoke {
|
||||||
|
param const char * name
|
||||||
|
param uint32_t slot
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptInvoke {
|
||||||
|
param RsScript s
|
||||||
|
param uint32_t slot
|
||||||
|
}
|
||||||
|
|
||||||
ScriptSetRoot {
|
ScriptSetRoot {
|
||||||
param bool isRoot
|
param bool isRoot
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ Script::Script()
|
|||||||
mEnviroment.mClearColor[2] = 0;
|
mEnviroment.mClearColor[2] = 0;
|
||||||
mEnviroment.mClearColor[3] = 1;
|
mEnviroment.mClearColor[3] = 1;
|
||||||
mEnviroment.mClearDepth = 1;
|
mEnviroment.mClearDepth = 1;
|
||||||
|
mEnviroment.mClearStencil = 0;
|
||||||
|
mEnviroment.mIsRoot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Script::~Script()
|
Script::~Script()
|
||||||
@@ -83,10 +85,23 @@ void rsi_ScriptSetType(Context * rsc, RsType vt, uint32_t slot, bool writable, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rsi_ScriptSetInvoke(Context *rsc, const char *name, uint32_t slot)
|
||||||
|
{
|
||||||
|
ScriptCState *ss = &rsc->mScriptC;
|
||||||
|
ss->mInvokableNames[slot] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot)
|
||||||
|
{
|
||||||
|
Script *s = static_cast<Script *>(vs);
|
||||||
|
s->mEnviroment.mInvokables[slot]();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void rsi_ScriptSetRoot(Context * rsc, bool isRoot)
|
void rsi_ScriptSetRoot(Context * rsc, bool isRoot)
|
||||||
{
|
{
|
||||||
ScriptCState *ss = &rsc->mScriptC;
|
ScriptCState *ss = &rsc->mScriptC;
|
||||||
ss->mEnviroment.mIsRoot = isRoot;
|
ss->mScript->mEnviroment.mIsRoot = isRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class ProgramFragmentStore;
|
|||||||
class Script : public ObjectBase
|
class Script : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef void (* InvokeFunc_t)(void);
|
||||||
|
|
||||||
Script();
|
Script();
|
||||||
virtual ~Script();
|
virtual ~Script();
|
||||||
@@ -52,17 +53,22 @@ public:
|
|||||||
ObjectBaseRef<ProgramFragment> mFragment;
|
ObjectBaseRef<ProgramFragment> mFragment;
|
||||||
//ObjectBaseRef<ProgramRaster> mRaster;
|
//ObjectBaseRef<ProgramRaster> mRaster;
|
||||||
ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
|
ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
|
||||||
|
InvokeFunc_t mInvokables[MAX_SCRIPT_BANKS];
|
||||||
|
const char * mScriptText;
|
||||||
|
uint32_t mScriptTextLength;
|
||||||
};
|
};
|
||||||
Enviroment_t mEnviroment;
|
Enviroment_t mEnviroment;
|
||||||
|
|
||||||
uint32_t mCounstantBufferCount;
|
uint32_t mCounstantBufferCount;
|
||||||
|
|
||||||
|
|
||||||
ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS];
|
ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS];
|
||||||
ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS];
|
ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS];
|
||||||
String8 mSlotNames[MAX_SCRIPT_BANKS];
|
String8 mSlotNames[MAX_SCRIPT_BANKS];
|
||||||
bool mSlotWritable[MAX_SCRIPT_BANKS];
|
bool mSlotWritable[MAX_SCRIPT_BANKS];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool run(Context *, uint32_t launchID) = 0;
|
virtual bool run(Context *, uint32_t launchID) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -82,36 +82,27 @@ bool ScriptC::run(Context *rsc, uint32_t launchIndex)
|
|||||||
|
|
||||||
ScriptCState::ScriptCState()
|
ScriptCState::ScriptCState()
|
||||||
{
|
{
|
||||||
|
mScript = NULL;
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptCState::~ScriptCState()
|
ScriptCState::~ScriptCState()
|
||||||
{
|
{
|
||||||
if (mAccScript) {
|
delete mScript;
|
||||||
accDeleteScript(mAccScript);
|
mScript = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCState::clear()
|
void ScriptCState::clear()
|
||||||
{
|
{
|
||||||
memset(&mProgram, 0, sizeof(mProgram));
|
|
||||||
|
|
||||||
for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||||
mConstantBufferTypes[ct].clear();
|
mConstantBufferTypes[ct].clear();
|
||||||
mSlotNames[ct].setTo("");
|
mSlotNames[ct].setTo("");
|
||||||
|
mInvokableNames[ct].setTo("");
|
||||||
mSlotWritable[ct] = false;
|
mSlotWritable[ct] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&mEnviroment, 0, sizeof(mEnviroment));
|
delete mScript;
|
||||||
mEnviroment.mClearColor[0] = 0;
|
mScript = new ScriptC();
|
||||||
mEnviroment.mClearColor[1] = 0;
|
|
||||||
mEnviroment.mClearColor[2] = 0;
|
|
||||||
mEnviroment.mClearColor[3] = 1;
|
|
||||||
mEnviroment.mClearDepth = 1;
|
|
||||||
mEnviroment.mClearStencil = 0;
|
|
||||||
mEnviroment.mIsRoot = false;
|
|
||||||
|
|
||||||
mAccScript = NULL;
|
|
||||||
|
|
||||||
mInt32Defines.clear();
|
mInt32Defines.clear();
|
||||||
mFloatDefines.clear();
|
mFloatDefines.clear();
|
||||||
@@ -127,9 +118,9 @@ static ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCState::runCompiler(Context *rsc)
|
void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||||
{
|
{
|
||||||
mAccScript = accCreateScript();
|
s->mAccScript = accCreateScript();
|
||||||
String8 tmp;
|
String8 tmp;
|
||||||
|
|
||||||
rsc->appendNameDefines(&tmp);
|
rsc->appendNameDefines(&tmp);
|
||||||
@@ -139,44 +130,51 @@ void ScriptCState::runCompiler(Context *rsc)
|
|||||||
appendTypes(&tmp);
|
appendTypes(&tmp);
|
||||||
tmp.append("#line 1\n");
|
tmp.append("#line 1\n");
|
||||||
|
|
||||||
const char* scriptSource[] = {tmp.string(), mProgram.mScriptText};
|
const char* scriptSource[] = {tmp.string(), s->mEnviroment.mScriptText};
|
||||||
int scriptLength[] = {tmp.length(), mProgram.mScriptTextLength} ;
|
int scriptLength[] = {tmp.length(), s->mEnviroment.mScriptTextLength} ;
|
||||||
accScriptSource(mAccScript, sizeof(scriptLength) / sizeof(int), scriptSource, scriptLength);
|
accScriptSource(s->mAccScript, sizeof(scriptLength) / sizeof(int), scriptSource, scriptLength);
|
||||||
accRegisterSymbolCallback(mAccScript, symbolLookup, NULL);
|
accRegisterSymbolCallback(s->mAccScript, symbolLookup, NULL);
|
||||||
accCompileScript(mAccScript);
|
accCompileScript(s->mAccScript);
|
||||||
accGetScriptLabel(mAccScript, "main", (ACCvoid**) &mProgram.mScript);
|
accGetScriptLabel(s->mAccScript, "main", (ACCvoid**) &s->mProgram.mScript);
|
||||||
accGetScriptLabel(mAccScript, "init", (ACCvoid**) &mProgram.mInit);
|
accGetScriptLabel(s->mAccScript, "init", (ACCvoid**) &s->mProgram.mInit);
|
||||||
rsAssert(mProgram.mScript);
|
rsAssert(s->mProgram.mScript);
|
||||||
|
|
||||||
if (!mProgram.mScript) {
|
if (!s->mProgram.mScript) {
|
||||||
ACCchar buf[4096];
|
ACCchar buf[4096];
|
||||||
ACCsizei len;
|
ACCsizei len;
|
||||||
accGetScriptInfoLog(mAccScript, sizeof(buf), &len, buf);
|
accGetScriptInfoLog(s->mAccScript, sizeof(buf), &len, buf);
|
||||||
LOGE(buf);
|
LOGE(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mProgram.mInit) {
|
if (s->mProgram.mInit) {
|
||||||
mProgram.mInit();
|
s->mProgram.mInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||||
if (mSlotNames[ct].length() > 0) {
|
if (mSlotNames[ct].length() > 0) {
|
||||||
accGetScriptLabel(mAccScript,
|
accGetScriptLabel(s->mAccScript,
|
||||||
mSlotNames[ct].string(),
|
mSlotNames[ct].string(),
|
||||||
(ACCvoid**) &mProgram.mSlotPointers[ct]);
|
(ACCvoid**) &s->mProgram.mSlotPointers[ct]);
|
||||||
LOGE("var %s %p", mSlotNames[ct].string(), mProgram.mSlotPointers[ct]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||||
mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
|
if (mInvokableNames[ct].length() > 0) {
|
||||||
mEnviroment.mFragmentStore.set(rsc->getDefaultProgramFragmentStore());
|
accGetScriptLabel(s->mAccScript,
|
||||||
|
mInvokableNames[ct].string(),
|
||||||
|
(ACCvoid**) &s->mEnviroment.mInvokables[ct]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mProgram.mScript) {
|
s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
|
||||||
|
s->mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
|
||||||
|
s->mEnviroment.mFragmentStore.set(rsc->getDefaultProgramFragmentStore());
|
||||||
|
|
||||||
|
if (s->mProgram.mScript) {
|
||||||
const static int pragmaMax = 16;
|
const static int pragmaMax = 16;
|
||||||
ACCsizei pragmaCount;
|
ACCsizei pragmaCount;
|
||||||
ACCchar * str[pragmaMax];
|
ACCchar * str[pragmaMax];
|
||||||
accGetPragmas(mAccScript, &pragmaCount, pragmaMax, &str[0]);
|
accGetPragmas(s->mAccScript, &pragmaCount, pragmaMax, &str[0]);
|
||||||
|
|
||||||
for (int ct=0; ct < pragmaCount; ct+=2) {
|
for (int ct=0; ct < pragmaCount; ct+=2) {
|
||||||
if (!strcmp(str[ct], "version")) {
|
if (!strcmp(str[ct], "version")) {
|
||||||
@@ -188,12 +186,12 @@ void ScriptCState::runCompiler(Context *rsc)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(str[ct+1], "parent")) {
|
if (!strcmp(str[ct+1], "parent")) {
|
||||||
mEnviroment.mVertex.clear();
|
s->mEnviroment.mVertex.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ProgramVertex * pv = (ProgramVertex *)rsc->lookupName(str[ct+1]);
|
ProgramVertex * pv = (ProgramVertex *)rsc->lookupName(str[ct+1]);
|
||||||
if (pv != NULL) {
|
if (pv != NULL) {
|
||||||
mEnviroment.mVertex.set(pv);
|
s->mEnviroment.mVertex.set(pv);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOGE("Unreconized value %s passed to stateVertex", str[ct+1]);
|
LOGE("Unreconized value %s passed to stateVertex", str[ct+1]);
|
||||||
@@ -208,12 +206,12 @@ void ScriptCState::runCompiler(Context *rsc)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(str[ct+1], "parent")) {
|
if (!strcmp(str[ct+1], "parent")) {
|
||||||
mEnviroment.mFragment.clear();
|
s->mEnviroment.mFragment.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ProgramFragment * pf = (ProgramFragment *)rsc->lookupName(str[ct+1]);
|
ProgramFragment * pf = (ProgramFragment *)rsc->lookupName(str[ct+1]);
|
||||||
if (pf != NULL) {
|
if (pf != NULL) {
|
||||||
mEnviroment.mFragment.set(pf);
|
s->mEnviroment.mFragment.set(pf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOGE("Unreconized value %s passed to stateFragment", str[ct+1]);
|
LOGE("Unreconized value %s passed to stateFragment", str[ct+1]);
|
||||||
@@ -224,13 +222,13 @@ void ScriptCState::runCompiler(Context *rsc)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(str[ct+1], "parent")) {
|
if (!strcmp(str[ct+1], "parent")) {
|
||||||
mEnviroment.mFragmentStore.clear();
|
s->mEnviroment.mFragmentStore.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ProgramFragmentStore * pfs =
|
ProgramFragmentStore * pfs =
|
||||||
(ProgramFragmentStore *)rsc->lookupName(str[ct+1]);
|
(ProgramFragmentStore *)rsc->lookupName(str[ct+1]);
|
||||||
if (pfs != NULL) {
|
if (pfs != NULL) {
|
||||||
mEnviroment.mFragmentStore.set(pfs);
|
s->mEnviroment.mFragmentStore.set(pfs);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOGE("Unreconized value %s passed to stateFragmentStore", str[ct+1]);
|
LOGE("Unreconized value %s passed to stateFragmentStore", str[ct+1]);
|
||||||
@@ -351,33 +349,6 @@ void ScriptCState::appendTypes(String8 *str)
|
|||||||
s.append(";\n");
|
s.append(";\n");
|
||||||
LOGD(s);
|
LOGD(s);
|
||||||
str->append(s);
|
str->append(s);
|
||||||
#if 0
|
|
||||||
for (size_t ct2=0; ct2 < e->getComponentCount(); ct2++) {
|
|
||||||
const Component *c = e->getComponent(ct2);
|
|
||||||
tmp.setTo("#define ");
|
|
||||||
tmp.append(mSlotNames[ct]);
|
|
||||||
tmp.append("_");
|
|
||||||
tmp.append(c->getComponentName());
|
|
||||||
switch (c->getType()) {
|
|
||||||
case Component::FLOAT:
|
|
||||||
tmp.append(" loadF(");
|
|
||||||
break;
|
|
||||||
case Component::SIGNED:
|
|
||||||
sprintf(buf, " loadI%i(", c->getBits());
|
|
||||||
tmp.append(buf);
|
|
||||||
break;
|
|
||||||
case Component::UNSIGNED:
|
|
||||||
sprintf(buf, " loadU%i(", c->getBits());
|
|
||||||
tmp.append(buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sprintf(buf, "%i, %i)\n", ct, ct2);
|
|
||||||
tmp.append(buf);
|
|
||||||
|
|
||||||
LOGD(tmp);
|
|
||||||
str->append(tmp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,15 +365,16 @@ void rsi_ScriptCBegin(Context * rsc)
|
|||||||
|
|
||||||
void rsi_ScriptCSetScript(Context * rsc, void *vp)
|
void rsi_ScriptCSetScript(Context * rsc, void *vp)
|
||||||
{
|
{
|
||||||
ScriptCState *ss = &rsc->mScriptC;
|
rsAssert(0);
|
||||||
ss->mProgram.mScript = reinterpret_cast<ScriptC::RunScript_t>(vp);
|
//ScriptCState *ss = &rsc->mScriptC;
|
||||||
|
//ss->mProgram.mScript = reinterpret_cast<ScriptC::RunScript_t>(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len)
|
void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len)
|
||||||
{
|
{
|
||||||
ScriptCState *ss = &rsc->mScriptC;
|
ScriptCState *ss = &rsc->mScriptC;
|
||||||
ss->mProgram.mScriptText = text;
|
ss->mScript->mEnviroment.mScriptText = text;
|
||||||
ss->mProgram.mScriptTextLength = len;
|
ss->mScript->mEnviroment.mScriptTextLength = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -410,14 +382,11 @@ RsScript rsi_ScriptCCreate(Context * rsc)
|
|||||||
{
|
{
|
||||||
ScriptCState *ss = &rsc->mScriptC;
|
ScriptCState *ss = &rsc->mScriptC;
|
||||||
|
|
||||||
ss->runCompiler(rsc);
|
ScriptC *s = ss->mScript;
|
||||||
|
ss->mScript = NULL;
|
||||||
|
|
||||||
ScriptC *s = new ScriptC();
|
ss->runCompiler(rsc, s);
|
||||||
s->incUserRef();
|
s->incUserRef();
|
||||||
s->mAccScript = ss->mAccScript;
|
|
||||||
ss->mAccScript = NULL;
|
|
||||||
s->mEnviroment = ss->mEnviroment;
|
|
||||||
s->mProgram = ss->mProgram;
|
|
||||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||||
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
|
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
|
||||||
s->mSlotNames[ct] = ss->mSlotNames[ct];
|
s->mSlotNames[ct] = ss->mSlotNames[ct];
|
||||||
|
|||||||
@@ -67,17 +67,15 @@ public:
|
|||||||
ScriptCState();
|
ScriptCState();
|
||||||
~ScriptCState();
|
~ScriptCState();
|
||||||
|
|
||||||
ACCscript* mAccScript;
|
ScriptC *mScript;
|
||||||
|
|
||||||
ScriptC::Program_t mProgram;
|
|
||||||
Script::Enviroment_t mEnviroment;
|
|
||||||
|
|
||||||
ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
|
ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
|
||||||
String8 mSlotNames[MAX_SCRIPT_BANKS];
|
String8 mSlotNames[MAX_SCRIPT_BANKS];
|
||||||
bool mSlotWritable[MAX_SCRIPT_BANKS];
|
bool mSlotWritable[MAX_SCRIPT_BANKS];
|
||||||
|
String8 mInvokableNames[MAX_SCRIPT_BANKS];
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void runCompiler(Context *rsc);
|
void runCompiler(Context *rsc, ScriptC *s);
|
||||||
void appendVarDefines(String8 *str);
|
void appendVarDefines(String8 *str);
|
||||||
void appendTypes(String8 *str);
|
void appendTypes(String8 *str);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user