• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2013 Keith Packard
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that copyright
7  * notice and this permission notice appear in supporting documentation, and
8  * that the name of the copyright holders not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  The copyright holders make no representations
11  * about the suitability of this software for any purpose.  It is provided "as
12  * is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20  * OF THIS SOFTWARE.
21  */
22 
23 /* This file was derived from dri2_priv.h which carries the following
24  * copyright:
25  *
26  * Copyright © 2008 Red Hat, Inc.
27  *
28  * Permission is hereby granted, free of charge, to any person obtaining a
29  * copy of this software and associated documentation files (the "Soft-
30  * ware"), to deal in the Software without restriction, including without
31  * limitation the rights to use, copy, modify, merge, publish, distribute,
32  * and/or sell copies of the Software, and to permit persons to whom the
33  * Software is furnished to do so, provided that the above copyright
34  * notice(s) and this permission notice appear in all copies of the Soft-
35  * ware and that both the above copyright notice(s) and this permission
36  * notice appear in supporting documentation.
37  *
38  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
39  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
40  * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
41  * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
42  * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
43  * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
44  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
45  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
46  * MANCE OF THIS SOFTWARE.
47  *
48  * Except as contained in this notice, the name of a copyright holder shall
49  * not be used in advertising or otherwise to promote the sale, use or
50  * other dealings in this Software without prior written authorization of
51  * the copyright holder.
52  *
53  * Authors:
54  *   Kristian Høgsberg (krh@redhat.com)
55  */
56 
57 #include <xcb/xcb.h>
58 #include <xcb/dri3.h>
59 #include <xcb/present.h>
60 #include <xcb/sync.h>
61 
62 #include "loader_dri3_helper.h"
63 #include "GL/internal/mesa_interface.h"
64 
65 struct dri3_display
66 {
67    __GLXDRIdisplay base;
68 
69    const __DRIextension **loader_extensions;
70    int has_multibuffer;
71 };
72 
73 struct dri3_screen {
74    struct glx_screen base;
75 
76    __GLXDRIscreen vtable;
77 
78    /* DRI screen is created for display GPU in case of prime gpu offloading.
79     * This screen is used to allocate linear_buffer from
80     * display GPU space in dri3_alloc_render_buffer() function.
81     * In case of not gpu offloading driScreenDisplayGPU will be assigned with
82     * driScreenRenderGPU.
83     * In case of prime gpu offloading if display and render driver names are different
84     * (potentially not compatible), driScreenDisplayGPU will be NULL but
85     * fd_display_gpu will still hold fd for display driver.
86     */
87    __DRIscreen *driScreenDisplayGPU;
88    __DRIscreen *driScreenRenderGPU;
89 
90    const __DRIimageExtension *image;
91    const __DRIimageDriverExtension *image_driver;
92    const __DRIcoreExtension *core;
93    const __DRImesaCoreExtension *mesa;
94    const __DRI2flushExtension *f;
95    const __DRI2configQueryExtension *config;
96    const __DRItexBufferExtension *texBuffer;
97    const __DRI2rendererQueryExtension *rendererQuery;
98    const __DRI2interopExtension *interop;
99    const __DRIconfig **driver_configs;
100 
101    void *driver;
102    /* fd of the GPU used for rendering. */
103    int fd_render_gpu;
104    /* fd of the GPU used for display. If the same GPU is used for display
105     * and rendering, then fd_render_gpu == fd_display_gpu (no need to use
106     * os_same_file_description).
107     */
108    int fd_display_gpu;
109    bool prefer_back_buffer_reuse;
110 
111    struct loader_dri3_extensions loader_dri3_ext;
112 };
113 
114 struct dri3_drawable {
115    __GLXDRIdrawable base;
116    struct loader_dri3_drawable loader_drawable;
117 
118    /* LIBGL_SHOW_FPS support */
119    uint64_t previous_ust;
120    unsigned frames;
121 };
122 
123 bool
124 dri3_check_multibuffer(Display * dpy, bool *err);
125 
126 _X_HIDDEN int
127 dri3_query_renderer_integer(struct glx_screen *base, int attribute,
128                             unsigned int *value);
129 
130 _X_HIDDEN int
131 dri3_query_renderer_string(struct glx_screen *base, int attribute,
132                            const char **value);
133 
134 _X_HIDDEN int
135 dri3_interop_query_device_info(struct glx_context *ctx,
136                                struct mesa_glinterop_device_info *out);
137 
138 _X_HIDDEN int
139 dri3_interop_export_object(struct glx_context *ctx,
140                            struct mesa_glinterop_export_in *in,
141                            struct mesa_glinterop_export_out *out);
142 
143 _X_HIDDEN int
144 dri3_interop_flush_objects(struct glx_context *ctx,
145                            unsigned count, struct mesa_glinterop_export_in *objects,
146                            struct mesa_glinterop_flush_out *out);
147