Fix two EGLConfig selection bugs
This fixes two bugs introduced by Change-Id: Ia8cc084c02a0e3de910def024da8a08d02bbd89d (a) There is no invalid EGLConfig value, in particular zero is valid. Checking return values of eglGetConfigs and eglChooseConfig is the only way to determine success. (b) The "simple" EGLConfig query used as the emulator fallback should not include EGL_RECORDABLE; the emulator doesn't have it. Bug: 10935622 Change-Id: Ib798a24e7cf06a679811c46eaa45d39174a715ec
This commit is contained in:
parent
86206b41b2
commit
b65f32ebe2
@ -366,12 +366,10 @@ public:
|
|||||||
operator EGLint const* () const { return &mList.keyAt(0).v; }
|
operator EGLint const* () const { return &mList.keyAt(0).v; }
|
||||||
};
|
};
|
||||||
|
|
||||||
EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId,
|
status_t SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId,
|
||||||
EGLint renderableType) {
|
EGLint renderableType, EGLConfig* config) {
|
||||||
// select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if
|
// select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if
|
||||||
// it is to be used with WIFI displays
|
// it is to be used with WIFI displays
|
||||||
EGLConfig config;
|
|
||||||
EGLint dummy;
|
|
||||||
status_t err;
|
status_t err;
|
||||||
EGLint wantedAttribute;
|
EGLint wantedAttribute;
|
||||||
EGLint wantedAttributeValue;
|
EGLint wantedAttributeValue;
|
||||||
@ -390,22 +388,18 @@ EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisua
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if no renderable type specified, fallback to a simplified query
|
// if no renderable type specified, fallback to a simplified query
|
||||||
attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE;
|
|
||||||
wantedAttribute = EGL_NATIVE_VISUAL_ID;
|
wantedAttribute = EGL_NATIVE_VISUAL_ID;
|
||||||
wantedAttributeValue = nativeVisualId;
|
wantedAttributeValue = nativeVisualId;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = selectConfigForAttribute(display, attribs, wantedAttribute,
|
err = selectConfigForAttribute(display, attribs, wantedAttribute,
|
||||||
wantedAttributeValue, &config);
|
wantedAttributeValue, config);
|
||||||
if (!err)
|
if (err == NO_ERROR) {
|
||||||
goto success;
|
EGLint caveat;
|
||||||
|
if (eglGetConfigAttrib(display, *config, EGL_CONFIG_CAVEAT, &caveat))
|
||||||
return 0;
|
ALOGW_IF(caveat == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!");
|
||||||
|
}
|
||||||
success:
|
return err;
|
||||||
if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy))
|
|
||||||
ALOGW_IF(dummy == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!");
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceFlinger::init() {
|
void SurfaceFlinger::init() {
|
||||||
@ -413,6 +407,7 @@ void SurfaceFlinger::init() {
|
|||||||
ALOGI( "SurfaceFlinger's main thread ready to run. "
|
ALOGI( "SurfaceFlinger's main thread ready to run. "
|
||||||
"Initializing graphics H/W...");
|
"Initializing graphics H/W...");
|
||||||
|
|
||||||
|
status_t err;
|
||||||
Mutex::Autolock _l(mStateLock);
|
Mutex::Autolock _l(mStateLock);
|
||||||
|
|
||||||
// initialize EGL for the default display
|
// initialize EGL for the default display
|
||||||
@ -425,21 +420,23 @@ void SurfaceFlinger::init() {
|
|||||||
*static_cast<HWComposer::EventHandler *>(this));
|
*static_cast<HWComposer::EventHandler *>(this));
|
||||||
|
|
||||||
// First try to get an ES2 config
|
// First try to get an ES2 config
|
||||||
mEGLConfig = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), EGL_OPENGL_ES2_BIT);
|
err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), EGL_OPENGL_ES2_BIT,
|
||||||
|
&mEGLConfig);
|
||||||
|
|
||||||
if (!mEGLConfig) {
|
if (err != NO_ERROR) {
|
||||||
// If ES2 fails, try ES1
|
// If ES2 fails, try ES1
|
||||||
mEGLConfig = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), EGL_OPENGL_ES_BIT);
|
err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(),
|
||||||
|
EGL_OPENGL_ES_BIT, &mEGLConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mEGLConfig) {
|
if (err != NO_ERROR) {
|
||||||
// still didn't work, probably because we're on the emulator...
|
// still didn't work, probably because we're on the emulator...
|
||||||
// try a simplified query
|
// try a simplified query
|
||||||
ALOGW("no suitable EGLConfig found, trying a simpler query");
|
ALOGW("no suitable EGLConfig found, trying a simpler query");
|
||||||
mEGLConfig = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), 0);
|
err = selectEGLConfig(mEGLDisplay, mHwc->getVisualID(), 0, &mEGLConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mEGLConfig) {
|
if (err != NO_ERROR) {
|
||||||
// this EGL is too lame for android
|
// this EGL is too lame for android
|
||||||
LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up");
|
LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up");
|
||||||
}
|
}
|
||||||
|
@ -317,8 +317,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
static status_t selectConfigForAttribute(EGLDisplay dpy,
|
static status_t selectConfigForAttribute(EGLDisplay dpy,
|
||||||
EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig);
|
EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig);
|
||||||
static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId,
|
static status_t selectEGLConfig(EGLDisplay disp, EGLint visualId,
|
||||||
EGLint renderableType);
|
EGLint renderableType, EGLConfig* config);
|
||||||
size_t getMaxTextureSize() const;
|
size_t getMaxTextureSize() const;
|
||||||
size_t getMaxViewportDims() const;
|
size_t getMaxViewportDims() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user