Merge "Fix error mask generation in checkLineContinuity" into nougat-cts-dev
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / gen_framework.py
index 2e2482a..e6d9e55 100644 (file)
@@ -49,6 +49,7 @@ INSTANCE_FUNCTIONS    = [
        "vkGetPhysicalDeviceFeatures",
        "vkGetPhysicalDeviceFormatProperties",
        "vkGetPhysicalDeviceImageFormatProperties",
+       "vkGetPhysicalDeviceSparseImageFormatProperties",
        "vkGetPhysicalDeviceLimits",
        "vkGetPhysicalDeviceProperties",
        "vkGetPhysicalDeviceQueueFamilyProperties",
@@ -57,6 +58,50 @@ INSTANCE_FUNCTIONS   = [
        "vkEnumerateDeviceLayerProperties",
        "vkCreateDevice",
        "vkGetDeviceProcAddr",
+
+       # VK_KHR_surface
+       "vkDestroySurfaceKHR",
+       "vkGetPhysicalDeviceSurfaceSupportKHR",
+       "vkGetPhysicalDeviceSurfaceCapabilitiesKHR",
+       "vkGetPhysicalDeviceSurfaceFormatsKHR",
+       "vkGetPhysicalDeviceSurfacePresentModesKHR",
+
+       # VK_KHR_display
+       "vkGetPhysicalDeviceDisplayPropertiesKHR",
+       "vkGetPhysicalDeviceDisplayPlanePropertiesKHR",
+       "vkGetDisplayPlaneSupportedDisplaysKHR",
+       "vkGetDisplayModePropertiesKHR",
+       "vkCreateDisplayModeKHR",
+       "vkGetDisplayPlaneCapabilitiesKHR",
+       "vkCreateDisplayPlaneSurfaceKHR",
+
+       # VK_KHR_xlib_surface
+       "vkCreateXlibSurfaceKHR",
+       "vkGetPhysicalDeviceXlibPresentationSupportKHR",
+
+       # VK_KHR_xcb_surface
+       "vkCreateXcbSurfaceKHR",
+       "vkGetPhysicalDeviceXcbPresentationSupportKHR",
+
+       # VK_KHR_wayland_surface
+       "vkCreateWaylandSurfaceKHR",
+       "vkGetPhysicalDeviceWaylandPresentationSupportKHR",
+
+       # VK_KHR_mir_surface
+       "vkCreateMirSurfaceKHR",
+       "vkGetPhysicalDeviceMirPresentationSupportKHR",
+
+       # VK_KHR_android_surface
+       "vkCreateAndroidSurfaceKHR",
+
+       # VK_KHR_win32_surface
+       "vkCreateWin32SurfaceKHR",
+       "vkGetPhysicalDeviceWin32PresentationSupportKHR",
+
+       # VK_EXT_debug_report
+       "vkCreateDebugReportCallbackEXT",
+       "vkDestroyDebugReportCallbackEXT",
+       "vkDebugReportMessageEXT",
 ]
 
 DEFINITIONS                    = [
@@ -68,8 +113,37 @@ DEFINITIONS                 = [
        "VK_MAX_MEMORY_HEAPS",
        "VK_MAX_DESCRIPTION_SIZE",
        "VK_ATTACHMENT_UNUSED",
+       "VK_SUBPASS_EXTERNAL"
 ]
 
+PLATFORM_TYPES         = [
+       # VK_KHR_xlib_surface
+       ("Display*",                    "XlibDisplayPtr",                       "void*"),
+       ("Window",                              "XlibWindow",                           "deUintptr",),
+       ("VisualID",                    "XlibVisualID",                         "deUint32"),
+
+       # VK_KHR_xcb_surface
+       ("xcb_connection_t*",   "XcbConnectionPtr",                     "void*"),
+       ("xcb_window_t",                "XcbWindow",                            "deUintptr"),
+       ("xcb_visualid_t",              "XcbVisualid",                          "deUint32"),
+
+       # VK_KHR_wayland_surface
+       ("struct wl_display*",  "WaylandDisplayPtr",            "void*"),
+       ("struct wl_surface*",  "WaylandSurfacePtr",            "void*"),
+
+       # VK_KHR_mir_surface
+       ("MirConnection*",              "MirConnectionPtr",                     "void*"),
+       ("MirSurface*",                 "MirSurfacePtr",                        "void*"),
+
+       # VK_KHR_android_surface
+       ("ANativeWindow*",              "AndroidNativeWindowPtr",       "void*"),
+
+       # VK_KHR_win32_surface
+       ("HINSTANCE",                   "Win32InstanceHandle",          "void*"),
+       ("HWND",                                "Win32WindowHandle",            "void*")
+]
+PLATFORM_TYPE_NAMESPACE        = "pt"
+
 class Handle:
        TYPE_DISP               = 0
        TYPE_NONDISP    = 1
@@ -157,6 +231,10 @@ def fixupEnumValues (values):
        return fixed
 
 def fixupType (type):
+       for platformType, substitute, compat in PLATFORM_TYPES:
+               if type == platformType:
+                       return PLATFORM_TYPE_NAMESPACE + "::" + substitute
+
        replacements = [
                        ("uint8_t",             "deUint8"),
                        ("uint16_t",    "deUint16"),
@@ -189,22 +267,24 @@ def getFunctionTypeName (function):
        assert function.name[:2] == "vk"
        return function.name[2:] + "Func"
 
+def endsWith (str, postfix):
+       return str[-len(postfix):] == postfix
+
+def splitNameExtPostfix (name):
+       knownExtPostfixes = ["KHR", "EXT"]
+       for postfix in knownExtPostfixes:
+               if endsWith(name, postfix):
+                       return (name[:-len(postfix)], postfix)
+       return (name, "")
+
 def getBitEnumNameForBitfield (bitfieldName):
-       if bitfieldName[-3:] == "KHR":
-               postfix = "KHR"
-               bitfieldName = bitfieldName[:-3]
-       else:
-               postfix = ""
+       bitfieldName, postfix = splitNameExtPostfix(bitfieldName)
 
        assert bitfieldName[-1] == "s"
        return bitfieldName[:-1] + "Bits" + postfix
 
 def getBitfieldNameForBitEnum (bitEnumName):
-       if bitEnumName[-3:] == "KHR":
-               postfix = "KHR"
-               bitEnumName = bitEnumName[:-3]
-       else:
-               postfix = ""
+       bitEnumName, postfix = splitNameExtPostfix(bitEnumName)
 
        assert bitEnumName[-4:] == "Bits"
        return bitEnumName[:-4] + "s" + postfix
@@ -250,9 +330,6 @@ def parseCompositeTypes (src):
        types   = []
 
        for type, structname, contents, typename in matches:
-               if typename[-3:] == "KHR":
-                       continue # \todo [2016-01-05 pyry] Figure out how to handle platform-specific types
-
                types.append(parseCompositeType(typeMap[type], typename, contents))
 
        return types
@@ -284,9 +361,6 @@ def parseFunctions (src):
        functions       = []
 
        for returnType, name, argList in matches:
-               if name[-3:] == "KHR":
-                       continue # \todo [2015-11-16 pyry] Figure out how to handle platform-specific extension functions
-
                functions.append(Function(name.strip(), returnType.strip(), parseArgList(argList)))
 
        return [fixupFunction(f) for f in functions]
@@ -340,7 +414,7 @@ def writeHandleType (api, filename):
 def getEnumValuePrefix (enum):
        prefix = enum.name[0]
        for i in range(1, len(enum.name)):
-               if enum.name[i].isupper():
+               if enum.name[i].isupper() and not enum.name[i-1].isupper():
                        prefix += "_"
                prefix += enum.name[i].upper()
        return prefix
@@ -416,6 +490,8 @@ def writeBasicTypes (api, filename):
                        for line in genBitfieldSrc(bitfield):
                                yield line
                        yield ""
+               for line in indentLines(["VK_DEFINE_PLATFORM_TYPE(%s,\t%s);" % (s, c) for n, s, c in PLATFORM_TYPES]):
+                       yield line
 
        writeInlFile(filename, INL_HEADER, gen())
 
@@ -494,6 +570,15 @@ def writeStrUtilImpl (api, filename):
                for line in indentLines(["template<> const char*\tgetTypeName<%s>\t(void) { return \"%s\";\t}" % (handle.name, handle.name) for handle in api.handles]):
                        yield line
 
+               yield ""
+               yield "namespace %s" % PLATFORM_TYPE_NAMESPACE
+               yield "{"
+
+               for line in indentLines("std::ostream& operator<< (std::ostream& s, %s\tv) { return s << tcu::toHex(v.internal); }" % s for n, s, c in PLATFORM_TYPES):
+                       yield line
+
+               yield "}"
+
                for enum in api.enums:
                        yield ""
                        yield "const char* get%sName (%s value)" % (enum.name[2:], enum.name)
@@ -545,8 +630,12 @@ def writeStrUtilImpl (api, filename):
                                                newLine = "'\\n' << "
                                                valFmt = "tcu::formatArray(tcu::Format::HexIterator<%s>(DE_ARRAY_BEGIN(value.%s)), tcu::Format::HexIterator<%s>(DE_ARRAY_END(value.%s)))" % (member.type, baseName, member.type, baseName)
                                        else:
+                                               if baseName == "memoryTypes" or baseName == "memoryHeaps":
+                                                       endIter = "DE_ARRAY_BEGIN(value.%s) + value.%sCount" % (baseName, baseName[:-1])
+                                               else:
+                                                       endIter = "DE_ARRAY_END(value.%s)" % baseName
                                                newLine = "'\\n' << "
-                                               valFmt = "tcu::formatArray(DE_ARRAY_BEGIN(value.%s), DE_ARRAY_END(value.%s))" % (baseName, baseName)
+                                               valFmt = "tcu::formatArray(DE_ARRAY_BEGIN(value.%s), %s)" % (baseName, endIter)
                                        memberName = baseName
                                else:
                                        valFmt = "value.%s" % member.name
@@ -570,6 +659,9 @@ def getConstructorFunctions (api):
        funcs = []
        for function in api.functions:
                if (function.name[:8] == "vkCreate" or function.name == "vkAllocateMemory") and not "count" in [a.name for a in function.arguments]:
+                       if function.name == "vkCreateDisplayModeKHR":
+                               continue # No way to delete display modes (bug?)
+
                        # \todo [pyry] Rather hacky
                        iface = None
                        if function.getType() == Function.TYPE_PLATFORM:
@@ -620,7 +712,15 @@ def writeRefUtilImpl (api, filename):
                yield ""
 
                for function in functions:
-                       dtorObj = "device" if function.type == Function.TYPE_DEVICE else "object"
+                       if function.type == Function.TYPE_DEVICE:
+                               dtorObj = "device"
+                       elif function.type == Function.TYPE_INSTANCE:
+                               if function.name == "createDevice":
+                                       dtorObj = "object"
+                               else:
+                                       dtorObj = "instance"
+                       else:
+                               dtorObj = "object"
 
                        yield "Move<%s> %s (%s)" % (function.objectType, function.name, argListToStr([function.iface] + function.arguments))
                        yield "{"
@@ -651,7 +751,9 @@ def writeNullDriverImpl (api, filename):
                                "vkFreeDescriptorSets",
                                "vkResetDescriptorPool",
                                "vkAllocateCommandBuffers",
-                               "vkFreeCommandBuffers"
+                               "vkFreeCommandBuffers",
+                               "vkCreateDisplayModeKHR",
+                               "vkCreateSharedSwapchainsKHR",
                        ]
                specialFuncs            = [f for f in api.functions if f.name in specialFuncNames]
                createFuncs                     = [f for f in api.functions if (f.name[:8] == "vkCreate" or f.name == "vkAllocateMemory") and not f in specialFuncs]