Ejemplo n.º 1
0
 /// <summary>
 /// Get whether a physical device meets requirement features and capabilities
 /// </summary>
 /// <param name="device"></param>
 /// <returns></returns>
 private static bool GetDeviceMeetsRequirements(PhysicalDevice device, SurfaceKhr surface)
 {
     // Argument checks
     if (device is null)
     {
         throw new ArgumentNullException(nameof(device));
     }
     if (surface is null)
     {
         throw new ArgumentNullException(nameof(surface));
     }
     // Check device features
     {
         var features = device.GetFeatures();
         if (!features.SamplerAnisotropy)
         {
             return(false);
         }
         var limits = device.GetProperties().Limits;
         if (limits.MaxVertexInputAttributes < 16)
         {
             return(false);
         }
         if (limits.MaxUniformBufferRange < sizeof(float) * 4 * 254)
         {
             return(false);
         }
         if (limits.MaxVertexInputBindings < 2)
         {
             return(false);
         }
         if (limits.MaxPointSize <= 1)
         {
             return(false);
         }
     }
     // Check queue families
     {
         var families = device.GetQueueFamilyProperties();
         // Graphics, compute, transfer
         {
             if (families.Count(family => QueueFamily.Supports(family, Queues.Graphics)) == 0 ||
                 families.Count(family => QueueFamily.Supports(family, Queues.Compute)) == 0 ||
                 families.Count(family => QueueFamily.Supports(family, Queues.Transfer)) == 0)
             {
                 return(false);
             }
         }
         // Present
         {
             var foundPresent = false;
             for (var i = 0; i < families.Length; i++)
             {
                 if (QueueFamily.SupportsPresenting(i, device, surface))
                 {
                     foundPresent = true;
                     break;
                 }
             }
             if (!foundPresent)
             {
                 return(false);
             }
         }
     }
     return(true);
 }