blob: b87ac281dd51592b6cae6093ced0ec762ac19696 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "rsContext.h"
18#include "rsScriptC.h"
19#include "rsMatrix.h"
Jason Samsbe36bf32010-05-11 14:03:58 -070020#include "../../../external/llvm/libbcc/include/bcc/bcc.h"
Joe Onorato9c4e4ca2009-08-09 11:39:02 -070021#include "utils/Timers.h"
Jack Palevich1ef8b802009-05-28 15:53:04 -070022
Jason Sams1aa5a4e2009-06-22 17:15:15 -070023#include <GLES/gl.h>
24#include <GLES/glext.h>
25
Jason Sams326e0dd2009-05-22 14:03:28 -070026using namespace android;
27using namespace android::renderscript;
28
Jason Samse5769102009-06-19 16:03:18 -070029#define GET_TLS() Context::ScriptTLSStruct * tls = \
30 (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
31 Context * rsc = tls->mContext; \
32 ScriptC * sc = (ScriptC *) tls->mScript
33
Jason Sams326e0dd2009-05-22 14:03:28 -070034
Jason Samse514b452009-09-25 14:51:22 -070035ScriptC::ScriptC(Context *rsc) : Script(rsc)
Jason Sams326e0dd2009-05-22 14:03:28 -070036{
Jason Samsf2649a92009-09-25 16:37:33 -070037 mAllocFile = __FILE__;
38 mAllocLine = __LINE__;
Jason Samsbe36bf32010-05-11 14:03:58 -070039 mBccScript = NULL;
Jason Samsefb8de12009-06-08 15:20:31 -070040 memset(&mProgram, 0, sizeof(mProgram));
Jason Sams326e0dd2009-05-22 14:03:28 -070041}
42
43ScriptC::~ScriptC()
44{
Jason Samsbe36bf32010-05-11 14:03:58 -070045 if (mBccScript) {
46 bccDeleteScript(mBccScript);
Jack Palevich1ef8b802009-05-28 15:53:04 -070047 }
Jason Samse402ed32009-11-03 11:25:42 -080048 free(mEnviroment.mScriptText);
49 mEnviroment.mScriptText = NULL;
Jason Sams326e0dd2009-05-22 14:03:28 -070050}
51
Jason Samsc61346b2010-05-28 18:23:22 -070052void ScriptC::setupScript(Context *rsc)
Jason Samsada7f272009-09-24 14:55:38 -070053{
Jason Samsc61346b2010-05-28 18:23:22 -070054 setupGLState(rsc);
55 mEnviroment.mStartTimeMillis
56 = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
57
Jason Samsbe36bf32010-05-11 14:03:58 -070058 for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) {
59 if (!mSlots[ct].get())
60 continue;
61 void *ptr = mSlots[ct]->getPtr();
62 void **dest = ((void ***)mEnviroment.mFieldAddress)[ct];
63 //LOGE("setupScript %i %p = %p %p %i", ct, dest, ptr, mSlots[ct]->getType(), mSlots[ct]->getType()->getDimX());
64
65 //const uint32_t *p32 = (const uint32_t *)ptr;
66 //for (uint32_t ct2=0; ct2 < mSlots[ct]->getType()->getDimX(); ct2++) {
67 //LOGE(" %i = 0x%08x ", ct2, p32[ct2]);
68 //}
69
70 if (dest) {
71 *dest = ptr;
72 } else {
73 LOGE("ScriptC::setupScript, NULL var binding address.");
Jason Samsada7f272009-09-24 14:55:38 -070074 }
75 }
76}
77
Jason Samsce92d4b2010-05-17 14:55:34 -070078const Allocation *ScriptC::ptrToAllocation(const void *ptr) const
79{
80 if (!ptr) {
81 return NULL;
82 }
83 for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) {
84 if (!mSlots[ct].get())
85 continue;
86 if (mSlots[ct]->getPtr() == ptr) {
87 return mSlots[ct].get();
88 }
89 }
90 LOGE("ScriptC::ptrToAllocation, failed to find %p", ptr);
91 return NULL;
92}
93
Jason Samsc61346b2010-05-28 18:23:22 -070094Script * ScriptC::setTLS(Script *sc)
Jason Sams22fa3712010-05-19 17:22:57 -070095{
96 Context::ScriptTLSStruct * tls = (Context::ScriptTLSStruct *)
97 pthread_getspecific(Context::gThreadTLSKey);
98 rsAssert(tls);
Jason Samsc61346b2010-05-28 18:23:22 -070099 Script *old = tls->mScript;
100 tls->mScript = sc;
101 return old;
Jason Sams22fa3712010-05-19 17:22:57 -0700102}
103
Jason Sams326e0dd2009-05-22 14:03:28 -0700104
Jason Samsc61346b2010-05-28 18:23:22 -0700105void ScriptC::setupGLState(Context *rsc)
Jason Sams326e0dd2009-05-22 14:03:28 -0700106{
Jason Samsa0a1b6f2009-06-10 15:04:38 -0700107 if (mEnviroment.mFragmentStore.get()) {
108 rsc->setFragmentStore(mEnviroment.mFragmentStore.get());
109 }
110 if (mEnviroment.mFragment.get()) {
111 rsc->setFragment(mEnviroment.mFragment.get());
112 }
Jason Sams8ce125b2009-06-17 16:52:59 -0700113 if (mEnviroment.mVertex.get()) {
114 rsc->setVertex(mEnviroment.mVertex.get());
115 }
Jason Samsb681c8a2009-09-28 18:12:56 -0700116 if (mEnviroment.mRaster.get()) {
117 rsc->setRaster(mEnviroment.mRaster.get());
118 }
Jason Samsc61346b2010-05-28 18:23:22 -0700119}
Jason Samsa0a1b6f2009-06-10 15:04:38 -0700120
Jason Samsc61346b2010-05-28 18:23:22 -0700121uint32_t ScriptC::run(Context *rsc)
122{
123 if (mProgram.mRoot == NULL) {
124 rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script");
125 return 0;
Joe Onorato9c4e4ca2009-08-09 11:39:02 -0700126 }
Jason Samsc61346b2010-05-28 18:23:22 -0700127
128 setupScript(rsc);
Jason Sams1d54f102009-09-03 15:43:13 -0700129
Jason Sams2dca84d2009-12-09 11:05:45 -0800130 uint32_t ret = 0;
Jason Samsc61346b2010-05-28 18:23:22 -0700131 Script * oldTLS = setTLS(this);
Jason Samsbe36bf32010-05-11 14:03:58 -0700132 //LOGE("ScriptC::run %p", mProgram.mRoot);
133 ret = mProgram.mRoot();
Jason Samsc61346b2010-05-28 18:23:22 -0700134 setTLS(oldTLS);
Jason Samsbe36bf32010-05-11 14:03:58 -0700135 //LOGE("ScriptC::run ret %i", ret);
Jason Samse45ac6e2009-07-20 14:31:06 -0700136 return ret;
Jason Sams326e0dd2009-05-22 14:03:28 -0700137}
138
Jason Samsc61346b2010-05-28 18:23:22 -0700139
Jason Samsace3e012010-07-15 17:11:13 -0700140void ScriptC::runForEach(Context *rsc,
141 const Allocation * ain,
142 Allocation * aout,
143 const void * usr,
144 const RsScriptCall *sc)
Jason Samsc61346b2010-05-28 18:23:22 -0700145{
146 uint32_t dimX = ain->getType()->getDimX();
Jason Samsace3e012010-07-15 17:11:13 -0700147 uint32_t dimY = ain->getType()->getDimY();
148 uint32_t dimZ = ain->getType()->getDimZ();
149 uint32_t dimA = 0;//ain->getType()->getDimArray();
Jason Samsc61346b2010-05-28 18:23:22 -0700150
Jason Samsace3e012010-07-15 17:11:13 -0700151 uint32_t xStart = 0;
152 uint32_t xEnd = 0;
153 uint32_t yStart = 0;
154 uint32_t yEnd = 0;
155 uint32_t zStart = 0;
156 uint32_t zEnd = 0;
157 uint32_t arrayStart = 0;
158 uint32_t arrayEnd = 0;
159
160 if (!sc || (sc->xEnd == 0)) {
161 xStart = 0;
162 xEnd = ain->getType()->getDimX();
163 } else {
164 rsAssert(xStart < dimX);
165 rsAssert(xEnd <= dimX);
166 rsAssert(sc->xStart < sc->xEnd);
167 xStart = rsMin(dimX, sc->xStart);
168 xEnd = rsMin(dimX, sc->xEnd);
169 if (xStart >= xEnd) return;
170 }
171
172 if (!sc || (sc->yEnd == 0)) {
173 yStart = 0;
174 yEnd = ain->getType()->getDimY();
175 } else {
176 rsAssert(yStart < dimY);
177 rsAssert(yEnd <= dimY);
178 rsAssert(sc->yStart < sc->yEnd);
179 yStart = rsMin(dimY, sc->yStart);
180 yEnd = rsMin(dimY, sc->yEnd);
181 if (yStart >= yEnd) return;
182 }
183
184 xEnd = rsMax((uint32_t)1, xEnd);
185 yEnd = rsMax((uint32_t)1, yEnd);
186 zEnd = rsMax((uint32_t)1, zEnd);
187 arrayEnd = rsMax((uint32_t)1, arrayEnd);
188
189 rsAssert(ain->getType()->getDimZ() == 0);
Jason Samsc61346b2010-05-28 18:23:22 -0700190
191 setupScript(rsc);
192 Script * oldTLS = setTLS(this);
193
Jason Samsace3e012010-07-15 17:11:13 -0700194 typedef int (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
195
Jason Samsc61346b2010-05-28 18:23:22 -0700196 const uint8_t *ptrIn = (const uint8_t *)ain->getPtr();
Jason Samsace3e012010-07-15 17:11:13 -0700197 uint32_t eStrideIn = ain->getType()->getElementSizeBytes();
Jason Samsc61346b2010-05-28 18:23:22 -0700198
199 uint8_t *ptrOut = NULL;
Jason Samsace3e012010-07-15 17:11:13 -0700200 uint32_t eStrideOut = 0;
Jason Samsc61346b2010-05-28 18:23:22 -0700201 if (aout) {
202 ptrOut = (uint8_t *)aout->getPtr();
Jason Samsace3e012010-07-15 17:11:13 -0700203 eStrideOut = aout->getType()->getElementSizeBytes();
Jason Samsc61346b2010-05-28 18:23:22 -0700204 }
205
Jason Samsace3e012010-07-15 17:11:13 -0700206 for (uint32_t ar = arrayStart; ar < arrayEnd; ar++) {
207 for (uint32_t z = zStart; z < zEnd; z++) {
208 for (uint32_t y = yStart; y < yEnd; y++) {
209 uint32_t offset = dimX * dimY * dimZ * ar +
210 dimX * dimY * z +
211 dimX * y;
212 uint8_t *xPtrOut = ptrOut + (eStrideOut * offset);
213 const uint8_t *xPtrIn = ptrIn + (eStrideIn * offset);
214
215 for (uint32_t x = xStart; x < xEnd; x++) {
216 ((rs_t)mProgram.mRoot) (xPtrIn, xPtrOut, usr, x, y, z, ar);
217 xPtrIn += eStrideIn;
218 xPtrOut += eStrideOut;
219 }
220 }
221 }
222
Jason Samsc61346b2010-05-28 18:23:22 -0700223 }
224
225 setTLS(oldTLS);
226}
227
Jason Sams22fa3712010-05-19 17:22:57 -0700228void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len)
229{
230 //LOGE("rsi_ScriptInvoke %i", slot);
231 if ((slot >= mEnviroment.mInvokeFunctionCount) ||
232 (mEnviroment.mInvokeFunctions[slot] == NULL)) {
233 rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script");
234 return;
235 }
Jason Samsc61346b2010-05-28 18:23:22 -0700236 setupScript(rsc);
237 Script * oldTLS = setTLS(this);
Jason Sams22fa3712010-05-19 17:22:57 -0700238
Jason Sams2a63bf62010-06-08 15:40:48 -0700239 ((void (*)(const void *, uint32_t))
240 mEnviroment.mInvokeFunctions[slot])(data, len);
241
Jason Samsc61346b2010-05-28 18:23:22 -0700242 setTLS(oldTLS);
Jason Sams22fa3712010-05-19 17:22:57 -0700243}
244
Jason Sams326e0dd2009-05-22 14:03:28 -0700245ScriptCState::ScriptCState()
246{
Jason Sams8c6bc692009-09-16 15:04:38 -0700247 mScript = NULL;
Jason Sams326e0dd2009-05-22 14:03:28 -0700248 clear();
249}
250
251ScriptCState::~ScriptCState()
252{
Jason Sams8c6bc692009-09-16 15:04:38 -0700253 delete mScript;
254 mScript = NULL;
Jason Sams326e0dd2009-05-22 14:03:28 -0700255}
256
257void ScriptCState::clear()
258{
Jason Sams8b2c0652009-08-12 17:54:11 -0700259 for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
260 mConstantBufferTypes[ct].clear();
Jason Sams90b36a82009-08-17 13:56:09 -0700261 mSlotWritable[ct] = false;
Jason Sams8b2c0652009-08-12 17:54:11 -0700262 }
Jason Samsefb8de12009-06-08 15:20:31 -0700263
Jason Sams8c6bc692009-09-16 15:04:38 -0700264 delete mScript;
Jason Samse514b452009-09-25 14:51:22 -0700265 mScript = new ScriptC(NULL);
Jason Sams1f526332009-06-05 17:35:09 -0700266}
267
Jason Samsbe36bf32010-05-11 14:03:58 -0700268static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name)
Jason Sams29df66f2009-07-16 15:08:06 -0700269{
Jason Samsaeb094b2010-05-18 13:35:45 -0700270 const ScriptCState::SymbolTable_t *sym;
271 sym = ScriptCState::lookupSymbol(name);
272 if (sym) {
273 return sym->mPtr;
274 }
275 sym = ScriptCState::lookupSymbolCL(name);
276 if (sym) {
277 return sym->mPtr;
278 }
279 sym = ScriptCState::lookupSymbolGL(name);
Jason Sams29df66f2009-07-16 15:08:06 -0700280 if (sym) {
281 return sym->mPtr;
282 }
Jason Sams29df66f2009-07-16 15:08:06 -0700283 LOGE("ScriptC sym lookup failed for %s", name);
Jason Sams29df66f2009-07-16 15:08:06 -0700284 return NULL;
285}
Jason Samsa4a54e42009-06-10 18:39:40 -0700286
Jason Sams8c6bc692009-09-16 15:04:38 -0700287void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
Jason Sams1f526332009-06-05 17:35:09 -0700288{
Jason Samsace3e012010-07-15 17:11:13 -0700289 LOGV("ScriptCState::runCompiler ");
Jason Sams1f526332009-06-05 17:35:09 -0700290
Jason Samsbe36bf32010-05-11 14:03:58 -0700291 s->mBccScript = bccCreateScript();
292 bccScriptBitcode(s->mBccScript, s->mEnviroment.mScriptText, s->mEnviroment.mScriptTextLength);
293 bccRegisterSymbolCallback(s->mBccScript, symbolLookup, NULL);
Jason Samsbe36bf32010-05-11 14:03:58 -0700294 bccCompileScript(s->mBccScript);
Jason Samsbe36bf32010-05-11 14:03:58 -0700295 bccGetScriptLabel(s->mBccScript, "root", (BCCvoid**) &s->mProgram.mRoot);
296 bccGetScriptLabel(s->mBccScript, "init", (BCCvoid**) &s->mProgram.mInit);
Jason Samsace3e012010-07-15 17:11:13 -0700297 LOGV("root %p, init %p", s->mProgram.mRoot, s->mProgram.mInit);
Jason Samsf1685042009-07-16 17:47:40 -0700298
Jason Sams8c6bc692009-09-16 15:04:38 -0700299 if (s->mProgram.mInit) {
300 s->mProgram.mInit();
Jason Sams1d54f102009-09-03 15:43:13 -0700301 }
302
Jason Sams8c880902010-06-15 12:15:57 -0700303 bccGetExportFuncs(s->mBccScript, (BCCsizei*) &s->mEnviroment.mInvokeFunctionCount, 0, NULL);
304 if(s->mEnviroment.mInvokeFunctionCount <= 0)
305 s->mEnviroment.mInvokeFunctions = NULL;
306 else {
307 s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t*) calloc(s->mEnviroment.mInvokeFunctionCount, sizeof(Script::InvokeFunc_t));
308 bccGetExportFuncs(s->mBccScript, NULL, s->mEnviroment.mInvokeFunctionCount, (BCCvoid **) s->mEnviroment.mInvokeFunctions);
Jason Sams1d54f102009-09-03 15:43:13 -0700309 }
310
Jason Samsbe36bf32010-05-11 14:03:58 -0700311 s->mEnviroment.mFieldAddress = (void **)calloc(100, sizeof(void *));
312 bccGetExportVars(s->mBccScript, (BCCsizei *)&s->mEnviroment.mFieldCount,
313 100, s->mEnviroment.mFieldAddress);
Jason Samsa4a54e42009-06-10 18:39:40 -0700314
Jason Sams8c6bc692009-09-16 15:04:38 -0700315 s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
316 s->mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
Jason Samsccc010b2010-05-13 18:30:11 -0700317 s->mEnviroment.mFragmentStore.set(rsc->getDefaultProgramStore());
Jason Samsb681c8a2009-09-28 18:12:56 -0700318 s->mEnviroment.mRaster.set(rsc->getDefaultProgramRaster());
Jason Sams8c6bc692009-09-16 15:04:38 -0700319
Jason Samsbe36bf32010-05-11 14:03:58 -0700320 if (s->mProgram.mRoot) {
Jason Sams10308932009-06-09 12:15:30 -0700321 const static int pragmaMax = 16;
Jason Samsbe36bf32010-05-11 14:03:58 -0700322 BCCsizei pragmaCount;
323 BCCchar * str[pragmaMax];
324 bccGetPragmas(s->mBccScript, &pragmaCount, pragmaMax, &str[0]);
Jason Sams10308932009-06-09 12:15:30 -0700325
Jason Sams10308932009-06-09 12:15:30 -0700326 for (int ct=0; ct < pragmaCount; ct+=2) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700327 //LOGE("pragme %s %s", str[ct], str[ct+1]);
Jason Sams10308932009-06-09 12:15:30 -0700328 if (!strcmp(str[ct], "version")) {
329 continue;
Jason Sams10308932009-06-09 12:15:30 -0700330 }
331
Jason Sams10308932009-06-09 12:15:30 -0700332 if (!strcmp(str[ct], "stateVertex")) {
Jason Sams8ce125b2009-06-17 16:52:59 -0700333 if (!strcmp(str[ct+1], "default")) {
334 continue;
335 }
336 if (!strcmp(str[ct+1], "parent")) {
Jason Sams8c6bc692009-09-16 15:04:38 -0700337 s->mEnviroment.mVertex.clear();
Jason Sams8ce125b2009-06-17 16:52:59 -0700338 continue;
339 }
Jason Sams10308932009-06-09 12:15:30 -0700340 LOGE("Unreconized value %s passed to stateVertex", str[ct+1]);
341 }
342
343 if (!strcmp(str[ct], "stateRaster")) {
Jason Samsb681c8a2009-09-28 18:12:56 -0700344 if (!strcmp(str[ct+1], "default")) {
345 continue;
346 }
347 if (!strcmp(str[ct+1], "parent")) {
348 s->mEnviroment.mRaster.clear();
349 continue;
350 }
Jason Sams10308932009-06-09 12:15:30 -0700351 LOGE("Unreconized value %s passed to stateRaster", str[ct+1]);
352 }
353
354 if (!strcmp(str[ct], "stateFragment")) {
Jason Sams8ce125b2009-06-17 16:52:59 -0700355 if (!strcmp(str[ct+1], "default")) {
356 continue;
357 }
358 if (!strcmp(str[ct+1], "parent")) {
Jason Sams8c6bc692009-09-16 15:04:38 -0700359 s->mEnviroment.mFragment.clear();
Jason Sams8ce125b2009-06-17 16:52:59 -0700360 continue;
361 }
Jason Sams10308932009-06-09 12:15:30 -0700362 LOGE("Unreconized value %s passed to stateFragment", str[ct+1]);
363 }
364
Jason Samsb681c8a2009-09-28 18:12:56 -0700365 if (!strcmp(str[ct], "stateStore")) {
Jason Sams8ce125b2009-06-17 16:52:59 -0700366 if (!strcmp(str[ct+1], "default")) {
367 continue;
368 }
369 if (!strcmp(str[ct+1], "parent")) {
Jason Sams8c6bc692009-09-16 15:04:38 -0700370 s->mEnviroment.mFragmentStore.clear();
Jason Sams8ce125b2009-06-17 16:52:59 -0700371 continue;
372 }
Jason Samsb681c8a2009-09-28 18:12:56 -0700373 LOGE("Unreconized value %s passed to stateStore", str[ct+1]);
Jason Sams10308932009-06-09 12:15:30 -0700374 }
375
376 }
377
Jason Samsd34b7252009-08-04 16:58:20 -0700378
Jason Sams10308932009-06-09 12:15:30 -0700379 } else {
380 // Deal with an error.
381 }
Jason Sams326e0dd2009-05-22 14:03:28 -0700382}
383
Jason Sams8b2c0652009-08-12 17:54:11 -0700384
Joe Onorato57b79ce2009-08-09 22:57:44 -0700385
Jason Sams326e0dd2009-05-22 14:03:28 -0700386namespace android {
387namespace renderscript {
388
389void rsi_ScriptCBegin(Context * rsc)
390{
391 ScriptCState *ss = &rsc->mScriptC;
392 ss->clear();
393}
394
Jason Samsefb8de12009-06-08 15:20:31 -0700395void rsi_ScriptCSetScript(Context * rsc, void *vp)
Jason Sams326e0dd2009-05-22 14:03:28 -0700396{
Jason Sams8c6bc692009-09-16 15:04:38 -0700397 rsAssert(0);
398 //ScriptCState *ss = &rsc->mScriptC;
399 //ss->mProgram.mScript = reinterpret_cast<ScriptC::RunScript_t>(vp);
Jason Sams326e0dd2009-05-22 14:03:28 -0700400}
401
Jason Sams1f526332009-06-05 17:35:09 -0700402void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len)
403{
404 ScriptCState *ss = &rsc->mScriptC;
Jason Samse402ed32009-11-03 11:25:42 -0800405
406 char *t = (char *)malloc(len + 1);
407 memcpy(t, text, len);
408 t[len] = 0;
409 ss->mScript->mEnviroment.mScriptText = t;
Jason Sams8c6bc692009-09-16 15:04:38 -0700410 ss->mScript->mEnviroment.mScriptTextLength = len;
Jason Sams1f526332009-06-05 17:35:09 -0700411}
412
413
Jason Sams326e0dd2009-05-22 14:03:28 -0700414RsScript rsi_ScriptCCreate(Context * rsc)
415{
416 ScriptCState *ss = &rsc->mScriptC;
417
Jason Sams8c6bc692009-09-16 15:04:38 -0700418 ScriptC *s = ss->mScript;
419 ss->mScript = NULL;
Jason Sams1f526332009-06-05 17:35:09 -0700420
Jason Sams8c6bc692009-09-16 15:04:38 -0700421 ss->runCompiler(rsc, s);
Jason Sams9397e302009-08-27 20:23:34 -0700422 s->incUserRef();
Jason Samse514b452009-09-25 14:51:22 -0700423 s->setContext(rsc);
Jason Samsfa517192009-08-13 12:59:04 -0700424 for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
425 s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
Jason Sams90b36a82009-08-17 13:56:09 -0700426 s->mSlotWritable[ct] = ss->mSlotWritable[ct];
Jason Samsfa517192009-08-13 12:59:04 -0700427 }
Jason Sams10308932009-06-09 12:15:30 -0700428
Jason Samsfa517192009-08-13 12:59:04 -0700429 ss->clear();
Jason Sams326e0dd2009-05-22 14:03:28 -0700430 return s;
431}
432
Jason Sams326e0dd2009-05-22 14:03:28 -0700433}
434}
435
436