| 861 | } |
| 862 | |
| 863 | void |
| 864 | OSGLContext_x11::getGPUInfos(std::list<OpenGLRendererInfo>& renderers) |
| 865 | { |
| 866 | const OSGLContext_glx_data* glxInfo = appPTR->getGLXData(); |
| 867 | |
| 868 | assert(glxInfo); |
| 869 | if (!glxInfo) { |
| 870 | return; |
| 871 | } |
| 872 | if (!glxInfo->_imp->x11.display) { |
| 873 | return; |
| 874 | } |
| 875 | if (!glxInfo->_imp->MESA_query_renderer) { |
| 876 | std::unique_ptr<OSGLContext_x11> context; |
| 877 | try { |
| 878 | context.reset( new OSGLContext_x11(FramebufferConfig(), GLVersion.major, GLVersion.minor, false, GLRendererID(), 0) ); |
| 879 | } catch (const std::exception& e) { |
| 880 | std::cerr << e.what() << std::endl; |
| 881 | |
| 882 | return; |
| 883 | } |
| 884 | |
| 885 | if ( !makeContextCurrent( context.get() ) ) { |
| 886 | return; |
| 887 | } |
| 888 | |
| 889 | try { |
| 890 | OSGLContext::checkOpenGLVersion(); |
| 891 | } catch (const std::exception& e) { |
| 892 | std::cerr << e.what() << std::endl; |
| 893 | |
| 894 | return; |
| 895 | } |
| 896 | |
| 897 | OpenGLRendererInfo info; |
| 898 | info.vendorName = std::string( (const char *) glGetString(GL_VENDOR) ); |
| 899 | info.rendererName = std::string( (const char *) glGetString(GL_RENDERER) ); |
| 900 | info.glVersionString = std::string( (const char *) glGetString(GL_VERSION) ); |
| 901 | info.glslVersionString = std::string( (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION) ); |
| 902 | glGetIntegerv(GL_MAX_TEXTURE_SIZE, &info.maxTextureSize); |
| 903 | // We don't have any way to get memory size, set it to 0 |
| 904 | info.maxMemBytes = 0; |
| 905 | info.rendererID.renderID = -1; |
| 906 | renderers.push_back(info); |
| 907 | } else { |
| 908 | // Just use the first screen |
| 909 | const int screen = 0; |
| 910 | // The function QueryRendererIntegerMESA can return at most 3 values: https://www.opengl.org/registry/specs/MESA/glx_query_renderer.txt |
| 911 | unsigned int v[3]; |
| 912 | int renderer = 0; |
| 913 | bool gotRenderer; |
| 914 | do { |
| 915 | gotRenderer = (bool)glxInfo->_imp->QueryRendererIntegerMESA(glxInfo->_imp->x11.display, screen, renderer, GLX_RENDERER_DEVICE_ID_MESA, v); |
| 916 | if (gotRenderer) { |
| 917 | int rendererID = v[0]; |
| 918 | if ( (unsigned int)rendererID == 0xFFFFFFFF ) { |
| 919 | gotRenderer = false; |
| 920 | } else { |
nothing calls this directly
no test coverage detected