diff options
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/Android.mk | 7 | ||||
-rw-r--r-- | libs/rs/driver/rsdBcc.cpp | 69 | ||||
-rw-r--r-- | libs/rs/driver/rsdGL.cpp | 80 | ||||
-rw-r--r-- | libs/rs/rsElement.cpp | 12 |
4 files changed, 76 insertions, 92 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk index d9cc6b6..a8aa0c7 100644 --- a/libs/rs/Android.mk +++ b/libs/rs/Android.mk @@ -77,11 +77,6 @@ rs_generated_source += $(GEN) LOCAL_GENERATED_SOURCES += $(GEN) -# libRS needs libacc, which isn't 64-bit clean, and so can't be built -# for the simulator on gHardy, and therefore libRS needs to be excluded -# from the simulator as well. -ifneq ($(TARGET_SIMULATOR),true) - LOCAL_SRC_FILES:= \ rsAdapter.cpp \ rsAllocation.cpp \ @@ -228,5 +223,3 @@ LOCAL_STATIC_LIBRARIES := libcutils libutils LOCAL_LDLIBS := -lpthread include $(BUILD_HOST_STATIC_LIBRARY) - -endif #simulator diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp index 27fc41f..bbf2836 100644 --- a/libs/rs/driver/rsdBcc.cpp +++ b/libs/rs/driver/rsdBcc.cpp @@ -66,65 +66,6 @@ static Script * setTLS(Script *sc) { } -// Input: cacheDir -// Input: resName -// Input: extName -// -// Note: cacheFile = resName + extName -// -// Output: Returns cachePath == cacheDir + cacheFile -static char *genCacheFileName(const char *cacheDir, - const char *resName, - const char *extName) { - char cachePath[512]; - char cacheFile[sizeof(cachePath)]; - const size_t kBufLen = sizeof(cachePath) - 1; - - cacheFile[0] = '\0'; - // Note: resName today is usually something like - // "/com.android.fountain:raw/fountain" - if (resName[0] != '/') { - // Get the absolute path of the raw/***.bc file. - - // Generate the absolute path. This doesn't do everything it - // should, e.g. if resName is "./out/whatever" it doesn't crunch - // the leading "./" out because this if-block is not triggered, - // but it'll make do. - // - if (getcwd(cacheFile, kBufLen) == NULL) { - LOGE("Can't get CWD while opening raw/***.bc file\n"); - return NULL; - } - // Append "/" at the end of cacheFile so far. - strncat(cacheFile, "/", kBufLen); - } - - // cacheFile = resName + extName - // - strncat(cacheFile, resName, kBufLen); - if (extName != NULL) { - // TODO(srhines): strncat() is a bit dangerous - strncat(cacheFile, extName, kBufLen); - } - - // Turn the path into a flat filename by replacing - // any slashes after the first one with '@' characters. - char *cp = cacheFile + 1; - while (*cp != '\0') { - if (*cp == '/') { - *cp = '@'; - } - cp++; - } - - // Tack on the file name for the actual cache file path. - strncpy(cachePath, cacheDir, kBufLen); - strncat(cachePath, cacheFile, kBufLen); - - LOGV("Cache file for '%s' '%s' is '%s'\n", resName, extName, cachePath); - return strdup(cachePath); -} - bool rsdScriptInit(const Context *rsc, ScriptC *script, char const *resName, @@ -164,15 +105,12 @@ bool rsdScriptInit(const Context *rsc, goto error; } -#if 1 if (bccLinkFile(drv->mBccScript, "/system/lib/libclcore.bc", 0) != 0) { LOGE("bcc: FAILS to link bitcode"); goto error; } -#endif - cachePath = genCacheFileName(cacheDir, resName, ".oBCC"); - if (bccPrepareExecutable(drv->mBccScript, cachePath, 0) != 0) { + if (bccPrepareExecutableEx(drv->mBccScript, cacheDir, resName, 0) != 0) { LOGE("bcc: FAILS to prepare executable"); goto error; } @@ -214,14 +152,13 @@ bool rsdScriptInit(const Context *rsc, const char ** mPragmaKeys; const char ** mPragmaValues; - const static int pragmaMax = 16; drv->mPragmaCount = bccGetPragmaCount(drv->mBccScript); if (drv->mPragmaCount <= 0) { drv->mPragmaKeys = NULL; drv->mPragmaValues = NULL; } else { - drv->mPragmaKeys = (const char **) calloc(drv->mFieldCount, sizeof(const char *)); - drv->mPragmaValues = (const char **) calloc(drv->mFieldCount, sizeof(const char *)); + drv->mPragmaKeys = (const char **) calloc(drv->mPragmaCount, sizeof(const char *)); + drv->mPragmaValues = (const char **) calloc(drv->mPragmaCount, sizeof(const char *)); bccGetPragmaList(drv->mBccScript, drv->mPragmaCount, drv->mPragmaKeys, drv->mPragmaValues); } diff --git a/libs/rs/driver/rsdGL.cpp b/libs/rs/driver/rsdGL.cpp index 1f7bb0f..04446ad 100644 --- a/libs/rs/driver/rsdGL.cpp +++ b/libs/rs/driver/rsdGL.cpp @@ -99,9 +99,8 @@ static void printEGLConfiguration(EGLDisplay dpy, EGLConfig config) { for (size_t j = 0; j < sizeof(names) / sizeof(names[0]); j++) { EGLint value = -1; - EGLint returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value); - EGLint error = eglGetError(); - if (returnVal && error == EGL_SUCCESS) { + EGLBoolean returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value); + if (returnVal) { LOGV(" %s: %d (0x%x)", names[j].name, value, value); } } @@ -169,6 +168,24 @@ bool rsdGLInit(const Context *rsc) { configAttribsPtr[1] = EGL_OPENGL_ES2_BIT; configAttribsPtr += 2; + configAttribsPtr[0] = EGL_RED_SIZE; + configAttribsPtr[1] = 8; + configAttribsPtr += 2; + + configAttribsPtr[0] = EGL_GREEN_SIZE; + configAttribsPtr[1] = 8; + configAttribsPtr += 2; + + configAttribsPtr[0] = EGL_BLUE_SIZE; + configAttribsPtr[1] = 8; + configAttribsPtr += 2; + + if (rsc->mUserSurfaceConfig.alphaMin > 0) { + configAttribsPtr[0] = EGL_ALPHA_SIZE; + configAttribsPtr[1] = rsc->mUserSurfaceConfig.alphaMin; + configAttribsPtr += 2; + } + if (rsc->mUserSurfaceConfig.depthMin > 0) { configAttribsPtr[0] = EGL_DEPTH_SIZE; configAttribsPtr[1] = rsc->mUserSurfaceConfig.depthMin; @@ -191,16 +208,53 @@ bool rsdGLInit(const Context *rsc) { eglInitialize(dc->gl.egl.display, &dc->gl.egl.majorVersion, &dc->gl.egl.minorVersion); checkEglError("eglInitialize"); - PixelFormat pf = PIXEL_FORMAT_RGBA_8888; - if (rsc->mUserSurfaceConfig.alphaMin == 0) { - pf = PIXEL_FORMAT_RGBX_8888; - } + EGLBoolean ret; - status_t err = EGLUtils::selectConfigForPixelFormat(dc->gl.egl.display, configAttribs, - pf, &dc->gl.egl.config); - if (err) { - LOGE("%p, couldn't find an EGLConfig matching the screen format\n", rsc); + EGLint numConfigs = -1, n = 0; + ret = eglChooseConfig(dc->gl.egl.display, configAttribs, 0, 0, &numConfigs); + checkEglError("eglGetConfigs", ret); + + if (numConfigs) { + EGLConfig* const configs = new EGLConfig[numConfigs]; + + ret = eglChooseConfig(dc->gl.egl.display, + configAttribs, configs, numConfigs, &n); + if (!ret || !n) { + checkEglError("eglChooseConfig", ret); + LOGE("%p, couldn't find an EGLConfig matching the screen format\n", rsc); + } + + // The first config is guaranteed to over-satisfy the constraints + dc->gl.egl.config = configs[0]; + + // go through the list and skip configs that over-satisfy our needs + for (int i=0 ; i<n ; i++) { + if (rsc->mUserSurfaceConfig.alphaMin <= 0) { + EGLint alphaSize; + eglGetConfigAttrib(dc->gl.egl.display, + configs[i], EGL_ALPHA_SIZE, &alphaSize); + if (alphaSize > 0) { + continue; + } + } + + if (rsc->mUserSurfaceConfig.depthMin <= 0) { + EGLint depthSize; + eglGetConfigAttrib(dc->gl.egl.display, + configs[i], EGL_DEPTH_SIZE, &depthSize); + if (depthSize > 0) { + continue; + } + } + + // Found one! + dc->gl.egl.config = configs[i]; + break; + } + + delete [] configs; } + //if (props.mLogVisual) { if (0) { printEGLConfiguration(dc->gl.egl.display, dc->gl.egl.config); @@ -227,8 +281,8 @@ bool rsdGLInit(const Context *rsc) { return false; } - EGLBoolean ret = eglMakeCurrent(dc->gl.egl.display, dc->gl.egl.surfaceDefault, - dc->gl.egl.surfaceDefault, dc->gl.egl.context); + ret = eglMakeCurrent(dc->gl.egl.display, dc->gl.egl.surfaceDefault, + dc->gl.egl.surfaceDefault, dc->gl.egl.context); if (ret == EGL_FALSE) { LOGE("eglMakeCurrent returned EGL_FALSE"); checkEglError("eglMakeCurrent", ret); diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp index 2b58e9e..b77b18a 100644 --- a/libs/rs/rsElement.cpp +++ b/libs/rs/rsElement.cpp @@ -263,10 +263,10 @@ void Element::incRefs(const void *ptr) const { const uint8_t *p = static_cast<const uint8_t *>(ptr); for (uint32_t i=0; i < mFieldCount; i++) { if (mFields[i].e->mHasReference) { - p = &p[mFields[i].offsetBits >> 3]; + const uint8_t *p2 = &p[mFields[i].offsetBits >> 3]; for (uint32_t ct=0; ct < mFields[i].arraySize; ct++) { - mFields[i].e->incRefs(p); - p += mFields[i].e->getSizeBytes(); + mFields[i].e->incRefs(p2); + p2 += mFields[i].e->getSizeBytes(); } } } @@ -285,10 +285,10 @@ void Element::decRefs(const void *ptr) const { const uint8_t *p = static_cast<const uint8_t *>(ptr); for (uint32_t i=0; i < mFieldCount; i++) { if (mFields[i].e->mHasReference) { - p = &p[mFields[i].offsetBits >> 3]; + const uint8_t *p2 = &p[mFields[i].offsetBits >> 3]; for (uint32_t ct=0; ct < mFields[i].arraySize; ct++) { - mFields[i].e->decRefs(p); - p += mFields[i].e->getSizeBytes(); + mFields[i].e->decRefs(p2); + p2 += mFields[i].e->getSizeBytes(); } } } |