From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/make_vulkan | 96 ++++++++++--------------------------- include/wine/vulkan.h | 66 +++++++++++++++++-------- 2 files changed, 71 insertions(+), 91 deletions(-)
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 2a7b192685c..759ca680779 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -330,6 +330,10 @@ def api_is_vulkan(obj): return "vulkan" in obj.get("api", "vulkan").split(",")
+def innertext(tag): + return (tag.text or '') + ''.join(innertext(e) for e in tag) + (tag.tail or '') + + def convert_suffix(direction, win_type, unwrap, is_wrapped): if direction == Direction.OUTPUT: if not is_wrapped: @@ -405,8 +409,7 @@ class VkConstant(object):
class VkDefine(object): - def __init__(self, name, value): - self.name = name + def __init__(self, value): self.value = value
@staticmethod @@ -414,59 +417,16 @@ class VkDefine(object): if not api_is_vulkan(define): return None
- name_elem = define.find("name") - - if name_elem is None: - # <type category="define" name="some_name">some_value</type> - name = define.attrib.get("name") - - # We override behavior of VK_USE_64_BIT_PTR_DEFINES as the default non-dispatchable handle - # definition various between 64-bit (uses pointers) and 32-bit (uses uint64_t). - # This complicates TRACEs in the thunks, so just use uint64_t. - if name == "VK_USE_64_BIT_PTR_DEFINES": - value = "#define VK_USE_64_BIT_PTR_DEFINES 0" - else: - value = define.text - return VkDefine(name, value) - - # With a name element the structure is like: - # <type category="define"><name>some_name</name>some_value</type> - name = name_elem.text - - # Perform minimal parsing for Vulkan constants, which we don't need, but are referenced - # elsewhere in vk.xml. - # - VK_API_VERSION is a messy, deprecated constant and we don't want generate code for it. - # - AHardwareBuffer/ANativeWindow are forward declarations for Android types, which leaked - # into the define region. - if name in ["VK_API_VERSION", "AHardwareBuffer", "ANativeWindow", "CAMetalLayer"]: - return VkDefine(name, None) - - # The body of the define is basically unstructured C code. It is not meant for easy parsing. - # Some lines contain deprecated values or comments, which we try to filter out. - value = "" - for line in define.text.splitlines(): - # Skip comments or deprecated values. - if "//" in line: - continue - value += line - - for child in define: - value += child.text - if child.tail is not None: - # Split comments for VK_API_VERSION_1_0 / VK_API_VERSION_1_1 - if "//" in child.tail: - value += child.tail.split("//")[0] - else: - value += child.tail + value = innertext(define) + value = re.sub(r'\s*//.*$', '', value, flags=re.M) + value = value.strip()
- return VkDefine(name, value.rstrip(' ')) + if "#define VK_USE_64_BIT_PTR_DEFINES" in value: + return VkDefine("#define VK_USE_64_BIT_PTR_DEFINES 0") + return VkDefine(value)
def definition(self): - if self.value is None: - return "" - - # Nothing to do as the value was already put in the right form during parsing. - return "{0}\n".format(self.value) + return self.value + '\n'
class VkEnum(object): @@ -3692,26 +3652,18 @@ class VkRegistry(object):
if type_info["category"] == "basetype": name = t.find("name").text - _type = None - if not t.find("type") is None: - _type = t.find("type").text - tail = t.find("type").tail - if tail is not None: - _type += tail.strip() - basetype = VkBaseType(name, _type) - if basetype: - base_types.append(basetype) - type_info["data"] = basetype - else: - continue + define = VkDefine.from_xml(t) + defines.append(define) + type_info["data"] = define
# Basic C types don't need us to define them, but we do need data for them - if type_info["requires"] == "vk_platform": + elif type_info["requires"] == "vk_platform": + name = t.attrib.get("name") requires = type_info["requires"] - basic_c = VkBaseType(name, _type, requires=requires) + basic_c = VkBaseType(name, name, requires=requires) type_info["data"] = basic_c
- if type_info["category"] == "bitmask": + elif type_info["category"] == "bitmask": name = t.find("name").text _type = t.find("type").text
@@ -3722,7 +3674,7 @@ class VkRegistry(object): bitmasks.append(bitmask) type_info["data"] = bitmask
- if type_info["category"] == "define": + elif type_info["category"] == "define": define = VkDefine.from_xml(t) if define: defines.append(define) @@ -3730,7 +3682,7 @@ class VkRegistry(object): else: continue
- if type_info["category"] == "enum": + elif type_info["category"] == "enum": name = t.attrib.get("name") # The type section only contains enum names, not the actual definition. # Since we already parsed the enum before, just link it in. @@ -3742,7 +3694,7 @@ class VkRegistry(object): # definitions. type_info["data"] = None
- if type_info["category"] == "funcpointer": + elif type_info["category"] == "funcpointer": funcpointer = VkFunctionPointer.from_xml(t) if funcpointer: funcpointers.append(funcpointer) @@ -3750,7 +3702,7 @@ class VkRegistry(object): else: continue
- if type_info["category"] == "handle": + elif type_info["category"] == "handle": handle = VkHandle.from_xml(t) if handle: handles.append(handle) @@ -3758,7 +3710,7 @@ class VkRegistry(object): else: continue
- if type_info["category"] in ["struct", "union"]: + elif type_info["category"] in ["struct", "union"]: # We store unions among structs as some structs depend # on unions. The types are very similar in parsing and # generation anyway. The official Vulkan scripts use diff --git a/include/wine/vulkan.h b/include/wine/vulkan.h index 15c902a333e..c6a41ef73b9 100644 --- a/include/wine/vulkan.h +++ b/include/wine/vulkan.h @@ -891,6 +891,7 @@ #define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) #define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) #define VKSC_API_VARIANT 1 + #define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0) #define VK_API_VERSION_1_1 VK_MAKE_API_VERSION(0, 1, 1, 0) #define VK_API_VERSION_1_2 VK_MAKE_API_VERSION(0, 1, 2, 0) @@ -901,7 +902,6 @@ #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 4, VK_HEADER_VERSION) #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; #define VK_USE_64_BIT_PTR_DEFINES 0 - #ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE #if (VK_USE_64_BIT_PTR_DEFINES==1) #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)) @@ -916,7 +916,6 @@ #ifndef VK_NULL_HANDLE #define VK_NULL_HANDLE 0 #endif - #ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE #if (VK_USE_64_BIT_PTR_DEFINES==1) #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; @@ -924,6 +923,52 @@ #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif #endif +struct ANativeWindow; +struct AHardwareBuffer; +#ifdef __OBJC__ +@class CAMetalLayer; +#else +typedef void CAMetalLayer; +#endif +#ifdef __OBJC__ +@protocol MTLDevice; +typedef __unsafe_unretained id<MTLDevice> MTLDevice_id; +#else +typedef void* MTLDevice_id; +#endif +#ifdef __OBJC__ +@protocol MTLCommandQueue; +typedef __unsafe_unretained id<MTLCommandQueue> MTLCommandQueue_id; +#else +typedef void* MTLCommandQueue_id; +#endif +#ifdef __OBJC__ +@protocol MTLBuffer; +typedef __unsafe_unretained id<MTLBuffer> MTLBuffer_id; +#else +typedef void* MTLBuffer_id; +#endif +#ifdef __OBJC__ +@protocol MTLTexture; +typedef __unsafe_unretained id<MTLTexture> MTLTexture_id; +#else +typedef void* MTLTexture_id; +#endif +#ifdef __OBJC__ +@protocol MTLSharedEvent; +typedef __unsafe_unretained id<MTLSharedEvent> MTLSharedEvent_id; +#else +typedef void* MTLSharedEvent_id; +#endif +typedef struct __IOSurface* IOSurfaceRef; +typedef uint32_t VkSampleMask; +typedef uint32_t VkBool32; +typedef uint32_t VkFlags; +typedef uint64_t VkFlags64; +typedef uint64_t VkDeviceSize; +typedef uint64_t VkDeviceAddress; +typedef struct NativeWindow OHNativeWindow; +typedef void* VkRemoteAddressNV; #define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) #define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) @@ -988,23 +1033,6 @@ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkValidationCacheEXT) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR)
-struct AHardwareBuffer; -struct ANativeWindow; -struct CAMetalLayer; -struct IOSurfaceRef; -struct MTLBuffer_id; -struct MTLCommandQueue_id; -struct MTLDevice_id; -struct MTLSharedEvent_id; -struct MTLTexture_id; -struct OHNativeWindow; -typedef uint32_t VkBool32; -typedef uint64_t VkDeviceAddress; -typedef uint64_t VkDeviceSize; -typedef uint32_t VkFlags; -typedef uint64_t VkFlags64; -typedef void* VkRemoteAddressNV; -typedef uint32_t VkSampleMask;
typedef VkFlags VkAccelerationStructureCreateFlagsKHR; typedef VkFlags VkAccelerationStructureMotionInfoFlagsNV;