rsScriptC.cpp revision b2cfc988101f93ee5e1fbcfc717230dee71aee3b
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" 19#include "rsMatrix.h" 20#include "utils/Timers.h" 21#include "utils/StopWatch.h" 22extern "C" { 23#include "libdex/ZipArchive.h" 24} 25 26#include <GLES/gl.h> 27#include <GLES/glext.h> 28 29using namespace android; 30using namespace android::renderscript; 31 32#define GET_TLS() Context::ScriptTLSStruct * tls = \ 33 (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \ 34 Context * rsc = tls->mContext; \ 35 ScriptC * sc = (ScriptC *) tls->mScript 36 37// Input: cacheDir 38// Input: resName 39// Input: extName 40// 41// Note: cacheFile = resName + extName 42// 43// Output: Returns cachePath == cacheDir + cacheFile 44char *genCacheFileName(const char *cacheDir, 45 const char *resName, 46 const char *extName) { 47 char cachePath[512]; 48 char cacheFile[sizeof(cachePath)]; 49 const size_t kBufLen = sizeof(cachePath) - 1; 50 51 cacheFile[0] = '\0'; 52 // Note: resName today is usually something like 53 // "/com.android.fountain:raw/fountain" 54 if (resName[0] != '/') { 55 // Get the absolute path of the raw/***.bc file. 56 57 // Generate the absolute path. This doesn't do everything it 58 // should, e.g. if resName is "./out/whatever" it doesn't crunch 59 // the leading "./" out because this if-block is not triggered, 60 // but it'll make do. 61 // 62 if (getcwd(cacheFile, kBufLen) == NULL) { 63 LOGE("Can't get CWD while opening raw/***.bc file\n"); 64 return NULL; 65 } 66 // Append "/" at the end of cacheFile so far. 67 strncat(cacheFile, "/", kBufLen); 68 } 69 70 // cacheFile = resName + extName 71 // 72 strncat(cacheFile, resName, kBufLen); 73 if (extName != NULL) { 74 // TODO(srhines): strncat() is a bit dangerous 75 strncat(cacheFile, extName, kBufLen); 76 } 77 78 // Turn the path into a flat filename by replacing 79 // any slashes after the first one with '@' characters. 80 char *cp = cacheFile + 1; 81 while (*cp != '\0') { 82 if (*cp == '/') { 83 *cp = '@'; 84 } 85 cp++; 86 } 87 88 // Tack on the file name for the actual cache file path. 89 strncpy(cachePath, cacheDir, kBufLen); 90 strncat(cachePath, cacheFile, kBufLen); 91 92 LOGV("Cache file for '%s' '%s' is '%s'\n", resName, extName, cachePath); 93 return strdup(cachePath); 94} 95 96ScriptC::ScriptC(Context *rsc) : Script(rsc) { 97 LOGD(">>>> ScriptC ctor called, obj=%p", this); 98 mBccScript = NULL; 99 memset(&mProgram, 0, sizeof(mProgram)); 100} 101 102ScriptC::~ScriptC() { 103 LOGD(">>>> ~ScriptC() mBccScript = %p", mBccScript); 104 if (mBccScript) { 105 bccDisposeScript(mBccScript); 106 LOGD(">>>> ~ScriptC(mBCCScript)"); 107 } 108 free(mEnviroment.mScriptText); 109 mEnviroment.mScriptText = NULL; 110} 111 112void ScriptC::setupScript(Context *rsc) { 113 mEnviroment.mStartTimeMillis 114 = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC)); 115 116 for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) { 117 if (mSlots[ct].get() && !mTypes[ct].get()) { 118 mTypes[ct].set(mSlots[ct]->getType()); 119 } 120 121 if (!mTypes[ct].get()) 122 continue; 123 void *ptr = NULL; 124 if (mSlots[ct].get()) { 125 ptr = mSlots[ct]->getPtr(); 126 } 127 void **dest = ((void ***)mEnviroment.mFieldAddress)[ct]; 128 129 if (rsc->props.mLogScripts) { 130 if (mSlots[ct].get() != NULL) { 131 LOGV("%p ScriptC::setupScript slot=%i dst=%p src=%p type=%p", rsc, ct, dest, ptr, mSlots[ct]->getType()); 132 } else { 133 LOGV("%p ScriptC::setupScript slot=%i dst=%p src=%p type=null", rsc, ct, dest, ptr); 134 } 135 } 136 137 if (dest) { 138 *dest = ptr; 139 } 140 } 141} 142 143const Allocation *ScriptC::ptrToAllocation(const void *ptr) const { 144 if (!ptr) { 145 return NULL; 146 } 147 for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) { 148 if (!mSlots[ct].get()) 149 continue; 150 if (mSlots[ct]->getPtr() == ptr) { 151 return mSlots[ct].get(); 152 } 153 } 154 LOGE("ScriptC::ptrToAllocation, failed to find %p", ptr); 155 return NULL; 156} 157 158Script * ScriptC::setTLS(Script *sc) { 159 Context::ScriptTLSStruct * tls = (Context::ScriptTLSStruct *) 160 pthread_getspecific(Context::gThreadTLSKey); 161 rsAssert(tls); 162 Script *old = tls->mScript; 163 tls->mScript = sc; 164 return old; 165} 166 167void ScriptC::setupGLState(Context *rsc) { 168 if (mEnviroment.mFragmentStore.get()) { 169 rsc->setProgramStore(mEnviroment.mFragmentStore.get()); 170 } 171 if (mEnviroment.mFragment.get()) { 172 rsc->setProgramFragment(mEnviroment.mFragment.get()); 173 } 174 if (mEnviroment.mVertex.get()) { 175 rsc->setProgramVertex(mEnviroment.mVertex.get()); 176 } 177 if (mEnviroment.mRaster.get()) { 178 rsc->setProgramRaster(mEnviroment.mRaster.get()); 179 } 180} 181 182uint32_t ScriptC::run(Context *rsc) { 183 if (mProgram.mRoot == NULL) { 184 rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script"); 185 return 0; 186 } 187 188 setupGLState(rsc); 189 setupScript(rsc); 190 191 uint32_t ret = 0; 192 Script * oldTLS = setTLS(this); 193 194 if (rsc->props.mLogScripts) { 195 LOGV("%p ScriptC::run invoking root, ptr %p", rsc, mProgram.mRoot); 196 } 197 198 ret = mProgram.mRoot(); 199 200 if (rsc->props.mLogScripts) { 201 LOGV("%p ScriptC::run invoking complete, ret=%i", rsc, ret); 202 } 203 204 setTLS(oldTLS); 205 return ret; 206} 207 208typedef struct { 209 Context *rsc; 210 ScriptC *script; 211 const Allocation * ain; 212 Allocation * aout; 213 const void * usr; 214 215 uint32_t mSliceSize; 216 volatile int mSliceNum; 217 218 const uint8_t *ptrIn; 219 uint32_t eStrideIn; 220 uint8_t *ptrOut; 221 uint32_t eStrideOut; 222 223 uint32_t xStart; 224 uint32_t xEnd; 225 uint32_t yStart; 226 uint32_t yEnd; 227 uint32_t zStart; 228 uint32_t zEnd; 229 uint32_t arrayStart; 230 uint32_t arrayEnd; 231 232 uint32_t dimX; 233 uint32_t dimY; 234 uint32_t dimZ; 235 uint32_t dimArray; 236} MTLaunchStruct; 237typedef int (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t); 238 239static void wc_xy(void *usr, uint32_t idx) { 240 MTLaunchStruct *mtls = (MTLaunchStruct *)usr; 241 242 while (1) { 243 uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum); 244 uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize; 245 uint32_t yEnd = yStart + mtls->mSliceSize; 246 yEnd = rsMin(yEnd, mtls->yEnd); 247 if (yEnd <= yStart) { 248 return; 249 } 250 251 //LOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd); 252 //LOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut); 253 for (uint32_t y = yStart; y < yEnd; y++) { 254 uint32_t offset = mtls->dimX * y; 255 uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * offset); 256 const uint8_t *xPtrIn = mtls->ptrIn + (mtls->eStrideIn * offset); 257 258 for (uint32_t x = mtls->xStart; x < mtls->xEnd; x++) { 259 ((rs_t)mtls->script->mProgram.mRoot) (xPtrIn, xPtrOut, mtls->usr, x, y, 0, 0); 260 xPtrIn += mtls->eStrideIn; 261 xPtrOut += mtls->eStrideOut; 262 } 263 } 264 } 265} 266 267static void wc_x(void *usr, uint32_t idx) { 268 MTLaunchStruct *mtls = (MTLaunchStruct *)usr; 269 270 while (1) { 271 uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum); 272 uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize; 273 uint32_t xEnd = xStart + mtls->mSliceSize; 274 xEnd = rsMin(xEnd, mtls->xEnd); 275 if (xEnd <= xStart) { 276 return; 277 } 278 279 //LOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd); 280 //LOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut); 281 uint8_t *xPtrOut = mtls->ptrOut + (mtls->eStrideOut * xStart); 282 const uint8_t *xPtrIn = mtls->ptrIn + (mtls->eStrideIn * xStart); 283 for (uint32_t x = xStart; x < xEnd; x++) { 284 ((rs_t)mtls->script->mProgram.mRoot) (xPtrIn, xPtrOut, mtls->usr, x, 0, 0, 0); 285 xPtrIn += mtls->eStrideIn; 286 xPtrOut += mtls->eStrideOut; 287 } 288 } 289} 290 291void ScriptC::runForEach(Context *rsc, 292 const Allocation * ain, 293 Allocation * aout, 294 const void * usr, 295 const RsScriptCall *sc) { 296 MTLaunchStruct mtls; 297 memset(&mtls, 0, sizeof(mtls)); 298 Context::PushState ps(rsc); 299 300 if (ain) { 301 mtls.dimX = ain->getType()->getDimX(); 302 mtls.dimY = ain->getType()->getDimY(); 303 mtls.dimZ = ain->getType()->getDimZ(); 304 //mtls.dimArray = ain->getType()->getDimArray(); 305 } else if (aout) { 306 mtls.dimX = aout->getType()->getDimX(); 307 mtls.dimY = aout->getType()->getDimY(); 308 mtls.dimZ = aout->getType()->getDimZ(); 309 //mtls.dimArray = aout->getType()->getDimArray(); 310 } else { 311 rsc->setError(RS_ERROR_BAD_SCRIPT, "rsForEach called with null allocations"); 312 return; 313 } 314 315 if (!sc || (sc->xEnd == 0)) { 316 mtls.xEnd = mtls.dimX; 317 } else { 318 rsAssert(sc->xStart < mtls.dimX); 319 rsAssert(sc->xEnd <= mtls.dimX); 320 rsAssert(sc->xStart < sc->xEnd); 321 mtls.xStart = rsMin(mtls.dimX, sc->xStart); 322 mtls.xEnd = rsMin(mtls.dimX, sc->xEnd); 323 if (mtls.xStart >= mtls.xEnd) return; 324 } 325 326 if (!sc || (sc->yEnd == 0)) { 327 mtls.yEnd = mtls.dimY; 328 } else { 329 rsAssert(sc->yStart < mtls.dimY); 330 rsAssert(sc->yEnd <= mtls.dimY); 331 rsAssert(sc->yStart < sc->yEnd); 332 mtls.yStart = rsMin(mtls.dimY, sc->yStart); 333 mtls.yEnd = rsMin(mtls.dimY, sc->yEnd); 334 if (mtls.yStart >= mtls.yEnd) return; 335 } 336 337 mtls.xEnd = rsMax((uint32_t)1, mtls.xEnd); 338 mtls.yEnd = rsMax((uint32_t)1, mtls.yEnd); 339 mtls.zEnd = rsMax((uint32_t)1, mtls.zEnd); 340 mtls.arrayEnd = rsMax((uint32_t)1, mtls.arrayEnd); 341 342 rsAssert(ain->getType()->getDimZ() == 0); 343 344 setupGLState(rsc); 345 setupScript(rsc); 346 Script * oldTLS = setTLS(this); 347 348 mtls.rsc = rsc; 349 mtls.ain = ain; 350 mtls.aout = aout; 351 mtls.script = this; 352 mtls.usr = usr; 353 mtls.mSliceSize = 10; 354 mtls.mSliceNum = 0; 355 356 mtls.ptrIn = NULL; 357 mtls.eStrideIn = 0; 358 if (ain) { 359 mtls.ptrIn = (const uint8_t *)ain->getPtr(); 360 mtls.eStrideIn = ain->getType()->getElementSizeBytes(); 361 } 362 363 mtls.ptrOut = NULL; 364 mtls.eStrideOut = 0; 365 if (aout) { 366 mtls.ptrOut = (uint8_t *)aout->getPtr(); 367 mtls.eStrideOut = aout->getType()->getElementSizeBytes(); 368 } 369 370 if ((rsc->getWorkerPoolSize() > 1) && mEnviroment.mIsThreadable) { 371 if (mtls.dimY > 1) { 372 rsc->launchThreads(wc_xy, &mtls); 373 } else { 374 rsc->launchThreads(wc_x, &mtls); 375 } 376 377 //LOGE("launch 1"); 378 } else { 379 //LOGE("launch 3"); 380 for (uint32_t ar = mtls.arrayStart; ar < mtls.arrayEnd; ar++) { 381 for (uint32_t z = mtls.zStart; z < mtls.zEnd; z++) { 382 for (uint32_t y = mtls.yStart; y < mtls.yEnd; y++) { 383 uint32_t offset = mtls.dimX * mtls.dimY * mtls.dimZ * ar + 384 mtls.dimX * mtls.dimY * z + 385 mtls.dimX * y; 386 uint8_t *xPtrOut = mtls.ptrOut + (mtls.eStrideOut * offset); 387 const uint8_t *xPtrIn = mtls.ptrIn + (mtls.eStrideIn * offset); 388 389 for (uint32_t x = mtls.xStart; x < mtls.xEnd; x++) { 390 ((rs_t)mProgram.mRoot) (xPtrIn, xPtrOut, usr, x, y, z, ar); 391 xPtrIn += mtls.eStrideIn; 392 xPtrOut += mtls.eStrideOut; 393 } 394 } 395 } 396 } 397 } 398 399 setTLS(oldTLS); 400} 401 402void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) { 403 if ((slot >= mEnviroment.mInvokeFunctionCount) || 404 (mEnviroment.mInvokeFunctions[slot] == NULL)) { 405 rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); 406 return; 407 } 408 setupScript(rsc); 409 Script * oldTLS = setTLS(this); 410 411 if (rsc->props.mLogScripts) { 412 LOGV("%p ScriptC::Invoke invoking slot %i, ptr %p", rsc, slot, mEnviroment.mInvokeFunctions[slot]); 413 } 414 ((void (*)(const void *, uint32_t)) 415 mEnviroment.mInvokeFunctions[slot])(data, len); 416 if (rsc->props.mLogScripts) { 417 LOGV("%p ScriptC::Invoke complete", rsc); 418 } 419 420 setTLS(oldTLS); 421} 422 423ScriptCState::ScriptCState() { 424 mScript.clear(); 425} 426 427ScriptCState::~ScriptCState() { 428 mScript.clear(); 429} 430 431void ScriptCState::init(Context *rsc) { 432 clear(rsc); 433} 434 435void ScriptCState::clear(Context *rsc) { 436 rsAssert(rsc); 437 mScript.clear(); 438 mScript.set(new ScriptC(rsc)); 439} 440 441static void* symbolLookup(void* pContext, char const* name) { 442 const ScriptCState::SymbolTable_t *sym; 443 ScriptC *s = (ScriptC *)pContext; 444 if (!strcmp(name, "__isThreadable")) { 445 return (void*) s->mEnviroment.mIsThreadable; 446 } else if (!strcmp(name, "__clearThreadable")) { 447 s->mEnviroment.mIsThreadable = false; 448 return NULL; 449 } 450 sym = ScriptCState::lookupSymbol(name); 451 if (!sym) { 452 sym = ScriptCState::lookupSymbolCL(name); 453 } 454 if (!sym) { 455 sym = ScriptCState::lookupSymbolGL(name); 456 } 457 if (sym) { 458 s->mEnviroment.mIsThreadable &= sym->threadable; 459 return sym->mPtr; 460 } 461 LOGE("ScriptC sym lookup failed for %s", name); 462 return NULL; 463} 464 465#if 0 466extern const char rs_runtime_lib_bc[]; 467extern unsigned rs_runtime_lib_bc_size; 468#endif 469 470void ScriptCState::runCompiler(Context *rsc, 471 ScriptC *s, 472 const char *resName, 473 const char *cacheDir) { 474 { 475 s->mBccScript = bccCreateScript(); 476 477 s->mEnviroment.mIsThreadable = true; 478 479 bccRegisterSymbolCallback(s->mBccScript, symbolLookup, s); 480 481 if (bccReadBC(s->mBccScript, 482 resName, 483 s->mEnviroment.mScriptText, 484 s->mEnviroment.mScriptTextLength, 0) != 0) { 485 LOGE("bcc: FAILS to read bitcode"); 486 // Handle Fatal Error 487 } 488 489#if 1 490 if (bccLinkBC(s->mBccScript, 491 resName, 492 NULL /*rs_runtime_lib_bc*/, 493 1 /*rs_runtime_lib_bc_size*/ 494 /*"1" means skip buffer here, and let libbcc decide*/, 495 0) != 0) { 496 LOGE("bcc: FAILS to link bitcode"); 497 // Handle Fatal Error 498 } 499#endif 500 char *cachePath = genCacheFileName(cacheDir, resName, ".oBCC"); 501 502 if (bccPrepareExecutable(s->mBccScript, cachePath, 0) != 0) { 503 LOGE("bcc: FAILS to prepare executable"); 504 // Handle Fatal Error 505 } 506 507 free(cachePath); 508 509 s->mProgram.mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(s->mBccScript, "root")); 510 s->mProgram.mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(s->mBccScript, "init")); 511 } 512 LOGV("%p ScriptCState::runCompiler root %p, init %p", rsc, s->mProgram.mRoot, s->mProgram.mInit); 513 514 if (s->mProgram.mInit) { 515 s->mProgram.mInit(); 516 } 517 518 s->mEnviroment.mInvokeFunctionCount = bccGetExportFuncCount(s->mBccScript); 519 if (s->mEnviroment.mInvokeFunctionCount <= 0) 520 s->mEnviroment.mInvokeFunctions = NULL; 521 else { 522 s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t*) calloc(s->mEnviroment.mInvokeFunctionCount, sizeof(Script::InvokeFunc_t)); 523 bccGetExportFuncList(s->mBccScript, s->mEnviroment.mInvokeFunctionCount, (void **) s->mEnviroment.mInvokeFunctions); 524 } 525 526 s->mEnviroment.mFieldCount = bccGetExportVarCount(s->mBccScript); 527 if (s->mEnviroment.mFieldCount <= 0) 528 s->mEnviroment.mFieldAddress = NULL; 529 else { 530 s->mEnviroment.mFieldAddress = (void **) calloc(s->mEnviroment.mFieldCount, sizeof(void *)); 531 bccGetExportVarList(s->mBccScript, s->mEnviroment.mFieldCount, (void **) s->mEnviroment.mFieldAddress); 532 s->initSlots(); 533 } 534 535 s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment()); 536 s->mEnviroment.mVertex.set(rsc->getDefaultProgramVertex()); 537 s->mEnviroment.mFragmentStore.set(rsc->getDefaultProgramStore()); 538 s->mEnviroment.mRaster.set(rsc->getDefaultProgramRaster()); 539 540 if (s->mProgram.mRoot) { 541 const static int pragmaMax = 16; 542 size_t pragmaCount = bccGetPragmaCount(s->mBccScript); 543 char const *keys[pragmaMax]; 544 char const *values[pragmaMax]; 545 bccGetPragmaList(s->mBccScript, pragmaMax, keys, values); 546 547 for (size_t i=0; i < pragmaCount; ++i) { 548 //LOGE("pragma %s %s", keys[i], values[i]); 549 if (!strcmp(keys[i], "version")) { 550 continue; 551 } 552 553 if (!strcmp(keys[i], "stateVertex")) { 554 if (!strcmp(values[i], "default")) { 555 continue; 556 } 557 if (!strcmp(values[i], "parent")) { 558 s->mEnviroment.mVertex.clear(); 559 continue; 560 } 561 LOGE("Unreconized value %s passed to stateVertex", values[i]); 562 } 563 564 if (!strcmp(keys[i], "stateRaster")) { 565 if (!strcmp(values[i], "default")) { 566 continue; 567 } 568 if (!strcmp(values[i], "parent")) { 569 s->mEnviroment.mRaster.clear(); 570 continue; 571 } 572 LOGE("Unreconized value %s passed to stateRaster", values[i]); 573 } 574 575 if (!strcmp(keys[i], "stateFragment")) { 576 if (!strcmp(values[i], "default")) { 577 continue; 578 } 579 if (!strcmp(values[i], "parent")) { 580 s->mEnviroment.mFragment.clear(); 581 continue; 582 } 583 LOGE("Unreconized value %s passed to stateFragment", values[i]); 584 } 585 586 if (!strcmp(keys[i], "stateStore")) { 587 if (!strcmp(values[i], "default")) { 588 continue; 589 } 590 if (!strcmp(values[i], "parent")) { 591 s->mEnviroment.mFragmentStore.clear(); 592 continue; 593 } 594 LOGE("Unreconized value %s passed to stateStore", values[i]); 595 } 596 } 597 } else { 598 LOGE("bcc: FAILS to prepare executable"); 599 // Handle Fatal Error 600 } 601} 602 603namespace android { 604namespace renderscript { 605 606void rsi_ScriptCBegin(Context * rsc) { 607 ScriptCState *ss = &rsc->mScriptC; 608 ss->clear(rsc); 609} 610 611void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) { 612 ScriptCState *ss = &rsc->mScriptC; 613 614 char *t = (char *)malloc(len + 1); 615 memcpy(t, text, len); 616 t[len] = 0; 617 ss->mScript->mEnviroment.mScriptText = t; 618 ss->mScript->mEnviroment.mScriptTextLength = len; 619} 620 621 622RsScript rsi_ScriptCCreate(Context *rsc, 623 const char *packageName /* deprecated */, 624 const char *resName, 625 const char *cacheDir) 626{ 627 ScriptCState *ss = &rsc->mScriptC; 628 629 ObjectBaseRef<ScriptC> s(ss->mScript); 630 ss->mScript.clear(); 631 s->incUserRef(); 632 633 ss->runCompiler(rsc, s.get(), resName, cacheDir); 634 ss->clear(rsc); 635 return s.get(); 636} 637 638} 639} 640