Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 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 | |
Boyan Ding | fdacbc4 | 2015-07-21 23:43:55 +0800 | [diff] [blame] | 62 | #include "loader_dri3_helper.h" |
| 63 | |
Eric Engestrom | 04e8eaf | 2020-06-12 11:42:32 +0200 | [diff] [blame] | 64 | /* From driconf.h, user exposed so should be stable */ |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 65 | #define DRI_CONF_VBLANK_NEVER 0 |
| 66 | #define DRI_CONF_VBLANK_DEF_INTERVAL_0 1 |
| 67 | #define DRI_CONF_VBLANK_DEF_INTERVAL_1 2 |
| 68 | #define DRI_CONF_VBLANK_ALWAYS_SYNC 3 |
| 69 | |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 70 | struct dri3_display |
| 71 | { |
| 72 | __GLXDRIdisplay base; |
| 73 | |
Emil Velikov | ecfe986 | 2014-03-16 01:17:46 +0000 | [diff] [blame] | 74 | const __DRIextension **loader_extensions; |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 75 | |
| 76 | /* DRI3 bits */ |
| 77 | int dri3Major; |
| 78 | int dri3Minor; |
| 79 | |
| 80 | /* Present bits */ |
| 81 | int hasPresent; |
| 82 | int presentMajor; |
| 83 | int presentMinor; |
| 84 | }; |
| 85 | |
| 86 | struct dri3_screen { |
| 87 | struct glx_screen base; |
| 88 | |
| 89 | __DRIscreen *driScreen; |
| 90 | __GLXDRIscreen vtable; |
| 91 | |
| 92 | const __DRIimageExtension *image; |
| 93 | const __DRIimageDriverExtension *image_driver; |
| 94 | const __DRIcoreExtension *core; |
| 95 | const __DRI2flushExtension *f; |
| 96 | const __DRI2configQueryExtension *config; |
| 97 | const __DRItexBufferExtension *texBuffer; |
Ian Romanick | 625bdd6 | 2014-02-20 11:47:14 -0800 | [diff] [blame] | 98 | const __DRI2rendererQueryExtension *rendererQuery; |
Marek Olšák | 37d3a26 | 2016-03-03 18:43:53 +0100 | [diff] [blame] | 99 | const __DRI2interopExtension *interop; |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 100 | const __DRIconfig **driver_configs; |
| 101 | |
| 102 | void *driver; |
| 103 | int fd; |
Eric Engestrom | 4a1238a | 2017-06-19 00:16:51 +0100 | [diff] [blame] | 104 | bool is_different_gpu; |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 105 | |
Kenneth Graunke | 26122e0 | 2014-03-14 18:53:42 -0700 | [diff] [blame] | 106 | int show_fps_interval; |
Boyan Ding | fdacbc4 | 2015-07-21 23:43:55 +0800 | [diff] [blame] | 107 | |
| 108 | struct loader_dri3_extensions loader_dri3_ext; |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct dri3_context |
| 112 | { |
| 113 | struct glx_context base; |
| 114 | __DRIcontext *driContext; |
| 115 | }; |
| 116 | |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 117 | struct dri3_drawable { |
| 118 | __GLXDRIdrawable base; |
Boyan Ding | fdacbc4 | 2015-07-21 23:43:55 +0800 | [diff] [blame] | 119 | struct loader_dri3_drawable loader_drawable; |
Kenneth Graunke | 26122e0 | 2014-03-14 18:53:42 -0700 | [diff] [blame] | 120 | |
| 121 | /* LIBGL_SHOW_FPS support */ |
| 122 | uint64_t previous_ust; |
| 123 | unsigned frames; |
Keith Packard | 2d94601 | 2013-11-04 18:15:51 -0800 | [diff] [blame] | 124 | }; |
Jon TURNEY | 3fe7dae | 2014-08-17 17:22:22 +0100 | [diff] [blame] | 125 | |
| 126 | |
| 127 | _X_HIDDEN int |
| 128 | dri3_query_renderer_integer(struct glx_screen *base, int attribute, |
| 129 | unsigned int *value); |
| 130 | |
| 131 | _X_HIDDEN int |
| 132 | dri3_query_renderer_string(struct glx_screen *base, int attribute, |
| 133 | const char **value); |
Marek Olšák | 37d3a26 | 2016-03-03 18:43:53 +0100 | [diff] [blame] | 134 | |
| 135 | _X_HIDDEN int |
| 136 | dri3_interop_query_device_info(struct glx_context *ctx, |
Emil Velikov | 13faddb | 2016-05-30 10:56:33 +0100 | [diff] [blame] | 137 | struct mesa_glinterop_device_info *out); |
Marek Olšák | 37d3a26 | 2016-03-03 18:43:53 +0100 | [diff] [blame] | 138 | |
| 139 | _X_HIDDEN int |
| 140 | dri3_interop_export_object(struct glx_context *ctx, |
Emil Velikov | 13faddb | 2016-05-30 10:56:33 +0100 | [diff] [blame] | 141 | struct mesa_glinterop_export_in *in, |
| 142 | struct mesa_glinterop_export_out *out); |