U64 getSystemTotalRAM_conditionnally() { if ( isApplication32Bits() ) { return std::min( (U64)0x100000000ULL, getSystemTotalRAM() ); } else { return getSystemTotalRAM(); } }
void OSGLContext_win::getGPUInfos(std::list<OpenGLRendererInfo>& renderers) { const OSGLContext_wgl_data* wglInfo = appPTR->getWGLData(); assert(wglInfo); if (!wglInfo) { return; } bool defaultFallback = false; if (wglInfo->NV_gpu_affinity) { // https://www.opengl.org/registry/specs/NV/gpu_affinity.txt std::vector<HGPUNV> gpuHandles; int gpuIndex = 0; HGPUNV gpuHandle; bool gotGPU = true; do { gotGPU = wglInfo->EnumGpusNV(gpuIndex, &gpuHandle); if (gotGPU) { gpuHandles.push_back(gpuHandle); } ++gpuIndex; } while (gotGPU); if (gpuHandles.empty()) { defaultFallback = true; } for (std::size_t i = 0; i < gpuHandles.size(); ++i) { OpenGLRendererInfo info; info.rendererID.rendererHandle = (void*)gpuHandles[i]; boost::scoped_ptr<OSGLContext_win> context; try { GLRendererID gid; gid.rendererHandle = info.rendererID.rendererHandle; context.reset( new OSGLContext_win(FramebufferConfig(), appPTR->getOpenGLVersionMajor(), appPTR->getOpenGLVersionMinor(), false, gid, 0) ); } catch (const std::exception& e) { continue; } if ( !makeContextCurrent( context.get() ) ) { continue; } try { OSGLContext::checkOpenGLVersion(true); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; continue; } info.vendorName = std::string( (const char *) GL_GPU::GetString(GL_VENDOR) ); info.rendererName = std::string( (const char *) GL_GPU::GetString(GL_RENDERER) ); info.glVersionString = std::string( (const char *) GL_GPU::GetString(GL_VERSION) ); info.glslVersionString = std::string( (const char*) GL_GPU::GetString(GL_SHADING_LANGUAGE_VERSION) ); info.maxMemBytes = nvx_get_GPU_mem_info(); GL_GPU::GetIntegerv(GL_MAX_TEXTURE_SIZE, &info.maxTextureSize); renderers.push_back(info); makeContextCurrent(0); } } else if (wglInfo->AMD_gpu_association && !isApplication32Bits()) { //https://www.opengl.org/registry/specs/AMD/wgl_gpu_association.txt UINT getGpuIDMaxCount = wglInfo->GetGpuIDAMD(0, 0); UINT maxCount = getGpuIDMaxCount; std::vector<UINT> gpuIDs(maxCount); if (maxCount == 0) { defaultFallback = true; } else { UINT gpuCount = wglInfo->GetGpuIDAMD(maxCount, &gpuIDs[0]); if (gpuCount > maxCount) { gpuIDs.resize(gpuCount); } for (UINT index = 0; index < gpuCount; ++index) { assert(index < gpuIDs.size()); UINT gpuID = gpuIDs[index]; OpenGLRendererInfo info; info.rendererName = GetGPUInfoAMDInternal_string(wglInfo, gpuID, WGL_GPU_RENDERER_STRING_AMD); if (info.rendererName.empty()) { continue; } info.vendorName = GetGPUInfoAMDInternal_string(wglInfo, gpuID, WGL_GPU_VENDOR_AMD); if (info.vendorName.empty()) { continue; } info.glVersionString = GetGPUInfoAMDInternal_string(wglInfo, gpuID, WGL_GPU_OPENGL_VERSION_STRING_AMD); if (info.glVersionString.empty()) { continue; } // note: cannot retrieve GL_SHADING_LANGUAGE_VERSION info.maxMemBytes = 0; if (!isApplication32Bits()) { int ramMB = 0; // AMD drivers are f*** up in 32 bits, they read a wrong buffer size. // It works fine in 64 bits mode if (!GetGPUInfoAMDInternal_int(wglInfo, gpuID, WGL_GPU_RAM_AMD, &ramMB)) { continue; } info.maxMemBytes = ramMB * 1e6; } info.rendererID.renderID = gpuID; boost::scoped_ptr<OSGLContext_win> context; GLRendererID gid; gid.renderID = info.rendererID.renderID; try { context.reset( new OSGLContext_win(FramebufferConfig(), appPTR->getOpenGLVersionMajor(), appPTR->getOpenGLVersionMinor(), false, gid, 0) ); } catch (const std::exception& e) { continue; } if ( !makeContextCurrent( context.get() ) ) { continue; } try { OSGLContext::checkOpenGLVersion(true); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; continue; } GL_GPU::GetIntegerv(GL_MAX_TEXTURE_SIZE, &info.maxTextureSize); renderers.push_back(info); makeContextCurrent(0); } } } if (renderers.empty()) { defaultFallback = true; } if (defaultFallback) { // No extension, use default boost::scoped_ptr<OSGLContext_win> context; try { context.reset( new OSGLContext_win(FramebufferConfig(), appPTR->getOpenGLVersionMajor(), appPTR->getOpenGLVersionMinor(), false, GLRendererID(), 0) ); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return; } if ( !makeContextCurrent( context.get() ) ) { return; } try { OSGLContext::checkOpenGLVersion(true); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return; } OpenGLRendererInfo info; info.vendorName = std::string( (const char *) GL_GPU::GetString(GL_VENDOR) ); info.rendererName = std::string( (const char *) GL_GPU::GetString(GL_RENDERER) ); info.glVersionString = std::string( (const char *) GL_GPU::GetString(GL_VERSION) ); info.glslVersionString = std::string( (const char *) GL_GPU::GetString(GL_SHADING_LANGUAGE_VERSION) ); GL_GPU::GetIntegerv(GL_MAX_TEXTURE_SIZE, &info.maxTextureSize); // We don't have any way to get memory size, set it to 0 info.maxMemBytes = nvx_get_GPU_mem_info(); renderers.push_back(info); makeContextCurrent(0); } } // OSGLContext_win::getGPUInfos