drisw: learn to query shmid handle type
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Mon, 15 Jun 2015 12:48:27 +0000 (14:48 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 29 May 2018 23:11:54 +0000 (09:11 +1000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
src/gallium/include/state_tracker/drisw_api.h
src/gallium/include/state_tracker/sw_winsys.h
src/gallium/include/state_tracker/winsys_handle.h
src/gallium/winsys/sw/dri/dri_sw_winsys.c

index 36bef087a4f6855379c6479bdbe97a416a86c3ab..e365ab81f185f2290969795d8a3d5a5df31d3d27 100644 (file)
@@ -2,6 +2,7 @@
 #define _DRISW_API_H_
 
 #include "pipe/p_compiler.h"
+#include "sw_winsys.h"
 
 struct pipe_screen;
 struct dri_drawable;
index 0b792cd0ce4c4e9c82374cbfecaf6203dd3026b6..cd5838ad1d8be6eb5338edb71a6aaa8b4ac644ad 100644 (file)
 
 #include "pipe/p_compiler.h" /* for boolean */
 #include "pipe/p_format.h"
-
+#include "state_tracker/winsys_handle.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
-struct winsys_handle;
 struct pipe_screen;
 struct pipe_context;
 struct pipe_resource;
index 746e87683a7d7b4141af25a42a77e746161a0061..167c1a937fda696f123207b7a63b1bdca7be8831 100644 (file)
@@ -9,6 +9,7 @@ extern "C" {
 #define WINSYS_HANDLE_TYPE_SHARED 0
 #define WINSYS_HANDLE_TYPE_KMS    1
 #define WINSYS_HANDLE_TYPE_FD     2
+#define WINSYS_HANDLE_TYPE_SHMID   3
 
 /**
  * For use with pipe_screen::{texture_from_handle|texture_get_handle}.
index b36a53e960cc99115724ef00374f8a9c80c7a459..8335e52200fc9d35d26d33e1dec1a2ffbfa9157d 100644 (file)
@@ -209,7 +209,15 @@ dri_sw_displaytarget_get_handle(struct sw_winsys *winsys,
                                 struct sw_displaytarget *dt,
                                 struct winsys_handle *whandle)
 {
-   assert(0);
+   struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+
+   if (whandle->type == WINSYS_HANDLE_TYPE_SHMID) {
+      if (dri_sw_dt->shmid < 0)
+         return FALSE;
+      whandle->handle = dri_sw_dt->shmid;
+      return TRUE;
+   }
+
    return FALSE;
 }