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

📄 gamma_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 4 页
字号:
      do {	 u_int32_t m = gmesa->MaterialMode;	 FLUSH_BATCH( gmesa );	 if ( state ) {	    m |=  MaterialModeEnable;	 } else {	    m &= ~MaterialModeEnable;	 }	 if ( gmesa->MaterialMode != m ) {	    gmesa->MaterialMode = m;	    gmesa->dirty |= GAMMA_UPLOAD_LIGHT;	 }      } while (0);      break;#endif   case GL_LINE_SMOOTH:      FLUSH_BATCH( gmesa );      if ( state ) {         gmesa->AntialiasMode |= AntialiasModeEnable;         gmesa->LineMode |= LM_AntialiasEnable;      } else {         gmesa->AntialiasMode &= ~AntialiasModeEnable;         gmesa->LineMode &= ~LM_AntialiasEnable;      }      gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;      break;   case GL_POINT_SMOOTH:      FLUSH_BATCH( gmesa );      if ( state ) {         gmesa->AntialiasMode |= AntialiasModeEnable;         gmesa->PointMode |= PM_AntialiasEnable;      } else {         gmesa->AntialiasMode &= ~AntialiasModeEnable;         gmesa->PointMode &= ~PM_AntialiasEnable;      }      gmesa->dirty |= GAMMA_UPLOAD_POINTMODE;      break;   case GL_POLYGON_SMOOTH:      FLUSH_BATCH( gmesa );      if ( state ) {         gmesa->AntialiasMode |= AntialiasModeEnable;         gmesa->TriangleMode |= TM_AntialiasEnable;      } else {         gmesa->AntialiasMode &= ~AntialiasModeEnable;         gmesa->TriangleMode &= ~TM_AntialiasEnable;      }      gmesa->dirty |= GAMMA_UPLOAD_TRIMODE;      break;   case GL_SCISSOR_TEST:      FLUSH_BATCH( gmesa );      gmesa->new_state |= GAMMA_NEW_CLIP;      break;   case GL_POLYGON_OFFSET_FILL:   case GL_POLYGON_OFFSET_POINT:   case GL_POLYGON_OFFSET_LINE:      FLUSH_BATCH( gmesa );      gmesa->new_state |= GAMMA_NEW_POLYGON;      break;   case GL_LINE_STIPPLE:      FLUSH_BATCH( gmesa );      if ( state )         gmesa->LineMode |= LM_StippleEnable;      else         gmesa->LineMode &= ~LM_StippleEnable;      gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;      break;   case GL_POLYGON_STIPPLE:      FLUSH_BATCH( gmesa );      gmesa->new_state |= GAMMA_NEW_STIPPLE;      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 gammaEmitHwState( gammaContextPtr gmesa ){    if (!gmesa->driDrawable) return;    if (!gmesa->dirty) return;#ifdef DO_VALIDATE    /* Flush any partially filled buffers */    FLUSH_DMA_BUFFER(gmesa);    DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock,		 gmesa->driScreen->drawLockID);    VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);#endif    if (gmesa->dirty & GAMMA_UPLOAD_VIEWPORT) {	gmesa->dirty &= ~GAMMA_UPLOAD_VIEWPORT; 	CHECK_DMA_BUFFER(gmesa, 6); 	WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->ViewportOffsetX); 	WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->ViewportOffsetY); 	WRITEF(gmesa->buf, ViewPortOffsetZ, gmesa->ViewportOffsetZ); 	WRITEF(gmesa->buf, ViewPortScaleX, gmesa->ViewportScaleX); 	WRITEF(gmesa->buf, ViewPortScaleY, gmesa->ViewportScaleY); 	WRITEF(gmesa->buf, ViewPortScaleZ, gmesa->ViewportScaleZ);    }    if ( (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) ||	 (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) ||	 (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) ) { 	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) {	gmesa->dirty &= ~GAMMA_UPLOAD_POINTMODE; 	CHECK_DMA_BUFFER(gmesa, 1); 	WRITE(gmesa->buf, PointMode, gmesa->PointMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) {	gmesa->dirty &= ~GAMMA_UPLOAD_LINEMODE; 	CHECK_DMA_BUFFER(gmesa, 2); 	WRITE(gmesa->buf, LineMode, gmesa->LineMode); 	WRITE(gmesa->buf, LineStippleMode, gmesa->LineMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) {	gmesa->dirty &= ~GAMMA_UPLOAD_TRIMODE; 	CHECK_DMA_BUFFER(gmesa, 1); 	WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_FOG) {	GLchan c[3], col;   	UNCLAMPED_FLOAT_TO_RGB_CHAN( c, gmesa->glCtx->Fog.Color );	col = gammaPackColor(4, c[0], c[1], c[2], 0);	gmesa->dirty &= ~GAMMA_UPLOAD_FOG;	CHECK_DMA_BUFFER(gmesa, 5);#if 0	WRITE(gmesa->buf, FogMode, gmesa->FogMode);	WRITE(gmesa->buf, FogColor, col);	WRITEF(gmesa->buf, FStart, gmesa->glCtx->Fog.Start);#endif	WRITEF(gmesa->buf, FogEnd, gmesa->glCtx->Fog.End);	WRITEF(gmesa->buf, FogDensity, gmesa->glCtx->Fog.Density);	WRITEF(gmesa->buf, FogScale, 		1.0f/(gmesa->glCtx->Fog.End - gmesa->glCtx->Fog.Start));    }    if (gmesa->dirty & GAMMA_UPLOAD_DITHER) {	gmesa->dirty &= ~GAMMA_UPLOAD_DITHER;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_LOGICOP) {	gmesa->dirty &= ~GAMMA_UPLOAD_LOGICOP;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_CLIP) {	gmesa->dirty &= ~GAMMA_UPLOAD_CLIP;	CHECK_DMA_BUFFER(gmesa, 3);	WRITE(gmesa->buf, ScissorMinXY, gmesa->ScissorMinXY);	WRITE(gmesa->buf, ScissorMaxXY, gmesa->ScissorMaxXY);	WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_MASKS) {	gmesa->dirty &= ~GAMMA_UPLOAD_MASKS;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, FBHardwareWriteMask, gmesa->FBHardwareWriteMask);    }    if (gmesa->dirty & GAMMA_UPLOAD_ALPHA) {	gmesa->dirty &= ~GAMMA_UPLOAD_ALPHA;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_BLEND) {	gmesa->dirty &= ~GAMMA_UPLOAD_BLEND;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);    }     CHECK_DMA_BUFFER(gmesa, 1);    if (gmesa->glCtx->Color.BlendEnabled || gmesa->glCtx->Color.AlphaEnabled) {    	WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode | gmesa->AB_FBReadMode_Save);    } else {    	WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_LIGHT) {	gmesa->dirty &= ~GAMMA_UPLOAD_LIGHT;	CHECK_DMA_BUFFER(gmesa, 2);	WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);	WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_SHADE) {	gmesa->dirty &= ~GAMMA_UPLOAD_SHADE;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_POLYGON) {	gmesa->dirty &= ~GAMMA_UPLOAD_POLYGON;	CHECK_DMA_BUFFER(gmesa, 2);	WRITEF(gmesa->buf, PolygonOffsetBias, gmesa->glCtx->Polygon.OffsetUnits);	WRITEF(gmesa->buf, PolygonOffsetFactor, gmesa->glCtx->Polygon.OffsetFactor);    }    if (gmesa->dirty & GAMMA_UPLOAD_STIPPLE) {	gmesa->dirty &= ~GAMMA_UPLOAD_STIPPLE;	CHECK_DMA_BUFFER(gmesa, 33);	WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode);	WRITE(gmesa->buf, AreaStipplePattern0, gmesa->glCtx->PolygonStipple[0]);	WRITE(gmesa->buf, AreaStipplePattern1, gmesa->glCtx->PolygonStipple[1]);	WRITE(gmesa->buf, AreaStipplePattern2, gmesa->glCtx->PolygonStipple[2]);	WRITE(gmesa->buf, AreaStipplePattern3, gmesa->glCtx->PolygonStipple[3]);	WRITE(gmesa->buf, AreaStipplePattern4, gmesa->glCtx->PolygonStipple[4]);	WRITE(gmesa->buf, AreaStipplePattern5, gmesa->glCtx->PolygonStipple[5]);	WRITE(gmesa->buf, AreaStipplePattern6, gmesa->glCtx->PolygonStipple[6]);	WRITE(gmesa->buf, AreaStipplePattern7, gmesa->glCtx->PolygonStipple[7]);	WRITE(gmesa->buf, AreaStipplePattern8, gmesa->glCtx->PolygonStipple[8]);	WRITE(gmesa->buf, AreaStipplePattern9, gmesa->glCtx->PolygonStipple[9]);	WRITE(gmesa->buf, AreaStipplePattern10, gmesa->glCtx->PolygonStipple[10]);	WRITE(gmesa->buf, AreaStipplePattern11, gmesa->glCtx->PolygonStipple[11]);	WRITE(gmesa->buf, AreaStipplePattern12, gmesa->glCtx->PolygonStipple[12]);	WRITE(gmesa->buf, AreaStipplePattern13, gmesa->glCtx->PolygonStipple[13]);	WRITE(gmesa->buf, AreaStipplePattern14, gmesa->glCtx->PolygonStipple[14]);	WRITE(gmesa->buf, AreaStipplePattern15, gmesa->glCtx->PolygonStipple[15]);	WRITE(gmesa->buf, AreaStipplePattern16, gmesa->glCtx->PolygonStipple[16]);	WRITE(gmesa->buf, AreaStipplePattern17, gmesa->glCtx->PolygonStipple[17]);	WRITE(gmesa->buf, AreaStipplePattern18, gmesa->glCtx->PolygonStipple[18]);	WRITE(gmesa->buf, AreaStipplePattern19, gmesa->glCtx->PolygonStipple[19]);	WRITE(gmesa->buf, AreaStipplePattern20, gmesa->glCtx->PolygonStipple[20]);	WRITE(gmesa->buf, AreaStipplePattern21, gmesa->glCtx->PolygonStipple[21]);	WRITE(gmesa->buf, AreaStipplePattern22, gmesa->glCtx->PolygonStipple[22]);	WRITE(gmesa->buf, AreaStipplePattern23, gmesa->glCtx->PolygonStipple[23]);	WRITE(gmesa->buf, AreaStipplePattern24, gmesa->glCtx->PolygonStipple[24]);	WRITE(gmesa->buf, AreaStipplePattern25, gmesa->glCtx->PolygonStipple[25]);	WRITE(gmesa->buf, AreaStipplePattern26, gmesa->glCtx->PolygonStipple[26]);	WRITE(gmesa->buf, AreaStipplePattern27, gmesa->glCtx->PolygonStipple[27]);	WRITE(gmesa->buf, AreaStipplePattern28, gmesa->glCtx->PolygonStipple[28]);	WRITE(gmesa->buf, AreaStipplePattern29, gmesa->glCtx->PolygonStipple[29]);	WRITE(gmesa->buf, AreaStipplePattern30, gmesa->glCtx->PolygonStipple[30]);	WRITE(gmesa->buf, AreaStipplePattern31, gmesa->glCtx->PolygonStipple[31]);    }    if (gmesa->dirty & GAMMA_UPLOAD_DEPTH) {	gmesa->dirty &= ~GAMMA_UPLOAD_DEPTH;	CHECK_DMA_BUFFER(gmesa, 4);	WRITE(gmesa->buf, DepthMode,  gmesa->DepthMode);	WRITE(gmesa->buf, DeltaMode,  gmesa->DeltaMode);	WRITE(gmesa->buf, GLINTWindow,gmesa->Window | (gmesa->FrameCount << 9));	WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_GEOMETRY) {	gmesa->dirty &= ~GAMMA_UPLOAD_GEOMETRY;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_TRANSFORM) {	gmesa->dirty &= ~GAMMA_UPLOAD_TRANSFORM;	CHECK_DMA_BUFFER(gmesa, 1);	WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);    }    if (gmesa->dirty & GAMMA_UPLOAD_TEX0) {	gammaTextureObjectPtr curTex = gmesa->CurrentTexObj[0];	gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;	if (curTex) {	CHECK_DMA_BUFFER(gmesa, 21);	WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode | GM_TextureEnable);	WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode | DM_TextureEnable);	WRITE(gmesa->buf, TextureAddressMode, curTex->TextureAddressMode);	WRITE(gmesa->buf, TextureReadMode, curTex->TextureReadMode);	WRITE(gmesa->buf, TextureColorMode, curTex->TextureColorMode);	WRITE(gmesa->buf, TextureFilterMode, curTex->TextureFilterMode);	WRITE(gmesa->buf, TextureFormat, curTex->TextureFormat);	WRITE(gmesa->buf, GLINTBorderColor, curTex->TextureBorderColor);	WRITE(gmesa->buf, TxBaseAddr0, curTex->TextureBaseAddr[0]);	WRITE(gmesa->buf, TxBaseAddr1, curTex->TextureBaseAddr[1]);	WRITE(gmesa->buf, TxBaseAddr2, curTex->TextureBaseAddr[2]);	WRITE(gmesa->buf, TxBaseAddr3, curTex->TextureBaseAddr[3]);	WRITE(gmesa->buf, TxBaseAddr4, curTex->TextureBaseAddr[4]);	WRITE(gmesa->buf, TxBaseAddr5, curTex->TextureBaseAddr[5]);	WRITE(gmesa->buf, TxBaseAddr6, curTex->TextureBaseAddr[6]);	WRITE(gmesa->buf, TxBaseAddr7, curTex->TextureBaseAddr[7]);	WRITE(gmesa->buf, TxBaseAddr8, curTex->TextureBaseAddr[8]);	WRITE(gmesa->buf, TxBaseAddr9, curTex->TextureBaseAddr[9]);	WRITE(gmesa->buf, TxBaseAddr10, curTex->TextureBaseAddr[10]);	WRITE(gmesa->buf, TxBaseAddr11, curTex->TextureBaseAddr[11]);	WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));	} else {	CHECK_DMA_BUFFER(gmesa, 6);	WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);	WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);	WRITE(gmesa->buf, TextureAddressMode, TextureAddressModeDisable);	WRITE(gmesa->buf, TextureReadMode, TextureReadModeDisable);	WRITE(gmesa->buf, TextureFilterMode, TextureFilterModeDisable);	WRITE(gmesa->buf, TextureColorMode, TextureColorModeDisable);	}    }#ifdef DO_VALIDATE    PROCESS_DMA_BUFFER_TOP_HALF(gmesa);    DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock,		   gmesa->driScreen->drawLockID);    VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);    PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);#endif}void gammaDDUpdateHWState( GLcontext *ctx ){   gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);   int new_state = gmesa->new_state;   if ( new_state )   {      FLUSH_BATCH( gmesa );      gmesa->new_state = 0;      /* Update the various parts of the context's state.       */      if ( new_state & GAMMA_NEW_ALPHA )	 gammaUpdateAlphaMode( ctx );      if ( new_state & GAMMA_NEW_DEPTH )	 gammaUpdateZMode( ctx );      if ( new_state & GAMMA_NEW_FOG )	 gammaUpdateFogAttrib( ctx );      if ( new_state & GAMMA_NEW_CLIP )	 gammaUpdateClipping( ctx );      if ( new_state & GAMMA_NEW_POLYGON )	 gammaUpdatePolygon( ctx );      if ( new_state & GAMMA_NEW_CULL )	 gammaUpdateCull( ctx );      if ( new_state & GAMMA_NEW_MASKS )	 gammaUpdateMasks( ctx );      if ( new_state & GAMMA_NEW_WINDOW )	 gammaUpdateWindow( ctx );      if ( new_state & GAMMA_NEW_STIPPLE )	 gammaUpdateStipple( ctx );   }   /* HACK ! */   gammaEmitHwState( gmesa );}static void gammaDDUpdateState( 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 );   GAMMA_CONTEXT(ctx)->new_gl_state |= new_state;}/* Initialize the context's hardware state. */void gammaDDInitState( gammaContextPtr gmesa ){   gmesa->new_state = 0;}/* Initialize the driver's state functions. */void gammaDDInitStateFuncs( GLcontext *ctx ){   ctx->Driver.UpdateState		= gammaDDUpdateState;   ctx->Driver.Clear			= gammaDDClear;   ctx->Driver.ClearIndex		= NULL;   ctx->Driver.ClearColor		= gammaDDClearColor;   ctx->Driver.DrawBuffer		= gammaDDDrawBuffer;   ctx->Driver.ReadBuffer		= gammaDDReadBuffer;   ctx->Driver.IndexMask		= NULL;   ctx->Driver.ColorMask		= gammaDDColorMask;   ctx->Driver.AlphaFunc		= gammaDDAlphaFunc;   ctx->Driver.BlendEquationSeparate	= gammaDDBlendEquationSeparate;   ctx->Driver.BlendFuncSeparate	= gammaDDBlendFuncSeparate;   ctx->Driver.ClearDepth		= gammaDDClearDepth;   ctx->Driver.CullFace			= gammaDDCullFace;   ctx->Driver.FrontFace		= gammaDDFrontFace;   ctx->Driver.DepthFunc		= gammaDDDepthFunc;   ctx->Driver.DepthMask		= gammaDDDepthMask;   ctx->Driver.DepthRange		= gammaDDDepthRange;   ctx->Driver.Enable			= gammaDDEnable;   ctx->Driver.Finish			= gammaDDFinish;   ctx->Driver.Flush			= gammaDDFlush;#if 0   ctx->Driver.Fogfv			= gammaDDFogfv;#endif   ctx->Driver.Hint			= NULL;   ctx->Driver.LineWidth		= gammaDDLineWidth;   ctx->Driver.LineStipple		= gammaDDLineStipple;#if ENABLELIGHTING   ctx->Driver.Lightfv			= gammaDDLightfv;    ctx->Driver.LightModelfv		= gammaDDLightModelfv;#endif   ctx->Driver.LogicOpcode		= gammaDDLogicalOpcode;   ctx->Driver.PointSize		= gammaDDPointSize;   ctx->Driver.PolygonMode		= gammaDDPolygonMode;   ctx->Driver.PolygonStipple		= gammaDDPolygonStipple;   ctx->Driver.Scissor			= gammaDDScissor;   ctx->Driver.ShadeModel		= gammaDDShadeModel;   ctx->Driver.Viewport			= gammaDDViewport;}

⌨️ 快捷键说明

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