void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds) { VendorID vendor = GetVendorID(functions); // Don't use 1-bit alpha formats on desktop GL with AMD or Intel drivers. workarounds->avoid1BitAlphaTextureFormats = functions->standard == STANDARD_GL_DESKTOP && (vendor == VENDOR_ID_AMD || vendor == VENDOR_ID_INTEL); workarounds->rgba4IsNotSupportedForColorRendering = functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_INTEL; }
egl::Error DisplayAndroid::getDriverVersion(std::string *version) const { VendorID vendor = GetVendorID(mFunctionsGL); switch (vendor) { case VENDOR_ID_QUALCOMM: *version = reinterpret_cast<const char *>(mFunctionsGL->getString(GL_VERSION)); return egl::Error(EGL_SUCCESS); default: *version = ""; return egl::Error(EGL_SUCCESS); } }
egl::Error DisplayGLX::getDriverVersion(std::string *version) const { VendorID vendor = GetVendorID(mFunctionsGL); switch (vendor) { case VENDOR_ID_NVIDIA: return getNVIDIADriverVersion(version); case VENDOR_ID_AMD: return GetAMDDriverVersion(version); default: *version = ""; return egl::Error(EGL_SUCCESS); } }
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds) { VendorID vendor = GetVendorID(functions); // Don't use 1-bit alpha formats on desktop GL with AMD or Intel drivers. workarounds->avoid1BitAlphaTextureFormats = functions->standard == STANDARD_GL_DESKTOP && (vendor == VENDOR_ID_AMD || vendor == VENDOR_ID_INTEL); workarounds->rgba4IsNotSupportedForColorRendering = functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_INTEL; workarounds->doesSRGBClearsOnLinearFramebufferAttachments = functions->standard == STANDARD_GL_DESKTOP && (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_AMD); #if defined(ANGLE_PLATFORM_APPLE) workarounds->doWhileGLSLCausesGPUHang = true; #endif workarounds->finishDoesNotCauseQueriesToBeAvailable = functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_NVIDIA; }
egl::Error DisplayGLX::initialize(egl::Display *display) { mEGLDisplay = display; Display *xDisplay = display->getNativeDisplayId(); const auto &attribMap = display->getAttributeMap(); // ANGLE_platform_angle allows the creation of a default display // using EGL_DEFAULT_DISPLAY (= nullptr). In this case just open // the display specified by the DISPLAY environment variable. if (xDisplay == EGL_DEFAULT_DISPLAY) { mUsesNewXDisplay = true; xDisplay = XOpenDisplay(NULL); if (!xDisplay) { return egl::Error(EGL_NOT_INITIALIZED, "Could not open the default X display."); } } std::string glxInitError; if (!mGLX.initialize(xDisplay, DefaultScreen(xDisplay), &glxInitError)) { return egl::Error(EGL_NOT_INITIALIZED, glxInitError.c_str()); } mHasMultisample = mGLX.minorVersion > 3 || mGLX.hasExtension("GLX_ARB_multisample"); mHasARBCreateContext = mGLX.hasExtension("GLX_ARB_create_context"); mHasARBCreateContextProfile = mGLX.hasExtension("GLX_ARB_create_context_profile"); mHasEXTCreateContextES2Profile = mGLX.hasExtension("GLX_EXT_create_context_es2_profile"); // Choose the swap_control extension to use, if any. // The EXT version is better as it allows glXSwapInterval to be called per // window, while we'll potentially need to change the swap interval on each // swap buffers when using the SGI or MESA versions. if (mGLX.hasExtension("GLX_EXT_swap_control")) { mSwapControl = SwapControl::EXT; // In GLX_EXT_swap_control querying these is done on a GLXWindow so we just // set default values. mMinSwapInterval = 0; mMaxSwapInterval = 4; } else if (mGLX.hasExtension("GLX_MESA_swap_control")) { // If we have the Mesa or SGI extension, assume that you can at least set // a swap interval of 0 or 1. mSwapControl = SwapControl::Mesa; mMinSwapInterval = 0; mMinSwapInterval = 1; } else if (mGLX.hasExtension("GLX_SGI_swap_control")) { mSwapControl = SwapControl::SGI; mMinSwapInterval = 0; mMinSwapInterval = 1; } else { mSwapControl = SwapControl::Absent; mMinSwapInterval = 1; mMinSwapInterval = 1; } if (attribMap.contains(EGL_X11_VISUAL_ID_ANGLE)) { mRequestedVisual = attribMap.get(EGL_X11_VISUAL_ID_ANGLE, -1); // There is no direct way to get the GLXFBConfig matching an X11 visual ID // so we have to iterate over all the GLXFBConfigs to find the right one. int nConfigs; int attribList[] = { None, }; glx::FBConfig *allConfigs = mGLX.chooseFBConfig(attribList, &nConfigs); for (int i = 0; i < nConfigs; ++i) { if (getGLXFBConfigAttrib(allConfigs[i], GLX_VISUAL_ID) == mRequestedVisual) { mContextConfig = allConfigs[i]; break; } } XFree(allConfigs); if (mContextConfig == nullptr) { return egl::Error(EGL_NOT_INITIALIZED, "Invalid visual ID requested."); } } else { // When glXMakeCurrent is called, the context and the surface must be // compatible which in glX-speak means that their config have the same // color buffer type, are both RGBA or ColorIndex, and their buffers have // the same depth, if they exist. // Since our whole EGL implementation is backed by only one GL context, this // context must be compatible with all the GLXFBConfig corresponding to the // EGLconfigs that we will be exposing. int nConfigs; int attribList[] = { // We want RGBA8 and DEPTH24_STENCIL8 GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, // We want RGBA rendering (vs COLOR_INDEX) and doublebuffer GLX_RENDER_TYPE, GLX_RGBA_BIT, // Double buffer is not strictly required as a non-doublebuffer // context can work with a doublebuffered surface, but it still // flickers and all applications want doublebuffer anyway. GLX_DOUBLEBUFFER, True, // All of these must be supported for full EGL support GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PBUFFER_BIT | GLX_PIXMAP_BIT, // This makes sure the config have an associated visual Id GLX_X_RENDERABLE, True, GLX_CONFIG_CAVEAT, GLX_NONE, None }; glx::FBConfig *candidates = mGLX.chooseFBConfig(attribList, &nConfigs); if (nConfigs == 0) { XFree(candidates); return egl::Error(EGL_NOT_INITIALIZED, "Could not find a decent GLX FBConfig to create the context."); } mContextConfig = candidates[0]; XFree(candidates); } const auto &eglAttributes = display->getAttributeMap(); if (mHasARBCreateContext) { egl::Error error = initializeContext(mContextConfig, eglAttributes, &mContext); if (error.isError()) { return error; } } else { if (eglAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE) { return egl::Error(EGL_NOT_INITIALIZED, "Cannot create an OpenGL ES platform on GLX without the " "GLX_ARB_create_context extension."); } XVisualInfo visualTemplate; visualTemplate.visualid = getGLXFBConfigAttrib(mContextConfig, GLX_VISUAL_ID); int numVisuals = 0; XVisualInfo *visuals = XGetVisualInfo(xDisplay, VisualIDMask, &visualTemplate, &numVisuals); if (numVisuals <= 0) { return egl::Error(EGL_NOT_INITIALIZED, "Could not get the visual info from the fb config"); } ASSERT(numVisuals == 1); mContext = mGLX.createContext(&visuals[0], nullptr, true); XFree(visuals); if (!mContext) { return egl::Error(EGL_NOT_INITIALIZED, "Could not create GL context."); } } ASSERT(mContext); // FunctionsGL and DisplayGL need to make a few GL calls, for example to // query the version of the context so we need to make the context current. // glXMakeCurrent requires a GLXDrawable so we create a temporary Pbuffer // (of size 1, 1) for the duration of these calls. // Ideally we would want to unset the current context and destroy the pbuffer // before going back to the application but this is TODO // We could use a pbuffer of size (0, 0) but it fails on the Intel Mesa driver // as commented on https://bugs.freedesktop.org/show_bug.cgi?id=38869 so we // use (1, 1) instead. int dummyPbufferAttribs[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, None, }; mDummyPbuffer = mGLX.createPbuffer(mContextConfig, dummyPbufferAttribs); if (!mDummyPbuffer) { return egl::Error(EGL_NOT_INITIALIZED, "Could not create the dummy pbuffer."); } if (!mGLX.makeCurrent(mDummyPbuffer, mContext)) { return egl::Error(EGL_NOT_INITIALIZED, "Could not make the dummy pbuffer current."); } mFunctionsGL = new FunctionsGLGLX(mGLX.getProc); mFunctionsGL->initialize(); // TODO(cwallez, angleproject:1303) Disable the OpenGL ES backend on Linux NVIDIA and Intel as // it has problems on our automated testing. An OpenGL ES backend might not trigger this test if // there is no Desktop OpenGL support, but that's not the case in our automated testing. VendorID vendor = GetVendorID(mFunctionsGL); bool isOpenGLES = eglAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE; if (isOpenGLES && (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_NVIDIA)) { return egl::Error(EGL_NOT_INITIALIZED, "Intel or NVIDIA OpenGL ES drivers are not supported."); } syncXCommands(); std::string rendererString = reinterpret_cast<const char*>(mFunctionsGL->getString(GL_RENDERER)); mIsMesa = rendererString.find("Mesa") != std::string::npos; return DisplayGL::initialize(display); }
int main(int argc, char *argv[]) { int n; int ch; int method='I'; int ConfigRead; char *DaemonName; char ChipInfoStr[CHIP_STR_LEN]; unsigned int VendID; unsigned int ChipID; int LocalOnly; int sock; int sock6; int length; int ipv4_enable=1; struct sockaddr_in server; int msgsock; char buf[1024]; char outbuf[1024]; int rval; int selretval; int syserr; fd_set ready; struct servent *sp; unsigned long port; int psd = -1; struct sockaddr_in paddr; struct hostent *hent; struct itimerval tmo = {{0,0},{0,0}}; struct itimerval tmooff = {{0,0},{0,0}}; sock = 0; sock6 = 0; count = 0; tabout = 0; iter = 1; ConfigRead = 0; ReReadConfigFile = 0; ExitProgram = 0; UseVbat = 0; pushit = 0; quiet = 1; MonitorType = NO_CHIP; if ((sp = getservbyname("healthd", "tcp")) == NULL) { port = 1281; } else { port = ntohs(sp->s_port); } if (strchr(argv[0], '/')) { DaemonName = strrchr(argv[0], '/') + 1; } else { DaemonName=argv[0]; } /* * Set some defaults */ for (n=0; n<MAX_TYPES; n++) { active[n] = 0; fail_count[n] = 0; warn_level[n] = 2; warn_sent[n] = 0; fail_level[n] = 5; fail_sent[n] = 0; doWarn[n] = 0; doFail[n] = 0; } temp_warn[0] = '\0'; temp_fail[0] = '\0'; fan_warn[0] = '\0'; fan_fail[0] = '\0'; volt_warn[0] = '\0'; volt_fail[0] = '\0'; debug = 0; local = 0; LocalOnly = 0; while((ch=getopt(argc, argv, "12BDILSP:Vc:df:t:p:q")) != -1) { switch(ch){ case '1': MonitorType = W83781D; break; case '2': MonitorType = W83782D; break; case 'B': UseVbat = 1; break; case 'D': case 'd': debug = 1; break; case 'I': method='I'; break; case 'L': local = 1; break; case 'P': port = atoi(optarg); break; case 'S': method='S'; break; case 'V': fprintf(stderr, "Version %s\n", hdVERSION); exit(0); break; case 't': tabout = 1; break; case 'p': if ((psd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { (void)fprintf(stderr, "%s: cannot create push socket: %s\n", DaemonName, strerror(errno)); exit(1); } if (!(hent = gethostbyname(optarg))) { herror("Can't resolve hostname"); exit(1); } bzero(&paddr, sizeof(struct sockaddr_in)); paddr.sin_family = AF_INET; bcopy(hent->h_addr_list[0], &paddr.sin_addr.s_addr, sizeof(paddr.sin_addr.s_addr)); paddr.sin_port = htons(PUSH_PORT); if (connect(psd, (struct sockaddr*)&paddr, sizeof(struct sockaddr_in)) < 0) { (void)fprintf(stderr, "%s: connect failed: %s\n", DaemonName, strerror(errno)); exit(1); } pushit = 1; break; case 'c': count = atoi(optarg); if (count < 1) { count = 0; } debug = 1; break; case 'f': { int fd; if ((fd = open(optarg, O_RDONLY, 0)) < 0) { (void)fprintf(stderr, "%s: %s: %s\n", DaemonName, optarg, strerror(errno)); exit(1); } close(fd); strncpy(ConfigFile, optarg, MAXPATHLEN); ReadConfigFile (ConfigFile); ConfigRead = 1; } break; case 'q': quiet = 0; break; default: fprintf(stderr, "Usage: %s -[1|2] -[I|S] [-dLV] [-f configfile] [-c|t count] <seconds for sleep>"\ " (default %d sec)\n", DaemonName, DEFAULT_SEC); exit(1); } } if (ConfigRead == 0) { strncpy(ConfigFile, CONFIG_FILE, MAXPATHLEN); ReadConfigFile (ConfigFile); ConfigRead = 1; } if (argc > optind) { if((n = atoi(argv[optind])) > 0) { tmo.it_value.tv_sec = n; } else { fprintf(stderr, "Usage: %s -[1|2] -[I|S] [-dLV] [-f configfile] [-c|t count] <seconds for sleep>"\ " (default %d sec)\n", DaemonName, DEFAULT_SEC); exit(1); } } else { tmo.it_value.tv_sec = DEFAULT_SEC; } if (InitMBInfo(method) != 0) { perror("InitMBInfo"); exit(1); } if (RstChip() < 0) { perror("RstChip"); exit(1); } if (local || debug) { /* If debug mode or local mode don't open a socket */ LocalOnly = 1; } VendID = GetVendorID(); switch (VendID) { case 0x5CA3: ChipID = GetChipID_winbond(); switch (ChipID) { case 0x10: snprintf(ChipInfoStr, CHIP_STR_LEN, "WinBond Chip: W83781D"); if (MonitorType == NO_CHIP) MonitorType = W83781D; break; case 0x11: snprintf(ChipInfoStr, CHIP_STR_LEN, "Asus: AS97127F"); if (MonitorType == NO_CHIP) MonitorType = W83781D; break; case 0x21: snprintf(ChipInfoStr, CHIP_STR_LEN, "WinBond Chip: W83627HF"); if (MonitorType == NO_CHIP) MonitorType = W83627HF; break; case 0x30: snprintf(ChipInfoStr, CHIP_STR_LEN, "WinBond Chip: W83782D"); if (MonitorType == NO_CHIP) MonitorType = W83782D; break; case 0x40: snprintf(ChipInfoStr, CHIP_STR_LEN, "WinBond Chip: W83783S"); if (MonitorType == NO_CHIP) MonitorType = W83783S; break; default: snprintf(ChipInfoStr, CHIP_STR_LEN, "WinBond Chip: (unknown)"); if (MonitorType == NO_CHIP) MonitorType = W83781D; break; } break; case 0x12C3: snprintf(ChipInfoStr, CHIP_STR_LEN, "Asus: AS99127F"); if (MonitorType == NO_CHIP) MonitorType = AS99127F; break; case 0xFFFF0040: snprintf(ChipInfoStr, CHIP_STR_LEN, "National Semi: LM78"); if (MonitorType == NO_CHIP) MonitorType = LM78; break; case 0xFFFF00C0: snprintf(ChipInfoStr, CHIP_STR_LEN, "National Semi: LM79"); if (MonitorType == NO_CHIP) MonitorType = LM79; break; default: snprintf(ChipInfoStr, CHIP_STR_LEN, "Unknown Vendor: ID = %X", VendID); if (MonitorType == NO_CHIP) MonitorType = W83781D; break; } if (debug) { printf("************************\n"); printf("* Hardware Information *\n"); printf("************************\n"); printf("%s\n", ChipInfoStr); printf("************************\n\n"); } (void) openlog(DaemonName, LOG_CONS|LOG_NDELAY, hdFACILITY); signal(SIGALRM, SIGALRM_handler); if (debug == 0) { /* * Okay so far. Try and make ourself a daemon */ if (daemon(0,0) < 0) { syslog(hdALERT, "daemon libray call failed: %m (aborting)"); exit(2); } syslog(hdNOTICE, "Started"); } if (debug == 0) { /* Don't set the signal handler if we are in debug mode */ /* Since we don't check the ranges */ signal(SIGHUP, SIGHUP_handler); signal(SIGTERM, SIGTERM_handler); siginterrupt(SIGALRM,1); } if (LocalOnly == 0) { /* Create name with wildcards. */ if (ipv4_enable) { /* Create socket from which to read. */ sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { syslog(hdALERT, "opening datagram socket: %m"); syslog(hdALERT, "Aborting"); exit(1); } server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(port); if (bind(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in))) { close(sock); syslog(hdALERT, "binding datagram socket: %m"); syslog(hdALERT, "Aborting"); exit(1); } /* Find assigned port value and print it out. */ length = sizeof(server); if (getsockname(sock, (struct sockaddr *)&server, &length)) { close(sock); syslog(hdALERT, "getting socket name: %m"); syslog(hdALERT, "Aborting"); exit(1); } } } ReadCurrentValues(); if (LocalOnly == 0) { /* Start accepting connections */ if (sock != 0) { listen(sock, 32); } } /* Main daemon loop */ while ((iter<count) || (count==0)) { FD_ZERO(&ready); if (LocalOnly == 0) { if (sock != 0) { FD_SET(sock, &ready); } } /* Wait for connection, or timeout */ setitimer(ITIMER_REAL,&tmo,0); selretval = select(getdtablesize(), &ready, 0, 0, 0); syserr = errno; setitimer(ITIMER_REAL,&tmooff,0); if ( ExitProgram ) { break; } switch (selretval) { case -1: if (syserr && syserr != EINTR) { syslog(hdCRITICAL, "OOPS! select returned a weird error, bailing out: %m"); exit(1); } if (ReReadConfigFile) { /* * If we are updating the config file * then we should clear the error counts. */ for (n=0; n<MAX_TYPES; n++) { active[n] = 0; fail_count[n] = 0; warn_level[n] = 2; warn_sent[n] = 0; fail_level[n] = 5; fail_sent[n] = 0; } ReadConfigFile (ConfigFile); ReReadConfigFile = 0; syslog(hdWARNING, "Restarted"); break; } if (count > 0) { iter++; } ReadCurrentValues(); if (pushit) { push_stat(psd); } break; default: if (LocalOnly == 0) { if (FD_ISSET(sock, &ready)) { msgsock = accept(sock, 0, 0); if (msgsock == -1) { /* Add error handling here */ } else { do { bzero(buf, sizeof(buf)); bzero(outbuf, sizeof(outbuf)); if ((rval = read(msgsock, buf, 1024)) > 0) { rval = GetAnswer(buf, outbuf); write(msgsock, outbuf, strlen(outbuf)); } else if (rval < 0) { break; } } while (rval != 0); close(msgsock); } } } break; } if (ExitProgram) { break; } } if (LocalOnly == 0) { close(sock); } if (debug == 0) { signal(SIGHUP, SIG_DFL); signal(SIGTERM, SIG_DFL); } syslog(hdWARNING, "Exiting.."); exit(0); }
// do the work void mitk::DicomDiffusionImageHeaderReader::Update() { // check if there are filenames if(m_DicomFilenames.size()) { m_Output = mitk::DiffusionImageHeaderInformation::New(); m_Output->m_DicomFilenames = m_DicomFilenames; // create correct reader switch(GetVendorID()) { case(SV_GE): { GEDicomDiffusionImageHeaderReader::Pointer reader = GEDicomDiffusionImageHeaderReader::New(); reader->SetSeriesDicomFilenames(this->m_DicomFilenames); reader->SetGdcmIO(this->m_GdcmIO); reader->SetVolumeReader(this->m_VolumeReader); reader->SetOutputPointer(this->m_Output); reader->Update(); this->m_Output = reader->GetOutput(); break; } case(SV_SIEMENS): { SiemensDicomDiffusionImageHeaderReader::Pointer reader = SiemensDicomDiffusionImageHeaderReader::New(); reader->SetSeriesDicomFilenames(this->m_DicomFilenames); reader->SetGdcmIO(this->m_GdcmIO); reader->SetVolumeReader(this->m_VolumeReader); reader->SetOutputPointer(this->m_Output); reader->Update(); this->m_Output = reader->GetOutput(); break; } case(SV_SIEMENS_MOSAIC): { SiemensMosaicDicomDiffusionImageHeaderReader::Pointer reader = SiemensMosaicDicomDiffusionImageHeaderReader::New(); reader->SetSeriesDicomFilenames(this->m_DicomFilenames); reader->SetGdcmIO(this->m_GdcmIO); reader->SetVolumeReader(this->m_VolumeReader); reader->SetOutputPointer(this->m_Output); reader->Update(); this->m_Output = reader->GetOutput(); break; } case(SV_PHILIPS): { PhilipsDicomDiffusionImageHeaderReader::Pointer reader = PhilipsDicomDiffusionImageHeaderReader::New(); reader->SetSeriesDicomFilenames(this->m_DicomFilenames); reader->SetGdcmIO(this->m_GdcmIO); reader->SetVolumeReader(this->m_VolumeReader); reader->SetOutputPointer(this->m_Output); reader->Update(); this->m_Output = reader->GetOutput(); break; } case(SV_UNKNOWN_VENDOR): { std::cerr << "diffusion header reader: unknown vendor" << std::endl; break; } } } }