On Fri, 4 Sep 2009 12:17:20 -0700
Jesse Barnes <jbar...@virtuousgeek.org> wrote:

> I've been working on coding up the server and client side of
> SGI_video_sync, OML_sync_control and SGI_swap_control.  I came up with
> this set of new protocol (against the dri2-swapbuffers branch) to
> support the new requests.
> 
> We still need to change the DRI2SwapBuffers request to handle the
> various OML bits before it gets merged.
> 
> To summarize:
>   DRI2GetMSCReq - get MSC triple
>   DRI2WaitMSCReq - wait on an MSC count or divisor/remainder
>   DRI2WaitSBCReq - wait on a swap count or all pending swaps
>   DRI2MSCReply - MSC triple (generated in response to any of the
> above)
> 
> Kristian and I talked briefly about doing this client side using
> events to notify clients when their CRTC changes, but there are a few
> issues:
>   - races between client blocking and other server events (DPMS,
> window movement)
>   - compositor interaction; in the compositor case the display server
>     will be incrementing frame count based on compositor drawing
> rather than vblank events
> so we thought a DRI2 solution was best here.  These particular calls
> are expected to block frequently, so I don't think latency is as big a
> concern as with some other operations (like SwapBuffers, but it also
> has the second issue mentioned above, so needs to be server side).
> 
> Comments?  If these look ok I'll push them into the dri2-swapbuffers
> branch and fix up DRI2SwapBuffers with the rest of the OML fields.

Updated with the DRI2SwapBuffers additions.

-- 
Jesse Barnes, Intel Open Source Technology Center

diff --git a/dri2proto.h b/dri2proto.h
index 37873c4..affa417 100644
--- a/dri2proto.h
+++ b/dri2proto.h
@@ -50,6 +50,9 @@
 #define X_DRI2CopyRegion               6
 #define X_DRI2GetBuffersWithFormat     7
 #define X_DRI2SwapBuffers              8
+#define X_DRI2GetMSC                   9
+#define X_DRI2WaitMSC                  10
+#define X_DRI2WaitSBC                  11
 
 typedef struct {
     CARD32  attachment B32;
@@ -197,7 +200,69 @@ typedef struct {
     CARD8   dri2ReqType;
     CARD16  length B16;
     CARD32  drawable B32;
+    CARD32  target_msc_hi B32;
+    CARD32  target_msc_lo B32;
+    CARD32  divisor_hi B32;
+    CARD32  divisor_lo B32;
+    CARD32  remainder_hi B32;
+    CARD32  remainder_lo B32;
 } xDRI2SwapBuffersReq;
-#define sz_xDRI2SwapBuffersReq   8
+#define sz_xDRI2SwapBuffersReq  32
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD16  length B16;
+    CARD32  swap_hi B32;
+    CARD32  swap_lo B32;
+} xDRI2SwapBuffersReply;
+#define sz_xDRI2SwapBuffersReply 14
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+} xDRI2GetMSCReq;
+#define sz_xDRI2GetMSCReq 8
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+    CARD32  target_msc_hi B32;
+    CARD32  target_msc_lo B32;
+    CARD32  divisor_hi B32;
+    CARD32  divisor_lo B32;
+    CARD32  remainder_hi B32;
+    CARD32  remainder_lo B32;
+} xDRI2WaitMSCReq;
+#define sz_xDRI2WaitMSCReq 26
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+    CARD32  target_sbc_hi B32;
+    CARD32  target_sbc_lo B32;
+} xDRI2WaitSBCReq;
+#define sz_xDRI2WaitSBCReq 16
+
+typedef struct {
+    CARD8   type;
+    CARD8   pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  ust_hi B32;
+    CARD32  ust_lo B32;
+    CARD32  msc_hi B32;
+    CARD32  msc_lo B32;
+    CARD32  sbc_hi B32;
+    CARD32  sbc_lo B32;
+} xDRI2MSCReply;
+#define sz_xDRI2MSCReply 32
 
 #endif
diff --git a/dri2proto.txt b/dri2proto.txt
index 1bad3b9..efc7c57 100644
--- a/dri2proto.txt
+++ b/dri2proto.txt
@@ -110,6 +110,18 @@ of the front and back buffers.  If the display server 
supports it, this
 operation may be preferred, since it may be easier and/or more performant
 for the server to perform a simple buffer swap rather than a blit.
 
+2.6 Synchronizing rendering
+
+DRI2 provides several methods for synchronizing drawing with various events.
+The protocol for these methods is based on the SGI_video_sync and
+OML_sync_control GLX extensions.  Using the DRI2WaitMSC request, a client
+can wait for a specific frame count or divisor/remainder before continuing
+its processing.  With the DRI2WaitSBC request, clients can block until a given
+swap count is reached (as incremented by DRI2SwapBuffers).  Finally, using
+DRI2SwapBuffers, clients can limit their frame rate by specifying a swap
+interval using the swap interval call (currently only available through GLX)
+or by using the OML swap buffers routine.
+
 
                             ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
 
@@ -297,17 +309,21 @@ The name of this extension is "DRI2".
     DRI2SwapBuffers
        drawable: DRAWABLE
       ▶        
-       buffers: LISTofDRI2BUFFER
+       count: two CARD32s
 └───
        Errors: Window
 
        Schedule a swap of the front and back buffers with the display
        server.
 
-       This request has no reply.  The server is expected to either perform
-       a buffer exchange or queue one before returning.  The client should
-       invalidate its render buffers after sending this request, causing
-       a subsequent GetBuffers request to get updated buffer info.
+       Returns the swap count value when the swap will actually occur.
+
+       The client should invalidate its render buffers after sending this
+       request, causing a subsequent GetBuffers request to get updated buffer
+       info.
+
+       This request is only available with protocol version 1.2 or
+       later.
 
 ┌───
     DRI2GetBuffersWithFormat
@@ -334,6 +350,68 @@ The name of this extension is "DRI2".
        This request is only available with protocol version 1.1 or
        later.
 
+┌───
+    DRI2GetMSC
+       drawable: DRAWABLE
+      ▶
+       ust, msc, sbc: CARD64
+└───
+       Errors: Window
+
+       Get the current media stamp counter (MSC) and swap buffer count (SBC)
+       along with the unadjusted system time (UST) when the MSC was last
+       incremented.
+
+       This request is only available with protocol version 1.2 or
+       later.
+
+┌───
+    DRI2WaitMSC
+       drawable: DRAWABLE
+       target_msc: two CARD32s
+       divisor: two CARD32s
+       remainder: two CARD32s
+      ▶
+       ust, msc, sbc: CARD64
+└───
+       Errors: Window
+
+       Blocks the client until either the frame count reaches target_msc or,
+       if the frame count is already greater than target_msc when the request
+       is received, until the frame count % divisor = remainder.  If divisor
+       is 0, the client will be unblocked if the frame count is greater than
+       or equal to the target_msc.
+
+       Returns the current media stamp counter (MSC) and swap buffer count
+       (SBC) along with the unadjusted system time (UST) when the MSC was last
+       incremented.
+
+       This request is only available with protocol version 1.2 or
+       later.
+
+┌───
+    DRI2WaitSBC
+       drawable: DRAWABLE
+       target_sbc: two CARD32s
+      ▶
+       ust, msc, sbc: CARD64
+└───
+       Errors: Window
+
+       Blocks the client until the swap buffer count reaches target_sbc.  If
+       the swap buffer count is already greater than or equal to target_sbc
+       when the request is recieved, this request will return immediately.
+
+       If target_sbc is 0, this request will block the client until all
+       previous DRI2SwapBuffers requests have completed.
+
+       Returns the current media stamp counter (MSC) and swap buffer count
+       (SBC) along with the unadjusted system time (UST) when the MSC was last
+       incremented.
+
+       This request is only available with protocol version 1.2 or
+       later.
+
                             ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
 
 
@@ -558,10 +636,6 @@ A.2 Protocol Requests
        5n      LISTofDRI2BUFFER        buffers
 └───
 
-A.3 Protocol Events
-
-The DRI2 extension specifies no events.
-
 ┌───
     DRI2SwapBuffers
        1       CARD8                   major opcode
@@ -583,6 +657,96 @@ The DRI2 extension specifies no events.
        5n      LISTofDRI2BUFFER        buffers
 └───
 
+┌───
+    DRI2SwapBuffers
+       1       CARD8                   major opcode
+       1       7                       DRI2 opcode
+       2       8                       length
+       4       DRAWABLE                drawable
+       4       CARD32                  target_msc_hi
+       4       CARD32                  target_msc_lo
+       4       CARD32                  divisor_hi
+       4       CARD32                  divisor_lo
+       4       CARD32                  remainder_hi
+       4       CARD32                  remainder_lo
+      ▶        
+       1       1                       Reply
+        1                              unused
+       2       CARD16                  sequence number
+       4       0                       reply length
+       4       CARD32                  swap_hi
+       4       CARD32                  swap_lo
+       5n      LISTofDRI2BUFFER        buffers
+└───
+
+┌───
+    DRI2GetMSC
+       1       CARD8                   major opcode
+       1       7                       DRI2 opcode
+       2       8                       length
+       4       DRAWABLE                drawable
+      ▶
+       1       1                       Reply
+        1                              unused
+       2       CARD16                  sequence number
+       4       0                       reply length
+       4       CARD32                  ust_hi
+       4       CARD32                  ust_lo
+       4       CARD32                  msc_hi
+       4       CARD32                  msc_lo
+       4       CARD32                  sbc_hi
+       4       CARD32                  sbc_lo
+└───
+
+┌───
+    DRI2WaitMSC
+       1       CARD8                   major opcode
+       1       7                       DRI2 opcode
+       2       8                       length
+       4       DRAWABLE                drawable
+       4       CARD32                  target_msc_hi
+       4       CARD32                  target_msc_lo
+       4       CARD32                  divisor_hi
+       4       CARD32                  divisor_lo
+       4       CARD32                  remainder_hi
+       4       CARD32                  remainder_lo
+      ▶
+       1       1                       Reply
+        1                              unused
+       2       CARD16                  sequence number
+       4       0                       reply length
+       4       CARD32                  ust_hi
+       4       CARD32                  ust_lo
+       4       CARD32                  msc_hi
+       4       CARD32                  msc_lo
+       4       CARD32                  sbc_hi
+       4       CARD32                  sbc_lo
+└───
+
+┌───
+    DRI2WaitSBC
+       1       CARD8                   major opcode
+       1       7                       DRI2 opcode
+       2       8                       length
+       4       DRAWABLE                drawable
+       4       CARD32                  swap_hi
+       4       CARD32                  swap_lo
+     ▶
+       1       1                       Reply
+        1                              unused
+       2       CARD16                  sequence number
+       4       0                       reply length
+       4       CARD32                  ust_hi
+       4       CARD32                  ust_lo
+       4       CARD32                  msc_hi
+       4       CARD32                  msc_lo
+       4       CARD32                  sbc_hi
+       4       CARD32                  sbc_lo
+└───
+
+A.3 Protocol Events
+
+The DRI2 extension specifies no events.
 
 A.4 Protocol Errors
 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to