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