📄 mga_xmesa.c
字号:
fprintf(stderr, "mgaDestroyScreen\n"); drmUnmapBufs(mgaScreen->bufs); /* free all option information */ driDestroyOptionInfo (&mgaScreen->optionCache); FREE(mgaScreen); sPriv->private = NULL;}extern const struct tnl_pipeline_stage _mga_render_stage;static const struct tnl_pipeline_stage *mga_pipeline[] = { &_tnl_vertex_transform_stage, &_tnl_normal_transform_stage, &_tnl_lighting_stage, &_tnl_fog_coordinate_stage, &_tnl_texgen_stage, &_tnl_texture_transform_stage, &_tnl_vertex_program_stage, /* REMOVE: point attenuation stage */#if 0 &_mga_render_stage, /* ADD: unclipped rastersetup-to-dma */ /* Need new ioctl for wacceptseq */#endif &_tnl_render_stage, 0,};static const struct dri_extension g400_extensions[] ={ { "GL_ARB_multitexture", NULL }, { "GL_ARB_texture_env_add", NULL }, { "GL_ARB_texture_env_combine", NULL }, { "GL_ARB_texture_env_crossbar", NULL }, { "GL_EXT_texture_env_combine", NULL }, { "GL_EXT_texture_edge_clamp", NULL }, { "GL_ATI_texture_env_combine3", NULL }, { NULL, NULL }};static const struct dri_extension card_extensions[] ={ { "GL_ARB_multisample", GL_ARB_multisample_functions }, { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, { "GL_ARB_texture_rectangle", NULL }, { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, { "GL_EXT_blend_logic_op", NULL }, { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions }, /* paletted_textures currently doesn't work, but we could fix them later */#if defined( need_GL_EXT_paletted_texture ) { "GL_EXT_shared_texture_palette", NULL }, { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions },#endif { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, { "GL_EXT_stencil_wrap", NULL }, { "GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions }, { "GL_MESA_ycbcr_texture", NULL }, { "GL_SGIS_generate_mipmap", NULL }, { NULL, NULL }};static const struct dri_extension ARB_vp_extensions[] = { { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions }, { NULL, NULL }};static const struct dri_extension NV_vp_extensions[] = { { "GL_NV_vertex_program", GL_NV_vertex_program_functions }, { "GL_NV_vertex_program1_1", NULL }, { NULL, NULL }};static const struct dri_debug_control debug_control[] ={ { "fall", DEBUG_VERBOSE_FALLBACK }, { "tex", DEBUG_VERBOSE_TEXTURE }, { "ioctl", DEBUG_VERBOSE_IOCTL }, { "verb", DEBUG_VERBOSE_MSG }, { "dri", DEBUG_VERBOSE_DRI }, { NULL, 0 }};static GLbooleanmgaCreateContext( const __GLcontextModes *mesaVis, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate ){ int i; unsigned maxlevels; GLcontext *ctx, *shareCtx; mgaContextPtr mmesa; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private; drm_mga_sarea_t *saPriv = (drm_mga_sarea_t *)(((char*)sPriv->pSAREA)+ mgaScreen->sarea_priv_offset); struct dd_function_table functions; if (MGA_DEBUG&DEBUG_VERBOSE_DRI) fprintf(stderr, "mgaCreateContext\n"); /* allocate mga context */ mmesa = (mgaContextPtr) CALLOC(sizeof(mgaContext)); if (!mmesa) { return GL_FALSE; } /* Init default driver functions then plug in our Radeon-specific functions * (the texture functions are especially important) */ _mesa_init_driver_functions( &functions ); mgaInitDriverFuncs( &functions ); mgaInitTextureFuncs( &functions ); mgaInitIoctlFuncs( &functions ); /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((mgaContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, &functions, (void *) mmesa); if (!mmesa->glCtx) { FREE(mmesa); return GL_FALSE; } driContextPriv->driverPrivate = mmesa; /* Init mga state */ mmesa->hHWContext = driContextPriv->hHWContext; mmesa->driFd = sPriv->fd; mmesa->driHwLock = &sPriv->pSAREA->lock; mmesa->mgaScreen = mgaScreen; mmesa->driScreen = sPriv; mmesa->sarea = (void *)saPriv; /* Parse configuration files */ driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache, sPriv->myNum, "mga"); (void) memset( mmesa->texture_heaps, 0, sizeof( mmesa->texture_heaps ) ); make_empty_list( & mmesa->swapped ); mmesa->nr_heaps = mgaScreen->texVirtual[MGA_AGP_HEAP] ? 2 : 1; for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) { mmesa->texture_heaps[i] = driCreateTextureHeap( i, mmesa, mgaScreen->textureSize[i], 6, MGA_NR_TEX_REGIONS, (drmTextureRegionPtr)mmesa->sarea->texList[i], &mmesa->sarea->texAge[i], &mmesa->swapped, sizeof( mgaTextureObject_t ), (destroy_texture_object_t *) mgaDestroyTexObj ); } /* Set the maximum texture size small enough that we can guarentee * that both texture units can bind a maximal texture and have them * on the card at once. */ ctx = mmesa->glCtx; if ( mgaScreen->chipset == MGA_CARD_TYPE_G200 ) { ctx->Const.MaxTextureUnits = 1; ctx->Const.MaxTextureImageUnits = 1; ctx->Const.MaxTextureCoordUnits = 1; maxlevels = G200_TEX_MAXLEVELS; } else { ctx->Const.MaxTextureUnits = 2; ctx->Const.MaxTextureImageUnits = 2; ctx->Const.MaxTextureCoordUnits = 2; maxlevels = G400_TEX_MAXLEVELS; } driCalculateMaxTextureLevels( mmesa->texture_heaps, mmesa->nr_heaps, & ctx->Const, 4, 11, /* max 2D texture size is 2048x2048 */ 0, /* 3D textures unsupported. */ 0, /* cube textures unsupported. */ 11, /* max texture rect size is 2048x2048 */ maxlevels, GL_FALSE, 0 ); ctx->Const.MinLineWidth = 1.0; ctx->Const.MinLineWidthAA = 1.0; ctx->Const.MaxLineWidth = 10.0; ctx->Const.MaxLineWidthAA = 10.0; ctx->Const.LineWidthGranularity = 1.0; mmesa->texture_depth = driQueryOptioni (&mmesa->optionCache, "texture_depth"); if (mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB) mmesa->texture_depth = ( mesaVis->rgbBits >= 24 ) ? DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16; mmesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24; switch (mesaVis->depthBits) { case 16: mmesa->depth_scale = 1.0/(GLdouble)0xffff; mmesa->depth_clear_mask = ~0; mmesa->ClearDepth = 0xffff; break; case 24: mmesa->depth_scale = 1.0/(GLdouble)0xffffff; if (mmesa->hw_stencil) { mmesa->depth_clear_mask = 0xffffff00; mmesa->stencil_clear_mask = 0x000000ff; } else mmesa->depth_clear_mask = ~0; mmesa->ClearDepth = 0xffffff00; break; case 32: mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; mmesa->depth_clear_mask = ~0; mmesa->ClearDepth = 0xffffffff; break; }; mmesa->haveHwStipple = GL_FALSE; mmesa->RenderIndex = -1; /* impossible value */ mmesa->dirty = ~0; mmesa->vertex_format = 0; mmesa->CurrentTexObj[0] = 0; mmesa->CurrentTexObj[1] = 0; mmesa->tmu_source[0] = 0; mmesa->tmu_source[1] = 1; mmesa->texAge[0] = 0; mmesa->texAge[1] = 0; /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _vbo_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); /* Install the customized pipeline: */ _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, mga_pipeline ); /* Configure swrast and T&L 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 ); mmesa->primary_offset = mmesa->mgaScreen->primary.handle; ctx->DriverCtx = (void *) mmesa; mmesa->glCtx = ctx; driInitExtensions( ctx, card_extensions, GL_FALSE ); if (MGA_IS_G400(MGA_CONTEXT(ctx))) { driInitExtensions( ctx, g400_extensions, GL_FALSE ); } if ( driQueryOptionb( &mmesa->optionCache, "arb_vertex_program" ) ) { driInitExtensions(ctx, ARB_vp_extensions, GL_FALSE); } if ( driQueryOptionb( &mmesa->optionCache, "nv_vertex_program" ) ) { driInitExtensions( ctx, NV_vp_extensions, GL_FALSE ); } /* XXX these should really go right after _mesa_init_driver_functions() */ mgaDDInitStateFuncs( ctx ); mgaDDInitSpanFuncs( ctx ); mgaDDInitPixelFuncs( ctx ); mgaDDInitTriFuncs( ctx ); mgaInitVB( ctx ); mgaInitState( mmesa ); driContextPriv->driverPrivate = (void *) mmesa;#if DO_DEBUG MGA_DEBUG = driParseDebugString( getenv( "MGA_DEBUG" ), debug_control );#endif (*sPriv->systemTime->getUST)( & mmesa->swap_ust ); if (driQueryOptionb(&mmesa->optionCache, "no_rast")) { fprintf(stderr, "disabling 3D acceleration\n"); FALLBACK(mmesa->glCtx, MGA_FALLBACK_DISABLE, 1); } return GL_TRUE;}static voidmgaDestroyContext(__DRIcontextPrivate *driContextPriv){ mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; if (MGA_DEBUG&DEBUG_VERBOSE_DRI) fprintf( stderr, "[%s:%d] mgaDestroyContext start\n", __FILE__, __LINE__ ); assert(mmesa); /* should never be null */ if (mmesa) { GLboolean release_texture_heaps; release_texture_heaps = (mmesa->glCtx->Shared->RefCount == 1); _swsetup_DestroyContext( mmesa->glCtx ); _tnl_DestroyContext( mmesa->glCtx ); _vbo_DestroyContext( mmesa->glCtx ); _swrast_DestroyContext( mmesa->glCtx ); mgaFreeVB( mmesa->glCtx ); /* free the Mesa context */ mmesa->glCtx->DriverCtx = NULL; _mesa_destroy_context(mmesa->glCtx); if ( release_texture_heaps ) { /* This share group is about to go away, free our private * texture object data. */ int i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -