1 /* 2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26 /** 27 * \file dri_util.h 28 * DRI utility functions definitions. 29 * 30 * \author Kevin E. Martin <kevin@precisioninsight.com> 31 * \author Brian Paul <brian@precisioninsight.com> 32 */ 33 34 #ifndef _DRI_UTIL_H_ 35 #define _DRI_UTIL_H_ 36 37 #include <GL/gl.h> 38 #include <GL/internal/dri_interface.h> 39 #include "kopper_interface.h" 40 #include "main/formats.h" 41 #include "main/glconfig.h" 42 #include "main/menums.h" 43 #include "util/xmlconfig.h" 44 #include <stdbool.h> 45 46 struct dri_screen; 47 48 #define __DRI_BACKEND_VTABLE "DRI_DriverVtable" 49 50 struct __DRIconfigRec { 51 struct gl_config modes; 52 }; 53 54 /** 55 * Extensions. 56 */ 57 extern const __DRIcoreExtension driCoreExtension; 58 extern const __DRIswrastExtension driSWRastExtension; 59 extern const __DRIdri2Extension driDRI2Extension; 60 extern const __DRIdri2Extension swkmsDRI2Extension; 61 extern const __DRI2configQueryExtension dri2ConfigQueryExtension; 62 extern const __DRI2flushControlExtension dri2FlushControlExtension; 63 64 /** 65 * Description of the attributes used to create a config. 66 * 67 * This is passed as the context_config parameter to CreateContext. The idea 68 * with this struct is that it can be extended without having to modify all of 69 * the drivers. The first three members (major/minor_version and flags) are 70 * always valid, but the remaining members are only valid if the corresponding 71 * flag is set for the attribute. If the flag is not set then the default 72 * value should be assumed. That way the driver can quickly check if any 73 * attributes were set that it doesn't understand and report an error. 74 */ 75 struct __DriverContextConfig { 76 /* These members are always valid */ 77 unsigned major_version; 78 unsigned minor_version; 79 uint32_t flags; 80 81 /* Flags describing which of the remaining members are valid */ 82 uint32_t attribute_mask; 83 84 /* Only valid if __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY is set */ 85 int reset_strategy; 86 87 /* Only valid if __DRIVER_CONTEXT_PRIORITY is set */ 88 unsigned priority; 89 90 /* Only valid if __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR is set */ 91 int release_behavior; 92 93 /* Only valid if __DRIVER_CONTEXT_ATTRIB_NO_ERROR is set */ 94 int no_error; 95 96 /* Only valid if __DRIVER_CONTEXT_ATTRIB_PROTECTED is set */ 97 int protected_context; 98 }; 99 100 #define __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY (1 << 0) 101 #define __DRIVER_CONTEXT_ATTRIB_PRIORITY (1 << 1) 102 #define __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR (1 << 2) 103 #define __DRIVER_CONTEXT_ATTRIB_NO_ERROR (1 << 3) 104 #define __DRIVER_CONTEXT_ATTRIB_PROTECTED (1 << 4) 105 106 __DRIscreen * 107 driCreateNewScreen2(int scrn, int fd, 108 const __DRIextension **loader_extensions, 109 const __DRIextension **driver_extensions, 110 const __DRIconfig ***driver_configs, void *data); 111 __DRIcontext * 112 driCreateContextAttribs(__DRIscreen *psp, int api, 113 const __DRIconfig *config, 114 __DRIcontext *shared, 115 unsigned num_attribs, 116 const uint32_t *attribs, 117 unsigned *error, 118 void *data); 119 120 extern uint32_t 121 driGLFormatToImageFormat(mesa_format format); 122 123 extern uint32_t 124 driGLFormatToSizedInternalGLFormat(mesa_format format); 125 126 extern mesa_format 127 driImageFormatToGLFormat(uint32_t image_format); 128 129 extern const __DRIimageDriverExtension driImageDriverExtension; 130 131 #endif /* _DRI_UTIL_H_ */ 132