@@ -41,7 +41,11 @@ def compare_flags():
4141 idl = get_idl_parser ()
4242 hp = get_h_parser ()
4343
44- name_map = {"ColorWrite" : "ColorWriteMask" }
44+ name_map = {
45+ "ColorWrite" : "ColorWriteMask" ,
46+ "TextureUsage.TextureBinding" : "Sampled" ,
47+ "TextureUsage.StorageBinding" : "Storage" ,
48+ }
4549
4650 for name , flag in idl .flags .items ():
4751 name = name_map .get (name , name )
@@ -50,6 +54,7 @@ def compare_flags():
5054 else :
5155 for key , val in flag .items ():
5256 key = key .title ().replace ("_" , "" ) # MAP_READ -> MapRead
57+ key = name_map .get (f"{ name } .{ key } " ) or key
5358 if key not in hp .flags [name ]:
5459 print (f"Flag field { name } .{ key } missing in wgpu.h" )
5560 elif val != hp .flags [name ][key ]:
@@ -65,7 +70,11 @@ def write_mappings():
6570 idl = get_idl_parser ()
6671 hp = get_h_parser ()
6772
68- field_map = {"discard" : "clear" }
73+ name_map = {
74+ "VertexStepMode" : "InputStepMode" ,
75+ "StoreOp.discard" : "clear" ,
76+ }
77+ name_map_i = {v : k for k , v in name_map .items ()}
6978
7079 # Init generated code
7180 pylines = [mappings_preamble ]
@@ -74,15 +83,14 @@ def write_mappings():
7483 # to the corresponding integer value.
7584 enummap = {}
7685 for name in idl .enums :
77- if name not in hp .enums :
78- print (f"Enum { name } missing in wgpu.h" )
86+ hname = name_map .get (name , name )
87+ if hname not in hp .enums :
88+ print (f"Enum { hname } missing in wgpu.h" )
7989 continue
80- hp_enum = {key .lower (): val for key , val in hp .enums [name ].items ()}
90+ hp_enum = {key .lower (): val for key , val in hp .enums [hname ].items ()}
8191 for ikey in idl .enums [name ].values ():
82- if ikey in field_map :
83- hkey = field_map [ikey ]
84- else :
85- hkey = ikey .lower ().replace ("-" , "" )
92+ hkey = ikey .lower ().replace ("-" , "" )
93+ hkey = name_map .get (f"{ name } .{ hkey } " ) or hkey
8694 if hkey in hp_enum :
8795 enummap [name + "." + ikey ] = hp_enum [hkey ]
8896 else :
@@ -101,7 +109,8 @@ def write_mappings():
101109 for structname , struct in hp .structs .items ():
102110 for key , val in struct .items ():
103111 if isinstance (val , str ) and val .startswith ("WGPU" ):
104- enumname = val [4 :].split ("/" )[0 ]
112+ henumname = val [4 :].split ("/" )[0 ]
113+ enumname = name_map_i .get (henumname , henumname )
105114 if enumname in idl .enums :
106115 cstructfield2enum [f"{ structname [4 :]} .{ key } " ] = enumname
107116 else :
0 commit comments