1*8975f5c5SAndroid Build Coastguard Worker#!/usr/bin/python3 2*8975f5c5SAndroid Build Coastguard Worker# 3*8975f5c5SAndroid Build Coastguard Worker# Copyright 2018 The ANGLE Project Authors. All rights reserved. 4*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 5*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file. 6*8975f5c5SAndroid Build Coastguard Worker# 7*8975f5c5SAndroid Build Coastguard Worker# registry_xml.py: 8*8975f5c5SAndroid Build Coastguard Worker# Parses information from Khronos registry files.. 9*8975f5c5SAndroid Build Coastguard Worker 10*8975f5c5SAndroid Build Coastguard Worker# List of supported extensions. Add to this list to enable new extensions 11*8975f5c5SAndroid Build Coastguard Worker# available in gl.xml. 12*8975f5c5SAndroid Build Coastguard Worker 13*8975f5c5SAndroid Build Coastguard Workerimport difflib 14*8975f5c5SAndroid Build Coastguard Workerimport os 15*8975f5c5SAndroid Build Coastguard Workerimport sys 16*8975f5c5SAndroid Build Coastguard Workerimport xml.etree.ElementTree as etree 17*8975f5c5SAndroid Build Coastguard Worker 18*8975f5c5SAndroid Build Coastguard Workerfrom enum import Enum 19*8975f5c5SAndroid Build Coastguard Worker 20*8975f5c5SAndroid Build Coastguard Workerkhronos_xml_inputs = [ 21*8975f5c5SAndroid Build Coastguard Worker '../third_party/EGL-Registry/src/api/egl.xml', 22*8975f5c5SAndroid Build Coastguard Worker '../third_party/OpenCL-Docs/src/xml/cl.xml', 23*8975f5c5SAndroid Build Coastguard Worker '../third_party/OpenGL-Registry/src/xml/gl.xml', 24*8975f5c5SAndroid Build Coastguard Worker '../third_party/OpenGL-Registry/src/xml/glx.xml', 25*8975f5c5SAndroid Build Coastguard Worker '../third_party/OpenGL-Registry/src/xml/wgl.xml', 26*8975f5c5SAndroid Build Coastguard Worker] 27*8975f5c5SAndroid Build Coastguard Worker 28*8975f5c5SAndroid Build Coastguard Workerangle_xml_inputs = [ 29*8975f5c5SAndroid Build Coastguard Worker 'gl_angle_ext.xml', 30*8975f5c5SAndroid Build Coastguard Worker 'egl_angle_ext.xml', 31*8975f5c5SAndroid Build Coastguard Worker 'registry_xml.py', 32*8975f5c5SAndroid Build Coastguard Worker] 33*8975f5c5SAndroid Build Coastguard Worker 34*8975f5c5SAndroid Build Coastguard Workerxml_inputs = sorted(khronos_xml_inputs + angle_xml_inputs) 35*8975f5c5SAndroid Build Coastguard Worker 36*8975f5c5SAndroid Build Coastguard Worker# Notes on categories of extensions: 37*8975f5c5SAndroid Build Coastguard Worker# 'Requestable' extensions are extensions that can be enabled with ANGLE_request_extension 38*8975f5c5SAndroid Build Coastguard Worker# 'ES-Only' extensions are always implicitly enabled. 39*8975f5c5SAndroid Build Coastguard Worker# 'Toggleable' extensions are like 'Requestable' except they can be also disabled. 40*8975f5c5SAndroid Build Coastguard Worker# 'ANGLE' extensions are extensions that are not yet officially upstreamed to Khronos. 41*8975f5c5SAndroid Build Coastguard Worker# We document those extensions in gl_angle_ext.xml instead of the canonical gl.xml. 42*8975f5c5SAndroid Build Coastguard Worker 43*8975f5c5SAndroid Build Coastguard Workerangle_toggleable_extensions = [ 44*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_texture_rectangle", 45*8975f5c5SAndroid Build Coastguard Worker] 46*8975f5c5SAndroid Build Coastguard Worker 47*8975f5c5SAndroid Build Coastguard Workerangle_requestable_extensions = [ 48*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_base_vertex_base_instance", 49*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_base_vertex_base_instance_shader_builtin", 50*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_blob_cache", 51*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_clip_cull_distance", 52*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_compressed_texture_etc", 53*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_copy_texture_3d", 54*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_framebuffer_multisample", 55*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_get_image", 56*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_get_tex_level_parameter", 57*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_logic_op", 58*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_lossy_etc_decode", 59*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_memory_object_flags", 60*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_memory_object_fuchsia", 61*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_memory_size", 62*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_multi_draw", 63*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_multiview_multisample", 64*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_polygon_mode", 65*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_provoking_vertex", 66*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_read_only_depth_stencil_feedback_loops", 67*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_renderability_validation", 68*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_robust_fragment_shader_output", 69*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_semaphore_fuchsia", 70*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_shader_pixel_local_storage", 71*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_shader_pixel_local_storage_coherent", 72*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_stencil_texturing", 73*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_texture_compression_dxt3", 74*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_texture_compression_dxt5", 75*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_texture_external_update", 76*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_texture_multisample", 77*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_vulkan_image", 78*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_yuv_internal_format", 79*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_color_buffer_float_rgb", 80*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_color_buffer_float_rgba", 81*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_lose_context", 82*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_sync_query", 83*8975f5c5SAndroid Build Coastguard Worker] 84*8975f5c5SAndroid Build Coastguard Worker 85*8975f5c5SAndroid Build Coastguard Workergles_requestable_extensions = [ 86*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_framebuffer_blit", 87*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_instanced_arrays", 88*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_pack_reverse_row_order", 89*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_texture_usage", 90*8975f5c5SAndroid Build Coastguard Worker "GL_APPLE_clip_distance", 91*8975f5c5SAndroid Build Coastguard Worker "GL_ARB_sync", 92*8975f5c5SAndroid Build Coastguard Worker "GL_ARM_rgba8", 93*8975f5c5SAndroid Build Coastguard Worker "GL_ARM_shader_framebuffer_fetch", 94*8975f5c5SAndroid Build Coastguard Worker "GL_ARM_shader_framebuffer_fetch_depth_stencil", 95*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_base_instance", 96*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_blend_func_extended", 97*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_blend_minmax", 98*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_buffer_storage", 99*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_clear_texture", 100*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_clip_control", 101*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_clip_cull_distance", 102*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_color_buffer_float", 103*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_color_buffer_half_float", 104*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_compressed_ETC1_RGB8_sub_texture", 105*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_conservative_depth", 106*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_copy_image", 107*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_depth_clamp", 108*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_disjoint_timer_query", 109*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_draw_buffers", 110*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_draw_buffers_indexed", 111*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_draw_elements_base_vertex", 112*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_EGL_image_array", 113*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_EGL_image_external_wrap_modes", 114*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_EGL_image_storage", 115*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_EGL_image_storage_compression", 116*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_external_buffer", 117*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_float_blend", 118*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_frag_depth", 119*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_geometry_shader", 120*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_gpu_shader5", 121*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_instanced_arrays", 122*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_map_buffer_range", 123*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_memory_object", 124*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_memory_object_fd", 125*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_multi_draw_indirect", 126*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_multisampled_render_to_texture", 127*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_multisampled_render_to_texture2", 128*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_occlusion_query_boolean", 129*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_polygon_offset_clamp", 130*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_protected_textures", 131*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_pvrtc_sRGB", 132*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_read_format_bgra", 133*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_render_snorm", 134*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_semaphore", 135*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_semaphore_fd", 136*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_separate_depth_stencil", 137*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_separate_shader_objects", 138*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_shader_framebuffer_fetch", 139*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_shader_framebuffer_fetch_non_coherent", 140*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_shader_io_blocks", 141*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_shader_non_constant_global_initializers", 142*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_shader_texture_lod", 143*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_shadow_samplers", 144*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_sRGB", 145*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_tessellation_shader", 146*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_border_clamp", 147*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_buffer", 148*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_astc_decode_mode", 149*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_astc_decode_mode_rgb9e5", 150*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_bptc", 151*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_dxt1", 152*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_rgtc", 153*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_s3tc", 154*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_compression_s3tc_srgb", 155*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_cube_map_array", 156*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_filter_anisotropic", 157*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_filter_minmax", 158*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_format_BGRA8888", 159*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_mirror_clamp_to_edge", 160*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_norm16", 161*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_query_lod", 162*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_rg", 163*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_shadow_lod", 164*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_sRGB_R8", 165*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_sRGB_RG8", 166*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_storage", 167*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_storage_compression", 168*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_type_2_10_10_10_REV", 169*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_unpack_subimage", 170*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_YUV_target", 171*8975f5c5SAndroid Build Coastguard Worker "GL_IMG_texture_compression_pvrtc", 172*8975f5c5SAndroid Build Coastguard Worker "GL_IMG_texture_compression_pvrtc2", 173*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_parallel_shader_compile", 174*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_texture_compression_astc_hdr", 175*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_texture_compression_astc_ldr", 176*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_texture_compression_astc_sliced_3d", 177*8975f5c5SAndroid Build Coastguard Worker "GL_MESA_framebuffer_flip_y", 178*8975f5c5SAndroid Build Coastguard Worker "GL_NV_depth_buffer_float2", 179*8975f5c5SAndroid Build Coastguard Worker "GL_NV_EGL_stream_consumer_external", 180*8975f5c5SAndroid Build Coastguard Worker "GL_NV_framebuffer_blit", 181*8975f5c5SAndroid Build Coastguard Worker "GL_NV_pack_subimage", 182*8975f5c5SAndroid Build Coastguard Worker "GL_NV_pixel_buffer_object", 183*8975f5c5SAndroid Build Coastguard Worker "GL_NV_polygon_mode", 184*8975f5c5SAndroid Build Coastguard Worker "GL_NV_read_depth", 185*8975f5c5SAndroid Build Coastguard Worker "GL_NV_read_depth_stencil", 186*8975f5c5SAndroid Build Coastguard Worker "GL_NV_read_stencil", 187*8975f5c5SAndroid Build Coastguard Worker "GL_NV_shader_noperspective_interpolation", 188*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_EAC_R11_signed_texture", 189*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_EAC_R11_unsigned_texture", 190*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_EAC_RG11_signed_texture", 191*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_EAC_RG11_unsigned_texture", 192*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC1_RGB8_texture", 193*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC2_punchthroughA_RGBA8_texture", 194*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture", 195*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC2_RGB8_texture", 196*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC2_RGBA8_texture", 197*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC2_sRGB8_alpha8_texture", 198*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_ETC2_sRGB8_texture", 199*8975f5c5SAndroid Build Coastguard Worker "GL_OES_compressed_paletted_texture", 200*8975f5c5SAndroid Build Coastguard Worker "GL_OES_copy_image", 201*8975f5c5SAndroid Build Coastguard Worker "GL_OES_depth_texture_cube_map", 202*8975f5c5SAndroid Build Coastguard Worker "GL_OES_draw_buffers_indexed", 203*8975f5c5SAndroid Build Coastguard Worker "GL_OES_draw_elements_base_vertex", 204*8975f5c5SAndroid Build Coastguard Worker "GL_OES_EGL_image", 205*8975f5c5SAndroid Build Coastguard Worker "GL_OES_EGL_image_external", 206*8975f5c5SAndroid Build Coastguard Worker "GL_OES_EGL_image_external_essl3", 207*8975f5c5SAndroid Build Coastguard Worker "GL_OES_element_index_uint", 208*8975f5c5SAndroid Build Coastguard Worker "GL_OES_fbo_render_mipmap", 209*8975f5c5SAndroid Build Coastguard Worker "GL_OES_geometry_shader", 210*8975f5c5SAndroid Build Coastguard Worker "GL_OES_get_program_binary", 211*8975f5c5SAndroid Build Coastguard Worker "GL_OES_gpu_shader5", 212*8975f5c5SAndroid Build Coastguard Worker "GL_OES_mapbuffer", 213*8975f5c5SAndroid Build Coastguard Worker "GL_OES_required_internalformat", 214*8975f5c5SAndroid Build Coastguard Worker "GL_OES_rgb8_rgba8", 215*8975f5c5SAndroid Build Coastguard Worker "GL_OES_sample_shading", 216*8975f5c5SAndroid Build Coastguard Worker "GL_OES_sample_variables", 217*8975f5c5SAndroid Build Coastguard Worker "GL_OES_shader_image_atomic", 218*8975f5c5SAndroid Build Coastguard Worker "GL_OES_shader_io_blocks", 219*8975f5c5SAndroid Build Coastguard Worker "GL_OES_shader_multisample_interpolation", 220*8975f5c5SAndroid Build Coastguard Worker "GL_OES_standard_derivatives", 221*8975f5c5SAndroid Build Coastguard Worker "GL_OES_tessellation_shader", 222*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_3D", 223*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_border_clamp", 224*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_buffer", 225*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_compression_astc", 226*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_cube_map_array", 227*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_float", 228*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_float_linear", 229*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_half_float", 230*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_half_float_linear", 231*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_npot", 232*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_stencil8", 233*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_storage_multisample_2d_array", 234*8975f5c5SAndroid Build Coastguard Worker "GL_OES_vertex_array_object", 235*8975f5c5SAndroid Build Coastguard Worker "GL_OES_vertex_half_float", 236*8975f5c5SAndroid Build Coastguard Worker "GL_OES_vertex_type_10_10_10_2", 237*8975f5c5SAndroid Build Coastguard Worker "GL_OVR_multiview", 238*8975f5c5SAndroid Build Coastguard Worker "GL_OVR_multiview2", 239*8975f5c5SAndroid Build Coastguard Worker "GL_QCOM_framebuffer_foveated", 240*8975f5c5SAndroid Build Coastguard Worker "GL_QCOM_render_shared_exponent", 241*8975f5c5SAndroid Build Coastguard Worker "GL_QCOM_shading_rate", 242*8975f5c5SAndroid Build Coastguard Worker "GL_QCOM_texture_foveated", 243*8975f5c5SAndroid Build Coastguard Worker "GL_QCOM_tiled_rendering", 244*8975f5c5SAndroid Build Coastguard Worker "GL_WEBGL_video_texture", 245*8975f5c5SAndroid Build Coastguard Worker] 246*8975f5c5SAndroid Build Coastguard Worker 247*8975f5c5SAndroid Build Coastguard Workerangle_es_only_extensions = [ 248*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_client_arrays", 249*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_get_serialized_context_string", 250*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_program_binary", 251*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_program_binary_readiness_query", 252*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_program_cache_control", 253*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_relaxed_vertex_attribute_type", 254*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_request_extension", 255*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_rgbx_internal_format", 256*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_robust_client_memory", 257*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_robust_resource_initialization", 258*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_shader_binary", 259*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_webgl_compatibility", 260*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_bind_generates_resource", 261*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_bind_uniform_location", 262*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_copy_compressed_texture", 263*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_copy_texture", 264*8975f5c5SAndroid Build Coastguard Worker "GL_CHROMIUM_framebuffer_mixed_samples", 265*8975f5c5SAndroid Build Coastguard Worker] 266*8975f5c5SAndroid Build Coastguard Worker 267*8975f5c5SAndroid Build Coastguard Workergles_es_only_extensions = [ 268*8975f5c5SAndroid Build Coastguard Worker "GL_AMD_performance_monitor", 269*8975f5c5SAndroid Build Coastguard Worker "GL_ANDROID_extension_pack_es31a", 270*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_depth_texture", 271*8975f5c5SAndroid Build Coastguard Worker "GL_ANGLE_translated_shader_source", 272*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_debug_label", 273*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_debug_marker", 274*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_discard_framebuffer", 275*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_multisample_compatibility", 276*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_primitive_bounding_box", 277*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_robustness", 278*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_sRGB_write_control", 279*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_format_sRGB_override", 280*8975f5c5SAndroid Build Coastguard Worker "GL_EXT_texture_sRGB_decode", 281*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_blend_equation_advanced", 282*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_blend_equation_advanced_coherent", 283*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_debug", 284*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_no_error", 285*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_robust_buffer_access_behavior", 286*8975f5c5SAndroid Build Coastguard Worker "GL_KHR_robustness", 287*8975f5c5SAndroid Build Coastguard Worker "GL_NV_fence", 288*8975f5c5SAndroid Build Coastguard Worker "GL_NV_robustness_video_memory_purge", 289*8975f5c5SAndroid Build Coastguard Worker "GL_OES_depth24", 290*8975f5c5SAndroid Build Coastguard Worker "GL_OES_depth32", 291*8975f5c5SAndroid Build Coastguard Worker "GL_OES_depth_texture", 292*8975f5c5SAndroid Build Coastguard Worker "GL_OES_EGL_sync", 293*8975f5c5SAndroid Build Coastguard Worker "GL_OES_packed_depth_stencil", 294*8975f5c5SAndroid Build Coastguard Worker "GL_OES_primitive_bounding_box", 295*8975f5c5SAndroid Build Coastguard Worker "GL_OES_surfaceless_context", 296*8975f5c5SAndroid Build Coastguard Worker] 297*8975f5c5SAndroid Build Coastguard Worker 298*8975f5c5SAndroid Build Coastguard Worker# ES1 (Possibly the min set of extensions needed by Android) 299*8975f5c5SAndroid Build Coastguard Workergles1_extensions = [ 300*8975f5c5SAndroid Build Coastguard Worker "GL_OES_blend_subtract", 301*8975f5c5SAndroid Build Coastguard Worker "GL_OES_draw_texture", 302*8975f5c5SAndroid Build Coastguard Worker "GL_OES_framebuffer_object", 303*8975f5c5SAndroid Build Coastguard Worker "GL_OES_matrix_palette", 304*8975f5c5SAndroid Build Coastguard Worker "GL_OES_point_size_array", 305*8975f5c5SAndroid Build Coastguard Worker "GL_OES_point_sprite", 306*8975f5c5SAndroid Build Coastguard Worker "GL_OES_query_matrix", 307*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_cube_map", 308*8975f5c5SAndroid Build Coastguard Worker "GL_OES_texture_mirrored_repeat", 309*8975f5c5SAndroid Build Coastguard Worker] 310*8975f5c5SAndroid Build Coastguard Worker 311*8975f5c5SAndroid Build Coastguard Worker 312*8975f5c5SAndroid Build Coastguard Workerdef check_sorted(name, l): 313*8975f5c5SAndroid Build Coastguard Worker unidiff = difflib.unified_diff(l, sorted(l, key=str.casefold), 'unsorted', 'sorted') 314*8975f5c5SAndroid Build Coastguard Worker diff_lines = list(unidiff) 315*8975f5c5SAndroid Build Coastguard Worker assert not diff_lines, '\n\nPlease sort "%s":\n%s' % (name, '\n'.join(diff_lines)) 316*8975f5c5SAndroid Build Coastguard Worker 317*8975f5c5SAndroid Build Coastguard Worker 318*8975f5c5SAndroid Build Coastguard Workerangle_extensions = angle_requestable_extensions + angle_es_only_extensions + angle_toggleable_extensions 319*8975f5c5SAndroid Build Coastguard Workergles_extensions = gles_requestable_extensions + gles_es_only_extensions 320*8975f5c5SAndroid Build Coastguard Workersupported_extensions = sorted(angle_extensions + gles1_extensions + gles_extensions) 321*8975f5c5SAndroid Build Coastguard Worker 322*8975f5c5SAndroid Build Coastguard Workerassert len(supported_extensions) == len(set(supported_extensions)), 'Duplicates in extension list' 323*8975f5c5SAndroid Build Coastguard Workercheck_sorted('angle_requestable_extensions', angle_requestable_extensions) 324*8975f5c5SAndroid Build Coastguard Workercheck_sorted('angle_es_only_extensions', angle_es_only_extensions) 325*8975f5c5SAndroid Build Coastguard Workercheck_sorted('angle_toggleable_extensions', angle_toggleable_extensions) 326*8975f5c5SAndroid Build Coastguard Workercheck_sorted('gles_requestable_extensions', gles_requestable_extensions) 327*8975f5c5SAndroid Build Coastguard Workercheck_sorted('gles_es_only_extensions', gles_es_only_extensions) 328*8975f5c5SAndroid Build Coastguard Workercheck_sorted('gles_extensions', gles1_extensions) 329*8975f5c5SAndroid Build Coastguard Worker 330*8975f5c5SAndroid Build Coastguard Workersupported_egl_extensions = [ 331*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_blob_cache", 332*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_create_native_client_buffer", 333*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_framebuffer_target", 334*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_get_frame_timestamps", 335*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_get_native_client_buffer", 336*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_native_fence_sync", 337*8975f5c5SAndroid Build Coastguard Worker "EGL_ANDROID_presentation_time", 338*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_create_surface_swap_interval", 339*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_d3d_share_handle_client_buffer", 340*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_device_creation", 341*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_device_d3d", 342*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_device_d3d11", 343*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_device_d3d9", 344*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_display_semaphore_share_group", 345*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_display_texture_share_group", 346*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_external_context_and_surface", 347*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_feature_control", 348*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_ggp_stream_descriptor", 349*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_metal_create_context_ownership_identity", 350*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_metal_shared_event_sync", 351*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_no_error", 352*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_power_preference", 353*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_prepare_swap_buffers", 354*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_program_cache_control", 355*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_query_surface_pointer", 356*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_stream_producer_d3d_texture", 357*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_surface_d3d_texture_2d_share_handle", 358*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_swap_with_frame_token", 359*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_sync_control_rate", 360*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_vulkan_image", 361*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_wait_until_work_scheduled", 362*8975f5c5SAndroid Build Coastguard Worker "EGL_ANGLE_window_fixed_size", 363*8975f5c5SAndroid Build Coastguard Worker "EGL_CHROMIUM_sync_control", 364*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_create_context_robustness", 365*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_device_query", 366*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_bt2020_hlg", 367*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_bt2020_linear", 368*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_bt2020_pq", 369*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_display_p3", 370*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_display_p3_linear", 371*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_display_p3_passthrough", 372*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_scrgb", 373*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_scrgb_linear", 374*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_image_dma_buf_import", 375*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_image_dma_buf_import_modifiers", 376*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_image_gl_colorspace", 377*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_pixel_format_float", 378*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_platform_base", 379*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_platform_device", 380*8975f5c5SAndroid Build Coastguard Worker "EGL_EXT_protected_content", 381*8975f5c5SAndroid Build Coastguard Worker "EGL_IMG_context_priority", 382*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_debug", 383*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_fence_sync", 384*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_gl_colorspace", 385*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_image", 386*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_lock_surface3", 387*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_mutable_render_buffer", 388*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_no_config_context", 389*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_partial_update", 390*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_reusable_sync", 391*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_stream", 392*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_stream_consumer_gltexture", 393*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_surfaceless_context", 394*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_swap_buffers_with_damage", 395*8975f5c5SAndroid Build Coastguard Worker "EGL_KHR_wait_sync", 396*8975f5c5SAndroid Build Coastguard Worker "EGL_NV_post_sub_buffer", 397*8975f5c5SAndroid Build Coastguard Worker "EGL_NV_stream_consumer_gltexture_yuv", 398*8975f5c5SAndroid Build Coastguard Worker] 399*8975f5c5SAndroid Build Coastguard Worker 400*8975f5c5SAndroid Build Coastguard Workercheck_sorted('supported_egl_extensions', supported_egl_extensions) 401*8975f5c5SAndroid Build Coastguard Worker 402*8975f5c5SAndroid Build Coastguard Workersupported_cl_extensions = [ 403*8975f5c5SAndroid Build Coastguard Worker # Since OpenCL 1.1 404*8975f5c5SAndroid Build Coastguard Worker "cl_khr_byte_addressable_store", 405*8975f5c5SAndroid Build Coastguard Worker "cl_khr_global_int32_base_atomics", 406*8975f5c5SAndroid Build Coastguard Worker "cl_khr_global_int32_extended_atomics", 407*8975f5c5SAndroid Build Coastguard Worker "cl_khr_local_int32_base_atomics", 408*8975f5c5SAndroid Build Coastguard Worker "cl_khr_local_int32_extended_atomics", 409*8975f5c5SAndroid Build Coastguard Worker 410*8975f5c5SAndroid Build Coastguard Worker # OpenCL 2.0 - 2.2 411*8975f5c5SAndroid Build Coastguard Worker "cl_khr_3d_image_writes", 412*8975f5c5SAndroid Build Coastguard Worker "cl_khr_depth_images", 413*8975f5c5SAndroid Build Coastguard Worker "cl_khr_image2d_from_buffer", 414*8975f5c5SAndroid Build Coastguard Worker 415*8975f5c5SAndroid Build Coastguard Worker # Optional 416*8975f5c5SAndroid Build Coastguard Worker "cl_khr_extended_versioning", 417*8975f5c5SAndroid Build Coastguard Worker "cl_khr_fp64", 418*8975f5c5SAndroid Build Coastguard Worker "cl_khr_icd", 419*8975f5c5SAndroid Build Coastguard Worker "cl_khr_int64_base_atomics", 420*8975f5c5SAndroid Build Coastguard Worker "cl_khr_int64_extended_atomics", 421*8975f5c5SAndroid Build Coastguard Worker] 422*8975f5c5SAndroid Build Coastguard Worker 423*8975f5c5SAndroid Build Coastguard Worker# Strip these suffixes from Context entry point names. NV is excluded (for now). 424*8975f5c5SAndroid Build Coastguard Workerstrip_suffixes = ["AMD", "ANDROID", "ANGLE", "CHROMIUM", "EXT", "KHR", "OES", "OVR", "QCOM"] 425*8975f5c5SAndroid Build Coastguard Workercheck_sorted('strip_suffixes', strip_suffixes) 426*8975f5c5SAndroid Build Coastguard Worker 427*8975f5c5SAndroid Build Coastguard Worker# The EGL_ANGLE_explicit_context extension is generated differently from other extensions. 428*8975f5c5SAndroid Build Coastguard Worker# Toggle generation here. 429*8975f5c5SAndroid Build Coastguard Workersupport_EGL_ANGLE_explicit_context = True 430*8975f5c5SAndroid Build Coastguard Worker 431*8975f5c5SAndroid Build Coastguard Worker# Group names that appear in command/param, but not present in groups/group 432*8975f5c5SAndroid Build Coastguard Workerunsupported_enum_group_names = { 433*8975f5c5SAndroid Build Coastguard Worker 'GetMultisamplePNameNV', 434*8975f5c5SAndroid Build Coastguard Worker 'BufferPNameARB', 435*8975f5c5SAndroid Build Coastguard Worker 'BufferPointerNameARB', 436*8975f5c5SAndroid Build Coastguard Worker 'VertexAttribPointerPropertyARB', 437*8975f5c5SAndroid Build Coastguard Worker 'VertexAttribPropertyARB', 438*8975f5c5SAndroid Build Coastguard Worker 'FenceParameterNameNV', 439*8975f5c5SAndroid Build Coastguard Worker 'FenceConditionNV', 440*8975f5c5SAndroid Build Coastguard Worker 'BufferPointerNameARB', 441*8975f5c5SAndroid Build Coastguard Worker 'MatrixIndexPointerTypeARB', 442*8975f5c5SAndroid Build Coastguard Worker 'PointParameterNameARB', 443*8975f5c5SAndroid Build Coastguard Worker 'ClampColorTargetARB', 444*8975f5c5SAndroid Build Coastguard Worker 'ClampColorModeARB', 445*8975f5c5SAndroid Build Coastguard Worker} 446*8975f5c5SAndroid Build Coastguard Worker 447*8975f5c5SAndroid Build Coastguard Worker# Versions (major, minor). Note that GLES intentionally places 1.0 last. 448*8975f5c5SAndroid Build Coastguard WorkerGLES_VERSIONS = [(2, 0), (3, 0), (3, 1), (3, 2), (1, 0)] 449*8975f5c5SAndroid Build Coastguard WorkerEGL_VERSIONS = [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] 450*8975f5c5SAndroid Build Coastguard WorkerCL_VERSIONS = [(1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), (3, 0)] 451*8975f5c5SAndroid Build Coastguard Worker 452*8975f5c5SAndroid Build Coastguard Worker 453*8975f5c5SAndroid Build Coastguard Worker# API types 454*8975f5c5SAndroid Build Coastguard Workerclass apis: 455*8975f5c5SAndroid Build Coastguard Worker GL = 'GL' 456*8975f5c5SAndroid Build Coastguard Worker GLES = 'GLES' 457*8975f5c5SAndroid Build Coastguard Worker WGL = 'WGL' 458*8975f5c5SAndroid Build Coastguard Worker GLX = 'GLX' 459*8975f5c5SAndroid Build Coastguard Worker EGL = 'EGL' 460*8975f5c5SAndroid Build Coastguard Worker CL = 'CL' 461*8975f5c5SAndroid Build Coastguard Worker 462*8975f5c5SAndroid Build Coastguard Worker# For GLenum types 463*8975f5c5SAndroid Build Coastguard Workerapi_enums = {apis.GL: 'BigGLEnum', apis.GLES: 'GLESEnum'} 464*8975f5c5SAndroid Build Coastguard Workerdefault_enum_group_name = 'AllEnums' 465*8975f5c5SAndroid Build Coastguard Worker 466*8975f5c5SAndroid Build Coastguard Worker 467*8975f5c5SAndroid Build Coastguard Workerdef script_relative(path): 468*8975f5c5SAndroid Build Coastguard Worker return os.path.join(os.path.dirname(sys.argv[0]), path) 469*8975f5c5SAndroid Build Coastguard Worker 470*8975f5c5SAndroid Build Coastguard Worker 471*8975f5c5SAndroid Build Coastguard Workerdef path_to(folder, file): 472*8975f5c5SAndroid Build Coastguard Worker return os.path.join(script_relative(".."), "src", folder, file) 473*8975f5c5SAndroid Build Coastguard Worker 474*8975f5c5SAndroid Build Coastguard Worker 475*8975f5c5SAndroid Build Coastguard Workerdef strip_api_prefix(cmd_name): 476*8975f5c5SAndroid Build Coastguard Worker return cmd_name.lstrip("cwegl") 477*8975f5c5SAndroid Build Coastguard Worker 478*8975f5c5SAndroid Build Coastguard Worker 479*8975f5c5SAndroid Build Coastguard Workerdef find_xml_input(xml_file): 480*8975f5c5SAndroid Build Coastguard Worker for found_xml in xml_inputs: 481*8975f5c5SAndroid Build Coastguard Worker if found_xml == xml_file or found_xml.endswith('/' + xml_file): 482*8975f5c5SAndroid Build Coastguard Worker return found_xml 483*8975f5c5SAndroid Build Coastguard Worker raise Exception('Could not find XML input: ' + xml_file) 484*8975f5c5SAndroid Build Coastguard Worker 485*8975f5c5SAndroid Build Coastguard Worker 486*8975f5c5SAndroid Build Coastguard Workerdef get_cmd_name(command_node): 487*8975f5c5SAndroid Build Coastguard Worker proto = command_node.find('proto') 488*8975f5c5SAndroid Build Coastguard Worker cmd_name = proto.find('name').text 489*8975f5c5SAndroid Build Coastguard Worker return cmd_name 490*8975f5c5SAndroid Build Coastguard Worker 491*8975f5c5SAndroid Build Coastguard Worker 492*8975f5c5SAndroid Build Coastguard Workerclass CommandNames: 493*8975f5c5SAndroid Build Coastguard Worker 494*8975f5c5SAndroid Build Coastguard Worker def __init__(self): 495*8975f5c5SAndroid Build Coastguard Worker self.command_names = {} 496*8975f5c5SAndroid Build Coastguard Worker 497*8975f5c5SAndroid Build Coastguard Worker def get_commands(self, version): 498*8975f5c5SAndroid Build Coastguard Worker return self.command_names[version] 499*8975f5c5SAndroid Build Coastguard Worker 500*8975f5c5SAndroid Build Coastguard Worker def get_all_commands(self): 501*8975f5c5SAndroid Build Coastguard Worker cmd_names = [] 502*8975f5c5SAndroid Build Coastguard Worker # Combine all the version lists into a single list 503*8975f5c5SAndroid Build Coastguard Worker for version, version_cmd_names in sorted(self.command_names.items()): 504*8975f5c5SAndroid Build Coastguard Worker cmd_names += version_cmd_names 505*8975f5c5SAndroid Build Coastguard Worker 506*8975f5c5SAndroid Build Coastguard Worker return cmd_names 507*8975f5c5SAndroid Build Coastguard Worker 508*8975f5c5SAndroid Build Coastguard Worker def add_commands(self, version, commands): 509*8975f5c5SAndroid Build Coastguard Worker # Add key if it doesn't exist 510*8975f5c5SAndroid Build Coastguard Worker if version not in self.command_names: 511*8975f5c5SAndroid Build Coastguard Worker self.command_names[version] = [] 512*8975f5c5SAndroid Build Coastguard Worker # Add the commands that aren't duplicates 513*8975f5c5SAndroid Build Coastguard Worker self.command_names[version] += commands 514*8975f5c5SAndroid Build Coastguard Worker 515*8975f5c5SAndroid Build Coastguard Worker 516*8975f5c5SAndroid Build Coastguard Workerclass RegistryXML: 517*8975f5c5SAndroid Build Coastguard Worker 518*8975f5c5SAndroid Build Coastguard Worker def __init__(self, xml_file, ext_file=None): 519*8975f5c5SAndroid Build Coastguard Worker tree = etree.parse(script_relative(find_xml_input(xml_file))) 520*8975f5c5SAndroid Build Coastguard Worker self.root = tree.getroot() 521*8975f5c5SAndroid Build Coastguard Worker if (ext_file): 522*8975f5c5SAndroid Build Coastguard Worker self._AppendANGLEExts(find_xml_input(ext_file)) 523*8975f5c5SAndroid Build Coastguard Worker self.all_commands = self.root.findall('commands/command') 524*8975f5c5SAndroid Build Coastguard Worker self.all_cmd_names = CommandNames() 525*8975f5c5SAndroid Build Coastguard Worker self.commands = {} 526*8975f5c5SAndroid Build Coastguard Worker 527*8975f5c5SAndroid Build Coastguard Worker def _AppendANGLEExts(self, ext_file): 528*8975f5c5SAndroid Build Coastguard Worker angle_ext_tree = etree.parse(script_relative(ext_file)) 529*8975f5c5SAndroid Build Coastguard Worker angle_ext_root = angle_ext_tree.getroot() 530*8975f5c5SAndroid Build Coastguard Worker 531*8975f5c5SAndroid Build Coastguard Worker insertion_point = self.root.findall("./types")[0] 532*8975f5c5SAndroid Build Coastguard Worker for t in angle_ext_root.iter('types'): 533*8975f5c5SAndroid Build Coastguard Worker insertion_point.extend(t) 534*8975f5c5SAndroid Build Coastguard Worker 535*8975f5c5SAndroid Build Coastguard Worker insertion_point = self.root.findall("./commands")[0] 536*8975f5c5SAndroid Build Coastguard Worker for command in angle_ext_root.iter('commands'): 537*8975f5c5SAndroid Build Coastguard Worker insertion_point.extend(command) 538*8975f5c5SAndroid Build Coastguard Worker 539*8975f5c5SAndroid Build Coastguard Worker insertion_point = self.root.findall("./extensions")[0] 540*8975f5c5SAndroid Build Coastguard Worker for extension in angle_ext_root.iter('extensions'): 541*8975f5c5SAndroid Build Coastguard Worker insertion_point.extend(extension) 542*8975f5c5SAndroid Build Coastguard Worker 543*8975f5c5SAndroid Build Coastguard Worker insertion_point = self.root 544*8975f5c5SAndroid Build Coastguard Worker for enums in angle_ext_root.iter('enums'): 545*8975f5c5SAndroid Build Coastguard Worker insertion_point.append(enums) 546*8975f5c5SAndroid Build Coastguard Worker 547*8975f5c5SAndroid Build Coastguard Worker def AddCommands(self, feature_name, annotation): 548*8975f5c5SAndroid Build Coastguard Worker xpath = ".//feature[@name='%s']//command" % feature_name 549*8975f5c5SAndroid Build Coastguard Worker commands = [cmd.attrib['name'] for cmd in self.root.findall(xpath)] 550*8975f5c5SAndroid Build Coastguard Worker 551*8975f5c5SAndroid Build Coastguard Worker # Remove commands that have already been processed 552*8975f5c5SAndroid Build Coastguard Worker current_cmds = self.all_cmd_names.get_all_commands() 553*8975f5c5SAndroid Build Coastguard Worker commands = [cmd for cmd in commands if cmd not in current_cmds] 554*8975f5c5SAndroid Build Coastguard Worker 555*8975f5c5SAndroid Build Coastguard Worker self.all_cmd_names.add_commands(annotation, commands) 556*8975f5c5SAndroid Build Coastguard Worker self.commands[annotation] = commands 557*8975f5c5SAndroid Build Coastguard Worker 558*8975f5c5SAndroid Build Coastguard Worker def _ClassifySupport(self, extension): 559*8975f5c5SAndroid Build Coastguard Worker supported = extension.attrib['supported'] 560*8975f5c5SAndroid Build Coastguard Worker # Desktop GL extensions exposed in ANGLE GLES for Chrome. 561*8975f5c5SAndroid Build Coastguard Worker if extension.attrib['name'] in ['GL_ARB_sync', 'GL_NV_robustness_video_memory_purge']: 562*8975f5c5SAndroid Build Coastguard Worker supported += "|gles2" 563*8975f5c5SAndroid Build Coastguard Worker if 'gles2' in supported: 564*8975f5c5SAndroid Build Coastguard Worker return 'gl2ext' 565*8975f5c5SAndroid Build Coastguard Worker elif 'gles1' in supported: 566*8975f5c5SAndroid Build Coastguard Worker return 'glext' 567*8975f5c5SAndroid Build Coastguard Worker elif 'egl' in supported: 568*8975f5c5SAndroid Build Coastguard Worker return 'eglext' 569*8975f5c5SAndroid Build Coastguard Worker elif 'wgl' in supported: 570*8975f5c5SAndroid Build Coastguard Worker return 'wglext' 571*8975f5c5SAndroid Build Coastguard Worker elif 'glx' in supported: 572*8975f5c5SAndroid Build Coastguard Worker return 'glxext' 573*8975f5c5SAndroid Build Coastguard Worker elif 'cl' in supported: 574*8975f5c5SAndroid Build Coastguard Worker return 'clext' 575*8975f5c5SAndroid Build Coastguard Worker else: 576*8975f5c5SAndroid Build Coastguard Worker assert False, 'Cannot classify support for %s: %s' % (extension.attrib['name'], 577*8975f5c5SAndroid Build Coastguard Worker supported) 578*8975f5c5SAndroid Build Coastguard Worker return 'unknown' 579*8975f5c5SAndroid Build Coastguard Worker 580*8975f5c5SAndroid Build Coastguard Worker def AddExtensionCommands(self, supported_extensions, apis): 581*8975f5c5SAndroid Build Coastguard Worker # Use a first step to run through the extensions so we can generate them 582*8975f5c5SAndroid Build Coastguard Worker # in sorted order. 583*8975f5c5SAndroid Build Coastguard Worker self.ext_data = {} 584*8975f5c5SAndroid Build Coastguard Worker self.ext_dupes = {} 585*8975f5c5SAndroid Build Coastguard Worker ext_annotations = {} 586*8975f5c5SAndroid Build Coastguard Worker 587*8975f5c5SAndroid Build Coastguard Worker for extension in self.root.findall("extensions/extension"): 588*8975f5c5SAndroid Build Coastguard Worker extension_name = extension.attrib['name'] 589*8975f5c5SAndroid Build Coastguard Worker if not extension_name in supported_extensions: 590*8975f5c5SAndroid Build Coastguard Worker continue 591*8975f5c5SAndroid Build Coastguard Worker 592*8975f5c5SAndroid Build Coastguard Worker ext_annotations[extension_name] = self._ClassifySupport(extension) 593*8975f5c5SAndroid Build Coastguard Worker 594*8975f5c5SAndroid Build Coastguard Worker ext_cmd_names = [] 595*8975f5c5SAndroid Build Coastguard Worker 596*8975f5c5SAndroid Build Coastguard Worker # There's an extra step here to filter out 'api=gl' extensions. This 597*8975f5c5SAndroid Build Coastguard Worker # is necessary for handling KHR extensions, which have separate entry 598*8975f5c5SAndroid Build Coastguard Worker # point signatures (without the suffix) for desktop GL. Note that this 599*8975f5c5SAndroid Build Coastguard Worker # extra step is necessary because of Etree's limited Xpath support. 600*8975f5c5SAndroid Build Coastguard Worker for require in extension.findall('require'): 601*8975f5c5SAndroid Build Coastguard Worker if 'api' in require.attrib and require.attrib['api'] not in apis: 602*8975f5c5SAndroid Build Coastguard Worker continue 603*8975f5c5SAndroid Build Coastguard Worker 604*8975f5c5SAndroid Build Coastguard Worker # A special case for EXT_texture_storage 605*8975f5c5SAndroid Build Coastguard Worker filter_out_comment = "Supported only if GL_EXT_direct_state_access is supported" 606*8975f5c5SAndroid Build Coastguard Worker if 'comment' in require.attrib and require.attrib['comment'] == filter_out_comment: 607*8975f5c5SAndroid Build Coastguard Worker continue 608*8975f5c5SAndroid Build Coastguard Worker 609*8975f5c5SAndroid Build Coastguard Worker extension_commands = require.findall('command') 610*8975f5c5SAndroid Build Coastguard Worker ext_cmd_names += [command.attrib['name'] for command in extension_commands] 611*8975f5c5SAndroid Build Coastguard Worker 612*8975f5c5SAndroid Build Coastguard Worker self.ext_data[extension_name] = sorted(ext_cmd_names) 613*8975f5c5SAndroid Build Coastguard Worker 614*8975f5c5SAndroid Build Coastguard Worker for extension_name, ext_cmd_names in sorted(self.ext_data.items()): 615*8975f5c5SAndroid Build Coastguard Worker 616*8975f5c5SAndroid Build Coastguard Worker # Detect and filter duplicate extensions. 617*8975f5c5SAndroid Build Coastguard Worker dupes = [] 618*8975f5c5SAndroid Build Coastguard Worker for ext_cmd in ext_cmd_names: 619*8975f5c5SAndroid Build Coastguard Worker if ext_cmd in self.all_cmd_names.get_all_commands(): 620*8975f5c5SAndroid Build Coastguard Worker dupes.append(ext_cmd) 621*8975f5c5SAndroid Build Coastguard Worker 622*8975f5c5SAndroid Build Coastguard Worker for dupe in dupes: 623*8975f5c5SAndroid Build Coastguard Worker ext_cmd_names.remove(dupe) 624*8975f5c5SAndroid Build Coastguard Worker 625*8975f5c5SAndroid Build Coastguard Worker self.ext_data[extension_name] = sorted(ext_cmd_names) 626*8975f5c5SAndroid Build Coastguard Worker self.ext_dupes[extension_name] = dupes 627*8975f5c5SAndroid Build Coastguard Worker self.all_cmd_names.add_commands(ext_annotations[extension_name], ext_cmd_names) 628*8975f5c5SAndroid Build Coastguard Worker 629*8975f5c5SAndroid Build Coastguard Worker def GetEnums(self, override_prefix=None): 630*8975f5c5SAndroid Build Coastguard Worker cmd_names = [] 631*8975f5c5SAndroid Build Coastguard Worker for cmd in self.all_cmd_names.get_all_commands(): 632*8975f5c5SAndroid Build Coastguard Worker stripped = strip_api_prefix(cmd) 633*8975f5c5SAndroid Build Coastguard Worker prefix = override_prefix or cmd[:(len(cmd) - len(stripped))] 634*8975f5c5SAndroid Build Coastguard Worker cmd_names.append( 635*8975f5c5SAndroid Build Coastguard Worker ('%s%s' % (prefix.upper(), stripped), '%s%s' % (prefix.lower(), stripped))) 636*8975f5c5SAndroid Build Coastguard Worker return cmd_names 637*8975f5c5SAndroid Build Coastguard Worker 638*8975f5c5SAndroid Build Coastguard Worker 639*8975f5c5SAndroid Build Coastguard Workerclass EntryPoints: 640*8975f5c5SAndroid Build Coastguard Worker 641*8975f5c5SAndroid Build Coastguard Worker def __init__(self, api, xml, commands): 642*8975f5c5SAndroid Build Coastguard Worker self.api = api 643*8975f5c5SAndroid Build Coastguard Worker self._cmd_info = [] 644*8975f5c5SAndroid Build Coastguard Worker 645*8975f5c5SAndroid Build Coastguard Worker for command_node in xml.all_commands: 646*8975f5c5SAndroid Build Coastguard Worker cmd_name = get_cmd_name(command_node) 647*8975f5c5SAndroid Build Coastguard Worker 648*8975f5c5SAndroid Build Coastguard Worker if api == apis.WGL: 649*8975f5c5SAndroid Build Coastguard Worker cmd_name = cmd_name if cmd_name.startswith('wgl') else 'wgl' + cmd_name 650*8975f5c5SAndroid Build Coastguard Worker 651*8975f5c5SAndroid Build Coastguard Worker if cmd_name not in commands: 652*8975f5c5SAndroid Build Coastguard Worker continue 653*8975f5c5SAndroid Build Coastguard Worker 654*8975f5c5SAndroid Build Coastguard Worker param_text = ["".join(param.itertext()) for param in command_node.findall('param')] 655*8975f5c5SAndroid Build Coastguard Worker 656*8975f5c5SAndroid Build Coastguard Worker # Treat (void) as () 657*8975f5c5SAndroid Build Coastguard Worker if len(param_text) == 1 and param_text[0].strip() == 'void': 658*8975f5c5SAndroid Build Coastguard Worker param_text = [] 659*8975f5c5SAndroid Build Coastguard Worker 660*8975f5c5SAndroid Build Coastguard Worker proto = command_node.find('proto') 661*8975f5c5SAndroid Build Coastguard Worker proto_text = "".join(proto.itertext()) 662*8975f5c5SAndroid Build Coastguard Worker 663*8975f5c5SAndroid Build Coastguard Worker self._cmd_info.append((cmd_name, command_node, param_text, proto_text)) 664*8975f5c5SAndroid Build Coastguard Worker 665*8975f5c5SAndroid Build Coastguard Worker def get_infos(self): 666*8975f5c5SAndroid Build Coastguard Worker return self._cmd_info 667*8975f5c5SAndroid Build Coastguard Worker 668*8975f5c5SAndroid Build Coastguard Worker 669*8975f5c5SAndroid Build Coastguard Workerdef GetEGL(): 670*8975f5c5SAndroid Build Coastguard Worker egl = RegistryXML('egl.xml', 'egl_angle_ext.xml') 671*8975f5c5SAndroid Build Coastguard Worker for major_version, minor_version in EGL_VERSIONS: 672*8975f5c5SAndroid Build Coastguard Worker version = "%d_%d" % (major_version, minor_version) 673*8975f5c5SAndroid Build Coastguard Worker name_prefix = "EGL_VERSION_" 674*8975f5c5SAndroid Build Coastguard Worker feature_name = "%s%s" % (name_prefix, version) 675*8975f5c5SAndroid Build Coastguard Worker egl.AddCommands(feature_name, version) 676*8975f5c5SAndroid Build Coastguard Worker egl.AddExtensionCommands(supported_egl_extensions, ['egl']) 677*8975f5c5SAndroid Build Coastguard Worker return egl 678*8975f5c5SAndroid Build Coastguard Worker 679*8975f5c5SAndroid Build Coastguard Worker 680*8975f5c5SAndroid Build Coastguard Workerdef GetGLES(): 681*8975f5c5SAndroid Build Coastguard Worker gles = RegistryXML('gl.xml', 'gl_angle_ext.xml') 682*8975f5c5SAndroid Build Coastguard Worker for major_version, minor_version in GLES_VERSIONS: 683*8975f5c5SAndroid Build Coastguard Worker version = "{}_{}".format(major_version, minor_version) 684*8975f5c5SAndroid Build Coastguard Worker name_prefix = "GL_ES_VERSION_" 685*8975f5c5SAndroid Build Coastguard Worker if major_version == 1: 686*8975f5c5SAndroid Build Coastguard Worker name_prefix = "GL_VERSION_ES_CM_" 687*8975f5c5SAndroid Build Coastguard Worker feature_name = "{}{}".format(name_prefix, version) 688*8975f5c5SAndroid Build Coastguard Worker gles.AddCommands(feature_name, version) 689*8975f5c5SAndroid Build Coastguard Worker gles.AddExtensionCommands(supported_extensions, ['gles2', 'gles1']) 690*8975f5c5SAndroid Build Coastguard Worker return gles 691