private void createVulkanInstance() { InstanceBuilder builder = new InstanceBuilder(); builder.SetApplicationName("Thingy"); builder.SetApplicationVersion(Vk.Version.Make(1, 0, 0)); builder.SetEngineName("None"); builder.SetEngineVersion(Vk.Version.Make(1, 0, 0)); builder.SetApiVersion(Vk.Version.Make(1, 0, 0)); builder.EnableExtensions(VkHelper.GetGLFWRequiredInstanceExtensions()); builder.EnableExtensions(this.InstanceExtensions); if (this.validationLayersEnabled) { builder.EnableExtensions(this.ValidationExtensions); builder.EnableValidationLayers(this.ValidationLayers); } try { this.Instance = builder.Create(); } catch (Vk.ResultException result) { throw new VkException("An error occurred while creating the Vulkan instance.", result); } }
public static bool InitAllAvaliableInstances(AbstractionDesc desc, out List <InstanceBase> instances) { instances = new List <InstanceBase>(); if (desc.supportedAPIs == null) { return(false); } foreach (var api in desc.supportedAPIs) { switch (api) { #if WIN32 || WIN32 case AbstractionAPI.D3D12: { if (!LoadNativeLib(Path.Combine(desc.nativeLibPathD3D12, D3D12.Instance.lib))) { continue; } var instanceD3D12 = new D3D12.Instance(); if (instanceD3D12.Init(desc.instanceDescD3D12)) { instances.Add(instanceD3D12); } else { instanceD3D12.Dispose(); } } break; case AbstractionAPI.Vulkan: { if (!LoadNativeLib(Path.Combine(desc.nativeLibPathVulkan, Vulkan.Instance.lib))) { continue; } var instanceVulkan = new Vulkan.Instance(); if (instanceVulkan.Init(desc.instanceDescVulkan)) { instances.Add(instanceVulkan); } else { instanceVulkan.Dispose(); } } break; #endif } } return(true); }
public static Vk.DebugReportCallbackExt RegisterDebugReportCallback(Vk.Instance instance, Vk.DebugReportFlagsExt flag, DebugCallback callback) { LowLevelDebugCallback container = BuildCallbackContainer(callback); IntPtr callbackPointer = Marshal.GetFunctionPointerForDelegate <LowLevelDebugCallback>(container); var callbackInfo = new Vk.DebugReportCallbackCreateInfoExt(); callbackInfo.PfnCallback = callbackPointer; callbackInfo.Flags = flag; callbackInfo.UserData = IntPtr.Zero; return(instance.CreateDebugReportCallbackEXT(callbackInfo)); }
public static Vk.PhysicalDevice SelectPhysicalDevice(Vk.Instance instance, IEnumerable <PhysicalDeviceSuitabilityCheck> checks) { Vk.PhysicalDevice[] devices = instance.EnumeratePhysicalDevices(); foreach (Vk.PhysicalDevice device in devices) { foreach (var check in checks) { if (!check.Invoke(device)) { break; } return(device); } } return(null); }
public static IntPtr InstancePointer(Vk.Instance instance) => ((Vk.IMarshalling)instance).Handle;