[v2,xserver,1/2] glamor: Add glamor_shareable_fd_from_pixmap()

Submitted by Hans de Goede on Aug. 23, 2016, 10:30 a.m.

Details

Message ID 20160823103022.966-1-hdegoede@redhat.com
State Accepted
Commit a74d553cb97d545148bd2f81b7bd021cca94e076
Headers show
Series "Series without cover letter" ( rev: 1 ) in X.org (DEPRECATED - USE GITLAB)

Not browsing as part of any series.

Commit Message

Hans de Goede Aug. 23, 2016, 10:30 a.m.
Add glamor_shareable_fd_from_pixmap function to get dma-buf fds suitable
for sharing across GPUs (not using GPU specific tiling).

This is necessary for the modesetting driver to correctly implement
the DRI2 SharePixmapBacking callback.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 glamor/glamor.c | 20 ++++++++++++++++++++
 glamor/glamor.h | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+)

Patch hide | download patch | download mbox

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 5ba440c..903f6bd 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -821,6 +821,26 @@  glamor_fd_from_pixmap(ScreenPtr screen,
     return -1;
 }
 
+_X_EXPORT int
+glamor_shareable_fd_from_pixmap(ScreenPtr screen,
+                                PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
+{
+    unsigned orig_usage_hint = pixmap->usage_hint;
+    int ret;
+
+    /*
+     * The actual difference between a sharable and non sharable buffer
+     * is decided 4 call levels deep in glamor_make_pixmap_exportable()
+     * based on pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED
+     * 2 of those calls are also exported API, so we cannot just add a flag.
+     */
+    pixmap->usage_hint = CREATE_PIXMAP_USAGE_SHARED;
+    ret = glamor_fd_from_pixmap(screen, pixmap, stride, size);
+    pixmap->usage_hint = orig_usage_hint;
+
+    return ret;
+}
+
 int
 glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
 {
diff --git a/glamor/glamor.h b/glamor/glamor.h
index e27033a..bdd2374 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -181,6 +181,26 @@  extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen,
                                            PixmapPtr pixmap,
                                            CARD16 *stride, CARD32 *size);
 
+/* @glamor_shareable_fd_from_pixmap: Get a dma-buf fd suitable for sharing
+ *				     with other GPUs from a pixmap.
+ *
+ * @screen: Current screen pointer.
+ * @pixmap: The pixmap from which we want the fd.
+ * @stride, @size: Pointers to fill the stride and size of the
+ * 		   buffer associated to the fd.
+ *
+ * The returned fd will point to a buffer which is suitable for sharing
+ * across GPUs (not using GPU specific tiling).
+ * The pixmap and the buffer associated by the fd will share the same
+ * content.
+ * The pixmap's stride may be modified by this function.
+ * Returns the fd on success, -1 on error.
+ * */
+extern _X_EXPORT int glamor_shareable_fd_from_pixmap(ScreenPtr screen,
+                                                     PixmapPtr pixmap,
+                                                     CARD16 *stride,
+                                                     CARD32 *size);
+
 /**
  * @glamor_name_from_pixmap: Gets a gem name from a pixmap.
  *

Comments

Hans de Goede <hdegoede@redhat.com> writes:

> Add glamor_shareable_fd_from_pixmap function to get dma-buf fds suitable
> for sharing across GPUs (not using GPU specific tiling).
>
> This is necessary for the modesetting driver to correctly implement
> the DRI2 SharePixmapBacking callback.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

For the series:

Reviewed-by: Keith Packard <keithp@keithp.com>
Hi,

On 24-08-16 20:48, Keith Packard wrote:
> Hans de Goede <hdegoede@redhat.com> writes:
>
>> Add glamor_shareable_fd_from_pixmap function to get dma-buf fds suitable
>> for sharing across GPUs (not using GPU specific tiling).
>>
>> This is necessary for the modesetting driver to correctly implement
>> the DRI2 SharePixmapBacking callback.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> For the series:
>
> Reviewed-by: Keith Packard <keithp@keithp.com>

Thanks.

It would also be great to get your input on my reply to
Airlied's "modesetting: prefer primary crtc when picking over nothing"
and/or my series starting with:
"modesetting: ms_covering_crtc: Remove unused arguments, make static"
which solves the same problem, but then only for showing DRI3
buffers on slave-outputs (which currently gets throttled
to 1 fps with the modesetting driver though).

I've a slight preference for Airlied's fix actually since
all 3 major drivers (intel, nouveau, ati) seem to do the
same so chances are that epiphany is not the only driver
depending on this.

Regards,

Hans

p.s.

About my series for the throttling on slave output's
I'm working on a v2 which will not fallback to the
primary crtc if that is DPMSOff, but the basic principle
will be unchanged.