コード例 #1
0
        public static IntPtr GetDelegate(VkInstance inst, string name)
        {
            byte[]   n   = System.Text.Encoding.UTF8.GetBytes(name + '\0');
            GCHandle hnd = GCHandle.Alloc(n, GCHandleType.Pinned);
            IntPtr   del = Vk.vkGetInstanceProcAddr(inst, hnd.AddrOfPinnedObject());

            if (del == IntPtr.Zero)
            {
                System.Diagnostics.Debug.WriteLine("instance function pointer not found for " + name);
            }
            hnd.Free();
            return(del);
        }
コード例 #2
0
        /// <summary>
        /// Returns global layer properties.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static VkPhysicalDevice[] PhysicalDevices(this VkInstance instance)
        {
            VkPhysicalDevice[] result;
            UInt32             count;

            vkAPI.vkEnumeratePhysicalDevices(instance, &count, null).Check();
            result = new VkPhysicalDevice[count];
            if (count > 0)
            {
                fixed(VkPhysicalDevice *pointer = result)
                {
                    vkAPI.vkEnumeratePhysicalDevices(instance, &count, pointer).Check();
                }
            }

            return(result);
        }
コード例 #3
0
        public static bool TryGetPhysicalDevice(this VkInstance inst, VkPhysicalDeviceType deviceType, out VkPhysicalDevice phy)
        {
            CheckResult(vkEnumeratePhysicalDevices(inst, out uint phyCount, IntPtr.Zero));

            VkPhysicalDevice[] phys = new VkPhysicalDevice[phyCount];

            CheckResult(vkEnumeratePhysicalDevices(inst, out phyCount, phys.Pin()));

            for (int i = 0; i < phys.Length; i++)
            {
                phy = phys[i];
                vkGetPhysicalDeviceProperties(phy, out VkPhysicalDeviceProperties props);
                if (props.deviceType == deviceType)
                {
                    return(true);
                }
            }
            phy = default;
            return(false);
        }