co1umbarius has joined #wayland
columbarius has quit [Ping timeout: 480 seconds]
robert_mader has joined #wayland
robert_mader has quit []
robert_mader has joined #wayland
<robert_mader> Hi. I shortly wanted to ask for an opinion concerning submitted buffer. IIUC it's safe to assume that Wayland compositors don't change the content of such buffers. So looking at different ways to implement partial damage with double/n-buffering, does anything speak against blitting from a already commited and not yet released buffer back to the next buffer in preparation? It's likely not possible with the wayland EGL platform, but I sup
<robert_mader> pose it is when using dmabufs/shm.
<robert_mader> phrased differently, the Wayland spec only forbids writing to "locked" buffers, not reading, right?
robert_mader1 has joined #wayland
robert_mader has quit [Ping timeout: 480 seconds]
mooff has joined #wayland
neonking has quit []
blue_penquin is now known as Guest53
Guest53 is now known as blue_penquin
Lyude has quit [Ping timeout: 480 seconds]
dos1 has quit [Ping timeout: 480 seconds]
Lyude has joined #wayland
hardening has joined #wayland
hir0pro has quit [Ping timeout: 480 seconds]
hir0pro has joined #wayland
<emersion> hm, i wonder. wayland buffer submission is non-destructive, but that doesn't necessarily mean that the buffer contents are untouched
<emersion> one use-case would be to change the buffer tiling in-place (this is called a "transition", e.g. to allow direct scanout)
<emersion> and then change it back before releasing the buffer to the client
<emersion> what is the wording used in the protocol?
robert_mader1 has quit []
danvet has joined #wayland
<daniels> emersion: if you did that, you'd have to ensure that you returned -1 as buffer_age to the client to tell its contents were trashed
<daniels> we can't specifically preclude it in wl_buffer because sometimes they get used for screenshots or whatever, but perhaps wl_buffer.attach() could carry an explicit 'no we won't destructively modify anything'
<emersion> daniels: not if the compositor transitions the buffer back before returning it to the client?
<daniels> that sounds like it'd break multiple attach
<emersion> it… depends
<emersion> transition on first surface commit, transition back when the last surface commit has done using the buffer…
<emersion> it'd definitely be weird, and no compositor does that so far
<jadahl> only time I've seen a buffer changing behind the scene was a i915 bug where trying to glReadPixel() from a texture from a wl_buffer would accidentally discard modifier flags without changing the actual buffer content
<jadahl> resulting in fun graphical glitches
<emersion> also, with dmabuf-hints, it's better if the client does the transition itself
<daniels> srsly
<daniels> if you want to do anything destructive, do a copy?
<emersion> the whole point of doing it in-place is to make it Fast™ and avoid any copy
<daniels> but the speed slope is: making a copy <<<< in-place transformation <<<<<< client just doing what you wanted it to in the first place, right :P
<emersion> yup
<emersion> with dmabuf-hints, the client can just do the right thing
blue__penquin has joined #wayland
<emersion> so, maybe it's fine to spec wl_surface.attach as read-only?
agd5f_ has joined #wayland
agd5f has quit [Ping timeout: 480 seconds]
<daniels> I would ack the bejesus out of that
pnowack has joined #wayland
saumon has joined #wayland
blue__penquin has quit []
Asmadeus has quit [Remote host closed the connection]
<emersion> jadahl, seems like we have some sed work to do in the wayland and w-p readme/docs
<pq> emersion, I have always, from the very start, assumed that wl_surface.attach does not allow the compositor to modify the buffers in any way, at any time. So robert_mader's suggestion is ok. Has reality made this false already?
<pq> If not, then yes, let's make it very explicit in the spec if it's not already.
romangg has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
zamundaaa has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
<emersion> pq, not yet, but James Jones had patches pretty close from completion to make this false
<pq> yikes
<emersion> see XDC 2019, IIRC
<emersion> OTOH, it was discussed there that clients should do transitions
<emersion> not compositors
<pq> I remember hearing about transitions, but I never connected here
<jadahl> emersion: yea
<pq> clients do it, definitely
<pq> good
<emersion> pq, so yeah i think it's fine to clarify the spec this way
<pq> yup
<pq> I think every request that takes a wl_buffer should be very explicit on the expectations on *both* sides - like sync: can you read or write, and if not then when can you
<pq> sides: compositor and client
<pq> also whether the compositor is "allowed" to detect and act on a client violating the rules
<pq> like we cannot have a compositor disconnecting a client because it is writing into a wl_buffer reserved by wl_surface.attach+commit, since there could already be clients that do that and run "fine"
<pq> e.g. old Xwayland
<emersion> hm right
Sumera[m] has joined #wayland
romangg has joined #wayland
zamundaaa has joined #wayland
zumbi has joined #wayland
<daniels> emersion: I mean Streams was all kind of spec violating
<daniels> I don't think transitions make that any better or worse
<daniels> it's already a mystical black box of 'errrr dunno it works for us'
jryans has joined #wayland
ppascher has quit [Ping timeout: 480 seconds]
ppascher has joined #wayland
<pq> swick, btw. I don't I saw any copyright notices from you in the CM&HDR code, would you want some?
<pq> *I don't think
robert_mader has joined #wayland
<robert_mader> emersion: "Committing a pending wl_buffer allows the compositor to read the pixels in the wl_buffer. The compositor may access the pixels at any time after the wl_surface.commit request." - the first sentence indicates that the compositor is not free to *write* to the buffer
<emersion> robert_mader, i'd explicitly indicate that mutating the buffer's underlying storage is forbidden
<emersion> also, nothing says a wl_buffer has pixels in it :>
<emersion> there can be some "inventive" wl_buffer types
<emersion> like solid color, mirror of another surface, stereoscopic 3D content, etc
<pq> svg... :-P
<emersion> yeah, that's a good one as well…
<robert_mader> :D
<emersion> so i'd prefer to refer to "buffer contents" or "underlying buffer storage" instead
<robert_mader> But in tendency, would you say back-blitting should be avoided?
<emersion> why do you need to back-blit?
<emersion> not possible to accumulate damage like in the GL path?
<pq> what' back-blitting?
<emersion> pq, submit a buffer, realize you need a new one to draw, blit the buffer you've submitted to the new buffer
<pq> well, copying from the buffer you just submitted allows you to not track damage for further than just one frame, and it also allows you to simply blit instead of re-render.
<robert_mader> yeah apparently the Firefox compositor integration gl paths do something like that on CoreAnimation
<emersion> robert_mader, do you always unconditionally blit the whole buffer?
<emersion> or just a region of it?
<emersion> pq, blitting when allocating a new buffer sounds like an unnecessary optimization
<emersion> allocating a new buffer should be pretty rare
<robert_mader> I'd say only a region - which could be calculated using buffer age and the damage region from previous commits
<emersion> ok, good
<pq> emersion, it's not about when allocating, but when starting every frame.
<emersion> i think there are cases where blitting is a bad idea
<emersion> let's say the whole buffer is updated each frame, e.g. solid color fill changing at every frame
<emersion> blitting is a bad idea in this case because the blitted region gets over-written when drawing the new content
<pq> sure, but I think this more towards the cases where you have tons of geometry to render, like a web page?
<emersion> if you know what changed since the last frame, you can blit (accumulated_buffer_age_damage - next_frame_damage)
<emersion> then render next_frame_damage
<pq> yes
<robert_mader> well, tracking some damage regions over multiple frames is apparently much easier than making the whole gl stack aware of that possibility
<robert_mader> so selective blitting should be easy
<emersion> so yeah, i think blitting is a good idea if you don't blit the region you're going to re-render, robert_mader
<emersion> and only blit what's necessary according to the buffer age
<robert_mader> emersion: cool, thanks. Then I'll consider that option
<emersion> i think dnkl has been thinking about things like this as well
<gitlab-bot> swaywm issue 2705 in wlroots "Add support for GL_EXT_robustness" [Enhancement, Renderer, Open]
<emersion> eh, the bot does GitHub issues as well? interesting
<emersion> the numbers aren't necessarily directly applicable to firefox, because the rendering workload will be different
<emersion> thanks for working on this, robert_mader :)
<robert_mader> ah right, the software backend on compositors that hold shm buffers also falls into this category. And sure :)
<dnkl> I haven't been following this discussion in detail, but does sound familiar :) If (one of) the question is "should the compositor be allowed to modify a non-released buffer", then I'll just mention that foot will break if a) compositor doesn't do immediate releases, and b) the compositor modifies the unreleased buffer, and c) the buffer we're rendering to is "too old" - in this case
<dnkl> foot memcpy:es/blits the last buffer (currently in-use by the compositor) to the new buffer
<emersion> dnkl, (a) is pretty bad, it means foot breaks on software-rendered compositors
<robert_mader> emersion: by the way, you'd do me a huge favor if you (or somebody else) could have a look at https://github.com/swaywm/wlroots/issues/1865 - I think it's the only blocker for the "delegated compositing" firefox backend, and sway is the last one to not support it ;)
<gitlab-bot> swaywm issue 1865 in wlroots "wl_subsurface_place_above ignores parent" [Bug, Surface, Open]
<emersion> robert_mader, oh ok, will prioritize this!
<dnkl> emersion: sorry, meant that foot breaks if all three conditions are met
<emersion> oh i see
<robert_mader> thanks!
<emersion> dnkl, so with the protocol spec'ed so that compositors can't mutate buffers, we should be good
<dnkl> emersion: yup. And if it's spec:ed to *allow* it, I'll update foot to re-render instead of copy. As long as we're only switching between two buffers we'll never hit the memcpy path
is0ke3 has joined #wayland
soreau has quit [Read error: Connection reset by peer]
soreau has joined #wayland
st3r4g has joined #wayland
ppascher has quit [Ping timeout: 480 seconds]
toggleton[m] has joined #wayland
is0ke3 has quit [Ping timeout: 480 seconds]
is0ke3 has joined #wayland
ppascher has joined #wayland
ecloud has quit [Ping timeout: 480 seconds]
ecloud has joined #wayland
dos1 has joined #wayland
hir0pro has quit [Ping timeout: 480 seconds]
_whitelogger has joined #wayland
MrCooper has quit [Remote host closed the connection]
MrCooper has joined #wayland
spstarr has joined #wayland
hir0pro has joined #wayland
hir0pro has quit []
jekstrand has joined #wayland
jbit_ has joined #wayland
jbit_ has left #wayland [#wayland]
spstarr has quit [Remote host closed the connection]
<swick> pq: wouldn't mind
zamundaaa has left #wayland [#wayland]
zamundaaa has joined #wayland
niecoinny[m] has joined #wayland
Arnavion has quit [Ping timeout: 480 seconds]
Arnavion has joined #wayland
spstarr has joined #wayland
Narrat has joined #wayland
hir0pro has joined #wayland
hir0pro has quit [Quit: Konversation terminated!]
hir0pro has joined #wayland
hir0pro has quit []
hir0pro has joined #wayland
hesperos has joined #wayland
<robert_mader> emersion, daniels: talking about shm buffer handling, has one of you looked into https://software.intel.com/content/www/us/en/develop/articles/zero-copy-texture-uploads-in-chrome-os.html before? Looks like on intel and similar we could avoid texture uploads from shm altogether
hesperos_ has joined #wayland
hesperos_ has quit []
<daniels> robert_mader: we can't really avoid uploads from shm, because you need to alloc a BO from vgem - it doesn't give you a way to wrap vaddr+len into a BO
<daniels> so clients can do that today if they alloc using vgem and send via dmabuf
<robert_mader> oh cool - so all compositors support this in theory?
zubzub has joined #wayland
hesperos has quit []
hir0pro has quit [Ping timeout: 480 seconds]
smurray is now known as scottm
<jadahl> daniels: sounds like something gtk3 could benefit from
<jadahl> as it'll likely never see any hw acceleration
hesperos66 has joined #wayland
scottm is now known as smurray
<hesperos66> is it okay to call something like i.e. `weston_view_geometry_dirty` from a different thread than the one running `wl_display_run`?
<daniels> hesperos66: afraid not
<daniels> robert_mader: yeah, as long as your driver can import from vgem, which is ... not all of them
<daniels> jadahl: EFL does this too
<hesperos66> daniels: so more or less the compositor has to be single threaded?
<hesperos66> is there a way to post an operation like `weston_view_geometry_dirty` to event_loop from another thread?
<daniels> yeah, it pretty much has to be single-threaded - you can spawn helper threads to do background things if you like, but all your interactions with weston API & structures can only be in the main thread
<daniels> the usual pattern is to create a pipe(), add it as a wl_event_source, and use that to post messages between your main & helper threads
<jadahl> daniels: so you effectively need a per driver allow-list then?
<jadahl> in gtk
YaLTeR[m] has joined #wayland
<robert_mader> jadahl: or a small check?
<robert_mader> because gkt should also be able to import, right?
<emersion> i don't see vgem loaded often
<daniels> a lot of people don't ship it because it will generally claim card0 and annoy dumb userspace
<daniels> also it's an unguarded interface which allows userspace to allocate memory outwith ulimit
<emersion> allocations not counted towards the allocating process?
<daniels> right, they don't accrue towards your memory limit
<daniels> (insert opinion about practical usefulness of ulimit here)
<emersion> :S
<emersion> oom-killer already random enough, no need to make it even more random
<robert_mader> hm ok that's the crux of the matter
danvet has quit [Ping timeout: 480 seconds]
hardening has quit [Quit: http://quassel-irc.org - Discuter simplement. Partout.]
spstarr has quit [Remote host closed the connection]
ppascher has quit [Ping timeout: 480 seconds]
Narrat has quit []
robert_mader has left #wayland [#wayland]