• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2009, VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 /*
28  * Author: Keith Whitwell <keithw@vmware.com>
29  * Author: Jakob Bornecrantz <wallbraker@gmail.com>
30  */
31 
32 #ifndef DRI_SCREEN_H
33 #define DRI_SCREEN_H
34 
35 #include "dri_util.h"
36 
37 #include "util/compiler.h"
38 #include "pipe/p_context.h"
39 #include "pipe/p_state.h"
40 #include "frontend/api.h"
41 #include "frontend/opencl_interop.h"
42 #include "util/u_thread.h"
43 #include "postprocess/filters.h"
44 #include "kopper_interface.h"
45 
46 struct dri_context;
47 struct dri_drawable;
48 struct pipe_loader_device;
49 
50 struct dri_screen
51 {
52    /* st_api */
53    struct pipe_frontend_screen base;
54 
55    /* dri */
56    /* Current screen's number */
57    int myNum;
58 
59    void *loaderPrivate;
60 
61    int max_gl_core_version;
62    int max_gl_compat_version;
63    int max_gl_es1_version;
64    int max_gl_es2_version;
65 
66    enum dri_screen_type type;
67 
68    const __DRIswrastLoaderExtension *swrast_loader;
69    const __DRIkopperLoaderExtension *kopper_loader;
70 
71    struct {
72        /* Flag to indicate that this is a DRI2 screen.  Many of the above
73         * fields will not be valid or initializaed in that case. */
74        const __DRIdri2LoaderExtension *loader;
75        const __DRIimageLookupExtension *image;
76        const __DRIuseInvalidateExtension *useInvalidate;
77        const __DRIbackgroundCallableExtension *backgroundCallable;
78    } dri2;
79 
80    struct {
81        const __DRIimageLoaderExtension *loader;
82    } image;
83 
84    struct {
85       const __DRImutableRenderBufferLoaderExtension *loader;
86    } mutableRenderBuffer;
87 
88    driOptionCache optionInfo;
89    driOptionCache optionCache;
90 
91    unsigned int api_mask;
92 
93    bool throttle;
94    bool dmabuf_import;
95 
96    struct st_config_options options;
97 
98    /* Which postprocessing filters are enabled. */
99    unsigned pp_enabled[PP_FILTERS];
100 
101    /* drm */
102    int fd;
103    bool can_share_buffer;
104 
105    struct pipe_loader_device *dev;
106 
107    /* gallium */
108    bool auto_fake_front;
109    bool has_reset_status_query;
110    bool has_protected_context;
111    enum pipe_texture_target target;
112 
113    bool swrast_no_present;
114 
115    /* DRI exts that vary based on gallium pipe_screen caps. */
116    __DRIimageExtension image_extension;
117    __DRI2bufferDamageExtension buffer_damage_extension;
118 
119    /* DRI exts on this screen. Populated at init time based on device caps. */
120    const __DRIextension *screen_extensions[14];
121 
122    /* OpenCL interop */
123    mtx_t opencl_func_mutex;
124    opencl_dri_event_add_ref_t opencl_dri_event_add_ref;
125    opencl_dri_event_release_t opencl_dri_event_release;
126    opencl_dri_event_wait_t opencl_dri_event_wait;
127    opencl_dri_event_get_fence_t opencl_dri_event_get_fence;
128 
129    /* kopper */
130    bool has_dmabuf;
131    bool is_sw;
132 };
133 
134 static inline const __DRIkopperLoaderExtension *
dri_screen_get_kopper(struct dri_screen * screen)135 dri_screen_get_kopper(struct dri_screen *screen)
136 {
137    return screen->kopper_loader;
138 }
139 
140 struct dri_image {
141    struct pipe_resource *texture;
142    unsigned level;
143    unsigned layer;
144    uint32_t dri_format;
145    uint32_t dri_fourcc;
146    uint32_t dri_components;
147    /* Provided by eglCreateImageKHR if creating from a
148     * texture or a renderbuffer. 0 otherwise.
149     */
150    uint32_t internal_format;
151    unsigned use;
152    unsigned plane;
153 
154    int in_fence_fd;
155 
156    void *loader_private;
157 
158    bool imported_dmabuf;
159    /**
160     * Provided by EGL_EXT_image_dma_buf_import.
161     */
162    enum __DRIYUVColorSpace yuv_color_space;
163    enum __DRISampleRange sample_range;
164    enum __DRIChromaSiting horizontal_siting;
165    enum __DRIChromaSiting vertical_siting;
166 
167    struct dri_screen *screen;
168 };
169 
170 static inline bool
dri_with_format(struct dri_screen * screen)171 dri_with_format(struct dri_screen *screen)
172 {
173    const __DRIdri2LoaderExtension *loader = screen->dri2.loader;
174 
175    return loader
176        && (loader->base.version >= 3)
177        && (loader->getBuffersWithFormat != NULL);
178 }
179 
180 void
181 dri_fill_st_visual(struct st_visual *stvis,
182                    const struct dri_screen *screen,
183                    const struct gl_config *mode);
184 
185 void
186 dri_init_options(struct dri_screen *screen);
187 
188 const struct dri_config **
189 dri_init_screen(struct dri_screen *screen,
190                 struct pipe_screen *pscreen,
191                 bool has_multibuffer);
192 
193 void
194 dri_release_screen(struct dri_screen * screen);
195 
196 void
197 dri_destroy_screen(struct dri_screen *screen);
198 
199 struct pipe_screen *
200 dri2_init_screen(struct dri_screen *screen, bool driver_name_is_inferred);
201 struct pipe_screen *
202 dri_swrast_kms_init_screen(struct dri_screen *screen, bool driver_name_is_inferred);
203 struct pipe_screen *
204 kopper_init_screen(struct dri_screen *screen, bool driver_name_is_inferred);
205 struct pipe_screen *
206 drisw_init_screen(struct dri_screen *screen, bool driver_name_is_inferred);
207 
208 extern const struct __DriverAPIRec dri_swrast_kms_driver_api;
209 extern const __DRIextension *dri_swrast_kms_driver_extensions[];
210 extern const struct __DriverAPIRec galliumdrm_driver_api;
211 extern const __DRIextension *galliumdrm_driver_extensions[];
212 extern const struct __DriverAPIRec galliumsw_driver_api;
213 extern const __DRIextension *galliumsw_driver_extensions[];
214 extern const struct __DriverAPIRec galliumvk_driver_api;
215 extern const __DRIextension *galliumvk_driver_extensions[];
216 extern const __DRIconfigOptionsExtension gallium_config_options;
217 
218 #endif
219 
220 /* vim: set sw=3 ts=8 sts=3 expandtab: */
221