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

📄 r300_context.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
	    driQueryOptioni(&r300->radeon.optionCache, "texture_image_units");	ctx->Const.MaxTextureCoordUnits =	    driQueryOptioni(&r300->radeon.optionCache, "texture_coord_units");	ctx->Const.MaxTextureUnits =	    MIN2(ctx->Const.MaxTextureImageUnits,		 ctx->Const.MaxTextureCoordUnits);	ctx->Const.MaxTextureMaxAnisotropy = 16.0;	ctx->Const.MaxTextureLodBias = 16.0;	if (screen->chip_family >= CHIP_FAMILY_RV515) {	    ctx->Const.MaxTextureLevels = 13;	    ctx->Const.MaxTextureRectSize = 4096;	}	ctx->Const.MinPointSize = 1.0;	ctx->Const.MinPointSizeAA = 1.0;	ctx->Const.MaxPointSize = R300_POINTSIZE_MAX;	ctx->Const.MaxPointSizeAA = R300_POINTSIZE_MAX;	ctx->Const.MinLineWidth = 1.0;	ctx->Const.MinLineWidthAA = 1.0;	ctx->Const.MaxLineWidth = R300_LINESIZE_MAX;	ctx->Const.MaxLineWidthAA = R300_LINESIZE_MAX;#ifdef USER_BUFFERS	/* Needs further modifications */#if 0	ctx->Const.MaxArrayLockSize =	    ( /*512 */ RADEON_BUFFER_SIZE * 16 * 1024) / (4 * 4);#endif#endif	/* 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, r300_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);	/* currently bogus data */	if (screen->chip_flags & RADEON_CHIPSET_TCL) {	        ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;		ctx->Const.VertexProgram.MaxNativeInstructions =		  VSF_MAX_FRAGMENT_LENGTH / 4;		ctx->Const.VertexProgram.MaxNativeAttribs = 16;	/* r420 */		ctx->Const.VertexProgram.MaxTemps = 32;		ctx->Const.VertexProgram.MaxNativeTemps =		  /*VSF_MAX_FRAGMENT_TEMPS */ 32;		ctx->Const.VertexProgram.MaxNativeParameters = 256;	/* r420 */		ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;	}	ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;	ctx->Const.FragmentProgram.MaxNativeAttribs = 11;	/* copy i915... */	ctx->Const.FragmentProgram.MaxNativeParameters = PFS_NUM_CONST_REGS;	ctx->Const.FragmentProgram.MaxNativeAluInstructions = PFS_MAX_ALU_INST;	ctx->Const.FragmentProgram.MaxNativeTexInstructions = PFS_MAX_TEX_INST;	ctx->Const.FragmentProgram.MaxNativeInstructions =	    PFS_MAX_ALU_INST + PFS_MAX_TEX_INST;	ctx->Const.FragmentProgram.MaxNativeTexIndirections =	    PFS_MAX_TEX_INDIRECT;	ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;	/* and these are?? */	_tnl_ProgramCacheInit(ctx);	ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;	driInitExtensions(ctx, card_extensions, GL_TRUE);	if (driQueryOptionb	    (&r300->radeon.optionCache, "disable_stencil_two_side"))		_mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");	if (r300->radeon.glCtx->Mesa_DXTn	    && !driQueryOptionb(&r300->radeon.optionCache, "disable_s3tc")) {		_mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");		_mesa_enable_extension(ctx, "GL_S3_s3tc");	} else	    if (driQueryOptionb(&r300->radeon.optionCache, "force_s3tc_enable"))	{		_mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");	}	r300->disable_lowimpact_fallback =	    driQueryOptionb(&r300->radeon.optionCache,			    "disable_lowimpact_fallback");	radeonInitSpanFuncs(ctx);	r300InitCmdBuf(r300);	r300InitState(r300);	if (!(screen->chip_flags & RADEON_CHIPSET_TCL))	        r300InitSwtcl(ctx);	TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;	tcl_mode = driQueryOptioni(&r300->radeon.optionCache, "tcl_mode");	if (driQueryOptionb(&r300->radeon.optionCache, "no_rast")) {		fprintf(stderr, "disabling 3D acceleration\n");#if R200_MERGED		FALLBACK(&r300->radeon, RADEON_FALLBACK_DISABLE, 1);#endif	}	if (tcl_mode == DRI_CONF_TCL_SW ||	    !(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {		if (r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {			r300->radeon.radeonScreen->chip_flags &=			    ~RADEON_CHIPSET_TCL;			fprintf(stderr, "Disabling HW TCL support\n");		}		TCL_FALLBACK(r300->radeon.glCtx,			     RADEON_TCL_FALLBACK_TCL_DISABLE, 1);	}	return GL_TRUE;}static void r300FreeGartAllocations(r300ContextPtr r300){	int i, ret, tries = 0, done_age, in_use = 0;	drm_radeon_mem_free_t memfree;	memfree.region = RADEON_MEM_REGION_GART;#ifdef USER_BUFFERS	for (i = r300->rmm->u_last; i > 0; i--) {		if (r300->rmm->u_list[i].ptr == NULL) {			continue;		}		/* check whether this buffer is still in use */		if (r300->rmm->u_list[i].pending) {			in_use++;		}	}	/* Cannot flush/lock if no context exists. */	if (in_use)		r300FlushCmdBuf(r300, __FUNCTION__);	done_age = radeonGetAge((radeonContextPtr) r300);	for (i = r300->rmm->u_last; i > 0; i--) {		if (r300->rmm->u_list[i].ptr == NULL) {			continue;		}		/* check whether this buffer is still in use */		if (!r300->rmm->u_list[i].pending) {			continue;		}		assert(r300->rmm->u_list[i].h_pending == 0);		tries = 0;		while (r300->rmm->u_list[i].age > done_age && tries++ < 1000) {			usleep(10);			done_age = radeonGetAge((radeonContextPtr) r300);		}		if (tries >= 1000) {			WARN_ONCE("Failed to idle region!");		}		memfree.region_offset = (char *)r300->rmm->u_list[i].ptr -		    (char *)r300->radeon.radeonScreen->gartTextures.map;		ret = drmCommandWrite(r300->radeon.radeonScreen->driScreen->fd,				      DRM_RADEON_FREE, &memfree,				      sizeof(memfree));		if (ret) {			fprintf(stderr, "Failed to free at %p\nret = %s\n",				r300->rmm->u_list[i].ptr, strerror(-ret));		} else {			if (i == r300->rmm->u_last)				r300->rmm->u_last--;			r300->rmm->u_list[i].pending = 0;			r300->rmm->u_list[i].ptr = NULL;		}	}	r300->rmm->u_head = i;#endif				/* USER_BUFFERS */}/* Destroy the device specific context. */void r300DestroyContext(__DRIcontextPrivate * driContextPriv){	GET_CURRENT_CONTEXT(ctx);	r300ContextPtr r300 = (r300ContextPtr) driContextPriv->driverPrivate;	radeonContextPtr radeon = (radeonContextPtr) r300;	radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;	if (RADEON_DEBUG & DEBUG_DRI) {		fprintf(stderr, "Destroying context !\n");	}	/* check if we're deleting the currently bound context */	if (&r300->radeon == current) {		radeonFlush(r300->radeon.glCtx);		_mesa_make_current(NULL, NULL, NULL);	}	/* Free r300 context resources */	assert(r300);		/* should never be null */	if (r300) {		GLboolean release_texture_heaps;		release_texture_heaps =		    (r300->radeon.glCtx->Shared->RefCount == 1);		_swsetup_DestroyContext(r300->radeon.glCtx);		_tnl_ProgramCacheDestroy(r300->radeon.glCtx);		_tnl_DestroyContext(r300->radeon.glCtx);		_vbo_DestroyContext(r300->radeon.glCtx);		_swrast_DestroyContext(r300->radeon.glCtx);		if (r300->dma.current.buf) {			r300ReleaseDmaRegion(r300, &r300->dma.current,					     __FUNCTION__);#ifndef USER_BUFFERS			r300FlushCmdBuf(r300, __FUNCTION__);#endif		}		r300FreeGartAllocations(r300);		r300DestroyCmdBuf(r300);		if (radeon->state.scissor.pClipRects) {			FREE(radeon->state.scissor.pClipRects);			radeon->state.scissor.pClipRects = NULL;		}		if (release_texture_heaps) {			/* This share group is about to go away, free our private			 * texture object data.			 */			int i;			for (i = 0; i < r300->nr_heaps; i++) {				driDestroyTextureHeap(r300->texture_heaps[i]);				r300->texture_heaps[i] = NULL;			}			assert(is_empty_list(&r300->swapped));		}		radeonCleanupContext(&r300->radeon);#ifdef USER_BUFFERS		/* the memory manager might be accessed when Mesa frees the shared		 * state, so don't destroy it earlier		 */		r300_mem_destroy(r300);#endif		/* free the option cache */		driDestroyOptionCache(&r300->radeon.optionCache);		FREE(r300);	}}

⌨️ 快捷键说明

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