Bug 1586696 Comment 8 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(In reply to Martin Stránský [:stransky] from comment #2)
> Created attachment 9120077 [details] [diff] [review]
> webgl-dmabuf patch
> 
> Hi Sotaro,
> 
> there's a WIP dmabuf backend patch for WebGL, I see 100% performance boost with it for simple WebGL samples at GL compositor (it's even faster than chrome/chromium on my box). It implements shared surfaces backed by dmabuf surface.
> 
> But I have some questions about it:
> 
> - Is is better to export export texture or framebuffer by shared surface? (dmabuf has both)
Texture is better, if GL can naively wrap the texture in its own framebuffer for RTT.
> - What does mean a surface can be recycled? (a param at SharedSurface::SharedSurface()). Is that important and what is needed for that?

We avoid reallocating surfaces for two reasons:
* glGetError is a pipeline flush, but we need to use it to check for OOM/failure to allocate.
* Framebuffer completeness should be cached/reused instead of making temporary framebuffers and requiring revalidation.

> - I'm unable to decode what are the lock/unlock methods used for as there isn't any documentation for it: 
>     LockProdImpl()/UnlockProdImpl()
>     ProducerAcquireImpl()/ProducerReleaseImpl()
>     ProducerReadAcquireImpl()/ProducerReadReleaseImpl()
>     So do I need to implement them and do we need to implement commit?
Yep, we need those for synchronization. Check out other SharedSurface implementations to see what these are for:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/gfx/gl/SharedSurfaceANGLE.cpp#111

LockProd(ucer) is exclusive:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/gfx/gl/SharedSurface.cpp#63

ProducerAcquire/Release is Acquired before WebGL renders into a surfaces, and Released at the end of a WebGL frame. Here's the example implementation for stock GL:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/gfx/gl/SharedSurfaceGL.cpp#127

ProducerReadAcquire/Release are when the producer (like WebGL, generally content) needs to read from the surface, but isn't writing to it.

> - WebRender() - when I use this patch with webrender I get GL errors although it generally works somehow. I wonder if that's due to missing sync or something. I'll look at it later.
Just don't enable it until it works without errors.
(In reply to Martin Stránský [:stransky] from comment #2)
> Created attachment 9120077 [details] [diff] [review]
> webgl-dmabuf patch
> 
> Hi Sotaro,
> 
> there's a WIP dmabuf backend patch for WebGL, I see 100% performance boost with it for simple WebGL samples at GL compositor (it's even faster than chrome/chromium on my box). It implements shared surfaces backed by dmabuf surface.
> 
> But I have some questions about it:
> 
> - Is is better to export export texture or framebuffer by shared surface? (dmabuf has both)

Texture is better, if GL can naively wrap the texture in its own framebuffer for RTT.

> - What does mean a surface can be recycled? (a param at SharedSurface::SharedSurface()). Is that important and what is needed for that?

We avoid reallocating surfaces for two reasons:
* glGetError is a pipeline flush, but we need to use it to check for OOM/failure to allocate.
* Framebuffer completeness should be cached/reused instead of making temporary framebuffers and requiring revalidation.

> - I'm unable to decode what are the lock/unlock methods used for as there isn't any documentation for it: 
>     LockProdImpl()/UnlockProdImpl()
>     ProducerAcquireImpl()/ProducerReleaseImpl()
>     ProducerReadAcquireImpl()/ProducerReadReleaseImpl()
>     So do I need to implement them and do we need to implement commit?

Yep, we need those for synchronization. Check out other SharedSurface implementations to see what these are for:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/gfx/gl/SharedSurfaceANGLE.cpp#111

LockProd(ucer) is exclusive:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/gfx/gl/SharedSurface.cpp#63

ProducerAcquire/Release is Acquired before WebGL renders into a surfaces, and Released at the end of a WebGL frame. Here's the example implementation for stock GL:
https://searchfox.org/mozilla-central/rev/9b4b41b95cbcda63f565bdc24411e15248f91d83/gfx/gl/SharedSurfaceGL.cpp#127

ProducerReadAcquire/Release are when the producer (like WebGL, generally content) needs to read from the surface, but isn't writing to it.

> - WebRender() - when I use this patch with webrender I get GL errors although it generally works somehow. I wonder if that's due to missing sync or something. I'll look at it later.

Just don't enable it until it works without errors.

Back to Bug 1586696 Comment 8