1848b8605Smrg/* 2848b8605Smrg * (C) Copyright IBM Corporation 2002, 2004 3848b8605Smrg * All Rights Reserved. 4848b8605Smrg * 5848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6848b8605Smrg * copy of this software and associated documentation files (the "Software"), 7848b8605Smrg * to deal in the Software without restriction, including without limitation 8848b8605Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub 9848b8605Smrg * license, and/or sell copies of the Software, and to permit persons to whom 10848b8605Smrg * the Software is furnished to do so, subject to the following conditions: 11848b8605Smrg * 12848b8605Smrg * The above copyright notice and this permission notice (including the next 13848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the 14848b8605Smrg * Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20848b8605Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21848b8605Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22848b8605Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 23848b8605Smrg */ 24848b8605Smrg 25848b8605Smrg/** 26848b8605Smrg * \file glxextensions.c 27848b8605Smrg * 28848b8605Smrg * \author Ian Romanick <idr@us.ibm.com> 29848b8605Smrg */ 30848b8605Smrg 31848b8605Smrg#include "glxclient.h" 32848b8605Smrg#include <X11/extensions/extutil.h> 33848b8605Smrg#include <X11/extensions/Xext.h> 34848b8605Smrg#include <string.h> 35848b8605Smrg#include "glxextensions.h" 36848b8605Smrg 37848b8605Smrg 38848b8605Smrg#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8))) 39848b8605Smrg#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8))) 40848b8605Smrg#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0) 41848b8605Smrg#define CONCAT(a,b) a ## b 42848b8605Smrg#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit) 43848b8605Smrg#define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit 44848b8605Smrg#define VER(a,b) a, b 45848b8605Smrg#define Y 1 46848b8605Smrg#define N 0 47848b8605Smrg#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit )) 48848b8605Smrg 49848b8605Smrg 50848b8605Smrgstruct extension_info 51848b8605Smrg{ 52848b8605Smrg const char *const name; 53848b8605Smrg unsigned name_len; 54848b8605Smrg 55848b8605Smrg unsigned char bit; 56848b8605Smrg 57848b8605Smrg /* This is the lowest version of GLX that "requires" this extension. 58848b8605Smrg * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and 59848b8605Smrg * SGI_make_current_read. If the extension is not required by any known 60848b8605Smrg * version of GLX, use 0, 0. 61848b8605Smrg */ 62848b8605Smrg unsigned char version_major; 63848b8605Smrg unsigned char version_minor; 64b8e80941Smrg 65b8e80941Smrg /** 66b8e80941Smrg * The client (i.e., libGL) supports this extension. 67b8e80941Smrg * 68b8e80941Smrg * Except during bring up, all extensions should have this set to Y. There 69b8e80941Smrg * are a few cases of extensions that have partial (or speculative) 70b8e80941Smrg * support, but these are rare. There also shouldn't be any new ones 71b8e80941Smrg * added. 72b8e80941Smrg * 73b8e80941Smrg * Generally, extensions require server support and ::client_support to be 74b8e80941Smrg * enabled. If the display is capable of direct rendering, 75b8e80941Smrg * ::direct_support is also required. 76b8e80941Smrg * 77b8e80941Smrg * \sa ::client_only 78b8e80941Smrg */ 79848b8605Smrg unsigned char client_support; 80b8e80941Smrg 81b8e80941Smrg /** 82b8e80941Smrg * The direct-renderer (e.g., i965_dri.so) supports this extension. 83b8e80941Smrg * 84b8e80941Smrg * For cases where all of the infrastructure to support the extension is a 85b8e80941Smrg * required part of the loader/driver interface, this can default to Y. 86b8e80941Smrg * For most cases, extended functionality, usually in the form of DRI2 87b8e80941Smrg * extensions, is necessary to support the extension. The loader will set 88b8e80941Smrg * the flag true if all the requirements are met. 89b8e80941Smrg * 90b8e80941Smrg * If the display is capable of direct rendering, ::direct_support is 91b8e80941Smrg * required for the extension to be enabled. 92b8e80941Smrg */ 93848b8605Smrg unsigned char direct_support; 94b8e80941Smrg 95b8e80941Smrg /** 96b8e80941Smrg * The extension depends only on client support. 97b8e80941Smrg * 98b8e80941Smrg * This is for extensions like GLX_ARB_get_proc_address that are contained 99b8e80941Smrg * entirely in the client library. There is no dependency on the server or 100b8e80941Smrg * the direct-renderer. 101b8e80941Smrg * 102b8e80941Smrg * These extensions will be enabled if ::client_support is set. 103b8e80941Smrg * 104b8e80941Smrg * \note 105b8e80941Smrg * An extension \b cannot be both client-only and direct-only because being 106b8e80941Smrg * direct-only implies a dependency on the direct renderer. 107b8e80941Smrg * 108b8e80941Smrg * \sa ::client_support, ::direct_only 109b8e80941Smrg */ 110b8e80941Smrg unsigned char client_only; 111b8e80941Smrg 112b8e80941Smrg /** 113b8e80941Smrg * The extension only functions with direct-rendering contexts 114b8e80941Smrg * 115b8e80941Smrg * The extension has no GLX protocol, and, therefore, no explicit 116b8e80941Smrg * dependency on the server. The functionality is contained entirely in 117b8e80941Smrg * the client library and the direct renderer. A few of the swap-related 118b8e80941Smrg * extensions are intended to behave this way. 119b8e80941Smrg * 120b8e80941Smrg * These extensions will be enabled if both ::client_support and 121b8e80941Smrg * ::direct_support are set. 122b8e80941Smrg * 123b8e80941Smrg * \note 124b8e80941Smrg * An extension \b cannot be both client-only and direct-only because being 125b8e80941Smrg * client-only implies that all functionality is outside the 126b8e80941Smrg * direct-renderer. 127b8e80941Smrg * 128b8e80941Smrg * \sa ::direct_support, ::client_only 129b8e80941Smrg */ 130b8e80941Smrg unsigned char direct_only; 131848b8605Smrg}; 132848b8605Smrg 133848b8605Smrg/* *INDENT-OFF* */ 134848b8605Smrgstatic const struct extension_info known_glx_extensions[] = { 135b8e80941Smrg { GLX(ARB_context_flush_control), VER(0,0), Y, N, N, N }, 136848b8605Smrg { GLX(ARB_create_context), VER(0,0), Y, N, N, N }, 137b8e80941Smrg { GLX(ARB_create_context_no_error), VER(1,4), Y, N, N, N }, 138848b8605Smrg { GLX(ARB_create_context_profile), VER(0,0), Y, N, N, N }, 139848b8605Smrg { GLX(ARB_create_context_robustness), VER(0,0), Y, N, N, N }, 140848b8605Smrg { GLX(ARB_fbconfig_float), VER(0,0), Y, Y, N, N }, 141848b8605Smrg { GLX(ARB_framebuffer_sRGB), VER(0,0), Y, Y, N, N }, 142848b8605Smrg { GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N }, 143848b8605Smrg { GLX(ARB_multisample), VER(1,4), Y, Y, N, N }, 144b8e80941Smrg { GLX(EXT_buffer_age), VER(0,0), Y, N, N, Y }, 145b8e80941Smrg { GLX(EXT_create_context_es2_profile), VER(0,0), Y, N, N, N }, 146b8e80941Smrg { GLX(EXT_create_context_es_profile), VER(0,0), Y, N, N, N }, 147b8e80941Smrg { GLX(EXT_fbconfig_packed_float), VER(0,0), Y, Y, N, N }, 148b8e80941Smrg { GLX(EXT_framebuffer_sRGB), VER(0,0), Y, Y, N, N }, 149848b8605Smrg { GLX(EXT_import_context), VER(0,0), Y, Y, N, N }, 150b8e80941Smrg { GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N }, 151848b8605Smrg { GLX(EXT_visual_info), VER(0,0), Y, Y, N, N }, 152848b8605Smrg { GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N }, 153b8e80941Smrg { GLX(ATI_pixel_format_float), VER(0,0), N, N, N, N }, 154b8e80941Smrg { GLX(INTEL_swap_event), VER(0,0), Y, N, N, N }, 155848b8605Smrg { GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N }, 156b8e80941Smrg { GLX(MESA_multithread_makecurrent),VER(0,0), Y, N, N, Y }, 157848b8605Smrg { GLX(MESA_query_renderer), VER(0,0), Y, N, N, Y }, 158848b8605Smrg { GLX(MESA_swap_control), VER(0,0), Y, N, N, Y }, 159848b8605Smrg { GLX(NV_float_buffer), VER(0,0), N, N, N, N }, 160848b8605Smrg { GLX(OML_swap_method), VER(0,0), Y, Y, N, N }, 161848b8605Smrg { GLX(OML_sync_control), VER(0,0), Y, N, N, Y }, 162848b8605Smrg { GLX(SGIS_multisample), VER(0,0), Y, Y, N, N }, 163848b8605Smrg { GLX(SGIX_fbconfig), VER(1,3), Y, Y, N, N }, 164848b8605Smrg { GLX(SGIX_pbuffer), VER(1,3), Y, Y, N, N }, 165848b8605Smrg { GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N }, 166b8e80941Smrg { GLX(SGI_make_current_read), VER(1,3), Y, N, N, N }, 167b8e80941Smrg { GLX(SGI_swap_control), VER(0,0), Y, N, N, N }, 168b8e80941Smrg { GLX(SGI_video_sync), VER(0,0), Y, N, N, Y }, 169848b8605Smrg { NULL } 170848b8605Smrg}; 171848b8605Smrg 172848b8605Smrgstatic const struct extension_info known_gl_extensions[] = { 173848b8605Smrg { GL(ARB_depth_texture), VER(1,4), Y, N, N, N }, 174848b8605Smrg { GL(ARB_draw_buffers), VER(0,0), Y, N, N, N }, 175848b8605Smrg { GL(ARB_fragment_program), VER(0,0), Y, N, N, N }, 176848b8605Smrg { GL(ARB_fragment_program_shadow), VER(0,0), Y, N, N, N }, 177848b8605Smrg { GL(ARB_framebuffer_object), VER(0,0), Y, N, N, N }, 178848b8605Smrg { GL(ARB_imaging), VER(0,0), Y, N, N, N }, 179848b8605Smrg { GL(ARB_multisample), VER(1,3), Y, N, N, N }, 180848b8605Smrg { GL(ARB_multitexture), VER(1,3), Y, N, N, N }, 181848b8605Smrg { GL(ARB_occlusion_query), VER(1,5), Y, N, N, N }, 182848b8605Smrg { GL(ARB_point_parameters), VER(1,4), Y, N, N, N }, 183848b8605Smrg { GL(ARB_point_sprite), VER(0,0), Y, N, N, N }, 184848b8605Smrg { GL(ARB_shadow), VER(1,4), Y, N, N, N }, 185848b8605Smrg { GL(ARB_shadow_ambient), VER(0,0), Y, N, N, N }, 186848b8605Smrg { GL(ARB_texture_border_clamp), VER(1,3), Y, N, N, N }, 187848b8605Smrg { GL(ARB_texture_compression), VER(1,3), Y, N, N, N }, 188848b8605Smrg { GL(ARB_texture_cube_map), VER(1,3), Y, N, N, N }, 189848b8605Smrg { GL(ARB_texture_env_add), VER(1,3), Y, N, N, N }, 190848b8605Smrg { GL(ARB_texture_env_combine), VER(1,3), Y, N, N, N }, 191848b8605Smrg { GL(ARB_texture_env_crossbar), VER(1,4), Y, N, N, N }, 192848b8605Smrg { GL(ARB_texture_env_dot3), VER(1,3), Y, N, N, N }, 193b8e80941Smrg { GL(ARB_texture_filter_anisotropic), VER(0,0), Y, N, N, N }, 194848b8605Smrg { GL(ARB_texture_mirrored_repeat), VER(1,4), Y, N, N, N }, 195848b8605Smrg { GL(ARB_texture_non_power_of_two), VER(1,5), Y, N, N, N }, 196848b8605Smrg { GL(ARB_texture_rectangle), VER(0,0), Y, N, N, N }, 197848b8605Smrg { GL(ARB_texture_rg), VER(0,0), Y, N, N, N }, 198848b8605Smrg { GL(ARB_transpose_matrix), VER(1,3), Y, N, Y, N }, 199848b8605Smrg { GL(ARB_vertex_buffer_object), VER(1,5), N, N, N, N }, 200848b8605Smrg { GL(ARB_vertex_program), VER(0,0), Y, N, N, N }, 201848b8605Smrg { GL(ARB_window_pos), VER(1,4), Y, N, N, N }, 202848b8605Smrg { GL(EXT_abgr), VER(0,0), Y, N, N, N }, 203848b8605Smrg { GL(EXT_bgra), VER(1,2), Y, N, N, N }, 204848b8605Smrg { GL(EXT_blend_color), VER(1,4), Y, N, N, N }, 205848b8605Smrg { GL(EXT_blend_equation_separate), VER(0,0), Y, N, N, N }, 206848b8605Smrg { GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N }, 207848b8605Smrg { GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N }, 208848b8605Smrg { GL(EXT_blend_minmax), VER(1,4), Y, N, N, N }, 209848b8605Smrg { GL(EXT_blend_subtract), VER(1,4), Y, N, N, N }, 210848b8605Smrg { GL(EXT_clip_volume_hint), VER(0,0), Y, N, N, N }, 211848b8605Smrg { GL(EXT_compiled_vertex_array), VER(0,0), N, N, N, N }, 212848b8605Smrg { GL(EXT_convolution), VER(0,0), N, N, N, N }, 213848b8605Smrg { GL(EXT_copy_texture), VER(1,1), Y, N, N, N }, 214848b8605Smrg { GL(EXT_cull_vertex), VER(0,0), N, N, N, N }, 215848b8605Smrg { GL(EXT_depth_bounds_test), VER(0,0), N, N, N, N }, 216848b8605Smrg { GL(EXT_draw_range_elements), VER(1,2), Y, N, Y, N }, 217848b8605Smrg { GL(EXT_fog_coord), VER(1,4), Y, N, N, N }, 218848b8605Smrg { GL(EXT_framebuffer_blit), VER(0,0), Y, N, N, N }, 219848b8605Smrg { GL(EXT_framebuffer_multisample), VER(0,0), Y, N, N, N }, 220848b8605Smrg { GL(EXT_framebuffer_object), VER(0,0), Y, N, N, N }, 221848b8605Smrg { GL(EXT_framebuffer_sRGB), VER(0,0), Y, N, N, N }, 222848b8605Smrg { GL(EXT_multi_draw_arrays), VER(1,4), Y, N, Y, N }, 223848b8605Smrg { GL(EXT_packed_depth_stencil), VER(0,0), Y, N, N, N }, 224848b8605Smrg { GL(EXT_packed_pixels), VER(1,2), Y, N, N, N }, 225848b8605Smrg { GL(EXT_paletted_texture), VER(0,0), Y, N, N, N }, 226848b8605Smrg { GL(EXT_pixel_buffer_object), VER(0,0), N, N, N, N }, 227848b8605Smrg { GL(EXT_point_parameters), VER(1,4), Y, N, N, N }, 228848b8605Smrg { GL(EXT_polygon_offset), VER(1,1), Y, N, N, N }, 229848b8605Smrg { GL(EXT_rescale_normal), VER(1,2), Y, N, N, N }, 230848b8605Smrg { GL(EXT_secondary_color), VER(1,4), Y, N, N, N }, 231848b8605Smrg { GL(EXT_separate_specular_color), VER(1,2), Y, N, N, N }, 232848b8605Smrg { GL(EXT_shadow_funcs), VER(1,5), Y, N, N, N }, 233848b8605Smrg { GL(EXT_shared_texture_palette), VER(0,0), Y, N, N, N }, 234848b8605Smrg { GL(EXT_stencil_two_side), VER(0,0), Y, N, N, N }, 235848b8605Smrg { GL(EXT_stencil_wrap), VER(1,4), Y, N, N, N }, 236848b8605Smrg { GL(EXT_subtexture), VER(1,1), Y, N, N, N }, 237848b8605Smrg { GL(EXT_texture), VER(1,1), Y, N, N, N }, 238848b8605Smrg { GL(EXT_texture3D), VER(1,2), Y, N, N, N }, 239848b8605Smrg { GL(EXT_texture_compression_dxt1), VER(0,0), Y, N, N, N }, 240848b8605Smrg { GL(EXT_texture_compression_s3tc), VER(0,0), Y, N, N, N }, 241848b8605Smrg { GL(EXT_texture_edge_clamp), VER(1,2), Y, N, N, N }, 242848b8605Smrg { GL(EXT_texture_env_add), VER(1,3), Y, N, N, N }, 243848b8605Smrg { GL(EXT_texture_env_combine), VER(1,3), Y, N, N, N }, 244848b8605Smrg { GL(EXT_texture_env_dot3), VER(0,0), Y, N, N, N }, 245848b8605Smrg { GL(EXT_texture_filter_anisotropic), VER(0,0), Y, N, N, N }, 246b8e80941Smrg { GL(EXT_texture_integer), VER(0,0), Y, N, N, N }, 247848b8605Smrg { GL(EXT_texture_lod), VER(1,2), Y, N, N, N }, 248848b8605Smrg { GL(EXT_texture_lod_bias), VER(1,4), Y, N, N, N }, 249848b8605Smrg { GL(EXT_texture_mirror_clamp), VER(0,0), Y, N, N, N }, 250848b8605Smrg { GL(EXT_texture_object), VER(1,1), Y, N, N, N }, 251848b8605Smrg { GL(EXT_texture_rectangle), VER(0,0), Y, N, N, N }, 252848b8605Smrg { GL(EXT_vertex_array), VER(0,0), Y, N, N, N }, 253848b8605Smrg { GL(3DFX_texture_compression_FXT1), VER(0,0), Y, N, N, N }, 254848b8605Smrg { GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N }, 255848b8605Smrg { GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N }, 256848b8605Smrg { GL(ATI_draw_buffers), VER(0,0), Y, N, N, N }, 257848b8605Smrg { GL(ATI_text_fragment_shader), VER(0,0), Y, N, N, N }, 258848b8605Smrg { GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N }, 259848b8605Smrg { GL(ATI_texture_float), VER(0,0), Y, N, N, N }, 260848b8605Smrg { GL(ATI_texture_mirror_once), VER(0,0), Y, N, N, N }, 261848b8605Smrg { GL(ATIX_texture_env_combine3), VER(0,0), Y, N, N, N }, 262848b8605Smrg { GL(HP_convolution_border_modes), VER(0,0), Y, N, N, N }, 263848b8605Smrg { GL(HP_occlusion_test), VER(0,0), Y, N, N, N }, 264848b8605Smrg { GL(IBM_cull_vertex), VER(0,0), Y, N, N, N }, 265848b8605Smrg { GL(IBM_pixel_filter_hint), VER(0,0), Y, N, N, N }, 266848b8605Smrg { GL(IBM_rasterpos_clip), VER(0,0), Y, N, N, N }, 267848b8605Smrg { GL(IBM_texture_clamp_nodraw), VER(0,0), Y, N, N, N }, 268848b8605Smrg { GL(IBM_texture_mirrored_repeat), VER(0,0), Y, N, N, N }, 269848b8605Smrg { GL(INGR_blend_func_separate), VER(0,0), Y, N, N, N }, 270848b8605Smrg { GL(INGR_interlace_read), VER(0,0), Y, N, N, N }, 271848b8605Smrg { GL(MESA_pack_invert), VER(0,0), Y, N, N, N }, 272848b8605Smrg { GL(MESA_ycbcr_texture), VER(0,0), Y, N, N, N }, 273848b8605Smrg { GL(NV_blend_square), VER(1,4), Y, N, N, N }, 274848b8605Smrg { GL(NV_copy_depth_to_color), VER(0,0), Y, N, N, N }, 275848b8605Smrg { GL(NV_depth_clamp), VER(0,0), Y, N, N, N }, 276848b8605Smrg { GL(NV_fog_distance), VER(0,0), Y, N, N, N }, 277848b8605Smrg { GL(NV_fragment_program), VER(0,0), Y, N, N, N }, 278848b8605Smrg { GL(NV_fragment_program_option), VER(0,0), Y, N, N, N }, 279848b8605Smrg { GL(NV_fragment_program2), VER(0,0), Y, N, N, N }, 280848b8605Smrg { GL(NV_light_max_exponent), VER(0,0), Y, N, N, N }, 281848b8605Smrg { GL(NV_multisample_filter_hint), VER(0,0), Y, N, N, N }, 282848b8605Smrg { GL(NV_packed_depth_stencil), VER(0,0), Y, N, N, N }, 283848b8605Smrg { GL(NV_point_sprite), VER(0,0), Y, N, N, N }, 284848b8605Smrg { GL(NV_texgen_reflection), VER(0,0), Y, N, N, N }, 285848b8605Smrg { GL(NV_texture_compression_vtc), VER(0,0), Y, N, N, N }, 286848b8605Smrg { GL(NV_texture_env_combine4), VER(0,0), Y, N, N, N }, 287848b8605Smrg { GL(NV_texture_rectangle), VER(0,0), Y, N, N, N }, 288848b8605Smrg { GL(NV_vertex_program), VER(0,0), Y, N, N, N }, 289848b8605Smrg { GL(NV_vertex_program1_1), VER(0,0), Y, N, N, N }, 290848b8605Smrg { GL(NV_vertex_program2), VER(0,0), Y, N, N, N }, 291848b8605Smrg { GL(NV_vertex_program2_option), VER(0,0), Y, N, N, N }, 292848b8605Smrg { GL(NV_vertex_program3), VER(0,0), Y, N, N, N }, 293848b8605Smrg { GL(OES_read_format), VER(0,0), Y, N, N, N }, 294848b8605Smrg { GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N }, 295848b8605Smrg { GL(SGI_color_matrix), VER(0,0), Y, N, N, N }, 296848b8605Smrg { GL(SGI_color_table), VER(0,0), Y, N, N, N }, 297848b8605Smrg { GL(SGI_texture_color_table), VER(0,0), Y, N, N, N }, 298848b8605Smrg { GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N }, 299848b8605Smrg { GL(SGIS_multisample), VER(0,0), Y, N, N, N }, 300848b8605Smrg { GL(SGIS_texture_border_clamp), VER(1,3), Y, N, N, N }, 301848b8605Smrg { GL(SGIS_texture_edge_clamp), VER(1,2), Y, N, N, N }, 302848b8605Smrg { GL(SGIS_texture_lod), VER(1,2), Y, N, N, N }, 303848b8605Smrg { GL(SGIX_blend_alpha_minmax), VER(0,0), Y, N, N, N }, 304848b8605Smrg { GL(SGIX_clipmap), VER(0,0), Y, N, N, N }, 305848b8605Smrg { GL(SGIX_depth_texture), VER(0,0), Y, N, N, N }, 306848b8605Smrg { GL(SGIX_fog_offset), VER(0,0), Y, N, N, N }, 307848b8605Smrg { GL(SGIX_shadow), VER(0,0), Y, N, N, N }, 308848b8605Smrg { GL(SGIX_shadow_ambient), VER(0,0), Y, N, N, N }, 309848b8605Smrg { GL(SGIX_texture_coordinate_clamp), VER(0,0), Y, N, N, N }, 310848b8605Smrg { GL(SGIX_texture_lod_bias), VER(0,0), Y, N, N, N }, 311848b8605Smrg { GL(SGIX_texture_range), VER(0,0), Y, N, N, N }, 312848b8605Smrg { GL(SGIX_texture_scale_bias), VER(0,0), Y, N, N, N }, 313848b8605Smrg { GL(SGIX_vertex_preclip), VER(0,0), Y, N, N, N }, 314848b8605Smrg { GL(SGIX_vertex_preclip_hint), VER(0,0), Y, N, N, N }, 315848b8605Smrg { GL(SGIX_ycrcb), VER(0,0), Y, N, N, N }, 316848b8605Smrg { GL(SUN_convolution_border_modes), VER(0,0), Y, N, N, N }, 317848b8605Smrg { GL(SUN_multi_draw_arrays), VER(0,0), Y, N, Y, N }, 318848b8605Smrg { GL(SUN_slice_accum), VER(0,0), Y, N, N, N }, 319848b8605Smrg { NULL } 320848b8605Smrg}; 321848b8605Smrg/* *INDENT-ON* */ 322848b8605Smrg 323848b8605Smrg 324848b8605Smrg/* global bit-fields of available extensions and their characteristics */ 325848b8605Smrgstatic unsigned char client_glx_support[8]; 326848b8605Smrgstatic unsigned char client_glx_only[8]; 327848b8605Smrgstatic unsigned char direct_glx_only[8]; 328848b8605Smrgstatic unsigned char client_gl_support[__GL_EXT_BYTES]; 329848b8605Smrgstatic unsigned char client_gl_only[__GL_EXT_BYTES]; 330848b8605Smrg 331848b8605Smrg/** 332848b8605Smrg * Bits representing the set of extensions that are enabled by default in all 333848b8605Smrg * direct rendering drivers. 334848b8605Smrg */ 335848b8605Smrgstatic unsigned char direct_glx_support[8]; 336848b8605Smrg 337848b8605Smrg/** 338848b8605Smrg * Highest core GL version that can be supported for indirect rendering. 339848b8605Smrg */ 340848b8605Smrgstatic const unsigned gl_major = 1; 341848b8605Smrgstatic const unsigned gl_minor = 4; 342848b8605Smrg 343848b8605Smrg/* client extensions string */ 344848b8605Smrgstatic const char *__glXGLXClientExtensions = NULL; 345848b8605Smrg 346848b8605Smrgstatic void __glXExtensionsCtr(void); 347848b8605Smrgstatic void __glXExtensionsCtrScreen(struct glx_screen * psc); 348848b8605Smrgstatic void __glXProcessServerString(const struct extension_info *ext, 349848b8605Smrg const char *server_string, 350848b8605Smrg unsigned char *server_support); 351848b8605Smrg 352848b8605Smrg/** 353848b8605Smrg * Set the state of a GLX extension. 354848b8605Smrg * 355848b8605Smrg * \param name Name of the extension. 356848b8605Smrg * \param name_len Length, in characters, of the extension name. 357848b8605Smrg * \param state New state (either enabled or disabled) of the extension. 358848b8605Smrg * \param supported Table in which the state of the extension is to be set. 359848b8605Smrg */ 360848b8605Smrgstatic void 361848b8605Smrgset_glx_extension(const struct extension_info *ext, 362848b8605Smrg const char *name, unsigned name_len, GLboolean state, 363848b8605Smrg unsigned char *supported) 364848b8605Smrg{ 365848b8605Smrg unsigned i; 366848b8605Smrg 367848b8605Smrg 368848b8605Smrg for (i = 0; ext[i].name != NULL; i++) { 369848b8605Smrg if ((name_len == ext[i].name_len) 370848b8605Smrg && (strncmp(ext[i].name, name, name_len) == 0)) { 371848b8605Smrg if (state) { 372848b8605Smrg SET_BIT(supported, ext[i].bit); 373848b8605Smrg } 374848b8605Smrg else { 375848b8605Smrg CLR_BIT(supported, ext[i].bit); 376848b8605Smrg } 377848b8605Smrg 378848b8605Smrg return; 379848b8605Smrg } 380848b8605Smrg } 381848b8605Smrg} 382848b8605Smrg 383848b8605Smrg 384848b8605Smrg#define NUL '\0' 385848b8605Smrg#define SEPARATOR ' ' 386848b8605Smrg 387848b8605Smrg/** 388848b8605Smrg * Convert the server's extension string to a bit-field. 389848b8605Smrg * 390848b8605Smrg * \param server_string GLX extension string from the server. 391848b8605Smrg * \param server_support Bit-field of supported extensions. 392848b8605Smrg * 393848b8605Smrg * \note 394848b8605Smrg * This function is used to process both GLX and GL extension strings. The 395848b8605Smrg * bit-fields used to track each of these have different sizes. Therefore, 396848b8605Smrg * the data pointed by \c server_support must be preinitialized to zero. 397848b8605Smrg */ 398848b8605Smrgstatic void 399848b8605Smrg__glXProcessServerString(const struct extension_info *ext, 400848b8605Smrg const char *server_string, 401848b8605Smrg unsigned char *server_support) 402848b8605Smrg{ 403848b8605Smrg unsigned base; 404848b8605Smrg unsigned len; 405848b8605Smrg 406848b8605Smrg for (base = 0; server_string[base] != NUL; /* empty */ ) { 407848b8605Smrg /* Determine the length of the next extension name. 408848b8605Smrg */ 409848b8605Smrg for (len = 0; (server_string[base + len] != SEPARATOR) 410848b8605Smrg && (server_string[base + len] != NUL); len++) { 411848b8605Smrg /* empty */ 412848b8605Smrg } 413848b8605Smrg 414848b8605Smrg /* Set the bit for the extension in the server_support table. 415848b8605Smrg */ 416848b8605Smrg set_glx_extension(ext, &server_string[base], len, GL_TRUE, 417848b8605Smrg server_support); 418848b8605Smrg 419848b8605Smrg 420848b8605Smrg /* Advance to the next extension string. This means that we skip 421848b8605Smrg * over the previous string and any trialing white-space. 422848b8605Smrg */ 423848b8605Smrg for (base += len; (server_string[base] == SEPARATOR) 424848b8605Smrg && (server_string[base] != NUL); base++) { 425848b8605Smrg /* empty */ 426848b8605Smrg } 427848b8605Smrg } 428848b8605Smrg} 429848b8605Smrg 430848b8605Smrgvoid 431848b8605Smrg__glXEnableDirectExtension(struct glx_screen * psc, const char *name) 432848b8605Smrg{ 433848b8605Smrg __glXExtensionsCtr(); 434848b8605Smrg __glXExtensionsCtrScreen(psc); 435848b8605Smrg 436848b8605Smrg set_glx_extension(known_glx_extensions, 437848b8605Smrg name, strlen(name), GL_TRUE, psc->direct_support); 438848b8605Smrg} 439848b8605Smrg 440848b8605Smrg/** 441848b8605Smrg * Initialize global extension support tables. 442848b8605Smrg */ 443848b8605Smrg 444848b8605Smrgstatic void 445848b8605Smrg__glXExtensionsCtr(void) 446848b8605Smrg{ 447848b8605Smrg unsigned i; 448848b8605Smrg static GLboolean ext_list_first_time = GL_TRUE; 449848b8605Smrg 450848b8605Smrg 451848b8605Smrg if (ext_list_first_time) { 452848b8605Smrg ext_list_first_time = GL_FALSE; 453848b8605Smrg 454848b8605Smrg (void) memset(client_glx_support, 0, sizeof(client_glx_support)); 455848b8605Smrg (void) memset(direct_glx_support, 0, sizeof(direct_glx_support)); 456848b8605Smrg (void) memset(client_glx_only, 0, sizeof(client_glx_only)); 457848b8605Smrg (void) memset(direct_glx_only, 0, sizeof(direct_glx_only)); 458848b8605Smrg 459848b8605Smrg (void) memset(client_gl_support, 0, sizeof(client_gl_support)); 460848b8605Smrg (void) memset(client_gl_only, 0, sizeof(client_gl_only)); 461848b8605Smrg 462848b8605Smrg for (i = 0; known_glx_extensions[i].name != NULL; i++) { 463848b8605Smrg const unsigned bit = known_glx_extensions[i].bit; 464848b8605Smrg 465848b8605Smrg if (known_glx_extensions[i].client_support) { 466848b8605Smrg SET_BIT(client_glx_support, bit); 467848b8605Smrg } 468848b8605Smrg 469848b8605Smrg if (known_glx_extensions[i].direct_support) { 470848b8605Smrg SET_BIT(direct_glx_support, bit); 471848b8605Smrg } 472848b8605Smrg 473848b8605Smrg if (known_glx_extensions[i].client_only) { 474848b8605Smrg SET_BIT(client_glx_only, bit); 475848b8605Smrg } 476848b8605Smrg 477848b8605Smrg if (known_glx_extensions[i].direct_only) { 478848b8605Smrg SET_BIT(direct_glx_only, bit); 479848b8605Smrg } 480848b8605Smrg } 481848b8605Smrg 482848b8605Smrg for (i = 0; known_gl_extensions[i].name != NULL; i++) { 483848b8605Smrg const unsigned bit = known_gl_extensions[i].bit; 484848b8605Smrg 485848b8605Smrg if (known_gl_extensions[i].client_support) { 486848b8605Smrg SET_BIT(client_gl_support, bit); 487848b8605Smrg } 488848b8605Smrg 489848b8605Smrg if (known_gl_extensions[i].client_only) { 490848b8605Smrg SET_BIT(client_gl_only, bit); 491848b8605Smrg } 492848b8605Smrg } 493848b8605Smrg 494848b8605Smrg#if 0 495848b8605Smrg fprintf(stderr, "[%s:%u] Maximum client library version: %u.%u\n", 496848b8605Smrg __func__, __LINE__, gl_major, gl_minor); 497848b8605Smrg#endif 498848b8605Smrg } 499848b8605Smrg} 500848b8605Smrg 501848b8605Smrg 502848b8605Smrg/** 503848b8605Smrg * Make sure that per-screen direct-support table is initialized. 504848b8605Smrg * 505848b8605Smrg * \param psc Pointer to GLX per-screen record. 506848b8605Smrg */ 507848b8605Smrg 508848b8605Smrgstatic void 509848b8605Smrg__glXExtensionsCtrScreen(struct glx_screen * psc) 510848b8605Smrg{ 511848b8605Smrg if (psc->ext_list_first_time) { 512848b8605Smrg psc->ext_list_first_time = GL_FALSE; 513848b8605Smrg (void) memcpy(psc->direct_support, direct_glx_support, 514848b8605Smrg sizeof(direct_glx_support)); 515848b8605Smrg } 516848b8605Smrg} 517848b8605Smrg 518848b8605Smrg 519848b8605Smrg/** 520848b8605Smrg * Check if a certain extension is enabled on a given screen. 521848b8605Smrg * 522848b8605Smrg * \param psc Pointer to GLX per-screen record. 523848b8605Smrg * \param bit Bit index in the direct-support table. 524848b8605Smrg * \returns If the extension bit is enabled for the screen, \c GL_TRUE is 525848b8605Smrg * returned. If the extension bit is not enabled or if \c psc is 526848b8605Smrg * \c NULL, then \c GL_FALSE is returned. 527848b8605Smrg */ 528848b8605SmrgGLboolean 529848b8605Smrg__glXExtensionBitIsEnabled(struct glx_screen * psc, unsigned bit) 530848b8605Smrg{ 531848b8605Smrg GLboolean enabled = GL_FALSE; 532848b8605Smrg 533848b8605Smrg if (psc != NULL) { 534848b8605Smrg __glXExtensionsCtr(); 535848b8605Smrg __glXExtensionsCtrScreen(psc); 536848b8605Smrg enabled = EXT_ENABLED(bit, psc->direct_support); 537848b8605Smrg } 538848b8605Smrg 539848b8605Smrg return enabled; 540848b8605Smrg} 541848b8605Smrg 542848b8605Smrg 543848b8605Smrg/** 544848b8605Smrg * Check if a certain extension is enabled in a given context. 545848b8605Smrg * 546848b8605Smrg */ 547848b8605SmrgGLboolean 548848b8605Smrg__glExtensionBitIsEnabled(struct glx_context *gc, unsigned bit) 549848b8605Smrg{ 550848b8605Smrg GLboolean enabled = GL_FALSE; 551848b8605Smrg 552848b8605Smrg if (gc != NULL) { 553848b8605Smrg enabled = EXT_ENABLED(bit, gc->gl_extension_bits); 554848b8605Smrg } 555848b8605Smrg 556848b8605Smrg return enabled; 557848b8605Smrg} 558848b8605Smrg 559848b8605Smrg 560848b8605Smrg 561848b8605Smrg/** 562848b8605Smrg * Convert a bit-field to a string of supported extensions. 563848b8605Smrg */ 564848b8605Smrgstatic char * 565848b8605Smrg__glXGetStringFromTable(const struct extension_info *ext, 566848b8605Smrg const unsigned char *supported) 567848b8605Smrg{ 568848b8605Smrg unsigned i; 569848b8605Smrg unsigned ext_str_len; 570848b8605Smrg char *ext_str; 571848b8605Smrg char *point; 572848b8605Smrg 573848b8605Smrg 574848b8605Smrg ext_str_len = 0; 575848b8605Smrg for (i = 0; ext[i].name != NULL; i++) { 576848b8605Smrg if (EXT_ENABLED(ext[i].bit, supported)) { 577848b8605Smrg ext_str_len += ext[i].name_len + 1; 578848b8605Smrg } 579848b8605Smrg } 580848b8605Smrg 581848b8605Smrg ext_str = malloc(ext_str_len + 1); 582848b8605Smrg if (ext_str != NULL) { 583848b8605Smrg point = ext_str; 584848b8605Smrg 585848b8605Smrg for (i = 0; ext[i].name != NULL; i++) { 586848b8605Smrg if (EXT_ENABLED(ext[i].bit, supported)) { 587848b8605Smrg (void) memcpy(point, ext[i].name, ext[i].name_len); 588848b8605Smrg point += ext[i].name_len; 589848b8605Smrg 590848b8605Smrg *point = ' '; 591848b8605Smrg point++; 592848b8605Smrg } 593848b8605Smrg } 594848b8605Smrg 595848b8605Smrg *point = '\0'; 596848b8605Smrg } 597848b8605Smrg 598848b8605Smrg return ext_str; 599848b8605Smrg} 600848b8605Smrg 601848b8605Smrg 602848b8605Smrg/** 603848b8605Smrg * Get the string of client library supported extensions. 604848b8605Smrg */ 605848b8605Smrgconst char * 606848b8605Smrg__glXGetClientExtensions(void) 607848b8605Smrg{ 608848b8605Smrg if (__glXGLXClientExtensions == NULL) { 609848b8605Smrg __glXExtensionsCtr(); 610848b8605Smrg __glXGLXClientExtensions = __glXGetStringFromTable(known_glx_extensions, 611848b8605Smrg client_glx_support); 612848b8605Smrg } 613848b8605Smrg 614848b8605Smrg return __glXGLXClientExtensions; 615848b8605Smrg} 616848b8605Smrg 617848b8605Smrg 618848b8605Smrg/** 619848b8605Smrg * Calculate the list of application usable extensions. The resulting 620848b8605Smrg * string is stored in \c psc->effectiveGLXexts. 621848b8605Smrg * 622848b8605Smrg * \param psc Pointer to GLX per-screen record. 623848b8605Smrg * \param display_is_direct_capable True if the display is capable of 624848b8605Smrg * direct rendering. 625848b8605Smrg * \param minor_version GLX minor version from the server. 626848b8605Smrg */ 627848b8605Smrg 628848b8605Smrgvoid 629848b8605Smrg__glXCalculateUsableExtensions(struct glx_screen * psc, 630848b8605Smrg GLboolean display_is_direct_capable, 631848b8605Smrg int minor_version) 632848b8605Smrg{ 633848b8605Smrg unsigned char server_support[8]; 634848b8605Smrg unsigned char usable[8]; 635848b8605Smrg unsigned i; 636848b8605Smrg 637848b8605Smrg __glXExtensionsCtr(); 638848b8605Smrg __glXExtensionsCtrScreen(psc); 639848b8605Smrg 640848b8605Smrg (void) memset(server_support, 0, sizeof(server_support)); 641848b8605Smrg __glXProcessServerString(known_glx_extensions, 642848b8605Smrg psc->serverGLXexts, server_support); 643848b8605Smrg 644848b8605Smrg 645848b8605Smrg /* This is a hack. Some servers support GLX 1.3 but don't export 646848b8605Smrg * all of the extensions implied by GLX 1.3. If the server claims 647848b8605Smrg * support for GLX 1.3, enable support for the extensions that can be 648848b8605Smrg * "emulated" as well. 649848b8605Smrg */ 650848b8605Smrg#ifndef GLX_USE_APPLEGL 651848b8605Smrg if (minor_version >= 3) { 652848b8605Smrg SET_BIT(server_support, EXT_visual_info_bit); 653848b8605Smrg SET_BIT(server_support, EXT_visual_rating_bit); 654848b8605Smrg SET_BIT(server_support, SGI_make_current_read_bit); 655848b8605Smrg SET_BIT(server_support, SGIX_fbconfig_bit); 656848b8605Smrg SET_BIT(server_support, SGIX_pbuffer_bit); 657848b8605Smrg 658848b8605Smrg /* This one is a little iffy. GLX 1.3 doesn't incorporate all of this 659848b8605Smrg * extension. However, the only part that is not strictly client-side 660848b8605Smrg * is shared. That's the glXQueryContext / glXQueryContextInfoEXT 661848b8605Smrg * function. 662848b8605Smrg */ 663848b8605Smrg 664848b8605Smrg SET_BIT(server_support, EXT_import_context_bit); 665848b8605Smrg } 666848b8605Smrg#endif 667848b8605Smrg 668848b8605Smrg /* An extension is supported if the client-side (i.e., libGL) supports 669848b8605Smrg * it and the "server" supports it. In this case that means that either 670848b8605Smrg * the true server supports it or it is only for direct-rendering and 671848b8605Smrg * the direct rendering driver supports it. 672848b8605Smrg * 673848b8605Smrg * If the display is not capable of direct rendering, then the extension 674848b8605Smrg * is enabled if and only if the client-side library and the server 675848b8605Smrg * support it. 676848b8605Smrg */ 677848b8605Smrg 678848b8605Smrg if (display_is_direct_capable) { 679848b8605Smrg for (i = 0; i < 8; i++) { 680848b8605Smrg usable[i] = (client_glx_support[i] & client_glx_only[i]) 681848b8605Smrg | (client_glx_support[i] & psc->direct_support[i] & 682848b8605Smrg server_support[i]) 683848b8605Smrg | (client_glx_support[i] & psc->direct_support[i] & 684848b8605Smrg direct_glx_only[i]); 685848b8605Smrg } 686848b8605Smrg } 687848b8605Smrg else { 688848b8605Smrg for (i = 0; i < 8; i++) { 689848b8605Smrg usable[i] = (client_glx_support[i] & client_glx_only[i]) 690848b8605Smrg | (client_glx_support[i] & server_support[i]); 691848b8605Smrg } 692848b8605Smrg } 693848b8605Smrg 694848b8605Smrg psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions, 695848b8605Smrg usable); 696848b8605Smrg} 697848b8605Smrg 698848b8605Smrg 699848b8605Smrg/** 700848b8605Smrg * Calculate the list of application usable extensions. The resulting 701848b8605Smrg * string is stored in \c gc->extensions. 702848b8605Smrg * 703848b8605Smrg * \param gc Pointer to GLX context. 704848b8605Smrg * \param server_string Extension string from the server. 705848b8605Smrg * \param major_version GL major version from the server. 706848b8605Smrg * \param minor_version GL minor version from the server. 707848b8605Smrg */ 708848b8605Smrg 709848b8605Smrgvoid 710848b8605Smrg__glXCalculateUsableGLExtensions(struct glx_context * gc, 711848b8605Smrg const char *server_string, 712848b8605Smrg int major_version, int minor_version) 713848b8605Smrg{ 714848b8605Smrg unsigned char server_support[__GL_EXT_BYTES]; 715848b8605Smrg unsigned char usable[__GL_EXT_BYTES]; 716848b8605Smrg unsigned i; 717848b8605Smrg 718848b8605Smrg 719848b8605Smrg __glXExtensionsCtr(); 720848b8605Smrg 721848b8605Smrg (void) memset(server_support, 0, sizeof(server_support)); 722848b8605Smrg __glXProcessServerString(known_gl_extensions, server_string, 723848b8605Smrg server_support); 724848b8605Smrg 725848b8605Smrg 726848b8605Smrg /* Handle lazy servers that don't export all the extensions strings that 727848b8605Smrg * are part of the GL core version that they support. 728848b8605Smrg */ 729848b8605Smrg 730848b8605Smrg for (i = 0; i < __GL_EXT_BYTES; i++) { 731848b8605Smrg if ((known_gl_extensions[i].version_major != 0) 732848b8605Smrg && ((major_version > known_gl_extensions[i].version_major) 733848b8605Smrg || ((major_version == known_gl_extensions[i].version_major) 734848b8605Smrg && (minor_version >= 735848b8605Smrg known_gl_extensions[i].version_minor)))) { 736848b8605Smrg SET_BIT(server_support, known_gl_extensions[i].bit); 737848b8605Smrg } 738848b8605Smrg } 739848b8605Smrg 740848b8605Smrg 741848b8605Smrg /* An extension is supported if the client-side (i.e., libGL) supports 742848b8605Smrg * it and the server supports it or the client-side library supports it 743848b8605Smrg * and it only needs client-side support. 744848b8605Smrg */ 745848b8605Smrg 746848b8605Smrg for (i = 0; i < __GL_EXT_BYTES; i++) { 747848b8605Smrg usable[i] = (client_gl_support[i] & client_gl_only[i]) 748848b8605Smrg | (client_gl_support[i] & server_support[i]); 749848b8605Smrg } 750848b8605Smrg 751848b8605Smrg gc->extensions = (unsigned char *) 752848b8605Smrg __glXGetStringFromTable(known_gl_extensions, usable); 753848b8605Smrg (void) memcpy(gc->gl_extension_bits, usable, sizeof(usable)); 754848b8605Smrg} 755848b8605Smrg 756848b8605Smrg 757848b8605Smrg/** 758848b8605Smrg * Calculates the maximum core GL version that can be supported for indirect 759848b8605Smrg * rendering. 760848b8605Smrg */ 761848b8605Smrgvoid 762848b8605Smrg__glXGetGLVersion(int *major_version, int *minor_version) 763848b8605Smrg{ 764848b8605Smrg __glXExtensionsCtr(); 765848b8605Smrg *major_version = gl_major; 766848b8605Smrg *minor_version = gl_minor; 767848b8605Smrg} 768848b8605Smrg 769848b8605Smrg 770848b8605Smrg/** 771848b8605Smrg * Get a string representing the set of extensions supported by the client 772848b8605Smrg * library. This is currently only used to send the list of extensions 773848b8605Smrg * supported by the client to the server. 774848b8605Smrg */ 775848b8605Smrgchar * 776848b8605Smrg__glXGetClientGLExtensionString(void) 777848b8605Smrg{ 778848b8605Smrg __glXExtensionsCtr(); 779848b8605Smrg return __glXGetStringFromTable(known_gl_extensions, client_gl_support); 780848b8605Smrg} 781