MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp:1554–1965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1552}
1553
1554bool GPUDeviceVulkan::Init()
1555{
1556 TotalGraphicsMemory = 0;
1557
1558 _state = DeviceState::Created;
1559 const auto gpu = Adapter->Gpu;
1560
1561 // Get queues properties
1562 uint32 queueCount = 0;
1563 vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queueCount, nullptr);
1564 ASSERT(queueCount >= 1);
1565 QueueFamilyProps.AddDefault(queueCount);
1566 vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queueCount, QueueFamilyProps.Get());
1567
1568 // Query device features
1569 RenderToolsVulkan::ZeroStruct(PhysicalDeviceFeatures12, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES);
1570 vkGetPhysicalDeviceFeatures(gpu, &PhysicalDeviceFeatures);
1571 if (vkGetPhysicalDeviceFeatures2)
1572 {
1573 VkPhysicalDeviceFeatures2 features2;
1574 RenderToolsVulkan::ZeroStruct(features2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2);
1575 features2.pNext = &PhysicalDeviceFeatures12;
1576 vkGetPhysicalDeviceFeatures2(gpu, &features2);
1577 }
1578
1579 // Get extensions and layers
1580 Array<const char*> deviceExtensions;
1581 Array<const char*> validationLayers;
1582 GetDeviceExtensionsAndLayers(gpu, deviceExtensions, validationLayers);
1583 ParseOptionalDeviceExtensions(deviceExtensions);
1584
1585 // Setup device info
1586 VkDeviceCreateInfo deviceInfo;
1587 RenderToolsVulkan::ZeroStruct(deviceInfo, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
1588 deviceInfo.enabledExtensionCount = deviceExtensions.Count();
1589 deviceInfo.ppEnabledExtensionNames = deviceExtensions.Get();
1590 deviceInfo.enabledLayerCount = validationLayers.Count();
1591 deviceInfo.ppEnabledLayerNames = deviceInfo.enabledLayerCount > 0 ? validationLayers.Get() : nullptr;
1592
1593 // Setup queues info
1594 Array<VkDeviceQueueCreateInfo> queueFamilyInfos;
1595 int32 graphicsQueueFamilyIndex = -1;
1596 int32 computeQueueFamilyIndex = -1;
1597 int32 transferQueueFamilyIndex = -1;
1598 LOG(Info, "Found {0} queue families:", QueueFamilyProps.Count());
1599 uint32 numPriorities = 0;
1600 for (int32 familyIndex = 0; familyIndex < QueueFamilyProps.Count(); familyIndex++)
1601 {
1602 const VkQueueFamilyProperties& curProps = QueueFamilyProps[familyIndex];
1603
1604 bool isValidQueue = false;
1605 if ((curProps.queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
1606 {
1607 if (graphicsQueueFamilyIndex == -1)
1608 {
1609 graphicsQueueFamilyIndex = familyIndex;
1610 isValidQueue = true;
1611 }

Callers 4

GetDummyTextureMethod · 0.45
GetDummyBufferMethod · 0.45
GetDummyVertexBufferMethod · 0.45
CreateMethod · 0.45

Calls 15

volkLoadDeviceFunction · 0.85
GetMaxSampleCountFunction · 0.85
ClampFunction · 0.85
GetShaderProfileFunction · 0.85
MemoryClearFunction · 0.85
EnumHasAnyFlagsFunction · 0.85
FormatFeaturesFunction · 0.85
vmaCreateAllocatorFunction · 0.85
LeftMethod · 0.80
MinFunction · 0.50
StringClass · 0.50
InitFunction · 0.50

Tested by

no test coverage detected