Skip to content

Commit 80fe2c4

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge changes I7a6b9db4,Ib579f580
* changes: EGLConfig is now not remaped to an internal EGLConfig remove multiplexing of multiple EGL implementation
2 parents 9090a7a + b749dd8 commit 80fe2c4

File tree

10 files changed

+254
-630
lines changed

10 files changed

+254
-630
lines changed

opengl/libs/EGL/Loader.cpp

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,16 @@ status_t Loader::driver_t::set(void* hnd, int32_t api)
118118

119119
// ----------------------------------------------------------------------------
120120

121-
Loader::entry_t::entry_t(int dpy, int impl, const char* tag)
122-
: dpy(dpy), impl(impl), tag(tag) {
123-
}
124-
125-
// ----------------------------------------------------------------------------
126-
127121
Loader::Loader()
128122
{
129123
char line[256];
130124
char tag[256];
131125

132126
/* Special case for GLES emulation */
133127
if (checkGlesEmulationStatus() == 0) {
134-
ALOGD("Emulator without GPU support detected. Fallback to software renderer.");
135-
gConfig.add( entry_t(0, 0, "android") );
128+
ALOGD("Emulator without GPU support detected. "
129+
"Fallback to software renderer.");
130+
mDriverTag.setTo("android");
136131
return;
137132
}
138133

@@ -141,14 +136,16 @@ Loader::Loader()
141136
if (cfg == NULL) {
142137
// default config
143138
ALOGD("egl.cfg not found, using default config");
144-
gConfig.add( entry_t(0, 0, "android") );
139+
mDriverTag.setTo("android");
145140
} else {
146141
while (fgets(line, 256, cfg)) {
147-
int dpy;
148-
int impl;
142+
int dpy, impl;
149143
if (sscanf(line, "%u %u %s", &dpy, &impl, tag) == 3) {
150144
//ALOGD(">>> %u %u %s", dpy, impl, tag);
151-
gConfig.add( entry_t(dpy, impl, tag) );
145+
// We only load the h/w accelerated implementation
146+
if (tag != String8("android")) {
147+
mDriverTag = tag;
148+
}
152149
}
153150
}
154151
fclose(cfg);
@@ -160,30 +157,12 @@ Loader::~Loader()
160157
GLTrace_stop();
161158
}
162159

163-
const char* Loader::getTag(int dpy, int impl)
160+
void* Loader::open(egl_connection_t* cnx)
164161
{
165-
const Vector<entry_t>& cfgs(gConfig);
166-
const size_t c = cfgs.size();
167-
for (size_t i=0 ; i<c ; i++) {
168-
if (dpy == cfgs[i].dpy)
169-
if (impl == cfgs[i].impl)
170-
return cfgs[i].tag.string();
171-
}
172-
return 0;
173-
}
174-
175-
void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx)
176-
{
177-
/*
178-
* TODO: if we don't find display/0, then use 0/0
179-
* (0/0 should always work)
180-
*/
181-
182162
void* dso;
183-
int index = int(display);
184163
driver_t* hnd = 0;
185164

186-
char const* tag = getTag(index, impl);
165+
char const* tag = mDriverTag.string();
187166
if (tag) {
188167
dso = load_driver("GLES", tag, cnx, EGL | GLESv1_CM | GLESv2);
189168
if (dso) {
@@ -193,16 +172,14 @@ void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx
193172
dso = load_driver("EGL", tag, cnx, EGL);
194173
if (dso) {
195174
hnd = new driver_t(dso);
196-
197175
// TODO: make this more automated
198176
hnd->set( load_driver("GLESv1_CM", tag, cnx, GLESv1_CM), GLESv1_CM );
199-
200-
hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 );
177+
hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 );
201178
}
202179
}
203180
}
204181

205-
LOG_FATAL_IF(!index && !impl && !hnd,
182+
LOG_FATAL_IF(!index && !hnd,
206183
"couldn't find the default OpenGL ES implementation "
207184
"for default display");
208185

@@ -221,7 +198,7 @@ void Loader::init_api(void* dso,
221198
__eglMustCastToProperFunctionPointerType* curr,
222199
getProcAddressType getProcAddress)
223200
{
224-
const size_t SIZE = 256;
201+
const ssize_t SIZE = 256;
225202
char scrap[SIZE];
226203
while (*api) {
227204
char const * name = *api;
@@ -326,14 +303,14 @@ void *Loader::load_driver(const char* kind, const char *tag,
326303
if (mask & GLESv1_CM) {
327304
init_api(dso, gl_names,
328305
(__eglMustCastToProperFunctionPointerType*)
329-
&cnx->hooks[GLESv1_INDEX]->gl,
306+
&cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
330307
getProcAddress);
331308
}
332309

333310
if (mask & GLESv2) {
334311
init_api(dso, gl_names,
335312
(__eglMustCastToProperFunctionPointerType*)
336-
&cnx->hooks[GLESv2_INDEX]->gl,
313+
&cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
337314
getProcAddress);
338315
}
339316

opengl/libs/EGL/Loader.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <utils/Errors.h>
2525
#include <utils/Singleton.h>
2626
#include <utils/String8.h>
27-
#include <utils/Vector.h>
2827

2928
#include <EGL/egl.h>
3029

@@ -53,23 +52,13 @@ class Loader : public Singleton<Loader>
5352
void* dso[3];
5453
};
5554

56-
struct entry_t {
57-
entry_t() { }
58-
entry_t(int dpy, int impl, const char* tag);
59-
int dpy;
60-
int impl;
61-
String8 tag;
62-
};
63-
64-
Vector<entry_t> gConfig;
55+
String8 mDriverTag;
6556
getProcAddressType getProcAddress;
6657

67-
const char* getTag(int dpy, int impl);
68-
6958
public:
7059
~Loader();
7160

72-
void* open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx);
61+
void* open(egl_connection_t* cnx);
7362
status_t close(void* driver);
7463

7564
private:

opengl/libs/EGL/egl.cpp

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
namespace android {
4949
// ----------------------------------------------------------------------------
5050

51-
egl_connection_t gEGLImpl[IMPL_NUM_IMPLEMENTATIONS];
52-
gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS];
51+
egl_connection_t gEGLImpl;
52+
gl_hooks_t gHooks[2];
5353
gl_hooks_t gHooksNoContext;
5454
pthread_key_t gGLWrapperKey = -1;
5555

@@ -187,16 +187,13 @@ egl_display_t* validate_display(EGLDisplay dpy) {
187187
return dp;
188188
}
189189

190-
egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig config,
190+
egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig,
191191
egl_display_t const*& dp) {
192192
dp = validate_display(dpy);
193193
if (!dp)
194194
return (egl_connection_t*) NULL;
195195

196-
if (intptr_t(config) >= dp->numTotalConfigs) {
197-
return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
198-
}
199-
egl_connection_t* const cnx = &gEGLImpl[dp->configs[intptr_t(config)].impl];
196+
egl_connection_t* const cnx = &gEGLImpl;
200197
if (cnx->dso == 0) {
201198
return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
202199
}
@@ -228,7 +225,7 @@ EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image)
228225
// EGL.
229226

230227
egl_image_t const * const i = get_image(image);
231-
return i->images[c->impl];
228+
return i->image;
232229
}
233230

234231
// ----------------------------------------------------------------------------
@@ -266,34 +263,17 @@ static EGLBoolean egl_init_drivers_locked() {
266263
// get our driver loader
267264
Loader& loader(Loader::getInstance());
268265

269-
// dynamically load all our EGL implementations
270-
egl_connection_t* cnx;
271-
272-
cnx = &gEGLImpl[IMPL_SOFTWARE];
273-
if (cnx->dso == 0) {
274-
cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_SOFTWARE];
275-
cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_SOFTWARE];
276-
cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 0, cnx);
277-
}
278-
279-
cnx = &gEGLImpl[IMPL_HARDWARE];
266+
// dynamically load our EGL implementation
267+
egl_connection_t* cnx = &gEGLImpl;
280268
if (cnx->dso == 0) {
281-
char value[PROPERTY_VALUE_MAX];
282-
property_get("debug.egl.hw", value, "1");
283-
if (atoi(value) != 0) {
284-
cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_HARDWARE];
285-
cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_HARDWARE];
286-
cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 1, cnx);
287-
} else {
288-
ALOGD("3D hardware acceleration is disabled");
289-
}
290-
}
291-
292-
if (!gEGLImpl[IMPL_SOFTWARE].dso && !gEGLImpl[IMPL_HARDWARE].dso) {
293-
return EGL_FALSE;
269+
cnx->hooks[egl_connection_t::GLESv1_INDEX] =
270+
&gHooks[egl_connection_t::GLESv1_INDEX];
271+
cnx->hooks[egl_connection_t::GLESv2_INDEX] =
272+
&gHooks[egl_connection_t::GLESv2_INDEX];
273+
cnx->dso = loader.open(cnx);
294274
}
295275

296-
return EGL_TRUE;
276+
return cnx->dso ? EGL_TRUE : EGL_FALSE;
297277
}
298278

299279
static pthread_mutex_t sInitDriverMutex = PTHREAD_MUTEX_INITIALIZER;

0 commit comments

Comments
 (0)