From 99174e7630676307f618c252755a20ba61ad9158 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 16 Jul 2009 15:57:22 -0700 Subject: i965: Add missing state dependency of sf_unit on _NEW_BUFFERS. --- src/mesa/drivers/dri/i965/brw_sf_state.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index e73e57a1c8..b5f6371c82 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -246,7 +246,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key, else if (sf.sf6.line_width <= 0x2) sf.sf6.line_width = 0; - /* _NEW_POINT */ + /* _NEW_BUFFERS */ key->render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0; if (!key->render_to_fbo) { /* Rendering to an OpenGL window */ @@ -276,6 +276,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key, } /* XXX clamp max depends on AA vs. non-AA */ + /* _NEW_POINT */ sf.sf7.sprite_point = key->point_sprite; sf.sf7.point_size = CLAMP(rint(key->point_size), 1, 255) * (1<<3); sf.sf7.use_point_size_state = !key->point_attenuated; @@ -341,7 +342,8 @@ const struct brw_tracked_state brw_sf_unit = { .mesa = (_NEW_POLYGON | _NEW_LINE | _NEW_POINT | - _NEW_SCISSOR), + _NEW_SCISSOR | + _NEW_BUFFERS), .brw = BRW_NEW_URB_FENCE, .cache = (CACHE_NEW_SF_VP | CACHE_NEW_SF_PROG) -- cgit v1.2.3 From cca31340b5a9c0b941946753a31236c7201ca87c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 17 Jul 2009 11:53:03 -0600 Subject: egl: Use the link functions to manage resources. This commit uses the newly introduced link functions to manage EGL contexts and surfaces. As a result of this, the API for drivers are changed. All drivers are updated for the change. Signed-off-by: Chia-I Wu --- src/egl/drivers/demo/demo.c | 17 ++++--- src/egl/drivers/dri/egldri.c | 33 ++++++++------ src/egl/drivers/glx/egl_glx.c | 42 +++++++++++------ src/egl/drivers/xdri/egl_xdri.c | 19 ++++---- src/egl/main/eglcontext.c | 45 +++++------------- src/egl/main/eglcontext.h | 12 +---- src/egl/main/eglglobals.h | 1 + src/egl/main/eglscreen.c | 15 ++++-- src/egl/main/eglsurface.c | 68 ++++++++++++---------------- src/egl/main/eglsurface.h | 13 +----- src/gallium/state_trackers/egl/egl_context.c | 8 ++-- src/gallium/state_trackers/egl/egl_surface.c | 7 +-- src/gallium/winsys/egl_xlib/egl_xlib.c | 13 +++--- src/mesa/drivers/dri/fb/fb_egl.c | 10 ++-- 14 files changed, 143 insertions(+), 160 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 1750e976b8..fa9efa5d35 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -146,12 +146,12 @@ demoCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!c) return EGL_NO_CONTEXT; - _eglInitContext(drv, dpy, &c->Base, config, attrib_list); + _eglInitContext(drv, &c->Base, conf, attrib_list); c->DemoStuff = 1; printf("demoCreateContext\n"); - /* generate handle and insert into hash table */ - _eglSaveContext(&c->Base); + /* link to display */ + _eglLinkContext(&c->Base, _eglLookupDisplay(dpy)); assert(_eglGetContextHandle(&c->Base)); return _eglGetContextHandle(&c->Base); @@ -213,11 +213,14 @@ demoCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { DemoSurface *surf = (DemoSurface *) calloc(1, sizeof(DemoSurface)); + _EGLConfig *conf; + if (!surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + conf = _eglLookupConfig(drv, dpy, config); + if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } @@ -232,7 +235,7 @@ static EGLBoolean demoDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { DemoSurface *fs = LookupDemoSurface(surface); - _eglRemoveSurface(&fs->Base); + _eglUnlinkSurface(&fs->Base); if (fs->Base.IsBound) { fs->Base.DeletePending = EGL_TRUE; } @@ -247,7 +250,7 @@ static EGLBoolean demoDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { DemoContext *fc = LookupDemoContext(context); - _eglRemoveContext(&fc->Base); + _eglUnlinkContext(&fc->Base); if (fc->Base.IsBound) { fc->Base.DeletePending = EGL_TRUE; } diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 57661cc3ab..df45fbfbe2 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -171,7 +171,10 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!c) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, &c->Base, config, attrib_list)) { + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + + if (!_eglInitContext(drv, &c->Base, conf, attrib_list)) { free(c); return EGL_NO_CONTEXT; } @@ -189,8 +192,6 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, else sharePriv = NULL; - conf = _eglLookupConfig(drv, dpy, config); - assert(conf); _eglConfigToContextModesRec(conf, &visMode); c->driContext.private = disp->driScreen.createNewContext(disp, &visMode, @@ -200,8 +201,8 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_FALSE; } - /* generate handle and insert into hash table */ - _eglSaveContext(&c->Base); + /* link to display */ + _eglLinkContext(&c->Base, &disp->Base); return _eglGetContextHandle(&c->Base); } @@ -237,14 +238,18 @@ _eglDRICreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { driSurface *surf; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); surf = (driSurface *) calloc(1, sizeof(*surf)); if (!surf) { return EGL_NO_SURFACE; } - if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } @@ -275,7 +280,7 @@ _eglDRICreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, #endif } - _eglSaveSurface(&surf->Base); + _eglLinkSurface(&surf->Base, _eglLookupDisplay(dpy)); return surf->Base.Handle; } @@ -287,7 +292,7 @@ _eglDRIDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) driDisplay *disp = Lookup_driDisplay(dpy); driSurface *fs = Lookup_driSurface(surface); - _eglRemoveSurface(&fs->Base); + _eglUnlinkSurface(&fs->Base); fs->drawable.destroyDrawable(disp, fs->drawable.private); @@ -307,7 +312,7 @@ _eglDRIDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) driDisplay *disp = Lookup_driDisplay(dpy); driContext *fc = Lookup_driContext(context); - _eglRemoveContext(&fc->Base); + _eglUnlinkContext(&fc->Base); fc->driContext.destroyContext(disp, 0, fc->driContext.private); @@ -340,13 +345,13 @@ _eglDRICreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, } /* init base class, do error checking, etc. */ - if (!_eglInitSurface(drv, dpy, &surface->Base, EGL_SCREEN_BIT_MESA, - cfg, attrib_list)) { + if (!_eglInitSurface(drv, &surface->Base, EGL_SCREEN_BIT_MESA, + config, attrib_list)) { free(surface); return EGL_NO_SURFACE; } - _eglSaveSurface(&surface->Base); + _eglLinkSurface(&surface->Base &disp->Base); /* @@ -363,7 +368,7 @@ _eglDRICreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, if (!disp->driScreen.createNewDrawable(disp, &visMode, drawBuf, &surface->drawable, GLX_WINDOW_BIT, empty_attribute_list)) { - _eglRemoveSurface(&surface->Base); + _eglUnlinkSurface(&surface->Base); free(surface); return EGL_NO_SURFACE; } diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 155caa413c..661b313ae2 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -532,7 +532,10 @@ GLX_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!GLX_ctx) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, &GLX_ctx->Base, config, attrib_list)) { + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + + if (!_eglInitContext(drv, &GLX_ctx->Base, conf, attrib_list)) { free(GLX_ctx); return EGL_NO_CONTEXT; } @@ -546,9 +549,6 @@ GLX_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, GLX_ctx_shared = GLX_egl_context(shareCtx); } - conf = _eglLookupConfig(drv, dpy, config); - assert(conf); - #ifdef GLX_VERSION_1_3 if (GLX_drv->fbconfigs) GLX_ctx->context = glXCreateNewContext(disp->Xdpy, GLX_drv->fbconfigs[(int)config-1], GLX_RGBA_TYPE, GLX_ctx_shared ? GLX_ctx_shared->context : NULL, GL_TRUE); @@ -564,7 +564,7 @@ GLX_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_FALSE; #endif - return _eglGetContextHandle(&GLX_ctx->Base); + return _eglLinkContext(&GLX_ctx->Base, disp); } @@ -619,18 +619,22 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, _EGLDisplay *disp = _eglLookupDisplay(dpy); struct GLX_egl_surface *GLX_surf; uint width, height; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &GLX_surf->Base, EGL_WINDOW_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &GLX_surf->Base, EGL_WINDOW_BIT, + conf, attrib_list)) { free(GLX_surf); return EGL_FALSE; } - _eglSaveSurface(&GLX_surf->Base); + _eglLinkSurface(&GLX_surf->Base, disp); GLX_surf->drawable = window; get_drawable_size(disp->Xdpy, window, &width, &height); @@ -648,19 +652,23 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv); _EGLDisplay *disp = _eglLookupDisplay(dpy); struct GLX_egl_surface *GLX_surf; + _EGLConfig *conf; int i; + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &GLX_surf->Base, EGL_PIXMAP_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &GLX_surf->Base, EGL_PIXMAP_BIT, + conf, attrib_list)) { free(GLX_surf); return EGL_FALSE; } - _eglSaveSurface(&GLX_surf->Base); + _eglLinkSurface(&GLX_surf->Base, disp); for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { @@ -683,20 +691,24 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv); _EGLDisplay *disp = _eglLookupDisplay(dpy); struct GLX_egl_surface *GLX_surf; + _EGLConfig *conf; int attribs[5]; int i = 0, j = 0; + conf = _eglLookupConfig(drv, dpy, config); + assert(conf); + GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &GLX_surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &GLX_surf->Base, EGL_PBUFFER_BIT, + conf, attrib_list)) { free(GLX_surf); return EGL_NO_SURFACE; } - _eglSaveSurface(&GLX_surf->Base); + _eglLinkSurface(&GLX_surf->Base, disp); while(attrib_list[i] != EGL_NONE) { switch (attrib_list[i]) { @@ -726,7 +738,7 @@ GLX_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) _EGLSurface *surf = _eglLookupSurface(surface); return EGL_TRUE; if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(surf); if (surf->IsBound) { surf->DeletePending = EGL_TRUE; } diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 3b3e312746..34d69def6a 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -770,7 +770,7 @@ xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!xdri_ctx) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, &xdri_ctx->Base, config, attrib_list)) { + if (!_eglInitContext(drv, &xdri_ctx->Base, &xdri_config->Base, attrib_list)) { free(xdri_ctx); return EGL_NO_CONTEXT; } @@ -794,7 +794,7 @@ xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_ctx->driContext.mode = xdri_config->mode; - return _eglGetContextHandle(&xdri_ctx->Base); + return _eglLinkContext(&xdri_ctx->Base, &disp); } @@ -835,6 +835,7 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) { _EGLDisplay *disp = _eglLookupDisplay(dpy); + struct xdri_egl_config *xdri_config = lookup_config(drv, dpy, config); struct xdri_egl_surface *xdri_surf; int scrn = DefaultScreen(disp->Xdpy); uint width, height; @@ -843,8 +844,8 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!xdri_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &xdri_surf->Base, EGL_WINDOW_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &xdri_surf->Base, EGL_WINDOW_BIT, + &xdri_config->Base, attrib_list)) { free(xdri_surf); return EGL_FALSE; } @@ -856,7 +857,7 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_surf->driDrawable = window; - _eglSaveSurface(&xdri_surf->Base); + _eglLinkSurface(&xdri_surf->Base, disp); get_drawable_size(disp->Xdpy, window, &width, &height); xdri_surf->Base.Width = width; @@ -888,8 +889,8 @@ xdri_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!xdri_surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, &xdri_surf->Base, EGL_PBUFFER_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &xdri_surf->Base, EGL_PBUFFER_BIT, + &xdri_config->Base, attrib_list)) { free(xdri_surf); return EGL_FALSE; } @@ -939,7 +940,7 @@ xdri_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_surf->driDrawable = window; - _eglSaveSurface(&xdri_surf->Base); + _eglLinkSurface(&xdri_surf->Base, disp); _eglLog(_EGL_DEBUG, "XDRI: CreatePbufferSurface handle %d hDrawable %d", @@ -956,7 +957,7 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { struct xdri_egl_surface *xdri_surf = lookup_surface(surface); if (xdri_surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(&xdri_surf->Base); if (xdri_surf->Base.IsBound) { xdri_surf->Base.DeletePending = EGL_TRUE; } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index edcc6a986f..01cb116d00 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -14,11 +14,9 @@ * in the attrib_list. */ EGLBoolean -_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, - EGLConfig config, const EGLint *attrib_list) +_eglInitContext(_EGLDriver *drv, _EGLContext *ctx, + _EGLConfig *conf, const EGLint *attrib_list) { - _EGLConfig *conf; - _EGLDisplay *display = _eglLookupDisplay(dpy); EGLint i; const EGLenum api = eglQueryAPI(); @@ -27,7 +25,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, return EGL_FALSE; } - conf = _eglLookupConfig(drv, dpy, config); if (!conf) { _eglError(EGL_BAD_CONFIG, "_eglInitContext"); return EGL_FALSE; @@ -49,7 +46,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, } } - ctx->Display = display; ctx->Config = conf; ctx->DrawSurface = EGL_NO_SURFACE; ctx->ReadSurface = EGL_NO_SURFACE; @@ -59,30 +55,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, } -/** - * Save a new _EGLContext into the hash table. - */ -void -_eglSaveContext(_EGLContext *ctx) -{ - /* no-op. - * Public EGLContext handle and private _EGLContext are the same. - */ -} - - -/** - * Remove the given _EGLContext object from the hash table. - */ -void -_eglRemoveContext(_EGLContext *ctx) -{ - /* no-op. - * Public EGLContext handle and private _EGLContext are the same. - */ -} - - /** * Just a placeholder/demo function. Real driver will never use this! */ @@ -92,18 +64,24 @@ _eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, { #if 0 /* example code */ _EGLContext *context; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + if (!conf) { + _eglError(EGL_BAD_CONFIG, "eglCreateContext"); + return EGL_NO_CONTEXT; + } context = (_EGLContext *) calloc(1, sizeof(_EGLContext)); if (!context) return EGL_NO_CONTEXT; - if (!_eglInitContext(drv, dpy, context, config, attrib_list)) { + if (!_eglInitContext(drv, context, conf, attrib_list)) { free(context); return EGL_NO_CONTEXT; } - _eglSaveContext(context); - return (EGLContext) context; + return _eglLinkContext(context, _eglLookupDisplay(dpy)); #endif return EGL_NO_CONTEXT; } @@ -117,6 +95,7 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) { _EGLContext *context = _eglLookupContext(ctx); if (context) { + _eglUnlinkContext(context); if (context->IsBound) { context->DeletePending = EGL_TRUE; } diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 6e418dfbbe..8e20643177 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -29,16 +29,8 @@ struct _egl_context extern EGLBoolean -_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, - EGLConfig config, const EGLint *attrib_list); - - -extern void -_eglSaveContext(_EGLContext *ctx); - - -extern void -_eglRemoveContext(_EGLContext *ctx); +_eglInitContext(_EGLDriver *drv, _EGLContext *ctx, + _EGLConfig *config, const EGLint *attrib_list); extern EGLContext diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index fbb55c23f0..a9443cfbdd 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -13,6 +13,7 @@ struct _egl_global { EGLBoolean Initialized; + /* these are private to egldisplay.c */ _EGLHashtable *Displays; _EGLHashtable *Surfaces; diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 9c9a8377bf..b6bde65e8b 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -128,20 +128,25 @@ _eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, { #if 0 /* THIS IS JUST EXAMPLE CODE */ _EGLSurface *surf; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + if (!conf) { + _eglError(EGL_BAD_CONFIG, "eglCreateScreenSurfaceMESA"); + return EGL_NO_SURFACE; + } surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); if (!surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, surf, EGL_SCREEN_BIT_MESA, - config, attrib_list)) { + if (!_eglInitSurface(drv, surf, EGL_SCREEN_BIT_MESA, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } - _eglSaveSurface(surf); - - return surf->Handle; + return _eglLinkSurface(surf, _eglLookupDisplay(dpy)); #endif return EGL_NO_SURFACE; } diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 854f499fce..b122124585 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -21,12 +21,10 @@ * \return EGL_TRUE if no errors, EGL_FALSE otherwise. */ EGLBoolean -_eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, - _EGLSurface *surf, EGLint type, EGLConfig config, - const EGLint *attrib_list) +_eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type, + _EGLConfig *conf, const EGLint *attrib_list) { const char *func; - _EGLConfig *conf; EGLint width = 0, height = 0, largest = 0; EGLint texFormat = 0, texTarget = 0, mipmapTex = 0; EGLint renderBuffer = EGL_BACK_BUFFER; @@ -56,7 +54,6 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, return EGL_FALSE; } - conf = _eglLookupConfig(drv, dpy, config); if (!conf) { _eglError(EGL_BAD_CONFIG, func); return EGL_FALSE; @@ -212,26 +209,6 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, } -void -_eglSaveSurface(_EGLSurface *surf) -{ - EGLuint key = _eglHashGenKey(_eglGlobal.Surfaces); - assert(surf); - assert(!surf->Handle); - surf->Handle = (EGLSurface) key; - assert(surf->Handle); - _eglHashInsert(_eglGlobal.Surfaces, key, surf); -} - - -void -_eglRemoveSurface(_EGLSurface *surf) -{ - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surf->Handle); -} - - - EGLBoolean _eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) { @@ -340,19 +317,24 @@ _eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, { #if 0 /* THIS IS JUST EXAMPLE CODE */ _EGLSurface *surf; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + if (!conf) { + _eglError(EGL_BAD_CONFIG, "eglCreateWindowSurface"); + return EGL_NO_SURFACE; + } surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); if (!surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, surf, EGL_WINDOW_BIT, config, attrib_list)) { + if (!_eglInitSurface(drv, surf, EGL_WINDOW_BIT, conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } - _eglSaveSurface(surf); - - return surf->Handle; + return _eglLinkSurface(surf, _eglLookupDisplay(dpy)); #endif return EGL_NO_SURFACE; } @@ -367,19 +349,24 @@ _eglCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, { #if 0 /* THIS IS JUST EXAMPLE CODE */ _EGLSurface *surf; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + if (!conf) { + _eglError(EGL_BAD_CONFIG, "eglCreatePixmapSurface"); + return EGL_NO_SURFACE; + } surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); if (!surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, surf, EGL_PIXMAP_BIT, config, attrib_list)) { + if (!_eglInitSurface(drv, surf, EGL_PIXMAP_BIT, conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } - _eglSaveSurface(surf); - - return surf->Handle; + return _eglLinkSurface(surf, _eglLookupDisplay(dpy)); #endif return EGL_NO_SURFACE; } @@ -394,19 +381,24 @@ _eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, { #if 0 /* THIS IS JUST EXAMPLE CODE */ _EGLSurface *surf; + _EGLConfig *conf; + + conf = _eglLookupConfig(drv, dpy, config); + if (!conf) { + _eglError(EGL_BAD_CONFIG, "eglCreatePbufferSurface"); + return EGL_NO_SURFACE; + } surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); if (!surf) return EGL_NO_SURFACE; - if (!_eglInitSurface(drv, dpy, surf, EGL_PBUFFER_BIT, config, attrib_list)) { + if (!_eglInitSurface(drv, surf, EGL_PBUFFER_BIT, conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } - _eglSaveSurface(surf); - - return surf->Handle; + return _eglLinkSurface(surf, _eglLookupDisplay(dpy)); #endif return EGL_NO_SURFACE; } @@ -420,7 +412,7 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { _EGLSurface *surf = _eglLookupSurface(surface); if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(surf); if (surf->IsBound) { surf->DeletePending = EGL_TRUE; } diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index dc53669091..f6874e6278 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -43,17 +43,8 @@ struct _egl_surface extern EGLBoolean -_eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, - _EGLSurface *surf, EGLint type, EGLConfig config, - const EGLint *attrib_list); - - -extern void -_eglSaveSurface(_EGLSurface *surf); - - -extern void -_eglRemoveSurface(_EGLSurface *surf); +_eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type, + _EGLConfig *config, const EGLint *attrib_list); extern EGLBoolean diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c index edd49486e5..95dfcb9983 100644 --- a/src/gallium/state_trackers/egl/egl_context.c +++ b/src/gallium/state_trackers/egl/egl_context.c @@ -113,7 +113,7 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!ctx) goto err_c; - _eglInitContext(drv, dpy, &ctx->base, config, attrib_list); + _eglInitContext(drv, dpy, &ctx->base, conf, attrib_list); ctx->pipe = dev->api->create_context(dev->api, dev->screen); if (!ctx->pipe) @@ -129,8 +129,8 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!ctx->st) goto err_gl; - /* generate handle and insert into hash table */ - _eglSaveContext(&ctx->base); + /* link to display */ + _eglLinkContext(&ctx->base, _eglLookupDisplay(dpy)); assert(_eglGetContextHandle(&ctx->base)); return _eglGetContextHandle(&ctx->base); @@ -147,7 +147,7 @@ EGLBoolean drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { struct drm_context *c = lookup_drm_context(context); - _eglRemoveContext(&c->base); + _eglUnlinkContext(&c->base); if (c->base.IsBound) { c->base.DeletePending = EGL_TRUE; } else { diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index de8194a46a..27b35052d1 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -232,7 +232,7 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (!surf) goto err; - if (!_eglInitSurface(drv, dpy, &surf->base, EGL_PBUFFER_BIT, config, attrib_list)) + if (!_eglInitSurface(drv, &surf->base, EGL_PBUFFER_BIT, conf, attrib_list)) goto err_surf; surf->w = width; @@ -245,7 +245,7 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, (void*)surf); drm_visual_modes_destroy(visual); - _eglSaveSurface(&surf->base); + _eglLinkSurface(&surf->base, _eglLookupDisplay(dpy)); return surf->base.Handle; err_surf: @@ -364,7 +364,8 @@ EGLBoolean drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { struct drm_surface *surf = lookup_drm_surface(surface); - _eglRemoveSurface(&surf->base); + _eglUnlinkSurface(&surf->base); + if (surf->base.IsBound) { surf->base.DeletePending = EGL_TRUE; } else { diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index c10e3c00ff..9914dff964 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -345,7 +345,7 @@ xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_NO_CONTEXT; /* let EGL lib init the common stuff */ - if (!_eglInitContext(drv, dpy, &ctx->Base, config, attrib_list)) { + if (!_eglInitContext(drv, &ctx->Base, conf, attrib_list)) { free(ctx); return EGL_NO_CONTEXT; } @@ -370,7 +370,7 @@ xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_NO_CONTEXT; } - _eglSaveContext(&ctx->Base); + _eglLinkContext(&ctx->Base, _eglLookupDisplay(dpy)); return _eglGetContextHandle(&ctx->Base); } @@ -381,6 +381,7 @@ xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) { struct xlib_egl_context *context = lookup_context(ctx); if (context) { + _eglUnlinkContext(&context->Base); if (context->Base.IsBound) { context->Base.DeletePending = EGL_TRUE; } @@ -491,13 +492,13 @@ xlib_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, return EGL_NO_SURFACE; /* Let EGL lib init the common stuff */ - if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_WINDOW_BIT, - config, attrib_list)) { + if (!_eglInitSurface(drv, &surf->Base, EGL_WINDOW_BIT, + conf, attrib_list)) { free(surf); return EGL_NO_SURFACE; } - _eglSaveSurface(&surf->Base); + _eglLinkSurface(&surf->Base, disp); /* * Now init the Xlib and gallium stuff @@ -534,7 +535,7 @@ xlib_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { struct xlib_egl_surface *surf = lookup_surface(surface); if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + _eglUnlinkSurface(&surf->Base); if (surf->Base.IsBound) { surf->Base.DeletePending = EGL_TRUE; } diff --git a/src/mesa/drivers/dri/fb/fb_egl.c b/src/mesa/drivers/dri/fb/fb_egl.c index 35c268441c..c367741f52 100644 --- a/src/mesa/drivers/dri/fb/fb_egl.c +++ b/src/mesa/drivers/dri/fb/fb_egl.c @@ -472,8 +472,8 @@ fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext sh c->Base.DrawSurface = EGL_NO_SURFACE; c->Base.ReadSurface = EGL_NO_SURFACE; - /* generate handle and insert into hash table */ - _eglSaveContext(&c->Base); + /* link to display */ + _eglLinkContext(&c->Base, disp); assert(c->Base.Handle); /* Init default driver functions then plug in our FBdev-specific functions @@ -604,7 +604,7 @@ static EGLBoolean fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { fbSurface *fs = Lookup_fbSurface(surface); - _eglRemoveSurface(&fs->Base); + _eglUnlinkSurface(&fs->Base); if (fs->Base.IsBound) { fs->Base.DeletePending = EGL_TRUE; } @@ -619,7 +619,7 @@ static EGLBoolean fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { fbContext *fc = Lookup_fbContext(context); - _eglRemoveContext(&fc->Base); + _eglUnlinkContext(&fc->Base); if (fc->Base.IsBound) { fc->Base.DeletePending = EGL_TRUE; } @@ -688,7 +688,7 @@ fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, surface->mesa_framebuffer = _mesa_create_framebuffer(&vis); if (!surface->mesa_framebuffer) { free(surface); - _eglRemoveSurface(&surface->Base); + _eglUnlinkSurface(&surface->Base); return EGL_NO_SURFACE; } -- cgit v1.2.3 From 15fdbc8361d0b865aea5e2f374b471081ed4214a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 17 Jul 2009 11:56:00 -0600 Subject: egl: Remove redundant DeletePending flag. A context or surface that is neither linked to a display nor current to a thread should be destroyed. Therefore, an unlinked context or surface implies a pending delete automatically. Signed-off-by: Chia-I Wu --- src/egl/drivers/demo/demo.c | 12 ++---------- src/egl/drivers/dri/egldri.c | 12 ++---------- src/egl/drivers/glx/egl_glx.c | 6 +----- src/egl/drivers/xdri/egl_xdri.c | 5 +---- src/egl/main/eglcontext.c | 14 +++++--------- src/egl/main/eglcontext.h | 1 - src/egl/main/egldisplay.h | 29 ++++++++++++++++++++++++++++ src/egl/main/eglsurface.c | 6 +----- src/egl/main/eglsurface.h | 1 - src/gallium/state_trackers/egl/egl_context.c | 4 +--- src/gallium/state_trackers/egl/egl_surface.c | 4 +--- src/gallium/winsys/egl_xlib/egl_xlib.c | 10 ++-------- src/mesa/drivers/dri/fb/fb_egl.c | 12 ++---------- 13 files changed, 47 insertions(+), 69 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index fa9efa5d35..f316974d83 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -236,12 +236,8 @@ demoDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { DemoSurface *fs = LookupDemoSurface(surface); _eglUnlinkSurface(&fs->Base); - if (fs->Base.IsBound) { - fs->Base.DeletePending = EGL_TRUE; - } - else { + if (!fs->Base.IsBound) free(fs); - } return EGL_TRUE; } @@ -251,12 +247,8 @@ demoDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { DemoContext *fc = LookupDemoContext(context); _eglUnlinkContext(&fc->Base); - if (fc->Base.IsBound) { - fc->Base.DeletePending = EGL_TRUE; - } - else { + if (!fc->Base.IsBound) free(fc); - } return EGL_TRUE; } diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index df45fbfbe2..3f9617a8f9 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -296,12 +296,8 @@ _eglDRIDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) fs->drawable.destroyDrawable(disp, fs->drawable.private); - if (fs->Base.IsBound) { - fs->Base.DeletePending = EGL_TRUE; - } - else { + if (!fs->Base.IsBound) free(fs); - } return EGL_TRUE; } @@ -316,12 +312,8 @@ _eglDRIDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) fc->driContext.destroyContext(disp, 0, fc->driContext.private); - if (fc->Base.IsBound) { - fc->Base.DeletePending = EGL_TRUE; - } - else { + if (!fc->Base.IsBound) free(fc); - } return EGL_TRUE; } diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 661b313ae2..207b1ea779 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -739,12 +739,8 @@ GLX_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) return EGL_TRUE; if (surf) { _eglUnlinkSurface(surf); - if (surf->IsBound) { - surf->DeletePending = EGL_TRUE; - } - else { + if (!surf->IsBound) free(surf); - } return EGL_TRUE; } diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 34d69def6a..e040efdd43 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -958,10 +958,7 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) struct xdri_egl_surface *xdri_surf = lookup_surface(surface); if (xdri_surf) { _eglUnlinkSurface(&xdri_surf->Base); - if (xdri_surf->Base.IsBound) { - xdri_surf->Base.DeletePending = EGL_TRUE; - } - else { + if (!xdri_surf->Base.IsBound) { /* st_unreference_framebuffer(surf->Framebuffer); */ diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 01cb116d00..9ab4286d3a 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -96,12 +96,8 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) _EGLContext *context = _eglLookupContext(ctx); if (context) { _eglUnlinkContext(context); - if (context->IsBound) { - context->DeletePending = EGL_TRUE; - } - else { + if (!context->IsBound) free(context); - } return EGL_TRUE; } else { @@ -146,7 +142,7 @@ _eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx, /** * Drivers will typically call this to do the error checking and - * update the various IsBound and DeletePending flags. + * update the various flags. * Then, the driver will do its device-dependent Make-Current stuff. */ EGLBoolean @@ -212,7 +208,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, */ if (oldDrawSurface != NULL) { oldDrawSurface->IsBound = EGL_FALSE; - if (oldDrawSurface->DeletePending) { + if (!_eglIsSurfaceLinked(oldDrawSurface)) { /* make sure we don't try to rebind a deleted surface */ if (draw == oldDrawSurface || draw == oldReadSurface) { draw = NULL; @@ -223,7 +219,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, } if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) { oldReadSurface->IsBound = EGL_FALSE; - if (oldReadSurface->DeletePending) { + if (!_eglIsSurfaceLinked(oldReadSurface)) { /* make sure we don't try to rebind a deleted surface */ if (read == oldDrawSurface || read == oldReadSurface) { read = NULL; @@ -234,7 +230,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, } if (oldContext != NULL) { oldContext->IsBound = EGL_FALSE; - if (oldContext->DeletePending) { + if (!_eglIsContextLinked(oldContext)) { /* make sure we don't try to rebind a deleted context */ if (ctx == oldContext) { ctx = NULL; diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 8e20643177..2fb28d38b9 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -21,7 +21,6 @@ struct _egl_context _EGLSurface *ReadSurface; EGLBoolean IsBound; - EGLBoolean DeletePending; EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */ EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 30b466cb4a..372ed3cd79 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -52,6 +52,16 @@ extern _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy); +/** + * Return true if the display is linked. + */ +static INLINE EGLBoolean +_eglIsDisplayLinked(_EGLDisplay *dpy) +{ + return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY); +} + + extern _EGLDisplay * _eglFindDisplay(NativeDisplayType nativeDisplay); @@ -80,6 +90,15 @@ extern _EGLContext * _eglLookupContext(EGLContext ctx); +/** + * Return true if the context is linked to a display. + */ +static INLINE EGLBoolean +_eglIsContextLinked(_EGLContext *ctx) +{ + return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT); +} + extern EGLSurface _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy); @@ -96,4 +115,14 @@ extern _EGLSurface * _eglLookupSurface(EGLSurface surf); +/** + * Return true if the surface is linked to a display. + */ +static INLINE EGLBoolean +_eglIsSurfaceLinked(_EGLSurface *surf) +{ + return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE); +} + + #endif /* EGLDISPLAY_INCLUDED */ diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index b122124585..9821e63628 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -413,12 +413,8 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) _EGLSurface *surf = _eglLookupSurface(surface); if (surf) { _eglUnlinkSurface(surf); - if (surf->IsBound) { - surf->DeletePending = EGL_TRUE; - } - else { + if (!surf->IsBound) free(surf); - } return EGL_TRUE; } else { diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index f6874e6278..f9413eb9d7 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -19,7 +19,6 @@ struct _egl_surface /* May need reference counting here */ EGLBoolean IsBound; - EGLBoolean DeletePending; EGLBoolean BoundToTexture; EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c index 95dfcb9983..f03a29582a 100644 --- a/src/gallium/state_trackers/egl/egl_context.c +++ b/src/gallium/state_trackers/egl/egl_context.c @@ -148,9 +148,7 @@ drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { struct drm_context *c = lookup_drm_context(context); _eglUnlinkContext(&c->base); - if (c->base.IsBound) { - c->base.DeletePending = EGL_TRUE; - } else { + if (!c->base.IsBound) { st_destroy_context(c->st); c->pipe->destroy(c->pipe); free(c); diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index 27b35052d1..86f2ea97e5 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -366,9 +366,7 @@ drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) struct drm_surface *surf = lookup_drm_surface(surface); _eglUnlinkSurface(&surf->base); - if (surf->base.IsBound) { - surf->base.DeletePending = EGL_TRUE; - } else { + if (!surf->base.IsBound) { if (surf->screen) drm_takedown_shown_screen(drv, surf->screen); st_unreference_framebuffer(surf->stfb); diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index 9914dff964..e1ddcae97b 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -382,10 +382,7 @@ xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) struct xlib_egl_context *context = lookup_context(ctx); if (context) { _eglUnlinkContext(&context->Base); - if (context->Base.IsBound) { - context->Base.DeletePending = EGL_TRUE; - } - else { + if (!context->Base.IsBound) { /* API-dependent clean-up */ switch (context->Base.ClientAPI) { case EGL_OPENGL_ES_API: @@ -536,10 +533,7 @@ xlib_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) struct xlib_egl_surface *surf = lookup_surface(surface); if (surf) { _eglUnlinkSurface(&surf->Base); - if (surf->Base.IsBound) { - surf->Base.DeletePending = EGL_TRUE; - } - else { + if (!surf->Base.IsBound) { XFreeGC(surf->Dpy, surf->Gc); st_unreference_framebuffer(surf->Framebuffer); free(surf); diff --git a/src/mesa/drivers/dri/fb/fb_egl.c b/src/mesa/drivers/dri/fb/fb_egl.c index c367741f52..dee67feb5a 100644 --- a/src/mesa/drivers/dri/fb/fb_egl.c +++ b/src/mesa/drivers/dri/fb/fb_egl.c @@ -605,12 +605,8 @@ fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { fbSurface *fs = Lookup_fbSurface(surface); _eglUnlinkSurface(&fs->Base); - if (fs->Base.IsBound) { - fs->Base.DeletePending = EGL_TRUE; - } - else { + if (!fs->Base.IsBound) free(fs); - } return EGL_TRUE; } @@ -620,12 +616,8 @@ fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) { fbContext *fc = Lookup_fbContext(context); _eglUnlinkContext(&fc->Base); - if (fc->Base.IsBound) { - fc->Base.DeletePending = EGL_TRUE; - } - else { + if (!fc->Base.IsBound) free(fc); - } return EGL_TRUE; } -- cgit v1.2.3