2 * Mesa 3-D graphics library
5 * Copyright (C) 2010-2011 LunarG Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Chia-I Wu <olv@lunarg.com>
29 #include "common/egl_g3d_loader.h"
30 #include "egldriver.h"
35 static struct egl_g3d_loader egl_g3d_loader
;
37 static struct st_module
{
40 } st_modules
[ST_API_COUNT
];
42 static struct st_api
*
43 get_st_api(enum st_api_type api
)
45 struct st_module
*stmod
= &st_modules
[api
];
47 if (!stmod
->initialized
) {
48 stmod
->stapi
= egl_st_create_api(api
);
49 stmod
->initialized
= TRUE
;
55 static struct st_api
*
56 guess_gl_api(enum st_profile_type profile
)
58 return get_st_api(ST_API_OPENGL
);
61 static struct pipe_screen
*
62 create_drm_screen(const char *name
, int fd
)
64 return egl_pipe_create_drm_screen(name
, fd
);
67 static struct pipe_screen
*
68 create_sw_screen(struct sw_winsys
*ws
)
70 return egl_pipe_create_swrast_screen(ws
);
73 static const struct egl_g3d_loader
*
78 for (i
= 0; i
< ST_API_COUNT
; i
++)
79 egl_g3d_loader
.profile_masks
[i
] = egl_st_get_profile_mask(i
);
81 egl_g3d_loader
.get_st_api
= get_st_api
;
82 egl_g3d_loader
.guess_gl_api
= guess_gl_api
;
83 egl_g3d_loader
.create_drm_screen
= create_drm_screen
;
84 egl_g3d_loader
.create_sw_screen
= create_sw_screen
;
86 return &egl_g3d_loader
;
94 for (i
= 0; i
< ST_API_COUNT
; i
++) {
95 struct st_module
*stmod
= &st_modules
[i
];
98 stmod
->stapi
->destroy(stmod
->stapi
);
101 stmod
->initialized
= FALSE
;
106 egl_g3d_unload(_EGLDriver
*drv
)
108 egl_g3d_destroy_driver(drv
);
113 _EGL_MAIN(const char *args
)
115 const struct egl_g3d_loader
*loader
;
118 loader
= loader_init();
119 drv
= egl_g3d_create_driver(loader
);
125 drv
->Name
= "Gallium";
126 drv
->Unload
= egl_g3d_unload
;