rsCpuCore.cpp revision 005113297b19ed256b6db9d6bc293ed9266899fc
1/* 2 * Copyright (C) 2012 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 "rsCpuCore.h" 18#include "rsCpuScript.h" 19#include "rsCpuScriptGroup.h" 20 21#include <malloc.h> 22#include "rsContext.h" 23 24#include <sys/types.h> 25#include <sys/resource.h> 26#include <sched.h> 27#include <sys/syscall.h> 28#include <string.h> 29#include <unistd.h> 30 31#include <stdio.h> 32#include <stdlib.h> 33#include <fcntl.h> 34 35#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB) 36#include <cutils/properties.h> 37#include "utils/StopWatch.h" 38#endif 39 40#ifdef RS_SERVER 41// Android exposes gettid(), standard Linux does not 42static pid_t gettid() { 43 return syscall(SYS_gettid); 44} 45#endif 46 47using namespace android; 48using namespace android::renderscript; 49 50typedef void (*outer_foreach_t)( 51 const android::renderscript::RsForEachStubParamStruct *, 52 uint32_t x1, uint32_t x2, 53 uint32_t instep, uint32_t outstep); 54 55 56static pthread_key_t gThreadTLSKey = 0; 57static uint32_t gThreadTLSKeyCount = 0; 58static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER; 59 60bool android::renderscript::gArchUseSIMD = false; 61 62RsdCpuReference::~RsdCpuReference() { 63} 64 65RsdCpuReference * RsdCpuReference::create(Context *rsc, uint32_t version_major, 66 uint32_t version_minor, sym_lookup_t lfn, script_lookup_t slfn 67#ifndef RS_COMPATIBILITY_LIB 68 , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback, 69 RSSelectRTCallback pSelectRTCallback, 70 const char *pBccPluginName 71#endif 72 ) { 73 74 RsdCpuReferenceImpl *cpu = new RsdCpuReferenceImpl(rsc); 75 if (!cpu) { 76 return NULL; 77 } 78 if (!cpu->init(version_major, version_minor, lfn, slfn)) { 79 delete cpu; 80 return NULL; 81 } 82 83#ifndef RS_COMPATIBILITY_LIB 84 cpu->setLinkRuntimeCallback(pLinkRuntimeCallback); 85 cpu->setSelectRTCallback(pSelectRTCallback); 86 if (pBccPluginName) { 87 cpu->setBccPluginName(pBccPluginName); 88 } 89#endif 90 91 return cpu; 92} 93 94 95Context * RsdCpuReference::getTlsContext() { 96 ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(gThreadTLSKey); 97 return tls->mContext; 98} 99 100const Script * RsdCpuReference::getTlsScript() { 101 ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(gThreadTLSKey); 102 return tls->mScript; 103} 104 105pthread_key_t RsdCpuReference::getThreadTLSKey(){ return gThreadTLSKey; } 106 107//////////////////////////////////////////////////////////// 108/// 109 110RsdCpuReferenceImpl::RsdCpuReferenceImpl(Context *rsc) { 111 mRSC = rsc; 112 113 version_major = 0; 114 version_minor = 0; 115 mInForEach = false; 116 memset(&mWorkers, 0, sizeof(mWorkers)); 117 memset(&mTlsStruct, 0, sizeof(mTlsStruct)); 118 mExit = false; 119#ifndef RS_COMPATIBILITY_LIB 120 mLinkRuntimeCallback = NULL; 121 mSelectRTCallback = NULL; 122 mSetupCompilerCallback = NULL; 123#endif 124} 125 126 127void * RsdCpuReferenceImpl::helperThreadProc(void *vrsc) { 128 RsdCpuReferenceImpl *dc = (RsdCpuReferenceImpl *)vrsc; 129 130 uint32_t idx = __sync_fetch_and_add(&dc->mWorkers.mLaunchCount, 1); 131 132 //ALOGV("RS helperThread starting %p idx=%i", dc, idx); 133 134 dc->mWorkers.mLaunchSignals[idx].init(); 135 dc->mWorkers.mNativeThreadId[idx] = gettid(); 136 137 memset(&dc->mTlsStruct, 0, sizeof(dc->mTlsStruct)); 138 int status = pthread_setspecific(gThreadTLSKey, &dc->mTlsStruct); 139 if (status) { 140 ALOGE("pthread_setspecific %i", status); 141 } 142 143#if 0 144 typedef struct {uint64_t bits[1024 / 64]; } cpu_set_t; 145 cpu_set_t cpuset; 146 memset(&cpuset, 0, sizeof(cpuset)); 147 cpuset.bits[idx / 64] |= 1ULL << (idx % 64); 148 int ret = syscall(241, rsc->mWorkers.mNativeThreadId[idx], 149 sizeof(cpuset), &cpuset); 150 ALOGE("SETAFFINITY ret = %i %s", ret, EGLUtils::strerror(ret)); 151#endif 152 153 while (!dc->mExit) { 154 dc->mWorkers.mLaunchSignals[idx].wait(); 155 if (dc->mWorkers.mLaunchCallback) { 156 // idx +1 is used because the calling thread is always worker 0. 157 dc->mWorkers.mLaunchCallback(dc->mWorkers.mLaunchData, idx+1); 158 } 159 __sync_fetch_and_sub(&dc->mWorkers.mRunningCount, 1); 160 dc->mWorkers.mCompleteSignal.set(); 161 } 162 163 //ALOGV("RS helperThread exited %p idx=%i", dc, idx); 164 return NULL; 165} 166 167void RsdCpuReferenceImpl::launchThreads(WorkerCallback_t cbk, void *data) { 168 mWorkers.mLaunchData = data; 169 mWorkers.mLaunchCallback = cbk; 170 171 // fast path for very small launches 172 MTLaunchStruct *mtls = (MTLaunchStruct *)data; 173 if (mtls && mtls->fep.dimY <= 1 && mtls->xEnd <= mtls->xStart + mtls->mSliceSize) { 174 if (mWorkers.mLaunchCallback) { 175 mWorkers.mLaunchCallback(mWorkers.mLaunchData, 0); 176 } 177 return; 178 } 179 180 mWorkers.mRunningCount = mWorkers.mCount; 181 __sync_synchronize(); 182 183 for (uint32_t ct = 0; ct < mWorkers.mCount; ct++) { 184 mWorkers.mLaunchSignals[ct].set(); 185 } 186 187 // We use the calling thread as one of the workers so we can start without 188 // the delay of the thread wakeup. 189 if (mWorkers.mLaunchCallback) { 190 mWorkers.mLaunchCallback(mWorkers.mLaunchData, 0); 191 } 192 193 while (__sync_fetch_and_or(&mWorkers.mRunningCount, 0) != 0) { 194 mWorkers.mCompleteSignal.wait(); 195 } 196} 197 198 199void RsdCpuReferenceImpl::lockMutex() { 200 pthread_mutex_lock(&gInitMutex); 201} 202 203void RsdCpuReferenceImpl::unlockMutex() { 204 pthread_mutex_unlock(&gInitMutex); 205} 206 207#if defined(ARCH_ARM_HAVE_VFP) || defined(ARCH_X86_HAVE_SSSE3) 208static int 209read_file(const char* pathname, char* buffer, size_t buffsize) 210{ 211 int fd, len; 212 213 fd = open(pathname, O_RDONLY); 214 if (fd < 0) 215 return -1; 216 217 do { 218 len = read(fd, buffer, buffsize); 219 } while (len < 0 && errno == EINTR); 220 221 close(fd); 222 223 return len; 224} 225 226static void GetCpuInfo() { 227 char cpuinfo[4096]; 228 int cpuinfo_len; 229 230 cpuinfo_len = read_file("/proc/cpuinfo", cpuinfo, sizeof cpuinfo); 231 if (cpuinfo_len < 0) /* should not happen */ { 232 return; 233 } 234 235#if defined(ARCH_ARM_HAVE_VFP) 236 gArchUseSIMD = !!strstr(cpuinfo, " neon"); 237#elif defined(ARCH_X86_HAVE_SSSE3) 238 gArchUseSIMD = !!strstr(cpuinfo, " ssse3"); 239#endif 240} 241#endif // ARCH_ARM_HAVE_VFP || ARCH_X86_HAVE_SSSE3 242 243bool RsdCpuReferenceImpl::init(uint32_t version_major, uint32_t version_minor, 244 sym_lookup_t lfn, script_lookup_t slfn) { 245 246 mSymLookupFn = lfn; 247 mScriptLookupFn = slfn; 248 249 lockMutex(); 250 if (!gThreadTLSKeyCount) { 251 int status = pthread_key_create(&gThreadTLSKey, NULL); 252 if (status) { 253 ALOGE("Failed to init thread tls key."); 254 unlockMutex(); 255 return false; 256 } 257 } 258 gThreadTLSKeyCount++; 259 unlockMutex(); 260 261 mTlsStruct.mContext = mRSC; 262 mTlsStruct.mScript = NULL; 263 int status = pthread_setspecific(gThreadTLSKey, &mTlsStruct); 264 if (status) { 265 ALOGE("pthread_setspecific %i", status); 266 } 267 268#if defined(ARCH_ARM_HAVE_VFP) || defined(ARCH_X86_HAVE_SSSE3) 269 GetCpuInfo(); 270#endif 271 272 int cpu = sysconf(_SC_NPROCESSORS_ONLN); 273 if(mRSC->props.mDebugMaxThreads) { 274 cpu = mRSC->props.mDebugMaxThreads; 275 } 276 if (cpu < 2) { 277 mWorkers.mCount = 0; 278 return true; 279 } 280 281 // Subtract one from the cpu count because we also use the command thread as a worker. 282 mWorkers.mCount = (uint32_t)(cpu - 1); 283 284 ALOGV("%p Launching thread(s), CPUs %i", mRSC, mWorkers.mCount + 1); 285 286 mWorkers.mThreadId = (pthread_t *) calloc(mWorkers.mCount, sizeof(pthread_t)); 287 mWorkers.mNativeThreadId = (pid_t *) calloc(mWorkers.mCount, sizeof(pid_t)); 288 mWorkers.mLaunchSignals = new Signal[mWorkers.mCount]; 289 mWorkers.mLaunchCallback = NULL; 290 291 mWorkers.mCompleteSignal.init(); 292 293 mWorkers.mRunningCount = mWorkers.mCount; 294 mWorkers.mLaunchCount = 0; 295 __sync_synchronize(); 296 297 pthread_attr_t threadAttr; 298 status = pthread_attr_init(&threadAttr); 299 if (status) { 300 ALOGE("Failed to init thread attribute."); 301 return false; 302 } 303 304 for (uint32_t ct=0; ct < mWorkers.mCount; ct++) { 305 status = pthread_create(&mWorkers.mThreadId[ct], &threadAttr, helperThreadProc, this); 306 if (status) { 307 mWorkers.mCount = ct; 308 ALOGE("Created fewer than expected number of RS threads."); 309 break; 310 } 311 } 312 while (__sync_fetch_and_or(&mWorkers.mRunningCount, 0) != 0) { 313 usleep(100); 314 } 315 316 pthread_attr_destroy(&threadAttr); 317 return true; 318} 319 320 321void RsdCpuReferenceImpl::setPriority(int32_t priority) { 322 for (uint32_t ct=0; ct < mWorkers.mCount; ct++) { 323 setpriority(PRIO_PROCESS, mWorkers.mNativeThreadId[ct], priority); 324 } 325} 326 327RsdCpuReferenceImpl::~RsdCpuReferenceImpl() { 328 mExit = true; 329 mWorkers.mLaunchData = NULL; 330 mWorkers.mLaunchCallback = NULL; 331 mWorkers.mRunningCount = mWorkers.mCount; 332 __sync_synchronize(); 333 for (uint32_t ct = 0; ct < mWorkers.mCount; ct++) { 334 mWorkers.mLaunchSignals[ct].set(); 335 } 336 void *res; 337 for (uint32_t ct = 0; ct < mWorkers.mCount; ct++) { 338 pthread_join(mWorkers.mThreadId[ct], &res); 339 } 340 rsAssert(__sync_fetch_and_or(&mWorkers.mRunningCount, 0) == 0); 341 free(mWorkers.mThreadId); 342 free(mWorkers.mNativeThreadId); 343 delete[] mWorkers.mLaunchSignals; 344 345 // Global structure cleanup. 346 lockMutex(); 347 --gThreadTLSKeyCount; 348 if (!gThreadTLSKeyCount) { 349 pthread_key_delete(gThreadTLSKey); 350 } 351 unlockMutex(); 352 353} 354 355typedef void (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t); 356 357static void wc_xy(void *usr, uint32_t idx) { 358 MTLaunchStruct *mtls = (MTLaunchStruct *)usr; 359 RsForEachStubParamStruct p; 360 memcpy(&p, &mtls->fep, sizeof(p)); 361 p.lid = idx; 362 uint32_t sig = mtls->sig; 363 364 outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 365 while (1) { 366 uint32_t slice = (uint32_t)__sync_fetch_and_add(&mtls->mSliceNum, 1); 367 uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize; 368 uint32_t yEnd = yStart + mtls->mSliceSize; 369 yEnd = rsMin(yEnd, mtls->yEnd); 370 if (yEnd <= yStart) { 371 return; 372 } 373 374 //ALOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd); 375 //ALOGE("usr ptr in %p, out %p", mtls->fep.ptrIn, mtls->fep.ptrOut); 376 377 for (p.y = yStart; p.y < yEnd; p.y++) { 378 p.out = mtls->fep.ptrOut + (mtls->fep.yStrideOut * p.y) + 379 (mtls->fep.eStrideOut * mtls->xStart); 380 p.in = mtls->fep.ptrIn + (mtls->fep.yStrideIn * p.y) + 381 (mtls->fep.eStrideIn * mtls->xStart); 382 fn(&p, mtls->xStart, mtls->xEnd, mtls->fep.eStrideIn, mtls->fep.eStrideOut); 383 } 384 } 385} 386 387static void wc_x(void *usr, uint32_t idx) { 388 MTLaunchStruct *mtls = (MTLaunchStruct *)usr; 389 RsForEachStubParamStruct p; 390 memcpy(&p, &mtls->fep, sizeof(p)); 391 p.lid = idx; 392 uint32_t sig = mtls->sig; 393 394 outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 395 while (1) { 396 uint32_t slice = (uint32_t)__sync_fetch_and_add(&mtls->mSliceNum, 1); 397 uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize; 398 uint32_t xEnd = xStart + mtls->mSliceSize; 399 xEnd = rsMin(xEnd, mtls->xEnd); 400 if (xEnd <= xStart) { 401 return; 402 } 403 404 //ALOGE("usr slice %i idx %i, x %i,%i", slice, idx, xStart, xEnd); 405 //ALOGE("usr ptr in %p, out %p", mtls->fep.ptrIn, mtls->fep.ptrOut); 406 407 p.out = mtls->fep.ptrOut + (mtls->fep.eStrideOut * xStart); 408 p.in = mtls->fep.ptrIn + (mtls->fep.eStrideIn * xStart); 409 fn(&p, xStart, xEnd, mtls->fep.eStrideIn, mtls->fep.eStrideOut); 410 } 411} 412 413void RsdCpuReferenceImpl::launchThreads(const Allocation * ain, Allocation * aout, 414 const RsScriptCall *sc, MTLaunchStruct *mtls) { 415 416 //android::StopWatch kernel_time("kernel time"); 417 418 if ((mWorkers.mCount >= 1) && mtls->isThreadable && !mInForEach) { 419 const size_t targetByteChunk = 16 * 1024; 420 mInForEach = true; 421 if (mtls->fep.dimY > 1) { 422 uint32_t s1 = mtls->fep.dimY / ((mWorkers.mCount + 1) * 4); 423 uint32_t s2 = 0; 424 425 // This chooses our slice size to rate limit atomic ops to 426 // one per 16k bytes of reads/writes. 427 if (mtls->fep.yStrideOut) { 428 s2 = targetByteChunk / mtls->fep.yStrideOut; 429 } else { 430 s2 = targetByteChunk / mtls->fep.yStrideIn; 431 } 432 mtls->mSliceSize = rsMin(s1, s2); 433 434 if(mtls->mSliceSize < 1) { 435 mtls->mSliceSize = 1; 436 } 437 438 // mtls->mSliceSize = 2; 439 launchThreads(wc_xy, mtls); 440 } else { 441 uint32_t s1 = mtls->fep.dimX / ((mWorkers.mCount + 1) * 4); 442 uint32_t s2 = 0; 443 444 // This chooses our slice size to rate limit atomic ops to 445 // one per 16k bytes of reads/writes. 446 if (mtls->fep.eStrideOut) { 447 s2 = targetByteChunk / mtls->fep.eStrideOut; 448 } else { 449 s2 = targetByteChunk / mtls->fep.eStrideIn; 450 } 451 mtls->mSliceSize = rsMin(s1, s2); 452 453 if(mtls->mSliceSize < 1) { 454 mtls->mSliceSize = 1; 455 } 456 457 launchThreads(wc_x, mtls); 458 } 459 mInForEach = false; 460 461 //ALOGE("launch 1"); 462 } else { 463 RsForEachStubParamStruct p; 464 memcpy(&p, &mtls->fep, sizeof(p)); 465 uint32_t sig = mtls->sig; 466 467 //ALOGE("launch 3"); 468 outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 469 for (p.ar[0] = mtls->arrayStart; p.ar[0] < mtls->arrayEnd; p.ar[0]++) { 470 for (p.z = mtls->zStart; p.z < mtls->zEnd; p.z++) { 471 for (p.y = mtls->yStart; p.y < mtls->yEnd; p.y++) { 472 uint32_t offset = mtls->fep.dimY * mtls->fep.dimZ * p.ar[0] + 473 mtls->fep.dimY * p.z + p.y; 474 p.out = mtls->fep.ptrOut + (mtls->fep.yStrideOut * offset) + 475 (mtls->fep.eStrideOut * mtls->xStart); 476 p.in = mtls->fep.ptrIn + (mtls->fep.yStrideIn * offset) + 477 (mtls->fep.eStrideIn * mtls->xStart); 478 fn(&p, mtls->xStart, mtls->xEnd, mtls->fep.eStrideIn, mtls->fep.eStrideOut); 479 } 480 } 481 } 482 } 483} 484 485RsdCpuScriptImpl * RsdCpuReferenceImpl::setTLS(RsdCpuScriptImpl *sc) { 486 //ALOGE("setTls %p", sc); 487 ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(gThreadTLSKey); 488 rsAssert(tls); 489 RsdCpuScriptImpl *old = tls->mImpl; 490 tls->mImpl = sc; 491 tls->mContext = mRSC; 492 if (sc) { 493 tls->mScript = sc->getScript(); 494 } else { 495 tls->mScript = NULL; 496 } 497 return old; 498} 499 500const RsdCpuReference::CpuSymbol * RsdCpuReferenceImpl::symLookup(const char *name) { 501 return mSymLookupFn(mRSC, name); 502} 503 504 505RsdCpuReference::CpuScript * RsdCpuReferenceImpl::createScript(const ScriptC *s, 506 char const *resName, char const *cacheDir, 507 uint8_t const *bitcode, size_t bitcodeSize, 508 uint32_t flags) { 509 510 RsdCpuScriptImpl *i = new RsdCpuScriptImpl(this, s); 511 if (!i->init(resName, cacheDir, bitcode, bitcodeSize, flags 512#ifndef RS_COMPATIBILITY_LIB 513 , getBccPluginName() 514#endif 515 )) { 516 delete i; 517 return NULL; 518 } 519 return i; 520} 521 522extern RsdCpuScriptImpl * rsdIntrinsic_3DLUT(RsdCpuReferenceImpl *ctx, 523 const Script *s, const Element *e); 524extern RsdCpuScriptImpl * rsdIntrinsic_Convolve3x3(RsdCpuReferenceImpl *ctx, 525 const Script *s, const Element *e); 526extern RsdCpuScriptImpl * rsdIntrinsic_ColorMatrix(RsdCpuReferenceImpl *ctx, 527 const Script *s, const Element *e); 528extern RsdCpuScriptImpl * rsdIntrinsic_LUT(RsdCpuReferenceImpl *ctx, 529 const Script *s, const Element *e); 530extern RsdCpuScriptImpl * rsdIntrinsic_Convolve5x5(RsdCpuReferenceImpl *ctx, 531 const Script *s, const Element *e); 532extern RsdCpuScriptImpl * rsdIntrinsic_Blur(RsdCpuReferenceImpl *ctx, 533 const Script *s, const Element *e); 534extern RsdCpuScriptImpl * rsdIntrinsic_YuvToRGB(RsdCpuReferenceImpl *ctx, 535 const Script *s, const Element *e); 536extern RsdCpuScriptImpl * rsdIntrinsic_Blend(RsdCpuReferenceImpl *ctx, 537 const Script *s, const Element *e); 538extern RsdCpuScriptImpl * rsdIntrinsic_Histogram(RsdCpuReferenceImpl *ctx, 539 const Script *s, const Element *e); 540extern RsdCpuScriptImpl * rsdIntrinsic_LoopFilter(RsdCpuReferenceImpl *ctx, 541 const Script *s, const Element *e); 542extern RsdCpuScriptImpl * rsdIntrinsic_Resize(RsdCpuReferenceImpl *ctx, 543 const Script *s, const Element *e); 544 545RsdCpuReference::CpuScript * RsdCpuReferenceImpl::createIntrinsic(const Script *s, 546 RsScriptIntrinsicID iid, Element *e) { 547 548 RsdCpuScriptImpl *i = NULL; 549 switch (iid) { 550 case RS_SCRIPT_INTRINSIC_ID_3DLUT: 551 i = rsdIntrinsic_3DLUT(this, s, e); 552 break; 553 case RS_SCRIPT_INTRINSIC_ID_CONVOLVE_3x3: 554 i = rsdIntrinsic_Convolve3x3(this, s, e); 555 break; 556 case RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX: 557 i = rsdIntrinsic_ColorMatrix(this, s, e); 558 break; 559 case RS_SCRIPT_INTRINSIC_ID_LUT: 560 i = rsdIntrinsic_LUT(this, s, e); 561 break; 562 case RS_SCRIPT_INTRINSIC_ID_CONVOLVE_5x5: 563 i = rsdIntrinsic_Convolve5x5(this, s, e); 564 break; 565 case RS_SCRIPT_INTRINSIC_ID_BLUR: 566 i = rsdIntrinsic_Blur(this, s, e); 567 break; 568 case RS_SCRIPT_INTRINSIC_ID_YUV_TO_RGB: 569 i = rsdIntrinsic_YuvToRGB(this, s, e); 570 break; 571 case RS_SCRIPT_INTRINSIC_ID_BLEND: 572 i = rsdIntrinsic_Blend(this, s, e); 573 break; 574 case RS_SCRIPT_INTRINSIC_ID_HISTOGRAM: 575 i = rsdIntrinsic_Histogram(this, s, e); 576 break; 577 case RS_SCRIPT_INTRINSIC_ID_RESIZE: 578 i = rsdIntrinsic_Resize(this, s, e); 579 break; 580#ifndef RS_COMPATIBILITY_LIB 581 case RS_SCRIPT_INTRINSIC_ID_LOOP_FILTER: 582 i = rsdIntrinsic_LoopFilter(this, s, e); 583 break; 584#endif 585 586 default: 587 rsAssert(0); 588 } 589 590 return i; 591} 592 593RsdCpuReference::CpuScriptGroup * RsdCpuReferenceImpl::createScriptGroup(const ScriptGroup *sg) { 594 CpuScriptGroupImpl *sgi = new CpuScriptGroupImpl(this, sg); 595 if (!sgi->init()) { 596 delete sgi; 597 return NULL; 598 } 599 return sgi; 600} 601 602 603