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

📄 radeon_screen.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
   if (screen->chip_family >= CHIP_FAMILY_RV515) {       ret = radeonGetParam( sPriv->fd, RADEON_PARAM_NUM_GB_PIPES,			     &temp);       if (ret) {	   fprintf(stderr, "Unable to get num_pipes, need newer drm\n");	   switch (screen->chip_family) {	   case CHIP_FAMILY_R300:	   case CHIP_FAMILY_R350:	       screen->num_gb_pipes = 2;	       break;	   case CHIP_FAMILY_R420:	   case CHIP_FAMILY_R520:	   case CHIP_FAMILY_R580:	   case CHIP_FAMILY_RV560:	   case CHIP_FAMILY_RV570:	       screen->num_gb_pipes = 4;	       break;	   case CHIP_FAMILY_RV350:	   case CHIP_FAMILY_RV515:	   case CHIP_FAMILY_RV530:	   case CHIP_FAMILY_RV410:	   default:	       screen->num_gb_pipes = 1;	       break;	   }       } else {	   screen->num_gb_pipes = temp;       }   }   if ( sPriv->drm_version.minor >= 10 ) {      drm_radeon_setparam_t sp;      sp.param = RADEON_SETPARAM_FB_LOCATION;      sp.value = screen->fbLocation;      drmCommandWrite( sPriv->fd, DRM_RADEON_SETPARAM,		       &sp, sizeof( sp ) );   }   screen->frontOffset	= dri_priv->frontOffset;   screen->frontPitch	= dri_priv->frontPitch;   screen->backOffset	= dri_priv->backOffset;   screen->backPitch	= dri_priv->backPitch;   screen->depthOffset	= dri_priv->depthOffset;   screen->depthPitch	= dri_priv->depthPitch;   /* Check if ddx has set up a surface reg to cover depth buffer */   screen->depthHasSurface = (sPriv->ddx_version.major > 4) ||      /* these chips don't use tiled z without hyperz. So always pretend         we have set up a surface which will cause linear reads/writes */      ((screen->chip_family & RADEON_CLASS_R100) &&      !(screen->chip_flags & RADEON_CHIPSET_TCL));   if ( dri_priv->textureSize == 0 ) {      screen->texOffset[RADEON_LOCAL_TEX_HEAP] = screen->gart_texture_offset;      screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->gartTexMapSize;      screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =	 dri_priv->log2GARTTexGran;   } else {      screen->texOffset[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureOffset				               + screen->fbLocation;      screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureSize;      screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =	 dri_priv->log2TexGran;   }   if ( !screen->gartTextures.map || dri_priv->textureSize == 0	|| getenv( "RADEON_GARTTEXTURING_FORCE_DISABLE" ) ) {      screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;      screen->texOffset[RADEON_GART_TEX_HEAP] = 0;      screen->texSize[RADEON_GART_TEX_HEAP] = 0;      screen->logTexGranularity[RADEON_GART_TEX_HEAP] = 0;   } else {      screen->numTexHeaps = RADEON_NR_TEX_HEAPS;      screen->texOffset[RADEON_GART_TEX_HEAP] = screen->gart_texture_offset;      screen->texSize[RADEON_GART_TEX_HEAP] = dri_priv->gartTexMapSize;      screen->logTexGranularity[RADEON_GART_TEX_HEAP] =	 dri_priv->log2GARTTexGran;   }   i = 0;   screen->extensions[i++] = &driCopySubBufferExtension.base;   screen->extensions[i++] = &driFrameTrackingExtension.base;   screen->extensions[i++] = &driReadDrawableExtension;   if ( screen->irq != 0 ) {       screen->extensions[i++] = &driSwapControlExtension.base;       screen->extensions[i++] = &driMediaStreamCounterExtension.base;   }#if !RADEON_COMMON   screen->extensions[i++] = &radeonTexOffsetExtension.base;#endif#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)   if (IS_R200_CLASS(screen))       screen->extensions[i++] = &r200AllocateExtension.base;   screen->extensions[i++] = &r200texOffsetExtension.base;#endif#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)   screen->extensions[i++] = &r300texOffsetExtension.base;#endif   screen->extensions[i++] = NULL;   sPriv->extensions = screen->extensions;   screen->driScreen = sPriv;   screen->sarea_priv_offset = dri_priv->sarea_priv_offset;   return screen;}/* Destroy the device specific screen private data struct. */static voidradeonDestroyScreen( __DRIscreenPrivate *sPriv ){   radeonScreenPtr screen = (radeonScreenPtr)sPriv->private;   if (!screen)      return;   if ( screen->gartTextures.map ) {      drmUnmap( screen->gartTextures.map, screen->gartTextures.size );   }   drmUnmapBufs( screen->buffers );   drmUnmap( screen->status.map, screen->status.size );   drmUnmap( screen->mmio.map, screen->mmio.size );   /* free all option information */   driDestroyOptionInfo (&screen->optionCache);   FREE( screen );   sPriv->private = NULL;}/* Initialize the driver specific screen private data. */static GLbooleanradeonInitDriver( __DRIscreenPrivate *sPriv ){   sPriv->private = (void *) radeonCreateScreen( sPriv );   if ( !sPriv->private ) {      radeonDestroyScreen( sPriv );      return GL_FALSE;   }   return GL_TRUE;}/** * Create the Mesa framebuffer and renderbuffers for a given window/drawable. * * \todo This function (and its interface) will need to be updated to support * pbuffers. */static GLbooleanradeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,                    __DRIdrawablePrivate *driDrawPriv,                    const __GLcontextModes *mesaVis,                    GLboolean isPixmap ){   radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;   if (isPixmap) {      return GL_FALSE; /* not implemented */   }   else {      const GLboolean swDepth = GL_FALSE;      const GLboolean swAlpha = GL_FALSE;      const GLboolean swAccum = mesaVis->accumRedBits > 0;      const GLboolean swStencil = mesaVis->stencilBits > 0 &&         mesaVis->depthBits != 24;      struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);      /* front color renderbuffer */      {         driRenderbuffer *frontRb            = driNewRenderbuffer(GL_RGBA,                                 driScrnPriv->pFB + screen->frontOffset,                                 screen->cpp,                                 screen->frontOffset, screen->frontPitch,                                 driDrawPriv);         radeonSetSpanFunctions(frontRb, mesaVis);         _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);      }      /* back color renderbuffer */      if (mesaVis->doubleBufferMode) {         driRenderbuffer *backRb            = driNewRenderbuffer(GL_RGBA,                                 driScrnPriv->pFB + screen->backOffset,                                 screen->cpp,                                 screen->backOffset, screen->backPitch,                                 driDrawPriv);         radeonSetSpanFunctions(backRb, mesaVis);         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);      }      /* depth renderbuffer */      if (mesaVis->depthBits == 16) {         driRenderbuffer *depthRb            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,                                 driScrnPriv->pFB + screen->depthOffset,                                 screen->cpp,                                 screen->depthOffset, screen->depthPitch,                                 driDrawPriv);         radeonSetSpanFunctions(depthRb, mesaVis);         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);	 depthRb->depthHasSurface = screen->depthHasSurface;      }      else if (mesaVis->depthBits == 24) {         driRenderbuffer *depthRb            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,                                 driScrnPriv->pFB + screen->depthOffset,                                 screen->cpp,                                 screen->depthOffset, screen->depthPitch,                                 driDrawPriv);         radeonSetSpanFunctions(depthRb, mesaVis);         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);	 depthRb->depthHasSurface = screen->depthHasSurface;      }      /* stencil renderbuffer */      if (mesaVis->stencilBits > 0 && !swStencil) {         driRenderbuffer *stencilRb            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,                                 driScrnPriv->pFB + screen->depthOffset,                                 screen->cpp,                                 screen->depthOffset, screen->depthPitch,                                 driDrawPriv);         radeonSetSpanFunctions(stencilRb, mesaVis);         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);	 stencilRb->depthHasSurface = screen->depthHasSurface;      }      _mesa_add_soft_renderbuffers(fb,                                   GL_FALSE, /* color */                                   swDepth,                                   swStencil,                                   swAccum,                                   swAlpha,                                   GL_FALSE /* aux */);      driDrawPriv->driverPrivate = (void *) fb;      return (driDrawPriv->driverPrivate != NULL);   }}static voidradeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv){   _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));}#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)/** * Choose the appropriate CreateContext function based on the chipset. * Eventually, all drivers will go through this process. */static GLboolean radeonCreateContext(const __GLcontextModes * glVisual,				     __DRIcontextPrivate * driContextPriv,				     void *sharedContextPriv){	__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;	radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);	if (IS_R300_CLASS(screen))		return r300CreateContext(glVisual, driContextPriv, sharedContextPriv);        return GL_FALSE;}/** * Choose the appropriate DestroyContext function based on the chipset. */static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv){	radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;	if (IS_R300_CLASS(radeon->radeonScreen))		return r300DestroyContext(driContextPriv);}#endif/** * This is the driver specific part of the createNewScreen entry point. * * \todo maybe fold this into intelInitDriver * * \return the __GLcontextModes supported by this driver */static const __DRIconfig **radeonInitScreen(__DRIscreenPrivate *psp){#if !RADEON_COMMON   static const char *driver_name = "Radeon";   static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };   static const __DRIversion dri_expected = { 4, 0, 0 };   static const __DRIversion drm_expected = { 1, 6, 0 };#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)   static const char *driver_name = "R200";   static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };   static const __DRIversion dri_expected = { 4, 0, 0 };   static const __DRIversion drm_expected = { 1, 6, 0 };#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)   static const char *driver_name = "R300";   static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };   static const __DRIversion dri_expected = { 4, 0, 0 };   static const __DRIversion drm_expected = { 1, 24, 0 };#endif   RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;   if ( ! driCheckDriDdxDrmVersions3( driver_name,				      &psp->dri_version, & dri_expected,				      &psp->ddx_version, & ddx_expected,				      &psp->drm_version, & drm_expected ) ) {      return NULL;   }   /* Calling driInitExtensions here, with a NULL context pointer,    * does not actually enable the extensions.  It just makes sure    * that all the dispatch offsets for all the extensions that    * *might* be enables are known.  This is needed because the    * dispatch offsets need to be known when _mesa_context_create    * is called, but we can't enable the extensions until we have a    * context pointer.    *    * Hello chicken.  Hello egg.  How are you two today?    */   driInitExtensions( NULL, card_extensions, GL_FALSE );#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)   driInitExtensions( NULL, blend_extensions, GL_FALSE );   driInitSingleExtension( NULL, ARB_vp_extension );   driInitSingleExtension( NULL, NV_vp_extension );   driInitSingleExtension( NULL, ATI_fs_extension );   driInitExtensions( NULL, point_extensions, GL_FALSE );#endif   if (!radeonInitDriver(psp))       return NULL;   return radeonFillInModes( psp,			     dri_priv->bpp,			     (dri_priv->bpp == 16) ? 16 : 24,			     (dri_priv->bpp == 16) ? 0  : 8,			     (dri_priv->backOffset != dri_priv->depthOffset) );}/** * Get information about previous buffer swaps. */static intgetSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo ){#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))   radeonContextPtr  rmesa;#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)   r200ContextPtr  rmesa;#endif   if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)	|| (dPriv->driContextPriv->driverPrivate == NULL)	|| (sInfo == NULL) ) {      return -1;   }   rmesa = dPriv->driContextPriv->driverPrivate;   sInfo->swap_count = rmesa->swap_count;   sInfo->swap_ust = rmesa->swap_ust;   sInfo->swap_missed_count = rmesa->swap_missed_count;   sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)       ? driCalculateSwapUsage( dPriv, 0, rmesa->swap_missed_ust )       : 0.0;   return 0;}#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))const struct __DriverAPIRec driDriverAPI = {   .InitScreen      = radeonInitScreen,   .DestroyScreen   = radeonDestroyScreen,   .CreateContext   = radeonCreateContext,   .DestroyContext  = radeonDestroyContext,   .CreateBuffer    = radeonCreateBuffer,   .DestroyBuffer   = radeonDestroyBuffer,   .SwapBuffers     = radeonSwapBuffers,   .MakeCurrent     = radeonMakeCurrent,   .UnbindContext   = radeonUnbindContext,   .GetSwapInfo     = getSwapInfo,   .GetDrawableMSC  = driDrawableGetMSC32,   .WaitForMSC      = driWaitForMSC32,   .WaitForSBC      = NULL,   .SwapBuffersMSC  = NULL,   .CopySubBuffer   = radeonCopySubBuffer,};#elseconst struct __DriverAPIRec driDriverAPI = {   .InitScreen      = radeonInitScreen,   .DestroyScreen   = radeonDestroyScreen,   .CreateContext   = r200CreateContext,   .DestroyContext  = r200DestroyContext,   .CreateBuffer    = radeonCreateBuffer,   .DestroyBuffer   = radeonDestroyBuffer,   .SwapBuffers     = r200SwapBuffers,   .MakeCurrent     = r200MakeCurrent,   .UnbindContext   = r200UnbindContext,   .GetSwapInfo     = getSwapInfo,   .GetDrawableMSC  = driDrawableGetMSC32,   .WaitForMSC      = driWaitForMSC32,   .WaitForSBC      = NULL,   .SwapBuffersMSC  = NULL,   .CopySubBuffer   = r200CopySubBuffer,};#endif

⌨️ 快捷键说明

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