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