ThePhD / infoware

C++ Library for pulling system and hardware information, without hitting the command line.
Creative Commons Zero v1.0 Universal
410 stars 84 forks source link

There should be robust backend selection for GPU detection #74

Closed Zaraka closed 6 months ago

Zaraka commented 6 months ago

Right now infoware is supporting multiple ways how to detect GPU, but on the Linux platform, many of them can fail. Vulkan can fail if the device is too old, on the other hand, OpenGL can fail on the opposite problem.

My problem is only one of them gets compiled into the resulting library.

I propose some kind of robust GPU detection that uses multiple backends, the priority table stated in Readme.md should be respected, but if for example, Vulkan detection fails (because vkCreateInstance or whatever vulkan related function fails) infoware would try to proceed to another detection in the priority table.

this will require device_properties() function to either throw an exception or return an error through the function parameter.

nabijaczleweli commented 6 months ago

Can it? The 6500XT is quite recent and the OGL detexion worked there.

nabijaczleweli commented 6 months ago

Regardless, I think making this a published library was a mistake, especially from the angle of GPU config, where, if you do care, you want more specific info (most importantly, well, the embedded/dedicated/software type enum, and maybe device groups).

More-so than a library, infoware should be modelled as a repository of methodologies (and also has an interface, which is quite ass; cf. CPU feature detexion which has Some random subset of x86 and arm64 with no real rhyme to it; the GPUs have memory size (with no memory type distinxion) and frequency (both are usually 0, only OpenCL returns them both)). Errors are not distinguished from no-entries for this reason (everything just tries to collect as much as it can), and (sans sometimes the PCI number part) there are no inter-dependencies.

Since no patents or trademarks apply here, the CC0 licence means you can (and if you need something more robust or useful, should) copy the relevant files and, with minimal patches, adjust them to do fallbacks (like in this case) and broader/narrower detexion (like including VkPhysicalDeviceType for https://github.com/ThePhD/infoware/commit/5158f0a2e433787c201f3b96877290763542eefb#commitcomment-140046003), and distribute under your prevailing license.

Adding fallbacks and error reporting and whatever makes it a more compelling library, but a less compelling copy-paste repository. And the latter is the target.