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

📄 ffb_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
		tmp = (fmesa->ppc & ~FFB_PPC_ABE_MASK);		if (state) {			tmp |= FFB_PPC_ABE_ENABLE;		} else {			tmp |= FFB_PPC_ABE_DISABLE;		}		if (fmesa->ppc != tmp) {			fmesa->ppc = tmp;			FFB_MAKE_DIRTY(fmesa, FFB_STATE_PPC, 1);			ffbDDBlendFuncSeparate(ctx, 0, 0, 0, 0 );		}		break;	case GL_DEPTH_TEST:		if (state)			tmp = 0x0fffffff;		else			tmp = 0x00000000;		if (tmp != fmesa->magnc) {			unsigned int fbc = fmesa->fbc;			fbc &= ~FFB_FBC_ZE_MASK;			if (state)				fbc |= FFB_FBC_ZE_ON;			else				fbc |= FFB_FBC_ZE_OFF;			fmesa->fbc = fbc;			ffbDDDepthFunc(ctx, ctx->Depth.Func);			fmesa->magnc = tmp;			FFB_MAKE_DIRTY(fmesa, (FFB_STATE_MAGNC | FFB_STATE_FBC), 2);		}		break;	case GL_SCISSOR_TEST:		ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,			     ctx->Scissor.Width, ctx->Scissor.Height);		break;	case GL_STENCIL_TEST:		if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {			FALLBACK( ctx, FFB_BADATTR_STENCIL, state );		}		tmp = fmesa->fbc & ~FFB_FBC_YE_MASK;		if (state) {			ffbDDStencilFuncSeparate(ctx, GL_FRONT,					 ctx->Stencil.Function[0],					 ctx->Stencil.Ref[0],					 ctx->Stencil.ValueMask[0]);			ffbDDStencilMaskSeparate(ctx, GL_FRONT,                                                 ctx->Stencil.WriteMask[0]);			ffbDDStencilOpSeparate(ctx, GL_FRONT,				       ctx->Stencil.FailFunc[0],				       ctx->Stencil.ZFailFunc[0],				       ctx->Stencil.ZPassFunc[0]);			tmp |= FFB_FBC_YE_MASK;		} else {			fmesa->stencil		= 0xf0000000;			fmesa->stencilctl	= 0x33300000;			FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);			tmp |= FFB_FBC_YE_OFF;		}		if (tmp != fmesa->fbc) {			fmesa->fbc = tmp;			FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);		}		break;	case GL_FOG:		/* Until I implement the fog support... */		FALLBACK( ctx, FFB_BADATTR_FOG, state );		break;	case GL_LINE_STIPPLE:		if (! state)			fmesa->lpat = 0;		else			ffbDDLineStipple(ctx,					 ctx->Line.StippleFactor,					 ctx->Line.StipplePattern);		break;	case GL_POLYGON_STIPPLE:		/* Do nothing, we interrogate the state during		 * reduced primitive changes.  Since our caller		 * will set NEW_POLYGON in the ctx NewState this		 * will cause the driver rasterization functions		 * to be reevaluated, which will cause us to force		 * a reduced primitive change next rendering pass		 * and it all works out.		 */		break;	default:		break;	};}void ffbSyncHardware(ffbContextPtr fmesa){	ffb_fbcPtr ffb = fmesa->regs;	unsigned int dirty;	int i;	FFBFifo(fmesa, fmesa->state_fifo_ents);	dirty = fmesa->state_dirty;	if (dirty & (FFB_STATE_FBC | FFB_STATE_PPC | FFB_STATE_DRAWOP |		     FFB_STATE_ROP | FFB_STATE_LPAT | FFB_STATE_WID)) {		if (dirty & FFB_STATE_FBC)			ffb->fbc = fmesa->fbc;		if (dirty & FFB_STATE_PPC)			ffb->ppc = fmesa->ppc;		if (dirty & FFB_STATE_DRAWOP)			ffb->drawop = fmesa->drawop;		if (dirty & FFB_STATE_ROP)			ffb->rop = fmesa->rop;		if (dirty & FFB_STATE_LPAT)			ffb->rop = fmesa->lpat;		if (dirty & FFB_STATE_WID)			ffb->wid = fmesa->wid;	}	if (dirty & (FFB_STATE_PMASK | FFB_STATE_XPMASK | FFB_STATE_YPMASK |		     FFB_STATE_ZPMASK | FFB_STATE_XCLIP | FFB_STATE_CMP |		     FFB_STATE_MATCHAB | FFB_STATE_MAGNAB | FFB_STATE_MATCHC |		     FFB_STATE_MAGNC)) {		if (dirty & FFB_STATE_PMASK)			ffb->pmask = fmesa->pmask;		if (dirty & FFB_STATE_XPMASK)			ffb->xpmask = fmesa->xpmask;		if (dirty & FFB_STATE_YPMASK)			ffb->ypmask = fmesa->ypmask;		if (dirty & FFB_STATE_ZPMASK)			ffb->zpmask = fmesa->zpmask;		if (dirty & FFB_STATE_XCLIP)			ffb->xclip = fmesa->xclip;		if (dirty & FFB_STATE_CMP)			ffb->cmp = fmesa->cmp;		if (dirty & FFB_STATE_MATCHAB)			ffb->matchab = fmesa->matchab;		if (dirty & FFB_STATE_MAGNAB)			ffb->magnab = fmesa->magnab;		if (dirty & FFB_STATE_MATCHC)			ffb->matchc = fmesa->matchc;		if (dirty & FFB_STATE_MAGNC)			ffb->magnc = fmesa->magnc;	}	if (dirty & FFB_STATE_DCUE) {		ffb->dcss = fmesa->dcss;		ffb->dcsf = fmesa->dcsf;		ffb->dcsb = fmesa->dcsb;		ffb->dczf = fmesa->dczf;		ffb->dczb = fmesa->dczb;		if (fmesa->ffb_sarea->flags & (FFB_DRI_FFB2 | FFB_DRI_FFB2PLUS)) {			ffb->dcss1 = fmesa->dcss1;			ffb->dcss2 = fmesa->dcss2;			ffb->dcss3 = fmesa->dcss3;			ffb->dcs2  = fmesa->dcs2;			ffb->dcs3  = fmesa->dcs3;			ffb->dcs4  = fmesa->dcs4;			ffb->dcd2  = fmesa->dcd2;			ffb->dcd3  = fmesa->dcd3;			ffb->dcd4  = fmesa->dcd4;		}	}	if (dirty & FFB_STATE_BLEND) {		ffb->blendc  = fmesa->blendc;		ffb->blendc1 = fmesa->blendc1;		ffb->blendc2 = fmesa->blendc2;	}	if (dirty & FFB_STATE_CLIP) {		ffb->vclipmin  = fmesa->vclipmin;		ffb->vclipmax  = fmesa->vclipmax;		ffb->vclipzmin = fmesa->vclipzmin;		ffb->vclipzmax = fmesa->vclipzmax;		for (i = 0; i < 4; i++) {			ffb->auxclip[i].min = fmesa->aux_clips[i].min;			ffb->auxclip[i].max = fmesa->aux_clips[i].max;		}	}	if ((dirty & FFB_STATE_STENCIL) &&	    (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {		ffb->stencil    = fmesa->stencil;		ffb->stencilctl = fmesa->stencilctl;		ffb->fbc = FFB_FBC_WB_C;		ffb->rawstencilctl = (fmesa->stencilctl | (1 << 19));		ffb->fbc = fmesa->fbc;		ffb->consty = fmesa->consty;	}	if (dirty & FFB_STATE_APAT) {		for (i = 0; i < 32; i++)			ffb->pattern[i] = fmesa->pattern[i];	}	fmesa->state_dirty = 0;	fmesa->state_fifo_ents = 0;	fmesa->ffbScreen->rp_active = 1;}static void ffbDDUpdateState(GLcontext *ctx, GLuint newstate){	ffbContextPtr fmesa = FFB_CONTEXT(ctx);	/* When we are hw rendering, changing certain kinds of	 * state does not require flushing all of our context.	 */	if (fmesa->bad_fragment_attrs == 0 &&	    (newstate & ~_NEW_COLOR) == 0)		return;	_swrast_InvalidateState( ctx, newstate );	_swsetup_InvalidateState( ctx, newstate );	_vbo_InvalidateState( ctx, newstate );	_tnl_InvalidateState( ctx, newstate );	if (newstate & _NEW_TEXTURE)	   FALLBACK( ctx, FFB_BADATTR_TEXTURE, 		     (ctx->Texture._EnabledUnits != 0));#ifdef STATE_TRACE	fprintf(stderr, "ffbDDUpdateState: newstate(%08x)\n", newstate);#endif	fmesa->new_gl_state |= newstate;	/* Force a reduced primitive change next rendering	 * pass.	 */	fmesa->raster_primitive = GL_POLYGON + 1;#if 0	/* When the modelview matrix changes, this changes what	 * the eye coordinates will be so we have to recompute	 * the depth cueing parameters.	 *	 * XXX DD_HAVE_HARDWARE_FOG.	 */	if (ctx->Fog.Enabled && (newstate & _NEW_MODELVIEW))		ffb_update_fog();#endif}void ffbDDInitStateFuncs(GLcontext *ctx){	ffbContextPtr fmesa = FFB_CONTEXT(ctx);	ctx->Driver.UpdateState = ffbDDUpdateState;	ctx->Driver.Enable = ffbDDEnable;	ctx->Driver.AlphaFunc = ffbDDAlphaFunc;	ctx->Driver.BlendEquationSeparate = ffbDDBlendEquationSeparate;	ctx->Driver.BlendFuncSeparate = ffbDDBlendFuncSeparate;	ctx->Driver.DepthFunc = ffbDDDepthFunc;	ctx->Driver.DepthMask = ffbDDDepthMask;	ctx->Driver.Fogfv = ffbDDFogfv;	ctx->Driver.LineStipple = ffbDDLineStipple;	ctx->Driver.PolygonStipple = ffbDDPolygonStipple;	ctx->Driver.Scissor = ffbDDScissor;	ctx->Driver.ColorMask = ffbDDColorMask;	ctx->Driver.LogicOpcode = ffbDDLogicOp;	ctx->Driver.Viewport = ffbDDViewport;	ctx->Driver.DepthRange = ffbDDDepthRange;	if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {		ctx->Driver.StencilFuncSeparate = ffbDDStencilFuncSeparate;		ctx->Driver.StencilMaskSeparate = ffbDDStencilMaskSeparate;		ctx->Driver.StencilOpSeparate = ffbDDStencilOpSeparate;	}	ctx->Driver.DrawBuffer = ffbDDDrawBuffer;	ctx->Driver.ReadBuffer = ffbDDReadBuffer;	ctx->Driver.ClearColor = ffbDDClearColor;	ctx->Driver.ClearDepth = ffbDDClearDepth;	ctx->Driver.ClearStencil = ffbDDClearStencil;	/* We will support color index modes later... -DaveM */        /*	ctx->Driver.ClearIndex = 0;	ctx->Driver.IndexMask = 0;        */}void ffbDDInitContextHwState(GLcontext *ctx){	ffbContextPtr fmesa = FFB_CONTEXT(ctx);	int fifo_count = 0;	int i;	fmesa->hw_locked = 0;	fmesa->bad_fragment_attrs = 0;	fmesa->state_dirty = FFB_STATE_ALL;	fmesa->new_gl_state = ~0;	fifo_count = 1;	fmesa->fbc = (FFB_FBC_WE_FORCEON | FFB_FBC_WM_COMBINED |		      FFB_FBC_SB_BOTH | FFB_FBC_ZE_MASK |		      FFB_FBC_YE_OFF | FFB_FBC_XE_OFF |		      FFB_FBC_RGBE_MASK);	if (ctx->Visual.doubleBufferMode) {		/* Buffer B is the initial back buffer. */		fmesa->back_buffer = 1;		fmesa->fbc |= FFB_FBC_WB_BC | FFB_FBC_RB_B;	} else {		fmesa->back_buffer = 0;		fmesa->fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;	}	fifo_count += 1;	fmesa->ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |		      FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_3D |		      FFB_PPC_APE_DISABLE | FFB_PPC_TBE_OPAQUE |		      FFB_PPC_ZS_CONST | FFB_PPC_YS_CONST |		      FFB_PPC_XS_WID | FFB_PPC_CS_VAR);	fifo_count += 3;	fmesa->drawop = FFB_DRAWOP_RECTANGLE;	/* GL_COPY is the default LogicOp. */	fmesa->rop = (FFB_ROP_NEW << 16) | (FFB_ROP_NEW << 8) | FFB_ROP_NEW;	/* No line patterning enabled. */	fmesa->lpat = 0x00000000;	/* We do not know the WID value until the first context switch. */	fifo_count += 1;	fmesa->wid = ~0;	fifo_count += 5;	/* ColorMask, all enabled. */	fmesa->pmask  = 0xffffffff;	fmesa->xpmask = 0x000000ff;	fmesa->ypmask = 0x0000000f;	fmesa->zpmask = 0x0fffffff;	/* AlphaFunc GL_ALWAYS, AlphaRef 0 */	fmesa->xclip  = FFB_XCLIP_TEST_ALWAYS | 0x00;	/* This sets us up to use WID clipping (so the DRI clipping	 * rectangle is unneeded by us).  All other match and magnitude	 * tests are set to pass.	 */	fifo_count += 5;	fmesa->cmp = ((FFB_CMP_MATCH_ALWAYS << 24) |	/* MATCH C  */		      (FFB_CMP_MAGN_ALWAYS  << 16) |	/* MAGN  C  */		      (FFB_CMP_MATCH_EQ     <<  8) |	/* MATCH AB */		      (FFB_CMP_MAGN_ALWAYS  <<  0));	/* MAGN  AB */	fmesa->matchab = 0xff000000;	fmesa->magnab  = 0x00000000;	fmesa->matchc  = 0x00000000;	fmesa->magnc   = 0x00000000;	/* Depth cue parameters, all zeros to start. */	fifo_count += 14;	fmesa->dcss  = 0x00000000;	fmesa->dcsf  = 0x00000000;	fmesa->dcsb  = 0x00000000;	fmesa->dczf  = 0x00000000;	fmesa->dczb  = 0x00000000;	fmesa->dcss1 = 0x00000000;	fmesa->dcss2 = 0x00000000;	fmesa->dcss3 = 0x00000000;	fmesa->dcs2  = 0x00000000;	fmesa->dcs3  = 0x00000000;	fmesa->dcs4  = 0x00000000;	fmesa->dcd2  = 0x00000000;	fmesa->dcd3  = 0x00000000;	fmesa->dcd4  = 0x00000000;	/* Alpha blending unit state. */	fifo_count += 3;	fmesa->blendc  = (1 << 0) | (0 << 2);  /* src(GL_ONE) | dst(GL_ZERO) */	fmesa->blendc1 = 0x00000000;	fmesa->blendc2 = 0x00000000;	/* ViewPort clip state. */	fifo_count += 4 + (4 * 2);	fmesa->vclipmin  = 0x00000000;	fmesa->vclipmax  = 0xffffffff;	fmesa->vclipzmin = 0x00000000;	fmesa->vclipzmax = 0x0fffffff;	for (i = 0; i < 4; i++) {		fmesa->aux_clips[0].min = 0x00000000;		fmesa->aux_clips[0].max = 0x00000000;	}	/* Stenciling state. */	fifo_count += 6;	fmesa->stencil    = 0xf0000000; /* Stencil MASK, Y plane */	fmesa->stencilctl = 0x33300000; /* All stencil tests disabled */	fmesa->consty	  = 0x0;	/* Area pattern, used for polygon stipples. */	fifo_count += 32;	for (i = 0; i < 32; i++)		fmesa->pattern[i] = 0x00000000;	fmesa->state_fifo_ents = fifo_count;	fmesa->state_all_fifo_ents = fifo_count;}

⌨️ 快捷键说明

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