-
Couldn't load subscription status.
- Fork 196
modesetting: Fix hw cursor v2 #734
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
base: master
Are you sure you want to change the base?
Conversation
|
@notbabaisyou Ping, as I couldn't add you as a reviewer through the github interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not a fan of combining both approaches here, this just makes one massive mess and I'd rather have one or the other. Of course I'm biased and prefer my one since it's a more widely used solution (i.e. Wayland) but I guess someone like @metux would probably be suited to picking one of the approaches here.
There's some smaller nits that I've left out and some formatting nitpicks too.
| } | ||
|
|
||
| static void | ||
| drmmode_paint_cursor(CARD32 * restrict cursor, int cursor_pitch, int cursor_width, int cursor_height, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of this, takes too many arguments and I think the memcpy's will break on a cursor size change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this does is:
If this is the first time we paint the cursor, paint the entire cursor.
Otherwise, let width_todo be max(new_glyph_width, old_glyph_width),
and let height_todo max(new_glyph_height, old_glyph_height).
And only paint the top width_todo * height_todo corner of the cursor.
We could merge your pr first, and I can then rebase, if you prefer.
This pr is still using the SIZE_HINTS from your pr. The rest are additions. |
|
@metux @callmetango @notbabaisyou @cepelinas9000 Do you think it's a good idea for sometime in the future to switch from using dumb bo's for the cursor and instead use gbm bo's? |
Not sure whether it's actually worth it. The buffers are pretty small and rarely updated, and HW scanout/overlays usually already optimized for them. Here's what chatgpt has to say about this: |
Wdym overlays here? I meant that we could create a cursor buffer with I don't think we want scanout here, I think we only want that for the screen buffer. The cursor buffer does get updated frequently, every time the mouse hovers over a text window, for example. |
|
@metux @callmetango @cepelinas9000 @notbabaisyou I also added an option for setting the hw cursor fallback size via xorg.conf. Many cards don't support SIZE_HINTS, and for those, we always use the fallback. The way this patch is now, for those cards, we either use the 64x64 fallback, or what the users puts in xorg.conf. Is this really a good idea, or should we keep the old probe for checking the minimum size on these cards? What are your thoughts? |
5203b6c to
f28eaa4
Compare
Hardware overlays - in C64 we called them sprites, X11 calls them "hardware cursors".
Yes, but then we're depending on gbm (IMHO we currently depending on it when glamor enabled).
Isn't the whole idea that the scanout automatically paints (blends in) the cursor on its own ?
That would be soft-cursors, eg. on a really dumb framebuffer. |
I think we should:
|
So you mean the cursor plane, right? As I understand it, there are 3 types of drm planes, primary, cursor and overlay. The primary plane presents the main part of the image.
As you said, we already use libgbm.
Yes, but I don't think we need to explicitly mark the buffer as scanout capable.
The cursor buffer has to be painted whenever the glyph changes. |
My thoughts, (I doubt worth the effort) I would instead The semantics, cursor sizes always from smallest to largest (in case square - by area). |
For now, I added the option to force a particular width and height, and pitch is determined automatically. |
I added back the old probe. |
a74f39e to
8bcd1dc
Compare
Yes, that would be a more high level term ;-) From Xserver PoW, there are HW cursors, which the HW automatically paints - Xserver only needs to update the buffer when the cursor image actually changes. Traditionally that's done in the scanout unit, but that's really HW specific.
Yes. in DRM terminology, the overlays are usually for things like HW colorspace transformation (eg. additional YUV images from a video). How much they're different from the other types is really HW specific, theoretically they could even be all the same on some HW.
On modern GPUs, yes. Older HW does that inside the scanout unit, much like the old 6560 did (interleaving two bit streams right before the encoder). That's why the distinction between the plane types, and Xserver terminology "HW cursor" still matters.
Note that X11, overlays theoretically could also go to different outputs. That's one of the things Xv is for. Strange historical stuff like a video output going through separate connector, which then finally might become mixed into the main image somewhere in the physical screen setup (analog). No idea whether KMS ever supported such stuff. Maybe we should make some dictionary, to prevent any babylonian confusion here ;-)
Haven't checked yet whether that's also the case w/o glamor. If it is, then I have no objections.
Careful with taking Wayland as reference - they're depending on modern GPUs. Older HW which might do the HW cursors in the scanout (instead of GPU/render) isn't practically supported by Wayland at all (those could only operate on dumb framebuffer, w/o any HW acceleration at all).
Yes, the cursor buffer needs to be updated (or switched to another one), when the cursor image changes (for whatever reason). But it doesn't need to be repainted (blitted onto) the main image, eg. when it moves - didn't count that as "frequently" ;-) |
In that case, we could try to support both dumb bo's and gbm bo's, and use gbm bo's if libgbm is available.
What do you mean by 'in the scanout'?
Yes, that's what I meant by painting the cursor, updating the cursor buffer, not rendering it at the correct position. For gbm vs dumb, I saw some discussion here: |
The piece of logic that's periodically reading out the framebuffer(s) and generating the data stream for the encoder. Then the encoder will make the actually output signal for the display (eg. VGA, PAL, HDMI, DP, ...). Back in the old times (when display signals been analog), this had been called "ramdac" (you'll still find that name in the Xserver codebase). Sometimes those terms become smeared a bit (eg. some people calling the whole graphics cards the "GPU"), because there're tons of different practical configurations and often only several pieces of it are CPU-accessible. For completeness: we haven't even talked about PHYs - but except for obscure embedded systems you probably won't ever get in touch with them (and even then, it's probably deeply buried in the kernel drivers). Yeah, graphics HW isn't entirely trivial :o (gladly, today, we don't need to sync CPU with display clocks anymore, like back on C64 when we did "impossible" things like painting over the screen border ;-))
Ah, okay, we've been talking about different things.
This is assuming the kernel driver is recent enough to support gbm (and that this one is working on all cards we wanna support). No mention of cursors at all. Probably just from application/client's PoV, who rarely deal with cursors at all. Unfortunately, not mentioned which of the various Xilinx designs they're actually talking about, and how it's working under the hood. Gutt feeling: they've got a simple multi-buffer scanout (depending on current pixel position, the cursor pixel is either coming from translated vram cell or default to all-transparent, and then alpha-blended (eg. XOR) with the main framebuffer's current pixel) ... just like HW cursors were done in the old times. And depending on the actual machine's physical memory/bus layout, that sprite buffer might or might not be in main RAM, or possibly constraint to certain regions, etc. Bottom line: we need to be careful with our assumptions, treat hw cursors as special entities, let the underlying drivers find out how exactly to deal with them. |
|
Since the queue is a bit bigger and we already accumulated a lot of discussion here, shall we perhaps split it into several ones ? Haven't read each patch one by one yet, but feels like several are disjunct and could land separately. |
Could you merge @notbabaisyou 's pr, and then I'll rebase this on top of it, and go from there? |
|
I added support for gbm cursor bo's. |
41c4636 to
5fdc765
Compare
…rted by all CRTCs. Signed-off-by: stefan11111 <[email protected]>
On many cards, SIZE_HINTS isn't implemented, so the hardware cursor used is the fallback one. With this, we allow the user to specify what size the hardware cursor should have, instead of forcing 64x64. Signed-off-by: stefan11111 <[email protected]>
On most cards, SIZE_HINTS isn't available. Without this, most users would have to set the fallback cursor size themselves, or rely on the 64x64 default. Signed-off-by: stefan11111 <[email protected]>
Now that we probe for the cursor size automatically, even if SIZE_HINTS isn't available, it isn't very useful to set the size of the fallback cursor. However, it might still be useful to force a particular cursor size via xorg.conf. For example, if on a system the probes fail, or if the user wants a particular cursor size, that is higher that the minimum size. Signed-off-by: stefan11111 <[email protected]>
We first try to allocate a gbm buffer for the hw cursor. If that fails, we fall back to dumb buffers. Signed-off-by: stefan11111 <[email protected]>
Signed-off-by: stefan11111 <[email protected]>
5fdc765 to
ba22b40
Compare
|
@stefan11111 what's the status on this one ? |
|
I'm pulling commits from this one into separate pr's, and improving them as I do that. |
|
Merge Conflict found |
This adds my changes on top of #691
Closes: #549
Closes: #675