svga/winsys: Implement surface sharing using prime fd handles
[mesa.git] / src / gallium / targets / dri-vmwgfx / target.c
1
2 #include "target-helpers/inline_wrapper_sw_helper.h"
3 #include "target-helpers/inline_debug_helper.h"
4 #include "state_tracker/drm_driver.h"
5 #include "svga/drm/svga_drm_public.h"
6 #include "svga/svga_public.h"
7
8 static struct pipe_screen *
9 create_screen(int fd)
10 {
11 struct svga_winsys_screen *sws;
12 struct pipe_screen *screen;
13
14 sws = svga_drm_winsys_screen_create(fd);
15 if (!sws)
16 return NULL;
17
18 screen = svga_screen_create(sws);
19 if (!screen)
20 return NULL;
21
22 screen = sw_screen_wrap(screen);
23
24 screen = debug_screen_wrap(screen);
25
26 return screen;
27 }
28
29 static const struct drm_conf_ret throttle_ret = {
30 .type = DRM_CONF_INT,
31 .val.val_int = 2,
32 };
33
34 /* Technically this requires kernel support that is not yet
35 * widespread.
36 *
37 * We could check for support in create_screen and return the correct
38 * value, but for now just return true in all cases.
39 */
40 static const struct drm_conf_ret share_fd_ret = {
41 .type = DRM_CONF_BOOL,
42 .val.val_int = true,
43 };
44
45 static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
46 {
47 switch (conf) {
48 case DRM_CONF_THROTTLE:
49 return &throttle_ret;
50 case DRM_CONF_SHARE_FD:
51 return &share_fd_ret;
52 default:
53 break;
54 }
55 return NULL;
56 }
57
58 DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen, drm_configuration)