-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Depth/stencil EGL image #133
Comments
I don't think there is an extension that targets a depth or stencil attachment from an EGL Image. |
There doesn't seem to be a drm_fourcc.h enum for a DEPTH format, so that is another hurdle to jump. |
From what I understand, it's because nobody needed it before. I don't know if it would be accepted, maybe if we show a strong enough use case. Otherwise we could use the fourcc bpp to match the GL internal format. Like |
Do you have a use case for using a pre-created depth buffer? this would justify the need. |
The use case is wxrc, a XR wayland compositor. Clients are rendering 3d geometry on their own given space, and send their color and depth buffer to the compositor to be rendered apropriately on the HMD. Here's a screenshot of a prototype. The 2 ducks are rendered on their own framebuffer. The code of the prototype is available here. The logic is the same, just without EGLImage/dmabuf. |
Seems like something unique for Wayland. Question: why is the color and depth sent to the compositor? Usually the 3D image is rendered by app, and that image is sent to compositor. Why would a compositor apply a depth to a frame? Usually a compositor uses depth for z-order of all visible frames. What about compositors that are not 3D engines? |
This isnt unique to wayland, it can be useful in any situation where two processes want to share depth buffers. wxrc uses wayland, but another VR compositor may use something else. |
Note we can't simply alias RGBA8888 with D24S8. They're very different formats at the HW level. If you want to share depth buffers, don't use dma-buf/EGLImage, use Vulkan + Vulkan/GL interop, where appropriate barriers are defined & required to ensure depth buffer data can be handed off between two users correctly. More generally, I've been told several times that more design work is needed before dma-buf + DRM format modifiers can be used to share non-color buffers in a cross-vendor fashion (And I agree), so I wouldn't want EGL to wade into that before the upstream ecosystem has weighed in with a consensus solution at that level. |
What makes depth buffer so different from color buffers? Sharing depth over color buffer works, why not simplify the process? |
(I'm working on this with @bl4ckb0ne) To clarify: we're probably willing/able to do any necessary prerequisite work if a broader approach is required. |
@cubanismo, do you suggest using Vulkan because Vulkan has the external_memory + external_memory_fd extensions which allow processes to share resources as long as the driver is the same? |
Yeah, it's going to have to be the same hardware or type of HW at least, unless you're using a non-tiled depth buffer which NV hardware hasn't supported in years, but we could blit it like the sample does here. Driver may matter less. However, I suggest it more because of the robust barriers defined for sharing resources across queues, processes, and devices in Vulkan, which was introduced into GL with the VK/GL interop extensions, but isn't directly applicable to EGLImages without further extensions. For OSS stuff, I don't know what other vendors need, but our existing modifiers don't contain enough state to define a depth layout from what I recall, because my understanding was they didn't have to yet. If they now do, that's fine, but we'll have to work through it or fall back on the less-flexible implicit kernel-side data path. I suspect we aren't the only vendor that does more special stuff with depth buffers than color buffers. However, it would save a lot of work to just use the existing Vulkan stuff, with Vulkan serving as the allocator and GL as the actual renderer and/or consumer since that's all already defined & widely implemented. |
I would quite like to avoid involving Vulkan in this, since it would directly translate to more work for the users of the API, doubly so when considering that this kind of resource sharing would be without precedent in Wayland. It seems odd that depth buffers would be treated as a special class among buffers, and I would prefer to find a way to mitigate that problem at its source rather than to look to Vulkan for a solution. |
Note, the GLES WG meets again Sept 1. So there is a bit of a wait before the WG has a open discussion. Please continue here. |
My apologies, because of technical issue (no internet, no conference), I was not able to introduce this issue to the GLES work group. We will schedule for next meeting. I am asking for feedback that may provide a more optimized solution for now, and to consider a new extension to import EGLImages of depth type into a depth attachment. I hope there will be feedback here as to pros and cons, and suggestions . |
No worries. Thanks for the update! |
No trouble, the next meeting will be on the 15th right? |
Probably. Depends on work load. Could be next week. Generally 2 weeks |
Barring details that inhibit it, I would expect you would need 1. EGL to recognize a dmabuf as type depth - based on format. Needs to be identified as depth/stencil not a 2d image for eglCreateImage. 2. a new extension with something like glEGLImageTargetTextureDepth/Stencil() instead of TargetTexture2DOES(), to import depth into a depth texture. The 3rd step use glFramebufferTexture to attach texture as depth. Does that seem right? I'm sure I'm missing details. But I'd like to get feedback to be sure this is the way to go, and not missing a detail. |
|
This issue was discussed in OpenGLES WG conference call today.
|
Well, it is a start. I think a reasonable next step would be to sketch up some of the necessary extensions and prove their design in principle by writing up an implementation for Mesa. We'll start with EGL and then move on to GLES, and return here with a summary of what changes are required for Mesa - giving some tangible code to look at for other driver implementors. For what it's worth, if we can get this working in Mesa then we don't really care of proprietary driver vendors can get it working or not in their own drivers. We have no care for proprietary drivers whatsoever. If this means we'll end up namespacing the extensions into MESA rather than as a general-purpose extension, then so be it. |
If you can get it in to the drivers you need as a MESA extension good. If you need to get the main desktop drivers we'll need to get them to buy-in and try for a EXT. |
Mesa is the main desktop drivers 😉 |
@bl4ckb0ne , Simon. we never got traction on this. Maybe the solution from James worked. You have probably moved on. One idea just popped into my head. maybe you already resolved it by now. |
This issue is specifically about windows which aren't simple 2D surfaces. Your solution would be useful if one wanted to communicate the position and orientation of a 2D surface inside a 3D space, but that's not what this issue is about. |
I suspected so. OK. Close this if you are done. I have not had any further discussion from OpenGLES WG since my last report. |
I have a use case where I need to create an image from a dmabuf using
eglCreateImageKHR
, then import it as a GL_DEPTH_COMPONENT/GL_DEPTH_STENCILtexture using
glEGLImageTargetTexture2DOES
. It seems that the second stepassumes that the texture format is always GL_RGBA, which forces me to use a shader
to blit the depth of my framebuffer onto the second image
Here's the simplified code of my process
This feels a bit heavy. Would there be a way to use the EGLImage as a depth
attachment directly? Maybe add a fourcc format to express depth/stencil and have
the driver translate the format into GL format, or add a parameter to one of the
function so let the user specify the desired GL format regardless of the dmabuf
format?
I'd be happy to help and contribute to a simpler solution.
The text was updated successfully, but these errors were encountered: