[Xcb] Is there any way to intercept or generate protocol to an in-memory buffer?

Bart Massey bart at cs.pdx.edu
Fri Dec 29 09:43:21 UTC 2017


I don't remember the details of how we did the sync in XCB back when: we
did something very like what you are doing, but the details are a bit
tricky to get right.  In particular, XCB will only send an input focus
request when no request (not just input focus) has received a reply in the
last 64K requests. So...yeah. It's been literally a decade since I looked
at this stuff, but I *think* you should be able to dig the last-sync count
out of XCB and just work from that: probably can just use the XCB code or
at least algorithm to tell you when to sync. We had a correctness proof at
one point. We had it again after we found and fixed a bug in the proof. :-)

On Thu, Dec 28, 2017 at 11:39 AM Clemens Eisserer <linuxhippy at gmail.com>
wrote:

> Hi Bart,
>
> > The overhead of doing separate XShmPutImages should be minimal.
>
> Xcb is performing fine, what is causing performance issues is how the
> drivers implement those tiny XPutImage requests (especially when
> operating on top of OpenGL like all glamor based setups).
> I've found a way to implement the deferred protocol submission using
> the socket handoff mechanism and it seems to work really well.
>
> However, currently the socket owner changes quite frequently, so I am
> struggling with the requirement to issue a XGetInputFocus-Request
> *every* time I call xcb_take_socket.
> For cases where there are only 4 requests to submit, an additional
> XGetInputFocus hurts.
>
> What I tried instead was:
>
> uint64_t lastManualSyncSeq; //Remember sequence-number, when the last
> manual sync was issued
> uint64_t socketTakenSeq; //Sequence number when the socket was taken
> uint32_t self_generated_count; //Number of self-generated X requests
>
> while(1) {
> xcb_take_socket(xcbCon, &returnSocketCB, &flags, 0, &socketTakenSeq);
>
>    while(1) {
>      if((socketTakenSeq + self_generated_count) - lastManualSyncSeq >
> 65000) {
>         //will cause socket to be revoked, callback will take care of
> flushing out generated protocol
>         lastManualSyncSeq = xcb_get_input_focus(xcbCon).sequence;
>         xcb_discard_reply(xcbCon, lastManualSyncSeq);
>         self_generated_count = 0;
>         break;
>    }
>
>     self_generated_count++;
>     GenerateXrenderFillRectanglesRequest(); //appends reply-less
> request to request data buffer
> }
>
>
>
> The idea is I can't be sure when xcb automatically generated the last
> XGetInputFocus request, but I know when I last called
> xcb_get_input_focus myself.
> As long as the last call to xcb_get_input_focus is less than 65k
> requests away, everything is fine (regardless of whether xcb issued
> some xcb_get_input_focus requests in between).
>
> However, this doesn't seem to work out as expected - I still get hangs
> from time to time.
>
> Any idea what is wrong with the above snippit?
>
> Thank you in advance, Clemens
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20171229/0b71b3d6/attachment.html>


More information about the Xcb mailing list