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; }
GLboolean s3vCreateContext(const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate) { GLcontext *ctx, *shareCtx; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; s3vContextPtr vmesa; s3vScreenPtr s3vScrn; S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) + sizeof(drm_sarea_t)); struct dd_function_table functions; DEBUG_WHERE(("*** s3vCreateContext ***\n")); vmesa = (s3vContextPtr) CALLOC( sizeof(*vmesa) ); if ( !vmesa ) return GL_FALSE; /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((s3vContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; _mesa_init_driver_functions(&functions); vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions, (void *)vmesa); if (!vmesa->glCtx) { FREE(vmesa); return GL_FALSE; } vmesa->driContext = driContextPriv; vmesa->driScreen = sPriv; vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */ vmesa->hHWContext = driContextPriv->hHWContext; vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock; vmesa->driFd = sPriv->fd; vmesa->sarea = saPriv; s3vScrn = vmesa->s3vScreen = (s3vScreenPtr)(sPriv->private); ctx = vmesa->glCtx; ctx->Const.MaxTextureLevels = 11; /* it is (11-1) -> 1024 * 1024 FIXME */ ctx->Const.MaxTextureUnits = 1; /* FIXME: or 2 ? */ /* 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; ctx->Const.MaxDrawBuffers = 1; vmesa->texHeap = mmInit( 0, vmesa->s3vScreen->textureSize ); DEBUG(("vmesa->s3vScreen->textureSize = 0x%x\n", vmesa->s3vScreen->textureSize)); /* NOTE */ /* mmInit(offset, size); */ /* allocates a structure like this: struct mem_block_t { struct mem_block_t *next; struct mem_block_t *heap; int ofs,size; int align; int free:1; int reserved:1; }; */ make_empty_list(&vmesa->TexObjList); make_empty_list(&vmesa->SwappedOut); vmesa->CurrentTexObj[0] = 0; vmesa->CurrentTexObj[1] = 0; /* FIXME */ vmesa->RenderIndex = ~0; /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _vbo_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); /* Install the customized pipeline: */ #if 0 _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, s3v_pipeline ); #endif /* Configure swrast to match hardware characteristics: */ #if 0 _swrast_allow_pixel_fog( ctx, GL_FALSE ); _swrast_allow_vertex_fog( ctx, GL_TRUE ); #endif vmesa->_3d_mode = 0; /* 3D lines / gouraud tris */ vmesa->CMD = ( AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555 | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF | Z_LESS | TEX_WRAP_ON | TEX_MODULATE | LINEAR | TEX_COL_ARGB1555 | CMD_3D ); vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF; vmesa->alpha_cmd = vmesa->_alpha[0]; vmesa->_tri[0] = DO_GOURAUD_TRI; vmesa->_tri[1] = DO_TEX_LIT_TRI; vmesa->prim_cmd = vmesa->_tri[0]; /* printf("first vmesa->CMD = 0x%x\n", vmesa->CMD); */ vmesa->TexOffset = vmesa->s3vScreen->texOffset; s3vInitVB( ctx ); s3vInitExtensions( ctx ); s3vInitDriverFuncs( ctx ); s3vInitStateFuncs( ctx ); s3vInitSpanFuncs( ctx ); s3vInitTextureFuncs( ctx ); s3vInitTriFuncs( ctx ); s3vInitState( vmesa ); driContextPriv->driverPrivate = (void *)vmesa; /* HACK */ vmesa->bufSize = S3V_DMA_BUF_SZ; DEBUG(("vmesa->bufSize = %i\n", vmesa->bufSize)); DEBUG(("vmesa->bufCount = %i\n", vmesa->bufCount)); /* dma init */ DEBUG_BUFS(("GET_FIRST_DMA\n")); vmesa->_bufNum = 0; GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext, 1, &(vmesa->bufIndex[0]), &(vmesa->bufSize), &vmesa->_buf[0], &vmesa->bufCount, s3vScrn); GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext, 1, &(vmesa->bufIndex[1]), &(vmesa->bufSize), &vmesa->_buf[1], &vmesa->bufCount, s3vScrn); vmesa->buf = vmesa->_buf[vmesa->_bufNum]; /* vmesa->CMD = (AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555 | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF | DO_GOURAUD_TRI | CMD_3D); vmesa->TexOffset = vmesa->s3vScreen->texOffset; */ /* ... but we should support only 15 bit in virge (out of 8/15/24)... */ DEBUG(("glVisual->depthBits = %i\n", glVisual->depthBits)); switch (glVisual->depthBits) { case 8: break; case 15: case 16: vmesa->depth_scale = 1.0f / 0xffff; break; case 24: vmesa->depth_scale = 1.0f / 0xffffff; break; default: break; } vmesa->cull_zero = 0.0f; vmesa->DepthSize = glVisual->depthBits; vmesa->Flags = S3V_FRONT_BUFFER; vmesa->Flags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0); vmesa->Flags |= (vmesa->DepthSize > 0 ? S3V_DEPTH_BUFFER : 0); vmesa->EnabledFlags = S3V_FRONT_BUFFER; vmesa->EnabledFlags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0); if (vmesa->Flags & S3V_BACK_BUFFER) { vmesa->readOffset = vmesa->drawOffset = vmesa->s3vScreen->backOffset; } else { vmesa->readOffset = vmesa->drawOffset = 0; } s3vInitHW( vmesa ); driContextPriv->driverPrivate = (void *)vmesa; return GL_TRUE; }