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 "pipe/p_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 "os/os_thread.h"
43#include "postprocess/filters.h"
44#include "kopper_interface.h"
45
46struct dri_context;
47struct dri_drawable;
48struct pipe_loader_device;
49
50struct dri_screen
51{
52   /* st_api */
53   struct st_manager base;
54   struct st_api *st_api;
55
56   /* dri */
57   __DRIscreen *sPriv;
58   boolean throttle;
59
60   struct st_config_options options;
61
62   /* Which postprocessing filters are enabled. */
63   unsigned pp_enabled[PP_FILTERS];
64
65   /* drm */
66   int fd;
67   boolean can_share_buffer;
68
69   struct pipe_loader_device *dev;
70
71   /* gallium */
72   boolean d_depth_bits_last;
73   boolean sd_depth_bits_last;
74   boolean auto_fake_front;
75   boolean has_reset_status_query;
76   enum pipe_texture_target target;
77
78   boolean swrast_no_present;
79
80   /* hooks filled in by dri2 & drisw */
81   __DRIimage * (*lookup_egl_image)(struct dri_screen *ctx, void *handle);
82   boolean (*validate_egl_image)(struct dri_screen *ctx, void *handle);
83   __DRIimage * (*lookup_egl_image_validated)(struct dri_screen *ctx, void *handle);
84
85   /* DRI exts that vary based on gallium pipe_screen caps. */
86   __DRIimageExtension image_extension;
87   __DRI2bufferDamageExtension buffer_damage_extension;
88
89   /* DRI exts on this screen. Populated at init time based on device caps. */
90   const __DRIextension *screen_extensions[14];
91
92   /* OpenCL interop */
93   mtx_t opencl_func_mutex;
94   opencl_dri_event_add_ref_t opencl_dri_event_add_ref;
95   opencl_dri_event_release_t opencl_dri_event_release;
96   opencl_dri_event_wait_t opencl_dri_event_wait;
97   opencl_dri_event_get_fence_t opencl_dri_event_get_fence;
98};
99
100/** cast wrapper */
101static inline struct dri_screen *
102dri_screen(__DRIscreen * sPriv)
103{
104   return (struct dri_screen *)sPriv->driverPrivate;
105}
106
107static inline const __DRIkopperLoaderExtension *
108dri_screen_get_kopper(struct dri_screen *screen)
109{
110   return screen->sPriv->kopper_loader;
111}
112
113struct __DRIimageRec {
114   struct pipe_resource *texture;
115   unsigned level;
116   unsigned layer;
117   uint32_t dri_format;
118   uint32_t dri_fourcc;
119   uint32_t dri_components;
120   /* Provided by eglCreateImageKHR if creating from a
121    * texture or a renderbuffer. 0 otherwise.
122    */
123   uint32_t internal_format;
124   unsigned use;
125   unsigned plane;
126
127   int in_fence_fd;
128
129   void *loader_private;
130
131   boolean imported_dmabuf;
132   /**
133    * Provided by EGL_EXT_image_dma_buf_import.
134    */
135   enum __DRIYUVColorSpace yuv_color_space;
136   enum __DRISampleRange sample_range;
137   enum __DRIChromaSiting horizontal_siting;
138   enum __DRIChromaSiting vertical_siting;
139
140   /* DRI loader screen */
141   __DRIscreen *sPriv;
142};
143
144static inline boolean
145dri_with_format(__DRIscreen * sPriv)
146{
147   const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader;
148
149   return loader
150       && (loader->base.version >= 3)
151       && (loader->getBuffersWithFormat != NULL);
152}
153
154void
155dri_fill_st_visual(struct st_visual *stvis,
156                   const struct dri_screen *screen,
157                   const struct gl_config *mode);
158
159void
160dri_init_options(struct dri_screen *screen);
161
162const __DRIconfig **
163dri_init_screen_helper(struct dri_screen *screen,
164                       struct pipe_screen *pscreen);
165
166void
167dri_destroy_screen_helper(struct dri_screen * screen);
168
169void
170dri_destroy_screen(__DRIscreen * sPriv);
171
172extern const struct __DriverAPIRec dri_swrast_kms_driver_api;
173extern const __DRIextension *dri_swrast_kms_driver_extensions[];
174extern const struct __DriverAPIRec galliumdrm_driver_api;
175extern const __DRIextension *galliumdrm_driver_extensions[];
176extern const struct __DriverAPIRec galliumsw_driver_api;
177extern const __DRIextension *galliumsw_driver_extensions[];
178extern const struct __DriverAPIRec galliumvk_driver_api;
179extern const __DRIextension *galliumvk_driver_extensions[];
180extern const __DRIconfigOptionsExtension gallium_config_options;
181
182#endif
183
184/* vim: set sw=3 ts=8 sts=3 expandtab: */
185