flypig.co.uk

List items

Items from the current list are shown below.

Gecko

3 Sep 2023 : Day 18 #
Following on from yesterday I'm continuing to work on the GLScreenBuffer errors today. This is turning out to be a tough one. The change set is large, spread across 107 files, completely removes the class we rely on and doesn't appear to provide an equivalent or similar replacement.

Reading carefully through the diff from beginning to end isn't giving me any satisfaction either.

The Phabricator summary suggests that GLScreenBuffer has been replaced by GLSwapChain:
 
Summary
  • Majorly simplify CanvasRenderer
  • Replace GLScreenBuffer with trivial GLSwapChain
  • Use descriptor structs so that future SharedSurface changes aren't so painful to propagate
  • Mortgage/strip out more OffscreenCanvas code for now

Although GLSwapChain doesn't exist, there is a class called just SwapChain that might be what's meant there. To get a better handle on this I'm going to go through the EmbedLite code to see what functionality we actually need.

The only place we use it is in EmbedLiteCompositorBridgeParent.cpp so checking all this shouldn't require too much effort.

For EmbedLiteCompositorBridgeParent::PrepareOffscreen() the following are required:
  1. screen->mCaps should provide access to a SurfaceCaps attribute. However, this is used to set up the flags parameter to be passed into SurfaceFactory_EGLImage::Create() and that parameter has been removed, so it looks like we can do without this now.
  2. UniquePtr<SurfaceFactory> mFactory: a parameter to capture the SurfaceFactory.
  3. screen->Morph(std::move(factory)): essentially the mFactory setter.
For EmbedLiteCompositorBridgeParent::PresentOffscreenSurface():
  1. screen->Size().IsEmpty(): for checking the surface size.
  2. screen->PublishFrame(screen->Size()): calls Swap(size) which acquires, attaches and copies the surface.
For EmbedLiteCompositorBridgeParent::GetPlatformImage():
  1. screen->Front()->Surf(): returns the SharedSurface.
  2. Important things are done with the SharedSurface, but it's a class that still exists in the ESR 91 code.
  3. There are two versions of GetPlatformImage() but they both use GLScreenBuffer in a similar way.
That's not a huge amount of functionality. The question is: how much of this can SwapChain provide? These are the equivalent pieces as far as I can tell:
  1. SwapChain has a public UniquePtr<SurfaceFactory> mFactory attribute.
  2. There is no Morph() method equivalent, but that's okay because mFactory is public so we can access it directly.
  3. The PublishFrame() functionality is less clear, but it looks like some of it might be handled by SwapChain::Acquire().
  4. The SharedSurface class has a public UniquePtr>MozFramebuffer< mFb attribute which has a gfx::IntSize mSize attribute.
  5. Alternatively SharedSurface itself has a public SharedSurfaceDesc mDesc attribute which also contains a gfx::IntSize size attribute.
  6. A SharedSurface object can be found as mFrontBuffer in SwapChain or as mBackBuffer in SwapChainPresenter.
So it looks like SwapChain and SwapChainPresenter provide most of what we need. What's missing is any reference to either in the GLContenxt. My plan therefore is to add this reference in place of the previous mScreen attribute.

I'm pretty sure that what I'll be left with is a broken renderer, but that won't become clear until the build is fully working, at which point I'll be able to come back to this. Hopefully the changes I make now will at least serve as a memory aid for what's needed.

I've now spent quite a frustrating amount of time trying to get to the bottom of this, to the extent that I've not set a build running for two days now. And I've still not made the changes necessary so that I can build one overnight tonight either. No matter, I'll aim to get these changes made tomorrow so I can run the build tomorrow night instead.

Frankly, my laptop is probably glad to have some overnight rest for once!

I also received some excellent advice from Fabrice on Mastodon:
 
Good luck for the graphics update - you should ask question in the the matrix.to/#/#gfx:mozilla.org matrix room, they are friendly :)

This is a really excellent idea. I've not had a chance to join the room yet, but I agree it's likely to be the most efficient and successful way to resolve this.

For all the other posts, check out my full Gecko Dev Diary.

Comments

Uncover Disqus comments