Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 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" |
Joe Onorato | 9c4e4ca | 2009-08-09 11:39:02 -0700 | [diff] [blame] | 19 | #include "utils/Timers.h" |
Alex Sakhartchouk | b26fb04 | 2010-09-24 15:18:12 -0700 | [diff] [blame] | 20 | #include "utils/StopWatch.h" |
Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 21 | |
Jason Sams | 1aa5a4e | 2009-06-22 17:15:15 -0700 | [diff] [blame] | 22 | #include <GLES/gl.h> |
| 23 | #include <GLES/glext.h> |
| 24 | |
Alex Sakhartchouk | 02000b3 | 2011-02-25 09:34:33 -0800 | [diff] [blame] | 25 | #include <bcc/bcc.h> |
| 26 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | using namespace android; |
| 28 | using namespace android::renderscript; |
| 29 | |
Jason Sams | e576910 | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 30 | #define GET_TLS() Context::ScriptTLSStruct * tls = \ |
| 31 | (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \ |
| 32 | Context * rsc = tls->mContext; \ |
| 33 | ScriptC * sc = (ScriptC *) tls->mScript |
| 34 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 35 | ScriptC::ScriptC(Context *rsc) : Script(rsc) { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 38 | ScriptC::~ScriptC() { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 39 | mRSC->mHal.funcs.script.destroy(mRSC, this); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 42 | void ScriptC::setupScript(Context *rsc) { |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 43 | mEnviroment.mStartTimeMillis |
| 44 | = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC)); |
| 45 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 46 | for (uint32_t ct=0; ct < mHal.info.exportedVariableCount; ct++) { |
Jason Sams | 900f161 | 2010-09-16 18:18:29 -0700 | [diff] [blame] | 47 | if (mSlots[ct].get() && !mTypes[ct].get()) { |
| 48 | mTypes[ct].set(mSlots[ct]->getType()); |
| 49 | } |
| 50 | |
| 51 | if (!mTypes[ct].get()) |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 52 | continue; |
Jason Sams | 900f161 | 2010-09-16 18:18:29 -0700 | [diff] [blame] | 53 | void *ptr = NULL; |
| 54 | if (mSlots[ct].get()) { |
| 55 | ptr = mSlots[ct]->getPtr(); |
| 56 | } |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 57 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 58 | rsc->mHal.funcs.script.setGlobalBind(rsc, this, ct, ptr); |
Jason Sams | ada7f27 | 2009-09-24 14:55:38 -0700 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 62 | const Allocation *ScriptC::ptrToAllocation(const void *ptr) const { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 63 | //LOGE("ptr to alloc %p", ptr); |
Jason Sams | ce92d4b | 2010-05-17 14:55:34 -0700 | [diff] [blame] | 64 | if (!ptr) { |
| 65 | return NULL; |
| 66 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 67 | for (uint32_t ct=0; ct < mHal.info.exportedVariableCount; ct++) { |
Jason Sams | ce92d4b | 2010-05-17 14:55:34 -0700 | [diff] [blame] | 68 | if (!mSlots[ct].get()) |
| 69 | continue; |
| 70 | if (mSlots[ct]->getPtr() == ptr) { |
| 71 | return mSlots[ct].get(); |
| 72 | } |
| 73 | } |
| 74 | LOGE("ScriptC::ptrToAllocation, failed to find %p", ptr); |
| 75 | return NULL; |
| 76 | } |
| 77 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 78 | void ScriptC::setupGLState(Context *rsc) { |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 79 | if (mEnviroment.mFragmentStore.get()) { |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 80 | rsc->setProgramStore(mEnviroment.mFragmentStore.get()); |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 81 | } |
| 82 | if (mEnviroment.mFragment.get()) { |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 83 | rsc->setProgramFragment(mEnviroment.mFragment.get()); |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 84 | } |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 85 | if (mEnviroment.mVertex.get()) { |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 86 | rsc->setProgramVertex(mEnviroment.mVertex.get()); |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 87 | } |
Jason Sams | b681c8a | 2009-09-28 18:12:56 -0700 | [diff] [blame] | 88 | if (mEnviroment.mRaster.get()) { |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 89 | rsc->setProgramRaster(mEnviroment.mRaster.get()); |
Jason Sams | b681c8a | 2009-09-28 18:12:56 -0700 | [diff] [blame] | 90 | } |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 91 | } |
Jason Sams | a0a1b6f | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 92 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 93 | uint32_t ScriptC::run(Context *rsc) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 94 | if (mHal.info.root == NULL) { |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 95 | rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script"); |
| 96 | return 0; |
Joe Onorato | 9c4e4ca | 2009-08-09 11:39:02 -0700 | [diff] [blame] | 97 | } |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 98 | |
Jason Sams | 1f24db4 | 2010-12-11 17:42:30 -0800 | [diff] [blame] | 99 | setupGLState(rsc); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 100 | setupScript(rsc); |
Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 101 | |
Jason Sams | 2dca84d | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 102 | uint32_t ret = 0; |
Jason Sams | b9077f4 | 2010-09-22 15:57:41 -0700 | [diff] [blame] | 103 | |
| 104 | if (rsc->props.mLogScripts) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 105 | LOGV("%p ScriptC::run invoking root, ptr %p", rsc, mHal.info.root); |
Jason Sams | b9077f4 | 2010-09-22 15:57:41 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 108 | ret = rsc->mHal.funcs.script.invokeRoot(rsc, this); |
Jason Sams | b9077f4 | 2010-09-22 15:57:41 -0700 | [diff] [blame] | 109 | |
| 110 | if (rsc->props.mLogScripts) { |
| 111 | LOGV("%p ScriptC::run invoking complete, ret=%i", rsc, ret); |
| 112 | } |
| 113 | |
Jason Sams | e45ac6e | 2009-07-20 14:31:06 -0700 | [diff] [blame] | 114 | return ret; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Jason Sams | 177f844 | 2010-10-29 10:19:21 -0700 | [diff] [blame] | 117 | |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 118 | void ScriptC::runForEach(Context *rsc, |
| 119 | const Allocation * ain, |
| 120 | Allocation * aout, |
| 121 | const void * usr, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 122 | size_t usrBytes, |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 123 | const RsScriptCall *sc) { |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 124 | |
Jason Sams | 6070925 | 2010-11-17 15:29:32 -0800 | [diff] [blame] | 125 | Context::PushState ps(rsc); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 126 | |
Jason Sams | 1f24db4 | 2010-12-11 17:42:30 -0800 | [diff] [blame] | 127 | setupGLState(rsc); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 128 | setupScript(rsc); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 129 | rsc->mHal.funcs.script.invokeForEach(rsc, this, ain, aout, usr, usrBytes, sc); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 132 | void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 133 | if (slot >= mHal.info.exportedFunctionCount) { |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 134 | rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); |
| 135 | return; |
| 136 | } |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 137 | setupScript(rsc); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 138 | |
Jason Sams | b9077f4 | 2010-09-22 15:57:41 -0700 | [diff] [blame] | 139 | if (rsc->props.mLogScripts) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 140 | LOGV("%p ScriptC::Invoke invoking slot %i, ptr %p", rsc, slot, this); |
Jason Sams | b9077f4 | 2010-09-22 15:57:41 -0700 | [diff] [blame] | 141 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 142 | rsc->mHal.funcs.script.invokeFunction(rsc, this, slot, data, len); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 145 | ScriptCState::ScriptCState() { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 148 | ScriptCState::~ScriptCState() { |
Jason Sams | 1f52633 | 2009-06-05 17:35:09 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 151 | /* |
Shih-wei Liao | 2b2e621 | 2011-01-14 06:21:28 -0800 | [diff] [blame] | 152 | static void* symbolLookup(void* pContext, char const* name) { |
Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 153 | const ScriptCState::SymbolTable_t *sym; |
Jason Sams | dd663fa | 2010-08-11 13:26:28 -0700 | [diff] [blame] | 154 | ScriptC *s = (ScriptC *)pContext; |
Shih-wei Liao | f17b13b | 2010-12-07 13:44:10 -0800 | [diff] [blame] | 155 | if (!strcmp(name, "__isThreadable")) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 156 | return (void*) s->mHal.info.isThreadable; |
Shih-wei Liao | f17b13b | 2010-12-07 13:44:10 -0800 | [diff] [blame] | 157 | } else if (!strcmp(name, "__clearThreadable")) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 158 | s->mHal.info.isThreadable = false; |
Shih-wei Liao | f17b13b | 2010-12-07 13:44:10 -0800 | [diff] [blame] | 159 | return NULL; |
| 160 | } |
Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 161 | sym = ScriptCState::lookupSymbol(name); |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 162 | if (!sym) { |
| 163 | sym = ScriptCState::lookupSymbolCL(name); |
Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 164 | } |
Jason Sams | 6bfc1b9 | 2010-11-01 14:26:30 -0700 | [diff] [blame] | 165 | if (!sym) { |
| 166 | sym = ScriptCState::lookupSymbolGL(name); |
Jason Sams | aeb094b | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 167 | } |
Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 168 | if (sym) { |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 169 | s->mHal.info.isThreadable &= sym->threadable; |
Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 170 | return sym->mPtr; |
| 171 | } |
Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 172 | LOGE("ScriptC sym lookup failed for %s", name); |
Jason Sams | 29df66f | 2009-07-16 15:08:06 -0700 | [diff] [blame] | 173 | return NULL; |
| 174 | } |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 175 | */ |
Jason Sams | a4a54e4 | 2009-06-10 18:39:40 -0700 | [diff] [blame] | 176 | |
Shih-wei Liao | 80761ec | 2011-01-16 02:23:04 -0800 | [diff] [blame] | 177 | #if 0 |
Shih-wei Liao | 1f9ba73 | 2010-10-23 02:15:57 -0700 | [diff] [blame] | 178 | extern const char rs_runtime_lib_bc[]; |
| 179 | extern unsigned rs_runtime_lib_bc_size; |
Shih-wei Liao | 80761ec | 2011-01-16 02:23:04 -0800 | [diff] [blame] | 180 | #endif |
Shih-wei Liao | 1f9ba73 | 2010-10-23 02:15:57 -0700 | [diff] [blame] | 181 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 182 | bool ScriptC::runCompiler(Context *rsc, |
| 183 | const char *resName, |
| 184 | const char *cacheDir, |
| 185 | const uint8_t *bitcode, |
| 186 | size_t bitcodeLen) { |
Shih-wei Liao | 37150de | 2011-01-07 18:17:07 -0800 | [diff] [blame] | 187 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 188 | //LOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen); |
Shih-wei Liao | 37150de | 2011-01-07 18:17:07 -0800 | [diff] [blame] | 189 | |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 190 | rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0); |
Shih-wei Liao | 37150de | 2011-01-07 18:17:07 -0800 | [diff] [blame] | 191 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 192 | mEnviroment.mFragment.set(rsc->getDefaultProgramFragment()); |
| 193 | mEnviroment.mVertex.set(rsc->getDefaultProgramVertex()); |
| 194 | mEnviroment.mFragmentStore.set(rsc->getDefaultProgramStore()); |
| 195 | mEnviroment.mRaster.set(rsc->getDefaultProgramRaster()); |
Shih-wei Liao | 37150de | 2011-01-07 18:17:07 -0800 | [diff] [blame] | 196 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 197 | rsc->mHal.funcs.script.invokeInit(rsc, this); |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 198 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 199 | for (size_t i=0; i < mHal.info.exportedPragmaCount; ++i) { |
| 200 | const char * key = mHal.info.exportedPragmaKeyList[i]; |
| 201 | const char * value = mHal.info.exportedPragmaValueList[i]; |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 202 | //LOGE("pragma %s %s", keys[i], values[i]); |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 203 | if (!strcmp(key, "version")) { |
| 204 | if (!strcmp(value, "1")) { |
Stephen Hines | b5dc6af | 2011-01-18 14:10:44 -0800 | [diff] [blame] | 205 | continue; |
| 206 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 207 | LOGE("Invalid version pragma value: %s\n", value); |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 208 | return false; |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 209 | } |
| 210 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 211 | if (!strcmp(key, "stateVertex")) { |
| 212 | if (!strcmp(value, "default")) { |
Jason Sams | 1030893 | 2009-06-09 12:15:30 -0700 | [diff] [blame] | 213 | continue; |
Jason Sams | 1030893 | 2009-06-09 12:15:30 -0700 | [diff] [blame] | 214 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 215 | if (!strcmp(value, "parent")) { |
| 216 | mEnviroment.mVertex.clear(); |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 217 | continue; |
Jason Sams | 1030893 | 2009-06-09 12:15:30 -0700 | [diff] [blame] | 218 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 219 | LOGE("Unrecognized value %s passed to stateVertex", value); |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 220 | return false; |
Jason Sams | 1030893 | 2009-06-09 12:15:30 -0700 | [diff] [blame] | 221 | } |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 222 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 223 | if (!strcmp(key, "stateRaster")) { |
| 224 | if (!strcmp(value, "default")) { |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 225 | continue; |
| 226 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 227 | if (!strcmp(value, "parent")) { |
| 228 | mEnviroment.mRaster.clear(); |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 229 | continue; |
| 230 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 231 | LOGE("Unrecognized value %s passed to stateRaster", value); |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 232 | return false; |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 233 | } |
| 234 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 235 | if (!strcmp(key, "stateFragment")) { |
| 236 | if (!strcmp(value, "default")) { |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 237 | continue; |
| 238 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 239 | if (!strcmp(value, "parent")) { |
| 240 | mEnviroment.mFragment.clear(); |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 241 | continue; |
| 242 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 243 | LOGE("Unrecognized value %s passed to stateFragment", value); |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 244 | return false; |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 245 | } |
| 246 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 247 | if (!strcmp(key, "stateStore")) { |
| 248 | if (!strcmp(value, "default")) { |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 249 | continue; |
| 250 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 251 | if (!strcmp(value, "parent")) { |
| 252 | mEnviroment.mFragmentStore.clear(); |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 253 | continue; |
| 254 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 255 | LOGE("Unrecognized value %s passed to stateStore", value); |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 256 | return false; |
Stephen Hines | 7b337b1 | 2011-01-17 17:31:58 -0800 | [diff] [blame] | 257 | } |
Jason Sams | 1030893 | 2009-06-09 12:15:30 -0700 | [diff] [blame] | 258 | } |
Jason Sams | 2e8665d | 2011-01-27 00:14:13 -0800 | [diff] [blame] | 259 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 260 | mSlots = new ObjectBaseRef<Allocation>[mHal.info.exportedVariableCount]; |
| 261 | mTypes = new ObjectBaseRef<const Type>[mHal.info.exportedVariableCount]; |
Jason Sams | 2e8665d | 2011-01-27 00:14:13 -0800 | [diff] [blame] | 262 | |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 263 | return true; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | namespace android { |
| 267 | namespace renderscript { |
| 268 | |
Shih-wei Liao | ce8a079 | 2010-12-20 20:45:56 +0800 | [diff] [blame] | 269 | RsScript rsi_ScriptCCreate(Context *rsc, |
Alex Sakhartchouk | 70b83c1 | 2011-04-06 10:57:51 -0700 | [diff] [blame^] | 270 | const char *resName, size_t resName_length, |
| 271 | const char *cacheDir, size_t cacheDir_length, |
| 272 | const char *text, uint32_t text_length) |
Shih-wei Liao | 9503b66 | 2010-11-08 01:33:59 -0800 | [diff] [blame] | 273 | { |
Jason Sams | 249d453 | 2011-01-23 17:48:45 -0800 | [diff] [blame] | 274 | ScriptC *s = new ScriptC(rsc); |
Jason Sams | 1f52633 | 2009-06-05 17:35:09 -0700 | [diff] [blame] | 275 | |
Alex Sakhartchouk | 70b83c1 | 2011-04-06 10:57:51 -0700 | [diff] [blame^] | 276 | if (!s->runCompiler(rsc, resName, cacheDir, (uint8_t *)text, text_length)) { |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 277 | // Error during compile, destroy s and return null. |
Jason Sams | 249d453 | 2011-01-23 17:48:45 -0800 | [diff] [blame] | 278 | delete s; |
Jason Sams | 26b2c9f | 2011-01-19 16:14:21 -0800 | [diff] [blame] | 279 | return NULL; |
| 280 | } |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 281 | |
| 282 | s->incUserRef(); |
Jason Sams | 249d453 | 2011-01-23 17:48:45 -0800 | [diff] [blame] | 283 | return s; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 286 | } |
| 287 | } |