Loading libs/rs/driver/rsdBcc.cpp +21 −8 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,6 @@ * limitations under the License. * limitations under the License. */ */ #include "rsdCore.h" #include "rsdCore.h" #include "rsdBcc.h" #include "rsdBcc.h" #include "rsdRuntime.h" #include "rsdRuntime.h" Loading @@ -30,7 +29,6 @@ extern "C" { #include "libdex/ZipArchive.h" #include "libdex/ZipArchive.h" } } using namespace android; using namespace android; using namespace android::renderscript; using namespace android::renderscript; Loading @@ -45,6 +43,7 @@ struct DrvScript { bcinfo::MetadataExtractor *ME; bcinfo::MetadataExtractor *ME; InvokeFunc_t *mInvokeFunctions; InvokeFunc_t *mInvokeFunctions; ForEachFunc_t *mForEachFunctions; void ** mFieldAddress; void ** mFieldAddress; bool * mFieldIsObject; bool * mFieldIsObject; const uint32_t *mExportForEachSignatureList; const uint32_t *mExportForEachSignatureList; Loading Loading @@ -162,8 +161,16 @@ bool rsdScriptInit(const Context *rsc, } } exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount(); exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount(); rsAssert(exportForEachSignatureCount <= 1); drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList(); drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList(); if (exportForEachSignatureCount > 0) { drv->mForEachFunctions = (ForEachFunc_t*) calloc(exportForEachSignatureCount, sizeof(ForEachFunc_t)); bccGetExportForEachList(drv->mBccScript, exportForEachSignatureCount, (void **) drv->mForEachFunctions); } else { drv->mForEachFunctions = NULL; } // Copy info over to runtime // Copy info over to runtime script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount(); script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount(); Loading Loading @@ -196,6 +203,7 @@ error: typedef struct { typedef struct { Context *rsc; Context *rsc; Script *script; Script *script; ForEachFunc_t kernel; uint32_t sig; uint32_t sig; const Allocation * ain; const Allocation * ain; Allocation * aout; Allocation * aout; Loading Loading @@ -235,7 +243,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 = (outer_foreach_t) mtls->script->mHal.info.root; outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 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; Loading Loading @@ -265,7 +273,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 = (outer_foreach_t) mtls->script->mHal.info.root; outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 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; Loading Loading @@ -299,8 +307,8 @@ void rsdScriptInvokeForEach(const Context *rsc, memset(&mtls, 0, sizeof(mtls)); memset(&mtls, 0, sizeof(mtls)); DrvScript *drv = (DrvScript *)s->mHal.drv; DrvScript *drv = (DrvScript *)s->mHal.drv; // We only support slot 0 (root) at this point in time. mtls.kernel = drv->mForEachFunctions[slot]; rsAssert(slot == 0); rsAssert(mtls.kernel != NULL); mtls.sig = 0x1f; // temp fix for old apps, full table in slang_rs_export_foreach.cpp mtls.sig = 0x1f; // temp fix for old apps, full table in slang_rs_export_foreach.cpp if (drv->mExportForEachSignatureList) { if (drv->mExportForEachSignatureList) { mtls.sig = drv->mExportForEachSignatureList[slot]; mtls.sig = drv->mExportForEachSignatureList[slot]; Loading Loading @@ -391,7 +399,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 = (outer_foreach_t) mtls.script->mHal.info.root; outer_foreach_t fn = (outer_foreach_t) mtls.kernel; 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++) { Loading Loading @@ -517,6 +525,11 @@ void rsdScriptDestroy(const Context *dc, Script *script) { drv->mInvokeFunctions = NULL; drv->mInvokeFunctions = NULL; } } if (drv->mForEachFunctions) { free(drv->mForEachFunctions); drv->mForEachFunctions = NULL; } delete drv->ME; delete drv->ME; drv->ME = NULL; drv->ME = NULL; Loading libs/rs/driver/rsdCore.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "rsdGL.h" #include "rsdGL.h" typedef void (* InvokeFunc_t)(void); typedef void (* InvokeFunc_t)(void); typedef void (* ForEachFunc_t)(void); typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); typedef struct RsdSymbolTableRec { typedef struct RsdSymbolTableRec { Loading libs/rs/rsScript.cpp +2 −2 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009-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. Loading Loading @@ -113,7 +113,7 @@ void rsi_ScriptForEach(Context *rsc, RsScript vs, uint32_t slot, RsAllocation vain, RsAllocation vaout, RsAllocation vain, RsAllocation vaout, const void *params, size_t paramLen) { const void *params, size_t paramLen) { Script *s = static_cast<Script *>(vs); Script *s = static_cast<Script *>(vs); s->runForEach(rsc, s->runForEach(rsc, slot, static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout), static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout), params, paramLen); params, paramLen); Loading libs/rs/rsScript.h +2 −1 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009-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. Loading Loading @@ -74,6 +74,7 @@ public: virtual bool freeChildren(); virtual bool freeChildren(); virtual void runForEach(Context *rsc, virtual void runForEach(Context *rsc, uint32_t slot, const Allocation * ain, const Allocation * ain, Allocation * aout, Allocation * aout, const void * usr, const void * usr, Loading libs/rs/rsScriptC.cpp +3 −2 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009-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. Loading Loading @@ -128,6 +128,7 @@ uint32_t ScriptC::run(Context *rsc) { void ScriptC::runForEach(Context *rsc, void ScriptC::runForEach(Context *rsc, uint32_t slot, const Allocation * ain, const Allocation * ain, Allocation * aout, Allocation * aout, const void * usr, const void * usr, Loading @@ -138,7 +139,7 @@ void ScriptC::runForEach(Context *rsc, setupGLState(rsc); setupGLState(rsc); setupScript(rsc); setupScript(rsc); rsc->mHal.funcs.script.invokeForEach(rsc, this, 0, ain, aout, usr, usrBytes, sc); rsc->mHal.funcs.script.invokeForEach(rsc, this, slot, ain, aout, usr, usrBytes, sc); } } void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { Loading Loading
libs/rs/driver/rsdBcc.cpp +21 −8 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,6 @@ * limitations under the License. * limitations under the License. */ */ #include "rsdCore.h" #include "rsdCore.h" #include "rsdBcc.h" #include "rsdBcc.h" #include "rsdRuntime.h" #include "rsdRuntime.h" Loading @@ -30,7 +29,6 @@ extern "C" { #include "libdex/ZipArchive.h" #include "libdex/ZipArchive.h" } } using namespace android; using namespace android; using namespace android::renderscript; using namespace android::renderscript; Loading @@ -45,6 +43,7 @@ struct DrvScript { bcinfo::MetadataExtractor *ME; bcinfo::MetadataExtractor *ME; InvokeFunc_t *mInvokeFunctions; InvokeFunc_t *mInvokeFunctions; ForEachFunc_t *mForEachFunctions; void ** mFieldAddress; void ** mFieldAddress; bool * mFieldIsObject; bool * mFieldIsObject; const uint32_t *mExportForEachSignatureList; const uint32_t *mExportForEachSignatureList; Loading Loading @@ -162,8 +161,16 @@ bool rsdScriptInit(const Context *rsc, } } exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount(); exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount(); rsAssert(exportForEachSignatureCount <= 1); drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList(); drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList(); if (exportForEachSignatureCount > 0) { drv->mForEachFunctions = (ForEachFunc_t*) calloc(exportForEachSignatureCount, sizeof(ForEachFunc_t)); bccGetExportForEachList(drv->mBccScript, exportForEachSignatureCount, (void **) drv->mForEachFunctions); } else { drv->mForEachFunctions = NULL; } // Copy info over to runtime // Copy info over to runtime script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount(); script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount(); Loading Loading @@ -196,6 +203,7 @@ error: typedef struct { typedef struct { Context *rsc; Context *rsc; Script *script; Script *script; ForEachFunc_t kernel; uint32_t sig; uint32_t sig; const Allocation * ain; const Allocation * ain; Allocation * aout; Allocation * aout; Loading Loading @@ -235,7 +243,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 = (outer_foreach_t) mtls->script->mHal.info.root; outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 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; Loading Loading @@ -265,7 +273,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 = (outer_foreach_t) mtls->script->mHal.info.root; outer_foreach_t fn = (outer_foreach_t) mtls->kernel; 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; Loading Loading @@ -299,8 +307,8 @@ void rsdScriptInvokeForEach(const Context *rsc, memset(&mtls, 0, sizeof(mtls)); memset(&mtls, 0, sizeof(mtls)); DrvScript *drv = (DrvScript *)s->mHal.drv; DrvScript *drv = (DrvScript *)s->mHal.drv; // We only support slot 0 (root) at this point in time. mtls.kernel = drv->mForEachFunctions[slot]; rsAssert(slot == 0); rsAssert(mtls.kernel != NULL); mtls.sig = 0x1f; // temp fix for old apps, full table in slang_rs_export_foreach.cpp mtls.sig = 0x1f; // temp fix for old apps, full table in slang_rs_export_foreach.cpp if (drv->mExportForEachSignatureList) { if (drv->mExportForEachSignatureList) { mtls.sig = drv->mExportForEachSignatureList[slot]; mtls.sig = drv->mExportForEachSignatureList[slot]; Loading Loading @@ -391,7 +399,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 = (outer_foreach_t) mtls.script->mHal.info.root; outer_foreach_t fn = (outer_foreach_t) mtls.kernel; 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++) { Loading Loading @@ -517,6 +525,11 @@ void rsdScriptDestroy(const Context *dc, Script *script) { drv->mInvokeFunctions = NULL; drv->mInvokeFunctions = NULL; } } if (drv->mForEachFunctions) { free(drv->mForEachFunctions); drv->mForEachFunctions = NULL; } delete drv->ME; delete drv->ME; drv->ME = NULL; drv->ME = NULL; Loading
libs/rs/driver/rsdCore.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "rsdGL.h" #include "rsdGL.h" typedef void (* InvokeFunc_t)(void); typedef void (* InvokeFunc_t)(void); typedef void (* ForEachFunc_t)(void); typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); typedef struct RsdSymbolTableRec { typedef struct RsdSymbolTableRec { Loading
libs/rs/rsScript.cpp +2 −2 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009-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. Loading Loading @@ -113,7 +113,7 @@ void rsi_ScriptForEach(Context *rsc, RsScript vs, uint32_t slot, RsAllocation vain, RsAllocation vaout, RsAllocation vain, RsAllocation vaout, const void *params, size_t paramLen) { const void *params, size_t paramLen) { Script *s = static_cast<Script *>(vs); Script *s = static_cast<Script *>(vs); s->runForEach(rsc, s->runForEach(rsc, slot, static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout), static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout), params, paramLen); params, paramLen); Loading
libs/rs/rsScript.h +2 −1 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009-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. Loading Loading @@ -74,6 +74,7 @@ public: virtual bool freeChildren(); virtual bool freeChildren(); virtual void runForEach(Context *rsc, virtual void runForEach(Context *rsc, uint32_t slot, const Allocation * ain, const Allocation * ain, Allocation * aout, Allocation * aout, const void * usr, const void * usr, Loading
libs/rs/rsScriptC.cpp +3 −2 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009-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. Loading Loading @@ -128,6 +128,7 @@ uint32_t ScriptC::run(Context *rsc) { void ScriptC::runForEach(Context *rsc, void ScriptC::runForEach(Context *rsc, uint32_t slot, const Allocation * ain, const Allocation * ain, Allocation * aout, Allocation * aout, const void * usr, const void * usr, Loading @@ -138,7 +139,7 @@ void ScriptC::runForEach(Context *rsc, setupGLState(rsc); setupGLState(rsc); setupScript(rsc); setupScript(rsc); rsc->mHal.funcs.script.invokeForEach(rsc, this, 0, ain, aout, usr, usrBytes, sc); rsc->mHal.funcs.script.invokeForEach(rsc, this, slot, ain, aout, usr, usrBytes, sc); } } void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) { Loading