diff --git a/Examples/gpu/UltralightNet.Vulkan.TestApp/Startup/Utils.cs b/Examples/gpu/UltralightNet.Vulkan.TestApp/Startup/Utils.cs index 17851c825..8282f11f9 100644 --- a/Examples/gpu/UltralightNet.Vulkan.TestApp/Startup/Utils.cs +++ b/Examples/gpu/UltralightNet.Vulkan.TestApp/Startup/Utils.cs @@ -14,9 +14,9 @@ public static void Check(this Result result) private static bool HasInstanceLayer(this Vk vk, ReadOnlySpan layer) { uint propertyCount = 0; - vk.EnumerateInstanceLayerProperties(ref propertyCount, null); + vk.EnumerateInstanceLayerProperties(ref propertyCount, null).Check(); var properties = stackalloc LayerProperties[(int)propertyCount]; - vk.EnumerateInstanceLayerProperties(ref propertyCount, properties); + vk.EnumerateInstanceLayerProperties(ref propertyCount, properties).Check(); for (int i = 0; i < propertyCount; i++) if (layer.SequenceEqual(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(properties[i].LayerName))) return true; return false; diff --git a/Examples/gpu/UltralightNet.Vulkan.TestApp/VulkanExample.cs b/Examples/gpu/UltralightNet.Vulkan.TestApp/VulkanExample.cs index eb39e52cc..910c396f8 100644 --- a/Examples/gpu/UltralightNet.Vulkan.TestApp/VulkanExample.cs +++ b/Examples/gpu/UltralightNet.Vulkan.TestApp/VulkanExample.cs @@ -1,6 +1,5 @@ //namespace VulkanExample; -using Silk.NET.Core.Native; using Silk.NET.Vulkan; using Silk.NET.Windowing; @@ -14,6 +13,8 @@ internal unsafe partial class Application : IDisposable readonly Vk vk = Vk.GetApi(); readonly Instance instance; + readonly PhysicalDevice physicalDevice; + public Application() { { // Window @@ -24,6 +25,14 @@ public Application() var extensions = window.VkSurface.GetRequiredExtensions(out uint extensionCount); Utils.CreateInstance(vk, extensionCount, extensions, out instance); } + { // Physical Device + uint deviceCount = 0; + vk.EnumeratePhysicalDevices(instance, ref deviceCount, null).Check(); + if (deviceCount is 0) throw new Exception("Couldn't find physical vulkan device."); + var devices = stackalloc PhysicalDevice[(int)deviceCount]; + vk.EnumeratePhysicalDevices(instance, ref deviceCount, devices).Check(); + physicalDevice = devices[0]; // idc + } Console.WriteLine(); }