diff options
author | Jason Sams <rjsams@android.com> | 2010-05-11 14:03:58 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-05-11 14:03:58 -0700 |
commit | be36bf3a76481737a7fa606a04144ceef80eb4f2 (patch) | |
tree | b99c2d6bc09a0d595106149de3e348bc35a04a20 /rsScript.cpp | |
parent | 3910dbf6d1291b2977ba59e4ed759360c518c9d3 (diff) | |
download | rs-be36bf3a76481737a7fa606a04144ceef80eb4f2.tar.gz |
Convert renderscript from using ACC to LLVM for its compiler.
This will also require application to be updated to support
the new compiler and data passing models.
Change-Id: If078e3a5148af395ba1b936169a407d8c3ad727f
Diffstat (limited to 'rsScript.cpp')
-rw-r--r-- | rsScript.cpp | 116 |
1 files changed, 103 insertions, 13 deletions
diff --git a/rsScript.cpp b/rsScript.cpp index a33933b6..1c63c115 100644 --- a/rsScript.cpp +++ b/rsScript.cpp @@ -30,13 +30,25 @@ Script::Script(Context *rsc) : ObjectBase(rsc) mEnviroment.mClearColor[3] = 1; mEnviroment.mClearDepth = 1; mEnviroment.mClearStencil = 0; - mEnviroment.mIsRoot = false; } Script::~Script() { } +void Script::setVar(uint32_t slot, const void *val, uint32_t len) +{ + int32_t *destPtr = ((int32_t **)mEnviroment.mFieldAddress)[slot]; + if (destPtr) { + //LOGE("setVar f1 %f", ((const float *)destPtr)[0]); + //LOGE("setVar %p %i", destPtr, len); + memcpy(destPtr, val, len); + //LOGE("setVar f2 %f", ((const float *)destPtr)[0]); + } else { + LOGE("Calling setVar on slot = %i which is null", slot); + } +} + namespace android { namespace renderscript { @@ -44,7 +56,9 @@ namespace renderscript { void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint32_t slot) { Script *s = static_cast<Script *>(vs); - s->mSlots[slot].set(static_cast<Allocation *>(va)); + Allocation *a = static_cast<Allocation *>(va); + s->mSlots[slot].set(a); + //LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr()); } void rsi_ScriptSetClearColor(Context * rsc, RsScript vs, float r, float g, float b, float a) @@ -80,35 +94,111 @@ void rsi_ScriptSetType(Context * rsc, RsType vt, uint32_t slot, bool writable, c const Type *t = static_cast<const Type *>(vt); ss->mConstantBufferTypes[slot].set(t); ss->mSlotWritable[slot] = writable; - if (name) { - ss->mSlotNames[slot].setTo(name); - } else { - ss->mSlotNames[slot].setTo(""); - } + LOGE("rsi_ScriptSetType"); } void rsi_ScriptSetInvoke(Context *rsc, const char *name, uint32_t slot) { - ScriptCState *ss = &rsc->mScriptC; - ss->mInvokableNames[slot] = name; + LOGE("rsi_ScriptSetInvoke"); } + void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot) { + //LOGE("rsi_ScriptInvoke %i", slot); Script *s = static_cast<Script *>(vs); - if (s->mEnviroment.mInvokables[slot] == NULL) { + if ((slot >= s->mEnviroment.mInvokeFunctionCount) || + (s->mEnviroment.mInvokeFunctions[slot] == NULL)) { rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); return; } s->setupScript(); - s->mEnviroment.mInvokables[slot](); + //LOGE("invoking %i %p", slot, s->mEnviroment.mInvokeFunctions[slot]); + s->mEnviroment.mInvokeFunctions[slot](); + //LOGE("invoke finished"); } +void rsi_ScriptInvokeData(Context *rsc, RsScript vs, uint32_t slot, void *data) +{ + //LOGE("rsi_ScriptInvoke %i", slot); + Script *s = static_cast<Script *>(vs); + if ((slot >= s->mEnviroment.mInvokeFunctionCount) || + (s->mEnviroment.mInvokeFunctions[slot] == NULL)) { + rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); + return; + } + s->setupScript(); + //LOGE("invoking %i %p", slot, s->mEnviroment.mInvokeFunctions[slot]); + s->mEnviroment.mInvokeFunctions[slot](); + //LOGE("invoke finished"); +} + +void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len) +{ + //LOGE("rsi_ScriptInvoke %i", slot); + Script *s = static_cast<Script *>(vs); + if ((slot >= s->mEnviroment.mInvokeFunctionCount) || + (s->mEnviroment.mInvokeFunctions[slot] == NULL)) { + rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); + return; + } + s->setupScript(); + + LOGE("rsi_ScriptInvokeV, len=%i", len); + const uint32_t * dPtr = (const uint32_t *)data; + switch(len) { + case 0: + s->mEnviroment.mInvokeFunctions[slot](); + break; + case 4: + ((void (*)(uint32_t)) + s->mEnviroment.mInvokeFunctions[slot])(dPtr[0]); + break; + case 8: + ((void (*)(uint32_t, uint32_t)) + s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1]); + break; + case 12: + ((void (*)(uint32_t, uint32_t, uint32_t)) + s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2]); + break; + case 16: + ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t)) + s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3]); + break; + case 20: + ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)) + s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3], dPtr[4]); + break; + + + } + +} + void rsi_ScriptSetRoot(Context * rsc, bool isRoot) { - ScriptCState *ss = &rsc->mScriptC; - ss->mScript->mEnviroment.mIsRoot = isRoot; + LOGE("rsi_ScriptSetRoot"); +} + +void rsi_ScriptSetVarI(Context *rsc, RsScript vs, uint32_t slot, int value) +{ + Script *s = static_cast<Script *>(vs); + s->setVar(slot, &value, sizeof(value)); +} + +void rsi_ScriptSetVarF(Context *rsc, RsScript vs, uint32_t slot, float value) +{ + Script *s = static_cast<Script *>(vs); + s->setVar(slot, &value, sizeof(value)); +} + +void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len) +{ + const float *fp = (const float *)data; + Script *s = static_cast<Script *>(vs); + s->setVar(slot, data, len); } |