From 95328c7cf91322813de846a72f157aefff9417a6 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 22 Oct 2009 17:18:01 -0400 Subject: [PATCH] r600: clean up context creation Make it more consistent with other radeon drivers. --- src/mesa/drivers/dri/r600/r600_context.c | 208 +++++++++++------------ 1 file changed, 103 insertions(+), 105 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index ba0d450cbb2..9776a868ff3 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -213,69 +213,9 @@ static void r600_init_vtbl(radeonContextPtr radeon) radeon->vtbl.fallback = r600_fallback; } -/* Create the device specific rendering context. - */ -GLboolean r600CreateContext(const __GLcontextModes * glVisual, - __DRIcontextPrivate * driContextPriv, - void *sharedContextPrivate) +static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) { - __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; - radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private); - struct dd_function_table functions; - context_t *r600; - GLcontext *ctx; - - assert(glVisual); - assert(driContextPriv); - assert(screen); - - /* Allocate the R600 context */ - r600 = (context_t*) CALLOC(sizeof(*r600)); - if (!r600) { - radeon_error("Failed to allocate memory for context.\n"); - return GL_FALSE; - } - - if (!(screen->chip_flags & RADEON_CHIPSET_TCL)) - hw_tcl_on = future_hw_tcl_on = 0; - - r600_init_vtbl(&r600->radeon); - /* Parse configuration files. - * Do this here so that initialMaxAnisotropy is set before we create - * the default textures. - */ - driParseConfigFiles(&r600->radeon.optionCache, &screen->optionCache, - screen->driScreen->myNum, "r600"); - - r600->radeon.initialMaxAnisotropy = driQueryOptionf(&r600->radeon.optionCache, - "def_max_anisotropy"); - - /* Init default driver functions then plug in our R600-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions(&functions); - - r700InitStateFuncs(&functions); - r600InitTextureFuncs(&functions); - r700InitShaderFuncs(&functions); - r700InitIoctlFuncs(&functions); - radeonInitBufferObjectFuncs(&functions); - - if (!radeonInitContext(&r600->radeon, &functions, - glVisual, driContextPriv, - sharedContextPrivate)) { - radeon_error("Initializing context failed.\n"); - FREE(r600); - return GL_FALSE; - } - - /* Init r600 context data */ - /* 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 = r600->radeon.glCtx; + context_t *r600 = R700_CONTEXT(ctx); ctx->Const.MaxTextureImageUnits = driQueryOptioni(&r600->radeon.optionCache, "texture_image_units"); @@ -300,38 +240,7 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual, ctx->Const.MaxLineWidth = 0xffff / 8.0; ctx->Const.MaxLineWidthAA = 0xffff / 8.0; - /* Needs further modifications */ -#if 0 - ctx->Const.MaxArrayLockSize = - ( /*512 */ RADEON_BUFFER_SIZE * 16 * 1024) / (4 * 4); -#endif - - ctx->Const.MaxDrawBuffers = 1; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext(ctx); - _vbo_CreateContext(ctx); - _tnl_CreateContext(ctx); - _swsetup_CreateContext(ctx); - _swsetup_Wakeup(ctx); - _ae_create_context(ctx); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline(ctx); - _tnl_install_pipeline(ctx, r700_pipeline); - - /* Try and keep materials and vertices separate: - */ -/* _tnl_isolate_materials(ctx, GL_TRUE); */ - - /* Configure swrast and 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); + ctx->Const.MaxDrawBuffers = 1; /* hw supports 8 */ /* 256 for reg-based consts, inline consts also supported */ ctx->Const.VertexProgram.MaxInstructions = 8192; /* in theory no limit */ @@ -355,10 +264,25 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual, ctx->Const.FragmentProgram.MaxNativeInstructions = 8192; ctx->Const.FragmentProgram.MaxNativeTexIndirections = 8; /* ??? */ ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* and these are?? */ - ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; - ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; +} - radeon_init_debug(); +static void r600ParseOptions(context_t *r600, radeonScreenPtr screen) +{ + /* Parse configuration files. + * Do this here so that initialMaxAnisotropy is set before we create + * the default textures. + */ + driParseConfigFiles(&r600->radeon.optionCache, &screen->optionCache, + screen->driScreen->myNum, "r600"); + + r600->radeon.initialMaxAnisotropy = driQueryOptionf(&r600->radeon.optionCache, + "def_max_anisotropy"); + +} + +static void r600InitGLExtensions(GLcontext *ctx) +{ + context_t *r600 = R700_CONTEXT(ctx); driInitExtensions(ctx, card_extensions, GL_TRUE); if (r600->radeon.radeonScreen->kernel_mm) @@ -377,21 +301,95 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual, { _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); } +} - r700InitDraw(ctx); +/* Create the device specific rendering context. + */ +GLboolean r600CreateContext(const __GLcontextModes * glVisual, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate) +{ + __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; + radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private); + struct dd_function_table functions; + context_t *r600; + GLcontext *ctx; + + assert(glVisual); + assert(driContextPriv); + assert(screen); + + /* Allocate the R600 context */ + r600 = (context_t*) CALLOC(sizeof(*r600)); + if (!r600) { + radeon_error("Failed to allocate memory for context.\n"); + return GL_FALSE; + } + + r600ParseOptions(r600, screen); + + r600->radeon.radeonScreen = screen; + r600_init_vtbl(&r600->radeon); + + /* Init default driver functions then plug in our R600-specific functions + * (the texture functions are especially important) + */ + _mesa_init_driver_functions(&functions); + + r700InitStateFuncs(&functions); + r600InitTextureFuncs(&functions); + r700InitShaderFuncs(&functions); + r700InitIoctlFuncs(&functions); + radeonInitBufferObjectFuncs(&functions); + + if (!radeonInitContext(&r600->radeon, &functions, + glVisual, driContextPriv, + sharedContextPrivate)) { + radeon_error("Initializing context failed.\n"); + FREE(r600); + return GL_FALSE; + } + + ctx = r600->radeon.glCtx; + + ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; + ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; + + r600InitConstValues(ctx, screen); + + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + + /* Initialize the software rasterizer and helper modules. + */ + _swrast_CreateContext(ctx); + _vbo_CreateContext(ctx); + _tnl_CreateContext(ctx); + _swsetup_CreateContext(ctx); + _swsetup_Wakeup(ctx); + + /* Install the customized pipeline: + */ + _tnl_destroy_pipeline(ctx); + _tnl_install_pipeline(ctx, r700_pipeline); + TNL_CONTEXT(ctx)->Driver.RunPipeline = r600RunPipeline; + + /* Configure swrast and 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); + + radeon_init_debug(); + + r700InitDraw(ctx); radeon_fbo_init(&r600->radeon); radeonInitSpanFuncs( ctx ); - r600InitCmdBuf(r600); - r700InitState(r600->radeon.glCtx); - TNL_CONTEXT(ctx)->Driver.RunPipeline = r600RunPipeline; - - if (driQueryOptionb(&r600->radeon.optionCache, "no_rast")) { - radeon_warning("disabling 3D acceleration\n"); - } + r600InitGLExtensions(ctx); return GL_TRUE; }