Re: Wayland: EGL_ALPHA_SIZE in egl_attributes_from_framebuffer_config()



On Wed, Dec 4, 2013 at 4:17 PM, Tomeu Vizoso <tomeu tomeuvizoso net> wrote:
On 4 December 2013 10:37, Richard G. Roman <rits rits hu> wrote:
>
> - is it possible that the Raspberry Pi code has a bug? In this case, shall
> we simply add a workaround?

It could very well be a bug in this EGL implementation, unfortunately.
Though I remember trying out some clutter and cogl examples during
development and don't remember the colors being off.

See here for how the EGL side negotiates the framebuffer config:

https://github.com/tomeuv/userland/blob/wayland/interface/khronos/egl/egl_client_cr.c#L268

I would recommend to look at the userland.git sources in the same way
as you did for clutter/cogl. I did very limited testing of this and
could very well be a bug on my code. Note though that the meat of the
GL stack is implemented in "the other side": the VideoCore. But the
config negotiation I think is all done in the CPU side.

Well, I did -- and I can't say I'm happy :)

The code is Khronos' EGL implementation:
- in egl_config_check_attribs() it leaves use_alpha set to false, as EGL_ALPHA_SIZE is set to EGL_DONT_CARE
- when sorting the available configurations, alpha size is thus not considered

My suspicion is that COGL is setting EGL_DONT_CARE incorrectly:
- fact: inside egl_attributes_from_framebuffer_config(), CoglFramebufferConfig is initialized to default, hence config->swap_chain->has_alpha will always be false
- fact: COGL always uses this default-initialized framebuffer config to call eglChooseConfig()
- I *think* has_alpha should be true though: I naively think it's impossible to create nice GL drawings without transparency

I tried to look at Mesa's code to see what eglChooseConfig() does there, in _eglCompareConfigs() I see it uses alpha_size similarly to compare configurations. I am guessing the available configs are also hardware dependent, not much chance to check them, simply too many indirections in the code.

In raspberrypi/userland, in egl_client_config.c I found the list of possible configurations, the first two are:

   {FEATURES_PACK(8, 8, 8, 8, 24, 8, 0, 0, 0), ABGR_8888, DEPTH_32_TLBD,        IMAGE_FORMAT_INVALID, IMAGE_FORMAT_INVALID},
   {FEATURES_PACK(8, 8, 8, 0, 24, 8, 0, 0, 0), XBGR_8888, DEPTH_32_TLBD,        IMAGE_FORMAT_INVALID, IMAGE_FORMAT_INVALID},

I added debug printouts to see which is being used. It looks like that if EGL_ALPHA_SIZE is set, then the first is returned; if it's set to EGL_DONT_CARE, then the second one.

This behavior seems to be correct. Again, I think COGL incorrectly requests the EGL configuration, stating it would not care about alpha -- while IMHO it should.

According to git, the COGL part was added by Robert Bragg, reviewed by Neil Roberts on Aug 22, 2011. An interesting part of the comment:

    This patch introduces an internal CoglFramebufferConfig to wrap up some
    of the configuration parameters that are common to CoglOnscreenTemplate
    and to CoglFramebuffer so we aim to re-use code when dealing with the
    above two problems.
   
    This patch also aims to rework the winsys code so it can be more
    naturally extended as we start adding more configureability to how
    onscreen framebuffers are created.

I really depleted my resources available for this (e.g., I cannot afford to learn about what framebuffers are, how they are used, etc). For my own purposes, I'll use the tiny patch I mentioned in my original e-mail, i.e. hardcoding alpha size to 1 if we're on Wayland.

Cheers,
Richard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]