Merge "Add support for new root.expand() calls."

This commit is contained in:
Stephen Hines
2012-01-13 13:57:24 -08:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 192 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2011-2012 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ using namespace android::renderscript;
struct DrvScript { struct DrvScript {
int (*mRoot)(); int (*mRoot)();
int (*mRootExpand)();
void (*mInit)(); void (*mInit)();
void (*mFreeChildren)(); void (*mFreeChildren)();
@@ -52,6 +53,10 @@ struct DrvScript {
uint32_t mScriptTextLength; uint32_t mScriptTextLength;
}; };
typedef void (*outer_foreach_t)(
const android::renderscript::RsForEachStubParamStruct *,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep);
static Script * setTLS(Script *sc) { static Script * setTLS(Script *sc) {
ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey);
@@ -123,6 +128,7 @@ bool rsdScriptInit(const Context *rsc,
} }
drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root")); drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root"));
drv->mRootExpand = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root.expand"));
drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init")); drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init"));
drv->mFreeChildren = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, ".rs.dtor")); drv->mFreeChildren = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, ".rs.dtor"));
@@ -165,7 +171,12 @@ bool rsdScriptInit(const Context *rsc,
script->mHal.info.exportedPragmaCount = drv->ME->getPragmaCount(); script->mHal.info.exportedPragmaCount = drv->ME->getPragmaCount();
script->mHal.info.exportedPragmaKeyList = drv->ME->getPragmaKeyList(); script->mHal.info.exportedPragmaKeyList = drv->ME->getPragmaKeyList();
script->mHal.info.exportedPragmaValueList = drv->ME->getPragmaValueList(); script->mHal.info.exportedPragmaValueList = drv->ME->getPragmaValueList();
if (drv->mRootExpand) {
script->mHal.info.root = drv->mRootExpand;
} else {
script->mHal.info.root = drv->mRoot; script->mHal.info.root = drv->mRoot;
}
pthread_mutex_unlock(&rsdgInitMutex); pthread_mutex_unlock(&rsdgInitMutex);
return true; return true;
@@ -224,7 +235,7 @@ static void wc_xy(void *usr, uint32_t idx) {
RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv; RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
uint32_t sig = mtls->sig; uint32_t sig = mtls->sig;
outer_foreach_t fn = dc->mForEachLaunch[sig]; outer_foreach_t fn = (outer_foreach_t) mtls->script->mHal.info.root;
while (1) { while (1) {
uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum); uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize; uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize;
@@ -240,8 +251,7 @@ static void wc_xy(void *usr, uint32_t idx) {
uint32_t offset = mtls->dimX * p.y; uint32_t offset = mtls->dimX * p.y;
p.out = mtls->ptrOut + (mtls->eStrideOut * offset); p.out = mtls->ptrOut + (mtls->eStrideOut * offset);
p.in = mtls->ptrIn + (mtls->eStrideIn * offset); p.in = mtls->ptrIn + (mtls->eStrideIn * offset);
fn(&mtls->script->mHal.info.root, &p, mtls->xStart, mtls->xEnd, fn(&p, mtls->xStart, mtls->xEnd, mtls->eStrideIn, mtls->eStrideOut);
mtls->eStrideIn, mtls->eStrideOut);
} }
} }
} }
@@ -255,7 +265,7 @@ static void wc_x(void *usr, uint32_t idx) {
RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv; RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
uint32_t sig = mtls->sig; uint32_t sig = mtls->sig;
outer_foreach_t fn = dc->mForEachLaunch[sig]; outer_foreach_t fn = (outer_foreach_t) mtls->script->mHal.info.root;
while (1) { while (1) {
uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum); uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize; uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize;
@@ -270,7 +280,7 @@ static void wc_x(void *usr, uint32_t idx) {
p.out = mtls->ptrOut + (mtls->eStrideOut * xStart); p.out = mtls->ptrOut + (mtls->eStrideOut * xStart);
p.in = mtls->ptrIn + (mtls->eStrideIn * xStart); p.in = mtls->ptrIn + (mtls->eStrideIn * xStart);
fn(&mtls->script->mHal.info.root, &p, xStart, xEnd, mtls->eStrideIn, mtls->eStrideOut); fn(&p, xStart, xEnd, mtls->eStrideIn, mtls->eStrideOut);
} }
} }
@@ -381,7 +391,7 @@ void rsdScriptInvokeForEach(const Context *rsc,
uint32_t sig = mtls.sig; uint32_t sig = mtls.sig;
//ALOGE("launch 3"); //ALOGE("launch 3");
outer_foreach_t fn = dc->mForEachLaunch[sig]; outer_foreach_t fn = (outer_foreach_t) mtls.script->mHal.info.root;
for (p.ar[0] = mtls.arrayStart; p.ar[0] < mtls.arrayEnd; p.ar[0]++) { for (p.ar[0] = mtls.arrayStart; p.ar[0] < mtls.arrayEnd; p.ar[0]++) {
for (p.z = mtls.zStart; p.z < mtls.zEnd; p.z++) { for (p.z = mtls.zStart; p.z < mtls.zEnd; p.z++) {
for (p.y = mtls.yStart; p.y < mtls.yEnd; p.y++) { for (p.y = mtls.yStart; p.y < mtls.yEnd; p.y++) {
@@ -390,8 +400,8 @@ void rsdScriptInvokeForEach(const Context *rsc,
mtls.dimX * p.y; mtls.dimX * p.y;
p.out = mtls.ptrOut + (mtls.eStrideOut * offset); p.out = mtls.ptrOut + (mtls.eStrideOut * offset);
p.in = mtls.ptrIn + (mtls.eStrideIn * offset); p.in = mtls.ptrIn + (mtls.eStrideIn * offset);
fn(&mtls.script->mHal.info.root, &p, mtls.xStart, mtls.xEnd, fn(&p, mtls.xStart, mtls.xEnd, mtls.eStrideIn,
mtls.eStrideIn, mtls.eStrideOut); mtls.eStrideOut);
} }
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2011-2012 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -43,7 +43,6 @@ using namespace android::renderscript;
static void Shutdown(Context *rsc); static void Shutdown(Context *rsc);
static void SetPriority(const Context *rsc, int32_t priority); static void SetPriority(const Context *rsc, int32_t priority);
static void initForEach(outer_foreach_t* forEachLaunch);
static RsdHalFunctions FunctionTable = { static RsdHalFunctions FunctionTable = {
rsdGLInit, rsdGLInit,
@@ -208,8 +207,6 @@ bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
rsdgThreadTLSKeyCount++; rsdgThreadTLSKeyCount++;
pthread_mutex_unlock(&rsdgInitMutex); pthread_mutex_unlock(&rsdgInitMutex);
initForEach(dc->mForEachLaunch);
dc->mTlsStruct.mContext = rsc; dc->mTlsStruct.mContext = rsc;
dc->mTlsStruct.mScript = NULL; dc->mTlsStruct.mScript = NULL;
int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct); int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
@@ -291,173 +288,3 @@ void Shutdown(Context *rsc) {
} }
static void rsdForEach17(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, uint32_t);
(*(fe*)vRoot)(p->in, p->y);
}
static void rsdForEach18(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(void *, uint32_t);
(*(fe*)vRoot)(p->out, p->y);
}
static void rsdForEach19(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, void *, uint32_t);
(*(fe*)vRoot)(p->in, p->out, p->y);
}
static void rsdForEach21(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, const void *, uint32_t);
(*(fe*)vRoot)(p->in, p->usr, p->y);
}
static void rsdForEach22(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(void *, const void *, uint32_t);
(*(fe*)vRoot)(p->out, p->usr, p->y);
}
static void rsdForEach23(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, void *, const void *, uint32_t);
(*(fe*)vRoot)(p->in, p->out, p->usr, p->y);
}
static void rsdForEach25(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, uint32_t, uint32_t);
const uint8_t *pin = (const uint8_t *)p->in;
uint32_t y = p->y;
for (uint32_t x = x1; x < x2; x++) {
(*(fe*)vRoot)(pin, x, y);
pin += instep;
}
}
static void rsdForEach26(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(void *, uint32_t, uint32_t);
uint8_t *pout = (uint8_t *)p->out;
uint32_t y = p->y;
for (uint32_t x = x1; x < x2; x++) {
(*(fe*)vRoot)(pout, x, y);
pout += outstep;
}
}
static void rsdForEach27(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, void *, uint32_t, uint32_t);
uint8_t *pout = (uint8_t *)p->out;
const uint8_t *pin = (const uint8_t *)p->in;
uint32_t y = p->y;
for (uint32_t x = x1; x < x2; x++) {
(*(fe*)vRoot)(pin, pout, x, y);
pin += instep;
pout += outstep;
}
}
static void rsdForEach29(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, const void *, uint32_t, uint32_t);
const uint8_t *pin = (const uint8_t *)p->in;
const void *usr = p->usr;
const uint32_t y = p->y;
for (uint32_t x = x1; x < x2; x++) {
(*(fe*)vRoot)(pin, usr, x, y);
pin += instep;
}
}
static void rsdForEach30(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(void *, const void *, uint32_t, uint32_t);
uint8_t *pout = (uint8_t *)p->out;
const void *usr = p->usr;
const uint32_t y = p->y;
for (uint32_t x = x1; x < x2; x++) {
(*(fe*)vRoot)(pout, usr, x, y);
pout += outstep;
}
}
static void rsdForEach31(const void *vRoot,
const android::renderscript::RsForEachStubParamStruct *p,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep) {
typedef void (*fe)(const void *, void *, const void *, uint32_t, uint32_t);
uint8_t *pout = (uint8_t *)p->out;
const uint8_t *pin = (const uint8_t *)p->in;
const void *usr = p->usr;
const uint32_t y = p->y;
for (uint32_t x = x1; x < x2; x++) {
(*(fe*)vRoot)(pin, pout, usr, x, y);
pin += instep;
pout += outstep;
}
}
static void initForEach(outer_foreach_t* forEachLaunch) {
rsAssert(forEachLaunch);
forEachLaunch[0x00] = NULL;
forEachLaunch[0x01] = rsdForEach31; // in
forEachLaunch[0x02] = rsdForEach30; // out
forEachLaunch[0x03] = rsdForEach31; // in, out
forEachLaunch[0x04] = NULL;
forEachLaunch[0x05] = rsdForEach29; // in, usr
forEachLaunch[0x06] = rsdForEach30; // out, usr
forEachLaunch[0x07] = rsdForEach31; // in, out, usr
forEachLaunch[0x08] = NULL;
forEachLaunch[0x09] = rsdForEach25; // in, x
forEachLaunch[0x0a] = rsdForEach26; // out, x
forEachLaunch[0x0b] = rsdForEach27; // in, out, x
forEachLaunch[0x0c] = NULL;
forEachLaunch[0x0d] = rsdForEach29; // in, usr, x
forEachLaunch[0x0e] = rsdForEach30; // out, usr, x
forEachLaunch[0x0f] = rsdForEach31; // in, out, usr, x
forEachLaunch[0x10] = NULL;
forEachLaunch[0x11] = rsdForEach17; // in y
forEachLaunch[0x12] = rsdForEach18; // out, y
forEachLaunch[0x13] = rsdForEach19; // in, out, y
forEachLaunch[0x14] = NULL;
forEachLaunch[0x15] = rsdForEach21; // in, usr, y
forEachLaunch[0x16] = rsdForEach22; // out, usr, y
forEachLaunch[0x17] = rsdForEach23; // in, out, usr, y
forEachLaunch[0x18] = NULL;
forEachLaunch[0x19] = rsdForEach25; // in, x, y
forEachLaunch[0x1a] = rsdForEach26; // out, x, y
forEachLaunch[0x1b] = rsdForEach27; // in, out, x, y
forEachLaunch[0x1c] = NULL;
forEachLaunch[0x1d] = rsdForEach29; // in, usr, x, y
forEachLaunch[0x1e] = rsdForEach30; // out, usr, x, y
forEachLaunch[0x1f] = rsdForEach31; // in, out, usr, x, y
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2011-2012 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -27,11 +27,6 @@
typedef void (* InvokeFunc_t)(void); typedef void (* InvokeFunc_t)(void);
typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
typedef void (*outer_foreach_t)(const void *,
const android::renderscript::RsForEachStubParamStruct *,
uint32_t x1, uint32_t x2,
uint32_t instep, uint32_t outstep);
typedef struct RsdSymbolTableRec { typedef struct RsdSymbolTableRec {
const char * mName; const char * mName;
void * mPtr; void * mPtr;
@@ -62,8 +57,6 @@ typedef struct RsdHalRec {
Workers mWorkers; Workers mWorkers;
bool mExit; bool mExit;
outer_foreach_t mForEachLaunch[32];
ScriptTLSStruct mTlsStruct; ScriptTLSStruct mTlsStruct;
RsdGL gl; RsdGL gl;