Skip to content
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

Add DRM modifiers to EGLImage creation #9453

Closed
wants to merge 1 commit into from

Conversation

elFarto
Copy link

@elFarto elFarto commented Nov 15, 2021

While attempting to get mpv to use my VA-API implementation on-top of NVDEC, I noticed that the VA-API GL path doesn't correctly set the DRM modifiers when creating the EGLImage. Without the modifiers the creation fails.

@sfan5 sfan5 requested a review from philipl November 15, 2021 11:46
@philipl-airtable
Copy link

This seems to make sense. Do you have your nvdec wrapper code anywhere I can see? The challenge has always been that you can't trivially export the decoded frames from cuda. But I do know that the decoded frames are in a linear format so I'm surprised that modifiers are necessary.

@elFarto
Copy link
Author

elFarto commented Nov 15, 2021

I don't have the wrapper code released yet, I'm still trying to squash the last (I hope) major bug out of it, where part of CUDA will crash after about 64 frames.
And yes, getting the data out was always the challenge, and it still is. Exporting just the linear buffer out of CUDA works, but NVIDIA's EGL implementation doesn't seem to let you import that image and bind it to a GL_TEXTURE_2D. So to get it to work I first have to copy to two cuArray's, then publish that array to a EGLstream, acquire an EGLimage from the stream, and then export that as a DMA-BUF.

@philipl-airtable
Copy link

Yuck, but not surprising. So you tried copying the frame to allocated memory and then export with cuMemExportToShareableHandle and that couldn't be imported?

@elFarto
Copy link
Author

elFarto commented Nov 15, 2021

Yes, that was my first idea/hope, but using cuMemExportToShareableHandle doesn't seem to produce fd's that are DMA-BUF compatible. I do plan on revisiting it once I've got it fully working to see what can be improved, but trying to work my way through this is a bit of a slog as there's basically no real documentation on how to do this.

@philipl
Copy link
Member

philipl commented Nov 15, 2021

Hmm. They claim that there is some way to import it into GL. Maybe you can slightly simplify it by exporting it as a shared memory handle and then importing it via that other extension and then export from EGL as a dma bug. That at least avoids the eglstream mess.

@philipl
Copy link
Member

philipl commented Nov 15, 2021

@elFarto Can you give the change a proper description? Explain that we should be exporting the frames with modifiers for correctness even if it was working before.

Include the supplied DRM modifiers in the call to to eglCreateImage.
Modifiers are required on certain implementations, and the
eglCreateImage call can fail without them.
@haasn
Copy link
Member

haasn commented Nov 23, 2021

Implemented in #9507. Sorry for ignoring your PR, I didn't see it until now.

@haasn haasn closed this Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants