summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/rsContext.cpp30
-rw-r--r--libs/rs/rsContext.h3
-rw-r--r--libs/rs/rsProgram.h4
-rw-r--r--libs/rs/rsProgramRaster.cpp2
4 files changed, 33 insertions, 6 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 195ea6f..cc39dac 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -29,6 +29,8 @@ using namespace android;
using namespace android::renderscript;
pthread_key_t Context::gThreadTLSKey = 0;
+uint32_t Context::gThreadTLSKeyCount = 0;
+pthread_mutex_t Context::gInitMutex = PTHREAD_MUTEX_INITIALIZER;
void Context::initEGL()
{
@@ -57,6 +59,7 @@ void Context::initEGL()
configAttribsPtr[0] = EGL_NONE;
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
+ LOGV("initEGL start");
mEGL.mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(mEGL.mDisplay, &mEGL.mMajorVersion, &mEGL.mMinorVersion);
@@ -144,6 +147,12 @@ bool Context::runRootScript()
}
mStateFragmentStore.mLast.clear();
bool ret = runScript(mRootScript.get(), 0);
+
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR) {
+ LOGE("Pending GL Error, 0x%x", err);
+ }
+
return ret;
}
@@ -293,6 +302,8 @@ void * Context::threadProc(void *vrsc)
Context::Context(Device *dev, Surface *sur, bool useDepth)
{
+ pthread_mutex_lock(&gInitMutex);
+
dev->addContext(this);
mDev = dev;
mRunning = false;
@@ -304,16 +315,18 @@ Context::Context(Device *dev, Surface *sur, bool useDepth)
int status;
pthread_attr_t threadAttr;
- if (!gThreadTLSKey) {
+ if (!gThreadTLSKeyCount) {
status = pthread_key_create(&gThreadTLSKey, NULL);
if (status) {
LOGE("Failed to init thread tls key.");
+ pthread_mutex_unlock(&gInitMutex);
return;
}
- } else {
- // HACK: workaround gl hang on start
- exit(-1);
}
+ gThreadTLSKeyCount++;
+ pthread_mutex_unlock(&gInitMutex);
+
+ // Global init done at this point.
status = pthread_attr_init(&threadAttr);
if (status) {
@@ -355,10 +368,16 @@ Context::~Context()
int status = pthread_join(mThreadId, &res);
objDestroyOOBRun();
+ // Global structure cleanup.
+ pthread_mutex_lock(&gInitMutex);
if (mDev) {
mDev->removeContext(this);
- pthread_key_delete(gThreadTLSKey);
+ --gThreadTLSKeyCount;
+ if (!gThreadTLSKeyCount) {
+ pthread_key_delete(gThreadTLSKey);
+ }
}
+ pthread_mutex_unlock(&gInitMutex);
objDestroyOOBDestroy();
}
@@ -419,6 +438,7 @@ void Context::setVertex(ProgramVertex *pv)
} else {
mVertex.set(pv);
}
+ mVertex->forceDirty();
}
void Context::assignName(ObjectBase *obj, const char *name, uint32_t len)
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 3570e10..0dd90ed 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -53,6 +53,9 @@ public:
~Context();
static pthread_key_t gThreadTLSKey;
+ static uint32_t gThreadTLSKeyCount;
+ static pthread_mutex_t gInitMutex;
+
struct ScriptTLSStruct {
Context * mContext;
Script * mScript;
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h
index 26b78dd..57c654f 100644
--- a/libs/rs/rsProgram.h
+++ b/libs/rs/rsProgram.h
@@ -44,6 +44,10 @@ protected:
ObjectBaseRef<Allocation> mConstants;
mutable bool mDirty;
+
+
+public:
+ void forceDirty() {mDirty = true;}
};
diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp
index fcf6824..51ae7cf 100644
--- a/libs/rs/rsProgramRaster.cpp
+++ b/libs/rs/rsProgramRaster.cpp
@@ -74,7 +74,7 @@ void ProgramRaster::setupGL(const Context *rsc, ProgramRasterState *state)
if (mLineSmooth) {
glEnable(GL_LINE_SMOOTH);
} else {
- glEnable(GL_LINE_SMOOTH);
+ glDisable(GL_LINE_SMOOTH);
}
if (rsc->checkVersion1_1()) {