egl: replace _eglInitDriver() with a simple variable
Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6037>
This commit is contained in:

committed by
Marge Bot

parent
3d4deb659e
commit
d24e3ea8cb
@@ -3674,62 +3674,56 @@ dri2_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx,
|
|||||||
return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out);
|
return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
_EGLDriver _eglDriver = {
|
||||||
* This is the main entrypoint into the driver, called by libEGL.
|
.Initialize = dri2_initialize,
|
||||||
* Gets an _EGLDriver object and init its dispatch table.
|
.Terminate = dri2_terminate,
|
||||||
*/
|
.CreateContext = dri2_create_context,
|
||||||
void
|
.DestroyContext = dri2_destroy_context,
|
||||||
_eglInitDriver(_EGLDriver *dri2_drv)
|
.MakeCurrent = dri2_make_current,
|
||||||
{
|
.CreateWindowSurface = dri2_create_window_surface,
|
||||||
dri2_drv->Initialize = dri2_initialize;
|
.CreatePixmapSurface = dri2_create_pixmap_surface,
|
||||||
dri2_drv->Terminate = dri2_terminate;
|
.CreatePbufferSurface = dri2_create_pbuffer_surface,
|
||||||
dri2_drv->CreateContext = dri2_create_context;
|
.DestroySurface = dri2_destroy_surface,
|
||||||
dri2_drv->DestroyContext = dri2_destroy_context;
|
.GetProcAddress = dri2_get_proc_address,
|
||||||
dri2_drv->MakeCurrent = dri2_make_current;
|
.WaitClient = dri2_wait_client,
|
||||||
dri2_drv->CreateWindowSurface = dri2_create_window_surface;
|
.WaitNative = dri2_wait_native,
|
||||||
dri2_drv->CreatePixmapSurface = dri2_create_pixmap_surface;
|
.BindTexImage = dri2_bind_tex_image,
|
||||||
dri2_drv->CreatePbufferSurface = dri2_create_pbuffer_surface;
|
.ReleaseTexImage = dri2_release_tex_image,
|
||||||
dri2_drv->DestroySurface = dri2_destroy_surface;
|
.SwapInterval = dri2_swap_interval,
|
||||||
dri2_drv->GetProcAddress = dri2_get_proc_address;
|
.SwapBuffers = dri2_swap_buffers,
|
||||||
dri2_drv->WaitClient = dri2_wait_client;
|
.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage,
|
||||||
dri2_drv->WaitNative = dri2_wait_native;
|
.SwapBuffersRegionNOK = dri2_swap_buffers_region,
|
||||||
dri2_drv->BindTexImage = dri2_bind_tex_image;
|
.SetDamageRegion = dri2_set_damage_region,
|
||||||
dri2_drv->ReleaseTexImage = dri2_release_tex_image;
|
.PostSubBufferNV = dri2_post_sub_buffer,
|
||||||
dri2_drv->SwapInterval = dri2_swap_interval;
|
.CopyBuffers = dri2_copy_buffers,
|
||||||
dri2_drv->SwapBuffers = dri2_swap_buffers;
|
.QueryBufferAge = dri2_query_buffer_age,
|
||||||
dri2_drv->SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
|
.CreateImageKHR = dri2_create_image,
|
||||||
dri2_drv->SwapBuffersRegionNOK = dri2_swap_buffers_region;
|
.DestroyImageKHR = dri2_destroy_image_khr,
|
||||||
dri2_drv->SetDamageRegion = dri2_set_damage_region;
|
.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image,
|
||||||
dri2_drv->PostSubBufferNV = dri2_post_sub_buffer;
|
.QuerySurface = dri2_query_surface,
|
||||||
dri2_drv->CopyBuffers = dri2_copy_buffers,
|
.QueryDriverName = dri2_query_driver_name,
|
||||||
dri2_drv->QueryBufferAge = dri2_query_buffer_age;
|
.QueryDriverConfig = dri2_query_driver_config,
|
||||||
dri2_drv->CreateImageKHR = dri2_create_image;
|
|
||||||
dri2_drv->DestroyImageKHR = dri2_destroy_image_khr;
|
|
||||||
dri2_drv->CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
|
|
||||||
dri2_drv->QuerySurface = dri2_query_surface;
|
|
||||||
dri2_drv->QueryDriverName = dri2_query_driver_name;
|
|
||||||
dri2_drv->QueryDriverConfig = dri2_query_driver_config;
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LIBDRM
|
||||||
dri2_drv->CreateDRMImageMESA = dri2_create_drm_image_mesa;
|
.CreateDRMImageMESA = dri2_create_drm_image_mesa,
|
||||||
dri2_drv->ExportDRMImageMESA = dri2_export_drm_image_mesa;
|
.ExportDRMImageMESA = dri2_export_drm_image_mesa,
|
||||||
dri2_drv->ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa;
|
.ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa,
|
||||||
dri2_drv->ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa;
|
.ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa,
|
||||||
dri2_drv->QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
|
.QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats,
|
||||||
dri2_drv->QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers;
|
.QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_WAYLAND_PLATFORM
|
#ifdef HAVE_WAYLAND_PLATFORM
|
||||||
dri2_drv->BindWaylandDisplayWL = dri2_bind_wayland_display_wl;
|
.BindWaylandDisplayWL = dri2_bind_wayland_display_wl,
|
||||||
dri2_drv->UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl;
|
.UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl,
|
||||||
dri2_drv->QueryWaylandBufferWL = dri2_query_wayland_buffer_wl;
|
.QueryWaylandBufferWL = dri2_query_wayland_buffer_wl,
|
||||||
#endif
|
#endif
|
||||||
dri2_drv->GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium;
|
.GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium,
|
||||||
dri2_drv->CreateSyncKHR = dri2_create_sync;
|
.CreateSyncKHR = dri2_create_sync,
|
||||||
dri2_drv->ClientWaitSyncKHR = dri2_client_wait_sync;
|
.ClientWaitSyncKHR = dri2_client_wait_sync,
|
||||||
dri2_drv->SignalSyncKHR = dri2_signal_sync;
|
.SignalSyncKHR = dri2_signal_sync,
|
||||||
dri2_drv->WaitSyncKHR = dri2_server_wait_sync;
|
.WaitSyncKHR = dri2_server_wait_sync,
|
||||||
dri2_drv->DestroySyncKHR = dri2_destroy_sync;
|
.DestroySyncKHR = dri2_destroy_sync,
|
||||||
dri2_drv->GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
|
.GLInteropQueryDeviceInfo = dri2_interop_query_device_info,
|
||||||
dri2_drv->GLInteropExportObject = dri2_interop_export_object;
|
.GLInteropExportObject = dri2_interop_export_object,
|
||||||
dri2_drv->DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
|
.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd,
|
||||||
dri2_drv->SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
|
.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs,
|
||||||
}
|
};
|
||||||
|
@@ -311,27 +311,16 @@ haiku_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the main entrypoint into the driver, called by libEGL.
|
|
||||||
* Gets an _EGLDriver object and init its dispatch table.
|
|
||||||
*/
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void
|
_EGLDriver _eglDriver = {
|
||||||
_eglInitDriver(_EGLDriver *driver)
|
.Initialize = init_haiku,
|
||||||
{
|
.Terminate = haiku_terminate,
|
||||||
CALLED();
|
.CreateContext = haiku_create_context,
|
||||||
|
.DestroyContext = haiku_destroy_context,
|
||||||
driver->Initialize = init_haiku;
|
.MakeCurrent = haiku_make_current,
|
||||||
driver->Terminate = haiku_terminate;
|
.CreateWindowSurface = haiku_create_window_surface,
|
||||||
driver->CreateContext = haiku_create_context;
|
.CreatePixmapSurface = haiku_create_pixmap_surface,
|
||||||
driver->DestroyContext = haiku_destroy_context;
|
.CreatePbufferSurface = haiku_create_pbuffer_surface,
|
||||||
driver->MakeCurrent = haiku_make_current;
|
.DestroySurface = haiku_destroy_surface,
|
||||||
driver->CreateWindowSurface = haiku_create_window_surface;
|
.SwapBuffers = haiku_swap_buffers,
|
||||||
driver->CreatePixmapSurface = haiku_create_pixmap_surface;
|
};
|
||||||
driver->CreatePbufferSurface = haiku_create_pbuffer_surface;
|
|
||||||
driver->DestroySurface = haiku_destroy_surface;
|
|
||||||
|
|
||||||
driver->SwapBuffers = haiku_swap_buffers;
|
|
||||||
|
|
||||||
TRACE("API Calls defined\n");
|
|
||||||
}
|
|
||||||
|
@@ -46,34 +46,20 @@
|
|||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
|
|
||||||
static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP;
|
extern _EGLDriver _eglDriver;
|
||||||
static _EGLDriver *_eglDriver;
|
|
||||||
|
|
||||||
static _EGLDriver *
|
static _EGLDriver *
|
||||||
_eglGetDriver(void)
|
_eglGetDriver(void)
|
||||||
{
|
{
|
||||||
mtx_lock(&_eglModuleMutex);
|
return &_eglDriver;
|
||||||
|
|
||||||
if (!_eglDriver) {
|
|
||||||
_eglDriver = calloc(1, sizeof(*_eglDriver));
|
|
||||||
if (!_eglDriver) {
|
|
||||||
mtx_unlock(&_eglModuleMutex);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
_eglInitDriver(_eglDriver);
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_unlock(&_eglModuleMutex);
|
|
||||||
|
|
||||||
return _eglDriver;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static _EGLDriver *
|
static _EGLDriver *
|
||||||
_eglMatchAndInitialize(_EGLDisplay *disp)
|
_eglMatchAndInitialize(_EGLDisplay *disp)
|
||||||
{
|
{
|
||||||
if (_eglGetDriver())
|
if (_eglGetDriver())
|
||||||
if (_eglDriver->Initialize(_eglDriver, disp))
|
if (_eglDriver.Initialize(&_eglDriver, disp))
|
||||||
return _eglDriver;
|
return &_eglDriver;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -112,19 +98,8 @@ _eglMatchDriver(_EGLDisplay *disp)
|
|||||||
__eglMustCastToProperFunctionPointerType
|
__eglMustCastToProperFunctionPointerType
|
||||||
_eglGetDriverProc(const char *procname)
|
_eglGetDriverProc(const char *procname)
|
||||||
{
|
{
|
||||||
if (_eglGetDriver() && _eglDriver->GetProcAddress)
|
if (_eglGetDriver() && _eglDriver.GetProcAddress)
|
||||||
return _eglDriver->GetProcAddress(_eglDriver, procname);
|
return _eglDriver.GetProcAddress(&_eglDriver, procname);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unload all drivers.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
_eglUnloadDrivers(void)
|
|
||||||
{
|
|
||||||
/* this is called at atexit time */
|
|
||||||
free(_eglDriver);
|
|
||||||
_eglDriver = NULL;
|
|
||||||
}
|
|
||||||
|
@@ -223,10 +223,6 @@ struct _egl_driver
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern void
|
|
||||||
_eglInitDriver(_EGLDriver *driver);
|
|
||||||
|
|
||||||
|
|
||||||
extern _EGLDriver *
|
extern _EGLDriver *
|
||||||
_eglMatchDriver(_EGLDisplay *disp);
|
_eglMatchDriver(_EGLDisplay *disp);
|
||||||
|
|
||||||
@@ -235,10 +231,6 @@ extern __eglMustCastToProperFunctionPointerType
|
|||||||
_eglGetDriverProc(const char *procname);
|
_eglGetDriverProc(const char *procname);
|
||||||
|
|
||||||
|
|
||||||
extern void
|
|
||||||
_eglUnloadDrivers(void);
|
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *),
|
_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *),
|
||||||
void *callback_data);
|
void *callback_data);
|
||||||
|
@@ -54,11 +54,10 @@ struct _egl_global _eglGlobal =
|
|||||||
.Mutex = &_eglGlobalMutex,
|
.Mutex = &_eglGlobalMutex,
|
||||||
.DisplayList = NULL,
|
.DisplayList = NULL,
|
||||||
.DeviceList = &_eglSoftwareDevice,
|
.DeviceList = &_eglSoftwareDevice,
|
||||||
.NumAtExitCalls = 3,
|
.NumAtExitCalls = 2,
|
||||||
.AtExitCalls = {
|
.AtExitCalls = {
|
||||||
/* default AtExitCalls, called in reverse order */
|
/* default AtExitCalls, called in reverse order */
|
||||||
_eglFiniDevice, /* always called last */
|
_eglFiniDevice, /* always called last */
|
||||||
_eglUnloadDrivers,
|
|
||||||
_eglFiniDisplay,
|
_eglFiniDisplay,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user