@@ -8,44 +8,49 @@ extern "C" {
88#include " webroguegfx_internal.h"
99}
1010
11- // clang-format off
12-
1311#include " gl2_entry.cpp"
1412#include " gl2_ftable.h"
1513
16- static thread_local PFNGLFLUSHPROC sGLFlushThreadLocal ;
14+ __attribute__ ((import_name(" gl_init" )))
15+ __attribute__((import_module(" webrogue_gfx" ))) void
16+ imported_webrogue_gfx_init_gl(uint8_t *out_status);
1717
18- void webrogue_gfx_internal_glFlush (void ) {
19- if (sGLFlushThreadLocal ) {
20- sGLFlushThreadLocal ();
21- }
22- }
18+ static thread_local PFNGLFLUSHPROC sGLFlush = nullptr ;
2319
24- extern " C" void * webroguegfx_gl_loader (const char * procname) {
25- if (!getEGLThreadInfo ()->hostConn ) {
26- // imported_init_gl();
20+ extern " C" void webroguegfx_init_gl () {
21+ if (!getEGLThreadInfo ()->hostConn ) {
22+ uint8_t status = 0 ;
23+ imported_webrogue_gfx_init_gl (&status);
24+ if (!status) {
25+ return ;
26+ }
2727 getEGLThreadInfo ()->hostConn = HostConnection::createUnique ();
2828 getEGLThreadInfo ()->hostConn ->gl2Encoder ()->setClientState (
29- new gfxstream::guest::GLClientState (2 , 0 )
30- );
31- // TODO GLSharedGroup should be stored in getEGLThreadInfo()->currentContext->sharedGroup
29+ new gfxstream::guest::GLClientState (3 , 0 ));
30+ // TODO GLSharedGroup should be stored in
31+ // getEGLThreadInfo()->currentContext->sharedGroup
3232 getEGLThreadInfo ()->hostConn ->gl2Encoder ()->setSharedGroup (
33- gfxstream::guest::GLSharedGroupPtr (
34- new gfxstream::guest::GLSharedGroup ()
35- )
36- );
37- getEGLThreadInfo ()->hostConn ->gl2Encoder ()->setVersion (
38- 3 , 0 ,
39- 3 , 0
40- );
41- for (int i = 0 ; i<gl2_num_funcs; i++) {
42- if (strcmp (gl2_funcs_by_name[i].name , " glFlush" ) == 0 ) {
43- sGLFlushThreadLocal = (PFNGLFLUSHPROC) gl2_funcs_by_name[i].proc ;
33+ gfxstream::guest::GLSharedGroupPtr (
34+ new gfxstream::guest::GLSharedGroup ()));
35+ getEGLThreadInfo ()->hostConn ->gl2Encoder ()->setVersion (3 , 0 , 3 , 0 );
36+ for (int i = 0 ; i < gl2_num_funcs; i++) {
37+ if (strcmp (gl2_funcs_by_name[i].name , " glFlush" ) == 0 ) {
38+ sGLFlush = (PFNGLFLUSHPROC)gl2_funcs_by_name[i].proc ;
4439 }
4540 }
4641 }
47- for (int i = 0 ; i<gl2_num_funcs; i++) {
48- if (strcmp (gl2_funcs_by_name[i].name , procname) == 0 ) {
42+ }
43+
44+ extern " C" void webrogue_gfx_internal_glFlush (void ) {
45+ if (sGLFlush ) {
46+ sGLFlush ();
47+ }
48+ }
49+
50+ extern " C" void *webroguegfx_gl_loader (const char *procname) {
51+ webroguegfx_init_gl ();
52+ for (int i = 0 ; i < gl2_num_funcs; i++) {
53+ if (strcmp (gl2_funcs_by_name[i].name , procname) == 0 ) {
4954 return gl2_funcs_by_name[i].proc ;
5055 }
5156 }
0 commit comments