示例#1
0
        private IEnumerable <uint> GetPresentQueues(SharpVk.PhysicalDevice device, VKSurface surface)
        {
            // - Gets GPU command queues
            var queues = device.GetQueueFamilyProperties();

            for (uint i = 0; i < queues.Length; ++i)
            {
                if (device.GetSurfaceSupport(i, surface.Handle))
                {
                    yield return(i);
                }
            }
        }
示例#2
0
        private IEnumerable <SharpVk.PhysicalDevice> FilterSuitableDevices(IEnumerable <SharpVk.PhysicalDevice> devices, VKSurface surface)
        {
            bool SuitabilityCriteria(SharpVk.PhysicalDevice device)
            {
                // - Gets device features
                var features = device.GetFeatures();

                // - Check if this GPU has a graphic queue
                if (GetSuitableQueues(device, QueueFlags.Graphics).Count() <= 0)
                {
                    return(false);
                }

                // - Check if this GPU has a compatible drawing surface
                if (GetPresentQueues(device, surface).Count() <= 0)
                {
                    return(false);
                }

                // - We need at least a geometry shader support
                if (!features.GeometryShader)
                {
                    return(false);
                }

                return(true);
            }

            return(devices.Where(SuitabilityCriteria));
        }