[RFC xserver 04/12] dri3: Implement FenceFromDMAFenceFD and DMAFenceFDFromFence

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Wed Aug 30 05:16:53 UTC 2017


Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
 dri3/dri3_request.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 2 deletions(-)

diff --git a/dri3/dri3_request.c b/dri3/dri3_request.c
index f111dc46b..4192b3521 100644
--- a/dri3/dri3_request.c
+++ b/dri3/dri3_request.c
@@ -526,13 +526,67 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
 static int
 proc_dri3_fence_from_dma_fence_fd(ClientPtr client)
 {
-    return BadImplementation;
+    REQUEST(xDRI3FenceFromDMAFenceFDReq);
+    DrawablePtr drawable;
+    int fd;
+    int status;
+
+    SetReqFds(client, 1);
+    REQUEST_SIZE_MATCH(xDRI3FenceFromDMAFenceFDReq);
+    LEGAL_NEW_RESOURCE(stuff->fence, client);
+
+    status = dixLookupDrawable(&drawable, stuff->drawable, client, M_ANY, DixGetAttrAccess);
+    if (status != Success)
+        return status;
+
+    fd = ReadFdFromClient(client);
+    if (fd < 0)
+        return BadValue;
+
+    status = SyncCreateFenceFromDMAFenceFD(client, drawable, stuff->fence, fd);
+    close(fd);
+
+    return status;
 }
 
 static int
 proc_dri3_dma_fence_fd_from_fence(ClientPtr client)
 {
-    return BadImplementation;
+    REQUEST(xDRI3DMAFenceFDFromFenceReq);
+    xDRI3DMAFenceFDFromFenceReply rep = {
+        .type = X_Reply,
+        .nfd = 1,
+        .sequenceNumber = client->sequence,
+        .length = 0,
+    };
+    DrawablePtr drawable;
+    int fd;
+    int status;
+    SyncFence *fence;
+
+    REQUEST_SIZE_MATCH(xDRI3DMAFenceFDFromFenceReq);
+
+    status = dixLookupDrawable(&drawable, stuff->drawable, client, M_ANY, DixGetAttrAccess);
+    if (status != Success)
+        return status;
+    status = SyncVerifyFence(&fence, stuff->fence, client, DixWriteAccess);
+    if (status != Success)
+        return status;
+
+    fd = SyncDMAFenceFDFromFence(client, drawable, fence);
+    if (fd < 0)
+        return BadMatch;
+
+    if (client->swapped) {
+        swaps(&rep.sequenceNumber);
+        swapl(&rep.length);
+    }
+    if (WriteFdToClient(client, fd, FALSE) < 0)
+        return BadAlloc;
+
+    WriteToClient(client, sizeof(rep), &rep);
+
+    return Success;
 }
 
 int (*proc_dri3_vector[DRI3NumberRequests]) (ClientPtr) = {
-- 
2.13.0



More information about the xorg-devel mailing list