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

📄 s3v_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
	vmesa->dirty |= S3V_UPLOAD_GEOMETRY;}static void s3vDDCullFace( GLcontext *ctx, GLenum mode ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	/* FLUSH_BATCH( vmesa ); */	vmesa->new_state |= S3V_NEW_CULL;}static void s3vDDFrontFace( GLcontext *ctx, GLenum mode ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	/* FLUSH_BATCH( vmesa ); */	vmesa->new_state |= S3V_NEW_CULL;}/* ============================================================= * Masks */static void s3vUpdateMasks( GLcontext *ctx ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	GLuint mask = s3vPackColor( vmesa->s3vScreen->cpp,				ctx->Color.ColorMask[RCOMP],				ctx->Color.ColorMask[GCOMP],				ctx->Color.ColorMask[BCOMP],				ctx->Color.ColorMask[ACOMP] );	if (vmesa->s3vScreen->cpp == 2) mask |= mask << 16;	/* FIXME: can we do something in virge? */}/*static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,			      GLboolean b, GLboolean a){   s3vContextPtr vmesa = S3V_CONTEXT(ctx);   FLUSH_BATCH( vmesa );   vmesa->new_state |= S3V_NEW_MASKS;}*//* ============================================================= * Rendering attributes *//* ============================================================= * Miscellaneous */static void s3vDDClearColor( GLcontext *ctx, const GLfloat color[4]){   s3vContextPtr vmesa = S3V_CONTEXT(ctx);   DEBUG(("*** s3vDDClearColor\n"));   vmesa->ClearColor = s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */				      color[0], color[1], color[2], color[3] );#if 0   if (vmesa->s3vScreen->cpp == 2) vmesa->ClearColor |= vmesa->ClearColor<<16;#endif}static void s3vDDSetDrawBuffer( GLcontext *ctx, GLenum mode ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	int found = GL_TRUE;	DEBUG(("*** s3vDDSetDrawBuffer ***\n"));	/* FLUSH_BATCH( vmesa ); */	switch ( mode ) {		case GL_FRONT_LEFT:			vmesa->drawOffset = vmesa->s3vScreen->frontOffset;			break;		case GL_BACK_LEFT:			vmesa->drawOffset = vmesa->s3vScreen->backOffset;			/* vmesa->driScreen->fbHeight *			 * vmesa->driScreen->fbWidth *			 * vmesa->s3vScreen->cpp; */			break;		default:			found = GL_FALSE;			break;	}	DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa->drawOffset));/*	return GL_TRUE; */}/* ============================================================= * Window position and viewport transformation */void s3vUpdateWindow( GLcontext *ctx ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	__DRIdrawablePrivate *dPriv = vmesa->driDrawable;	GLfloat xoffset = (GLfloat)dPriv->x;	GLfloat yoffset =		vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;	const GLfloat *v = ctx->Viewport._WindowMap.m;	GLfloat sx = v[MAT_SX];	GLfloat tx = v[MAT_TX] + xoffset;	GLfloat sy = v[MAT_SY];	GLfloat ty = v[MAT_TY] + yoffset;	GLfloat sz = v[MAT_SZ] * vmesa->depth_scale;	GLfloat tz = v[MAT_TZ] * vmesa->depth_scale;	vmesa->dirty |= S3V_UPLOAD_VIEWPORT;	vmesa->ViewportScaleX = sx;	vmesa->ViewportScaleY = sy;	vmesa->ViewportScaleZ = sz;	vmesa->ViewportOffsetX = tx;	vmesa->ViewportOffsetY = ty;	vmesa->ViewportOffsetZ = tz;}/*static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y,			    GLsizei width, GLsizei height ){	s3vUpdateWindow( ctx );}static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval,			      GLclampd farval ){	s3vUpdateWindow( ctx );}*/void s3vUpdateViewportOffset( GLcontext *ctx ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	__DRIdrawablePrivate *dPriv = vmesa->driDrawable;	GLfloat xoffset = (GLfloat)dPriv->x;	GLfloat yoffset =		vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;	const GLfloat *v = ctx->Viewport._WindowMap.m;	GLfloat tx = v[MAT_TX] + xoffset;	GLfloat ty = v[MAT_TY] + yoffset;	DEBUG(("*** s3vUpdateViewportOffset ***\n"));	if ( vmesa->ViewportOffsetX != tx ||		vmesa->ViewportOffsetY != ty )	{		vmesa->ViewportOffsetX = tx;		vmesa->ViewportOffsetY = ty;		vmesa->new_state |= S3V_NEW_WINDOW;	}/*	vmesa->new_state |= S3V_NEW_CLIP; */}/* ============================================================= * State enable/disable */static void s3vDDEnable( GLcontext *ctx, GLenum cap, GLboolean state ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	switch ( cap ) {	case GL_ALPHA_TEST:	case GL_BLEND:		vmesa->new_state |= S3V_NEW_ALPHA;		DEBUG(("s3vDDEnable: GL_BLEND\n"));	break;	case GL_CULL_FACE:		vmesa->new_state |= S3V_NEW_CULL;		DEBUG(("s3vDDEnable: GL_CULL_FACE\n"));	break;	case GL_DEPTH_TEST:		vmesa->new_state |= S3V_NEW_DEPTH;		DEBUG(("s3vDDEnable: GL_DEPTH\n"));	break;#if 0	case GL_FOG:		vmesa->new_state |= S3V_NEW_FOG;	break;#endif	case GL_SCISSOR_TEST:		vmesa->new_state |= S3V_NEW_CLIP;	break;	case GL_TEXTURE_2D:	   	DEBUG(("*** GL_TEXTURE_2D: %i\n", state));		vmesa->_3d_mode = state;		vmesa->restore_primitive = -1;	break;		default:		return;	}}/* ============================================================= * State initialization, management *//* * Load the current context's state into the hardware. * * NOTE: Be VERY careful about ensuring the context state is marked for * upload, the only place it shouldn't be uploaded is when the setup * state has changed in ReducedPrimitiveChange as this comes right after * a state update. * * Blits of any type should always upload the context and masks after * they are done. */void s3vEmitHwState( s3vContextPtr vmesa ){    if (!vmesa->driDrawable) return;    if (!vmesa->dirty) return; 	DEBUG(("**********************\n"));	DEBUG(("*** s3vEmitHwState ***\n"));	DEBUG(("**********************\n"));    if (vmesa->dirty & S3V_UPLOAD_VIEWPORT) {	vmesa->dirty &= ~S3V_UPLOAD_VIEWPORT;	DEBUG(("S3V_UPLOAD_VIEWPORT\n"));    }       if ( (vmesa->dirty & S3V_UPLOAD_POINTMODE) ||	 (vmesa->dirty & S3V_UPLOAD_LINEMODE) ||	 (vmesa->dirty & S3V_UPLOAD_TRIMODE) ) {    }        if (vmesa->dirty & S3V_UPLOAD_POINTMODE) {	vmesa->dirty &= ~S3V_UPLOAD_POINTMODE;    }    if (vmesa->dirty & S3V_UPLOAD_LINEMODE) {	vmesa->dirty &= ~S3V_UPLOAD_LINEMODE;    }        if (vmesa->dirty & S3V_UPLOAD_TRIMODE) {	vmesa->dirty &= ~S3V_UPLOAD_TRIMODE;    }    if (vmesa->dirty & S3V_UPLOAD_FOG) {	GLchan c[3], col;   	UNCLAMPED_FLOAT_TO_RGB_CHAN( c, vmesa->glCtx->Fog.Color );	DEBUG(("uploading ** FOG **\n"));	col = s3vPackColor(2, c[0], c[1], c[2], 0);	vmesa->dirty &= ~S3V_UPLOAD_FOG;    }        if (vmesa->dirty & S3V_UPLOAD_DITHER) {	vmesa->dirty &= ~S3V_UPLOAD_DITHER;    }        if (vmesa->dirty & S3V_UPLOAD_LOGICOP) {	vmesa->dirty &= ~S3V_UPLOAD_LOGICOP;    }        if (vmesa->dirty & S3V_UPLOAD_CLIP) {	vmesa->dirty &= ~S3V_UPLOAD_CLIP;	DEBUG(("S3V_UPLOAD_CLIP\n"));	DEBUG(("vmesa->ScissorLR: %i\n",  vmesa->ScissorLR));	DEBUG(("vmesa->ScissorTB: %i\n",  vmesa->ScissorTB));    }    if (vmesa->dirty & S3V_UPLOAD_MASKS) {	vmesa->dirty &= ~S3V_UPLOAD_MASKS;	DEBUG(("S3V_UPLOAD_BLEND\n"));    }        if (vmesa->dirty & S3V_UPLOAD_ALPHA) {	vmesa->dirty &= ~S3V_UPLOAD_ALPHA;	DEBUG(("S3V_UPLOAD_ALPHA\n"));    }        if (vmesa->dirty & S3V_UPLOAD_SHADE) {	vmesa->dirty &= ~S3V_UPLOAD_SHADE;    }        if (vmesa->dirty & S3V_UPLOAD_POLYGON) {	vmesa->dirty &= ~S3V_UPLOAD_POLYGON;    }        if (vmesa->dirty & S3V_UPLOAD_DEPTH) {	vmesa->dirty &= ~S3V_UPLOAD_DEPTH;	DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa->DepthMode));    }        if (vmesa->dirty & S3V_UPLOAD_GEOMETRY) {	vmesa->dirty &= ~S3V_UPLOAD_GEOMETRY;    }    if (vmesa->dirty & S3V_UPLOAD_TRANSFORM) {	vmesa->dirty &= ~S3V_UPLOAD_TRANSFORM;    }        if (vmesa->dirty & S3V_UPLOAD_TEX0) {	s3vTextureObjectPtr curTex = vmesa->CurrentTexObj[0];	vmesa->dirty &= ~S3V_UPLOAD_TEX0;	DEBUG(("S3V_UPLOAD_TEX0\n"));	if (curTex) {		DEBUG(("S3V_UPLOAD_TEX0: curTex\n"));	} else {		DEBUG(("S3V_UPLOAD_TEX0: !curTex\n"));	}    }}void s3vDDUpdateHWState( GLcontext *ctx ){	s3vContextPtr vmesa = S3V_CONTEXT(ctx);	int new_state = vmesa->new_state;	/* s3vUpdateClipping( ctx ); */	if ( new_state )	{		vmesa->new_state = 0;		/* Update the various parts of the context's state.		 */		if ( new_state & S3V_NEW_ALPHA )			s3vUpdateAlphaMode( ctx );		if ( new_state & S3V_NEW_DEPTH )			s3vUpdateZMode( ctx );		if ( new_state & S3V_NEW_FOG )			s3vUpdateFogAttrib( ctx );		if ( new_state & S3V_NEW_CLIP )		{			DEBUG(("---> going to s3vUpdateClipping\n"));			s3vUpdateClipping( ctx );		}		if ( new_state & S3V_NEW_POLYGON )			s3vUpdatePolygon( ctx );		if ( new_state & S3V_NEW_CULL )			s3vUpdateCull( ctx );		if ( new_state & S3V_NEW_MASKS )			s3vUpdateMasks( ctx );		if ( new_state & S3V_NEW_WINDOW )			s3vUpdateWindow( ctx );/*		if ( new_state & S3_NEW_TEXTURE )			s3vUpdateTextureState( ctx );		*/		CMDCHANGE();	}	/* HACK ! */	s3vEmitHwState( vmesa );}static void s3vDDUpdateState( GLcontext *ctx, GLuint new_state ){	_swrast_InvalidateState( ctx, new_state );	_swsetup_InvalidateState( ctx, new_state );	_vbo_InvalidateState( ctx, new_state );	_tnl_InvalidateState( ctx, new_state );	S3V_CONTEXT(ctx)->new_gl_state |= new_state;}/* Initialize the context's hardware state. */void s3vInitState( s3vContextPtr vmesa ){	vmesa->new_state = 0;}/* Initialize the driver's state functions. */void s3vInitStateFuncs( GLcontext *ctx ){   ctx->Driver.UpdateState		= s3vDDUpdateState;   ctx->Driver.Clear			= s3vDDClear;   ctx->Driver.ClearIndex		= NULL;   ctx->Driver.ClearColor		= s3vDDClearColor;   ctx->Driver.DrawBuffer		= s3vDDSetDrawBuffer;    ctx->Driver.ReadBuffer               = NULL; /* XXX */   ctx->Driver.IndexMask		= NULL;   ctx->Driver.ColorMask		= NULL; /* s3vDDColorMask; */ /* FIXME */   ctx->Driver.AlphaFunc		= s3vDDAlphaFunc; /* FIXME */#if 0   ctx->Driver.BlendEquation		= NULL; /* s3vDDBlendEquation; */   ctx->Driver.BlendFunc		= s3vDDBlendFunc; /* FIXME */#endif   ctx->Driver.BlendFuncSeparate	= NULL; /* s3vDDBlendFuncSeparate; */   ctx->Driver.ClearDepth		= s3vDDClearDepth;   ctx->Driver.CullFace			= s3vDDCullFace;    ctx->Driver.FrontFace		= s3vDDFrontFace;   ctx->Driver.DepthFunc		= s3vDDDepthFunc;	/* FIXME */   ctx->Driver.DepthMask		= s3vDDDepthMask;	/* FIXME */   ctx->Driver.DepthRange		= NULL; /* s3vDDDepthRange; */   ctx->Driver.Enable			= s3vDDEnable;		/* FIXME */   ctx->Driver.Finish			= s3vDDFinish;   ctx->Driver.Flush			= s3vDDFlush;#if 1   ctx->Driver.Fogfv			= NULL; /* s3vDDFogfv; */#endif   ctx->Driver.Hint			= NULL;   ctx->Driver.LineWidth		= NULL; /* s3vDDLineWidth; */   ctx->Driver.LineStipple		= NULL; /* s3vDDLineStipple; */#if ENABLELIGHTING   ctx->Driver.Lightfv			= NULL; /* s3vDDLightfv; */   ctx->Driver.LightModelfv		= NULL; /* s3vDDLightModelfv; */#endif   ctx->Driver.LogicOpcode		= NULL; /* s3vDDLogicalOpcode; */   ctx->Driver.PointSize		= NULL; /* s3vDDPointSize; */   ctx->Driver.PolygonMode		= NULL; /* s3vDDPolygonMode; */   ctx->Driver.PolygonStipple		= NULL; /* s3vDDPolygonStipple; */   ctx->Driver.Scissor			= s3vDDScissor; /* ScissorLR / ScissorTB */   ctx->Driver.ShadeModel		= NULL; /* s3vDDShadeModel; */   ctx->Driver.Viewport			= NULL; /* s3vDDViewport; */}

⌨️ 快捷键说明

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