2009-05-22 14:03:28 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "rsContext.h"
|
|
|
|
#include "rsScriptC.h"
|
|
|
|
#include "rsMatrix.h"
|
|
|
|
|
2009-05-28 15:53:04 -07:00
|
|
|
#include "acc/acc.h"
|
2009-08-09 11:39:02 -07:00
|
|
|
#include "utils/Timers.h"
|
2009-05-28 15:53:04 -07:00
|
|
|
|
2009-06-22 17:15:15 -07:00
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
using namespace android;
|
|
|
|
using namespace android::renderscript;
|
|
|
|
|
2009-06-19 16:03:18 -07:00
|
|
|
#define GET_TLS() Context::ScriptTLSStruct * tls = \
|
|
|
|
(Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
|
|
|
|
Context * rsc = tls->mContext; \
|
|
|
|
ScriptC * sc = (ScriptC *) tls->mScript
|
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
|
|
|
|
ScriptC::ScriptC()
|
|
|
|
{
|
2009-05-28 15:53:04 -07:00
|
|
|
mAccScript = NULL;
|
2009-06-08 15:20:31 -07:00
|
|
|
memset(&mProgram, 0, sizeof(mProgram));
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ScriptC::~ScriptC()
|
|
|
|
{
|
2009-05-28 15:53:04 -07:00
|
|
|
if (mAccScript) {
|
|
|
|
accDeleteScript(mAccScript);
|
|
|
|
}
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-19 16:03:18 -07:00
|
|
|
bool ScriptC::run(Context *rsc, uint32_t launchIndex)
|
2009-05-22 14:03:28 -07:00
|
|
|
{
|
2009-08-04 16:58:20 -07:00
|
|
|
Context::ScriptTLSStruct * tls =
|
2009-06-19 16:03:18 -07:00
|
|
|
(Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey);
|
2009-06-10 15:04:38 -07:00
|
|
|
|
|
|
|
if (mEnviroment.mFragmentStore.get()) {
|
|
|
|
rsc->setFragmentStore(mEnviroment.mFragmentStore.get());
|
|
|
|
}
|
|
|
|
if (mEnviroment.mFragment.get()) {
|
|
|
|
rsc->setFragment(mEnviroment.mFragment.get());
|
|
|
|
}
|
2009-06-17 16:52:59 -07:00
|
|
|
if (mEnviroment.mVertex.get()) {
|
|
|
|
rsc->setVertex(mEnviroment.mVertex.get());
|
|
|
|
}
|
2009-06-10 15:04:38 -07:00
|
|
|
|
2009-08-09 11:39:02 -07:00
|
|
|
if (launchIndex == 0) {
|
|
|
|
mEnviroment.mStartTimeMillis
|
|
|
|
= nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
|
|
|
|
}
|
|
|
|
|
2009-09-03 15:43:13 -07:00
|
|
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
|
|
|
if (mProgram.mSlotPointers[ct]) {
|
|
|
|
*mProgram.mSlotPointers[ct] = mSlots[ct]->getPtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-20 14:31:06 -07:00
|
|
|
bool ret = false;
|
2009-06-19 16:03:18 -07:00
|
|
|
tls->mScript = this;
|
2009-07-20 14:31:06 -07:00
|
|
|
ret = mProgram.mScript(launchIndex) != 0;
|
2009-06-19 16:03:18 -07:00
|
|
|
tls->mScript = NULL;
|
2009-07-20 14:31:06 -07:00
|
|
|
return ret;
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ScriptCState::ScriptCState()
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScriptCState::~ScriptCState()
|
|
|
|
{
|
2009-05-28 15:53:04 -07:00
|
|
|
if (mAccScript) {
|
|
|
|
accDeleteScript(mAccScript);
|
|
|
|
}
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptCState::clear()
|
|
|
|
{
|
2009-06-08 15:20:31 -07:00
|
|
|
memset(&mProgram, 0, sizeof(mProgram));
|
|
|
|
|
2009-08-12 17:54:11 -07:00
|
|
|
for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
|
|
|
mConstantBufferTypes[ct].clear();
|
2009-08-13 12:59:04 -07:00
|
|
|
mSlotNames[ct].setTo("");
|
2009-08-17 13:56:09 -07:00
|
|
|
mSlotWritable[ct] = false;
|
2009-08-12 17:54:11 -07:00
|
|
|
}
|
2009-06-08 15:20:31 -07:00
|
|
|
|
|
|
|
memset(&mEnviroment, 0, sizeof(mEnviroment));
|
|
|
|
mEnviroment.mClearColor[0] = 0;
|
|
|
|
mEnviroment.mClearColor[1] = 0;
|
|
|
|
mEnviroment.mClearColor[2] = 0;
|
|
|
|
mEnviroment.mClearColor[3] = 1;
|
|
|
|
mEnviroment.mClearDepth = 1;
|
|
|
|
mEnviroment.mClearStencil = 0;
|
|
|
|
mEnviroment.mIsRoot = false;
|
|
|
|
|
2009-05-28 15:53:04 -07:00
|
|
|
mAccScript = NULL;
|
2009-06-08 15:20:31 -07:00
|
|
|
|
2009-08-09 22:57:44 -07:00
|
|
|
mInt32Defines.clear();
|
|
|
|
mFloatDefines.clear();
|
2009-06-05 17:35:09 -07:00
|
|
|
}
|
|
|
|
|
2009-08-04 16:58:20 -07:00
|
|
|
static ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name)
|
2009-07-16 15:08:06 -07:00
|
|
|
{
|
|
|
|
const ScriptCState::SymbolTable_t *sym = ScriptCState::lookupSymbol(name);
|
|
|
|
if (sym) {
|
|
|
|
return sym->mPtr;
|
|
|
|
}
|
|
|
|
LOGE("ScriptC sym lookup failed for %s", name);
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-06-10 18:39:40 -07:00
|
|
|
|
2009-06-10 15:04:38 -07:00
|
|
|
void ScriptCState::runCompiler(Context *rsc)
|
2009-06-05 17:35:09 -07:00
|
|
|
{
|
|
|
|
mAccScript = accCreateScript();
|
2009-06-10 18:39:40 -07:00
|
|
|
String8 tmp;
|
|
|
|
|
|
|
|
rsc->appendNameDefines(&tmp);
|
2009-07-16 17:47:40 -07:00
|
|
|
appendDecls(&tmp);
|
2009-08-09 22:57:44 -07:00
|
|
|
rsc->appendVarDefines(&tmp);
|
|
|
|
appendVarDefines(&tmp);
|
2009-08-12 17:54:11 -07:00
|
|
|
appendTypes(&tmp);
|
2009-07-21 12:20:54 -07:00
|
|
|
tmp.append("#line 1\n");
|
2009-06-05 17:35:09 -07:00
|
|
|
|
2009-06-10 18:39:40 -07:00
|
|
|
const char* scriptSource[] = {tmp.string(), mProgram.mScriptText};
|
|
|
|
int scriptLength[] = {tmp.length(), mProgram.mScriptTextLength} ;
|
|
|
|
accScriptSource(mAccScript, sizeof(scriptLength) / sizeof(int), scriptSource, scriptLength);
|
2009-07-16 15:08:06 -07:00
|
|
|
accRegisterSymbolCallback(mAccScript, symbolLookup, NULL);
|
2009-06-05 17:35:09 -07:00
|
|
|
accCompileScript(mAccScript);
|
2009-06-08 15:20:31 -07:00
|
|
|
accGetScriptLabel(mAccScript, "main", (ACCvoid**) &mProgram.mScript);
|
2009-09-03 15:43:13 -07:00
|
|
|
accGetScriptLabel(mAccScript, "init", (ACCvoid**) &mProgram.mInit);
|
2009-06-09 12:15:30 -07:00
|
|
|
rsAssert(mProgram.mScript);
|
|
|
|
|
2009-07-16 17:47:40 -07:00
|
|
|
if (!mProgram.mScript) {
|
|
|
|
ACCchar buf[4096];
|
|
|
|
ACCsizei len;
|
|
|
|
accGetScriptInfoLog(mAccScript, sizeof(buf), &len, buf);
|
|
|
|
LOGE(buf);
|
|
|
|
}
|
|
|
|
|
2009-09-03 15:43:13 -07:00
|
|
|
if (mProgram.mInit) {
|
|
|
|
mProgram.mInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
|
|
|
if (mSlotNames[ct].length() > 0) {
|
|
|
|
accGetScriptLabel(mAccScript,
|
|
|
|
mSlotNames[ct].string(),
|
|
|
|
(ACCvoid**) &mProgram.mSlotPointers[ct]);
|
|
|
|
LOGE("var %s %p", mSlotNames[ct].string(), mProgram.mSlotPointers[ct]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-17 16:52:59 -07:00
|
|
|
mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
|
|
|
|
mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
|
|
|
|
mEnviroment.mFragmentStore.set(rsc->getDefaultProgramFragmentStore());
|
2009-06-10 18:39:40 -07:00
|
|
|
|
2009-06-09 12:15:30 -07:00
|
|
|
if (mProgram.mScript) {
|
|
|
|
const static int pragmaMax = 16;
|
|
|
|
ACCsizei pragmaCount;
|
|
|
|
ACCchar * str[pragmaMax];
|
|
|
|
accGetPragmas(mAccScript, &pragmaCount, pragmaMax, &str[0]);
|
|
|
|
|
|
|
|
for (int ct=0; ct < pragmaCount; ct+=2) {
|
|
|
|
if (!strcmp(str[ct], "version")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(str[ct], "stateVertex")) {
|
2009-06-17 16:52:59 -07:00
|
|
|
if (!strcmp(str[ct+1], "default")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(str[ct+1], "parent")) {
|
|
|
|
mEnviroment.mVertex.clear();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ProgramVertex * pv = (ProgramVertex *)rsc->lookupName(str[ct+1]);
|
|
|
|
if (pv != NULL) {
|
|
|
|
mEnviroment.mVertex.set(pv);
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-09 12:15:30 -07:00
|
|
|
LOGE("Unreconized value %s passed to stateVertex", str[ct+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(str[ct], "stateRaster")) {
|
|
|
|
LOGE("Unreconized value %s passed to stateRaster", str[ct+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(str[ct], "stateFragment")) {
|
2009-06-17 16:52:59 -07:00
|
|
|
if (!strcmp(str[ct+1], "default")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(str[ct+1], "parent")) {
|
|
|
|
mEnviroment.mFragment.clear();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ProgramFragment * pf = (ProgramFragment *)rsc->lookupName(str[ct+1]);
|
2009-06-10 15:04:38 -07:00
|
|
|
if (pf != NULL) {
|
|
|
|
mEnviroment.mFragment.set(pf);
|
2009-06-09 12:15:30 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
LOGE("Unreconized value %s passed to stateFragment", str[ct+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(str[ct], "stateFragmentStore")) {
|
2009-06-17 16:52:59 -07:00
|
|
|
if (!strcmp(str[ct+1], "default")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(str[ct+1], "parent")) {
|
|
|
|
mEnviroment.mFragmentStore.clear();
|
|
|
|
continue;
|
|
|
|
}
|
2009-08-04 16:58:20 -07:00
|
|
|
ProgramFragmentStore * pfs =
|
2009-06-10 15:04:38 -07:00
|
|
|
(ProgramFragmentStore *)rsc->lookupName(str[ct+1]);
|
|
|
|
if (pfs != NULL) {
|
|
|
|
mEnviroment.mFragmentStore.set(pfs);
|
2009-06-09 12:15:30 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
LOGE("Unreconized value %s passed to stateFragmentStore", str[ct+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-04 16:58:20 -07:00
|
|
|
|
2009-06-09 12:15:30 -07:00
|
|
|
} else {
|
|
|
|
// Deal with an error.
|
|
|
|
}
|
2009-08-09 22:57:44 -07:00
|
|
|
}
|
2009-06-09 12:15:30 -07:00
|
|
|
|
2009-09-03 15:43:13 -07:00
|
|
|
static void appendElementBody(String8 *s, const Element *e)
|
|
|
|
{
|
|
|
|
s->append(" {\n");
|
|
|
|
for (size_t ct2=0; ct2 < e->getComponentCount(); ct2++) {
|
|
|
|
const Component *c = e->getComponent(ct2);
|
|
|
|
s->append(" ");
|
|
|
|
s->append(c->getCType());
|
|
|
|
s->append(" ");
|
|
|
|
s->append(c->getComponentName());
|
|
|
|
s->append(";\n");
|
|
|
|
}
|
|
|
|
s->append("}");
|
|
|
|
}
|
2009-08-09 22:57:44 -07:00
|
|
|
|
|
|
|
void ScriptCState::appendVarDefines(String8 *str)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
LOGD("appendVarDefines mInt32Defines.size()=%d mFloatDefines.size()=%d\n",
|
|
|
|
mInt32Defines.size(), mFloatDefines.size());
|
|
|
|
for (size_t ct=0; ct < mInt32Defines.size(); ct++) {
|
|
|
|
str->append("#define ");
|
|
|
|
str->append(mInt32Defines.keyAt(ct));
|
|
|
|
str->append(" ");
|
|
|
|
sprintf(buf, "%i\n", (int)mInt32Defines.valueAt(ct));
|
|
|
|
str->append(buf);
|
|
|
|
}
|
|
|
|
for (size_t ct=0; ct < mFloatDefines.size(); ct++) {
|
|
|
|
str->append("#define ");
|
|
|
|
str->append(mFloatDefines.keyAt(ct));
|
|
|
|
str->append(" ");
|
|
|
|
sprintf(buf, "%ff\n", mFloatDefines.valueAt(ct));
|
|
|
|
str->append(buf);
|
|
|
|
}
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
2009-09-03 15:43:13 -07:00
|
|
|
|
|
|
|
|
2009-08-12 17:54:11 -07:00
|
|
|
void ScriptCState::appendTypes(String8 *str)
|
|
|
|
{
|
|
|
|
char buf[256];
|
2009-08-13 12:59:04 -07:00
|
|
|
String8 tmp;
|
2009-08-12 17:54:11 -07:00
|
|
|
|
2009-08-13 12:59:04 -07:00
|
|
|
for (size_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
2009-08-12 17:54:11 -07:00
|
|
|
const Type *t = mConstantBufferTypes[ct].get();
|
2009-08-13 12:59:04 -07:00
|
|
|
if (!t) {
|
2009-08-12 17:54:11 -07:00
|
|
|
continue;
|
|
|
|
}
|
2009-08-13 12:59:04 -07:00
|
|
|
const Element *e = t->getElement();
|
2009-09-03 15:43:13 -07:00
|
|
|
if (e->getName() && (e->getComponentCount() > 1)) {
|
|
|
|
String8 s("struct struct_");
|
|
|
|
s.append(e->getName());
|
|
|
|
appendElementBody(&s, e);
|
|
|
|
s.append(";\n");
|
|
|
|
s.append("#define ");
|
|
|
|
s.append(e->getName());
|
|
|
|
s.append("_t struct struct_");
|
|
|
|
s.append(e->getName());
|
|
|
|
s.append("\n\n");
|
|
|
|
LOGD(s);
|
|
|
|
str->append(s);
|
|
|
|
}
|
2009-08-13 12:59:04 -07:00
|
|
|
|
|
|
|
if (t->getName()) {
|
|
|
|
for (size_t ct2=0; ct2 < e->getComponentCount(); ct2++) {
|
|
|
|
const Component *c = e->getComponent(ct2);
|
|
|
|
tmp.setTo("#define OFFSETOF_");
|
|
|
|
tmp.append(t->getName());
|
|
|
|
tmp.append("_");
|
|
|
|
tmp.append(c->getComponentName());
|
|
|
|
sprintf(buf, " %i\n", ct2);
|
|
|
|
tmp.append(buf);
|
2009-09-03 15:43:13 -07:00
|
|
|
LOGD(tmp);
|
2009-08-13 12:59:04 -07:00
|
|
|
str->append(tmp);
|
|
|
|
}
|
2009-08-12 17:54:11 -07:00
|
|
|
}
|
|
|
|
|
2009-08-13 12:59:04 -07:00
|
|
|
if (mSlotNames[ct].length() > 0) {
|
2009-09-03 15:43:13 -07:00
|
|
|
String8 s;
|
|
|
|
if (e->getComponentCount() > 1) {
|
|
|
|
if (e->getName()) {
|
|
|
|
// Use the named struct
|
|
|
|
s.setTo(e->getName());
|
|
|
|
s.append("_t *");
|
|
|
|
} else {
|
|
|
|
// create an struct named from the slot.
|
|
|
|
s.setTo("struct ");
|
|
|
|
s.append(mSlotNames[ct]);
|
|
|
|
s.append("_s");
|
|
|
|
appendElementBody(&s, e);
|
|
|
|
s.append(";\n");
|
|
|
|
s.append("struct ");
|
|
|
|
s.append(mSlotNames[ct]);
|
|
|
|
s.append("_s * ");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Just make an array
|
|
|
|
s.setTo(e->getComponent(0)->getCType());
|
|
|
|
s.append("_t *");
|
|
|
|
}
|
|
|
|
s.append(mSlotNames[ct]);
|
|
|
|
s.append(";\n");
|
|
|
|
LOGD(s);
|
|
|
|
str->append(s);
|
|
|
|
#if 0
|
2009-08-13 12:59:04 -07:00
|
|
|
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);
|
|
|
|
|
2009-09-03 15:43:13 -07:00
|
|
|
LOGD(tmp);
|
2009-08-13 12:59:04 -07:00
|
|
|
str->append(tmp);
|
|
|
|
}
|
2009-09-03 15:43:13 -07:00
|
|
|
#endif
|
2009-08-13 12:59:04 -07:00
|
|
|
}
|
2009-08-12 17:54:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-09 22:57:44 -07:00
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
namespace android {
|
|
|
|
namespace renderscript {
|
|
|
|
|
|
|
|
void rsi_ScriptCBegin(Context * rsc)
|
|
|
|
{
|
|
|
|
ScriptCState *ss = &rsc->mScriptC;
|
|
|
|
ss->clear();
|
|
|
|
}
|
|
|
|
|
2009-06-08 15:20:31 -07:00
|
|
|
void rsi_ScriptCSetScript(Context * rsc, void *vp)
|
2009-05-22 14:03:28 -07:00
|
|
|
{
|
|
|
|
ScriptCState *ss = &rsc->mScriptC;
|
2009-07-20 14:31:06 -07:00
|
|
|
ss->mProgram.mScript = reinterpret_cast<ScriptC::RunScript_t>(vp);
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
2009-06-05 17:35:09 -07:00
|
|
|
void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len)
|
|
|
|
{
|
|
|
|
ScriptCState *ss = &rsc->mScriptC;
|
2009-06-08 15:20:31 -07:00
|
|
|
ss->mProgram.mScriptText = text;
|
|
|
|
ss->mProgram.mScriptTextLength = len;
|
2009-06-05 17:35:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
RsScript rsi_ScriptCCreate(Context * rsc)
|
|
|
|
{
|
|
|
|
ScriptCState *ss = &rsc->mScriptC;
|
|
|
|
|
2009-06-10 15:04:38 -07:00
|
|
|
ss->runCompiler(rsc);
|
2009-06-05 17:35:09 -07:00
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
ScriptC *s = new ScriptC();
|
2009-08-27 20:23:34 -07:00
|
|
|
s->incUserRef();
|
2009-05-28 15:53:04 -07:00
|
|
|
s->mAccScript = ss->mAccScript;
|
|
|
|
ss->mAccScript = NULL;
|
2009-06-08 15:20:31 -07:00
|
|
|
s->mEnviroment = ss->mEnviroment;
|
|
|
|
s->mProgram = ss->mProgram;
|
2009-08-13 12:59:04 -07:00
|
|
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
|
|
|
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
|
|
|
|
s->mSlotNames[ct] = ss->mSlotNames[ct];
|
2009-08-17 13:56:09 -07:00
|
|
|
s->mSlotWritable[ct] = ss->mSlotWritable[ct];
|
2009-08-13 12:59:04 -07:00
|
|
|
}
|
2009-06-09 12:15:30 -07:00
|
|
|
|
2009-08-13 12:59:04 -07:00
|
|
|
ss->clear();
|
2009-05-22 14:03:28 -07:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2009-08-09 22:57:44 -07:00
|
|
|
void rsi_ScriptCSetDefineF(Context *rsc, const char* name, float value)
|
|
|
|
{
|
|
|
|
ScriptCState *ss = &rsc->mScriptC;
|
|
|
|
ss->mFloatDefines.add(String8(name), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rsi_ScriptCSetDefineI32(Context *rsc, const char* name, int32_t value)
|
|
|
|
{
|
|
|
|
ScriptCState *ss = &rsc->mScriptC;
|
|
|
|
ss->mInt32Defines.add(String8(name), value);
|
|
|
|
}
|
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|