-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
==> tarta <== Infoware version 0.6.0 Properties: Device #1: Vendor : Unknown Name : llvmpipe (LLVM 15.0.6, 128 bits) RAM size : 2147483648B Cache size : 0B Max frequency: 0Hz ==> chrust <== Infoware version 0.6.0 Properties: Device #1: Vendor : Intel Name : Intel(R) UHD Graphics 600 (GLK 2) RAM size : 1986174976B Cache size : 0B Max frequency: 0Hz Device #2: Vendor : Unknown Name : llvmpipe (LLVM 17.0.6, 128 bits) RAM size : 3972349952B Cache size : 0B Max frequency: 0Hz ==> nabuter <== Infoware version 0.6.0 Properties: Device #1: Vendor : AMD Name : AMD Radeon RX 5700 XT RAM size : 16866344960B Cache size : 0B Max frequency: 0Hz ==> rozbian <== Infoware version 0.6.0 Properties: Device #1: Vendor : AMD Name : AMD Radeon RX 6500 XT (RADV NAVI24) RAM size : 37947559936B Cache size : 0B Max frequency: 0Hz Device #2: Vendor : Unknown Name : llvmpipe (LLVM 17.0.6, 256 bits) RAM size : 67338743808B Cache size : 0B Max frequency: 0Hz ==> babtop <== Infoware version 0.6.0 Properties: Device #1: Vendor : Intel Name : Intel(R) UHD Graphics (AML-CFL) RAM size : 12505884672B Cache size : 0B Max frequency: 0Hz Device #2: Vendor : Unknown Name : llvmpipe (LLVM 16.0.6, 256 bits) RAM size : 16674512896B Cache size : 0B Max frequency: 0Hz
- Loading branch information
1 parent
c15bd1c
commit abb8bf4
Showing
9 changed files
with
125 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// SPDX-License-Identifier: CC0-1.0 | ||
// infoware - C++ System information Library | ||
|
||
|
||
#ifdef INFOWARE_USE_VULKAN | ||
|
||
|
||
#include "infoware/detail/scope.hpp" | ||
#include "infoware/gpu.hpp" | ||
#include <iostream> | ||
#include <numeric> | ||
#include <vulkan/vulkan.h> | ||
|
||
|
||
std::vector<iware::gpu::device_properties_t> iware::gpu::device_properties() { | ||
VkApplicationInfo appInfo{}; | ||
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||
appInfo.pApplicationName = "Hello Triangle"; | ||
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); | ||
appInfo.pEngineName = "No Engine"; | ||
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); | ||
appInfo.apiVersion = VK_API_VERSION_1_0; | ||
|
||
VkInstanceCreateInfo createInfo{}; | ||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; | ||
createInfo.pApplicationInfo = &appInfo; | ||
|
||
VkInstance instance; | ||
VkResult result = vkCreateInstance(&createInfo, nullptr, &instance); | ||
if(result != VK_SUCCESS) | ||
throw nullptr; | ||
iware::detail::quickscope_wrapper instance_deleter{[&]() { vkDestroyInstance(instance, nullptr); }}; | ||
|
||
|
||
uint32_t devices_len = 2; | ||
std::vector<VkPhysicalDevice> devices(devices_len); | ||
while((result = vkEnumeratePhysicalDevices(instance, &devices_len, devices.data())) == VK_INCOMPLETE) { | ||
devices.emplace_back(); | ||
devices_len = devices.size(); | ||
} | ||
if(result != VK_SUCCESS) | ||
return {}; | ||
devices.resize(devices_len); | ||
|
||
std::vector<iware::gpu::device_properties_t> ret; | ||
for(auto&& device : devices) { | ||
VkPhysicalDeviceProperties props{}; | ||
vkGetPhysicalDeviceProperties(device, &props); | ||
|
||
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceProperties.html | ||
// > If the vendor has a PCI vendor ID, the low 16 bits of vendorID must contain that PCI vendor ID, and the remaining bits must be set to zero. | ||
// > Otherwise, the value returned must be a valid Khronos vendor ID, | ||
// None of the <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkVendorId.html>s match anything in our enum. | ||
auto vendor = vendor_t::unknown; | ||
switch(props.vendorID) { | ||
case 0x8086: // Intel Corporation | ||
vendor = vendor_t::intel; | ||
break; | ||
case 0x1002: // Advanced Micro Devices, Inc. [AMD/ATI] | ||
case 0x1022: // Advanced Micro Devices, Inc. [AMD] | ||
vendor = vendor_t::amd; | ||
break; | ||
case 0x10de: // NVIDIA Corporation | ||
case 0x12d2: // NVidia / SGS Thomson (Joint Venture) | ||
vendor = vendor_t::nvidia; | ||
break; | ||
case 0x1414: // Microsoft Corporation | ||
vendor = vendor_t::microsoft; | ||
break; | ||
case 0x168c: // Qualcomm Atheros | ||
case 0x17cb: // Qualcomm | ||
case 0x1969: // Qualcomm Atheros | ||
case 0x5143: // Qualcomm Inc | ||
vendor = vendor_t::qualcomm; | ||
break; | ||
case 0x106b: // Apple Inc. | ||
vendor = vendor_t::apple; | ||
break; | ||
} | ||
|
||
VkPhysicalDeviceMemoryProperties mem{}; | ||
vkGetPhysicalDeviceMemoryProperties(device, &mem); | ||
|
||
ret.emplace_back(device_properties_t{ | ||
vendor, | ||
props.deviceName, | ||
std::accumulate(mem.memoryHeaps, mem.memoryHeaps + mem.memoryHeapCount, static_cast<std::size_t>(0), [](auto i, auto&& heap) { return i + heap.size; }), | ||
0, | ||
0, | ||
}); | ||
} | ||
return ret; | ||
} | ||
|
||
|
||
#endif |