From 3a833d8e0f5e1f09a9e276d0f8faf18f7ab86e27 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Mon, 8 Jun 2009 15:20:31 -0700 Subject: Fix build issue and ref count bug with scripts. --- libs/rs/rsContext.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'libs/rs/rsContext.cpp') diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index ec4a309..a16bfc7 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -37,13 +37,9 @@ void Context::initEGL() EGL_NONE }; - LOGE("EGL 1"); mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - LOGE("EGL 2 %p", mDisplay); eglInitialize(mDisplay, &mMajorVersion, &mMinorVersion); - LOGE("EGL 3 %i %i", mMajorVersion, mMinorVersion); eglChooseConfig(mDisplay, s_configAttribs, &mConfig, 1, &mNumConfigs); - LOGE("EGL 4 %p", mConfig); if (mWndSurface) { mSurface = eglCreateWindowSurface(mDisplay, mConfig, @@ -55,13 +51,10 @@ void Context::initEGL() NULL); } - LOGE("EGL 5"); mContext = eglCreateContext(mDisplay, mConfig, NULL, NULL); eglMakeCurrent(mDisplay, mSurface, mSurface, mContext); eglQuerySurface(mDisplay, mSurface, EGL_WIDTH, &mWidth); eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight); - LOGE("EGL 9"); - } bool Context::runRootScript() @@ -123,16 +116,11 @@ void * Context::threadProc(void *vrsc) { Context *rsc = static_cast(vrsc); - LOGE("TP 1"); gIO = new ThreadIO(); - rsc->mServerCommands.init(128); rsc->mServerReturns.init(128); rsc->initEGL(); - - LOGE("TP 2"); - rsc->mRunning = true; bool mDraw = true; while (!rsc->mExit) { @@ -149,7 +137,6 @@ void * Context::threadProc(void *vrsc) } } - LOGE("TP 6"); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); eglSwapBuffers(rsc->mDisplay, rsc->mSurface); @@ -159,7 +146,6 @@ void * Context::threadProc(void *vrsc) Context::Context(Device *dev, Surface *sur) { - LOGE("CC 1"); dev->addContext(this); mDev = dev; mRunning = false; @@ -171,7 +157,6 @@ Context::Context(Device *dev, Surface *sur) // see comment in header gCon = this; - LOGE("CC 2"); int status; pthread_attr_t threadAttr; @@ -185,17 +170,16 @@ Context::Context(Device *dev, Surface *sur) sparam.sched_priority = ANDROID_PRIORITY_DISPLAY; pthread_attr_setschedparam(&threadAttr, &sparam); + LOGE("RS Launching thread"); status = pthread_create(&mThreadId, &threadAttr, threadProc, this); if (status) { LOGE("Failed to start rs context thread."); } - LOGE("CC 3"); mWndSurface = sur; while(!mRunning) { sleep(1); } - LOGE("CC 4"); pthread_attr_destroy(&threadAttr); } @@ -205,14 +189,11 @@ Context::~Context() mExit = true; void *res; - LOGE("DES 1"); int status = pthread_join(mThreadId, &res); - LOGE("DES 2"); if (mDev) { mDev->removeContext(this); } - LOGE("DES 3"); } void Context::swapBuffers() -- cgit v1.1 From 928f5cf2870177abd715e1dfb81da6ac1fe3e845 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Mon, 8 Jun 2009 18:50:13 -0700 Subject: Move placement of script enviroment data to base. --- libs/rs/rsContext.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libs/rs/rsContext.cpp') diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index a16bfc7..6a47de1 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -86,11 +86,11 @@ bool Context::runRootScript() glDepthMask(GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(mRootScript->mClearColor[0], - mRootScript->mClearColor[1], - mRootScript->mClearColor[2], - mRootScript->mClearColor[3]); - glClearDepthf(mRootScript->mClearDepth); + glClearColor(mRootScript->mEnviroment.mClearColor[0], + mRootScript->mEnviroment.mClearColor[1], + mRootScript->mEnviroment.mClearColor[2], + mRootScript->mEnviroment.mClearColor[3]); + glClearDepthf(mRootScript->mEnviroment.mClearDepth); glClear(GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT); -- cgit v1.1 From da423d8479a2cefb456a03d7dc550e74e473acf4 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Tue, 9 Jun 2009 12:15:30 -0700 Subject: checkpoint pragma support. Includes more cleanup of script enviroment storage to keep the env settings in the base and only the per language state in ScriptC. --- libs/rs/rsContext.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'libs/rs/rsContext.cpp') diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 6a47de1..82d6499 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -57,21 +57,34 @@ void Context::initEGL() eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight); } +bool Context::runScript(Script *s) +{ + ObjectBaseRef frag(mFragment); + ObjectBaseRef vtx(mVertex); + ObjectBaseRef store(mFragmentStore); + + + + return true; + +} + + bool Context::runRootScript() { - rsAssert(mRootScript->mIsRoot); + rsAssert(mRootScript->mEnviroment.mIsRoot); glColor4f(1,1,1,1); glEnable(GL_LIGHT0); - glViewport(0, 0, 320, 480); - float aspectH = 480.f / 320.f; + glViewport(0, 0, mWidth, mHeight); - if(mRootScript->mIsOrtho) { + if(mRootScript->mEnviroment.mIsOrtho) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrthof(0, 320, 480, 0, 0, 1); + glOrthof(0, mWidth, mHeight, 0, 0, 1); glMatrixMode(GL_MODELVIEW); } else { + float aspectH = ((float)mWidth) / mHeight; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustumf(-1, 1, -aspectH, aspectH, 1, 100); -- cgit v1.1 From 3eaa338e11a3b0d6b87d705e5bb95625e82347bd Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Wed, 10 Jun 2009 15:04:38 -0700 Subject: Add named objects and implement support for ProgramFragmentStore and ProgramFragment to be used by name in scripts. --- libs/rs/rsContext.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'libs/rs/rsContext.cpp') diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 82d6499..ffd03d5 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -57,14 +57,17 @@ void Context::initEGL() eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight); } -bool Context::runScript(Script *s) +bool Context::runScript(Script *s, uint32_t launchID) { ObjectBaseRef frag(mFragment); ObjectBaseRef vtx(mVertex); ObjectBaseRef store(mFragmentStore); + bool ret = s->run(this, launchID); - + mFragment.set(frag); + mVertex.set(vtx); + mFragmentStore.set(store); return true; } @@ -107,7 +110,7 @@ bool Context::runRootScript() glClear(GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT); - return mRootScript->run(this, 0); + return runScript(mRootScript.get(), 0); } void Context::setupCheck() @@ -243,6 +246,33 @@ void Context::setVertex(ProgramVertex *pv) pv->setupGL(); } +void Context::assignName(ObjectBase *obj, const char *name) +{ + rsAssert(!obj->getName()); + obj->setName(name); + mNames.add(obj); +} + +void Context::removeName(ObjectBase *obj) +{ + for(size_t ct=0; ct < mNames.size(); ct++) { + if (obj == mNames[ct]) { + mNames.removeAt(ct); + return; + } + } +} + +ObjectBase * Context::lookupName(const char *name) const +{ + for(size_t ct=0; ct < mNames.size(); ct++) { + if (!strcmp(name, mNames[ct]->getName())) { + return mNames[ct]; + } + } + return NULL; +} + /////////////////////////////////////////////////////////////////////////////////////////// // @@ -286,6 +316,11 @@ void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv) rsc->setVertex(pv); } +void rsi_AssignName(Context *rsc, void * obj, const char *name) +{ + ObjectBase *ob = static_cast(obj); + rsc->assignName(ob, name); +} } -- cgit v1.1 From d5680f9ba95ec7ce212e8025774914e79982a1ee Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Wed, 10 Jun 2009 18:39:40 -0700 Subject: Fix bug with bad conversion of java strings to C strings for object names. Update test app to test object defines. --- libs/rs/rsContext.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'libs/rs/rsContext.cpp') diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index ffd03d5..266c455 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -17,7 +17,7 @@ #include "rsDevice.h" #include "rsContext.h" #include "rsThreadIO.h" - +#include "utils/String8.h" using namespace android; using namespace android::renderscript; @@ -246,10 +246,10 @@ void Context::setVertex(ProgramVertex *pv) pv->setupGL(); } -void Context::assignName(ObjectBase *obj, const char *name) +void Context::assignName(ObjectBase *obj, const char *name, uint32_t len) { rsAssert(!obj->getName()); - obj->setName(name); + obj->setName(name, len); mNames.add(obj); } @@ -273,6 +273,19 @@ ObjectBase * Context::lookupName(const char *name) const return NULL; } +void Context::appendNameDefines(String8 *str) const +{ + char buf[256]; + for (size_t ct=0; ct < mNames.size(); ct++) { + str->append("#define NAMED_"); + str->append(mNames[ct]->getName()); + str->append(" "); + sprintf(buf, "%i\n", (int)mNames[ct]); + str->append(buf); + } +} + + /////////////////////////////////////////////////////////////////////////////////////////// // @@ -316,10 +329,10 @@ void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv) rsc->setVertex(pv); } -void rsi_AssignName(Context *rsc, void * obj, const char *name) +void rsi_AssignName(Context *rsc, void * obj, const char *name, uint32_t len) { ObjectBase *ob = static_cast(obj); - rsc->assignName(ob, name); + rsc->assignName(ob, name, len); } -- cgit v1.1