⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dri_glx.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
				    &ddx_version.minor,				    &ddx_version.patch,				    &driverName)) {	ErrorMessageF("XF86DRIGetClientDriverName failed\n");	goto handle_error;    }    Xfree(driverName); /* No longer needed. */    /*     * Get device-specific info.  pDevPriv will point to a struct     * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that     * has information about the screen size, depth, pitch, ancilliary     * buffers, DRM mmap handles, etc.     */    if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk,			      &framebuffer.size, &framebuffer.stride,			      &framebuffer.dev_priv_size, &framebuffer.dev_priv)) {	ErrorMessageF("XF86DRIGetDeviceInfo failed");	goto handle_error;    }    framebuffer.width = DisplayWidth(dpy, scrn);    framebuffer.height = DisplayHeight(dpy, scrn);    /* Map the framebuffer region. */    status = drmMap(fd, hFB, framebuffer.size, 		    (drmAddressPtr)&framebuffer.base);    if (status != 0) {	ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status));	goto handle_error;    }    /* Map the SAREA region.  Further mmap regions may be setup in     * each DRI driver's "createNewScreen" function.     */    status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA);    if (status != 0) {	ErrorMessageF("drmMap of SAREA failed (%s)", strerror(-status));	goto handle_error;    }    psp = (*psc->legacy->createNewScreen)(scrn,					  &ddx_version,					  &dri_version,					  &drm_version,					  &framebuffer,					  pSAREA,					  fd,					  loader_extensions,					  &driver_configs,					  psc);    if (psp == NULL) {	ErrorMessageF("Calling driver entry point failed");	goto handle_error;    }    psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);    psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);    return psp; handle_error:    if (pSAREA != MAP_FAILED)	drmUnmap(pSAREA, SAREA_MAX);    if (framebuffer.base != MAP_FAILED)	drmUnmap((drmAddress)framebuffer.base, framebuffer.size);    if (framebuffer.dev_priv != NULL)	Xfree(framebuffer.dev_priv);    if (fd >= 0)	drmCloseOnce(fd);    XF86DRICloseConnection(dpy, scrn);    ErrorMessageF("reverting to software direct rendering\n");    return NULL;}#else /* !GLX_USE_APPLEGL */static void *CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,		    __GLXDRIdisplayPrivate * driDpy){    return NULL;}#endif /* !GLX_USE_APPLEGL */static void driDestroyContext(__GLXDRIcontext *context,			      __GLXscreenConfigs *psc, Display *dpy){    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;			    (*psc->core->destroyContext)(pcp->driContext);    XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);    Xfree(pcp);}static Bool driBindContext(__GLXDRIcontext *context,			   __GLXDRIdrawable *draw, __GLXDRIdrawable *read){    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;    const __DRIcoreExtension *core = pcp->psc->core;    return (*core->bindContext)(pcp->driContext,				draw->driDrawable,				read->driDrawable);}static void driUnbindContext(__GLXDRIcontext *context){    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;    const __DRIcoreExtension *core = pcp->psc->core;    (*core->unbindContext)(pcp->driContext);}static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,					 const __GLcontextModes *mode,					 GLXContext gc,					 GLXContext shareList, int renderType){    __GLXDRIcontextPrivate *pcp, *pcp_shared;    drm_context_t hwContext;    __DRIcontext *shared = NULL;    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;    if (!psc || !psc->driScreen)	return NULL;    if (shareList) {	pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;	shared = pcp_shared->driContext;    }    pcp = Xmalloc(sizeof *pcp);    if (pcp == NULL)	return NULL;    pcp->psc = psc;    if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr,					mode->visualID,					&pcp->hwContextID, &hwContext)) {	Xfree(pcp);	return NULL;    }    pcp->driContext =        (*psc->legacy->createNewContext)(psc->__driScreen,					 config->driConfig,					 renderType,					 shared,					 hwContext,					 pcp);    if (pcp->driContext == NULL) {	XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);	Xfree(pcp);	return NULL;    }    pcp->base.destroyContext = driDestroyContext;    pcp->base.bindContext = driBindContext;    pcp->base.unbindContext = driUnbindContext;    return &pcp->base;}static void driDestroyDrawable(__GLXDRIdrawable *pdraw){    __GLXscreenConfigs *psc = pdraw->psc;    (*psc->core->destroyDrawable)(pdraw->driDrawable);    XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);    Xfree(pdraw);}static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,					   XID xDrawable,					   GLXDrawable drawable,					   const __GLcontextModes *modes){    __GLXDRIdrawable *pdraw;    drm_drawable_t hwDrawable;    void *empty_attribute_list = NULL;    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;    /* Old dri can't handle GLX 1.3+ drawable constructors. */    if (xDrawable != drawable)	return NULL;    pdraw = Xmalloc(sizeof(*pdraw));    if (!pdraw)	return NULL;    pdraw->drawable = drawable;    pdraw->psc = psc;    if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable))	return NULL;    /* Create a new drawable */    pdraw->driDrawable =	(*psc->legacy->createNewDrawable)(psc->__driScreen,					  config->driConfig,					  hwDrawable,					  GLX_WINDOW_BIT,					  empty_attribute_list,					  pdraw);    if (!pdraw->driDrawable) {	XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);	Xfree(pdraw);	return NULL;    }    pdraw->destroyDrawable = driDestroyDrawable;    return pdraw;}static void driDestroyScreen(__GLXscreenConfigs *psc){    /* Free the direct rendering per screen data */    if (psc->__driScreen)	(*psc->core->destroyScreen)(psc->__driScreen);    psc->__driScreen = NULL;    if (psc->driver)	dlclose(psc->driver);}static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,				       __GLXdisplayPrivate *priv){    __GLXDRIdisplayPrivate *pdp;    __GLXDRIscreen *psp;    const __DRIextension **extensions;    char *driverName;    int i;    psp = Xmalloc(sizeof *psp);    if (psp == NULL)	return NULL;    /* Initialize per screen dynamic client GLX extensions */    psc->ext_list_first_time = GL_TRUE;    if (!driGetDriverName(priv->dpy, screen, &driverName)) {	Xfree(psp);	return NULL;    }    psc->driver = driOpenDriver(driverName);    Xfree(driverName);    if (psc->driver == NULL) {	Xfree(psp);	return NULL;    }    extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);    if (extensions == NULL) { 	ErrorMessageF("driver exports no extensions (%s)\n", dlerror());	Xfree(psp);	return NULL;    }    for (i = 0; extensions[i]; i++) {	if (strcmp(extensions[i]->name, __DRI_CORE) == 0)	    psc->core = (__DRIcoreExtension *) extensions[i];	if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0)	    psc->legacy = (__DRIlegacyExtension *) extensions[i];    }    if (psc->core == NULL || psc->legacy == NULL) {	Xfree(psp);	return NULL;    }      pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay;    psc->__driScreen = 	CallCreateNewScreen(psc->dpy, screen, psc, pdp);    if (psc->__driScreen == NULL) { 	dlclose(psc->driver); 	Xfree(psp); 	return NULL;    }    driBindExtensions(psc, 0);    psp->destroyScreen = driDestroyScreen;    psp->createContext = driCreateContext;    psp->createDrawable = driCreateDrawable;    return psp;}/* Called from __glXFreeDisplayPrivate. */static void driDestroyDisplay(__GLXDRIdisplay *dpy){    Xfree(dpy);}/* * Allocate, initialize and return a __DRIdisplayPrivate object. * This is called from __glXInitialize() when we are given a new * display pointer. */_X_HIDDEN __GLXDRIdisplay *driCreateDisplay(Display *dpy){    __GLXDRIdisplayPrivate *pdpyp;    int eventBase, errorBase;    int major, minor, patch;    if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {	return NULL;    }    if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) {	return NULL;    }    pdpyp = Xmalloc(sizeof *pdpyp);    if (!pdpyp) {	return NULL;    }    pdpyp->driMajor = major;    pdpyp->driMinor = minor;    pdpyp->driPatch = patch;    pdpyp->base.destroyDisplay = driDestroyDisplay;    pdpyp->base.createScreen = driCreateScreen;    return &pdpyp->base;}#endif /* GLX_DIRECT_RENDERING */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -