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

Preliminary implementation of OpenGL detection on Linux #73

Closed Zaraka closed 6 months ago

Zaraka commented 6 months ago

I promised in #68 that I would implement Linux OpenGL detection, welp I totally forgot that I actually did some kind of detection months ago, so there you have it.

This right now uses only EGL, which is of course a problem. The status of Linux OpenGL suffers from many historical issues, especially X11 therefore we have two main ways how to get GL context in Linux

Getting renderer and vendor is easy, but it gets hard once you want to query memory or even frequency info. For memory, there are two GL extensions GL_NVX_gpu_memory_info and GL_ATI_meminfo, both work on AMD and NVIDIA, because mesa developers are chads. The problem is both require desktop GL, which would not be a problem, but... NVIDIA only supports OpenGL ES 2.0 on EGL, so that is a case which needs GLX instead of EGL. GL_ATI_meminfo is kinda useless because it won't give you the total memory amount only the free parts, I found out that there are functions to get the total amount (GetGPUInfoAMD), but they are only in the WGL association, that is not available on Linux. They may be available in GLX as well, but I have not found them yet.

GL_NVX_gpu_memory_info does not provide any info on the cache/shared memory size.

To this day I have no idea how to get GPU frequency on Linux without using AMD/NVIDIA specific tools and libraries (which we probably don't want to use as well)

I may contribute fixes and developments to this, maybe even GLX implementation in the future, but at this point, I would like to ask you a question I have been asking several times a week for the last year "Why not Vulkan?"

nabijaczleweli commented 6 months ago

remote/Lenovo 300e Chromebook 2nd Gen (Intel)/Lenovo 300e Chromebook 2nd Gen (MTK) (the warnings/errors went to the standard error stream)/local AMD GPU

==> tarta <==
Infoware version 0.6.0

  Properties:
    Device #1:
      Vendor       : Unknown
      Name         : llvmpipe (LLVM 15.0.6, 128 bits)
      RAM size     : 0B
      Cache size   : 0B
      Max frequency: 0Hz

==> chrust <==
Infoware version 0.6.0

  Properties:
    Device #1:
      Vendor       : Intel
      Name         : Mesa Intel(R) UHD Graphics 600 (GLK 2)
      RAM size     : 0B
      Cache size   : 0B
      Max frequency: 0Hz

==> chwast <==
libEGL warning: DRI2: failed to authenticate
MESA: error: ZINK: failed to choose pdev
libEGL warning: egl: failed to create dri2 screen
Infoware version 0.6.0

  Properties:
    Device #1:
      Vendor       : Unknown
      Name         : llvmpipe (LLVM 17.0.6, 128 bits)
      RAM size     : 0B
      Cache size   : 0B
      Max frequency: 0Hz

==> rozbian <==
Infoware version 0.6.0

  Properties:
    Device #1:
      Vendor       : AMD
      Name         : AMD Radeon RX 6500 XT (radeonsi, navi24, LLVM 17.0.6, DRM 3.54, 6.6.13-amd64)
      RAM size     : 0B
      Cache size   : 0B
      Max frequency: 0Hz
nabijaczleweli commented 6 months ago

Given the 1992 release date, GLX has a good part of a decade on me, yeah.

Output from my tests looks reasonable. The 6500 XT doesn't appear to have GL_NVX_gpu_memory_info, hence the 0B as-seen. Can't really test on my nvidia GPUs rn. Applied; cleanups in 3e49973f09ebb96886f49ae315c53bb7e66fb22a.

Not vulkan because in May 2016 (617bacaa64e24e5e6816158f5cb4cd1053536df1) vulkan was three months old to the public; I'm not opposed to a vulkan back-end.

nabijaczleweli commented 6 months ago

5158f0a2e433787c201f3b96877290763542eefb