From 2d77d0949fa7a5e858bfc3a11b02392d98b41198 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Tue, 31 Jul 2018 23:06:22 -0300 Subject: [PATCH] Vulkan bindings (#1) * Initial Vulkan support --- OpenTK.sln | 24 +- README.md | 2 + src/OpenTK/Configuration.cs | 10 +- src/OpenTK/Graphics/Vulkan/.gitignore | 1 + src/OpenTK/Graphics/Vulkan/BindingsHelpers.cs | 33 + .../Graphics/Vulkan/CalliRewriteAttribute.cs | 8 + src/OpenTK/Graphics/Vulkan/Commands.cs | 179 + src/OpenTK/Graphics/Vulkan/Constants.cs | 9 + src/OpenTK/Graphics/Vulkan/Delegates.cs | 45 + src/OpenTK/Graphics/Vulkan/ExternalTypes.cs | 83 + src/OpenTK/Graphics/Vulkan/FunctionPointer.cs | 15 + src/OpenTK/Graphics/Vulkan/Kernel32.cs | 17 + src/OpenTK/Graphics/Vulkan/Libdl.cs | 22 + src/OpenTK/Graphics/Vulkan/VkBool32.cs | 68 + .../Graphics/Vulkan/VkClearColorValue.cs | 33 + .../Vulkan/VkClearDepthStencilValue.cs | 16 + src/OpenTK/Graphics/Vulkan/VkExtent2D.cs | 107 + .../Graphics/Vulkan/VkImageMemoryBarrier.cs | 27 + .../Vulkan/VkImageSubresourceRange.cs | 17 + src/OpenTK/Graphics/Vulkan/VkOffset2D.cs | 91 + src/OpenTK/Graphics/Vulkan/VkRect2D.cs | 143 + src/OpenTK/Graphics/Vulkan/VulkanList.cs | 552 ++ src/OpenTK/Graphics/Vulkan/VulkanString.cs | 54 + src/OpenTK/Graphics/Vulkan/VulkanStrings.cs | 14 + src/OpenTK/Graphics/Vulkan/VulkanVersion.cs | 23 + src/OpenTK/NativeWindow.cs | 50 + src/OpenTK/OpenTK.Standard.csproj | 27 +- src/OpenTK/Platform/Factory.cs | 3 +- src/OpenTK/Platform/Windows/WinGLNative.cs | 6 +- src/OpenTK/Platform/X11/Structs.cs | 6 +- src/vk.generator/CodeGenerator.cs | 252 + src/vk.generator/CommandDefinition.cs | 77 + src/vk.generator/CommandHelpers.cs | 27 + src/vk.generator/Configuration.cs | 10 + src/vk.generator/ConstantDefinition.cs | 55 + src/vk.generator/ConstantHelpers.cs | 62 + src/vk.generator/EnumDefinition.cs | 101 + src/vk.generator/EnumHelpers.cs | 204 + src/vk.generator/ExtensionDefinition.cs | 126 + src/vk.generator/HandleDefinition.cs | 28 + src/vk.generator/HandleHelpers.cs | 39 + src/vk.generator/MemberSpec.cs | 76 + src/vk.generator/ParameterDefinition.cs | 76 + src/vk.generator/Program.cs | 69 + src/vk.generator/Require.cs | 32 + src/vk.generator/StructureDefinition.cs | 31 + src/vk.generator/StructureHelpers.cs | 111 + src/vk.generator/TypeNameMappings.cs | 70 + src/vk.generator/TypeSpec.cs | 51 + src/vk.generator/TypedefDefinition.cs | 31 + src/vk.generator/UnionHelpers.cs | 42 + src/vk.generator/Util.cs | 55 + src/vk.generator/VariantGenerator.cs | 122 + src/vk.generator/VulkanSpecification.cs | 126 + src/vk.generator/XElementExtensions.cs | 45 + src/vk.generator/vk.generator.csproj | 17 + src/vk.generator/vk.xml | 7634 +++++++++++++++++ src/vk.rewrite/Program.cs | 201 + src/vk.rewrite/rewritten.dll | 0 src/vk.rewrite/vk.rewrite.csproj | 14 + 60 files changed, 11439 insertions(+), 30 deletions(-) create mode 100644 src/OpenTK/Graphics/Vulkan/.gitignore create mode 100644 src/OpenTK/Graphics/Vulkan/BindingsHelpers.cs create mode 100644 src/OpenTK/Graphics/Vulkan/CalliRewriteAttribute.cs create mode 100644 src/OpenTK/Graphics/Vulkan/Commands.cs create mode 100644 src/OpenTK/Graphics/Vulkan/Constants.cs create mode 100644 src/OpenTK/Graphics/Vulkan/Delegates.cs create mode 100644 src/OpenTK/Graphics/Vulkan/ExternalTypes.cs create mode 100644 src/OpenTK/Graphics/Vulkan/FunctionPointer.cs create mode 100644 src/OpenTK/Graphics/Vulkan/Kernel32.cs create mode 100644 src/OpenTK/Graphics/Vulkan/Libdl.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkBool32.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkClearColorValue.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkClearDepthStencilValue.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkExtent2D.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkImageMemoryBarrier.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkImageSubresourceRange.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkOffset2D.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VkRect2D.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VulkanList.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VulkanString.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VulkanStrings.cs create mode 100644 src/OpenTK/Graphics/Vulkan/VulkanVersion.cs create mode 100644 src/vk.generator/CodeGenerator.cs create mode 100644 src/vk.generator/CommandDefinition.cs create mode 100644 src/vk.generator/CommandHelpers.cs create mode 100644 src/vk.generator/Configuration.cs create mode 100644 src/vk.generator/ConstantDefinition.cs create mode 100644 src/vk.generator/ConstantHelpers.cs create mode 100644 src/vk.generator/EnumDefinition.cs create mode 100644 src/vk.generator/EnumHelpers.cs create mode 100644 src/vk.generator/ExtensionDefinition.cs create mode 100644 src/vk.generator/HandleDefinition.cs create mode 100644 src/vk.generator/HandleHelpers.cs create mode 100644 src/vk.generator/MemberSpec.cs create mode 100644 src/vk.generator/ParameterDefinition.cs create mode 100644 src/vk.generator/Program.cs create mode 100644 src/vk.generator/Require.cs create mode 100644 src/vk.generator/StructureDefinition.cs create mode 100644 src/vk.generator/StructureHelpers.cs create mode 100644 src/vk.generator/TypeNameMappings.cs create mode 100644 src/vk.generator/TypeSpec.cs create mode 100644 src/vk.generator/TypedefDefinition.cs create mode 100644 src/vk.generator/UnionHelpers.cs create mode 100644 src/vk.generator/Util.cs create mode 100644 src/vk.generator/VariantGenerator.cs create mode 100644 src/vk.generator/VulkanSpecification.cs create mode 100644 src/vk.generator/XElementExtensions.cs create mode 100644 src/vk.generator/vk.generator.csproj create mode 100644 src/vk.generator/vk.xml create mode 100644 src/vk.rewrite/Program.cs create mode 100644 src/vk.rewrite/rewritten.dll create mode 100644 src/vk.rewrite/vk.rewrite.csproj diff --git a/OpenTK.sln b/OpenTK.sln index 37733420..2ecf3a21 100644 --- a/OpenTK.sln +++ b/OpenTK.sln @@ -11,10 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator.Rewrite", "src\Ge EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "src\OpenTK\OpenTK.csproj", "{A37A7E14-0000-0000-0000-000000000000}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Android", "src\OpenTK\OpenTK.Android.csproj", "{1648ACE1-E7D0-41CB-9A0E-C2A9D76C13A9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.iOS", "src\OpenTK\OpenTK.iOS.csproj", "{88368190-E3DF-4EBE-ACAA-7B1779F376CA}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.GLControl", "src\OpenTK.GLControl\OpenTK.GLControl.csproj", "{A625BE88-0000-0000-0000-000000000000}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.GLWidget", "src\OpenTK.GLWidget\OpenTK.GLWidget.csproj", "{A625BE87-0000-0000-0000-000000000000}" @@ -45,6 +41,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Generators", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTK.Standard", "src\OpenTK\OpenTK.Standard.csproj", "{67F02FD3-8F7F-4D89-8551-359993271CA3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vk.generator", "src\vk.generator\vk.generator.csproj", "{3766DF33-E28B-402D-9EE1-975C2AFB5EAF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vk.rewrite", "src\vk.rewrite\vk.rewrite.csproj", "{3E9B1C4D-BCB4-418A-A94E-DD164A19C6A2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,14 +67,6 @@ Global {A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {1648ACE1-E7D0-41CB-9A0E-C2A9D76C13A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1648ACE1-E7D0-41CB-9A0E-C2A9D76C13A9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1648ACE1-E7D0-41CB-9A0E-C2A9D76C13A9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1648ACE1-E7D0-41CB-9A0E-C2A9D76C13A9}.Release|Any CPU.Build.0 = Release|Any CPU - {88368190-E3DF-4EBE-ACAA-7B1779F376CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88368190-E3DF-4EBE-ACAA-7B1779F376CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88368190-E3DF-4EBE-ACAA-7B1779F376CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88368190-E3DF-4EBE-ACAA-7B1779F376CA}.Release|Any CPU.Build.0 = Release|Any CPU {A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {A625BE88-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -103,6 +95,14 @@ Global {67F02FD3-8F7F-4D89-8551-359993271CA3}.Debug|Any CPU.Build.0 = Debug|Any CPU {67F02FD3-8F7F-4D89-8551-359993271CA3}.Release|Any CPU.ActiveCfg = Release|Any CPU {67F02FD3-8F7F-4D89-8551-359993271CA3}.Release|Any CPU.Build.0 = Release|Any CPU + {3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Release|Any CPU.Build.0 = Release|Any CPU + {3E9B1C4D-BCB4-418A-A94E-DD164A19C6A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E9B1C4D-BCB4-418A-A94E-DD164A19C6A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E9B1C4D-BCB4-418A-A94E-DD164A19C6A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E9B1C4D-BCB4-418A-A94E-DD164A19C6A2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index 84d880a2..3c6217a2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ OpenTK ====== +This fork contains modified dependencies from mellinoe's Vulkan bindings, you can get the original from [here](https://github.com/mellinoe/vk). + ### MAINTAINERS WANTED diff --git a/src/OpenTK/Configuration.cs b/src/OpenTK/Configuration.cs index 8fedf6a7..c3850cf7 100644 --- a/src/OpenTK/Configuration.cs +++ b/src/OpenTK/Configuration.cs @@ -164,9 +164,9 @@ namespace OpenTK return t != null; } - #if SDL2 private static bool DetectSdl2() { +#if SDL2 bool supported = false; // Detect whether SDL2 is supported @@ -220,8 +220,10 @@ namespace OpenTK } return supported; - } - #endif +#else + return false; +#endif + } private static void DetectUnix(out bool unix, out bool linux, out bool macos) { @@ -298,7 +300,7 @@ namespace OpenTK initialized = true; #endif - Debug.Print("Detected configuration: {0} / {1}", + Debug.Print("Detected configuration: {0} / {1}", RunningOnWindows ? "Windows" : RunningOnLinux ? "Linux" : RunningOnMacOS ? "MacOS" : runningOnUnix ? "Unix" : RunningOnX11 ? "X11" : "Unknown Platform", RunningOnMono ? "Mono" : ".Net"); diff --git a/src/OpenTK/Graphics/Vulkan/.gitignore b/src/OpenTK/Graphics/Vulkan/.gitignore new file mode 100644 index 00000000..fac4002c --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/.gitignore @@ -0,0 +1 @@ +Generated/ \ No newline at end of file diff --git a/src/OpenTK/Graphics/Vulkan/BindingsHelpers.cs b/src/OpenTK/Graphics/Vulkan/BindingsHelpers.cs new file mode 100644 index 00000000..77ec3d87 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/BindingsHelpers.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Text; + +namespace OpenTK.Graphics.Vulkan +{ + public static class BindingsHelpers + { + public static unsafe StringHandle StringToHGlobalUtf8(string s) + { + int byteCount = Encoding.UTF8.GetByteCount(s); + IntPtr retPtr = Marshal.AllocHGlobal(byteCount); + fixed (char* stringPtr = s) + { + Encoding.UTF8.GetBytes(stringPtr, s.Length, (byte*)retPtr.ToPointer(), byteCount); + } + + return new StringHandle() { Handle = retPtr }; + } + + public static void FreeHGlobal(StringHandle ptr) + { + Marshal.FreeHGlobal(ptr.Handle); + } + } + + public struct StringHandle + { + public IntPtr Handle; + } +} diff --git a/src/OpenTK/Graphics/Vulkan/CalliRewriteAttribute.cs b/src/OpenTK/Graphics/Vulkan/CalliRewriteAttribute.cs new file mode 100644 index 00000000..8d07625d --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/CalliRewriteAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace OpenTK.Graphics.Vulkan.Generator +{ + internal class CalliRewriteAttribute : Attribute + { + } +} diff --git a/src/OpenTK/Graphics/Vulkan/Commands.cs b/src/OpenTK/Graphics/Vulkan/Commands.cs new file mode 100644 index 00000000..8a741f42 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/Commands.cs @@ -0,0 +1,179 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; + +namespace OpenTK.Graphics.Vulkan +{ + public static partial class VK + { + private static NativeLibrary s_nativeLib; + + static public void LoadFunctions() + { + if (s_nativeLib == null) + { + s_nativeLib = LoadNativeLibrary(); + } + + LoadFunctionPointers(); + } + + public static IntPtr LoadFunctionPointer(string functionName) + { + if (s_nativeLib == null) + { + s_nativeLib = LoadNativeLibrary(); + } + + return s_nativeLib.LoadFunctionPointer(functionName); + } + + private static NativeLibrary LoadNativeLibrary() + { + return NativeLibrary.Load(GetVulkanName()); + } + + private static string GetVulkanName() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return "vulkan-1.dll"; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + if (RuntimeInformation.OSDescription.Contains("Unix")) + { + // Android + return "libvulkan.so"; + } + else + { + // Desktop Linux + return "libvulkan.so.1"; + } + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return "libvulkan.dylib"; + } + else + { + throw new PlatformNotSupportedException(); + } + } + + private static Exception CreateMissingFunctionException() + { + return new InvalidOperationException("The function does not exist or could not be loaded."); + } + } + + public abstract class NativeLibrary : IDisposable + { + private readonly string _libraryName; + private readonly IntPtr _libraryHandle; + + public IntPtr NativeHandle => _libraryHandle; + + public NativeLibrary(string libraryName) + { + _libraryName = libraryName; + _libraryHandle = LoadLibrary(_libraryName); + if (_libraryHandle == IntPtr.Zero) + { + throw new InvalidOperationException("Could not load " + libraryName); + } + } + + protected abstract IntPtr LoadLibrary(string libraryName); + protected abstract void FreeLibrary(IntPtr libraryHandle); + protected abstract IntPtr LoadFunction(string functionName); + + public IntPtr LoadFunctionPointer(string functionName) + { + if (functionName == null) + { + throw new ArgumentNullException(nameof(functionName)); + } + + return LoadFunction(functionName); + } + + public void Dispose() + { + FreeLibrary(_libraryHandle); + } + + + public static NativeLibrary Load(string libraryName) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return new WindowsNativeLibrary(libraryName); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) + || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return new UnixNativeLibrary(libraryName); + } + else + { + throw new PlatformNotSupportedException("Cannot load native libraries on this platform: " + RuntimeInformation.OSDescription); + } + } + + private class WindowsNativeLibrary : NativeLibrary + { + public WindowsNativeLibrary(string libraryName) : base(libraryName) + { + } + + protected override IntPtr LoadLibrary(string libraryName) + { + return Kernel32.LoadLibrary(libraryName); + } + + protected override void FreeLibrary(IntPtr libraryHandle) + { + Kernel32.FreeLibrary(libraryHandle); + } + + protected override IntPtr LoadFunction(string functionName) + { + Debug.WriteLine("Loading " + functionName); + return Kernel32.GetProcAddress(NativeHandle, functionName); + } + } + + private class UnixNativeLibrary : NativeLibrary + { + public UnixNativeLibrary(string libraryName) : base(libraryName) + { + } + + protected override IntPtr LoadLibrary(string libraryName) + { + Libdl.dlerror(); + IntPtr handle = Libdl.dlopen(libraryName, Libdl.RTLD_NOW); + if (handle == IntPtr.Zero && !Path.IsPathRooted(libraryName)) + { + string localPath = Path.Combine(AppContext.BaseDirectory, libraryName); + handle = Libdl.dlopen(localPath, Libdl.RTLD_NOW); + } + + return handle; + } + + protected override void FreeLibrary(IntPtr libraryHandle) + { + Libdl.dlclose(libraryHandle); + } + + protected override IntPtr LoadFunction(string functionName) + { + return Libdl.dlsym(NativeHandle, functionName); + } + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/Constants.cs b/src/OpenTK/Graphics/Vulkan/Constants.cs new file mode 100644 index 00000000..ae1fbac6 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/Constants.cs @@ -0,0 +1,9 @@ +using System; + +namespace OpenTK.Graphics.Vulkan +{ + public static partial class VK + { + public static readonly IntPtr NullHandle = IntPtr.Zero; + } +} diff --git a/src/OpenTK/Graphics/Vulkan/Delegates.cs b/src/OpenTK/Graphics/Vulkan/Delegates.cs new file mode 100644 index 00000000..58115bce --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/Delegates.cs @@ -0,0 +1,45 @@ +using System; + +namespace OpenTK.Graphics.Vulkan +{ + public unsafe delegate void* PFN_vkAllocationFunction( + void* pUserData, + UIntPtr size, + UIntPtr alignment, + VkSystemAllocationScope allocationScope); + + public unsafe delegate void* PFN_vkReallocationFunction( + void* pUserData, + void* pOriginal, + UIntPtr size, + UIntPtr alignment, + VkSystemAllocationScope allocationScope); + + public unsafe delegate void PFN_vkFreeFunction( + void* pUserData, + void* pMemory); + + public unsafe delegate void PFN_vkInternalAllocationNotification( + void* pUserData, + UIntPtr size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + + public unsafe delegate void PFN_vkInternalFreeNotification( + void* pUserData, + UIntPtr size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + + public unsafe delegate void PFN_vkVoidFunction(); + + public unsafe delegate uint PFN_vkDebugReportCallbackEXT( + uint flags, + VkDebugReportObjectTypeEXT objectType, + ulong @object, + UIntPtr location, + int messageCode, + byte* pLayerPrefix, + byte* pMessage, + void* pUserData); +} diff --git a/src/OpenTK/Graphics/Vulkan/ExternalTypes.cs b/src/OpenTK/Graphics/Vulkan/ExternalTypes.cs new file mode 100644 index 00000000..cbe32f03 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/ExternalTypes.cs @@ -0,0 +1,83 @@ +using System; + +namespace OpenTK.Graphics.Vulkan +{ + // Windows + + namespace Win32 + { + public struct HINSTANCE + { + public IntPtr Handle; + public static implicit operator IntPtr(HINSTANCE hinst) => hinst.Handle; + public static implicit operator HINSTANCE(IntPtr handle) => new HINSTANCE() { Handle = handle }; + } + + public struct HWND + { + public IntPtr Handle; + public static implicit operator IntPtr(HWND hwnd) => hwnd.Handle; + public static implicit operator HWND(IntPtr handle) => new HWND() { Handle = handle }; + } + + public struct HANDLE + { + public IntPtr Handle; + public static implicit operator IntPtr(HANDLE handle) => handle.Handle; + public static implicit operator HANDLE(IntPtr handle) => new HANDLE() { Handle = handle }; + } + + public struct SECURITY_ATTRIBUTES + { + public uint nLength; + public IntPtr lpSecurityDescriptor; + public uint bInheritHandle; + } + } + + // Android + namespace Android + { + public struct ANativeWindow { } + } + + // Linux + namespace Mir + { + public struct MirConnection { } + public struct MirSurface { } + } + + namespace Wayland + { + public struct wl_display { } + public struct wl_surface { } + } + + namespace Xlib + { + public struct Display { } + public struct Window + { + public IntPtr Value; + } + public struct VisualID + { + public ulong ID; + public static implicit operator VisualID(ulong value) => new VisualID() { ID = value }; + public static implicit operator ulong(VisualID id) => id.ID; + } + } + + namespace Xcb + { + public struct xcb_connection_t { } + public struct xcb_window_t { } + public struct xcb_visualid_t + { + public uint ID; + public static implicit operator xcb_visualid_t(uint value) => new xcb_visualid_t() { ID = value }; + public static implicit operator uint(xcb_visualid_t id) => id.ID; + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/FunctionPointer.cs b/src/OpenTK/Graphics/Vulkan/FunctionPointer.cs new file mode 100644 index 00000000..5d34c8ab --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/FunctionPointer.cs @@ -0,0 +1,15 @@ +using System; +using System.Runtime.InteropServices; + +namespace OpenTK.Graphics.Vulkan +{ + public struct FunctionPointer + { + public IntPtr Pointer; + + public FunctionPointer(TFunc func) + { + Pointer = Marshal.GetFunctionPointerForDelegate(func); + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/Kernel32.cs b/src/OpenTK/Graphics/Vulkan/Kernel32.cs new file mode 100644 index 00000000..aaad1377 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/Kernel32.cs @@ -0,0 +1,17 @@ +using System; +using System.Runtime.InteropServices; + +namespace OpenTK.Graphics.Vulkan +{ + internal static class Kernel32 + { + [DllImport("kernel32")] + public static extern IntPtr LoadLibrary(string fileName); + + [DllImport("kernel32")] + public static extern IntPtr GetProcAddress(IntPtr module, string procName); + + [DllImport("kernel32")] + public static extern int FreeLibrary(IntPtr module); + } +} diff --git a/src/OpenTK/Graphics/Vulkan/Libdl.cs b/src/OpenTK/Graphics/Vulkan/Libdl.cs new file mode 100644 index 00000000..373c9310 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/Libdl.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.InteropServices; + +namespace OpenTK.Graphics.Vulkan +{ + internal static class Libdl + { + [DllImport("libdl")] + public static extern IntPtr dlopen(string fileName, int flags); + + [DllImport("libdl")] + public static extern IntPtr dlsym(IntPtr handle, string name); + + [DllImport("libdl")] + public static extern int dlclose(IntPtr handle); + + [DllImport("libdl")] + public static extern string dlerror(); + + public const int RTLD_NOW = 0x002; + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkBool32.cs b/src/OpenTK/Graphics/Vulkan/VkBool32.cs new file mode 100644 index 00000000..9463c9df --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkBool32.cs @@ -0,0 +1,68 @@ +using System; + +namespace OpenTK.Graphics.Vulkan +{ + /// + /// A boolean value stored in a 4-byte unsigned integer. + /// + public struct VkBool32 : IEquatable + { + /// + /// The raw value of the . A value of 0 represents "false", all other values represent "true". + /// + public uint Value; + + /// + /// Constructs a new with the given raw value. + /// + /// + public VkBool32(uint value) + { + Value = value; + } + + /// + /// Represents the boolean "true" value. Has a raw value of 1. + /// + public static readonly VkBool32 True = new VkBool32(1); + + /// + /// Represents the boolean "true" value. Has a raw value of 0. + /// + public static readonly VkBool32 False = new VkBool32(0); + + /// + /// Returns whether another value is considered equal to this one. + /// Two s are considered equal when their raw values are equal. + /// + /// The value to compare to. + /// True if the other value's underlying raw value is equal to this instance's. False otherwise. + public bool Equals(VkBool32 other) + { + return Value.Equals(other.Value); + } + + public override bool Equals(object obj) + { + return obj is VkBool32 b && Equals(b); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public override string ToString() + { + return $"{(this ? "True" : "False")} ({Value})"; + } + + public static implicit operator bool(VkBool32 b) => b.Value != 0; + public static implicit operator uint(VkBool32 b) => b.Value; + public static implicit operator VkBool32(bool b) => b ? True : False; + public static implicit operator VkBool32(uint value) => new VkBool32(value); + + public static bool operator ==(VkBool32 left, VkBool32 right) => left.Value == right.Value; + public static bool operator !=(VkBool32 left, VkBool32 right) => left.Value != right.Value; + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkClearColorValue.cs b/src/OpenTK/Graphics/Vulkan/VkClearColorValue.cs new file mode 100644 index 00000000..0ae848c0 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkClearColorValue.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace OpenTK.Graphics.Vulkan +{ + public partial struct VkClearColorValue + { + public VkClearColorValue(float r, float g, float b, float a = 1.0f) : this() + { + float32_0 = r; + float32_1 = g; + float32_2 = b; + float32_3 = a; + } + + public VkClearColorValue(int r, int g, int b, int a = 255) : this() + { + int32_0 = r; + int32_1 = g; + int32_2 = b; + int32_3 = a; + } + + public VkClearColorValue(uint r, uint g, uint b, uint a = 255) : this() + { + uint32_0 = r; + uint32_1 = g; + uint32_2 = b; + uint32_3 = a; + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkClearDepthStencilValue.cs b/src/OpenTK/Graphics/Vulkan/VkClearDepthStencilValue.cs new file mode 100644 index 00000000..ceb5393b --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkClearDepthStencilValue.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace OpenTK.Graphics.Vulkan +{ + public unsafe partial struct VkClearDepthStencilValue + { + public VkClearDepthStencilValue(float depth, uint stencil) + { + this.depth = depth; + this.stencil = stencil; + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkExtent2D.cs b/src/OpenTK/Graphics/Vulkan/VkExtent2D.cs new file mode 100644 index 00000000..688f057d --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkExtent2D.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenTK.Graphics.Vulkan +{ + /// + /// Structure specifying a two-dimensional extent. + /// + public unsafe partial struct VkExtent2D : IEquatable + { + /// + /// An with all of its components set to zero. + /// + public static readonly VkExtent2D Zero = new VkExtent2D(0, 0); + + /// + /// Initializes a new instance of structure. + /// + /// The width component of the extent. + /// The height component of the extent. + public VkExtent2D(uint width, uint height) + { + this.width = width; + this.height = height; + } + + /// + /// Initializes a new instance of structure. + /// + /// The width component of the extent. + /// The height component of the extent. + public VkExtent2D(int width, int height) + { + this.width = (uint)width; + this.height = (uint)height; + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(ref VkExtent2D other) + { + return other.width == width && other.height == height; + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(VkExtent2D other) + { + return Equals(ref other); + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + return obj is VkExtent2D && Equals((VkExtent2D)obj); + } + + /// + /// Returns the hash code for this instance. + /// + /// The hash code. + public override int GetHashCode() + { + unchecked + { + int hashCode = width.GetHashCode(); + hashCode = (hashCode * 397) ^ height.GetHashCode(); + return hashCode; + } + } + + /// + /// Returns a boolean indicating whether the two given extents are equal. + /// + /// The first extent to compare. + /// The second extent to compare. + /// true if the extents are equal; false otherwise. + public static bool operator ==(VkExtent2D left, VkExtent2D right) => left.Equals(ref right); + + /// + /// Returns a boolean indicating whether the two given extents are not equal. + /// + /// The first extent to compare. + /// The second extent to compare. + /// + /// true if the extents are not equal; false if they are equal. + /// + public static bool operator !=(VkExtent2D left, VkExtent2D right) => !left.Equals(ref right); + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkImageMemoryBarrier.cs b/src/OpenTK/Graphics/Vulkan/VkImageMemoryBarrier.cs new file mode 100644 index 00000000..00e91e4f --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkImageMemoryBarrier.cs @@ -0,0 +1,27 @@ +namespace OpenTK.Graphics.Vulkan +{ + public unsafe partial struct VkImageMemoryBarrier + { + public VkImageMemoryBarrier( + VkImage image, + VkImageSubresourceRange subresourceRange, + VkAccessFlags srcAccessMask, + VkAccessFlags dstAccessMask, + VkImageLayout oldLayout, + VkImageLayout newLayout, + uint srcQueueFamilyIndex = VK.QueueFamilyIgnored, + uint dstQueueFamilyIndex = VK.QueueFamilyIgnored) + { + sType = VkStructureType.ImageMemoryBarrier; + pNext = null; + this.srcAccessMask = srcAccessMask; + this.dstAccessMask = dstAccessMask; + this.oldLayout = oldLayout; + this.newLayout = newLayout; + this.srcQueueFamilyIndex = srcQueueFamilyIndex; + this.dstQueueFamilyIndex = dstQueueFamilyIndex; + this.image = image; + this.subresourceRange = subresourceRange; + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkImageSubresourceRange.cs b/src/OpenTK/Graphics/Vulkan/VkImageSubresourceRange.cs new file mode 100644 index 00000000..d0696874 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkImageSubresourceRange.cs @@ -0,0 +1,17 @@ +namespace OpenTK.Graphics.Vulkan +{ + public unsafe partial struct VkImageSubresourceRange + { + public VkImageSubresourceRange( + VkImageAspectFlags aspectMask, + uint baseMipLevel = 0, uint levelCount = 1, + uint baseArrayLayer = 0, uint layerCount = 1) + { + this.aspectMask = aspectMask; + this.baseMipLevel = baseMipLevel; + this.levelCount = levelCount; + this.baseArrayLayer = baseArrayLayer; + this.layerCount = layerCount; + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkOffset2D.cs b/src/OpenTK/Graphics/Vulkan/VkOffset2D.cs new file mode 100644 index 00000000..e942c85f --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkOffset2D.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenTK.Graphics.Vulkan +{ + /// + /// Structure specifying a two-dimensional offset. + /// + public unsafe partial struct VkOffset2D : IEquatable + { + /// + /// An with all of its components set to zero. + /// + public static readonly VkOffset2D Zero; + + public VkOffset2D(int x, int y) + { + this.x = x; + this.y = y; + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(ref VkOffset2D other) + { + return other.x == x && other.y == y; + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(VkOffset2D other) + { + return Equals(ref other); + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + return obj is VkOffset2D && Equals((VkOffset2D)obj); + } + + /// + /// Returns the hash code for this instance. + /// + /// The hash code. + public override int GetHashCode() + { + unchecked + { + int hashCode = x; + hashCode = (hashCode * 397) ^ y; + return hashCode; + } + } + + /// + /// Returns a boolean indicating whether the two given offsets are equal. + /// + /// The first offset to compare. + /// The second offset to compare. + /// true if the offsets are equal; false otherwise. + public static bool operator ==(VkOffset2D left, VkOffset2D right) => left.Equals(ref right); + + /// + /// Returns a boolean indicating whether the two given offsets are not equal. + /// + /// The first offset to compare. + /// The second offset to compare. + /// + /// true if the offsets are not equal; false if they are equal. + /// + public static bool operator !=(VkOffset2D left, VkOffset2D right) => !left.Equals(ref right); + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VkRect2D.cs b/src/OpenTK/Graphics/Vulkan/VkRect2D.cs new file mode 100644 index 00000000..1d2b53bc --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VkRect2D.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenTK.Graphics.Vulkan +{ + /// + /// Structure specifying a two-dimensional subregion. + /// + public unsafe partial struct VkRect2D : IEquatable + { + /// + /// An with all of its components set to zero. + /// + public static readonly VkRect2D Zero = new VkRect2D(VkOffset2D.Zero, VkExtent2D.Zero); + + /// + /// Initializes a new instance of the structure. + /// + /// The offset component of the rectangle. + /// The extent component of the rectangle. + public VkRect2D(VkOffset2D offset, VkExtent2D extent) + { + this.offset = offset; + this.extent = extent; + } + + /// + /// Initializes a new instance of the structure. + /// + /// The extent component of the rectangle. + public VkRect2D(VkExtent2D extent) + { + this.offset = default(VkOffset2D); + this.extent = extent; + } + + /// + /// Initializes a new instance of the structure. + /// + /// The X component of the offset. + /// The Y component of the offset. + /// The width component of the extent. + /// The height component of the extent. + public VkRect2D(int x, int y, uint width, uint height) + { + this.offset = new VkOffset2D(x, y); + this.extent = new VkExtent2D(width, height); + } + + /// + /// Initializes a new instance of the structure. + /// + /// The X component of the offset. + /// The Y component of the offset. + /// The width component of the extent. + /// The height component of the extent. + public VkRect2D(int x, int y, int width, int height) + { + this.offset = new VkOffset2D(x, y); + this.extent = new VkExtent2D(width, height); + } + + /// + /// Initializes a new instance of the structure. + /// + /// The width component of the extent. + /// The height component of the extent. + public VkRect2D(uint width, uint height) + { + this.offset = default(VkOffset2D); + this.extent = new VkExtent2D(width, height); + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(ref VkRect2D other) + { + return other.offset.Equals(ref offset) && other.extent.Equals(ref extent); + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(VkRect2D other) + { + return Equals(ref other); + } + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + return obj is VkRect2D && Equals((VkRect2D)obj); + } + + /// + /// Returns the hash code for this instance. + /// + /// The hash code. + public override int GetHashCode() + { + unchecked + { + int hashCode = extent.GetHashCode(); + hashCode = (hashCode * 397) ^ offset.GetHashCode(); + return hashCode; + } + } + + /// + /// Returns a boolean indicating whether the two given rectangles are equal. + /// + /// The first rectangle to compare. + /// The second rectangle to compare. + /// true if the rectangles are equal; false otherwise. + public static bool operator ==(VkRect2D left, VkRect2D right) => left.Equals(right); + + /// + /// Returns a boolean indicating whether the two given rectangles are not equal. + /// + /// The first rectangle to compare. + /// The second rectangle to compare. + /// + /// true if the rectangles are not equal; false if they are equal. + /// + public static bool operator !=(VkRect2D left, VkRect2D right) => !left.Equals(right); + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VulkanList.cs b/src/OpenTK/Graphics/Vulkan/VulkanList.cs new file mode 100644 index 00000000..df712912 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VulkanList.cs @@ -0,0 +1,552 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +#if !VALIDATE +using System.Diagnostics; +#endif + +namespace OpenTK.Graphics.Vulkan +{ + using Debug = System.Diagnostics.Debug; + + public unsafe class VulkanList : IEnumerable, IDisposable where T : struct + { + private byte* _dataPtr; + private uint _elementCapacity; + private uint _count; + + public const int DefaultCapacity = 4; + private const float GrowthFactor = 2f; + private static readonly uint s_elementByteSize = InitializeTypeSize(); + + public VulkanList() : this(DefaultCapacity) { } + public VulkanList(uint capacity) + { + Allocate(capacity); + } + + public VulkanList(uint capacity, uint count) + { + Allocate(capacity); + Count = count; + } + + public VulkanList(VulkanList existingList) + { + Allocate(existingList._elementCapacity); + Unsafe.CopyBlock(_dataPtr, existingList._dataPtr, existingList._count * s_elementByteSize); + } + + public static VulkanList New(uint count) + { + return new VulkanList(count, count); + } + + public IntPtr Data + { + get + { + ThrowIfDisposed(); + return new IntPtr(_dataPtr); + } + } + + public uint Count + { + get + { + ThrowIfDisposed(); + return _count; + } + set + { + ThrowIfDisposed(); + if (value > _elementCapacity) + { + uint newLements = value - Count; + CoreResize(value); + Unsafe.InitBlock(_dataPtr + _count * s_elementByteSize, 0, newLements * s_elementByteSize); + } + + _count = value; + } + } + + public ref T this[uint index] + { + get + { + ThrowIfDisposed(); +#if VALIDATE + if (index >= _count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } +#else + Debug.Assert(index < _count); +#endif + return ref Unsafe.AsRef(_dataPtr + index * s_elementByteSize); + } + } + + public ref T this[int index] + { + get + { + ThrowIfDisposed(); +#if VALIDATE + if (index < 0 || index >= _count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } +#else + Debug.Assert(index >= 0 && index < _count); +#endif + return ref Unsafe.AsRef(_dataPtr + index * s_elementByteSize); + } + } + + public ReadOnlyNativeListView GetReadOnlyView() + { + ThrowIfDisposed(); + return new ReadOnlyNativeListView(this, 0, _count); + } + + public ReadOnlyNativeListView GetReadOnlyView(uint start, uint count) + { + ThrowIfDisposed(); +#if VALIDATE + if (start + count > _count) + { + throw new ArgumentOutOfRangeException(); + } +#else + Debug.Assert(start + count <= _count); +#endif + return new ReadOnlyNativeListView(this, start, count); + } + + public View GetView() where ViewType : struct + { + ThrowIfDisposed(); + return new View(this); + } + + public bool IsDisposed => _dataPtr == null; + + public void Add(ref T item) + { + ThrowIfDisposed(); + if (_count == _elementCapacity) + { + CoreResize((uint)(_elementCapacity * GrowthFactor)); + } + + Unsafe.Copy(_dataPtr + _count * s_elementByteSize, ref item); + _count += 1; + } + + public void Add(T item) + { + ThrowIfDisposed(); + if (_count == _elementCapacity) + { + CoreResize((uint)(_elementCapacity * GrowthFactor)); + } + + Unsafe.Write(_dataPtr + _count * s_elementByteSize, item); + _count += 1; + } + + public void Add(void* data, uint numElements) + { + ThrowIfDisposed(); + uint needed = _count + numElements; + if (numElements > _elementCapacity) + { + CoreResize((uint)(needed * GrowthFactor)); + } + + Unsafe.CopyBlock(_dataPtr + _count * s_elementByteSize, data, numElements * s_elementByteSize); + _count += numElements; + } + + public bool Remove(ref T item) + { + ThrowIfDisposed(); + bool result = IndexOf(ref item, out uint index); + if (result) + { + CoreRemoveAt(index); + } + + return result; + } + + public bool Remove(T item) => Remove(ref item); + + public void RemoveAt(uint index) + { + ThrowIfDisposed(); +#if VALIDATE + if (index >= _count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } +#else + Debug.Assert(index < _count); +#endif + CoreRemoveAt(index); + } + + public void Clear() + { + ThrowIfDisposed(); + _count = 0; + } + + public bool IndexOf(ref T item, out uint index) + { + ThrowIfDisposed(); + byte* itemPtr = (byte*)Unsafe.AsPointer(ref item); + for (index = 0; index < _count; index++) + { + byte* ptr = _dataPtr + index * s_elementByteSize; + if (Equals(ptr, itemPtr, s_elementByteSize)) + { + return true; + } + } + + return false; + } + + public bool IndexOf(T item, out uint index) + { + ThrowIfDisposed(); + byte* itemPtr = (byte*)Unsafe.AsPointer(ref item); + for (index = 0; index < _count; index++) + { + byte* ptr = _dataPtr + index * s_elementByteSize; + if (Equals(ptr, itemPtr, s_elementByteSize)) + { + return true; + } + } + + return false; + } + + public IntPtr GetAddress(uint index) + { + ThrowIfDisposed(); +#if VALIDATE + if (index >= _count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + +#else + Debug.Assert(index < _count); +#endif + return new IntPtr(_dataPtr + (index * s_elementByteSize)); + } + + public void Resize(uint elementCount) + { + ThrowIfDisposed(); + CoreResize(elementCount); + if (_elementCapacity < _count) + { + _count = _elementCapacity; + } + } + + private static uint InitializeTypeSize() + { +#if VALIDATE + // TODO: DHetermine if the structure type contains references and throw if it does. + // https://github.com/dotnet/corefx/issues/14047 +#endif + return (uint)Unsafe.SizeOf(); + } + + private void CoreResize(uint elementCount) + { + _dataPtr = (byte*)Marshal.ReAllocHGlobal(new IntPtr(_dataPtr), (IntPtr)(elementCount * s_elementByteSize)); + _elementCapacity = elementCount; + } + + private void Allocate(uint elementCount) + { + _dataPtr = (byte*)Marshal.AllocHGlobal((int)(elementCount * s_elementByteSize)); + _elementCapacity = elementCount; + } + + private bool Equals(byte* ptr, byte* itemPtr, uint s_elementByteSize) + { + for (int i = 0; i < s_elementByteSize; i++) + { + if (ptr[i] != itemPtr[i]) + { + return false; + } + } + + return true; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CoreRemoveAt(uint index) + { + Unsafe.CopyBlock(_dataPtr + index * s_elementByteSize, _dataPtr + (_count - 1) * s_elementByteSize, s_elementByteSize); + _count -= 1; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] +#if !VALIDATE + [Conditional("DEBUG")] +#endif + private void ThrowIfDisposed() + { +#if VALIDATE + if (_dataPtr == null) + { + throw new ObjectDisposedException(nameof(Data)); + } +#else + Debug.Assert(_dataPtr != null, "NativeList is disposed."); +#endif + } + + public void Dispose() + { + ThrowIfDisposed(); + Marshal.FreeHGlobal(new IntPtr(_dataPtr)); + _dataPtr = null; + } + +#if DEBUG + ~NativeList() + { + if (_dataPtr != null) + { + Debug.WriteLine($"A NativeList<{typeof(T).Name}> was not properly disposed."); + Dispose(); + } + } +#endif + + public Enumerator GetEnumerator() + { + ThrowIfDisposed(); + return new Enumerator(_dataPtr, _count); + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + public struct Enumerator : IEnumerator + { + private byte* _basePtr; + private uint _count; + private uint _currentIndex; + private T _current; + + public Enumerator(byte* basePtr, uint count) + { + _basePtr = basePtr; + _count = count; + _currentIndex = 0; + _current = default(T); + } + + public T Current => _current; + object IEnumerator.Current => Current; + + public bool MoveNext() + { + if (_currentIndex != _count) + { + _current = Unsafe.Read(_basePtr + _currentIndex * s_elementByteSize); + _currentIndex += 1; + return true; + } + + return false; + } + + public void Reset() + { + _current = default(T); + _currentIndex = 0; + } + + public void Dispose() { } + } + + public struct View : IEnumerable where ViewType : struct + { + private static readonly uint s_elementByteSize = (uint)Unsafe.SizeOf(); + private readonly VulkanList _parent; + + public View(VulkanList parent) + { + _parent = parent; + } + + public uint Count => (_parent.Count * VulkanList.s_elementByteSize) / s_elementByteSize; + + public ViewType this[uint index] + { + get + { +#if VALIDATE + if (index >= Count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } +#else + Debug.Assert(index < Count); +#endif + return Unsafe.Read(_parent._dataPtr + index * s_elementByteSize); + } + } + + public Enumerator GetEnumerator() => new Enumerator(this); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + public struct Enumerator : IEnumerator + { + private View _view; + private uint _currentIndex; + private ViewType _current; + + public Enumerator(View view) + { + _view = view; + _currentIndex = 0; + _current = default(ViewType); + } + + public ViewType Current => _view[_currentIndex]; + object IEnumerator.Current => Current; + + public bool MoveNext() + { + if (_currentIndex != _view.Count) + { + _current = _view[_currentIndex]; + _currentIndex += 1; + return true; + } + + return false; + } + + public void Reset() + { + _currentIndex = 0; + _current = default(ViewType); + } + + public void Dispose() { } + } + } + } + + public struct ReadOnlyNativeListView : IEnumerable where T : struct + { + private readonly VulkanList _list; + private readonly uint _start; + public readonly uint Count; + + public ReadOnlyNativeListView(VulkanList list, uint start, uint count) + { + _list = list; + _start = start; + Count = count; + } + + public T this[uint index] + { + get + { +#if VALIDATE + if (index >= Count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } +#else + Debug.Assert(index < Count); +#endif + return _list[index + _start]; + } + } + + public T this[int index] + { + get + { +#if VALIDATE + if (index < 0 || index >= Count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } +#else + Debug.Assert(index >= 0 && index < Count); +#endif + return _list[(uint)index + _start]; + } + } + + public Enumerator GetEnumerator() => new Enumerator(this); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + public struct Enumerator : IEnumerator + { + private ReadOnlyNativeListView _view; + private uint _currentIndex; + private T _current; + + public Enumerator(ReadOnlyNativeListView view) + { + _view = view; + _currentIndex = view._start; + _current = default(T); + } + + public T Current => _view[_currentIndex]; + object IEnumerator.Current => Current; + + public bool MoveNext() + { + if (_currentIndex != _view._start + _view.Count) + { + _current = _view[_currentIndex]; + _currentIndex += 1; + return true; + } + + return false; + } + + public void Reset() + { + _currentIndex = _view._start; + _current = default(T); + } + + public void Dispose() { } + } + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VulkanString.cs b/src/OpenTK/Graphics/Vulkan/VulkanString.cs new file mode 100644 index 00000000..0ed13f50 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VulkanString.cs @@ -0,0 +1,54 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace OpenTK.Graphics.Vulkan +{ + public unsafe class VulkanString : IDisposable + { + private GCHandle _handle; + private uint _numBytes; + + public byte* StringPtr => (byte*)_handle.AddrOfPinnedObject().ToPointer(); + + public VulkanString(string s) + { + if (s == null) + { + throw new ArgumentNullException(nameof(s)); + } + + byte[] text = Encoding.UTF8.GetBytes(s); + _handle = GCHandle.Alloc(text, GCHandleType.Pinned); + _numBytes = (uint)text.Length; + } + + public void SetText(string s) + { + if (s == null) + { + throw new ArgumentNullException(nameof(s)); + } + + _handle.Free(); + byte[] text = Encoding.UTF8.GetBytes(s); + _handle = GCHandle.Alloc(text, GCHandleType.Pinned); + _numBytes = (uint)text.Length; + } + + private string GetString() + { + return Encoding.UTF8.GetString(StringPtr, (int)_numBytes); + } + + public void Dispose() + { + _handle.Free(); + } + + public static implicit operator byte* (VulkanString utf8String) => utf8String.StringPtr; + public static implicit operator IntPtr (VulkanString utf8String) => new IntPtr(utf8String.StringPtr); + public static implicit operator VulkanString(string s) => new VulkanString(s); + public static implicit operator string(VulkanString utf8String) => utf8String.GetString(); + } +} \ No newline at end of file diff --git a/src/OpenTK/Graphics/Vulkan/VulkanStrings.cs b/src/OpenTK/Graphics/Vulkan/VulkanStrings.cs new file mode 100644 index 00000000..9e19e029 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VulkanStrings.cs @@ -0,0 +1,14 @@ +namespace OpenTK.Graphics.Vulkan +{ + public static class VulkanStrings + { + public static VulkanString VK_KHR_SURFACE_EXTENSION_NAME = "VK_KHR_surface"; + public static VulkanString VK_KHR_WIN32_SURFACE_EXTENSION_NAME = "VK_KHR_win32_surface"; + public static VulkanString VK_KHR_XCB_SURFACE_EXTENSION_NAME = "VK_KHR_xcb_surface"; + public static VulkanString VK_KHR_XLIB_SURFACE_EXTENSION_NAME = "VK_KHR_xlib_surface"; + public static VulkanString VK_KHR_SWAPCHAIN_EXTENSION_NAME = "VK_KHR_swapchain"; + public static VulkanString VK_EXT_DEBUG_REPORT_EXTENSION_NAME = "VK_EXT_debug_report"; + public static VulkanString StandardValidationLayerName = "VK_LAYER_LUNARG_standard_validation"; + public static VulkanString main = "main"; + } +} diff --git a/src/OpenTK/Graphics/Vulkan/VulkanVersion.cs b/src/OpenTK/Graphics/Vulkan/VulkanVersion.cs new file mode 100644 index 00000000..c6658e42 --- /dev/null +++ b/src/OpenTK/Graphics/Vulkan/VulkanVersion.cs @@ -0,0 +1,23 @@ +namespace OpenTK.Graphics.Vulkan +{ + public struct VulkanVersion + { + private readonly uint value; + + public VulkanVersion(uint major, uint minor, uint patch) + { + value = major << 22 | minor << 12 | patch; + } + + public uint Major => value >> 22; + + public uint Minor => (value >> 12) & 0x3ff; + + public uint Patch => (value >> 22) & 0xfff; + + public static implicit operator uint(VulkanVersion version) + { + return version.value; + } + } +} \ No newline at end of file diff --git a/src/OpenTK/NativeWindow.cs b/src/OpenTK/NativeWindow.cs index b355ec75..d07f845a 100644 --- a/src/OpenTK/NativeWindow.cs +++ b/src/OpenTK/NativeWindow.cs @@ -29,6 +29,7 @@ using System.ComponentModel; using System.Drawing; #endif using OpenTK.Graphics; +using OpenTK.Graphics.Vulkan; using OpenTK.Input; using OpenTK.Platform; @@ -49,6 +50,55 @@ namespace OpenTK private bool events; private bool previous_cursor_visible = true; + public unsafe VkResult CreateVulkanSurface(VkInstance instance, out VkSurfaceKHR surface) + { + IPlatformFactory factory = Factory.Default; + + if (implementation is Platform.Windows.WinGLNative win) + { + VkWin32SurfaceCreateInfoKHR createInfo = VkWin32SurfaceCreateInfoKHR.New(); + createInfo.hwnd = win.Handle; + createInfo.hinstance = win.Instance; + + return VK.CreateWin32SurfaceKHR(instance, ref createInfo, IntPtr.Zero, out surface); + } + else if (implementation is Platform.X11.X11GLNative x11) + { + Platform.X11.X11WindowInfo info = x11.WindowInfo as Platform.X11.X11WindowInfo; + + Graphics.Vulkan.Xlib.Window window = new Graphics.Vulkan.Xlib.Window(); + window.Value = info.WindowHandle; + + VkXlibSurfaceCreateInfoKHR createInfo = VkXlibSurfaceCreateInfoKHR.New(); + createInfo.dpy = (Graphics.Vulkan.Xlib.Display*)info.Display; + createInfo.window = window; + + return VK.CreateXlibSurfaceKHR(instance, &createInfo, IntPtr.Zero, out surface); + } + else + { + //If someone knows how to create a MoltenVK surface, please add it here + + throw new NotImplementedException(implementation.ToString()); + } + } + + public IntPtr[] RequiredVulkanExtensions() + { + if (implementation is Platform.Windows.WinGLNative win) + { + return new IntPtr[] { VulkanStrings.VK_KHR_WIN32_SURFACE_EXTENSION_NAME }; + } + else if (implementation is Platform.X11.X11GLNative x11) + { + return new IntPtr[] { VulkanStrings.VK_KHR_XLIB_SURFACE_EXTENSION_NAME }; + } + else + { + throw new NotImplementedException(implementation.ToString()); + } + } + /// /// System.Threading.Thread.CurrentThread.ManagedThreadId of the thread that created this . /// diff --git a/src/OpenTK/OpenTK.Standard.csproj b/src/OpenTK/OpenTK.Standard.csproj index e52376d5..6101cb7e 100644 --- a/src/OpenTK/OpenTK.Standard.csproj +++ b/src/OpenTK/OpenTK.Standard.csproj @@ -3,7 +3,7 @@ OpenTK netstandard2.0 OpenTK - $(DefineConstants);WIN32;CARBON;X11;SDL2;OPENGL;OPENGLES;MINIMAL + $(DefineConstants);WIN32;CARBON;X11;OPENGL;OPENGLES;MINIMAL True @@ -68,22 +68,24 @@ true - 1.0.2 - The Open Toolkit library (OpenTK) is an advanced, low-level C# wrapper for OpenGL, OpenGL ES and OpenAL. + 1.0.5 + The Open Toolkit library (OpenTK) is an advanced, low-level C# wrapper for OpenGL, OpenGL ES, OpenAL and Vulkan. It is suitable for games, scientific visualizations and projects that require 3d graphics, audio or compute functionality. Features - - Create cutting-edge graphics with OpenGL 4.4 and OpenGL ES 3.0 + - Create cutting-edge graphics with OpenGL 4.6, OpenGL ES 3.0 and Vulkan - Use the .Net/Mono language of your choice: C#, F#, VB.Net, Boo, IronPython, IronRuby - - Develop faster with inline documentation and strongly-typed enumerations for all OpenGL and OpenAL functions + - Develop faster with inline documentation and strongly-typed enumerations for all OpenGL, OpenAL and Vulkan functions This is a .NET Core-compatible version of OpenTK. -This version can be found at https://github.com/emmauss/opentk +This version can be found at https://github.com/Ryujinx/Opentk OpenTK.NetStandard emmaus emmaus OpenTK - https://github.com/emmauss/opentk + https://github.com/Ryujinx/Opentk + 1.0.5.0 + 1.0.5.0 @@ -107,8 +109,17 @@ This version can be found at https://github.com/emmauss/opentk + - \ No newline at end of file + + + + + + + + + diff --git a/src/OpenTK/Platform/Factory.cs b/src/OpenTK/Platform/Factory.cs index 5274bcf8..a4626fe5 100644 --- a/src/OpenTK/Platform/Factory.cs +++ b/src/OpenTK/Platform/Factory.cs @@ -46,8 +46,9 @@ namespace OpenTK.Platform Toolkit.Init(); // Create regular platform backend + if (false) { } #if SDL2 - if (Configuration.RunningOnSdl2) + else if (Configuration.RunningOnSdl2) { Default = new SDL2.Sdl2Factory(); } diff --git a/src/OpenTK/Platform/Windows/WinGLNative.cs b/src/OpenTK/Platform/Windows/WinGLNative.cs index d2eebd88..afa71e50 100644 --- a/src/OpenTK/Platform/Windows/WinGLNative.cs +++ b/src/OpenTK/Platform/Windows/WinGLNative.cs @@ -45,9 +45,9 @@ namespace OpenTK.Platform.Windows private const ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow; private const ExtendedWindowStyle ChildStyleEx = 0; #if NETSTANDARD - private readonly IntPtr Instance = Functions.GetModuleHandle(typeof(WinGLNative).Module.Name); + public readonly IntPtr Instance = Functions.GetModuleHandle(typeof(WinGLNative).Module.Name); #else - private readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module); + public readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module); #endif private readonly IntPtr ClassName = Marshal.StringToHGlobalAuto(Guid.NewGuid().ToString()); private readonly WindowProcedure WindowProcedureDelegate; @@ -96,6 +96,8 @@ namespace OpenTK.Platform.Windows private static readonly object SyncRoot = new object(); + public IntPtr Handle { get => window.WindowHandle; } + public WinGLNative(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { lock (SyncRoot) diff --git a/src/OpenTK/Platform/X11/Structs.cs b/src/OpenTK/Platform/X11/Structs.cs index fc420295..ea190f23 100644 --- a/src/OpenTK/Platform/X11/Structs.cs +++ b/src/OpenTK/Platform/X11/Structs.cs @@ -692,10 +692,10 @@ namespace OpenTK.Platform.X11 public int backing_store; public IntPtr backing_planes; public IntPtr backing_pixel; - public bool save_under; + public int save_under; public IntPtr event_mask; public IntPtr do_not_propagate_mask; - public bool override_redirect; + public int override_redirect; public IntPtr colormap; public IntPtr cursor; } @@ -719,7 +719,7 @@ namespace OpenTK.Platform.X11 public IntPtr backing_pixel; public byte save_under; public IntPtr colormap; - public bool map_installed; + public int map_installed; public MapState map_state; public IntPtr all_event_masks; public IntPtr your_event_mask; diff --git a/src/vk.generator/CodeGenerator.cs b/src/vk.generator/CodeGenerator.cs new file mode 100644 index 00000000..5362849d --- /dev/null +++ b/src/vk.generator/CodeGenerator.cs @@ -0,0 +1,252 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace Vk.Generator +{ + public class CodeGenerator + { + public static void GenerateCodeFiles(VulkanSpecification spec, TypeNameMappings tnm, string path) + { + if (!Directory.Exists(path)) + { + + } + GenerateAllTypes(spec, tnm, path); + } + + private static void GenerateAllTypes(VulkanSpecification spec, TypeNameMappings tnm, string path) + { + using (StreamWriter sw = File.CreateText(Path.Combine(path, "Structures.gen.cs"))) + { + CsCodeWriter cw = new CsCodeWriter(sw); + cw.WriteHeader(); + cw.WriteLine(); + + cw.Using("System"); + cw.WriteLine(); + + using (cw.PushBlock("namespace OpenTK.Graphics.Vulkan")) + { + Util.SpaceSeparatedList(cw, spec.Structures, structure => + { + StructureHelpers.WriteStructure(cw, structure, tnm, spec.Constants); + }); + } + } + + using (StreamWriter enumWriter = File.CreateText(Path.Combine(path, "Enums.gen.cs"))) + { + CsCodeWriter cw = new CsCodeWriter(enumWriter); + cw.WriteHeader(); + cw.WriteLine(); + + cw.Using("System"); + cw.WriteLine(); + + using (cw.PushBlock("namespace OpenTK.Graphics.Vulkan")) + { + Util.SpaceSeparatedList(cw, spec.Enums, enumDef => + { + EnumHelpers.WriteEnum(cw, enumDef, tnm); + }); + } + } + + CommandDefinition[] allVariants = spec.Commands.SelectMany(cd => VariantGenerator.GenerateVariants(cd)).ToArray(); + CommandDefinition[] allCommandsWithVariants = spec.Commands.Concat(allVariants).OrderBy(cd => cd.Name).ToArray(); + + using (StreamWriter commandWriter = File.CreateText(Path.Combine(path, "Commands.gen.cs"))) + { + CsCodeWriter cw = new CsCodeWriter(commandWriter); + cw.WriteHeader(); + cw.WriteLine(); + + cw.Using("System"); + cw.Using("System.Runtime.InteropServices"); + cw.WriteLine(); + + using (cw.PushBlock("namespace OpenTK.Graphics.Vulkan")) + using (cw.PushBlock("public static unsafe partial class VK")) + { + Util.SpaceSeparatedList(cw, allCommandsWithVariants, command => + { + CommandHelpers.WriteCommand(cw, tnm, command); + }); + + cw.WriteLine(); + + using (cw.PushBlock("private static void LoadFunctionPointers()")) + { + foreach (CommandDefinition command in spec.Commands) + { + cw.WriteLine($"{command.Name}_ptr = s_nativeLib.LoadFunctionPointer(\"{command.RealName}\");"); + } + } + } + } + + using (StreamWriter handleWriter = File.CreateText(Path.Combine(path, "Handles.gen.cs"))) + { + CsCodeWriter cw = new CsCodeWriter(handleWriter); + cw.WriteHeader(); + cw.WriteLine(); + + cw.Using("System"); + cw.Using("System.Diagnostics"); + cw.WriteLine(); + + using (cw.PushBlock("namespace OpenTK.Graphics.Vulkan")) + { + Util.SpaceSeparatedList(cw, spec.Handles, handle => + { + HandleHelpers.WriteHandle(cw, handle); + }); + } + } + + using (StreamWriter unionWriter = File.CreateText(Path.Combine(path, "Unions.gen.cs"))) + { + CsCodeWriter cw = new CsCodeWriter(unionWriter); + cw.WriteHeader(); + cw.WriteLine(); + + cw.Using("System.Runtime.InteropServices"); + cw.WriteLine(); + + using (cw.PushBlock("namespace OpenTK.Graphics.Vulkan")) + { + Util.SpaceSeparatedList(cw, spec.Unions, union => + { + UnionHelpers.WriteUnion(cw, tnm, union); + }); + } + } + + using (StreamWriter unionWriter = File.CreateText(Path.Combine(path, "Constants.gen.cs"))) + { + CsCodeWriter cw = new CsCodeWriter(unionWriter); + cw.WriteHeader(); + cw.WriteLine(); + cw.Using("System.Runtime.InteropServices"); + cw.WriteLine(); + + using (cw.PushBlock("namespace OpenTK.Graphics.Vulkan")) + { + ConstantHelpers.WriteAllConstants(cw, tnm, spec.Constants); + } + } + } + } + + public class CsCodeWriter + { + private readonly StreamWriter _sw; + + private int _indentLevel = 0; + + public CsCodeWriter(StreamWriter sw) + { + _sw = sw; + } + + public void Using(string ns) + { + _sw.WriteLine($"using {ns};"); + } + + public void WriteHeader() + { + _sw.WriteLine("// This file is generated."); + } + + public void PushBlock() + { + WriteLine('{'); + _indentLevel += 4; + } + + public CodeBlock PushBlock(string ns) + { + return new CodeBlock(this, ns); + } + + public IfDefSection PushIfDef(string condition) + { + return new IfDefSection(this, condition); + } + + public void PopBlock() + { + _indentLevel -= 4; + WriteLine('}'); + } + + public void WriteLine() + { + _sw.WriteLine(); + } + + public void WriteLine(string text) + { + WriteIndentation(); + _sw.WriteLine(text); + } + + public void WriteLine(char c) + { + WriteIndentation(); + _sw.WriteLine(c); + } + + public void Write(string text) + { + _sw.Write(text); + } + + public void WriteIndentation() + { + for (int i = 0; i < _indentLevel; i++) + { + _sw.Write(' '); + } + } + + public class CodeBlock : IDisposable + { + private readonly CsCodeWriter _cw; + + public CodeBlock(CsCodeWriter cw, string header) + { + _cw = cw; + _cw.WriteLine(header); + _cw.PushBlock(); + } + + public void Dispose() + { + _cw.PopBlock(); + } + } + + public class IfDefSection : IDisposable + { + private readonly CsCodeWriter _cw; + private readonly string _condition; + + public IfDefSection(CsCodeWriter cw, string condition) + { + _cw = cw; + _condition = condition; + _cw.WriteLine($"#if {condition}"); + } + + public void Dispose() + { + _cw.WriteLine($"#endif // {_condition}"); + } + } + } +} diff --git a/src/vk.generator/CommandDefinition.cs b/src/vk.generator/CommandDefinition.cs new file mode 100644 index 00000000..2fb993b9 --- /dev/null +++ b/src/vk.generator/CommandDefinition.cs @@ -0,0 +1,77 @@ +using System; +using System.Linq; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class CommandDefinition + { + public string Name { get; } + public TypeSpec ReturnType { get; } + public ParameterDefinition[] Parameters { get; } + public string[] SuccessCodes { get; } + public string[] ErrorCodes { get; } + public bool IsVariant { get; } + public string RealName { get => "vk" + Name; } + + public CommandDefinition(string name, TypeSpec returnType, ParameterDefinition[] parameters, string[] successCodes, string[] errorCodes, bool isVariant) + { + Require.NotNull(parameters); + Require.NotNull(successCodes); + Require.NotNull(errorCodes); + + if (name.StartsWith("vk")) + { + name = name.Substring(2); + } + + Name = name; + ReturnType = returnType; + Parameters = parameters; + SuccessCodes = successCodes; + ErrorCodes = errorCodes; + IsVariant = isVariant; + } + + public static CommandDefinition CreateFromXml(XElement xe) + { + Require.Equal("command", xe.Name); + + var proto = xe.Element("proto"); + string name = proto.Element("name").Value; + string returnTypeName = proto.Element("type").Value; + TypeSpec returnType = new TypeSpec(returnTypeName); + + var successAttr = xe.Attribute("successcodes"); + string[] successCodes = successAttr != null + ? successAttr.Value.Split(',').ToArray() + : Array.Empty(); + + var errorAttr = xe.Attribute("errorcodes"); + string[] errorCodes = errorAttr != null + ? errorAttr.Value.Split(',').ToArray() + : Array.Empty(); + + ParameterDefinition[] parameters = xe.Elements("param") + .Select(paramXml => ParameterDefinition.CreateFromXml(paramXml)).ToArray(); + + return new CommandDefinition(name, returnType, parameters, successCodes, errorCodes, false); + } + + public string GetParametersSignature(TypeNameMappings tnm) + { + return string.Join(", ", Parameters.Select(pd => pd.GetMappedAndNormalizedString(tnm))); + } + + public string GetParametersSignature() + { + return string.Join(", ", Parameters.Select(pd => pd.ToString())); + } + + public override string ToString() + { + string paramSig = GetParametersSignature(); + return $"{ReturnType} {Name}({paramSig})"; + } + } +} diff --git a/src/vk.generator/CommandHelpers.cs b/src/vk.generator/CommandHelpers.cs new file mode 100644 index 00000000..2adcf00e --- /dev/null +++ b/src/vk.generator/CommandHelpers.cs @@ -0,0 +1,27 @@ +using System.Linq; +using System.Runtime.InteropServices; + +namespace Vk.Generator +{ + public static class CommandHelpers + { + public static void WriteCommand(CsCodeWriter cw, TypeNameMappings tnm, CommandDefinition command) + { + if (!command.IsVariant) + { + cw.WriteLine($"private static IntPtr {command.Name}_ptr;"); + } + + if (command.SuccessCodes.Length != 0) + { + cw.WriteLine($"///Success codes:{string.Join(", ", command.SuccessCodes)}. Error codes:{string.Join(", ", command.ErrorCodes)}"); + } + + cw.WriteLine("[Generator.CalliRewrite]"); + using (cw.PushBlock($"public static unsafe {command.ReturnType.MapTypeSpec(tnm)} {command.Name}({command.GetParametersSignature(tnm)})")) + { + cw.WriteLine("throw new NotImplementedException();"); + } + } + } +} diff --git a/src/vk.generator/Configuration.cs b/src/vk.generator/Configuration.cs new file mode 100644 index 00000000..1693c7c9 --- /dev/null +++ b/src/vk.generator/Configuration.cs @@ -0,0 +1,10 @@ +using System; + +namespace Vk.Generator +{ + public static class Configuration + { + public static string CodeOutputPath { get; set; } = AppContext.BaseDirectory; + public static bool MapBaseTypes { get; set; } = true; + } +} diff --git a/src/vk.generator/ConstantDefinition.cs b/src/vk.generator/ConstantDefinition.cs new file mode 100644 index 00000000..f69d1750 --- /dev/null +++ b/src/vk.generator/ConstantDefinition.cs @@ -0,0 +1,55 @@ +using System; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class ConstantDefinition + { + public string Name { get; } + public string Value { get; } + public ConstantType Type { get; } + public string Comment { get; } + + public ConstantDefinition(string name, string value, string comment) + { + Name = name; + Value = value; + Type = ParseType(value); + Comment = comment; + } + + private ConstantType ParseType(string value) + { + if (value.EndsWith("f")) + { + return ConstantType.Float32; + } + else if (value.EndsWith("ULL)")) + { + return ConstantType.UInt64; + } + else + { + return ConstantType.UInt32; + } + } + + public static ConstantDefinition CreateFromXml(XElement xe) + { + Require.NotNull(xe); + + string name = xe.GetNameAttribute(); + string value = xe.Attribute("value").Value; + string comment = xe.Attribute("comment")?.Value; + + return new ConstantDefinition(name, value, comment); + } + + public enum ConstantType + { + UInt32, + UInt64, + Float32, + } + } +} diff --git a/src/vk.generator/ConstantHelpers.cs b/src/vk.generator/ConstantHelpers.cs new file mode 100644 index 00000000..467402de --- /dev/null +++ b/src/vk.generator/ConstantHelpers.cs @@ -0,0 +1,62 @@ +using System; + +namespace Vk.Generator +{ + public static class ConstantHelpers + { + public static void WriteAllConstants(CsCodeWriter cw, TypeNameMappings tnm, ConstantDefinition[] constants) + { + using (cw.PushBlock("public static partial class VK")) + { + foreach (ConstantDefinition constant in constants) + { + if (constant.Comment != null) + { + cw.WriteLine($"///{constant.Comment}"); + } + + cw.WriteLine($"public const {GetCSharpNameForConstantType(constant.Type)} {EnumHelpers.GetPrettyEnumName(constant.Name, "VK_")} = {NormalizeValue(constant.Value)};"); + } + } + + cw.WriteLine(); + + using (cw.PushBlock("public static partial class RawConstants")) + { + foreach (ConstantDefinition constant in constants) + { + if (constant.Comment != null) + { + cw.WriteLine($"///{constant.Comment}"); + } + + cw.WriteLine($"public const {GetCSharpNameForConstantType(constant.Type)} {constant.Name} = VK.{EnumHelpers.GetPrettyEnumName(constant.Name, "VK_")};"); + } + } + } + + public static void WriteConstant(CsCodeWriter cw, TypeNameMappings tnm, ConstantDefinition constant) + { + } + + public static string GetCSharpNameForConstantType(ConstantDefinition.ConstantType type) + { + switch (type) + { + case ConstantDefinition.ConstantType.UInt32: + return "uint"; + case ConstantDefinition.ConstantType.UInt64: + return "ulong"; + case ConstantDefinition.ConstantType.Float32: + return "float"; + default: + throw new InvalidOperationException("Illegal ConstantType: " + type); + } + } + + private static string NormalizeValue(string value) + { + return value.Replace("ULL", "UL"); + } + } +} \ No newline at end of file diff --git a/src/vk.generator/EnumDefinition.cs b/src/vk.generator/EnumDefinition.cs new file mode 100644 index 00000000..4769e51e --- /dev/null +++ b/src/vk.generator/EnumDefinition.cs @@ -0,0 +1,101 @@ +using System; +using System.Linq; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class EnumDefinition + { + public string Name { get; } + public EnumType Type { get; } + public EnumValue[] Values { get; set; } + + public EnumDefinition(string name, EnumType type, EnumValue[] values) + { + Require.NotNullOrEmpty(name); + Require.NotNull(values); + + Name = name; + Type = type; + Values = values; + } + + public static EnumDefinition CreateFromXml(XElement xe) + { + Require.NotNull(xe); + + EnumType type; + var typeAttr = xe.Attribute("type"); + if (typeAttr != null) + { + string typeString = xe.Attribute("type").Value; + type = (EnumType)Enum.Parse(typeof(EnumType), typeString, true); + } + else + { + type = EnumType.Constants; + } + + string name = xe.Attribute("name").Value; + EnumValue[] values = xe.Elements("enum").Select(valuesx => EnumValue.CreateFromXml(valuesx, type == EnumType.Bitmask)).ToArray(); + return new EnumDefinition(name, type, values); + } + + public override string ToString() + { + return $"Enum: {Name} ({Type})[{Values.Length}]"; + } + } + + public enum EnumType + { + Bitmask, + Enum, + Constants, + } + + public class EnumValue + { + public string Name { get; } + public int ValueOrBitPosition { get; } + public string Comment { get; } + + public EnumValue(string name, int value, string comment) + { + Name = name; + ValueOrBitPosition = value; + Comment = comment; + } + + public static EnumValue CreateFromXml(XElement xe, bool isBitmask) + { + Require.NotNull(xe); + + string name = xe.Attribute("name").Value; + + int value; + string valueStr = xe.Attribute("value")?.Value; + if (valueStr != null) + { + if (valueStr.StartsWith("0x")) + { + valueStr = valueStr.Substring(2); + value = int.Parse(valueStr, System.Globalization.NumberStyles.HexNumber); + } + else + { + value = int.Parse(valueStr); + } + } + else + { + string bitposStr = xe.Attribute("bitpos").Value; + value = 1 << int.Parse(bitposStr); + } + + var commentAttr = xe.Attribute("comment"); + string comment = commentAttr != null ? commentAttr.Value : string.Empty; + return new EnumValue(name, value, comment); + } + } +} \ No newline at end of file diff --git a/src/vk.generator/EnumHelpers.cs b/src/vk.generator/EnumHelpers.cs new file mode 100644 index 00000000..729103b0 --- /dev/null +++ b/src/vk.generator/EnumHelpers.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Vk.Generator +{ + public static class EnumHelpers + { + private static readonly char[] s_underscoreSeparator = { '_' }; + + private static readonly Dictionary s_knownEnumPrefixes = new Dictionary + { + { "VkResult", "VK" }, + }; + + private static readonly Dictionary s_knownEnumValueNames = new Dictionary + { + { "VK_STENCIL_FRONT_AND_BACK", "FrontAndBack" }, + // VkStructureType + + // VkSampleCountFlagBits + { "VK_SAMPLE_COUNT_1_BIT", "Count1" }, + { "VK_SAMPLE_COUNT_2_BIT", "Count2" }, + { "VK_SAMPLE_COUNT_4_BIT", "Count4" }, + { "VK_SAMPLE_COUNT_8_BIT", "Count8" }, + { "VK_SAMPLE_COUNT_16_BIT", "Count16" }, + { "VK_SAMPLE_COUNT_32_BIT", "Count32" }, + { "VK_SAMPLE_COUNT_64_BIT", "Count64" }, + // VkImageType + { "VK_IMAGE_TYPE_1D", "Image1D" }, + { "VK_IMAGE_TYPE_2D", "Image2D" }, + { "VK_IMAGE_TYPE_3D", "Image3D" }, + // VkImageViewType + { "VK_IMAGE_VIEW_TYPE_1D", "Image1D" }, + { "VK_IMAGE_VIEW_TYPE_2D", "Image2D" }, + { "VK_IMAGE_VIEW_TYPE_3D", "Image3D" }, + { "VK_IMAGE_VIEW_TYPE_CUBE", "ImageCube" }, + { "VK_IMAGE_VIEW_TYPE_1D_ARRAY", "Image1DArray" }, + { "VK_IMAGE_VIEW_TYPE_2D_ARRAY", "Image2DArray" }, + { "VK_IMAGE_VIEW_TYPE_CUBE_ARRAY", "ImageCubeArray" }, + }; + + private static readonly HashSet s_ignoredParts = new HashSet(StringComparer.OrdinalIgnoreCase) + { + "flags", + "bit" + }; + + private static readonly HashSet s_preserveCaps = new HashSet(StringComparer.OrdinalIgnoreCase) + { + "khr", + "khx", + "ext", + "nv", + "nvx", + "amd", + }; + + public static void WriteEnum(CsCodeWriter cw, EnumDefinition enumDef, TypeNameMappings tnm) + { + if (enumDef.Type == EnumType.Bitmask) + { + cw.WriteLine("[Flags]"); + } + string mappedName = tnm.GetMappedName(enumDef.Name); + string enumNamePrefix = GetEnumNamePrefix(mappedName); + using (cw.PushBlock("public enum " + mappedName)) + { + if (enumDef.Type == EnumType.Bitmask && !enumDef.Values.Any(ev => GetPrettyEnumName(ev.Name, enumNamePrefix) == "None")) + { + cw.WriteLine($"None = 0,"); + } + foreach (var value in enumDef.Values) + { + if (!string.IsNullOrEmpty(value.Comment)) + { + cw.WriteLine($"///{value.Comment}"); + } + + string prettyName = GetPrettyEnumName(value.Name, enumNamePrefix); + cw.WriteLine($"{prettyName} = {value.ValueOrBitPosition},"); + } + } + + using (cw.PushBlock("public static partial class RawConstants")) + { + foreach (var value in enumDef.Values) + { + if (!string.IsNullOrEmpty(value.Comment)) + { + cw.WriteLine($"///{value.Comment}"); + } + + string prettyName = GetPrettyEnumName(value.Name, enumNamePrefix); + cw.WriteLine($"public const {mappedName} {value.Name} = {mappedName}.{prettyName};"); + } + } + } + + public static string GetEnumNamePrefix(string typeName) + { + if (s_knownEnumPrefixes.TryGetValue(typeName, out string knownValue)) + { + return knownValue; + } + + List parts = new List(4); + int chunkStart = 0; + for (int i = 0; i < typeName.Length; i++) + { + if (char.IsUpper(typeName[i])) + { + if (chunkStart != i) + { + parts.Add(typeName.Substring(chunkStart, i - chunkStart)); + } + + chunkStart = i; + if (i == typeName.Length - 1) + { + parts.Add(typeName.Substring(i, 1)); + } + } + else if (i == typeName.Length - 1) + { + parts.Add(typeName.Substring(chunkStart, typeName.Length - chunkStart)); + } + } + + for (int i = 0; i < parts.Count; i++) + { + if ( + parts[i] == "Flag" + || parts[i] == "Flags" + || (parts[i] == "K" && (i + 2) < parts.Count && parts[i + 1] == "H" && parts[i + 2] == "R") + || (parts[i] == "A" && (i + 2) < parts.Count && parts[i + 1] == "M" && parts[i + 2] == "D") + || (parts[i] == "E" && (i + 2) < parts.Count && parts[i + 1] == "X" && parts[i + 2] == "T") + || (parts[i] == "Type" && (i + 3) < parts.Count && parts[i + 1] == "N" && parts[i + 2] == "V" && parts[i + 3] == "X") + ) + { + parts = new List(parts.Take(i)); + break; + } + } + + return string.Join("_", parts.Select(s => s.ToUpper())); + } + + public static string TrimIgnoredParts(string ret) + { + foreach (string ignored in s_ignoredParts) + { + int index; + if ((index = ret.IndexOf(ignored, StringComparison.OrdinalIgnoreCase)) != -1) + { + ret = ret.Remove(index, ignored.Length); + } + } + + return ret; + } + + public static string GetPrettyEnumName(string value, string enumPrefix) + { + if (s_knownEnumValueNames.TryGetValue(value, out string knownName)) + { + return knownName; + } + + if (value.IndexOf(enumPrefix) != 0) + { + return value; + } + + string[] parts = value.Substring(enumPrefix.Length, value.Length - enumPrefix.Length) + .Split(s_underscoreSeparator, StringSplitOptions.RemoveEmptyEntries); + StringBuilder sb = new StringBuilder(); + foreach (string part in parts) + { + if (s_ignoredParts.Contains(part)) + { + continue; + } + + if (s_preserveCaps.Contains(part)) + { + sb.Append(part); + } + else + { + sb.Append(char.ToUpper(part[0])); + for (int i = 1; i < part.Length; i++) + { + sb.Append(char.ToLower(part[i])); + } + } + } + + string prettyName = sb.ToString(); + return (char.IsNumber(prettyName[0])) ? "_" + prettyName : prettyName; + } + } +} diff --git a/src/vk.generator/ExtensionDefinition.cs b/src/vk.generator/ExtensionDefinition.cs new file mode 100644 index 00000000..5128a0e9 --- /dev/null +++ b/src/vk.generator/ExtensionDefinition.cs @@ -0,0 +1,126 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class ExtensionDefinition + { + public string Name { get; } + public int Number { get; } + public string Type { get; } + public ExtensionConstant[] Constants { get; } + public EnumExtensionValue[] EnumExtensions { get; } + public string[] CommandNames { get; } + + public ExtensionDefinition( + string name, + int number, + string type, + ExtensionConstant[] constants, + EnumExtensionValue[] enumExtensions, + string[] commandNames) + { + Name = name; + Number = number; + Type = type; + Constants = constants; + EnumExtensions = enumExtensions; + CommandNames = commandNames; + } + + public static ExtensionDefinition CreateFromXml(XElement xe) + { + string name = xe.GetNameAttribute(); + string numberString = xe.Attribute("number").Value; + int number = int.Parse(numberString); + string type = xe.GetTypeAttributeOrNull(); + List extensionConstants = new List(); + List enumExtensions = new List(); + List commandNames = new List(); + + foreach (var require in xe.Elements("require")) + { + foreach (var enumXE in require.Elements("enum")) + { + string enumName = enumXE.GetNameAttribute(); + string extends = enumXE.Attribute("extends")?.Value; + if (extends != null) + { + string valueString; + string offsetString = enumXE.Attribute("offset")?.Value; + if (offsetString != null) + { + int offset = int.Parse(offsetString); + int direction = 1; + if (enumXE.Attribute("dir")?.Value == "-") + { + direction = -1; + } + + int value = direction * (1000000000 + (number - 1) * 1000 + offset); + valueString = value.ToString(); + } + else + { + string bitPosString = enumXE.Attribute("bitpos")?.Value; + if (bitPosString != null) + { + int shift = int.Parse(bitPosString); + valueString = (1 << shift).ToString(); + } + else + { + valueString = enumXE.Attribute("value").Value; + } + } + enumExtensions.Add(new EnumExtensionValue(extends, enumName, valueString)); + } + else + { + var valueAttribute = enumXE.Attribute("value"); + if (valueAttribute == null) + continue; + + extensionConstants.Add(new ExtensionConstant(name, valueAttribute.Value)); + } + } + foreach (var commandXE in require.Elements("command")) + { + commandNames.Add(commandXE.GetNameAttribute()); + } + } + return new ExtensionDefinition(name, number, type, extensionConstants.ToArray(), enumExtensions.ToArray(), commandNames.ToArray()); + } + } + + public class ExtensionConstant + { + public string Name { get; } + public string Value { get; } + public ExtensionConstant(string name, string value) + { + Name = name; + Value = value; + } + } + + [DebuggerDisplay("{DebuggerDisplayString}")] + public class EnumExtensionValue + { + public string ExtendedType { get; } + public string Name { get; } + public string Value { get; } + + public EnumExtensionValue(string extendedType, string name, string value) + { + ExtendedType = extendedType; + Name = name; + Value = value; + } + + private string DebuggerDisplayString => + $"Ext: {ExtendedType}, {Name} = {Value}"; + } +} diff --git a/src/vk.generator/HandleDefinition.cs b/src/vk.generator/HandleDefinition.cs new file mode 100644 index 00000000..03704533 --- /dev/null +++ b/src/vk.generator/HandleDefinition.cs @@ -0,0 +1,28 @@ +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class HandleDefinition + { + public string Name { get; } + public bool Dispatchable { get; } + public string Parent { get; } + + public HandleDefinition(string name, bool dispatchable, string parent) + { + Name = name; + Dispatchable = dispatchable; + Parent = parent; + } + + public static HandleDefinition CreateFromXml(XElement xe) + { + Require.NotNull(xe); + string name = xe.GetNameElement(); + bool dispatchable = xe.GetTypeElement() == "VK_DEFINE_HANDLE"; + string parent = xe.Attribute("parent")?.Value; + + return new HandleDefinition(name, dispatchable, parent); + } + } +} diff --git a/src/vk.generator/HandleHelpers.cs b/src/vk.generator/HandleHelpers.cs new file mode 100644 index 00000000..452d47e4 --- /dev/null +++ b/src/vk.generator/HandleHelpers.cs @@ -0,0 +1,39 @@ +using System; + +namespace Vk.Generator +{ + public static class HandleHelpers + { + public static void WriteHandle(CsCodeWriter cw, HandleDefinition handle) + { + if (handle.Parent != null) + { + cw.WriteIndentation(); + cw.Write($"///"); + cw.Write($"A {(handle.Dispatchable ? "dispatchable" : "non-dispatchable")} handle owned by a {handle.Parent}."); + cw.Write(""); + cw.Write(Environment.NewLine); + } + cw.WriteLine($"[DebuggerDisplay(\"{{DebuggerDisplay,nq}}\")]"); + using (cw.PushBlock($"public partial struct {handle.Name} : IEquatable<{handle.Name}>")) + { + string handleType = handle.Dispatchable ? "IntPtr" : "ulong"; + string nullValue = handle.Dispatchable ? "IntPtr.Zero" : "0"; + + cw.WriteLine($"public readonly {handleType} Handle;"); + + cw.WriteLine($"public {handle.Name}({handleType} existingHandle) {{ Handle = existingHandle; }}"); + cw.WriteLine($"public static {handle.Name} Null => new {handle.Name}({nullValue});"); + cw.WriteLine($"public static implicit operator {handle.Name}({handleType} handle) => new {handle.Name}(handle);"); + cw.WriteLine($"public static bool operator ==({handle.Name} left, {handle.Name} right) => left.Handle == right.Handle;"); + cw.WriteLine($"public static bool operator !=({handle.Name} left, {handle.Name} right) => left.Handle != right.Handle;"); + cw.WriteLine($"public static bool operator ==({handle.Name} left, {handleType} right) => left.Handle == right;"); + cw.WriteLine($"public static bool operator !=({handle.Name} left, {handleType} right) => left.Handle != right;"); + cw.WriteLine($"public bool Equals({handle.Name} h) => Handle.Equals(h.Handle);"); + cw.WriteLine($"public override bool Equals(object o) => o is {handle.Name} h && Equals(h);"); + cw.WriteLine($"public override int GetHashCode() => Handle.GetHashCode();"); + cw.WriteLine($"private string DebuggerDisplay => string.Format(\"{handle.Name} [0x{{0}}]\", Handle.ToString(\"X\"));"); + } + } + } +} \ No newline at end of file diff --git a/src/vk.generator/MemberSpec.cs b/src/vk.generator/MemberSpec.cs new file mode 100644 index 00000000..905fc2d5 --- /dev/null +++ b/src/vk.generator/MemberSpec.cs @@ -0,0 +1,76 @@ +using System.Text.RegularExpressions; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class MemberSpec + { + public string Name { get; } + public TypeSpec Type { get; } + public bool IsOptional { get; } + public int ElementCount { get; } + public string ElementCountSymbolic { get; } + public string Comment { get; } + public string LegalValues { get; } + + public MemberSpec(string name, TypeSpec type, bool isOptional, int elementCount, string elementCountSymbolic, string comment, string legalValues) + { + Name = name; + Type = type; + IsOptional = isOptional; + ElementCount = elementCount; + ElementCountSymbolic = elementCountSymbolic; + Comment = comment; + LegalValues = legalValues; + } + + public static MemberSpec CreateFromXml(XElement xe) + { + Require.NotNull(xe); + + string name = xe.GetNameElement(); + bool isOptional = xe.GetOptionalAttributeOrFalse(); + string typeName = xe.Element("type").Value; + int pointerLevel = xe.Value.Contains($"{typeName}*") ? 1 : 0; // TODO: Make this better. + if (xe.Value.Contains($"{typeName}* const*")) + { + pointerLevel += 1; + } + + TypeSpec type = new TypeSpec(typeName, pointerLevel); + + bool foundConstantElementCount = false; + int elementCount = 1; + string elementCountSymbolic = null; + for (int i = 2; i < 10; i++) + { + if (xe.Value.Contains($"{name}[{i}]")) + { + elementCount = i; + foundConstantElementCount = true; + break; + } + } + + if (!foundConstantElementCount) + { + Match m = Regex.Match(xe.Value, @"\[(.*)\]"); + if (m.Captures.Count > 0) + { + elementCountSymbolic = m.Groups[1].Value; + } + } + + string value = xe.Attribute("values")?.Value; + + return new MemberSpec(name, type, isOptional, elementCount, elementCountSymbolic, string.Empty, value); + } + + public override string ToString() + { + string optionalPart = IsOptional ? "[opt] " : ""; + string countPart = ElementCount != 1 ? $" [{ElementCount}]" : ElementCountSymbolic != null ? $" [{ElementCountSymbolic}]" : ""; + return $"{optionalPart}{Type} {Name}"; + } + } +} diff --git a/src/vk.generator/ParameterDefinition.cs b/src/vk.generator/ParameterDefinition.cs new file mode 100644 index 00000000..5ca5b938 --- /dev/null +++ b/src/vk.generator/ParameterDefinition.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class ParameterDefinition + { + public string Name { get; } + public TypeSpec Type { get; } + public ParameterModifier Modifier { get; } + public bool IsOptional { get; } + + public ParameterDefinition(string name, TypeSpec type, ParameterModifier modifier, bool isOptional) + { + Name = name; + Type = type; + Modifier = modifier; + IsOptional = isOptional; + } + + public static ParameterDefinition CreateFromXml(XElement xe) + { + string name = xe.Element("name").Value; + var optionalAttr = xe.Attribute("optional"); + bool isOptional = optionalAttr != null && optionalAttr.Value == "true"; + string typeName = xe.Element("type").Value; + int pointerLevel = 0; + if (xe.Value.Contains($"{typeName}**") || xe.Value.Contains($"{typeName}* const*")) + { + pointerLevel = 2; + } + else if(xe.Value.Contains($"{typeName}*")) + { + pointerLevel = 1; + } + + + TypeSpec type = new TypeSpec(typeName, pointerLevel); + + return new ParameterDefinition(name, type, ParameterModifier.None, isOptional); + } + + public string GetMappedAndNormalizedString(TypeNameMappings tnm) + { + return $"{GetModifierString()}{Type.MapTypeSpec(tnm)} {Util.NormalizeFieldName(Name)}"; + } + + public string GetModifierString() + { + if (Modifier == ParameterModifier.Ref) + { + return "ref "; + } + else if (Modifier == ParameterModifier.Out) + { + return "out "; + } + else + { + return string.Empty; + } + } + + public override string ToString() + { + return $"{GetModifierString()}{Type} {Name}"; + } + } + + public enum ParameterModifier + { + None, + Ref, + Out + } +} diff --git a/src/vk.generator/Program.cs b/src/vk.generator/Program.cs new file mode 100644 index 00000000..6e660f91 --- /dev/null +++ b/src/vk.generator/Program.cs @@ -0,0 +1,69 @@ +using System; +using System.IO; +using System.CommandLine; +using System.Collections.Generic; + +namespace Vk.Generator +{ + public class Program + { + public static int Main(string[] args) + { + string outputPath = AppContext.BaseDirectory; + + ArgumentSyntax.Parse(args, s => + { + s.DefineOption("o|out", ref outputPath, "The folder into which code is generated. Defaults to the application directory."); + }); + + Configuration.CodeOutputPath = outputPath; + + if (File.Exists(outputPath)) + { + Console.Error.WriteLine("The given path is a file, not a folder."); + return 1; + } + else if (!Directory.Exists(outputPath)) + { + Directory.CreateDirectory(outputPath); + } + + using (var fs = File.OpenRead(Path.Combine(AppContext.BaseDirectory, "vk.xml"))) + { + VulkanSpecification vs = VulkanSpecification.LoadFromXmlStream(fs); + TypeNameMappings tnm = new TypeNameMappings(); + foreach (var typedef in vs.Typedefs) + { + if (typedef.Requires != null) + { + tnm.AddMapping(typedef.Requires, typedef.Name); + } + else + { + tnm.AddMapping(typedef.Name, "uint"); + } + } + + HashSet definedBaseTypes = new HashSet + { + "VkBool32" + }; + + if (Configuration.MapBaseTypes) + { + foreach (var baseType in vs.BaseTypes) + { + if (!definedBaseTypes.Contains(baseType.Key)) + { + tnm.AddMapping(baseType.Key, baseType.Value); + } + } + } + + CodeGenerator.GenerateCodeFiles(vs, tnm, Configuration.CodeOutputPath); + } + + return 0; + } + } +} \ No newline at end of file diff --git a/src/vk.generator/Require.cs b/src/vk.generator/Require.cs new file mode 100644 index 00000000..773f3949 --- /dev/null +++ b/src/vk.generator/Require.cs @@ -0,0 +1,32 @@ +using System; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public static class Require + { + public static void NotNull(T obj) where T : class + { + if (obj == null) + { + throw new InvalidOperationException("Object should not have been null."); + } + } + + public static void NotNullOrEmpty(string name) + { + if (string.IsNullOrEmpty(name)) + { + throw new InvalidOperationException("Value should not have been null or empty."); + } + } + + internal static void Equal(T expected, T actual) where T : IEquatable + { + if (!expected.Equals(actual)) + { + throw new InvalidOperationException($"Requirement not met. Expected: {expected}, Actual: {actual}"); + } + } + } +} diff --git a/src/vk.generator/StructureDefinition.cs b/src/vk.generator/StructureDefinition.cs new file mode 100644 index 00000000..ec661144 --- /dev/null +++ b/src/vk.generator/StructureDefinition.cs @@ -0,0 +1,31 @@ +using System.Linq; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class StructureDefinition + { + public string Name { get; } + public MemberSpec[] Members { get; } + + public StructureDefinition(string name, MemberSpec[] members) + { + Name = name; + Members = members; + } + + public static StructureDefinition CreateFromXml(XElement xe) + { + Require.NotNull(xe); + + string name = xe.GetNameAttribute(); + MemberSpec[] members = xe.Elements("member").Select(memberx => MemberSpec.CreateFromXml(memberx)).ToArray(); + return new StructureDefinition(name, members); + } + + public override string ToString() + { + return $"struct {Name}[{Members.Length}]"; + } + } +} diff --git a/src/vk.generator/StructureHelpers.cs b/src/vk.generator/StructureHelpers.cs new file mode 100644 index 00000000..f10975f9 --- /dev/null +++ b/src/vk.generator/StructureHelpers.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Vk.Generator +{ + public static class StructureHelpers + { + private static readonly HashSet s_fixedCapableTypes = new HashSet() + { + "byte", "short", "int", "long", "char", "sbyte", "ushort", "uint", "ulong", "float", "double" + }; + + public static void WriteStructure(CsCodeWriter cw, StructureDefinition structure, TypeNameMappings tnm, ConstantDefinition[] constants) + { + using (cw.PushBlock("public unsafe partial struct " + structure.Name)) + { + foreach (var member in structure.Members) + { + if (member.ElementCount > 1) + { + for (int i = 0; i < member.ElementCount; i++) + { + WriteMember(cw, tnm, member, "_" + i); + } + } + else if (member.ElementCountSymbolic != null) + { + var validConstant = constants.FirstOrDefault(cd => cd.Name == member.ElementCountSymbolic); + if (validConstant != null) + WriteMemberSymbolicCount(cw, tnm, member, constants); + else + WriteMember(cw, tnm, member, string.Empty); + } + else + { + WriteMember(cw, tnm, member, string.Empty); + } + } + + if (HasAnyFieldWithSpecifiedValues(structure)) + { + // Add a helper property which fills in the structure type. + using (cw.PushBlock($"public static {structure.Name} New()")) + { + cw.WriteLine($"{structure.Name} ret = new {structure.Name}();"); + foreach (var member in structure.Members.Where(ms => ms.LegalValues != null)) + { + cw.WriteLine($"ret.{member.Name} = {member.Type}.{GetDefaultValueString(member.Type, member.LegalValues)};"); + } + cw.WriteLine("return ret;"); + } + } + } + } + + private static string GetDefaultValueString(TypeSpec type, string legalValues) + { + string prefix = EnumHelpers.GetEnumNamePrefix(type.Name); + string prettyName = EnumHelpers.GetPrettyEnumName(legalValues, prefix); + return prettyName; + } + + private static bool HasAnyFieldWithSpecifiedValues(StructureDefinition sd) + { + return sd.Members.Any(ms => ms.LegalValues != null); + } + + private static void WriteMember(CsCodeWriter cw, TypeNameMappings tnm, MemberSpec member, string nameSuffix) + { + if (!string.IsNullOrEmpty(member.Comment)) + { + cw.WriteLine($"///{member.Comment}"); + } + + cw.WriteLine($"public {member.Type.MapTypeSpec(tnm)} {Util.NormalizeFieldName(member.Name)}{nameSuffix};"); + } + + private static void WriteMemberSymbolicCount(CsCodeWriter cw, TypeNameMappings tnm, MemberSpec member, ConstantDefinition[] constants) + { + if (!CanUseFixed(member.Type.MapTypeSpec(tnm))) + { + int count = GetSymbolValue(member.ElementCountSymbolic, constants); + for (int i = 0; i < count; i++) + { + WriteMember(cw, tnm, member, "_" + i); + } + } + else + { + if (!string.IsNullOrEmpty(member.Comment)) + { + cw.WriteLine($"///{member.Comment}"); + } + + string mappedSymbolicName = EnumHelpers.GetPrettyEnumName(member.ElementCountSymbolic, "VK_"); + cw.WriteLine($"public fixed {member.Type.MapTypeSpec(tnm)} {Util.NormalizeFieldName(member.Name)}[(int)VK.{mappedSymbolicName}];"); + } + } + + private static int GetSymbolValue(string symbolName, ConstantDefinition[] constants) + { + return int.Parse(constants.Single(cd => cd.Name == symbolName).Value); + } + + private static bool CanUseFixed(TypeSpec type) + { + return s_fixedCapableTypes.Contains(type.Name); + } + } +} diff --git a/src/vk.generator/TypeNameMappings.cs b/src/vk.generator/TypeNameMappings.cs new file mode 100644 index 00000000..a1d9475b --- /dev/null +++ b/src/vk.generator/TypeNameMappings.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; + +namespace Vk.Generator +{ + public class TypeNameMappings + { + private readonly Dictionary _nameMappings = new Dictionary() + { + { "uint8_t", "byte" }, + { "uint32_t", "uint" }, + { "uint64_t", "ulong" }, + { "int32_t", "int" }, + { "int64_t", "long" }, + { "int64_t*", "long*" }, + { "char", "byte" }, + { "size_t", "UIntPtr" }, + { "DWORD", "uint" }, + + { "ANativeWindow", "Android.ANativeWindow" }, + + { "MirConnection", "Mir.MirConnection" }, + { "MirSurface", "Mir.MirSurface" }, + + { "wl_display", "Wayland.wl_display" }, + { "wl_surface", "Wayland.wl_surface" }, + + { "Display", "Xlib.Display" }, + { "Window", "Xlib.Window" }, + { "VisualID", "Xlib.VisualID" }, + { "RROutput", "IntPtr" }, + + { "HINSTANCE", "Win32.HINSTANCE" }, + { "HWND", "Win32.HWND" }, + { "HANDLE", "Win32.HANDLE" }, + { "SECURITY_ATTRIBUTES", "Win32.SECURITY_ATTRIBUTES" }, + { "LPCWSTR", "IntPtr" }, + + { "xcb_connection_t", "Xcb.xcb_connection_t" }, + { "xcb_window_t", "Xcb.xcb_window_t" }, + { "xcb_visualid_t", "Xcb.xcb_visualid_t" }, + }; + + internal IEnumerable> GetAllMappings() + { + return _nameMappings; + } + + public void AddMapping(string originalName, string newName) + { + _nameMappings.Add(originalName, newName); + } + + public string GetMappedName(string name) + { + if (_nameMappings.TryGetValue(name, out string mappedName)) + { + return GetMappedName(mappedName); + } + else if (name.StartsWith("PFN")) + { + return "IntPtr"; + } + else + { + return name; + } + } + } +} diff --git a/src/vk.generator/TypeSpec.cs b/src/vk.generator/TypeSpec.cs new file mode 100644 index 00000000..754ac67b --- /dev/null +++ b/src/vk.generator/TypeSpec.cs @@ -0,0 +1,51 @@ +using System; + +namespace Vk.Generator +{ + public class TypeSpec + { + public string Name { get; } + public int PointerIndirection { get; } + public int ArrayDimensions { get; } + + public TypeSpec(string name) : this(name, 0, 0) { } + public TypeSpec(string name, int pointerIndirection) : this(name, pointerIndirection, 0) { } + public TypeSpec(string name, int pointerIndirection, int arrayDimensions) + { + Name = name; + PointerIndirection = pointerIndirection; + ArrayDimensions = arrayDimensions; + } + + public TypeSpec MapTypeSpec(TypeNameMappings tnm) + { + return new TypeSpec(tnm.GetMappedName(Name), PointerIndirection, ArrayDimensions); + } + + public override string ToString() + { + return GetFullTypeName(); + } + + private string GetFullTypeName() + { + return $"{Name}{new string('*', PointerIndirection)}{GetArrayPortion()}"; + } + + private string GetArrayPortion() + { + if (ArrayDimensions == 0) + { + return string.Empty; + } + else if (ArrayDimensions == 1) + { + return "[]"; + } + else + { + return $"[{new string(',', ArrayDimensions - 1)}]"; + } + } + } +} diff --git a/src/vk.generator/TypedefDefinition.cs b/src/vk.generator/TypedefDefinition.cs new file mode 100644 index 00000000..a04e9ea1 --- /dev/null +++ b/src/vk.generator/TypedefDefinition.cs @@ -0,0 +1,31 @@ +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class TypedefDefinition + { + public string Name { get; } + public string Requires { get; } + public string Type { get; } + + public TypedefDefinition(string name, string requires, string type) + { + Name = name; + Requires = requires; + Type = type; + } + + public static TypedefDefinition CreateFromXml(XElement xe) + { + string name = xe.GetNameElement(); + string requires = xe.Attribute("requires")?.Value; + string type = xe.GetTypeElement(); + return new TypedefDefinition(name, requires, type); + } + + public override string ToString() + { + return $"{Name}, {Requires} -> {Type}"; + } + } +} diff --git a/src/vk.generator/UnionHelpers.cs b/src/vk.generator/UnionHelpers.cs new file mode 100644 index 00000000..9700e29e --- /dev/null +++ b/src/vk.generator/UnionHelpers.cs @@ -0,0 +1,42 @@ +using System; + +namespace Vk.Generator +{ + public class UnionHelpers + { + public static void WriteUnion(CsCodeWriter cw, TypeNameMappings tnm, StructureDefinition union) + { + cw.WriteLine("[StructLayout(LayoutKind.Explicit)]"); + using (cw.PushBlock("public partial struct " + union.Name)) + { + foreach (var member in union.Members) + { + if (member.ElementCount > 1) + { + for (int i = 0; i < member.ElementCount; i++) + { + int fieldSize = Util.GetTypeSize(member.Type.MapTypeSpec(tnm)); + cw.WriteLine($"[FieldOffset({i * fieldSize})]"); + WriteMember(cw, tnm, member, "_" + i); + } + } + else + { + cw.WriteLine("[FieldOffset(0)]"); + WriteMember(cw, tnm, member, string.Empty); + } + } + } + } + + private static void WriteMember(CsCodeWriter cw, TypeNameMappings tnm, MemberSpec member, string nameSuffix) + { + if (!string.IsNullOrEmpty(member.Comment)) + { + cw.WriteLine($"///{member.Comment}"); + } + + cw.WriteLine($"public {member.Type.MapTypeSpec(tnm)} {Util.NormalizeFieldName(member.Name)}{nameSuffix};"); + } + } +} \ No newline at end of file diff --git a/src/vk.generator/Util.cs b/src/vk.generator/Util.cs new file mode 100644 index 00000000..193bb71f --- /dev/null +++ b/src/vk.generator/Util.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; + +namespace Vk.Generator +{ + public static class Util + { + private static readonly Dictionary s_typeSizes = new Dictionary + { + { "byte", 1 }, + { "uint", 4 }, + { "ulong", 4 }, + { "int", 4 }, + { "float", 4 }, + }; + + private static readonly HashSet s_keywords = new HashSet + { + "object", + "event", + }; + + public static int GetTypeSize(TypeSpec type) + { + if (type.PointerIndirection != 0 || !s_typeSizes.TryGetValue(type.Name, out int size)) + { + throw new InvalidOperationException(); + } + + return size; + } + + public static string NormalizeFieldName(string name) + { + if (s_keywords.Contains(name)) + { + return "@" + name; + } + + return name; + } + public static void SpaceSeparatedList(CsCodeWriter cw, IList list, Action action) + { + for (int i = 0; i < list.Count; i++) + { + var item = list[i]; + action(item); + if (i != list.Count - 1) + { + cw.WriteLine(); + } + } + } + } +} \ No newline at end of file diff --git a/src/vk.generator/VariantGenerator.cs b/src/vk.generator/VariantGenerator.cs new file mode 100644 index 00000000..c3d6aea9 --- /dev/null +++ b/src/vk.generator/VariantGenerator.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Vk.Generator +{ + public static class VariantGenerator + { + public static CommandDefinition[] GenerateVariants(CommandDefinition cd) + { + ParameterDefinition[] parameters = cd.Parameters; + List[] parameterPossibilities = new List[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + parameterPossibilities[i] = new List() { parameters[i] }; + parameterPossibilities[i].AddRange(GenerateVariantParameters(cd, parameters[i])); + } + + ParameterDefinition[][] definitions = parameterPossibilities.Select(l => l.ToArray()).ToArray(); + var combos = GetCombinations(definitions).ToArray(); + CommandDefinition[] commands = combos.Skip(1).Select(pd => + { + return new CommandDefinition(cd.Name, cd.ReturnType, pd, cd.SuccessCodes, cd.ErrorCodes, true); + }).ToArray(); + + return commands; + } + + private static IEnumerable GetCombinations(ParameterDefinition[][] pds) + { + ParameterDefinition[] first = pds.First(); + ParameterDefinition[][] rest = GetSubArray(pds, 1); + foreach (var option in first) + { + if (!rest.Any()) + { + yield return new[] { option }; + } + else + { + var restVariants = GetCombinations(rest); + foreach (var restVariant in restVariants) + { + yield return Prepend(option, restVariant); + } + } + } + } + + private static IEnumerable GenerateVariantParameters(CommandDefinition cd, ParameterDefinition pd) + { + if (CanHaveVariant(pd)) + { + if ((cd.Name.StartsWith("Create") || cd.Name.StartsWith("Allocate") || cd.Name.StartsWith("Get")) && pd == cd.Parameters.Last()) + { + yield return OutVariant(pd); + } + else if (pd.Type.Name == "char" && pd.Type.PointerIndirection == 1) + { + yield return StringVariant(pd); + } + else + { + yield return RefVariant(pd); + yield return IntPtrVariant(pd); + if (pd.Name.EndsWith("Infos")) + { + yield return ArrayVariant(pd, 1); + } + } + } + } + + private static ParameterDefinition StringVariant(ParameterDefinition pd) + { + TypeSpec typeSpec = new TypeSpec("string"); + return new ParameterDefinition(pd.Name, typeSpec, ParameterModifier.None, pd.IsOptional); + } + + private static ParameterDefinition ArrayVariant(ParameterDefinition pd, int dimensions) + { + TypeSpec typeSpec = new TypeSpec(pd.Type.Name, pd.Type.PointerIndirection - 1, dimensions); + return new ParameterDefinition(pd.Name, typeSpec, ParameterModifier.None, pd.IsOptional); + } + + private static ParameterDefinition OutVariant(ParameterDefinition pd) + { + TypeSpec typeSpec = new TypeSpec(pd.Type.Name, pd.Type.PointerIndirection - 1); + return new ParameterDefinition(pd.Name, typeSpec, ParameterModifier.Out, pd.IsOptional); + } + + private static ParameterDefinition RefVariant(ParameterDefinition pd) + { + TypeSpec typeSpec = new TypeSpec(pd.Type.Name, pd.Type.PointerIndirection - 1); + return new ParameterDefinition(pd.Name, typeSpec, ParameterModifier.Ref, pd.IsOptional); + } + + private static ParameterDefinition IntPtrVariant(ParameterDefinition pd) + { + TypeSpec typeSpec = new TypeSpec(nameof(IntPtr)); + return new ParameterDefinition(pd.Name, typeSpec, ParameterModifier.None, pd.IsOptional); + } + + private static bool CanHaveVariant(ParameterDefinition pd) + { + return pd.Type.PointerIndirection > 0 && pd.Type.Name != "void"; + } + + private static T[] GetSubArray(T[] array, int skip) + { + return array.Skip(skip).ToArray(); + } + + private static T[] Prepend(T first, T[] rest) + { + T[] arr = new T[rest.Length + 1]; + rest.CopyTo(arr, 1); + arr[0] = first; + return arr; + } + } +} diff --git a/src/vk.generator/VulkanSpecification.cs b/src/vk.generator/VulkanSpecification.cs new file mode 100644 index 00000000..e9c188b0 --- /dev/null +++ b/src/vk.generator/VulkanSpecification.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public class VulkanSpecification + { + public CommandDefinition[] Commands { get; } + public ConstantDefinition[] Constants { get; } + public TypedefDefinition[] Typedefs { get; } + public EnumDefinition[] Enums { get; } + public StructureDefinition[] Structures { get; } + public StructureDefinition[] Unions{ get; } + public HandleDefinition[] Handles { get; } + public string[] BitmaskTypes { get; } + public Dictionary BaseTypes { get; } + public ExtensionDefinition[] Extensions { get; } + + public VulkanSpecification( + CommandDefinition[] commands, + ConstantDefinition[] constants, + TypedefDefinition[] typedefs, + EnumDefinition[] enums, + StructureDefinition[] structures, + StructureDefinition[] unions, + HandleDefinition[] handles, + string[] bitmaskTypes, + Dictionary baseTypes, + ExtensionDefinition[] extensions) + { + Commands = commands; + Constants = constants; + Typedefs = typedefs; + Enums = enums; + Structures = structures; + Unions = unions; + Handles = handles; + BitmaskTypes = bitmaskTypes; + BaseTypes = baseTypes; + Extensions = extensions; + AddExtensionEnums(Enums, Extensions); + } + + public static VulkanSpecification LoadFromXmlStream(Stream specFileStream) + { + var spec = XDocument.Load(specFileStream); + var registry = spec.Element("registry"); + var commands = registry.Element("commands"); + CommandDefinition[] commandDefinitions = commands.Elements("command") + .Select(commandx => CommandDefinition.CreateFromXml(commandx)).ToArray(); + + ConstantDefinition[] constantDefinitions = registry.Elements("enums") + .Where(enumx => enumx.Attribute("name").Value == "API Constants") + .SelectMany(enumx => enumx.Elements("enum")) + .Select(enumxx => ConstantDefinition.CreateFromXml(enumxx)).ToArray(); + + var types = registry.Elements("types"); + TypedefDefinition[] typedefDefinitions = types.Elements("type").Where(xe => xe.Value.Contains("typedef") && xe.HasCategoryAttribute("bitmask")) + .Select(xe2 => TypedefDefinition.CreateFromXml(xe2)).ToArray(); + + EnumDefinition[] enumDefinitions = registry.Elements("enums") + .Where(enumx => enumx.GetTypeAttributeOrNull() == "enum" || enumx.GetTypeAttributeOrNull() == "bitmask") + .Select(enumx => EnumDefinition.CreateFromXml(enumx)).ToArray(); + + StructureDefinition[] structures = types.Elements("type").Where(typex => typex.HasCategoryAttribute("struct")) + .Select(typex => StructureDefinition.CreateFromXml(typex)).ToArray(); + + StructureDefinition[] unions = + types.Elements("type") + .Where(typex => typex.HasCategoryAttribute("union")) + .Select(typex => StructureDefinition.CreateFromXml(typex)).ToArray(); + + HandleDefinition[] handles = types.Elements("type").Where(typex => typex.HasCategoryAttribute("handle")) + .Select(typex => HandleDefinition.CreateFromXml(typex)).ToArray(); + + string[] bitmaskTypes = types.Elements("type").Where(typex => typex.HasCategoryAttribute("bitmask")) + .Select(typex => typex.GetNameElement()).ToArray(); + + Dictionary baseTypes = types.Elements("type").Where(typex => typex.HasCategoryAttribute("basetype")) + .ToDictionary( + typex => typex.GetNameElement(), + typex => typex.Element("type").Value); + + ExtensionDefinition[] extensions = registry.Element("extensions").Elements("extension") + .Select(xe => ExtensionDefinition.CreateFromXml(xe)).ToArray(); + + return new VulkanSpecification( + commandDefinitions, + constantDefinitions, + typedefDefinitions, + enumDefinitions, + structures, + unions, + handles, + bitmaskTypes, + baseTypes, + extensions); + } + + private void AddExtensionEnums(EnumDefinition[] enums, ExtensionDefinition[] extensions) + { + foreach (ExtensionDefinition exDef in extensions) + { + if (exDef.Name == "VK_KHX_device_group") + { + + } + + foreach (var enumEx in exDef.EnumExtensions) + { + EnumDefinition enumDef = GetEnumDef(enums, enumEx.ExtendedType); + int value = int.Parse(enumEx.Value); + enumDef.Values = enumDef.Values.Append(new EnumValue(enumEx.Name, value, null)).ToArray(); + } + } + } + + private EnumDefinition GetEnumDef(EnumDefinition[] enums, string name) + { + return enums.Single(ed => ed.Name == name); + } + } +} diff --git a/src/vk.generator/XElementExtensions.cs b/src/vk.generator/XElementExtensions.cs new file mode 100644 index 00000000..bcc1a346 --- /dev/null +++ b/src/vk.generator/XElementExtensions.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Linq; + +namespace Vk.Generator +{ + public static class XElementExtensions + { + public static string GetNameAttribute(this XElement xe) + { + return xe.Attribute("name").Value; + } + + public static string GetNameElement(this XElement xe) + { + return xe.Element("name").Value; + } + + public static string GetTypeElement(this XElement xe) + { + return xe.Element("type").Value; + } + + public static string GetTypeAttributeOrNull(this XElement xe) + { + return xe.Attribute("type")?.Value; + } + + public static bool GetOptionalAttributeOrFalse(this XElement xe) + { + var attr = xe.Attribute("optional"); + return attr != null + ? attr.Value == "true" + : false; + } + + public static bool HasCategoryAttribute(this XElement xe, string value) + { + var attr = xe.Attribute("category"); + return attr != null && attr.Value == value; + } + } +} diff --git a/src/vk.generator/vk.generator.csproj b/src/vk.generator/vk.generator.csproj new file mode 100644 index 00000000..25660488 --- /dev/null +++ b/src/vk.generator/vk.generator.csproj @@ -0,0 +1,17 @@ + + + netcoreapp2.0 + Exe + vk.generator + Vk.Generator + true + false + + + + PreserveNewest + Designer + + + + \ No newline at end of file diff --git a/src/vk.generator/vk.xml b/src/vk.generator/vk.xml new file mode 100644 index 00000000..13fc2628 --- /dev/null +++ b/src/vk.generator/vk.xml @@ -0,0 +1,7634 @@ + + + +Copyright (c) 2015-2018 The Khronos Group Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +------------------------------------------------------------------------ + +This file, vk.xml, is the Vulkan API Registry. It is a critically important +and normative part of the Vulkan Specification, including a canonical +machine-readable definition of the API, parameter and member validation +language incorporated into the Specification and reference pages, and other +material which is registered by Khronos, such as tags used by extension and +layer authors. The authoritative public version of vk.xml is maintained in +the master branch of the Khronos Vulkan GitHub project. The authoritative +private version is maintained in the 1.0 branch of the member gitlab server. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #include "vk_platform.h" + + WSI extensions + #include "vulkan.h" + #include <X11/Xlib.h> + #include <X11/extensions/Xrandr.h> + #include <android/native_window.h> + #include <mir_toolkit/client_types.h> + #include <wayland-client.h> + #include <windows.h> + #include <xcb/xcb.h> + + + + + + + + + + + + + + + + + + + + + #define VK_MAKE_VERSION(major, minor, patch) \ + (((major) << 22) | ((minor) << 12) | (patch)) + #define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) + #define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff) + #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff) + + // DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. +//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 + // Vulkan 1.0 version number +#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)// Patch version should always be set to 0 + // Version of this file +#define VK_HEADER_VERSION 68 + + +#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + + +#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE) +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; +#else + #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; +#endif +#endif + + + +#define VK_NULL_HANDLE 0 + + + typedef uint32_t VkSampleMask; + typedef uint32_t VkBool32; + typedef uint32_t VkFlags; + typedef uint64_t VkDeviceSize; + + Basic C types, pulled in via vk_platform.h + + + + + + + + + + + Bitmask types + typedef VkFlags VkFramebufferCreateFlags; + typedef VkFlags VkQueryPoolCreateFlags; + typedef VkFlags VkRenderPassCreateFlags; + typedef VkFlags VkSamplerCreateFlags; + typedef VkFlags VkPipelineLayoutCreateFlags; + typedef VkFlags VkPipelineCacheCreateFlags; + typedef VkFlags VkPipelineDepthStencilStateCreateFlags; + typedef VkFlags VkPipelineDynamicStateCreateFlags; + typedef VkFlags VkPipelineColorBlendStateCreateFlags; + typedef VkFlags VkPipelineMultisampleStateCreateFlags; + typedef VkFlags VkPipelineRasterizationStateCreateFlags; + typedef VkFlags VkPipelineViewportStateCreateFlags; + typedef VkFlags VkPipelineTessellationStateCreateFlags; + typedef VkFlags VkPipelineInputAssemblyStateCreateFlags; + typedef VkFlags VkPipelineVertexInputStateCreateFlags; + typedef VkFlags VkPipelineShaderStageCreateFlags; + typedef VkFlags VkDescriptorSetLayoutCreateFlags; + typedef VkFlags VkBufferViewCreateFlags; + typedef VkFlags VkInstanceCreateFlags; + typedef VkFlags VkDeviceCreateFlags; + typedef VkFlags VkDeviceQueueCreateFlags; + typedef VkFlags VkQueueFlags; + typedef VkFlags VkMemoryPropertyFlags; + typedef VkFlags VkMemoryHeapFlags; + typedef VkFlags VkAccessFlags; + typedef VkFlags VkBufferUsageFlags; + typedef VkFlags VkBufferCreateFlags; + typedef VkFlags VkShaderStageFlags; + typedef VkFlags VkImageUsageFlags; + typedef VkFlags VkImageCreateFlags; + typedef VkFlags VkImageViewCreateFlags; + typedef VkFlags VkPipelineCreateFlags; + typedef VkFlags VkColorComponentFlags; + typedef VkFlags VkFenceCreateFlags; + typedef VkFlags VkSemaphoreCreateFlags; + typedef VkFlags VkFormatFeatureFlags; + typedef VkFlags VkQueryControlFlags; + typedef VkFlags VkQueryResultFlags; + typedef VkFlags VkShaderModuleCreateFlags; + typedef VkFlags VkEventCreateFlags; + typedef VkFlags VkCommandPoolCreateFlags; + typedef VkFlags VkCommandPoolResetFlags; + typedef VkFlags VkCommandBufferResetFlags; + typedef VkFlags VkCommandBufferUsageFlags; + typedef VkFlags VkQueryPipelineStatisticFlags; + typedef VkFlags VkMemoryMapFlags; + typedef VkFlags VkImageAspectFlags; + typedef VkFlags VkSparseMemoryBindFlags; + typedef VkFlags VkSparseImageFormatFlags; + typedef VkFlags VkSubpassDescriptionFlags; + typedef VkFlags VkPipelineStageFlags; + typedef VkFlags VkSampleCountFlags; + typedef VkFlags VkAttachmentDescriptionFlags; + typedef VkFlags VkStencilFaceFlags; + typedef VkFlags VkCullModeFlags; + typedef VkFlags VkDescriptorPoolCreateFlags; + typedef VkFlags VkDescriptorPoolResetFlags; + typedef VkFlags VkDependencyFlags; + + typedef VkFlags VkIndirectCommandsLayoutUsageFlagsNVX; + typedef VkFlags VkObjectEntryUsageFlagsNVX; + + typedef VkFlags VkDescriptorUpdateTemplateCreateFlagsKHR; + + WSI extensions + typedef VkFlags VkCompositeAlphaFlagsKHR; + typedef VkFlags VkDisplayPlaneAlphaFlagsKHR; + typedef VkFlags VkSurfaceTransformFlagsKHR; + typedef VkFlags VkSwapchainCreateFlagsKHR; + typedef VkFlags VkDisplayModeCreateFlagsKHR; + typedef VkFlags VkDisplaySurfaceCreateFlagsKHR; + typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; + typedef VkFlags VkMirSurfaceCreateFlagsKHR; + typedef VkFlags VkViSurfaceCreateFlagsNN; + typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; + typedef VkFlags VkWin32SurfaceCreateFlagsKHR; + typedef VkFlags VkXlibSurfaceCreateFlagsKHR; + typedef VkFlags VkXcbSurfaceCreateFlagsKHR; + typedef VkFlags VkIOSSurfaceCreateFlagsMVK; + typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; + typedef VkFlags VkPeerMemoryFeatureFlagsKHX; + typedef VkFlags VkMemoryAllocateFlagsKHX; + typedef VkFlags VkDeviceGroupPresentModeFlagsKHX; + + typedef VkFlags VkDebugReportFlagsEXT; + typedef VkFlags VkCommandPoolTrimFlagsKHR; + typedef VkFlags VkExternalMemoryHandleTypeFlagsNV; + typedef VkFlags VkExternalMemoryFeatureFlagsNV; + typedef VkFlags VkExternalMemoryHandleTypeFlagsKHR; + typedef VkFlags VkExternalMemoryFeatureFlagsKHR; + typedef VkFlags VkExternalSemaphoreHandleTypeFlagsKHR; + typedef VkFlags VkExternalSemaphoreFeatureFlagsKHR; + typedef VkFlags VkSemaphoreImportFlagsKHR; + typedef VkFlags VkExternalFenceHandleTypeFlagsKHR; + typedef VkFlags VkExternalFenceFeatureFlagsKHR; + typedef VkFlags VkFenceImportFlagsKHR; + typedef VkFlags VkSurfaceCounterFlagsEXT; + typedef VkFlags VkPipelineViewportSwizzleStateCreateFlagsNV; + typedef VkFlags VkPipelineDiscardRectangleStateCreateFlagsEXT; + typedef VkFlags VkPipelineCoverageToColorStateCreateFlagsNV; + typedef VkFlags VkPipelineCoverageModulationStateCreateFlagsNV; + typedef VkFlags VkValidationCacheCreateFlagsEXT; + typedef VkFlags VkPipelineRasterizationConservativeStateCreateFlagsEXT; + + Types which can be void pointers or class pointers, selected at compile time + VK_DEFINE_HANDLE(VkInstance) + VK_DEFINE_HANDLE(VkPhysicalDevice) + VK_DEFINE_HANDLE(VkDevice) + VK_DEFINE_HANDLE(VkQueue) + VK_DEFINE_HANDLE(VkCommandBuffer) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkObjectTableNVX) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkIndirectCommandsLayoutNVX) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplateKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversionKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkValidationCacheEXT) + + WSI extensions + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) + + Types generated from corresponding enums tags below + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Extensions + + + + + + + + + + + + + + + + WSI extensions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The PFN_vk*Function types are used by VkAllocationCallbacks below + typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)( + void* pUserData, + size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)( + void* pUserData, + size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)( + void* pUserData, + void* pOriginal, + size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope); + typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)( + void* pUserData, + size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope); + typedef void (VKAPI_PTR *PFN_vkFreeFunction)( + void* pUserData, + void* pMemory); + + The PFN_vkVoidFunction type are used by VkGet*ProcAddr below + typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void); + + The PFN_vkDebugReportCallbackEXT type are used by the DEBUG_REPORT extension + typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)( + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage, + void* pUserData); + + Struct types + + int32_t x + int32_t y + + + int32_t x + int32_t y + int32_t z + + + uint32_t width + uint32_t height + + + uint32_t width + uint32_t height + uint32_t depth + + + float x + float y + float width + float height + float minDepth + float maxDepth + + + VkOffset2D offset + VkExtent2D extent + + + VkRect2D rect + uint32_t baseArrayLayer + uint32_t layerCount + + + VkComponentSwizzle r + VkComponentSwizzle g + VkComponentSwizzle b + VkComponentSwizzle a + + + uint32_t apiVersion + uint32_t driverVersion + uint32_t vendorID + uint32_t deviceID + VkPhysicalDeviceType deviceType + char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE] + uint8_t pipelineCacheUUID[VK_UUID_SIZE] + VkPhysicalDeviceLimits limits + VkPhysicalDeviceSparseProperties sparseProperties + + + char extensionName[VK_MAX_EXTENSION_NAME_SIZE]extension name + uint32_t specVersionversion of the extension specification implemented + + + char layerName[VK_MAX_EXTENSION_NAME_SIZE]layer name + uint32_t specVersionversion of the layer specification implemented + uint32_t implementationVersionbuild or release version of the layer's library + char description[VK_MAX_DESCRIPTION_SIZE]Free-form description of the layer + + + VkStructureType sType + const void* pNext + const char* pApplicationName + uint32_t applicationVersion + const char* pEngineName + uint32_t engineVersion + uint32_t apiVersion + + + void* pUserData + PFN_vkAllocationFunction pfnAllocation + PFN_vkReallocationFunction pfnReallocation + PFN_vkFreeFunction pfnFree + PFN_vkInternalAllocationNotification pfnInternalAllocation + PFN_vkInternalFreeNotification pfnInternalFree + + + VkStructureType sType + const void* pNext + VkDeviceQueueCreateFlags flags + uint32_t queueFamilyIndex + uint32_t queueCount + const float* pQueuePriorities + + + VkStructureType sType + const void* pNext + VkDeviceCreateFlags flags + uint32_t queueCreateInfoCount + const VkDeviceQueueCreateInfo* pQueueCreateInfos + uint32_t enabledLayerCount + const char* const* ppEnabledLayerNamesOrdered list of layer names to be enabled + uint32_t enabledExtensionCount + const char* const* ppEnabledExtensionNames + const VkPhysicalDeviceFeatures* pEnabledFeatures + + + VkStructureType sType + const void* pNext + VkInstanceCreateFlags flags + const VkApplicationInfo* pApplicationInfo + uint32_t enabledLayerCount + const char* const* ppEnabledLayerNamesOrdered list of layer names to be enabled + uint32_t enabledExtensionCount + const char* const* ppEnabledExtensionNamesExtension names to be enabled + + + VkQueueFlags queueFlagsQueue flags + uint32_t queueCount + uint32_t timestampValidBits + VkExtent3D minImageTransferGranularityMinimum alignment requirement for image transfers + + + uint32_t memoryTypeCount + VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES] + uint32_t memoryHeapCount + VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS] + + + VkStructureType sType + const void* pNext + VkDeviceSize allocationSizeSize of memory allocation + uint32_t memoryTypeIndexIndex of the of the memory type to allocate from + + + VkDeviceSize sizeSpecified in bytes + VkDeviceSize alignmentSpecified in bytes + uint32_t memoryTypeBitsBitmask of the allowed memory type indices into memoryTypes[] for this object + + + VkImageAspectFlags aspectMask + VkExtent3D imageGranularity + VkSparseImageFormatFlags flags + + + VkSparseImageFormatProperties formatProperties + uint32_t imageMipTailFirstLod + VkDeviceSize imageMipTailSizeSpecified in bytes, must be a multiple of sparse block size in bytes / alignment + VkDeviceSize imageMipTailOffsetSpecified in bytes, must be a multiple of sparse block size in bytes / alignment + VkDeviceSize imageMipTailStrideSpecified in bytes, must be a multiple of sparse block size in bytes / alignment + + + VkMemoryPropertyFlags propertyFlagsMemory properties of this memory type + uint32_t heapIndexIndex of the memory heap allocations of this memory type are taken from + + + VkDeviceSize sizeAvailable memory in the heap + VkMemoryHeapFlags flagsFlags for the heap + + + VkStructureType sType + const void* pNext + VkDeviceMemory memoryMapped memory object + VkDeviceSize offsetOffset within the memory object where the range starts + VkDeviceSize sizeSize of the range within the memory object + + + VkFormatFeatureFlags linearTilingFeaturesFormat features in case of linear tiling + VkFormatFeatureFlags optimalTilingFeaturesFormat features in case of optimal tiling + VkFormatFeatureFlags bufferFeaturesFormat features supported by buffers + + + VkExtent3D maxExtentmax image dimensions for this resource type + uint32_t maxMipLevelsmax number of mipmap levels for this resource type + uint32_t maxArrayLayersmax array size for this resource type + VkSampleCountFlags sampleCountssupported sample counts for this resource type + VkDeviceSize maxResourceSizemax size (in bytes) of this resource type + + + VkBuffer bufferBuffer used for this descriptor slot when the descriptor is UNIFORM_BUFFER[_DYNAMIC] or STORAGE_BUFFER[_DYNAMIC]. VK_NULL_HANDLE otherwise. + VkDeviceSize offsetBase offset from buffer start in bytes to update in the descriptor set. + VkDeviceSize rangeSize in bytes of the buffer resource for this descriptor update. + + + VkSampler samplerSampler to write to the descriptor in case it is a SAMPLER or COMBINED_IMAGE_SAMPLER descriptor. Ignored otherwise. + VkImageView imageViewImage view to write to the descriptor in case it is a SAMPLED_IMAGE, STORAGE_IMAGE, COMBINED_IMAGE_SAMPLER, or INPUT_ATTACHMENT descriptor. Ignored otherwise. + VkImageLayout imageLayoutLayout the image is expected to be in when accessed using this descriptor (only used if imageView is not VK_NULL_HANDLE). + + + VkStructureType sType + const void* pNext + VkDescriptorSet dstSetDestination descriptor set + uint32_t dstBindingBinding within the destination descriptor set to write + uint32_t dstArrayElementArray element within the destination binding to write + uint32_t descriptorCountNumber of descriptors to write (determines the size of the array pointed by pDescriptors) + VkDescriptorType descriptorTypeDescriptor type to write (determines which members of the array pointed by pDescriptors are going to be used) + const VkDescriptorImageInfo* pImageInfoSampler, image view, and layout for SAMPLER, COMBINED_IMAGE_SAMPLER, {SAMPLED,STORAGE}_IMAGE, and INPUT_ATTACHMENT descriptor types. + const VkDescriptorBufferInfo* pBufferInfoRaw buffer, size, and offset for {UNIFORM,STORAGE}_BUFFER[_DYNAMIC] descriptor types. + const VkBufferView* pTexelBufferViewBuffer view to write to the descriptor for {UNIFORM,STORAGE}_TEXEL_BUFFER descriptor types. + + + VkStructureType sType + const void* pNext + VkDescriptorSet srcSetSource descriptor set + uint32_t srcBindingBinding within the source descriptor set to copy from + uint32_t srcArrayElementArray element within the source binding to copy from + VkDescriptorSet dstSetDestination descriptor set + uint32_t dstBindingBinding within the destination descriptor set to copy to + uint32_t dstArrayElementArray element within the destination binding to copy to + uint32_t descriptorCountNumber of descriptors to write (determines the size of the array pointed by pDescriptors) + + + VkStructureType sType + const void* pNext + VkBufferCreateFlags flagsBuffer creation flags + VkDeviceSize sizeSpecified in bytes + VkBufferUsageFlags usageBuffer usage flags + VkSharingMode sharingMode + uint32_t queueFamilyIndexCount + const uint32_t* pQueueFamilyIndices + + + VkStructureType sType + const void* pNext + VkBufferViewCreateFlagsflags + VkBuffer buffer + VkFormat formatOptionally specifies format of elements + VkDeviceSize offsetSpecified in bytes + VkDeviceSize rangeView size specified in bytes + + + VkImageAspectFlags aspectMask + uint32_t mipLevel + uint32_t arrayLayer + + + VkImageAspectFlags aspectMask + uint32_t mipLevel + uint32_t baseArrayLayer + uint32_t layerCount + + + VkImageAspectFlags aspectMask + uint32_t baseMipLevel + uint32_t levelCount + uint32_t baseArrayLayer + uint32_t layerCount + + + VkStructureType sType + const void* pNext + VkAccessFlags srcAccessMaskMemory accesses from the source of the dependency to synchronize + VkAccessFlags dstAccessMaskMemory accesses from the destination of the dependency to synchronize + + + VkStructureType sType + const void* pNext + VkAccessFlags srcAccessMaskMemory accesses from the source of the dependency to synchronize + VkAccessFlags dstAccessMaskMemory accesses from the destination of the dependency to synchronize + uint32_t srcQueueFamilyIndexQueue family to transition ownership from + uint32_t dstQueueFamilyIndexQueue family to transition ownership to + VkBuffer bufferBuffer to sync + VkDeviceSize offsetOffset within the buffer to sync + VkDeviceSize sizeAmount of bytes to sync + + + VkStructureType sType + const void* pNext + VkAccessFlags srcAccessMaskMemory accesses from the source of the dependency to synchronize + VkAccessFlags dstAccessMaskMemory accesses from the destination of the dependency to synchronize + VkImageLayout oldLayoutCurrent layout of the image + VkImageLayout newLayoutNew layout to transition the image to + uint32_t srcQueueFamilyIndexQueue family to transition ownership from + uint32_t dstQueueFamilyIndexQueue family to transition ownership to + VkImage imageImage to sync + VkImageSubresourceRange subresourceRangeSubresource range to sync + + + VkStructureType sType + const void* pNext + VkImageCreateFlags flagsImage creation flags + VkImageType imageType + VkFormat format + VkExtent3D extent + uint32_t mipLevels + uint32_t arrayLayers + VkSampleCountFlagBits samples + VkImageTiling tiling + VkImageUsageFlags usageImage usage flags + VkSharingMode sharingModeCross-queue-family sharing mode + uint32_t queueFamilyIndexCountNumber of queue families to share across + const uint32_t* pQueueFamilyIndicesArray of queue family indices to share across + VkImageLayout initialLayoutInitial image layout for all subresources + + + VkDeviceSize offsetSpecified in bytes + VkDeviceSize sizeSpecified in bytes + VkDeviceSize rowPitchSpecified in bytes + VkDeviceSize arrayPitchSpecified in bytes + VkDeviceSize depthPitchSpecified in bytes + + + VkStructureType sType + const void* pNext + VkImageViewCreateFlags flags + VkImage image + VkImageViewType viewType + VkFormat format + VkComponentMapping components + VkImageSubresourceRange subresourceRange + + + VkDeviceSize srcOffsetSpecified in bytes + VkDeviceSize dstOffsetSpecified in bytes + VkDeviceSize sizeSpecified in bytes + + + VkDeviceSize resourceOffsetSpecified in bytes + VkDeviceSize sizeSpecified in bytes + VkDeviceMemory memory + VkDeviceSize memoryOffsetSpecified in bytes + VkSparseMemoryBindFlagsflags + + + VkImageSubresource subresource + VkOffset3D offset + VkExtent3D extent + VkDeviceMemory memory + VkDeviceSize memoryOffsetSpecified in bytes + VkSparseMemoryBindFlagsflags + + + VkBuffer buffer + uint32_t bindCount + const VkSparseMemoryBind* pBinds + + + VkImage image + uint32_t bindCount + const VkSparseMemoryBind* pBinds + + + VkImage image + uint32_t bindCount + const VkSparseImageMemoryBind* pBinds + + + VkStructureType sType + const void* pNext + uint32_t waitSemaphoreCount + const VkSemaphore* pWaitSemaphores + uint32_t bufferBindCount + const VkSparseBufferMemoryBindInfo* pBufferBinds + uint32_t imageOpaqueBindCount + const VkSparseImageOpaqueMemoryBindInfo* pImageOpaqueBinds + uint32_t imageBindCount + const VkSparseImageMemoryBindInfo* pImageBinds + uint32_t signalSemaphoreCount + const VkSemaphore* pSignalSemaphores + + + VkImageSubresourceLayers srcSubresource + VkOffset3D srcOffsetSpecified in pixels for both compressed and uncompressed images + VkImageSubresourceLayers dstSubresource + VkOffset3D dstOffsetSpecified in pixels for both compressed and uncompressed images + VkExtent3D extentSpecified in pixels for both compressed and uncompressed images + + + VkImageSubresourceLayers srcSubresource + VkOffset3D srcOffsets[2]Specified in pixels for both compressed and uncompressed images + VkImageSubresourceLayers dstSubresource + VkOffset3D dstOffsets[2]Specified in pixels for both compressed and uncompressed images + + + VkDeviceSize bufferOffsetSpecified in bytes + uint32_t bufferRowLengthSpecified in texels + uint32_t bufferImageHeight + VkImageSubresourceLayers imageSubresource + VkOffset3D imageOffsetSpecified in pixels for both compressed and uncompressed images + VkExtent3D imageExtentSpecified in pixels for both compressed and uncompressed images + + + VkImageSubresourceLayers srcSubresource + VkOffset3D srcOffset + VkImageSubresourceLayers dstSubresource + VkOffset3D dstOffset + VkExtent3D extent + + + VkStructureType sType + const void* pNext + VkShaderModuleCreateFlags flags + size_t codeSizeSpecified in bytes + const uint32_t* pCodeBinary code of size codeSize + + + uint32_t bindingBinding number for this entry + VkDescriptorType descriptorTypeType of the descriptors in this binding + uint32_t descriptorCountNumber of descriptors in this binding + VkShaderStageFlags stageFlagsShader stages this binding is visible to + const VkSampler* pImmutableSamplersImmutable samplers (used if descriptor type is SAMPLER or COMBINED_IMAGE_SAMPLER, is either NULL or contains count number of elements) + + + VkStructureType sType + const void* pNext + VkDescriptorSetLayoutCreateFlags flags + uint32_t bindingCountNumber of bindings in the descriptor set layout + const VkDescriptorSetLayoutBinding* pBindingsArray of descriptor set layout bindings + + + VkDescriptorType type + uint32_t descriptorCount + + + VkStructureType sType + const void* pNext + VkDescriptorPoolCreateFlags flags + uint32_t maxSets + uint32_t poolSizeCount + const VkDescriptorPoolSize* pPoolSizes + + + VkStructureType sType + const void* pNext + VkDescriptorPool descriptorPool + uint32_t descriptorSetCount + const VkDescriptorSetLayout* pSetLayouts + + + uint32_t constantIDThe SpecConstant ID specified in the BIL + uint32_t offsetOffset of the value in the data block + size_t sizeSize in bytes of the SpecConstant + + + uint32_t mapEntryCountNumber of entries in the map + const VkSpecializationMapEntry* pMapEntriesArray of map entries + size_t dataSizeSize in bytes of pData + const void* pDataPointer to SpecConstant data + + + VkStructureType sType + const void* pNext + VkPipelineShaderStageCreateFlags flags + VkShaderStageFlagBits stageShader stage + VkShaderModule moduleModule containing entry point + const char* pNameNull-terminated entry point name + const VkSpecializationInfo* pSpecializationInfo + + + VkStructureType sType + const void* pNext + VkPipelineCreateFlags flagsPipeline creation flags + VkPipelineShaderStageCreateInfo stage + VkPipelineLayout layoutInterface layout of the pipeline + VkPipeline basePipelineHandleIf VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is nonzero, it specifies the handle of the base pipeline this is a derivative of + int32_t basePipelineIndexIf VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is not -1, it specifies an index into pCreateInfos of the base pipeline this is a derivative of + + + uint32_t bindingVertex buffer binding id + uint32_t strideDistance between vertices in bytes (0 = no advancement) + VkVertexInputRate inputRateThe rate at which the vertex data is consumed + + + uint32_t locationlocation of the shader vertex attrib + uint32_t bindingVertex buffer binding id + VkFormat formatformat of source data + uint32_t offsetOffset of first element in bytes from base of vertex + + + VkStructureType sType + const void* pNext + VkPipelineVertexInputStateCreateFlags flags + uint32_t vertexBindingDescriptionCountnumber of bindings + const VkVertexInputBindingDescription* pVertexBindingDescriptions + uint32_t vertexAttributeDescriptionCountnumber of attributes + const VkVertexInputAttributeDescription* pVertexAttributeDescriptions + + + VkStructureType sType + const void* pNext + VkPipelineInputAssemblyStateCreateFlags flags + VkPrimitiveTopology topology + VkBool32 primitiveRestartEnable + + + VkStructureType sType + const void* pNext + VkPipelineTessellationStateCreateFlags flags + uint32_t patchControlPoints + + + VkStructureType sType + const void* pNext + VkPipelineViewportStateCreateFlags flags + uint32_t viewportCount + const VkViewport* pViewports + uint32_t scissorCount + const VkRect2D* pScissors + + + VkStructureType sType + const void* pNext + VkPipelineRasterizationStateCreateFlags flags + VkBool32 depthClampEnable + VkBool32 rasterizerDiscardEnable + VkPolygonMode polygonModeoptional (GL45) + VkCullModeFlags cullMode + VkFrontFace frontFace + VkBool32 depthBiasEnable + float depthBiasConstantFactor + float depthBiasClamp + float depthBiasSlopeFactor + float lineWidth + + + VkStructureType sType + const void* pNext + VkPipelineMultisampleStateCreateFlags flags + VkSampleCountFlagBits rasterizationSamplesNumber of samples used for rasterization + VkBool32 sampleShadingEnableoptional (GL45) + float minSampleShadingoptional (GL45) + const VkSampleMask* pSampleMaskArray of sampleMask words + VkBool32 alphaToCoverageEnable + VkBool32 alphaToOneEnable + + + VkBool32 blendEnable + VkBlendFactor srcColorBlendFactor + VkBlendFactor dstColorBlendFactor + VkBlendOp colorBlendOp + VkBlendFactor srcAlphaBlendFactor + VkBlendFactor dstAlphaBlendFactor + VkBlendOp alphaBlendOp + VkColorComponentFlags colorWriteMask + + + VkStructureType sType + const void* pNext + VkPipelineColorBlendStateCreateFlags flags + VkBool32 logicOpEnable + VkLogicOp logicOp + uint32_t attachmentCount# of pAttachments + const VkPipelineColorBlendAttachmentState* pAttachments + float blendConstants[4] + + + VkStructureType sType + const void* pNext + VkPipelineDynamicStateCreateFlags flags + uint32_t dynamicStateCount + const VkDynamicState* pDynamicStates + + + VkStencilOp failOp + VkStencilOp passOp + VkStencilOp depthFailOp + VkCompareOp compareOp + uint32_t compareMask + uint32_t writeMask + uint32_t reference + + + VkStructureType sType + const void* pNext + VkPipelineDepthStencilStateCreateFlags flags + VkBool32 depthTestEnable + VkBool32 depthWriteEnable + VkCompareOp depthCompareOp + VkBool32 depthBoundsTestEnableoptional (depth_bounds_test) + VkBool32 stencilTestEnable + VkStencilOpState front + VkStencilOpState back + float minDepthBounds + float maxDepthBounds + + + VkStructureType sType + const void* pNext + VkPipelineCreateFlags flagsPipeline creation flags + uint32_t stageCount + const VkPipelineShaderStageCreateInfo* pStagesOne entry for each active shader stage + const VkPipelineVertexInputStateCreateInfo* pVertexInputState + const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState + const VkPipelineTessellationStateCreateInfo* pTessellationState + const VkPipelineViewportStateCreateInfo* pViewportState + const VkPipelineRasterizationStateCreateInfo* pRasterizationState + const VkPipelineMultisampleStateCreateInfo* pMultisampleState + const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState + const VkPipelineColorBlendStateCreateInfo* pColorBlendState + const VkPipelineDynamicStateCreateInfo* pDynamicState + VkPipelineLayout layoutInterface layout of the pipeline + VkRenderPass renderPass + uint32_t subpass + VkPipeline basePipelineHandleIf VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is nonzero, it specifies the handle of the base pipeline this is a derivative of + int32_t basePipelineIndexIf VK_PIPELINE_CREATE_DERIVATIVE_BIT is set and this value is not -1, it specifies an index into pCreateInfos of the base pipeline this is a derivative of + + + VkStructureType sType + const void* pNext + VkPipelineCacheCreateFlags flags + size_t initialDataSizeSize of initial data to populate cache, in bytes + const void* pInitialDataInitial data to populate cache + + + VkShaderStageFlags stageFlagsWhich stages use the range + uint32_t offsetStart of the range, in bytes + uint32_t sizeSize of the range, in bytes + + + VkStructureType sType + const void* pNext + VkPipelineLayoutCreateFlags flags + uint32_t setLayoutCountNumber of descriptor sets interfaced by the pipeline + const VkDescriptorSetLayout* pSetLayoutsArray of setCount number of descriptor set layout objects defining the layout of the + uint32_t pushConstantRangeCountNumber of push-constant ranges used by the pipeline + const VkPushConstantRange* pPushConstantRangesArray of pushConstantRangeCount number of ranges used by various shader stages + + + VkStructureType sType + const void* pNext + VkSamplerCreateFlags flags + VkFilter magFilterFilter mode for magnification + VkFilter minFilterFilter mode for minifiation + VkSamplerMipmapMode mipmapModeMipmap selection mode + VkSamplerAddressMode addressModeU + VkSamplerAddressMode addressModeV + VkSamplerAddressMode addressModeW + float mipLodBias + VkBool32 anisotropyEnable + float maxAnisotropy + VkBool32 compareEnable + VkCompareOp compareOp + float minLod + float maxLod + VkBorderColor borderColor + VkBool32 unnormalizedCoordinates + + + VkStructureType sType + const void* pNext + VkCommandPoolCreateFlags flagsCommand pool creation flags + uint32_t queueFamilyIndex + + + VkStructureType sType + const void* pNext + VkCommandPool commandPool + VkCommandBufferLevel level + uint32_t commandBufferCount + + + VkStructureType sType + const void* pNext + VkRenderPass renderPassRender pass for secondary command buffers + uint32_t subpass + VkFramebuffer framebufferFramebuffer for secondary command buffers + VkBool32 occlusionQueryEnableWhether this secondary command buffer may be executed during an occlusion query + VkQueryControlFlags queryFlagsQuery flags used by this secondary command buffer, if executed during an occlusion query + VkQueryPipelineStatisticFlags pipelineStatisticsPipeline statistics that may be counted for this secondary command buffer + + + VkStructureType sType + const void* pNext + VkCommandBufferUsageFlags flagsCommand buffer usage flags + const VkCommandBufferInheritanceInfo* pInheritanceInfoPointer to inheritance info for secondary command buffers + + + VkStructureType sType + const void* pNext + VkRenderPass renderPass + VkFramebuffer framebuffer + VkRect2D renderArea + uint32_t clearValueCount + const VkClearValue* pClearValues + + + float float32[4] + int32_t int32[4] + uint32_t uint32[4] + + + float depth + uint32_t stencil + + + VkClearColorValue color + VkClearDepthStencilValue depthStencil + + + VkImageAspectFlags aspectMask + uint32_t colorAttachment + VkClearValue clearValue + + + VkAttachmentDescriptionFlags flags + VkFormat format + VkSampleCountFlagBits samples + VkAttachmentLoadOp loadOpLoad operation for color or depth data + VkAttachmentStoreOp storeOpStore operation for color or depth data + VkAttachmentLoadOp stencilLoadOpLoad operation for stencil data + VkAttachmentStoreOp stencilStoreOpStore operation for stencil data + VkImageLayout initialLayout + VkImageLayout finalLayout + + + uint32_t attachment + VkImageLayout layout + + + VkSubpassDescriptionFlags flags + VkPipelineBindPoint pipelineBindPointMust be VK_PIPELINE_BIND_POINT_GRAPHICS for now + uint32_t inputAttachmentCount + const VkAttachmentReference* pInputAttachments + uint32_t colorAttachmentCount + const VkAttachmentReference* pColorAttachments + const VkAttachmentReference* pResolveAttachments + const VkAttachmentReference* pDepthStencilAttachment + uint32_t preserveAttachmentCount + const uint32_t* pPreserveAttachments + + + uint32_t srcSubpass + uint32_t dstSubpass + VkPipelineStageFlags srcStageMask + VkPipelineStageFlags dstStageMask + VkAccessFlags srcAccessMaskMemory accesses from the source of the dependency to synchronize + VkAccessFlags dstAccessMaskMemory accesses from the destination of the dependency to synchronize + VkDependencyFlags dependencyFlags + + + VkStructureType sType + const void* pNext + VkRenderPassCreateFlags flags + uint32_t attachmentCount + const VkAttachmentDescription* pAttachments + uint32_t subpassCount + const VkSubpassDescription* pSubpasses + uint32_t dependencyCount + const VkSubpassDependency* pDependencies + + + VkStructureType sType + const void* pNext + VkEventCreateFlags flagsEvent creation flags + + + VkStructureType sType + const void* pNext + VkFenceCreateFlags flagsFence creation flags + + + VkBool32 robustBufferAccessout of bounds buffer accesses are well defined + VkBool32 fullDrawIndexUint32full 32-bit range of indices for indexed draw calls + VkBool32 imageCubeArrayimage views which are arrays of cube maps + VkBool32 independentBlendblending operations are controlled per-attachment + VkBool32 geometryShadergeometry stage + VkBool32 tessellationShadertessellation control and evaluation stage + VkBool32 sampleRateShadingper-sample shading and interpolation + VkBool32 dualSrcBlendblend operations which take two sources + VkBool32 logicOplogic operations + VkBool32 multiDrawIndirectmulti draw indirect + VkBool32 drawIndirectFirstInstanceindirect draws can use non-zero firstInstance + VkBool32 depthClampdepth clamping + VkBool32 depthBiasClampdepth bias clamping + VkBool32 fillModeNonSolidpoint and wireframe fill modes + VkBool32 depthBoundsdepth bounds test + VkBool32 wideLineslines with width greater than 1 + VkBool32 largePointspoints with size greater than 1 + VkBool32 alphaToOnethe fragment alpha component can be forced to maximum representable alpha value + VkBool32 multiViewportviewport arrays + VkBool32 samplerAnisotropyanisotropic sampler filtering + VkBool32 textureCompressionETC2ETC texture compression formats + VkBool32 textureCompressionASTC_LDRASTC LDR texture compression formats + VkBool32 textureCompressionBCBC1-7 texture compressed formats + VkBool32 occlusionQueryPreciseprecise occlusion queries returning actual sample counts + VkBool32 pipelineStatisticsQuerypipeline statistics query + VkBool32 vertexPipelineStoresAndAtomicsstores and atomic ops on storage buffers and images are supported in vertex, tessellation, and geometry stages + VkBool32 fragmentStoresAndAtomicsstores and atomic ops on storage buffers and images are supported in the fragment stage + VkBool32 shaderTessellationAndGeometryPointSizetessellation and geometry stages can export point size + VkBool32 shaderImageGatherExtendedimage gather with run-time values and independent offsets + VkBool32 shaderStorageImageExtendedFormatsthe extended set of formats can be used for storage images + VkBool32 shaderStorageImageMultisamplemultisample images can be used for storage images + VkBool32 shaderStorageImageReadWithoutFormatread from storage image does not require format qualifier + VkBool32 shaderStorageImageWriteWithoutFormatwrite to storage image does not require format qualifier + VkBool32 shaderUniformBufferArrayDynamicIndexingarrays of uniform buffers can be accessed with dynamically uniform indices + VkBool32 shaderSampledImageArrayDynamicIndexingarrays of sampled images can be accessed with dynamically uniform indices + VkBool32 shaderStorageBufferArrayDynamicIndexingarrays of storage buffers can be accessed with dynamically uniform indices + VkBool32 shaderStorageImageArrayDynamicIndexingarrays of storage images can be accessed with dynamically uniform indices + VkBool32 shaderClipDistanceclip distance in shaders + VkBool32 shaderCullDistancecull distance in shaders + VkBool32 shaderFloat6464-bit floats (doubles) in shaders + VkBool32 shaderInt6464-bit integers in shaders + VkBool32 shaderInt1616-bit integers in shaders + VkBool32 shaderResourceResidencyshader can use texture operations that return resource residency information (requires sparseNonResident support) + VkBool32 shaderResourceMinLodshader can use texture operations that specify minimum resource LOD + VkBool32 sparseBindingSparse resources support: Resource memory can be managed at opaque page level rather than object level + VkBool32 sparseResidencyBufferSparse resources support: GPU can access partially resident buffers + VkBool32 sparseResidencyImage2DSparse resources support: GPU can access partially resident 2D (non-MSAA non-depth/stencil) images + VkBool32 sparseResidencyImage3DSparse resources support: GPU can access partially resident 3D images + VkBool32 sparseResidency2SamplesSparse resources support: GPU can access partially resident MSAA 2D images with 2 samples + VkBool32 sparseResidency4SamplesSparse resources support: GPU can access partially resident MSAA 2D images with 4 samples + VkBool32 sparseResidency8SamplesSparse resources support: GPU can access partially resident MSAA 2D images with 8 samples + VkBool32 sparseResidency16SamplesSparse resources support: GPU can access partially resident MSAA 2D images with 16 samples + VkBool32 sparseResidencyAliasedSparse resources support: GPU can correctly access data aliased into multiple locations (opt-in) + VkBool32 variableMultisampleRatemultisample rate must be the same for all pipelines in a subpass + VkBool32 inheritedQueriesQueries may be inherited from primary to secondary command buffers + + + VkBool32 residencyStandard2DBlockShapeSparse resources support: GPU will access all 2D (single sample) sparse resources using the standard sparse image block shapes (based on pixel format) + VkBool32 residencyStandard2DMultisampleBlockShapeSparse resources support: GPU will access all 2D (multisample) sparse resources using the standard sparse image block shapes (based on pixel format) + VkBool32 residencyStandard3DBlockShapeSparse resources support: GPU will access all 3D sparse resources using the standard sparse image block shapes (based on pixel format) + VkBool32 residencyAlignedMipSizeSparse resources support: Images with mip level dimensions that are NOT a multiple of the sparse image block dimensions will be placed in the mip tail + VkBool32 residencyNonResidentStrictSparse resources support: GPU can consistently access non-resident regions of a resource, all reads return as if data is 0, writes are discarded + + + resource maximum sizes + uint32_t maxImageDimension1Dmax 1D image dimension + uint32_t maxImageDimension2Dmax 2D image dimension + uint32_t maxImageDimension3Dmax 3D image dimension + uint32_t maxImageDimensionCubemax cubemap image dimension + uint32_t maxImageArrayLayersmax layers for image arrays + uint32_t maxTexelBufferElementsmax texel buffer size (fstexels) + uint32_t maxUniformBufferRangemax uniform buffer range (bytes) + uint32_t maxStorageBufferRangemax storage buffer range (bytes) + uint32_t maxPushConstantsSizemax size of the push constants pool (bytes) + memory limits + uint32_t maxMemoryAllocationCountmax number of device memory allocations supported + uint32_t maxSamplerAllocationCountmax number of samplers that can be allocated on a device + VkDeviceSize bufferImageGranularityGranularity (in bytes) at which buffers and images can be bound to adjacent memory for simultaneous usage + VkDeviceSize sparseAddressSpaceSizeTotal address space available for sparse allocations (bytes) + descriptor set limits + uint32_t maxBoundDescriptorSetsmax number of descriptors sets that can be bound to a pipeline + uint32_t maxPerStageDescriptorSamplersmax number of samplers allowed per-stage in a descriptor set + uint32_t maxPerStageDescriptorUniformBuffersmax number of uniform buffers allowed per-stage in a descriptor set + uint32_t maxPerStageDescriptorStorageBuffersmax number of storage buffers allowed per-stage in a descriptor set + uint32_t maxPerStageDescriptorSampledImagesmax number of sampled images allowed per-stage in a descriptor set + uint32_t maxPerStageDescriptorStorageImagesmax number of storage images allowed per-stage in a descriptor set + uint32_t maxPerStageDescriptorInputAttachmentsmax number of input attachments allowed per-stage in a descriptor set + uint32_t maxPerStageResourcesmax number of resources allowed by a single stage + uint32_t maxDescriptorSetSamplersmax number of samplers allowed in all stages in a descriptor set + uint32_t maxDescriptorSetUniformBuffersmax number of uniform buffers allowed in all stages in a descriptor set + uint32_t maxDescriptorSetUniformBuffersDynamicmax number of dynamic uniform buffers allowed in all stages in a descriptor set + uint32_t maxDescriptorSetStorageBuffersmax number of storage buffers allowed in all stages in a descriptor set + uint32_t maxDescriptorSetStorageBuffersDynamicmax number of dynamic storage buffers allowed in all stages in a descriptor set + uint32_t maxDescriptorSetSampledImagesmax number of sampled images allowed in all stages in a descriptor set + uint32_t maxDescriptorSetStorageImagesmax number of storage images allowed in all stages in a descriptor set + uint32_t maxDescriptorSetInputAttachmentsmax number of input attachments allowed in all stages in a descriptor set + vertex stage limits + uint32_t maxVertexInputAttributesmax number of vertex input attribute slots + uint32_t maxVertexInputBindingsmax number of vertex input binding slots + uint32_t maxVertexInputAttributeOffsetmax vertex input attribute offset added to vertex buffer offset + uint32_t maxVertexInputBindingStridemax vertex input binding stride + uint32_t maxVertexOutputComponentsmax number of output components written by vertex shader + tessellation control stage limits + uint32_t maxTessellationGenerationLevelmax level supported by tessellation primitive generator + uint32_t maxTessellationPatchSizemax patch size (vertices) + uint32_t maxTessellationControlPerVertexInputComponentsmax number of input components per-vertex in TCS + uint32_t maxTessellationControlPerVertexOutputComponentsmax number of output components per-vertex in TCS + uint32_t maxTessellationControlPerPatchOutputComponentsmax number of output components per-patch in TCS + uint32_t maxTessellationControlTotalOutputComponentsmax total number of per-vertex and per-patch output components in TCS + tessellation evaluation stage limits + uint32_t maxTessellationEvaluationInputComponentsmax number of input components per vertex in TES + uint32_t maxTessellationEvaluationOutputComponentsmax number of output components per vertex in TES + geometry stage limits + uint32_t maxGeometryShaderInvocationsmax invocation count supported in geometry shader + uint32_t maxGeometryInputComponentsmax number of input components read in geometry stage + uint32_t maxGeometryOutputComponentsmax number of output components written in geometry stage + uint32_t maxGeometryOutputVerticesmax number of vertices that can be emitted in geometry stage + uint32_t maxGeometryTotalOutputComponentsmax total number of components (all vertices) written in geometry stage + fragment stage limits + uint32_t maxFragmentInputComponentsmax number of input compontents read in fragment stage + uint32_t maxFragmentOutputAttachmentsmax number of output attachments written in fragment stage + uint32_t maxFragmentDualSrcAttachmentsmax number of output attachments written when using dual source blending + uint32_t maxFragmentCombinedOutputResourcesmax total number of storage buffers, storage images and output buffers + compute stage limits + uint32_t maxComputeSharedMemorySizemax total storage size of work group local storage (bytes) + uint32_t maxComputeWorkGroupCount[3]max num of compute work groups that may be dispatched by a single command (x,y,z) + uint32_t maxComputeWorkGroupInvocationsmax total compute invocations in a single local work group + uint32_t maxComputeWorkGroupSize[3]max local size of a compute work group (x,y,z) + uint32_t subPixelPrecisionBitsnumber bits of subpixel precision in screen x and y + uint32_t subTexelPrecisionBitsnumber bits of precision for selecting texel weights + uint32_t mipmapPrecisionBitsnumber bits of precision for selecting mipmap weights + uint32_t maxDrawIndexedIndexValuemax index value for indexed draw calls (for 32-bit indices) + uint32_t maxDrawIndirectCountmax draw count for indirect draw calls + float maxSamplerLodBiasmax absolute sampler LOD bias + float maxSamplerAnisotropymax degree of sampler anisotropy + uint32_t maxViewportsmax number of active viewports + uint32_t maxViewportDimensions[2]max viewport dimensions (x,y) + float viewportBoundsRange[2]viewport bounds range (min,max) + uint32_t viewportSubPixelBitsnumber bits of subpixel precision for viewport + size_t minMemoryMapAlignmentmin required alignment of pointers returned by MapMemory (bytes) + VkDeviceSize minTexelBufferOffsetAlignmentmin required alignment for texel buffer offsets (bytes) + VkDeviceSize minUniformBufferOffsetAlignmentmin required alignment for uniform buffer sizes and offsets (bytes) + VkDeviceSize minStorageBufferOffsetAlignmentmin required alignment for storage buffer offsets (bytes) + int32_t minTexelOffsetmin texel offset for OpTextureSampleOffset + uint32_t maxTexelOffsetmax texel offset for OpTextureSampleOffset + int32_t minTexelGatherOffsetmin texel offset for OpTextureGatherOffset + uint32_t maxTexelGatherOffsetmax texel offset for OpTextureGatherOffset + float minInterpolationOffsetfurthest negative offset for interpolateAtOffset + float maxInterpolationOffsetfurthest positive offset for interpolateAtOffset + uint32_t subPixelInterpolationOffsetBitsnumber of subpixel bits for interpolateAtOffset + uint32_t maxFramebufferWidthmax width for a framebuffer + uint32_t maxFramebufferHeightmax height for a framebuffer + uint32_t maxFramebufferLayersmax layer count for a layered framebuffer + VkSampleCountFlags framebufferColorSampleCountssupported color sample counts for a framebuffer + VkSampleCountFlags framebufferDepthSampleCountssupported depth sample counts for a framebuffer + VkSampleCountFlags framebufferStencilSampleCountssupported stencil sample counts for a framebuffer + VkSampleCountFlags framebufferNoAttachmentsSampleCountssupported sample counts for a framebuffer with no attachments + uint32_t maxColorAttachmentsmax number of color attachments per subpass + VkSampleCountFlags sampledImageColorSampleCountssupported color sample counts for a non-integer sampled image + VkSampleCountFlags sampledImageIntegerSampleCountssupported sample counts for an integer image + VkSampleCountFlags sampledImageDepthSampleCountssupported depth sample counts for a sampled image + VkSampleCountFlags sampledImageStencilSampleCountssupported stencil sample counts for a sampled image + VkSampleCountFlags storageImageSampleCountssupported sample counts for a storage image + uint32_t maxSampleMaskWordsmax number of sample mask words + VkBool32 timestampComputeAndGraphicstimestamps on graphics and compute queues + float timestampPeriodnumber of nanoseconds it takes for timestamp query value to increment by 1 + uint32_t maxClipDistancesmax number of clip distances + uint32_t maxCullDistancesmax number of cull distances + uint32_t maxCombinedClipAndCullDistancesmax combined number of user clipping + uint32_t discreteQueuePrioritiesdistinct queue priorities available + float pointSizeRange[2]range (min,max) of supported point sizes + float lineWidthRange[2]range (min,max) of supported line widths + float pointSizeGranularitygranularity of supported point sizes + float lineWidthGranularitygranularity of supported line widths + VkBool32 strictLinesline rasterization follows preferred rules + VkBool32 standardSampleLocationssupports standard sample locations for all supported sample counts + VkDeviceSize optimalBufferCopyOffsetAlignmentoptimal offset of buffer copies + VkDeviceSize optimalBufferCopyRowPitchAlignmentoptimal pitch of buffer copies + VkDeviceSize nonCoherentAtomSizeminimum size and alignment for non-coherent host-mapped device memory access + + + VkStructureType sType + const void* pNext + VkSemaphoreCreateFlags flagsSemaphore creation flags + + + VkStructureType sType + const void* pNext + VkQueryPoolCreateFlags flags + VkQueryType queryType + uint32_t queryCount + VkQueryPipelineStatisticFlags pipelineStatisticsOptional + + + VkStructureType sType + const void* pNext + VkFramebufferCreateFlags flags + VkRenderPass renderPass + uint32_t attachmentCount + const VkImageView* pAttachments + uint32_t width + uint32_t height + uint32_t layers + + + uint32_t vertexCount + uint32_t instanceCount + uint32_t firstVertex + uint32_t firstInstance + + + uint32_t indexCount + uint32_t instanceCount + uint32_t firstIndex + int32_t vertexOffset + uint32_t firstInstance + + + uint32_t x + uint32_t y + uint32_t z + + + VkStructureType sType + const void* pNext + uint32_t waitSemaphoreCount + const VkSemaphore* pWaitSemaphores + const VkPipelineStageFlags* pWaitDstStageMask + uint32_t commandBufferCount + const VkCommandBuffer* pCommandBuffers + uint32_t signalSemaphoreCount + const VkSemaphore* pSignalSemaphores + + WSI extensions + + VkDisplayKHR displayHandle of the display object + const char* displayNameName of the display + VkExtent2D physicalDimensionsIn millimeters? + VkExtent2D physicalResolutionMax resolution for CRT? + VkSurfaceTransformFlagsKHR supportedTransformsone or more bits from VkSurfaceTransformFlagsKHR + VkBool32 planeReorderPossibleVK_TRUE if the overlay plane's z-order can be changed on this display. + VkBool32 persistentContentVK_TRUE if this is a "smart" display that supports self-refresh/internal buffering. + + + VkDisplayKHR currentDisplayDisplay the plane is currently associated with. Will be VK_NULL_HANDLE if the plane is not in use. + uint32_t currentStackIndexCurrent z-order of the plane. + + + VkExtent2D visibleRegionVisible scanout region. + uint32_t refreshRateNumber of times per second the display is updated. + + + VkDisplayModeKHR displayModeHandle of this display mode. + VkDisplayModeParametersKHR parametersThe parameters this mode uses. + + + VkStructureType sType + const void* pNext + VkDisplayModeCreateFlagsKHR flags + VkDisplayModeParametersKHR parametersThe parameters this mode uses. + + + VkDisplayPlaneAlphaFlagsKHR supportedAlphaTypes of alpha blending supported, if any. + VkOffset2D minSrcPositionDoes the plane have any position and extent restrictions? + VkOffset2D maxSrcPosition + VkExtent2D minSrcExtent + VkExtent2D maxSrcExtent + VkOffset2D minDstPosition + VkOffset2D maxDstPosition + VkExtent2D minDstExtent + VkExtent2D maxDstExtent + + + VkStructureType sType + const void* pNext + VkDisplaySurfaceCreateFlagsKHR flags + VkDisplayModeKHR displayModeThe mode to use when displaying this surface + uint32_t planeIndexThe plane on which this surface appears. Must be between 0 and the value returned by vkGetPhysicalDeviceDisplayPlanePropertiesKHR() in pPropertyCount. + uint32_t planeStackIndexThe z-order of the plane. + VkSurfaceTransformFlagBitsKHR transformTransform to apply to the images as part of the scanout operation + float globalAlphaGlobal alpha value. Must be between 0 and 1, inclusive. Ignored if alphaMode is not VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR + VkDisplayPlaneAlphaFlagBitsKHR alphaModeWhat type of alpha blending to use. Must be a bit from vkGetDisplayPlanePropertiesKHR::supportedAlpha. + VkExtent2D imageExtentsize of the images to use with this surface + + + VkStructureType sType + const void* pNext + VkRect2D srcRectRectangle within the presentable image to read pixel data from when presenting to the display. + VkRect2D dstRectRectangle within the current display mode's visible region to display srcRectangle in. + VkBool32 persistentFor smart displays, use buffered mode. If the display properties member "persistentMode" is VK_FALSE, this member must always be VK_FALSE. + + + uint32_t minImageCountSupported minimum number of images for the surface + uint32_t maxImageCountSupported maximum number of images for the surface, 0 for unlimited + VkExtent2D currentExtentCurrent image width and height for the surface, (0, 0) if undefined + VkExtent2D minImageExtentSupported minimum image width and height for the surface + VkExtent2D maxImageExtentSupported maximum image width and height for the surface + uint32_t maxImageArrayLayersSupported maximum number of image layers for the surface + VkSurfaceTransformFlagsKHR supportedTransforms1 or more bits representing the transforms supported + VkSurfaceTransformFlagBitsKHR currentTransformThe surface's current transform relative to the device's natural orientation + VkCompositeAlphaFlagsKHR supportedCompositeAlpha1 or more bits representing the alpha compositing modes supported + VkImageUsageFlags supportedUsageFlagsSupported image usage flags for the surface + + + VkStructureType sType + const void* pNext + VkAndroidSurfaceCreateFlagsKHR flags + ANativeWindow* window + + + VkStructureType sType + const void* pNext + VkMirSurfaceCreateFlagsKHR flags + MirConnection* connection + MirSurface* mirSurface + + + VkStructureType sType + const void* pNext + VkViSurfaceCreateFlagsNN flags + void* window + + + VkStructureType sType + const void* pNext + VkWaylandSurfaceCreateFlagsKHR flags + struct wl_display* display + struct wl_surface* surface + + + VkStructureType sType + const void* pNext + VkWin32SurfaceCreateFlagsKHR flags + HINSTANCE hinstance + HWND hwnd + + + VkStructureType sType + const void* pNext + VkXlibSurfaceCreateFlagsKHR flags + Display* dpy + Window window + + + VkStructureType sType + const void* pNext + VkXcbSurfaceCreateFlagsKHR flags + xcb_connection_t* connection + xcb_window_t window + + + VkFormat formatSupported pair of rendering format + VkColorSpaceKHR colorSpaceand color space for the surface + + + VkStructureType sType + const void* pNext + VkSwapchainCreateFlagsKHR flags + VkSurfaceKHR surfaceThe swapchain's target surface + uint32_t minImageCountMinimum number of presentation images the application needs + VkFormat imageFormatFormat of the presentation images + VkColorSpaceKHR imageColorSpaceColorspace of the presentation images + VkExtent2D imageExtentDimensions of the presentation images + uint32_t imageArrayLayersDetermines the number of views for multiview/stereo presentation + VkImageUsageFlags imageUsageBits indicating how the presentation images will be used + VkSharingMode imageSharingModeSharing mode used for the presentation images + uint32_t queueFamilyIndexCountNumber of queue families having access to the images in case of concurrent sharing mode + const uint32_t* pQueueFamilyIndicesArray of queue family indices having access to the images in case of concurrent sharing mode + VkSurfaceTransformFlagBitsKHR preTransformThe transform, relative to the device's natural orientation, applied to the image content prior to presentation + VkCompositeAlphaFlagBitsKHR compositeAlphaThe alpha blending mode used when compositing this surface with other surfaces in the window system + VkPresentModeKHR presentModeWhich presentation mode to use for presents on this swap chain + VkBool32 clippedSpecifies whether presentable images may be affected by window clip regions + VkSwapchainKHR oldSwapchainExisting swap chain to replace, if any + + + VkStructureType sType + const void* pNext + uint32_t waitSemaphoreCountNumber of semaphores to wait for before presenting + const VkSemaphore* pWaitSemaphoresSemaphores to wait for before presenting + uint32_t swapchainCountNumber of swapchains to present in this call + const VkSwapchainKHR* pSwapchainsSwapchains to present an image from + const uint32_t* pImageIndicesIndices of which presentable images to present + VkResult* pResultsOptional (i.e. if non-NULL) VkResult for each swapchain + + + VkStructureType sType + const void* pNext + VkDebugReportFlagsEXT flagsIndicates which events call this callback + PFN_vkDebugReportCallbackEXT pfnCallbackFunction pointer of a callback function + void* pUserDataUser data provided to callback function + + + VkStructureType sTypeMust be VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT + const void* pNext + uint32_t disabledValidationCheckCountNumber of validation checks to disable + VkValidationCheckEXT* pDisabledValidationChecksValidation checks to disable + + + VkStructureType sType + const void* pNext + VkRasterizationOrderAMD rasterizationOrderRasterization order to use for the pipeline + + + VkStructureType sType + const void* pNext + VkDebugReportObjectTypeEXT objectTypeThe type of the object + uint64_t objectThe handle of the object, cast to uint64_t + const char* pObjectNameName to apply to the object + + + VkStructureType sType + const void* pNext + VkDebugReportObjectTypeEXT objectTypeThe type of the object + uint64_t objectThe handle of the object, cast to uint64_t + uint64_t tagNameThe name of the tag to set on the object + size_t tagSizeThe length in bytes of the tag data + const void* pTagTag data to attach to the object + + + VkStructureType sType + const void* pNext + const char* pMarkerNameName of the debug marker + float color[4]Optional color for debug marker + + + VkStructureType sType + const void* pNext + VkBool32 dedicatedAllocationWhether this image uses a dedicated allocation + + + VkStructureType sType + const void* pNext + VkBool32 dedicatedAllocationWhether this buffer uses a dedicated allocation + + + VkStructureType sType + const void* pNext + VkImage imageImage that this allocation will be bound to + VkBuffer bufferBuffer that this allocation will be bound to + + + VkImageFormatProperties imageFormatProperties + VkExternalMemoryFeatureFlagsNV externalMemoryFeatures + VkExternalMemoryHandleTypeFlagsNV exportFromImportedHandleTypes + VkExternalMemoryHandleTypeFlagsNV compatibleHandleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagsNV handleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagsNV handleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagsNV handleType + HANDLE handle + + + VkStructureType sType + const void* pNext + const SECURITY_ATTRIBUTES* pAttributes + DWORD dwAccess + + + VkStructureType sType + const void* pNext + uint32_t acquireCount + const VkDeviceMemory* pAcquireSyncs + const uint64_t* pAcquireKeys + const uint32_t* pAcquireTimeoutMilliseconds + uint32_t releaseCount + const VkDeviceMemory* pReleaseSyncs + const uint64_t* pReleaseKeys + + + VkStructureType sType + const void* pNext + VkBool32 computeBindingPointSupport + + + VkStructureType sType + const void* pNext + uint32_t maxIndirectCommandsLayoutTokenCount + uint32_t maxObjectEntryCounts + uint32_t minSequenceCountBufferOffsetAlignment + uint32_t minSequenceIndexBufferOffsetAlignment + uint32_t minCommandsTokenBufferOffsetAlignment + + + VkIndirectCommandsTokenTypeNVX tokenType + VkBuffer bufferbuffer containing tableEntries and additional data for indirectCommands + VkDeviceSize offsetoffset from the base address of the buffer + + + VkIndirectCommandsTokenTypeNVX tokenType + uint32_t bindingUnitBinding unit for vertex attribute / descriptor set, offset for pushconstants + uint32_t dynamicCountNumber of variable dynamic values for descriptor set / push constants + uint32_t divisorRate the which the array is advanced per element (must be power of 2, minimum 1) + + + VkStructureType sType + const void* pNext + VkPipelineBindPoint pipelineBindPoint + VkIndirectCommandsLayoutUsageFlagsNVX flags + uint32_t tokenCount + const VkIndirectCommandsLayoutTokenNVX* pTokens + + + VkStructureType sType + const void* pNext + VkObjectTableNVX objectTable + VkIndirectCommandsLayoutNVX indirectCommandsLayout + uint32_t indirectCommandsTokenCount + const VkIndirectCommandsTokenNVX* pIndirectCommandsTokens + uint32_t maxSequencesCount + VkCommandBuffer targetCommandBuffer + VkBuffer sequencesCountBuffer + VkDeviceSize sequencesCountOffset + VkBuffer sequencesIndexBuffer + VkDeviceSize sequencesIndexOffset + + + VkStructureType sType + const void* pNext + VkObjectTableNVX objectTable + VkIndirectCommandsLayoutNVX indirectCommandsLayout + uint32_t maxSequencesCount + + + VkStructureType sType + const void* pNext + uint32_t objectCount + const VkObjectEntryTypeNVX* pObjectEntryTypes + const uint32_t* pObjectEntryCounts + const VkObjectEntryUsageFlagsNVX* pObjectEntryUsageFlags + + uint32_t maxUniformBuffersPerDescriptor + uint32_t maxStorageBuffersPerDescriptor + uint32_t maxStorageImagesPerDescriptor + uint32_t maxSampledImagesPerDescriptor + uint32_t maxPipelineLayouts + + + VkObjectEntryTypeNVX type + VkObjectEntryUsageFlagsNVX flags + + + VkObjectEntryTypeNVX type + VkObjectEntryUsageFlagsNVX flags + VkPipeline pipeline + + + VkObjectEntryTypeNVX type + VkObjectEntryUsageFlagsNVX flags + VkPipelineLayout pipelineLayout + VkDescriptorSet descriptorSet + + + VkObjectEntryTypeNVX type + VkObjectEntryUsageFlagsNVX flags + VkBuffer buffer + + + VkObjectEntryTypeNVX type + VkObjectEntryUsageFlagsNVX flags + VkBuffer buffer + VkIndexType indexType + + + VkObjectEntryTypeNVX type + VkObjectEntryUsageFlagsNVX flags + VkPipelineLayout pipelineLayout + VkShaderStageFlags stageFlags + + + VkStructureType sType + void* pNext + VkPhysicalDeviceFeatures features + + + VkStructureType sType + void* pNext + VkPhysicalDeviceProperties properties + + + VkStructureType sType + void* pNext + VkFormatProperties formatProperties + + + VkStructureType sType + void* pNext + VkImageFormatProperties imageFormatProperties + + + VkStructureType sType + const void* pNext + VkFormat format + VkImageType type + VkImageTiling tiling + VkImageUsageFlags usage + VkImageCreateFlags flags + + + VkStructureType sType + void* pNext + VkQueueFamilyProperties queueFamilyProperties + + + VkStructureType sType + void* pNext + VkPhysicalDeviceMemoryProperties memoryProperties + + + VkStructureType sType + void* pNext + VkSparseImageFormatProperties properties + + + VkStructureType sType + const void* pNext + VkFormat format + VkImageType type + VkSampleCountFlagBits samples + VkImageUsageFlags usage + VkImageTiling tiling + + + VkStructureType sType + void* pNext + uint32_t maxPushDescriptors + + + VkStructureType sType + const void* pNext + uint32_t swapchainCountCopy of VkPresentInfoKHR::swapchainCount + const VkPresentRegionKHR* pRegionsThe regions that have changed + + + uint32_t rectangleCountNumber of rectangles in pRectangles + const VkRectLayerKHR* pRectanglesArray of rectangles that have changed in a swapchain's image(s) + + + VkOffset2D offsetupper-left corner of a rectangle that has not changed, in pixels of a presentation images + VkExtent2D extentDimensions of a rectangle that has not changed, in pixels of a presentation images + uint32_t layerLayer of a swapchain's image(s), for stereoscopic-3D images + + + VkStructureType sType + void* pNext + VkBool32 variablePointersStorageBuffer + VkBool32 variablePointers + + + VkExternalMemoryFeatureFlagsKHR externalMemoryFeatures + VkExternalMemoryHandleTypeFlagsKHR exportFromImportedHandleTypes + VkExternalMemoryHandleTypeFlagsKHR compatibleHandleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + void* pNext + VkExternalMemoryPropertiesKHR externalMemoryProperties + + + VkStructureType sType + const void* pNext + VkBufferCreateFlags flags + VkBufferUsageFlags usage + VkExternalMemoryHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + void* pNext + VkExternalMemoryPropertiesKHR externalMemoryProperties + + + VkStructureType sType + void* pNext + uint8_t deviceUUID[VK_UUID_SIZE] + uint8_t driverUUID[VK_UUID_SIZE] + uint8_t deviceLUID[VK_LUID_SIZE_KHR] + uint32_t deviceNodeMask + VkBool32 deviceLUIDValid + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagsKHR handleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagsKHR handleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagsKHR handleTypes + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagBitsKHR handleType + HANDLE handle + LPCWSTR name + + + VkStructureType sType + const void* pNext + const SECURITY_ATTRIBUTES* pAttributes + DWORD dwAccess + LPCWSTR name + + + VkStructureType sType + void* pNext + uint32_t memoryTypeBits + + + VkStructureType sType + const void* pNext + VkDeviceMemory memory + VkExternalMemoryHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagBitsKHR handleType + int fd + + + VkStructureType sType + void* pNext + uint32_t memoryTypeBits + + + VkStructureType sType + const void* pNext + VkDeviceMemory memory + VkExternalMemoryHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + const void* pNext + uint32_t acquireCount + const VkDeviceMemory* pAcquireSyncs + const uint64_t* pAcquireKeys + const uint32_t* pAcquireTimeouts + uint32_t releaseCount + const VkDeviceMemory* pReleaseSyncs + const uint64_t* pReleaseKeys + + + VkStructureType sType + const void* pNext + VkExternalSemaphoreHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + void* pNext + VkExternalSemaphoreHandleTypeFlagsKHR exportFromImportedHandleTypes + VkExternalSemaphoreHandleTypeFlagsKHR compatibleHandleTypes + VkExternalSemaphoreFeatureFlagsKHR externalSemaphoreFeatures + + + VkStructureType sType + const void* pNext + VkExternalSemaphoreHandleTypeFlagsKHR handleTypes + + + VkStructureType sType + const void* pNext + VkSemaphore semaphore + VkSemaphoreImportFlagsKHR flags + VkExternalSemaphoreHandleTypeFlagBitsKHR handleType + HANDLE handle + LPCWSTR name + + + VkStructureType sType + const void* pNext + const SECURITY_ATTRIBUTES* pAttributes + DWORD dwAccess + LPCWSTR name + + + VkStructureType sType + const void* pNext + uint32_t waitSemaphoreValuesCount + const uint64_t* pWaitSemaphoreValues + uint32_t signalSemaphoreValuesCount + const uint64_t* pSignalSemaphoreValues + + + VkStructureType sType + const void* pNext + VkSemaphore semaphore + VkExternalSemaphoreHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + const void* pNext + VkSemaphore semaphore + VkSemaphoreImportFlagsKHR flags + VkExternalSemaphoreHandleTypeFlagBitsKHR handleType + int fd + + + VkStructureType sType + const void* pNext + VkSemaphore semaphore + VkExternalSemaphoreHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + const void* pNext + VkExternalFenceHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + void* pNext + VkExternalFenceHandleTypeFlagsKHR exportFromImportedHandleTypes + VkExternalFenceHandleTypeFlagsKHR compatibleHandleTypes + VkExternalFenceFeatureFlagsKHR externalFenceFeatures + + + VkStructureType sType + const void* pNext + VkExternalFenceHandleTypeFlagsKHR handleTypes + + + VkStructureType sType + const void* pNext + VkFence fence + VkFenceImportFlagsKHR flags + VkExternalFenceHandleTypeFlagBitsKHR handleType + HANDLE handle + LPCWSTR name + + + VkStructureType sType + const void* pNext + const SECURITY_ATTRIBUTES* pAttributes + DWORD dwAccess + LPCWSTR name + + + VkStructureType sType + const void* pNext + VkFence fence + VkExternalFenceHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + const void* pNext + VkFence fence + VkFenceImportFlagsKHR flags + VkExternalFenceHandleTypeFlagBitsKHR handleType + int fd + + + VkStructureType sType + const void* pNext + VkFence fence + VkExternalFenceHandleTypeFlagBitsKHR handleType + + + VkStructureType sType + void* pNext + VkBool32 multiviewMultiple views in a renderpass + VkBool32 multiviewGeometryShaderMultiple views in a renderpass w/ geometry shader + VkBool32 multiviewTessellationShaderMultiple views in a renderpass w/ tessellation shader + + + VkStructureType sType + void* pNext + uint32_t maxMultiviewViewCountmax number of views in a subpass + uint32_t maxMultiviewInstanceIndexmax instance index for a draw in a multiview subpass + + + VkStructureType sType + const void* pNext + uint32_t subpassCount + const uint32_t* pViewMasks + uint32_t dependencyCount + const int32_t* pViewOffsets + uint32_t correlationMaskCount + const uint32_t* pCorrelationMasks + + + VkStructureType sType + void* pNext + uint32_t minImageCountSupported minimum number of images for the surface + uint32_t maxImageCountSupported maximum number of images for the surface, 0 for unlimited + VkExtent2D currentExtentCurrent image width and height for the surface, (0, 0) if undefined + VkExtent2D minImageExtentSupported minimum image width and height for the surface + VkExtent2D maxImageExtentSupported maximum image width and height for the surface + uint32_t maxImageArrayLayersSupported maximum number of image layers for the surface + VkSurfaceTransformFlagsKHR supportedTransforms1 or more bits representing the transforms supported + VkSurfaceTransformFlagBitsKHR currentTransformThe surface's current transform relative to the device's natural orientation + VkCompositeAlphaFlagsKHR supportedCompositeAlpha1 or more bits representing the alpha compositing modes supported + VkImageUsageFlags supportedUsageFlagsSupported image usage flags for the surface + VkSurfaceCounterFlagsEXT supportedSurfaceCounters + + + VkStructureType sType + const void* pNext + VkDisplayPowerStateEXT powerState + + + VkStructureType sType + const void* pNext + VkDeviceEventTypeEXT deviceEvent + + + VkStructureType sType + const void* pNext + VkDisplayEventTypeEXT displayEvent + + + VkStructureType sType + const void* pNext + VkSurfaceCounterFlagsEXT surfaceCounters + + + VkStructureType sType + void* pNext + uint32_t physicalDeviceCount + VkPhysicalDevice physicalDevices[VK_MAX_DEVICE_GROUP_SIZE_KHX] + VkBool32 subsetAllocation + + + VkStructureType sType + const void* pNext + VkMemoryAllocateFlagsKHX flags + uint32_t deviceMask + + + VkStructureType sType + const void* pNext + VkBuffer buffer + VkDeviceMemory memory + VkDeviceSize memoryOffset + + + VkStructureType sType + const void* pNext + uint32_t deviceIndexCount + const uint32_t* pDeviceIndices + + + VkStructureType sType + const void* pNext + VkImage image + VkDeviceMemory memory + VkDeviceSize memoryOffset + + + VkStructureType sType + const void* pNext + uint32_t deviceIndexCount + const uint32_t* pDeviceIndices + uint32_t SFRRectCount + const VkRect2D* pSFRRects + + + VkStructureType sType + const void* pNext + uint32_t deviceMask + uint32_t deviceRenderAreaCount + const VkRect2D* pDeviceRenderAreas + + + VkStructureType sType + const void* pNext + uint32_t deviceMask + + + VkStructureType sType + const void* pNext + uint32_t waitSemaphoreCount + const uint32_t* pWaitSemaphoreDeviceIndices + uint32_t commandBufferCount + const uint32_t* pCommandBufferDeviceMasks + uint32_t signalSemaphoreCount + const uint32_t* pSignalSemaphoreDeviceIndices + + + VkStructureType sType + const void* pNext + uint32_t resourceDeviceIndex + uint32_t memoryDeviceIndex + + + VkStructureType sType + const void* pNext + uint32_t presentMask[VK_MAX_DEVICE_GROUP_SIZE_KHX] + VkDeviceGroupPresentModeFlagsKHX modes + + + VkStructureType sType + const void* pNext + VkSwapchainKHR swapchain + + + VkStructureType sType + const void* pNext + VkSwapchainKHR swapchain + uint32_t imageIndex + + + VkStructureType sType + const void* pNext + VkSwapchainKHR swapchain + uint64_t timeout + VkSemaphore semaphore + VkFence fence + uint32_t deviceMask + + + VkStructureType sType + const void* pNext + uint32_t swapchainCount + const uint32_t* pDeviceMasks + VkDeviceGroupPresentModeFlagBitsKHX mode + + + VkStructureType sType + const void* pNext + uint32_t physicalDeviceCount + const VkPhysicalDevice* pPhysicalDevices + + + VkStructureType sType + const void* pNext + VkDeviceGroupPresentModeFlagsKHX modes + + + uint32_t dstBindingBinding within the destination descriptor set to write + uint32_t dstArrayElementArray element within the destination binding to write + uint32_t descriptorCountNumber of descriptors to write + VkDescriptorType descriptorTypeDescriptor type to write + size_t offsetOffset into pData where the descriptors to update are stored + size_t strideStride between two descriptors in pData when writing more than one descriptor + + + VkStructureType sType + void* pNext + VkDescriptorUpdateTemplateCreateFlagsKHR flags + uint32_t descriptorUpdateEntryCountNumber of descriptor update entries to use for the update template + const VkDescriptorUpdateTemplateEntryKHR* pDescriptorUpdateEntriesDescriptor update entries for the template + VkDescriptorUpdateTemplateTypeKHR templateType + VkDescriptorSetLayout descriptorSetLayout + VkPipelineBindPoint pipelineBindPoint + VkPipelineLayoutpipelineLayoutIf used for push descriptors, this is the only allowed layout + uint32_t set + + + float x + float y + + + Display primary in chromaticity coordinates + VkStructureType sType + const void* pNext + From SMPTE 2086 + VkXYColorEXT displayPrimaryRedDisplay primary's Red + VkXYColorEXT displayPrimaryGreenDisplay primary's Green + VkXYColorEXT displayPrimaryBlueDisplay primary's Blue + VkXYColorEXT whitePointDisplay primary's Blue + float maxLuminanceDisplay maximum luminance + float minLuminanceDisplay minimum luminance + From CTA 861.3 + float maxContentLightLevelContent maximum luminance + float maxFrameAverageLightLevel + + + uint64_t refreshDurationNumber of nanoseconds from the start of one refresh cycle to the next + + + uint32_t presentIDApplication-provided identifier, previously given to vkQueuePresentKHR + uint64_t desiredPresentTimeEarliest time an image should have been presented, previously given to vkQueuePresentKHR + uint64_t actualPresentTimeTime the image was actually displayed + uint64_t earliestPresentTimeEarliest time the image could have been displayed + uint64_t presentMarginHow early vkQueuePresentKHR was processed vs. how soon it needed to be and make earliestPresentTime + + + VkStructureType sType + const void* pNext + uint32_t swapchainCountCopy of VkPresentInfoKHR::swapchainCount + const VkPresentTimeGOOGLE* pTimesThe earliest times to present images + + + uint32_t presentIDApplication-provided identifier + uint64_t desiredPresentTimeEarliest time an image should be presented + + + VkStructureType sType + const void* pNext + VkIOSSurfaceCreateFlagsMVK flags + const void* pView + + + VkStructureType sType + const void* pNext + VkMacOSSurfaceCreateFlagsMVK flags + const void* pView + + + float xcoeff + float ycoeff + + + VkStructureType sType + const void* pNext + VkBool32 viewportWScalingEnable + uint32_t viewportCount + const VkViewportWScalingNV* pViewportWScalings + + + VkViewportCoordinateSwizzleNV x + VkViewportCoordinateSwizzleNV y + VkViewportCoordinateSwizzleNV z + VkViewportCoordinateSwizzleNV w + + + VkStructureType sType + const void* pNext + VkPipelineViewportSwizzleStateCreateFlagsNV flags + uint32_t viewportCount + const VkViewportSwizzleNV* pViewportSwizzles + + + VkStructureType sType + void* pNext + uint32_t maxDiscardRectanglesmax number of active discard rectangles + + + VkStructureType sType + const void* pNext + VkPipelineDiscardRectangleStateCreateFlagsEXT flags + VkDiscardRectangleModeEXT discardRectangleMode + uint32_t discardRectangleCount + const VkRect2D* pDiscardRectangles + + + VkStructureType sType + void* pNext + VkBool32 perViewPositionAllComponents + + + uint32_t subpass + uint32_t inputAttachmentIndex + VkImageAspectFlags aspectMask + + + VkStructureType sType + const void* pNext + uint32_t aspectReferenceCount + const VkInputAttachmentAspectReferenceKHR* pAspectReferences + + + VkStructureType sType + const void* pNext + VkSurfaceKHR surface + + + VkStructureType sType + void* pNext + VkSurfaceCapabilitiesKHR surfaceCapabilities + + + VkStructureType sType + void* pNext + VkSurfaceFormatKHR surfaceFormat + + + VkStructureType sType + void* pNext + VkImageUsageFlags sharedPresentSupportedUsageFlagsSupported image usage flags if swapchain created using a shared present mode + + + VkStructureType sType + void* pNext + VkBool32 storageBuffer16BitAccess16-bit integer/floating-point variables supported in BufferBlock + VkBool32 uniformAndStorageBuffer16BitAccess16-bit integer/floating-point variables supported in BufferBlock and Block + VkBool32 storagePushConstant1616-bit integer/floating-point variables supported in PushConstant + VkBool32 storageInputOutput1616-bit integer/floating-point variables supported in shader inputs and outputs + + + VkStructureType sType + const void* pNext + VkBuffer buffer + + + VkStructureType sType + const void* pNext + VkImage image + + + VkStructureType sType + const void* pNext + VkImage image + + + VkStructureType sType + void* pNext + VkMemoryRequirements memoryRequirements + + + VkStructureType sType + void* pNext + VkSparseImageMemoryRequirements memoryRequirements + + + VkStructureType sType + void* pNext + VkPointClippingBehaviorKHR pointClippingBehavior + + + VkStructureType sType + void* pNext + VkBool32 prefersDedicatedAllocation + VkBool32 requiresDedicatedAllocation + + + VkStructureType sType + const void* pNext + VkImage imageImage that this allocation will be bound to + VkBuffer bufferBuffer that this allocation will be bound to + + + VkStructureType sType + const void* pNext + VkImageUsageFlags usage + + + VkStructureType sType + const void* pNext + VkTessellationDomainOriginKHR domainOrigin + + + VkStructureType sType + const void* pNext + VkSamplerYcbcrConversionKHR conversion + + + VkStructureType sType + const void* pNext + VkFormat format + VkSamplerYcbcrModelConversionKHR ycbcrModel + VkSamplerYcbcrRangeKHR ycbcrRange + VkComponentMapping components + VkChromaLocationKHR xChromaOffset + VkChromaLocationKHR yChromaOffset + VkFilter chromaFilter + VkBool32 forceExplicitReconstruction + + + VkStructureType sType + const void* pNext + VkImageAspectFlagBits planeAspect + + + VkStructureType sType + const void* pNext + VkImageAspectFlagBits planeAspect + + + VkStructureType sType + void* pNext + VkBool32 samplerYcbcrConversionSampler color conversion supported + + + VkStructureType sType + void* pNext + uint32_t combinedImageSamplerDescriptorCount + + + VkStructureType sType + void* pNext + VkBool32 supportsTextureGatherLODBiasAMD + + + VkStructureType sType + const void* pNext + VkPipelineCoverageToColorStateCreateFlagsNV flags + VkBool32 coverageToColorEnable + uint32_t coverageToColorLocation + + + VkStructureType sType + void* pNext + VkBool32 filterMinmaxSingleComponentFormats + VkBool32 filterMinmaxImageComponentMapping + + + float x + float y + + + VkStructureType sType + const void* pNext + VkSampleCountFlagBits sampleLocationsPerPixel + VkExtent2D sampleLocationGridSize + uint32_t sampleLocationsCount + const VkSampleLocationEXT* pSampleLocations + + + uint32_t attachmentIndex + VkSampleLocationsInfoEXT sampleLocationsInfo + + + uint32_t subpassIndex + VkSampleLocationsInfoEXT sampleLocationsInfo + + + VkStructureType sType + const void* pNext + uint32_t attachmentInitialSampleLocationsCount + const VkAttachmentSampleLocationsEXT* pAttachmentInitialSampleLocations + uint32_t postSubpassSampleLocationsCount + const VkSubpassSampleLocationsEXT* pPostSubpassSampleLocations + + + VkStructureType sType + const void* pNext + VkBool32 sampleLocationsEnable + VkSampleLocationsInfoEXT sampleLocationsInfo + + + VkStructureType sType + void* pNext + VkSampleCountFlags sampleLocationSampleCounts + VkExtent2D maxSampleLocationGridSize + float sampleLocationCoordinateRange[2] + uint32_t sampleLocationSubPixelBits + VkBool32 variableSampleLocations + + + VkStructureType sType + void* pNext + VkExtent2D maxSampleLocationGridSize + + + VkStructureType sType + const void* pNext + VkSamplerReductionModeEXT reductionMode + + + VkStructureType sType + void* pNext + VkBool32 advancedBlendCoherentOperations + + + VkStructureType sType + void* pNext + uint32_t advancedBlendMaxColorAttachments + VkBool32 advancedBlendIndependentBlend + VkBool32 advancedBlendNonPremultipliedSrcColor + VkBool32 advancedBlendNonPremultipliedDstColor + VkBool32 advancedBlendCorrelatedOverlap + VkBool32 advancedBlendAllOperations + + + VkStructureType sType + const void* pNext + VkBool32 srcPremultiplied + VkBool32 dstPremultiplied + VkBlendOverlapEXT blendOverlap + + + VkStructureType sType + const void* pNext + VkPipelineCoverageModulationStateCreateFlagsNV flags + VkCoverageModulationModeNV coverageModulationMode + VkBool32 coverageModulationTableEnable + uint32_t coverageModulationTableCount + const float* pCoverageModulationTable + + + VkStructureType sType + const void* pNext + uint32_t viewFormatCount + const VkFormat* pViewFormats + + + VkStructureType sType + const void* pNext + VkValidationCacheCreateFlagsEXT flags + size_t initialDataSize + const void* pInitialData + + + VkStructureType sType + const void* pNext + VkValidationCacheEXT validationCache + + + VkStructureType sType + const void* pNext + const void* handle + int stride + int format + int usage + + + uint32_t numUsedVgprs + uint32_t numUsedSgprs + uint32_t ldsSizePerLocalWorkGroup + size_t ldsUsageSizeInBytes + size_t scratchMemUsageInBytes + + + VkShaderStageFlags shaderStageMask + VkShaderResourceUsageAMD resourceUsage + uint32_t numPhysicalVgprs + uint32_t numPhysicalSgprs + uint32_t numAvailableVgprs + uint32_t numAvailableSgprs + uint32_t computeWorkGroupSize[3] + + + VkStructureType sType + const void* pNext + VkQueueGlobalPriorityEXT globalPriority + + + VkStructureType sType + const void* pNext + VkExternalMemoryHandleTypeFlagBitsKHR handleType + void* pHostPointer + + + VkStructureType sType + void* pNext + uint32_t memoryTypeBits + + + VkStructureType sType + void* pNext + VkDeviceSize minImportedHostPointerAlignment + + + VkStructureType sType + void* pNextPointer to next structure + float primitiveOverestimationSizeThe size in pixels the primitive is enlarged at each edge during conservative rasterization + float maxExtraPrimitiveOverestimationSizeThe maximum additional overestimation the client can specify in the pipeline state + float extraPrimitiveOverestimationSizeGranularityThe granularity of extra overestimation sizes the implementations supports between 0 and maxExtraOverestimationSize + VkBool32 primitiveUnderestimationtrue if the implementation supports conservative rasterization underestimation mode + VkBool32 conservativePointAndLineRasterizationtrue if conservative rasterization also applies to points and lines + VkBool32 degenerateTrianglesRasterizedtrue if degenerate triangles (those with zero area after snap) are rasterized + VkBool32 degenerateLinesRasterizedtrue if degenerate lines (those with zero length after snap) are rasterized + VkBool32 fullyCoveredFragmentShaderInputVariabletrue if the implementation supports the FullyCoveredEXT SPIR-V builtin fragment shader input + variable + VkBool32 conservativeRasterizationPostDepthCoveragetrue if the implementation supports both conservative rasterization and post depth coverage sample coverage mask + + + VkStructureType sType + const void* pNext + VkPipelineRasterizationConservativeStateCreateFlagsEXT flags + VkConservativeRasterizationModeEXT conservativeRasterizationMode + float extraPrimitiveOverestimationSize + + + + Vulkan enumerant (token) definitions + + + + + + + + + + + + + + + + + + + + + + + + + Unlike OpenGL, most tokens in Vulkan are actual typed enumerants in + their own numeric namespaces. The "name" attribute is the C enum + type name, and is pulled in from a type tag definition above + (slightly clunky, but retains the type / enum distinction). "type" + attributes of "enum" or "bitmask" indicate that these values should + be generated inside an appropriate definition. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + value="4" reserved for VK_KHR_sampler_mirror_clamp_to_edge + enum VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; do not + alias! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Return codes (positive values) + + + + + + + Error codes (negative values) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Flags + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WSI Extensions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Placeholder for validation enums to be defined for VK_EXT_Validation_flags extension + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VkResult vkCreateInstance + const VkInstanceCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkInstance* pInstance + + + void vkDestroyInstance + VkInstance instance + const VkAllocationCallbacks* pAllocator + + + VkResult vkEnumeratePhysicalDevices + VkInstance instance + uint32_t* pPhysicalDeviceCount + VkPhysicalDevice* pPhysicalDevices + + + PFN_vkVoidFunction vkGetDeviceProcAddr + VkDevice device + const char* pName + + + PFN_vkVoidFunction vkGetInstanceProcAddr + VkInstance instance + const char* pName + + + void vkGetPhysicalDeviceProperties + VkPhysicalDevice physicalDevice + VkPhysicalDeviceProperties* pProperties + + + void vkGetPhysicalDeviceQueueFamilyProperties + VkPhysicalDevice physicalDevice + uint32_t* pQueueFamilyPropertyCount + VkQueueFamilyProperties* pQueueFamilyProperties + + + void vkGetPhysicalDeviceMemoryProperties + VkPhysicalDevice physicalDevice + VkPhysicalDeviceMemoryProperties* pMemoryProperties + + + void vkGetPhysicalDeviceFeatures + VkPhysicalDevice physicalDevice + VkPhysicalDeviceFeatures* pFeatures + + + void vkGetPhysicalDeviceFormatProperties + VkPhysicalDevice physicalDevice + VkFormat format + VkFormatProperties* pFormatProperties + + + VkResult vkGetPhysicalDeviceImageFormatProperties + VkPhysicalDevice physicalDevice + VkFormat format + VkImageType type + VkImageTiling tiling + VkImageUsageFlags usage + VkImageCreateFlags flags + VkImageFormatProperties* pImageFormatProperties + + + VkResult vkCreateDevice + VkPhysicalDevice physicalDevice + const VkDeviceCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkDevice* pDevice + + + void vkDestroyDevice + VkDevice device + const VkAllocationCallbacks* pAllocator + + + VkResult vkEnumerateInstanceLayerProperties + uint32_t* pPropertyCount + VkLayerProperties* pProperties + + + VkResult vkEnumerateInstanceExtensionProperties + const char* pLayerName + uint32_t* pPropertyCount + VkExtensionProperties* pProperties + + + VkResult vkEnumerateDeviceLayerProperties + VkPhysicalDevice physicalDevice + uint32_t* pPropertyCount + VkLayerProperties* pProperties + + + VkResult vkEnumerateDeviceExtensionProperties + VkPhysicalDevice physicalDevice + const char* pLayerName + uint32_t* pPropertyCount + VkExtensionProperties* pProperties + + + void vkGetDeviceQueue + VkDevice device + uint32_t queueFamilyIndex + uint32_t queueIndex + VkQueue* pQueue + + + VkResult vkQueueSubmit + VkQueue queue + uint32_t submitCount + const VkSubmitInfo* pSubmits + VkFence fence + + + VkResult vkQueueWaitIdle + VkQueue queue + + + VkResult vkDeviceWaitIdle + VkDevice device + + all sname:VkQueue objects created from pname:device + + + + VkResult vkAllocateMemory + VkDevice device + const VkMemoryAllocateInfo* pAllocateInfo + const VkAllocationCallbacks* pAllocator + VkDeviceMemory* pMemory + + + void vkFreeMemory + VkDevice device + VkDeviceMemory memory + const VkAllocationCallbacks* pAllocator + + + VkResult vkMapMemory + VkDevice device + VkDeviceMemory memory + VkDeviceSize offset + VkDeviceSize size + VkMemoryMapFlags flags + void** ppData + + + void vkUnmapMemory + VkDevice device + VkDeviceMemory memory + + + VkResult vkFlushMappedMemoryRanges + VkDevice device + uint32_t memoryRangeCount + const VkMappedMemoryRange* pMemoryRanges + + + VkResult vkInvalidateMappedMemoryRanges + VkDevice device + uint32_t memoryRangeCount + const VkMappedMemoryRange* pMemoryRanges + + + void vkGetDeviceMemoryCommitment + VkDevice device + VkDeviceMemory memory + VkDeviceSize* pCommittedMemoryInBytes + + + void vkGetBufferMemoryRequirements + VkDevice device + VkBuffer buffer + VkMemoryRequirements* pMemoryRequirements + + + VkResult vkBindBufferMemory + VkDevice device + VkBuffer buffer + VkDeviceMemory memory + VkDeviceSize memoryOffset + + + void vkGetImageMemoryRequirements + VkDevice device + VkImage image + VkMemoryRequirements* pMemoryRequirements + + + VkResult vkBindImageMemory + VkDevice device + VkImage image + VkDeviceMemory memory + VkDeviceSize memoryOffset + + + void vkGetImageSparseMemoryRequirements + VkDevice device + VkImage image + uint32_t* pSparseMemoryRequirementCount + VkSparseImageMemoryRequirements* pSparseMemoryRequirements + + + void vkGetPhysicalDeviceSparseImageFormatProperties + VkPhysicalDevice physicalDevice + VkFormat format + VkImageType type + VkSampleCountFlagBits samples + VkImageUsageFlags usage + VkImageTiling tiling + uint32_t* pPropertyCount + VkSparseImageFormatProperties* pProperties + + + VkResult vkQueueBindSparse + VkQueue queue + uint32_t bindInfoCount + const VkBindSparseInfo* pBindInfo + VkFence fence + + + VkResult vkCreateFence + VkDevice device + const VkFenceCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkFence* pFence + + + void vkDestroyFence + VkDevice device + VkFence fence + const VkAllocationCallbacks* pAllocator + + + VkResult vkResetFences + VkDevice device + uint32_t fenceCount + const VkFence* pFences + + + VkResult vkGetFenceStatus + VkDevice device + VkFence fence + + + VkResult vkWaitForFences + VkDevice device + uint32_t fenceCount + const VkFence* pFences + VkBool32 waitAll + uint64_t timeout + + + VkResult vkCreateSemaphore + VkDevice device + const VkSemaphoreCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSemaphore* pSemaphore + + + void vkDestroySemaphore + VkDevice device + VkSemaphore semaphore + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateEvent + VkDevice device + const VkEventCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkEvent* pEvent + + + void vkDestroyEvent + VkDevice device + VkEvent event + const VkAllocationCallbacks* pAllocator + + + VkResult vkGetEventStatus + VkDevice device + VkEvent event + + + VkResult vkSetEvent + VkDevice device + VkEvent event + + + VkResult vkResetEvent + VkDevice device + VkEvent event + + + VkResult vkCreateQueryPool + VkDevice device + const VkQueryPoolCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkQueryPool* pQueryPool + + + void vkDestroyQueryPool + VkDevice device + VkQueryPool queryPool + const VkAllocationCallbacks* pAllocator + + + VkResult vkGetQueryPoolResults + VkDevice device + VkQueryPool queryPool + uint32_t firstQuery + uint32_t queryCount + size_t dataSize + void* pData + VkDeviceSize stride + VkQueryResultFlags flags + + + VkResult vkCreateBuffer + VkDevice device + const VkBufferCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkBuffer* pBuffer + + + void vkDestroyBuffer + VkDevice device + VkBuffer buffer + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateBufferView + VkDevice device + const VkBufferViewCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkBufferView* pView + + + void vkDestroyBufferView + VkDevice device + VkBufferView bufferView + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateImage + VkDevice device + const VkImageCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkImage* pImage + + + void vkDestroyImage + VkDevice device + VkImage image + const VkAllocationCallbacks* pAllocator + + + void vkGetImageSubresourceLayout + VkDevice device + VkImage image + const VkImageSubresource* pSubresource + VkSubresourceLayout* pLayout + + + VkResult vkCreateImageView + VkDevice device + const VkImageViewCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkImageView* pView + + + void vkDestroyImageView + VkDevice device + VkImageView imageView + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateShaderModule + VkDevice device + const VkShaderModuleCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkShaderModule* pShaderModule + + + void vkDestroyShaderModule + VkDevice device + VkShaderModule shaderModule + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreatePipelineCache + VkDevice device + const VkPipelineCacheCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkPipelineCache* pPipelineCache + + + void vkDestroyPipelineCache + VkDevice device + VkPipelineCache pipelineCache + const VkAllocationCallbacks* pAllocator + + + VkResult vkGetPipelineCacheData + VkDevice device + VkPipelineCache pipelineCache + size_t* pDataSize + void* pData + + + VkResult vkMergePipelineCaches + VkDevice device + VkPipelineCache dstCache + uint32_t srcCacheCount + const VkPipelineCache* pSrcCaches + + + VkResult vkCreateGraphicsPipelines + VkDevice device + VkPipelineCache pipelineCache + uint32_t createInfoCount + const VkGraphicsPipelineCreateInfo* pCreateInfos + const VkAllocationCallbacks* pAllocator + VkPipeline* pPipelines + + + VkResult vkCreateComputePipelines + VkDevice device + VkPipelineCache pipelineCache + uint32_t createInfoCount + const VkComputePipelineCreateInfo* pCreateInfos + const VkAllocationCallbacks* pAllocator + VkPipeline* pPipelines + + + void vkDestroyPipeline + VkDevice device + VkPipeline pipeline + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreatePipelineLayout + VkDevice device + const VkPipelineLayoutCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkPipelineLayout* pPipelineLayout + + + void vkDestroyPipelineLayout + VkDevice device + VkPipelineLayout pipelineLayout + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateSampler + VkDevice device + const VkSamplerCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSampler* pSampler + + + void vkDestroySampler + VkDevice device + VkSampler sampler + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateDescriptorSetLayout + VkDevice device + const VkDescriptorSetLayoutCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkDescriptorSetLayout* pSetLayout + + + void vkDestroyDescriptorSetLayout + VkDevice device + VkDescriptorSetLayout descriptorSetLayout + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateDescriptorPool + VkDevice device + const VkDescriptorPoolCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkDescriptorPool* pDescriptorPool + + + void vkDestroyDescriptorPool + VkDevice device + VkDescriptorPool descriptorPool + const VkAllocationCallbacks* pAllocator + + + VkResult vkResetDescriptorPool + VkDevice device + VkDescriptorPool descriptorPool + VkDescriptorPoolResetFlags flags + + any sname:VkDescriptorSet objects allocated from pname:descriptorPool + + + + VkResult vkAllocateDescriptorSets + VkDevice device + const VkDescriptorSetAllocateInfo* pAllocateInfo + VkDescriptorSet* pDescriptorSets + + + VkResult vkFreeDescriptorSets + VkDevice device + VkDescriptorPool descriptorPool + uint32_t descriptorSetCount + const VkDescriptorSet* pDescriptorSets + + + void vkUpdateDescriptorSets + VkDevice device + uint32_t descriptorWriteCount + const VkWriteDescriptorSet* pDescriptorWrites + uint32_t descriptorCopyCount + const VkCopyDescriptorSet* pDescriptorCopies + + + VkResult vkCreateFramebuffer + VkDevice device + const VkFramebufferCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkFramebuffer* pFramebuffer + + + void vkDestroyFramebuffer + VkDevice device + VkFramebuffer framebuffer + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateRenderPass + VkDevice device + const VkRenderPassCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkRenderPass* pRenderPass + + + void vkDestroyRenderPass + VkDevice device + VkRenderPass renderPass + const VkAllocationCallbacks* pAllocator + + + void vkGetRenderAreaGranularity + VkDevice device + VkRenderPass renderPass + VkExtent2D* pGranularity + + + VkResult vkCreateCommandPool + VkDevice device + const VkCommandPoolCreateInfo* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkCommandPool* pCommandPool + + + void vkDestroyCommandPool + VkDevice device + VkCommandPool commandPool + const VkAllocationCallbacks* pAllocator + + + VkResult vkResetCommandPool + VkDevice device + VkCommandPool commandPool + VkCommandPoolResetFlags flags + + + VkResult vkAllocateCommandBuffers + VkDevice device + const VkCommandBufferAllocateInfo* pAllocateInfo + VkCommandBuffer* pCommandBuffers + + + void vkFreeCommandBuffers + VkDevice device + VkCommandPool commandPool + uint32_t commandBufferCount + const VkCommandBuffer* pCommandBuffers + + + VkResult vkBeginCommandBuffer + VkCommandBuffer commandBuffer + const VkCommandBufferBeginInfo* pBeginInfo + + the sname:VkCommandPool that pname:commandBuffer was allocated from + + + + VkResult vkEndCommandBuffer + VkCommandBuffer commandBuffer + + the sname:VkCommandPool that pname:commandBuffer was allocated from + + + + VkResult vkResetCommandBuffer + VkCommandBuffer commandBuffer + VkCommandBufferResetFlags flags + + + void vkCmdBindPipeline + VkCommandBuffer commandBuffer + VkPipelineBindPoint pipelineBindPoint + VkPipeline pipeline + + + void vkCmdSetViewport + VkCommandBuffer commandBuffer + uint32_t firstViewport + uint32_t viewportCount + const VkViewport* pViewports + + + void vkCmdSetScissor + VkCommandBuffer commandBuffer + uint32_t firstScissor + uint32_t scissorCount + const VkRect2D* pScissors + + + void vkCmdSetLineWidth + VkCommandBuffer commandBuffer + float lineWidth + + + void vkCmdSetDepthBias + VkCommandBuffer commandBuffer + float depthBiasConstantFactor + float depthBiasClamp + float depthBiasSlopeFactor + + + void vkCmdSetBlendConstants + VkCommandBuffer commandBuffer + const float blendConstants[4] + + + void vkCmdSetDepthBounds + VkCommandBuffer commandBuffer + float minDepthBounds + float maxDepthBounds + + + void vkCmdSetStencilCompareMask + VkCommandBuffer commandBuffer + VkStencilFaceFlags faceMask + uint32_t compareMask + + + void vkCmdSetStencilWriteMask + VkCommandBuffer commandBuffer + VkStencilFaceFlags faceMask + uint32_t writeMask + + + void vkCmdSetStencilReference + VkCommandBuffer commandBuffer + VkStencilFaceFlags faceMask + uint32_t reference + + + void vkCmdBindDescriptorSets + VkCommandBuffer commandBuffer + VkPipelineBindPoint pipelineBindPoint + VkPipelineLayout layout + uint32_t firstSet + uint32_t descriptorSetCount + const VkDescriptorSet* pDescriptorSets + uint32_t dynamicOffsetCount + const uint32_t* pDynamicOffsets + + + void vkCmdBindIndexBuffer + VkCommandBuffer commandBuffer + VkBuffer buffer + VkDeviceSize offset + VkIndexType indexType + + + void vkCmdBindVertexBuffers + VkCommandBuffer commandBuffer + uint32_t firstBinding + uint32_t bindingCount + const VkBuffer* pBuffers + const VkDeviceSize* pOffsets + + + void vkCmdDraw + VkCommandBuffer commandBuffer + uint32_t vertexCount + uint32_t instanceCount + uint32_t firstVertex + uint32_t firstInstance + + + void vkCmdDrawIndexed + VkCommandBuffer commandBuffer + uint32_t indexCount + uint32_t instanceCount + uint32_t firstIndex + int32_t vertexOffset + uint32_t firstInstance + + + void vkCmdDrawIndirect + VkCommandBuffer commandBuffer + VkBuffer buffer + VkDeviceSize offset + uint32_t drawCount + uint32_t stride + + + void vkCmdDrawIndexedIndirect + VkCommandBuffer commandBuffer + VkBuffer buffer + VkDeviceSize offset + uint32_t drawCount + uint32_t stride + + + void vkCmdDispatch + VkCommandBuffer commandBuffer + uint32_t groupCountX + uint32_t groupCountY + uint32_t groupCountZ + + + void vkCmdDispatchIndirect + VkCommandBuffer commandBuffer + VkBuffer buffer + VkDeviceSize offset + + + void vkCmdCopyBuffer + VkCommandBuffer commandBuffer + VkBuffer srcBuffer + VkBuffer dstBuffer + uint32_t regionCount + const VkBufferCopy* pRegions + + + void vkCmdCopyImage + VkCommandBuffer commandBuffer + VkImage srcImage + VkImageLayout srcImageLayout + VkImage dstImage + VkImageLayout dstImageLayout + uint32_t regionCount + const VkImageCopy* pRegions + + + void vkCmdBlitImage + VkCommandBuffer commandBuffer + VkImage srcImage + VkImageLayout srcImageLayout + VkImage dstImage + VkImageLayout dstImageLayout + uint32_t regionCount + const VkImageBlit* pRegions + VkFilter filter + + + void vkCmdCopyBufferToImage + VkCommandBuffer commandBuffer + VkBuffer srcBuffer + VkImage dstImage + VkImageLayout dstImageLayout + uint32_t regionCount + const VkBufferImageCopy* pRegions + + + void vkCmdCopyImageToBuffer + VkCommandBuffer commandBuffer + VkImage srcImage + VkImageLayout srcImageLayout + VkBuffer dstBuffer + uint32_t regionCount + const VkBufferImageCopy* pRegions + + + void vkCmdUpdateBuffer + VkCommandBuffer commandBuffer + VkBuffer dstBuffer + VkDeviceSize dstOffset + VkDeviceSize dataSize + const void* pData + + + void vkCmdFillBuffer + VkCommandBuffer commandBuffer + VkBuffer dstBuffer + VkDeviceSize dstOffset + VkDeviceSize size + uint32_t data + + + void vkCmdClearColorImage + VkCommandBuffer commandBuffer + VkImage image + VkImageLayout imageLayout + const VkClearColorValue* pColor + uint32_t rangeCount + const VkImageSubresourceRange* pRanges + + + void vkCmdClearDepthStencilImage + VkCommandBuffer commandBuffer + VkImage image + VkImageLayout imageLayout + const VkClearDepthStencilValue* pDepthStencil + uint32_t rangeCount + const VkImageSubresourceRange* pRanges + + + void vkCmdClearAttachments + VkCommandBuffer commandBuffer + uint32_t attachmentCount + const VkClearAttachment* pAttachments + uint32_t rectCount + const VkClearRect* pRects + + + void vkCmdResolveImage + VkCommandBuffer commandBuffer + VkImage srcImage + VkImageLayout srcImageLayout + VkImage dstImage + VkImageLayout dstImageLayout + uint32_t regionCount + const VkImageResolve* pRegions + + + void vkCmdSetEvent + VkCommandBuffer commandBuffer + VkEvent event + VkPipelineStageFlags stageMask + + + void vkCmdResetEvent + VkCommandBuffer commandBuffer + VkEvent event + VkPipelineStageFlags stageMask + + + void vkCmdWaitEvents + VkCommandBuffer commandBuffer + uint32_t eventCount + const VkEvent* pEvents + VkPipelineStageFlags srcStageMask + VkPipelineStageFlags dstStageMask + uint32_t memoryBarrierCount + const VkMemoryBarrier* pMemoryBarriers + uint32_t bufferMemoryBarrierCount + const VkBufferMemoryBarrier* pBufferMemoryBarriers + uint32_t imageMemoryBarrierCount + const VkImageMemoryBarrier* pImageMemoryBarriers + + + void vkCmdPipelineBarrier + VkCommandBuffer commandBuffer + VkPipelineStageFlags srcStageMask + VkPipelineStageFlags dstStageMask + VkDependencyFlags dependencyFlags + uint32_t memoryBarrierCount + const VkMemoryBarrier* pMemoryBarriers + uint32_t bufferMemoryBarrierCount + const VkBufferMemoryBarrier* pBufferMemoryBarriers + uint32_t imageMemoryBarrierCount + const VkImageMemoryBarrier* pImageMemoryBarriers + + + void vkCmdBeginQuery + VkCommandBuffer commandBuffer + VkQueryPool queryPool + uint32_t query + VkQueryControlFlags flags + + + void vkCmdEndQuery + VkCommandBuffer commandBuffer + VkQueryPool queryPool + uint32_t query + + + void vkCmdResetQueryPool + VkCommandBuffer commandBuffer + VkQueryPool queryPool + uint32_t firstQuery + uint32_t queryCount + + + void vkCmdWriteTimestamp + VkCommandBuffer commandBuffer + VkPipelineStageFlagBits pipelineStage + VkQueryPool queryPool + uint32_t query + + + void vkCmdCopyQueryPoolResults + VkCommandBuffer commandBuffer + VkQueryPool queryPool + uint32_t firstQuery + uint32_t queryCount + VkBuffer dstBuffer + VkDeviceSize dstOffset + VkDeviceSize stride + VkQueryResultFlags flags + + + void vkCmdPushConstants + VkCommandBuffer commandBuffer + VkPipelineLayout layout + VkShaderStageFlags stageFlags + uint32_t offset + uint32_t size + const void* pValues + + + void vkCmdBeginRenderPass + VkCommandBuffer commandBuffer + const VkRenderPassBeginInfo* pRenderPassBegin + VkSubpassContents contents + + + void vkCmdNextSubpass + VkCommandBuffer commandBuffer + VkSubpassContents contents + + + void vkCmdEndRenderPass + VkCommandBuffer commandBuffer + + + void vkCmdExecuteCommands + VkCommandBuffer commandBuffer + uint32_t commandBufferCount + const VkCommandBuffer* pCommandBuffers + + + VkResult vkCreateAndroidSurfaceKHR + VkInstance instance + const VkAndroidSurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkResult vkGetPhysicalDeviceDisplayPropertiesKHR + VkPhysicalDevice physicalDevice + uint32_t* pPropertyCount + VkDisplayPropertiesKHR* pProperties + + + VkResult vkGetPhysicalDeviceDisplayPlanePropertiesKHR + VkPhysicalDevice physicalDevice + uint32_t* pPropertyCount + VkDisplayPlanePropertiesKHR* pProperties + + + VkResult vkGetDisplayPlaneSupportedDisplaysKHR + VkPhysicalDevice physicalDevice + uint32_t planeIndex + uint32_t* pDisplayCount + VkDisplayKHR* pDisplays + + + VkResult vkGetDisplayModePropertiesKHR + VkPhysicalDevice physicalDevice + VkDisplayKHR display + uint32_t* pPropertyCount + VkDisplayModePropertiesKHR* pProperties + + + VkResult vkCreateDisplayModeKHR + VkPhysicalDevice physicalDevice + VkDisplayKHR display + const VkDisplayModeCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkDisplayModeKHR* pMode + + + VkResult vkGetDisplayPlaneCapabilitiesKHR + VkPhysicalDevice physicalDevice + VkDisplayModeKHR mode + uint32_t planeIndex + VkDisplayPlaneCapabilitiesKHR* pCapabilities + + + VkResult vkCreateDisplayPlaneSurfaceKHR + VkInstance instance + const VkDisplaySurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkResult vkCreateSharedSwapchainsKHR + VkDevice device + uint32_t swapchainCount + const VkSwapchainCreateInfoKHR* pCreateInfos + const VkAllocationCallbacks* pAllocator + VkSwapchainKHR* pSwapchains + + + VkResult vkCreateMirSurfaceKHR + VkInstance instance + const VkMirSurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkBool32 vkGetPhysicalDeviceMirPresentationSupportKHR + VkPhysicalDevice physicalDevice + uint32_t queueFamilyIndex + MirConnection* connection + + + void vkDestroySurfaceKHR + VkInstance instance + VkSurfaceKHR surface + const VkAllocationCallbacks* pAllocator + + + VkResult vkGetPhysicalDeviceSurfaceSupportKHR + VkPhysicalDevice physicalDevice + uint32_t queueFamilyIndex + VkSurfaceKHR surface + VkBool32* pSupported + + + VkResult vkGetPhysicalDeviceSurfaceCapabilitiesKHR + VkPhysicalDevice physicalDevice + VkSurfaceKHR surface + VkSurfaceCapabilitiesKHR* pSurfaceCapabilities + + + VkResult vkGetPhysicalDeviceSurfaceFormatsKHR + VkPhysicalDevice physicalDevice + VkSurfaceKHR surface + uint32_t* pSurfaceFormatCount + VkSurfaceFormatKHR* pSurfaceFormats + + + VkResult vkGetPhysicalDeviceSurfacePresentModesKHR + VkPhysicalDevice physicalDevice + VkSurfaceKHR surface + uint32_t* pPresentModeCount + VkPresentModeKHR* pPresentModes + + + VkResult vkCreateSwapchainKHR + VkDevice device + const VkSwapchainCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSwapchainKHR* pSwapchain + + + void vkDestroySwapchainKHR + VkDevice device + VkSwapchainKHR swapchain + const VkAllocationCallbacks* pAllocator + + + VkResult vkGetSwapchainImagesKHR + VkDevice device + VkSwapchainKHR swapchain + uint32_t* pSwapchainImageCount + VkImage* pSwapchainImages + + + VkResult vkAcquireNextImageKHR + VkDevice device + VkSwapchainKHR swapchain + uint64_t timeout + VkSemaphore semaphore + VkFence fence + uint32_t* pImageIndex + + + VkResult vkQueuePresentKHR + VkQueue queue + const VkPresentInfoKHR* pPresentInfo + + + VkResult vkCreateViSurfaceNN + VkInstance instance + const VkViSurfaceCreateInfoNN* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkResult vkCreateWaylandSurfaceKHR + VkInstance instance + const VkWaylandSurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkBool32 vkGetPhysicalDeviceWaylandPresentationSupportKHR + VkPhysicalDevice physicalDevice + uint32_t queueFamilyIndex + struct wl_display* display + + + VkResult vkCreateWin32SurfaceKHR + VkInstance instance + const VkWin32SurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkBool32 vkGetPhysicalDeviceWin32PresentationSupportKHR + VkPhysicalDevice physicalDevice + uint32_t queueFamilyIndex + + + VkResult vkCreateXlibSurfaceKHR + VkInstance instance + const VkXlibSurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkBool32 vkGetPhysicalDeviceXlibPresentationSupportKHR + VkPhysicalDevice physicalDevice + uint32_t queueFamilyIndex + Display* dpy + VisualID visualID + + + VkResult vkCreateXcbSurfaceKHR + VkInstance instance + const VkXcbSurfaceCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkBool32 vkGetPhysicalDeviceXcbPresentationSupportKHR + VkPhysicalDevice physicalDevice + uint32_t queueFamilyIndex + xcb_connection_t* connection + xcb_visualid_t visual_id + + + VkResult vkCreateDebugReportCallbackEXT + VkInstance instance + const VkDebugReportCallbackCreateInfoEXT* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkDebugReportCallbackEXT* pCallback + + + void vkDestroyDebugReportCallbackEXT + VkInstance instance + VkDebugReportCallbackEXT callback + const VkAllocationCallbacks* pAllocator + + + void vkDebugReportMessageEXT + VkInstance instance + VkDebugReportFlagsEXT flags + VkDebugReportObjectTypeEXT objectType + uint64_t object + size_t location + int32_t messageCode + const char* pLayerPrefix + const char* pMessage + + + VkResult vkDebugMarkerSetObjectNameEXT + VkDevice device + const VkDebugMarkerObjectNameInfoEXT* pNameInfo + + + VkResult vkDebugMarkerSetObjectTagEXT + VkDevice device + const VkDebugMarkerObjectTagInfoEXT* pTagInfo + + + void vkCmdDebugMarkerBeginEXT + VkCommandBuffer commandBuffer + const VkDebugMarkerMarkerInfoEXT* pMarkerInfo + + + void vkCmdDebugMarkerEndEXT + VkCommandBuffer commandBuffer + + + void vkCmdDebugMarkerInsertEXT + VkCommandBuffer commandBuffer + const VkDebugMarkerMarkerInfoEXT* pMarkerInfo + + + VkResult vkGetPhysicalDeviceExternalImageFormatPropertiesNV + VkPhysicalDevice physicalDevice + VkFormat format + VkImageType type + VkImageTiling tiling + VkImageUsageFlags usage + VkImageCreateFlags flags + VkExternalMemoryHandleTypeFlagsNV externalHandleType + VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties + + + VkResult vkGetMemoryWin32HandleNV + VkDevice device + VkDeviceMemory memory + VkExternalMemoryHandleTypeFlagsNV handleType + HANDLE* pHandle + + + void vkCmdDrawIndirectCountAMD + VkCommandBuffer commandBuffer + VkBuffer buffer + VkDeviceSize offset + VkBuffer countBuffer + VkDeviceSize countBufferOffset + uint32_t maxDrawCount + uint32_t stride + + + void vkCmdDrawIndexedIndirectCountAMD + VkCommandBuffer commandBuffer + VkBuffer buffer + VkDeviceSize offset + VkBuffer countBuffer + VkDeviceSize countBufferOffset + uint32_t maxDrawCount + uint32_t stride + + + void vkCmdProcessCommandsNVX + VkCommandBuffer commandBuffer + const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo + + + void vkCmdReserveSpaceForCommandsNVX + VkCommandBuffer commandBuffer + const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo + + + VkResult vkCreateIndirectCommandsLayoutNVX + VkDevice device + const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout + + + void vkDestroyIndirectCommandsLayoutNVX + VkDevice device + VkIndirectCommandsLayoutNVX indirectCommandsLayout + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateObjectTableNVX + VkDevice device + const VkObjectTableCreateInfoNVX* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkObjectTableNVX* pObjectTable + + + void vkDestroyObjectTableNVX + VkDevice device + VkObjectTableNVX objectTable + const VkAllocationCallbacks* pAllocator + + + VkResult vkRegisterObjectsNVX + VkDevice device + VkObjectTableNVX objectTable + uint32_t objectCount + const VkObjectTableEntryNVX* const* ppObjectTableEntries + const uint32_t* pObjectIndices + + + VkResult vkUnregisterObjectsNVX + VkDevice device + VkObjectTableNVX objectTable + uint32_t objectCount + const VkObjectEntryTypeNVX* pObjectEntryTypes + const uint32_t* pObjectIndices + + + void vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX + VkPhysicalDevice physicalDevice + VkDeviceGeneratedCommandsFeaturesNVX* pFeatures + VkDeviceGeneratedCommandsLimitsNVX* pLimits + + + void vkGetPhysicalDeviceFeatures2KHR + VkPhysicalDevice physicalDevice + VkPhysicalDeviceFeatures2KHR* pFeatures + + + void vkGetPhysicalDeviceProperties2KHR + VkPhysicalDevice physicalDevice + VkPhysicalDeviceProperties2KHR* pProperties + + + void vkGetPhysicalDeviceFormatProperties2KHR + VkPhysicalDevice physicalDevice + VkFormat format + VkFormatProperties2KHR* pFormatProperties + + + VkResult vkGetPhysicalDeviceImageFormatProperties2KHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo + VkImageFormatProperties2KHR* pImageFormatProperties + + + void vkGetPhysicalDeviceQueueFamilyProperties2KHR + VkPhysicalDevice physicalDevice + uint32_t* pQueueFamilyPropertyCount + VkQueueFamilyProperties2KHR* pQueueFamilyProperties + + + void vkGetPhysicalDeviceMemoryProperties2KHR + VkPhysicalDevice physicalDevice + VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties + + + void vkGetPhysicalDeviceSparseImageFormatProperties2KHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo + uint32_t* pPropertyCount + VkSparseImageFormatProperties2KHR* pProperties + + + void vkCmdPushDescriptorSetKHR + VkCommandBuffer commandBuffer + VkPipelineBindPoint pipelineBindPoint + VkPipelineLayout layout + uint32_t set + uint32_t descriptorWriteCount + const VkWriteDescriptorSet* pDescriptorWrites + + + void vkTrimCommandPoolKHR + VkDevice device + VkCommandPool commandPool + VkCommandPoolTrimFlagsKHR flags + + + void vkGetPhysicalDeviceExternalBufferPropertiesKHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo + VkExternalBufferPropertiesKHR* pExternalBufferProperties + + + VkResult vkGetMemoryWin32HandleKHR + VkDevice device + const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo + HANDLE* pHandle + + + VkResult vkGetMemoryWin32HandlePropertiesKHR + VkDevice device + VkExternalMemoryHandleTypeFlagBitsKHR handleType + HANDLE handle + VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties + + + VkResult vkGetMemoryFdKHR + VkDevice device + const VkMemoryGetFdInfoKHR* pGetFdInfo + int* pFd + + + VkResult vkGetMemoryFdPropertiesKHR + VkDevice device + VkExternalMemoryHandleTypeFlagBitsKHR handleType + int fd + VkMemoryFdPropertiesKHR* pMemoryFdProperties + + + void vkGetPhysicalDeviceExternalSemaphorePropertiesKHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceExternalSemaphoreInfoKHR* pExternalSemaphoreInfo + VkExternalSemaphorePropertiesKHR* pExternalSemaphoreProperties + + + VkResult vkGetSemaphoreWin32HandleKHR + VkDevice device + const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo + HANDLE* pHandle + + + VkResult vkImportSemaphoreWin32HandleKHR + VkDevice device + const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo + + + VkResult vkGetSemaphoreFdKHR + VkDevice device + const VkSemaphoreGetFdInfoKHR* pGetFdInfo + int* pFd + + + VkResult vkImportSemaphoreFdKHR + VkDevice device + const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo + + + void vkGetPhysicalDeviceExternalFencePropertiesKHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceExternalFenceInfoKHR* pExternalFenceInfo + VkExternalFencePropertiesKHR* pExternalFenceProperties + + + VkResult vkGetFenceWin32HandleKHR + VkDevice device + const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo + HANDLE* pHandle + + + VkResult vkImportFenceWin32HandleKHR + VkDevice device + const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo + + + VkResult vkGetFenceFdKHR + VkDevice device + const VkFenceGetFdInfoKHR* pGetFdInfo + int* pFd + + + VkResult vkImportFenceFdKHR + VkDevice device + const VkImportFenceFdInfoKHR* pImportFenceFdInfo + + + VkResult vkReleaseDisplayEXT + VkPhysicalDevice physicalDevice + VkDisplayKHR display + + + VkResult vkAcquireXlibDisplayEXT + VkPhysicalDevice physicalDevice + Display* dpy + VkDisplayKHR display + + + VkResult vkGetRandROutputDisplayEXT + VkPhysicalDevice physicalDevice + Display* dpy + RROutput rrOutput + VkDisplayKHR* pDisplay + + + VkResult vkDisplayPowerControlEXT + VkDevice device + VkDisplayKHR display + const VkDisplayPowerInfoEXT* pDisplayPowerInfo + + + VkResult vkRegisterDeviceEventEXT + VkDevice device + const VkDeviceEventInfoEXT* pDeviceEventInfo + const VkAllocationCallbacks* pAllocator + VkFence* pFence + + + VkResult vkRegisterDisplayEventEXT + VkDevice device + VkDisplayKHR display + const VkDisplayEventInfoEXT* pDisplayEventInfo + const VkAllocationCallbacks* pAllocator + VkFence* pFence + + + VkResult vkGetSwapchainCounterEXT + VkDevice device + VkSwapchainKHR swapchain + VkSurfaceCounterFlagBitsEXT counter + uint64_t* pCounterValue + + + VkResult vkGetPhysicalDeviceSurfaceCapabilities2EXT + VkPhysicalDevice physicalDevice + VkSurfaceKHR surface + VkSurfaceCapabilities2EXT* pSurfaceCapabilities + + + VkResult vkEnumeratePhysicalDeviceGroupsKHX + VkInstance instance + uint32_t* pPhysicalDeviceGroupCount + VkPhysicalDeviceGroupPropertiesKHX* pPhysicalDeviceGroupProperties + + + void vkGetDeviceGroupPeerMemoryFeaturesKHX + VkDevice device + uint32_t heapIndex + uint32_t localDeviceIndex + uint32_t remoteDeviceIndex + VkPeerMemoryFeatureFlagsKHX* pPeerMemoryFeatures + + + VkResult vkBindBufferMemory2KHR + VkDevice device + uint32_t bindInfoCount + const VkBindBufferMemoryInfoKHR* pBindInfos + + + VkResult vkBindImageMemory2KHR + VkDevice device + uint32_t bindInfoCount + const VkBindImageMemoryInfoKHR* pBindInfos + + + void vkCmdSetDeviceMaskKHX + VkCommandBuffer commandBuffer + uint32_t deviceMask + + + VkResult vkGetDeviceGroupPresentCapabilitiesKHX + VkDevice device + VkDeviceGroupPresentCapabilitiesKHX* pDeviceGroupPresentCapabilities + + + VkResult vkGetDeviceGroupSurfacePresentModesKHX + VkDevice device + VkSurfaceKHR surface + VkDeviceGroupPresentModeFlagsKHX* pModes + + + VkResult vkAcquireNextImage2KHX + VkDevice device + const VkAcquireNextImageInfoKHX* pAcquireInfo + uint32_t* pImageIndex + + + void vkCmdDispatchBaseKHX + VkCommandBuffer commandBuffer + uint32_t baseGroupX + uint32_t baseGroupY + uint32_t baseGroupZ + uint32_t groupCountX + uint32_t groupCountY + uint32_t groupCountZ + + + VkResult vkGetPhysicalDevicePresentRectanglesKHX + VkPhysicalDevice physicalDevice + VkSurfaceKHR surface + uint32_t* pRectCount + VkRect2D* pRects + + + VkResult vkCreateDescriptorUpdateTemplateKHR + VkDevice device + const VkDescriptorUpdateTemplateCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkDescriptorUpdateTemplateKHR* pDescriptorUpdateTemplate + + + void vkDestroyDescriptorUpdateTemplateKHR + VkDevice device + VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate + const VkAllocationCallbacks* pAllocator + + + void vkUpdateDescriptorSetWithTemplateKHR + VkDevice device + VkDescriptorSet descriptorSet + VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate + const void* pData + + + void vkCmdPushDescriptorSetWithTemplateKHR + VkCommandBuffer commandBuffer + VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate + VkPipelineLayout layout + uint32_t set + const void* pData + + + void vkSetHdrMetadataEXT + VkDevice device + uint32_t swapchainCount + const VkSwapchainKHR* pSwapchains + const VkHdrMetadataEXT* pMetadata + + + VkResult vkGetSwapchainStatusKHR + VkDevice device + VkSwapchainKHR swapchain + + + VkResult vkGetRefreshCycleDurationGOOGLE + VkDevice device + VkSwapchainKHR swapchain + VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties + + + VkResult vkGetPastPresentationTimingGOOGLE + VkDevice device + VkSwapchainKHR swapchain + uint32_t* pPresentationTimingCount + VkPastPresentationTimingGOOGLE* pPresentationTimings + + + VkResult vkCreateIOSSurfaceMVK + VkInstance instance + const VkIOSSurfaceCreateInfoMVK* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + VkResult vkCreateMacOSSurfaceMVK + VkInstance instance + const VkMacOSSurfaceCreateInfoMVK* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSurfaceKHR* pSurface + + + void vkCmdSetViewportWScalingNV + VkCommandBuffer commandBuffer + uint32_t firstViewport + uint32_t viewportCount + const VkViewportWScalingNV* pViewportWScalings + + + void vkCmdSetDiscardRectangleEXT + VkCommandBuffer commandBuffer + uint32_t firstDiscardRectangle + uint32_t discardRectangleCount + const VkRect2D* pDiscardRectangles + + + void vkCmdSetSampleLocationsEXT + VkCommandBuffer commandBuffer + const VkSampleLocationsInfoEXT* pSampleLocationsInfo + + + void vkGetPhysicalDeviceMultisamplePropertiesEXT + VkPhysicalDevice physicalDevice + VkSampleCountFlagBits samples + VkMultisamplePropertiesEXT* pMultisampleProperties + + + VkResult vkGetPhysicalDeviceSurfaceCapabilities2KHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo + VkSurfaceCapabilities2KHR* pSurfaceCapabilities + + + VkResult vkGetPhysicalDeviceSurfaceFormats2KHR + VkPhysicalDevice physicalDevice + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo + uint32_t* pSurfaceFormatCount + VkSurfaceFormat2KHR* pSurfaceFormats + + + void vkGetBufferMemoryRequirements2KHR + VkDevice device + const VkBufferMemoryRequirementsInfo2KHR* pInfo + VkMemoryRequirements2KHR* pMemoryRequirements + + + void vkGetImageMemoryRequirements2KHR + VkDevice device + const VkImageMemoryRequirementsInfo2KHR* pInfo + VkMemoryRequirements2KHR* pMemoryRequirements + + + void vkGetImageSparseMemoryRequirements2KHR + VkDevice device + const VkImageSparseMemoryRequirementsInfo2KHR* pInfo + uint32_t* pSparseMemoryRequirementCount + VkSparseImageMemoryRequirements2KHR* pSparseMemoryRequirements + + + VkResult vkCreateSamplerYcbcrConversionKHR + VkDevice device + const VkSamplerYcbcrConversionCreateInfoKHR* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkSamplerYcbcrConversionKHR* pYcbcrConversion + + + void vkDestroySamplerYcbcrConversionKHR + VkDevice device + VkSamplerYcbcrConversionKHR ycbcrConversion + const VkAllocationCallbacks* pAllocator + + + VkResult vkCreateValidationCacheEXT + VkDevice device + const VkValidationCacheCreateInfoEXT* pCreateInfo + const VkAllocationCallbacks* pAllocator + VkValidationCacheEXT* pValidationCache + + + void vkDestroyValidationCacheEXT + VkDevice device + VkValidationCacheEXT validationCache + const VkAllocationCallbacks* pAllocator + + + VkResult vkGetValidationCacheDataEXT + VkDevice device + VkValidationCacheEXT validationCache + size_t* pDataSize + void* pData + + + VkResult vkMergeValidationCachesEXT + VkDevice device + VkValidationCacheEXT dstCache + uint32_t srcCacheCount + const VkValidationCacheEXT* pSrcCaches + + + VkResult vkGetSwapchainGrallocUsageANDROID + VkDevice device + VkFormat format + VkImageUsageFlags imageUsage + int* grallocUsage + + + VkResult vkAcquireImageANDROID + VkDevice device + VkImage image + int nativeFenceFd + VkSemaphore semaphore + VkFence fence + + + VkResult vkQueueSignalReleaseImageANDROID + VkQueue queue + uint32_t waitSemaphoreCount + const VkSemaphore* pWaitSemaphores + VkImage image + int* pNativeFenceFd + + + VkResult vkGetShaderInfoAMD + VkDevice device + VkPipeline pipeline + VkShaderStageFlagBits shaderStage + VkShaderInfoTypeAMD infoType + size_t* pInfoSize + void* pInfo + + + VkResult vkGetMemoryHostPointerPropertiesEXT + VkDevice device + VkExternalMemoryHandleTypeFlagBitsKHR handleType + const void* pHostPointer + VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + offset 1 reserved for the old VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHX enum + offset 2 reserved for the old VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHX enum + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/vk.rewrite/Program.cs b/src/vk.rewrite/Program.cs new file mode 100644 index 00000000..e6e12244 --- /dev/null +++ b/src/vk.rewrite/Program.cs @@ -0,0 +1,201 @@ +using Mono.Cecil; +using Mono.Cecil.Cil; +using System; +using System.Linq; +using Mono.Collections.Generic; +using System.IO; +using System.Collections.Generic; +using System.Text; + +namespace Vk.Rewrite +{ + public class Program + { + private static TypeReference s_calliRewriteRef; + private static MethodReference s_stringToHGlobalUtf8Ref; + private static MethodDefinition s_freeHGlobalRef; + private static TypeReference s_stringHandleRef; + + public static int Main(string[] args) + { + string vkDllPath = null; + string outputPath = null; + bool copiedToTemp = false; + var s = System.CommandLine.ArgumentSyntax.Parse(args, syntax => + { + syntax.DefineOption("vkdll", ref vkDllPath, "The location of vk.dll to rewrite."); + syntax.DefineOption("out", ref outputPath, "The output location of the rewritten DLL. If not specified, the DLL is rewritten in-place."); + }); + + if (vkDllPath == null) + { + Console.WriteLine("Error: a path for --vkdll is required."); + Console.WriteLine(s.GetHelpText()); + return -1; + } + if (outputPath == null) + { + outputPath = vkDllPath; + string copyPath = Path.GetTempFileName(); + File.Copy(vkDllPath, copyPath, overwrite: true); + vkDllPath = copyPath; + copiedToTemp = true; + } + try + { + Rewrite(vkDllPath, outputPath); + } + finally + { + if (copiedToTemp) + { + File.Delete(vkDllPath); + } + } + return 0; + } + + private static void Rewrite(string vkDllPath, string outputPath) + { + using (AssemblyDefinition vkDll = AssemblyDefinition.ReadAssembly(vkDllPath)) + { + LoadRefs(vkDll); + ModuleDefinition mainModule = vkDll.Modules[0]; + + s_stringHandleRef = mainModule.GetType("OpenTK.Graphics.Vulkan.StringHandle"); + TypeDefinition bindingHelpers = mainModule.GetType("OpenTK.Graphics.Vulkan.BindingsHelpers"); + s_stringToHGlobalUtf8Ref = bindingHelpers.Methods.Single(md => md.Name == "StringToHGlobalUtf8"); + s_freeHGlobalRef = bindingHelpers.Methods.Single(md => md.Name == "FreeHGlobal"); + + foreach (var type in mainModule.Types) + { + ProcessType(type); + } + vkDll.Write(outputPath); + } + } + + private static void LoadRefs(AssemblyDefinition vkDll) + { + s_calliRewriteRef = vkDll.MainModule.GetType("OpenTK.Graphics.Vulkan.Generator.CalliRewriteAttribute"); + } + + private static void ProcessType(TypeDefinition type) + { + foreach (var method in type.Methods) + { + ProcessMethod(method); + } + } + + private static void ProcessMethod(MethodDefinition method) + { + if (method.CustomAttributes.Any(ca => ca.AttributeType == s_calliRewriteRef)) + { + var processor = method.Body.GetILProcessor(); + RewriteMethod(method); + method.CustomAttributes.Remove(method.CustomAttributes.Single(ca => ca.AttributeType == s_calliRewriteRef)); + } + } + + private static void RewriteMethod(MethodDefinition method) + { + var il = method.Body.GetILProcessor(); + il.Body.Instructions.Clear(); + + List stringParams = new List(); + for (int i = 0; i < method.Parameters.Count; i++) + { + EmitLoadArgument(il, i, method.Parameters); + TypeReference parameterType = method.Parameters[i].ParameterType; + if (parameterType.FullName == "System.String") + { + VariableDefinition variableDef = new VariableDefinition(s_stringHandleRef); + method.Body.Variables.Add(variableDef); + il.Emit(OpCodes.Call, s_stringToHGlobalUtf8Ref); + il.Emit(OpCodes.Stloc, variableDef); + il.Emit(OpCodes.Ldloc, variableDef); + stringParams.Add(variableDef); + } + else if (parameterType.IsByReference) + { + VariableDefinition byRefVariable = new VariableDefinition(new PinnedType(parameterType)); + method.Body.Variables.Add(byRefVariable); + il.Emit(OpCodes.Stloc, byRefVariable); + il.Emit(OpCodes.Ldloc, byRefVariable); + il.Emit(OpCodes.Conv_I); + } + } + + string functionPtrName = method.Name + "_ptr"; + var field = method.DeclaringType.Fields.SingleOrDefault(fd => fd.Name == functionPtrName); + if (field == null) + { + throw new InvalidOperationException("Can't find function pointer field for " + method.Name); + } + il.Emit(OpCodes.Ldsfld, field); + + CallSite callSite = new CallSite(method.ReturnType) + { + CallingConvention = MethodCallingConvention.StdCall + }; + foreach (ParameterDefinition pd in method.Parameters) + { + TypeReference parameterType; + if (pd.ParameterType.IsByReference) + { + parameterType = new PointerType(pd.ParameterType.GetElementType()); + } + else if (pd.ParameterType.FullName == "System.String") + { + parameterType = s_stringHandleRef; + } + else + { + parameterType = pd.ParameterType; + } + ParameterDefinition calliPD = new ParameterDefinition(pd.Name, pd.Attributes, parameterType); + + callSite.Parameters.Add(calliPD); + } + il.Emit(OpCodes.Calli, callSite); + + foreach (var stringVar in stringParams) + { + il.Emit(OpCodes.Ldloc, stringVar); + il.Emit(OpCodes.Call, s_freeHGlobalRef); + } + + il.Emit(OpCodes.Ret); + + if (method.Body.Variables.Count > 0) + { + method.Body.InitLocals = true; + } + } + + private static void EmitLoadArgument(ILProcessor il, int i, Collection parameters) + { + if (i == 0) + { + il.Emit(OpCodes.Ldarg_0); + } + else if (i == 1) + { + il.Emit(OpCodes.Ldarg_1); + } + else if (i == 2) + { + il.Emit(OpCodes.Ldarg_2); + } + else if (i == 3) + { + il.Emit(OpCodes.Ldarg_3); + } + else + { + il.Emit(OpCodes.Ldarg, i); + } + } + } +} \ No newline at end of file diff --git a/src/vk.rewrite/rewritten.dll b/src/vk.rewrite/rewritten.dll new file mode 100644 index 00000000..e69de29b diff --git a/src/vk.rewrite/vk.rewrite.csproj b/src/vk.rewrite/vk.rewrite.csproj new file mode 100644 index 00000000..e6e8be23 --- /dev/null +++ b/src/vk.rewrite/vk.rewrite.csproj @@ -0,0 +1,14 @@ + + + netcoreapp2.0 + Exe + vk.rewrite + Vk.Generator.Rewrite + true + false + + + + + + \ No newline at end of file