Esempio n. 1
0
        public DeviceGroupDeviceCreateInfo
        (
            StructureType?sType              = StructureType.DeviceGroupDeviceCreateInfo,
            void *pNext                      = null,
            uint?physicalDeviceCount         = null,
            PhysicalDevice *pPhysicalDevices = null
        ) : this()
        {
            if (sType is not null)
            {
                SType = sType.Value;
            }

            if (pNext is not null)
            {
                PNext = pNext;
            }

            if (physicalDeviceCount is not null)
            {
                PhysicalDeviceCount = physicalDeviceCount.Value;
            }

            if (pPhysicalDevices is not null)
            {
                PPhysicalDevices = pPhysicalDevices;
            }
        }
Esempio n. 2
0
        private unsafe void PickPhysicalDevice()
        {
            uint deviceCount = 0;

            _vk.EnumeratePhysicalDevices(_instance, &deviceCount, (PhysicalDevice *)null);

            if (deviceCount == 0)
            {
                throw new NotSupportedException("Failed to find GPUs with Vulkan support!");
            }
            PhysicalDevice *devices = stackalloc PhysicalDevice[(int)deviceCount];

            _vk.EnumeratePhysicalDevices(_instance, &deviceCount, devices);

            for (int i = 0; i < deviceCount; i++)
            {
                PhysicalDevice device = devices[i];
                if (IsDeviceSuitable(device))
                {
                    _physicalDevice = device;
                    return;
                }
            }
            throw new Exception("No suitable device.");
        }
Esempio n. 3
0
 public DeviceGroupDeviceCreateInfoKHR
 (
     StructureType sType              = StructureType.DeviceGroupDeviceCreateInfo,
     void *pNext                      = default,
     uint physicalDeviceCount         = default,
     PhysicalDevice *pPhysicalDevices = default
 )
 {
     SType = sType;
     PNext = pNext;
     PhysicalDeviceCount = physicalDeviceCount;
     PPhysicalDevices    = pPhysicalDevices;
 }
Esempio n. 4
0
        private PhysicalDevice SelectPhysicalDevice(out QueueFamilyIndices indices)
        {
            uint count = 0;
            var  res   = VkApi.EnumeratePhysicalDevices(this.Instance, &count, null);

            if (res != Result.Success)
            {
                throw new VMASharp.VulkanResultException("Unable to enumerate physical devices", res);
            }

            if (count == 0)
            {
                throw new Exception("No physical devices found!");
            }

            PhysicalDevice *deviceList = stackalloc PhysicalDevice[(int)count];

            res = VkApi.EnumeratePhysicalDevices(this.Instance, &count, deviceList);

            if (res != Result.Success)
            {
                throw new VMASharp.VulkanResultException("Unable to enumerate physical devices", res);
            }

            for (uint i = 0; i < count; ++i)
            {
                var device = deviceList[i];

                if (IsDeviceSuitable(device, out indices))
                {
                    return(device);
                }
            }

            throw new Exception("No suitable device found!");
        }