Remove global IO context and integrate it into the RS context.
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 2860452..52389ea 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -84,11 +84,6 @@
bool Context::runRootScript()
{
-#if RS_LOG_TIMES
- struct timespec beginTime;
- clock_gettime(CLOCK_MONOTONIC, &beginTime);
-#endif
-
rsAssert(mRootScript->mEnviroment.mIsRoot);
//glColor4f(1,1,1,1);
@@ -116,9 +111,10 @@
struct timespec endTime;
clock_gettime(CLOCK_MONOTONIC, &endTime);
- int t1 = ((unsigned long)startTime.tv_nsec - (unsigned long)beginTime.tv_nsec) / 1000 / 1000;
- int t2 = ((unsigned long)endTime.tv_nsec - (unsigned long)startTime.tv_nsec) / 1000 / 1000;
- LOGE("times %i, %i", t1, t2);
+ uint64_t t1 = endTime.tv_nsec + ((uint64_t)endTime.tv_sec * 1000 * 1000 * 1000);
+ uint64_t t2 = startTime.tv_nsec + ((uint64_t)startTime.tv_sec * 1000 * 1000 * 1000);
+ int t3 = (int)((t1 - t2) / 1000 / 1000);
+ LOGE("times %i", t3);
#endif
return ret;
@@ -143,7 +139,6 @@
{
Context *rsc = static_cast<Context *>(vrsc);
- gIO = new ThreadIO();
rsc->initEGL();
ScriptTLSStruct *tlsStruct = new ScriptTLSStruct;
@@ -168,7 +163,7 @@
rsc->mRunning = true;
bool mDraw = true;
while (!rsc->mExit) {
- mDraw |= gIO->playCoreCommands(rsc, !mDraw);
+ mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
mDraw &= (rsc->mRootScript.get() != NULL);
if (mDraw) {
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 60a526b..3d17298 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -21,6 +21,7 @@
#include <ui/Surface.h>
+#include "rsThreadIO.h"
#include "rsType.h"
#include "rsMatrix.h"
#include "rsAllocation.h"
@@ -115,6 +116,9 @@
uint32_t getWidth() const {return mWidth;}
uint32_t getHeight() const {return mHeight;}
+
+ ThreadIO mIO;
+
protected:
Device *mDev;
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
index 89df59d..20b0a94 100644
--- a/libs/rs/rsThreadIO.cpp
+++ b/libs/rs/rsThreadIO.cpp
@@ -21,8 +21,6 @@
using namespace android;
using namespace android::renderscript;
-ThreadIO *android::renderscript::gIO = NULL;
-
ThreadIO::ThreadIO()
{
mToCore.init(16 * 1024);
diff --git a/libs/rs/rsThreadIO.h b/libs/rs/rsThreadIO.h
index 72746c5..4aab1b4 100644
--- a/libs/rs/rsThreadIO.h
+++ b/libs/rs/rsThreadIO.h
@@ -43,9 +43,6 @@
};
-extern ThreadIO *gIO;
-
-
}
}
diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c
index 7cf6bb6..e3f816f 100644
--- a/libs/rs/rsg_generator.c
+++ b/libs/rs/rsg_generator.c
@@ -103,8 +103,10 @@
fprintf(f, " %s%s (", prefix, api->name);
if (addContext) {
fprintf(f, "Context *");
+ } else {
+ fprintf(f, "RsContext rsc");
}
- printArgList(f, api, addContext);
+ printArgList(f, api, 1);
fprintf(f, ")");
}
@@ -147,7 +149,7 @@
printFuncDecl(f, api, "rs", 0);
fprintf(f, "\n{\n");
- fprintf(f, " ThreadIO *io = gIO;\n");
+ fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
//fprintf(f, " LOGE(\"add command %s\\n\");\n", api->name);
fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->mToCore.reserve(sizeof(RS_CMD_%s)));\n", api->name, api->name, api->name);
fprintf(f, " uint32_t size = sizeof(RS_CMD_%s);\n", api->name);
@@ -200,7 +202,7 @@
fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
fprintf(f, " ");
if (api->ret.typeName[0]) {
- fprintf(f, "gIO->mToCoreRet = (intptr_t)");
+ fprintf(f, "con->mIO.mToCoreRet = (intptr_t)");
}
fprintf(f, "rsi_%s(con", api->name);
for(ct2=0; ct2 < api->paramCount; ct2++) {