AMesaContext GLAPIENTRY AMesaCreateContext(AMesaVisual visual, AMesaContext share) { AMesaContext context; GLboolean direct = GL_FALSE; GLcontext *ctx; context = (AMesaContext) malloc(sizeof(struct amesa_context)); if (!context) return NULL; context->GLContext = _mesa_create_context(visual->GLVisual, share ? share->GLContext : NULL, (void*)context, direct); if (!context->GLContext) { free(context); return NULL; } context->Visual = visual; ctx = context->GLContext; _mesa_enable_sw_extensions(ctx); _mesa_enable_1_3_extensions(ctx); /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); _swsetup_Wakeup( ctx ); /*AMesaRegisterSwrastFunctions(ctx);*/ return context; }
/* * New in Mesa 3.5 * * Create context and specify size of ancillary buffers. */ GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist ) { OSMesaContext osmesa; struct dd_function_table functions; GLint rind, gind, bind, aind; GLint indexBits = 0, redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0; GLboolean rgbmode; rind = gind = bind = aind = 0; if (format==OSMESA_COLOR_INDEX) { indexBits = 8; rgbmode = GL_FALSE; } else if (format==OSMESA_RGBA) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; rind = 0; gind = 1; bind = 2; aind = 3; rgbmode = GL_TRUE; } else if (format==OSMESA_BGRA) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; bind = 0; gind = 1; rind = 2; aind = 3; rgbmode = GL_TRUE; } else if (format==OSMESA_ARGB) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; aind = 0; rind = 1; gind = 2; bind = 3; rgbmode = GL_TRUE; } else if (format==OSMESA_RGB) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 0; gind = 1; bind = 2; rgbmode = GL_TRUE; } else if (format==OSMESA_BGR) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 2; gind = 1; bind = 0; rgbmode = GL_TRUE; } #if CHAN_TYPE == GL_UNSIGNED_BYTE else if (format==OSMESA_RGB_565) { indexBits = 0; redBits = 5; greenBits = 6; blueBits = 5; alphaBits = 0; rind = 0; /* not used */ gind = 0; bind = 0; rgbmode = GL_TRUE; } #endif else { return NULL; } osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context); if (osmesa) { osmesa->gl_visual = _mesa_create_visual( rgbmode, GL_FALSE, /* double buffer */ GL_FALSE, /* stereo */ redBits, greenBits, blueBits, alphaBits, indexBits, depthBits, stencilBits, accumBits, accumBits, accumBits, alphaBits ? accumBits : 0, 1 /* num samples */ ); if (!osmesa->gl_visual) { FREE(osmesa); return NULL; } /* Initialize device driver function table */ _mesa_init_driver_functions(&functions); /* override with our functions */ functions.GetString = get_string; functions.UpdateState = osmesa_update_state; functions.GetBufferSize = get_buffer_size; if (!_mesa_initialize_context(&osmesa->mesa, osmesa->gl_visual, sharelist ? &sharelist->mesa : (GLcontext *) NULL, &functions, (void *) osmesa)) { _mesa_destroy_visual( osmesa->gl_visual ); FREE(osmesa); return NULL; } _mesa_enable_sw_extensions(&(osmesa->mesa)); _mesa_enable_1_3_extensions(&(osmesa->mesa)); _mesa_enable_1_4_extensions(&(osmesa->mesa)); _mesa_enable_1_5_extensions(&(osmesa->mesa)); osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual); if (!osmesa->gl_buffer) { _mesa_destroy_visual( osmesa->gl_visual ); _mesa_free_context_data( &osmesa->mesa ); FREE(osmesa); return NULL; } /* create front color buffer in user-provided memory (no back buffer) */ _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, new_osmesa_renderbuffer(format)); _mesa_add_soft_renderbuffers(osmesa->gl_buffer, GL_FALSE, /* color */ osmesa->gl_visual->haveDepthBuffer, osmesa->gl_visual->haveStencilBuffer, osmesa->gl_visual->haveAccumBuffer, GL_FALSE, /* alpha */ GL_FALSE /* aux */ ); osmesa->format = format; osmesa->buffer = NULL; osmesa->width = 0; osmesa->height = 0; osmesa->userRowLength = 0; osmesa->rowlength = 0; osmesa->yup = GL_TRUE; osmesa->rInd = rind; osmesa->gInd = gind; osmesa->bInd = bind; osmesa->aInd = aind; /* Initialize the software rasterizer and helper modules. */ { GLcontext *ctx = &osmesa->mesa; SWcontext *swrast; TNLcontext *tnl; if (!_swrast_CreateContext( ctx ) || !_ac_CreateContext( ctx ) || !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(osmesa->gl_visual); _mesa_free_context_data(ctx); _mesa_free(osmesa); return NULL; } _swsetup_Wakeup( ctx ); /* use default TCL pipeline */ tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; /* Extend the software rasterizer with our optimized line and triangle * drawing functions. */ swrast = SWRAST_CONTEXT( ctx ); swrast->choose_line = osmesa_choose_line; swrast->choose_triangle = osmesa_choose_triangle; } } return osmesa; }
GLboolean gammaCreateContext( const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate) { GLcontext *ctx, *shareCtx; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; gammaContextPtr gmesa; gammaScreenPtr gammascrn; GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+ sizeof(drm_sarea_t)); struct dd_function_table functions; gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) ); if (!gmesa) return GL_FALSE; /* Init default driver functions then plug in our gamma-specific functions * (the texture functions are especially important) */ _mesa_init_driver_functions( &functions ); gammaDDInitTextureFuncs( &functions ); /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions, (void *) gmesa); if (!gmesa->glCtx) { FREE(gmesa); return GL_FALSE; } gmesa->driContext = driContextPriv; gmesa->driScreen = sPriv; gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */ gmesa->hHWContext = driContextPriv->hHWContext; gmesa->driHwLock = &sPriv->pSAREA->lock; gmesa->driFd = sPriv->fd; gmesa->sarea = saPriv; gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private); ctx = gmesa->glCtx; ctx->Const.MaxTextureLevels = 13; /* 4K by 4K? Is that right? */ ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */ ctx->Const.MaxTextureImageUnits = 1; ctx->Const.MaxTextureCoordUnits = 1; ctx->Const.MinLineWidth = 0.0; ctx->Const.MaxLineWidth = 255.0; ctx->Const.MinLineWidthAA = 0.0; ctx->Const.MaxLineWidthAA = 65536.0; ctx->Const.MinPointSize = 0.0; ctx->Const.MaxPointSize = 255.0; ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */ ctx->Const.MaxPointSizeAA = 16.0; ctx->Const.PointSizeGranularity = 0.25; gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize ); make_empty_list(&gmesa->TexObjList); make_empty_list(&gmesa->SwappedOut); gmesa->CurrentTexObj[0] = 0; gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */ gmesa->RenderIndex = ~0; /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); /* Install the customized pipeline: */ _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, gamma_pipeline ); /* Configure swrast & TNL to match hardware characteristics: */ _swrast_allow_pixel_fog( ctx, GL_FALSE ); _swrast_allow_vertex_fog( ctx, GL_TRUE ); _tnl_allow_pixel_fog( ctx, GL_FALSE ); _tnl_allow_vertex_fog( ctx, GL_TRUE ); gammaInitVB( ctx ); gammaDDInitExtensions( ctx ); /* XXX these should really go right after _mesa_init_driver_functions() */ gammaDDInitDriverFuncs( ctx ); gammaDDInitStateFuncs( ctx ); gammaDDInitSpanFuncs( ctx ); gammaDDInitTriFuncs( ctx ); gammaDDInitState( gmesa ); gammaInitTextureObjects( ctx ); driContextPriv->driverPrivate = (void *)gmesa; GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext, 1, &gmesa->bufIndex, &gmesa->bufSize, &gmesa->buf, &gmesa->bufCount, gammascrn); #ifdef DO_VALIDATE GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext, 1, &gmesa->WCbufIndex, &gmesa->WCbufSize, &gmesa->WCbuf, &gmesa->WCbufCount, gammascrn); #endif switch (glVisual->depthBits) { case 16: gmesa->DeltaMode = DM_Depth16; gmesa->depth_scale = 1.0f / 0xffff; break; case 24: gmesa->DeltaMode = DM_Depth24; gmesa->depth_scale = 1.0f / 0xffffff; break; case 32: gmesa->DeltaMode = DM_Depth32; gmesa->depth_scale = 1.0f / 0xffffffff; break; default: break; } gmesa->DepthSize = glVisual->depthBits; gmesa->Flags = GAMMA_FRONT_BUFFER; gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0); gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0); gmesa->EnabledFlags = GAMMA_FRONT_BUFFER; gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0); if (gmesa->Flags & GAMMA_BACK_BUFFER) { gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp; } else { gmesa->readOffset = gmesa->drawOffset = 0; } gammaInitHW( gmesa ); driContextPriv->driverPrivate = (void *)gmesa; return GL_TRUE; }
/* Create the device specific context. */ GLboolean r128CreateContext( const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate ) { GLcontext *ctx, *shareCtx; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; r128ContextPtr rmesa; r128ScreenPtr r128scrn; int i; /* Allocate the r128 context */ rmesa = (r128ContextPtr) CALLOC( sizeof(*rmesa) ); if ( !rmesa ) return GL_FALSE; /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((r128ContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE); if (!rmesa->glCtx) { FREE(rmesa); return GL_FALSE; } driContextPriv->driverPrivate = rmesa; ctx = rmesa->glCtx; rmesa->driContext = driContextPriv; rmesa->driScreen = sPriv; rmesa->driDrawable = NULL; rmesa->hHWContext = driContextPriv->hHWContext; rmesa->driHwLock = &sPriv->pSAREA->lock; rmesa->driFd = sPriv->fd; r128scrn = rmesa->r128Screen = (r128ScreenPtr)(sPriv->private); rmesa->sarea = (R128SAREAPrivPtr)((char *)sPriv->pSAREA + r128scrn->sarea_priv_offset); rmesa->CurrentTexObj[0] = NULL; rmesa->CurrentTexObj[1] = NULL; (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) ); make_empty_list( & rmesa->swapped ); rmesa->nr_heaps = r128scrn->numTexHeaps; for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa, r128scrn->texSize[i], 12, R128_NR_TEX_REGIONS, rmesa->sarea->texList[i], & rmesa->sarea->texAge[i], & rmesa->swapped, sizeof( r128TexObj ), (destroy_texture_object_t *) r128DestroyTexObj ); driSetTextureSwapCounterLocation( rmesa->texture_heaps[i], & rmesa->c_textureSwaps ); } rmesa->RenderIndex = -1; /* Impossible value */ rmesa->vert_buf = NULL; rmesa->num_verts = 0; /* Set the maximum texture size small enough that we can guarentee that * all texture units can bind a maximal texture and have them both in * texturable memory at once. */ ctx->Const.MaxTextureUnits = 2; driCalculateMaxTextureLevels( rmesa->texture_heaps, rmesa->nr_heaps, & ctx->Const, 4, 10, /* max 2D texture size is 1024x1024 */ 0, /* 3D textures unsupported. */ 0, /* cube textures unsupported. */ 0, /* texture rectangles unsupported. */ 11, GL_FALSE ); /* No wide points. */ ctx->Const.MinPointSize = 1.0; ctx->Const.MinPointSizeAA = 1.0; ctx->Const.MaxPointSize = 1.0; ctx->Const.MaxPointSizeAA = 1.0; /* No wide lines. */ ctx->Const.MinLineWidth = 1.0; ctx->Const.MinLineWidthAA = 1.0; ctx->Const.MaxLineWidth = 1.0; ctx->Const.MaxLineWidthAA = 1.0; ctx->Const.LineWidthGranularity = 1.0; #if ENABLE_PERF_BOXES rmesa->boxes = (getenv( "LIBGL_PERFORMANCE_BOXES" ) != NULL); #endif /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); /* Install the customized pipeline: */ /* _tnl_destroy_pipeline( ctx ); */ /* _tnl_install_pipeline( ctx, r128_pipeline ); */ /* Configure swrast to match hardware characteristics: */ _swrast_allow_pixel_fog( ctx, GL_FALSE ); _swrast_allow_vertex_fog( ctx, GL_TRUE ); driInitExtensions( ctx, card_extensions, GL_TRUE ); if (sPriv->drmMinor >= 4) _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" ); r128InitVB( ctx ); r128InitTriFuncs( ctx ); r128DDInitDriverFuncs( ctx ); r128DDInitIoctlFuncs( ctx ); r128DDInitStateFuncs( ctx ); r128DDInitSpanFuncs( ctx ); r128DDInitTextureFuncs( ctx ); r128DDInitState( rmesa ); rmesa->do_irqs = (rmesa->r128Screen->irq && !getenv("R128_NO_IRQS")); rmesa->vblank_flags = (rmesa->r128Screen->irq != 0) ? driGetDefaultVBlankFlags() : VBLANK_FLAG_NO_IRQ; driContextPriv->driverPrivate = (void *)rmesa; #if DO_DEBUG R128_DEBUG = driParseDebugString( getenv( "R128_DEBUG" ), debug_control ); #endif return GL_TRUE; }
/* Create the device specific context. */ GLboolean radeonCreateContext( const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate) { __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private); radeonContextPtr rmesa; GLcontext *ctx, *shareCtx; int i; assert(glVisual); assert(driContextPriv); assert(screen); /* Allocate the Radeon context */ rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) ); if ( !rmesa ) return GL_FALSE; /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE); if (!rmesa->glCtx) { FREE(rmesa); return GL_FALSE; } driContextPriv->driverPrivate = rmesa; /* Init radeon context data */ rmesa->dri.context = driContextPriv; rmesa->dri.screen = sPriv; rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */ rmesa->dri.hwContext = driContextPriv->hHWContext; rmesa->dri.hwLock = &sPriv->pSAREA->lock; rmesa->dri.fd = sPriv->fd; rmesa->dri.drmMinor = sPriv->drmMinor; rmesa->radeonScreen = screen; rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA + screen->sarea_priv_offset); rmesa->dma.buf0_address = rmesa->radeonScreen->buffers->list[0].address; (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) ); make_empty_list( & rmesa->swapped ); rmesa->nr_heaps = screen->numTexHeaps; for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa, screen->texSize[i], 12, RADEON_NR_TEX_REGIONS, rmesa->sarea->texList[i], & rmesa->sarea->texAge[i], & rmesa->swapped, sizeof( radeonTexObj ), (destroy_texture_object_t *) radeonDestroyTexObj ); driSetTextureSwapCounterLocation( rmesa->texture_heaps[i], & rmesa->c_textureSwaps ); } rmesa->swtcl.RenderIndex = ~0; rmesa->lost_context = 1; /* Set the maximum texture size small enough that we can guarentee that * all texture units can bind a maximal texture and have them both in * texturable memory at once. */ ctx = rmesa->glCtx; ctx->Const.MaxTextureUnits = 2; driCalculateMaxTextureLevels( rmesa->texture_heaps, rmesa->nr_heaps, & ctx->Const, 4, 11, /* max 2D texture size is 2048x2048 */ 0, /* 3D textures unsupported. */ 0, /* cube textures unsupported. */ 11, /* max rect texture size is 2048x2048. */ 12, GL_FALSE ); ctx->Const.MaxTextureMaxAnisotropy = 16.0; /* No wide points. */ ctx->Const.MinPointSize = 1.0; ctx->Const.MinPointSizeAA = 1.0; ctx->Const.MaxPointSize = 1.0; ctx->Const.MaxPointSizeAA = 1.0; ctx->Const.MinLineWidth = 1.0; ctx->Const.MinLineWidthAA = 1.0; ctx->Const.MaxLineWidth = 10.0; ctx->Const.MaxLineWidthAA = 10.0; ctx->Const.LineWidthGranularity = 0.0625; /* Set maxlocksize (and hence vb size) small enough to avoid * fallbacks in radeon_tcl.c. ie. guarentee that all vertices can * fit in a single dma buffer for indexed rendering of quad strips, * etc. */ ctx->Const.MaxArrayLockSize = MIN2( ctx->Const.MaxArrayLockSize, RADEON_BUFFER_SIZE / RADEON_MAX_TCL_VERTSIZE ); rmesa->boxes = (getenv("LIBGL_PERFORMANCE_BOXES") != NULL); /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); _ae_create_context( ctx ); /* Install the customized pipeline: */ _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, radeon_pipeline ); ctx->Driver.FlushVertices = radeonFlushVertices; /* Try and keep materials and vertices separate: */ _tnl_isolate_materials( ctx, GL_TRUE ); /* _mesa_allow_light_in_model( ctx, GL_FALSE ); */ /* Try and keep materials and vertices separate: */ _tnl_isolate_materials( ctx, GL_TRUE ); /* Configure swrast to match hardware characteristics: */ _swrast_allow_pixel_fog( ctx, GL_FALSE ); _swrast_allow_vertex_fog( ctx, GL_TRUE ); _math_matrix_ctr( &rmesa->TexGenMatrix[0] ); _math_matrix_ctr( &rmesa->TexGenMatrix[1] ); _math_matrix_ctr( &rmesa->tmpmat ); _math_matrix_set_identity( &rmesa->TexGenMatrix[0] ); _math_matrix_set_identity( &rmesa->TexGenMatrix[1] ); _math_matrix_set_identity( &rmesa->tmpmat ); driInitExtensions( ctx, card_extensions, GL_TRUE ); if (rmesa->dri.drmMinor >= 9) _mesa_enable_extension( ctx, "GL_NV_texture_rectangle"); radeonInitDriverFuncs( ctx ); radeonInitIoctlFuncs( ctx ); radeonInitStateFuncs( ctx ); radeonInitSpanFuncs( ctx ); radeonInitTextureFuncs( ctx ); radeonInitState( rmesa ); radeonInitSwtcl( ctx ); rmesa->iw.irq_seq = -1; rmesa->irqsEmitted = 0; rmesa->do_irqs = (rmesa->radeonScreen->irq && !getenv("RADEON_NO_IRQS")); rmesa->do_usleeps = !getenv("RADEON_NO_USLEEPS"); rmesa->vblank_flags = (rmesa->radeonScreen->irq != 0) ? driGetDefaultVBlankFlags() : VBLANK_FLAG_NO_IRQ; rmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" ); if ( rmesa->get_ust == NULL ) { rmesa->get_ust = get_ust_nop; } (*rmesa->get_ust)( & rmesa->swap_ust ); #if DO_DEBUG RADEON_DEBUG = driParseDebugString( getenv( "RADEON_DEBUG" ), debug_control ); #endif if (getenv("RADEON_NO_RAST")) { fprintf(stderr, "disabling 3D acceleration\n"); FALLBACK(rmesa, RADEON_FALLBACK_DISABLE, 1); } else if (getenv("RADEON_TCL_FORCE_ENABLE")) { fprintf(stderr, "Enabling TCL support... this will probably crash\n"); fprintf(stderr, " your card if it isn't capable of TCL!\n"); rmesa->radeonScreen->chipset |= RADEON_CHIPSET_TCL; } else if (getenv("RADEON_TCL_FORCE_DISABLE") || !(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)) { rmesa->radeonScreen->chipset &= ~RADEON_CHIPSET_TCL; fprintf(stderr, "disabling TCL support\n"); TCL_FALLBACK(rmesa->glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1); } if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) { if (!getenv("RADEON_NO_VTXFMT")) radeonVtxfmtInit( ctx ); _tnl_need_dlist_norm_lengths( ctx, GL_FALSE ); } return GL_TRUE; }
GLboolean sisCreateContext( const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate ) { GLcontext *ctx, *shareCtx; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; sisContextPtr smesa; sisScreenPtr sisScreen; int i; struct dd_function_table functions; smesa = (sisContextPtr)CALLOC( sizeof(*smesa) ); if (smesa == NULL) return GL_FALSE; /* Init default driver functions then plug in our SIS-specific functions * (the texture functions are especially important) */ _mesa_init_driver_functions(&functions); sisInitDriverFuncs(&functions); sisInitTextureFuncs(&functions); /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((sisContextPtr)sharedContextPrivate)->glCtx; else shareCtx = NULL; smesa->glCtx = _mesa_create_context( glVisual, shareCtx, &functions, (void *) smesa); if (!smesa->glCtx) { FREE(smesa); return GL_FALSE; } driContextPriv->driverPrivate = smesa; ctx = smesa->glCtx; sisScreen = smesa->sisScreen = (sisScreenPtr)(sPriv->private); smesa->driContext = driContextPriv; smesa->driScreen = sPriv; smesa->driDrawable = NULL; smesa->hHWContext = driContextPriv->hHWContext; smesa->driHwLock = &sPriv->pSAREA->lock; smesa->driFd = sPriv->fd; smesa->virtualX = sisScreen->screenX; smesa->virtualY = sisScreen->screenY; smesa->bytesPerPixel = sisScreen->cpp; smesa->IOBase = sisScreen->mmio.map; smesa->Chipset = sisScreen->deviceID; smesa->irqEnabled = sisScreen->irqEnabled; smesa->FbBase = sPriv->pFB; smesa->displayWidth = sPriv->fbWidth; smesa->frontPitch = sPriv->fbStride; smesa->sarea = (SISSAREAPriv *)((char *)sPriv->pSAREA + sisScreen->sarea_priv_offset); #if defined(SIS_DUMP) IOBase4Debug = GET_IOBase (smesa); #endif /* support ARGB8888 and RGB565 */ switch (smesa->bytesPerPixel) { case 4: smesa->redMask = 0x00ff0000; smesa->greenMask = 0x0000ff00; smesa->blueMask = 0x000000ff; smesa->alphaMask = 0xff000000; smesa->colorFormat = DST_FORMAT_ARGB_8888; break; case 2: smesa->redMask = 0xf800; smesa->greenMask = 0x07e0; smesa->blueMask = 0x001f; smesa->alphaMask = 0; smesa->colorFormat = DST_FORMAT_RGB_565; break; default: sis_fatal_error("Bad bytesPerPixel.\n"); } /* Parse configuration files */ driParseConfigFiles (&smesa->optionCache, &sisScreen->optionCache, sisScreen->driScreen->myNum, "sis"); /* TODO: index mode */ smesa->CurrentQueueLenPtr = &(smesa->sarea->QueueLength); smesa->FrameCountPtr = &(smesa->sarea->FrameCount); /* set AGP */ smesa->AGPSize = sisScreen->agp.size; smesa->AGPBase = sisScreen->agp.map; smesa->AGPAddr = sisScreen->agp.handle; /* Create AGP command buffer */ if (smesa->AGPSize != 0 && !driQueryOptionb(&smesa->optionCache, "agp_disable")) { smesa->vb = sisAllocAGP(smesa, 64 * 1024, &smesa->vb_agp_handle); if (smesa->vb != NULL) { smesa->using_agp = GL_TRUE; smesa->vb_cur = smesa->vb; smesa->vb_last = smesa->vb; smesa->vb_end = smesa->vb + 64 * 1024; smesa->vb_agp_offset = ((long)smesa->vb - (long)smesa->AGPBase + (long)smesa->AGPAddr); } } if (!smesa->using_agp) { smesa->vb = malloc(64 * 1024); if (smesa->vb == NULL) { FREE(smesa); return GL_FALSE; } smesa->vb_cur = smesa->vb; smesa->vb_last = smesa->vb; smesa->vb_end = smesa->vb + 64 * 1024; } smesa->GlobalFlag = 0L; smesa->Fallback = 0; /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); _swrast_allow_pixel_fog( ctx, GL_TRUE ); _swrast_allow_vertex_fog( ctx, GL_FALSE ); _tnl_allow_pixel_fog( ctx, GL_TRUE ); _tnl_allow_vertex_fog( ctx, GL_FALSE ); /* XXX these should really go right after _mesa_init_driver_functions() */ sisDDInitStateFuncs( ctx ); sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */ sisInitTriFuncs( ctx ); sisDDInitSpanFuncs( ctx ); sisDDInitStencilFuncs( ctx ); driInitExtensions( ctx, card_extensions, GL_FALSE ); /* TODO */ /* smesa->blockWrite = SGRAMbw = IsBlockWrite (); */ smesa->blockWrite = GL_FALSE; for (i = 0; i < SIS_MAX_TEXTURES; i++) { smesa->TexStates[i] = 0; smesa->PrevTexFormat[i] = 0; } return GL_TRUE; }