cannot create opengl by dynamically loading wayland symbols from library

Pekka Paalanen ppaalanen at gmail.com
Wed Apr 16 11:27:29 PDT 2014


Hi,

I'm moving this conversation to where it belongs.

On Wed, 16 Apr 2014 11:25:26 +0000
bugzilla-daemon at freedesktop.org wrote:

> https://bugs.freedesktop.org/show_bug.cgi?id=77521
> 
>           Priority: medium
>             Bug ID: 77521
>           Assignee: wayland-bugs at lists.freedesktop.org
>            Summary: cannot create opengl by dynamically loading wayland
>                     symbols from library
>           Severity: blocker
>     Classification: Unclassified
>                 OS: All
>           Reporter: pulkitnandan at gmail.com
>           Hardware: All
>             Status: NEW
>            Version: 1.3.0
>          Component: wayland
>            Product: Wayland
> 
> I was trying to implement a window system agnostic library which will be used
> in creating opengl apps with different windows systems. Lets name that library
> as WSAL.Now to achieve this WSAL implements window system interfaces which is
> used in creating native windows etc of specific window system while egl calls
> are in main WSAL library.Consider wayland and X as examples of such two
> libraries. As I separate several implementations of wayland and and X from
> different team members.So to test them efficiently I have to create several
> function pointers and object pointers that are present in those library
> implementations and load them with symbols from libraries using dlsym utility
> so that at compile time I donot have to link with any library.
> 
> For X I was successfully in creating X backend.
> For wayland I first got stuck at functions which are inline in
> wayland_client_protocol.h. For them I cannot do the same.Instead I created a
> function pointer which these functions actually calls in inline definition.
> 
> Like when wl_display_get_registry is called wl_proxy_marshal_constructor is
> ultimately called.
> 
> The terrible fucntions are wl_proxy_marshal_constructor and wl_proxy_marshal as
> they are defined with variable arguments.So I declared
> new_wl_proxy_marshal_constructor a function pointer of same type as
> wl_proxy_marshal_constructor and loaded the symbol from library using dlsym
> into new_wl_proxy_marshal_constructor.
> 
> But faced a fundamental problem of determing argument types as these terrible
> functions (TFs) don't have constant argument signature i.e it may sometime pass
> a int as its 4th aguments in one inline expansion while a char * in some other
> inline function.

Why do you need to know the arguments?
Why cannot you just use it as is, with variable arguments?

Btw. if the generated inline wrapper functions do not suit you, I
think you could generate your own from the XML files, that end up
calling the real functions exported from libwayland-client. That is
how bindings to other programming languages are supposed work to my
understanding.

> So I explored this wl_proxy_marshal_constructor which actually calls
> wl_proxy_marshal_array_constructor after forming a variable arguments to a
> single argument using some wl_proxy object signature which I have no access to
> in main wayland interface.
> 
> dlsym option of using rtld_now doesnot work.
> 
> How to implement such functionality in wayland or provide a way to create a app
> with no linking at build time.

Have you looked at SDL2?
http://hg.libsdl.org/SDL/file/tip/src/video/wayland

To me it seems like it uses dlopen and dlsym equivalents to load
Wayland libraries. I don't know if it is complete or in use yet,
there seems to be also a non-dlopen path.


Thanks,
pq


More information about the wayland-devel mailing list