-
Notifications
You must be signed in to change notification settings - Fork 15
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
Remove explicit usage of linear modifier #240
Conversation
running The error from before is changed to this: Nvidia driver just doesn't wanna I guess. Edit: |
Try again. |
|
277a3f1
to
4eecb1a
Compare
Try again. |
All tests seem to run to completion now |
What are the contents of /dev/dri? |
@cubanismo in the scenario above we Open If we change this to However, even then, trying to Are these additional restrictions of your driver that are documented somewhere? All of these issues seem like bugs or at least things where you significantly diverge from mesa. |
4eecb1a
to
1520232
Compare
@krakow10 I've reverted the two workarounds that I mentioned in the comment above. They were just hacks that will not work with mesa or will cause significant problems with mesa drivers. Still, I'm wondering if |
During my testing in #239 (comment) I was able to test linear-modifier base branch
linear-modifier base branch
linear-modifier with test patch 4eecb1a:
|
This does not sound correct. That error message no longer exists in that branch. |
I revived the commit from my local git to see what would happen, but maybe I made a mistake and it just built the master branch |
Expected. Our driver can't render to linear buffers in general. GBM isn't expressive enough to say exactly what sort of rendering will be performed, so we have to just assume one of the incompatible methods will be attempted.
Again, expected. Since no modifier was requested, we'll choose on of our tiled layouts internally given the rendering usage.
Of course. We have no way to know what modifier was used, so the layout is undefined and hence unsupported. If you figure out the modify and specify it, the layout is deterministic and can be supported.
Why would you expect to be able to perform an operation you didn't ask to be supported? Note we don't perform any tile/untile swizzling during CPU map operations, so you won't actually be able to use the mapping for much if it's a renderable buffer. This has been widely discussed, and is a purposeful divergence from the behavior of most, but not all, Mesa drivers, since it is an unreasonable burden to support.
Is there a place you'd expect to find documentation describing how a driver behaves in undefined or loosely defined situations? GBM has no specification that I'm aware of, so there's no documented behavior to document divergence from. The implementation is the spec, and ours behaves how it behaves.
None of these behaviors are likely to change. If you want more well-defined access to a GBM buffer from all vendors, import it into a well-defined API (OpenGL, Vulkan), and access it using that API. You'll also gain access to a superset of the operations available directly in GBM. |
What's the correct way to allocate buffers for cursor planes with your driver? Should I just omit all usages? I cannot use GBM_BO_USAGE_WRITE because that deoptimizes on mesa. I would prefer it if you could allow RENDERING in GBM though. AFAIK, compositors call into GBM with the intersection of whatever their OpenGL/Vulkan API reports as renderable and what the DRM planes report as IN_FORMATs. And even if someone passed in LINEAR with RENDERING and you returned a buffer, the graphics API would still not allow them to import it for rendering. Another perspective: What if I wanted to use VK_NV_linear_color_attachment to render to linear buffers? Is it not possible to allocate such buffers with your GBM backend?
The problem is that some mesa drivers also return explicit modifiers in this case just like nvidia. However, the very same drivers don't allow that modifier to be imported via their OpenGL/Vulkan APIs. Therefore I know of at least 3 compositors that explicitly overwrite such modifiers with the INVALID modifier which then allows successful import into OpenGL and Vulkan with these drivers (!). This seems to be a fundamental incompatibility between the two implementations.
I believe the GBM API only requires the WRITE usage for the To be clear: What are the exact usage requirements for gbm_bo_map in your driver?
Isn't this just a violation of the GBM api? It says
If this does not apply to all backends, then the documentation should definitely be adjusted.
Some kind of document describing how your driver diverges from mesa behavior (insofar such divergences are known) would be nice. Having to guess what EINVAL means without being able to check the source is burdensome.
Unfortunately in my integration tests I use software rendering because I encountered slight differences in blending behavior across different drivers. Enough to cause tests that compared screenshots to fail. At the same time I have to use dmabufs because their usage is hardcoded all over the place. |
GBM_BO_USAGE_CURSOR. Note this will also get you a linear buffer, since our hardware doesn't support tiled images for cursor planes either.
For Linear? The hardware doesn't support rendering to linear in various situations, so we don't advertise it. That would cause more problems than it would solve.
If you have to do it in GBM, just don't specify RENDERING usage. As I say, our implementation assumes that non-specific term implies rendering beyond the capabilities VK_NV_linear_color_attachment exposes. There's no way to fix that inconsistency without revving the GBM API.
I'm not saying the GBM API doesn't have problems. The whole GBM usage flag concept just doesn't work that well. However, I looked at the implementation, and it should allow importing without specifying a modifier as long as the import operation uses the same parameters (width/height/format/usage) as the allocation, since it will derive the same modifier in each case. Is that what you're trying? If so, it should work, so there may be a bug.
I misunderstood. All the same, our driver fails mapping of any non-linear buffer. GBM_BO_USE_WRITE usage is essentially a synonym for linear in our implementation.
As I say, this is deliberate. It's not going to change. Don't use gbm_bo_map(), and if you have to, use it on linear buffers. |
I remember something about USAGE_CURSOR being deprecated or at least no longer needed with modifiers.
On the import side I am not specifying any usage since I'm only using it for mapping. Anyway, I'll try to see if I can make the necessary changes. Thanks for your input. |
@krakow10 a proper solution for this will probably involve writing a new allocator based on /dev/udmabuf for tests. I'll be out of the office for the next 4 weeks but I'll look into it afterwards. The screenshot case should already be solved in this branch. I have something locally for using non-linear modifiers for screensharing. |
All flags besides USEAGE_SCANOUT are invalid with modifiers. This suggestion would be for if you weren't using modifiers.
Thinking about this, that shouldn't matter. All I was suggesting was using e.g., Vulkan's transfer functions to implement a read-modify-write operation, where your software rendering would be the "modify" portion of that operation in this case, instead of using GBM to map a tiled image for software rendering. If you needed more functionality, Vulkan has that too, but it sounds like that's not relevant in this case. |
What do you mean by this? Your driver does not seem to ignore other flags, because it still rejects RENDERING with the linear modifier. But is also doesn't outright reject RENDERING + valid modifier because I always use the RENDERING flag for framebuffers. jay/src/backends/metal/video.rs Line 2782 in 3eb539c
I believe that wlroots does the same. It is possible, I suppose, that even in mesa these flags don't affect the allocated buffer and are only used for validation.
That's an interesting idea that I had not considered. That would have worked. |
Superseded by several PRs that have been merged into master.
|
For the record, I mispoke/remembered the design incorrectly here. Only the linear flag is explicitly invalid when mixed with modifiers. However, as you note we'll also reject any flags that imply linear on our architecture if combined with a non-linear modifier. |
No description provided.