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

📄 sis_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ============================================================= * Window position *//* ============================================================= * Viewport */static void sisCalcViewport( GLcontext *ctx ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   const GLfloat *v = ctx->Viewport._WindowMap.m;   GLfloat *m = smesa->hw_viewport;   /* See also sis_translate_vertex.    */   m[MAT_SX] =   v[MAT_SX];   m[MAT_TX] =   v[MAT_TX] + SUBPIXEL_X;   m[MAT_SY] = - v[MAT_SY];   m[MAT_TY] = - v[MAT_TY] + smesa->driDrawable->h + SUBPIXEL_Y;   m[MAT_SZ] =   v[MAT_SZ] * smesa->depth_scale;   m[MAT_TZ] =   v[MAT_TZ] * smesa->depth_scale;}static void sisDDViewport( GLcontext *ctx,			   GLint x, GLint y,			   GLsizei width, GLsizei height ){   sisCalcViewport( ctx );}static void sisDDDepthRange( GLcontext *ctx,			     GLclampd nearval, GLclampd farval ){   sisCalcViewport( ctx );}/* ============================================================= * Miscellaneous */static voidsisDDLogicOpCode( GLcontext *ctx, GLenum opcode ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   current->hwDstSet &= ~MASK_ROP2;   switch (opcode)   {   case GL_CLEAR:      current->hwDstSet |= LOP_CLEAR;      break;   case GL_SET:      current->hwDstSet |= LOP_SET;      break;   case GL_COPY:      current->hwDstSet |= LOP_COPY;      break;   case GL_COPY_INVERTED:      current->hwDstSet |= LOP_COPY_INVERTED;      break;   case GL_NOOP:      current->hwDstSet |= LOP_NOOP;      break;   case GL_INVERT:      current->hwDstSet |= LOP_INVERT;      break;   case GL_AND:      current->hwDstSet |= LOP_AND;      break;   case GL_NAND:      current->hwDstSet |= LOP_NAND;      break;   case GL_OR:      current->hwDstSet |= LOP_OR;      break;   case GL_NOR:      current->hwDstSet |= LOP_NOR;      break;   case GL_XOR:      current->hwDstSet |= LOP_XOR;      break;   case GL_EQUIV:      current->hwDstSet |= LOP_EQUIV;      break;   case GL_AND_REVERSE:      current->hwDstSet |= LOP_AND_REVERSE;      break;   case GL_AND_INVERTED:      current->hwDstSet |= LOP_AND_INVERTED;      break;   case GL_OR_REVERSE:      current->hwDstSet |= LOP_OR_REVERSE;      break;   case GL_OR_INVERTED:      current->hwDstSet |= LOP_OR_INVERTED;      break;   }   if (current->hwDstSet ^ prev->hwDstSet) {      prev->hwDstSet = current->hwDstSet;      smesa->GlobalFlag |= GFLAG_DESTSETTING;   }}void sisDDDrawBuffer( GLcontext *ctx, GLenum mode ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );      return;   }   current->hwDstSet &= ~MASK_DstBufferPitch;   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {   case BUFFER_FRONT_LEFT:      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );      current->hwOffsetDest = smesa->front.offset >> 1;      current->hwDstSet |= smesa->front.pitch >> 2;      break;   case BUFFER_BACK_LEFT:      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );      current->hwOffsetDest = smesa->back.offset >> 1;      current->hwDstSet |= smesa->back.pitch >> 2;      break;   default:      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );      return;   }   if (current->hwDstSet != prev->hwDstSet) {      prev->hwDstSet = current->hwDstSet;      smesa->GlobalFlag |= GFLAG_DESTSETTING;   }   if (current->hwOffsetDest != prev->hwOffsetDest) {      prev->hwOffsetDest = current->hwOffsetDest;      smesa->GlobalFlag |= GFLAG_DESTSETTING;   }}/* ============================================================= * Polygon stipple *//* ============================================================= * Render mode *//* ============================================================= * State enable/disable */static voidsisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *current = &smesa->current;   switch (cap)   {   case GL_ALPHA_TEST:      if (state)         current->hwCapEnable |= MASK_AlphaTestEnable;      else         current->hwCapEnable &= ~MASK_AlphaTestEnable;      break;   case GL_BLEND:      /* TODO: */      if (state)      /* if (state & !ctx->Color.ColorLogicOpEnabled) */         current->hwCapEnable |= MASK_BlendEnable;      else         current->hwCapEnable &= ~MASK_BlendEnable;      break;   case GL_CULL_FACE:      if (state)         current->hwCapEnable |= MASK_CullEnable;      else         current->hwCapEnable &= ~MASK_CullEnable;      break;   case GL_DEPTH_TEST:      if (state && smesa->depth.offset != 0)         current->hwCapEnable |= MASK_ZTestEnable;      else         current->hwCapEnable &= ~MASK_ZTestEnable;      sisDDDepthMask( ctx, ctx->Depth.Mask );      break;   case GL_DITHER:      if (state)         current->hwCapEnable |= MASK_DitherEnable;      else         current->hwCapEnable &= ~MASK_DitherEnable;      break;   case GL_FOG:      if (state)         current->hwCapEnable |= MASK_FogEnable;      else         current->hwCapEnable &= ~MASK_FogEnable;      break;   case GL_COLOR_LOGIC_OP:      if (state)         sisDDLogicOpCode( ctx, ctx->Color.LogicOp );      else         sisDDLogicOpCode( ctx, GL_COPY );      break;   case GL_SCISSOR_TEST:      sisUpdateClipping( ctx );      break;   case GL_STENCIL_TEST:      if (state) {         if (smesa->zFormat != SiS_ZFORMAT_S8Z24)            FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1);         else            current->hwCapEnable |= (MASK_StencilTestEnable |				     MASK_StencilWriteEnable);      } else {         FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0);         current->hwCapEnable &= ~(MASK_StencilTestEnable |				   MASK_StencilWriteEnable);      }      break;   case GL_LIGHTING:   case GL_COLOR_SUM_EXT:      sisUpdateSpecular(ctx);      break;   }}/* ============================================================= * State initialization, management *//* Called before beginning of rendering. */voidsisUpdateHWState( GLcontext *ctx ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   /* enable setting 1 */   if (current->hwCapEnable ^ prev->hwCapEnable) {      prev->hwCapEnable = current->hwCapEnable;      smesa->GlobalFlag |= GFLAG_ENABLESETTING;   }  /* enable setting 2 */   if (current->hwCapEnable2 ^ prev->hwCapEnable2) {      prev->hwCapEnable2 = current->hwCapEnable2;      smesa->GlobalFlag |= GFLAG_ENABLESETTING2;   }   if (smesa->GlobalFlag & GFLAG_RENDER_STATES)      sis_update_render_state( smesa );   if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES)      sis_update_texture_state( smesa );}static voidsisDDInvalidateState( GLcontext *ctx, GLuint new_state ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   _swrast_InvalidateState( ctx, new_state );   _swsetup_InvalidateState( ctx, new_state );   _vbo_InvalidateState( ctx, new_state );   _tnl_InvalidateState( ctx, new_state );   smesa->NewGLState |= new_state;}/* Initialize the context's hardware state. */void sisDDInitState( sisContextPtr smesa ){   __GLSiSHardware *current = &smesa->current;   __GLSiSHardware *prev = &(smesa->prev);   GLcontext *ctx = smesa->glCtx;   /* add Texture Perspective Enable */   prev->hwCapEnable = MASK_FogPerspectiveEnable | MASK_TextureCacheEnable |      MASK_TexturePerspectiveEnable | MASK_DitherEnable;   /*   prev->hwCapEnable2 = 0x00aa0080;   */   /* if multi-texture enabled, disable Z pre-test */   prev->hwCapEnable2 = MASK_TextureMipmapBiasEnable;   /* Z test mode is LESS */   prev->hwZ = SiS_Z_COMP_S_LT_B;   /* Depth mask */   prev->hwZMask = 0xffffffff;   /* Alpha test mode is ALWAYS, alpha ref value is 0 */   prev->hwAlpha = SiS_ALPHA_ALWAYS;   /* ROP2 is COPYPEN */   prev->hwDstSet = LOP_COPY;   /* color mask */   prev->hwDstMask = 0xffffffff;   /* LinePattern is 0, Repeat Factor is 0 */   prev->hwLinePattern = 0x00008000;   /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */   prev->hwDstSrcBlend = SiS_S_ONE | SiS_D_ZERO;   /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */   prev->hwStSetting = STENCIL_FORMAT_8 | SiS_STENCIL_ALWAYS | 0xff;   /* Op is KEEP for all three operations */   prev->hwStSetting2 = SiS_SFAIL_KEEP | SiS_SPASS_ZFAIL_KEEP |       SiS_SPASS_ZPASS_KEEP;   /* Texture mapping mode is Tile */#if 0   prev->texture[0].hwTextureSet = 0x00030000;#endif   /* Magnified & minified texture filter is NEAREST */#if 0   prev->texture[0].hwTextureMip = 0;#endif   /* Texture Blending setting -- use fragment color/alpha*/   prev->hwTexBlendColor0 = STAGE0_C_CF;   prev->hwTexBlendColor1 = STAGE1_C_CF;   prev->hwTexBlendAlpha0 = STAGE0_A_AF;   prev->hwTexBlendAlpha1 = STAGE1_A_AF;      switch (smesa->bytesPerPixel)   {   case 2:      prev->hwDstSet |= DST_FORMAT_RGB_565;      break;   case 4:      prev->hwDstSet |= DST_FORMAT_ARGB_8888;      break;   }   switch (ctx->Visual.depthBits)   {   case 0:      prev->hwCapEnable &= ~MASK_ZWriteEnable;   case 16:      smesa->zFormat = SiS_ZFORMAT_Z16;      prev->hwCapEnable |= MASK_ZWriteEnable;      smesa->depth_scale = 1.0 / (GLfloat)0xffff;      break;   case 32:      smesa->zFormat = SiS_ZFORMAT_Z32;      prev->hwCapEnable |= MASK_ZWriteEnable;      smesa->depth_scale = 1.0 / (GLfloat)0xffffffff;      break;   case 24:      assert (ctx->Visual.stencilBits);      smesa->zFormat = SiS_ZFORMAT_S8Z24;      prev->hwCapEnable |= MASK_StencilBufferEnable;      prev->hwCapEnable |= MASK_ZWriteEnable;      smesa->depth_scale = 1.0 / (GLfloat)0xffffff;      break;   }   prev->hwZ |= smesa->zFormat;   /* TODO: need to clear cache? */   smesa->clearTexCache = GL_TRUE;   smesa->clearColorPattern = 0;   smesa->AGPParseSet = MASK_PsTexture1FromB | MASK_PsBumpTextureFromC;   smesa->dwPrimitiveSet = OP_3D_Texture1FromB | OP_3D_TextureBumpFromC;   sisUpdateZStencilPattern( smesa, 1.0, 0 );   sisUpdateCull( ctx );   memcpy( current, prev, sizeof (__GLSiSHardware) );   /* Set initial fog settings. Start and end are the same case.  */   sisDDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );   sisDDFogfv( ctx, GL_FOG_END, &ctx->Fog.End );   sisDDFogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL );   sisDDFogfv( ctx, GL_FOG_MODE, NULL );}/* Initialize the driver's state functions. */void sisDDInitStateFuncs( GLcontext *ctx ){   ctx->Driver.UpdateState	 = sisDDInvalidateState;   ctx->Driver.Clear		 = sisDDClear;   ctx->Driver.ClearColor	 = sisDDClearColor;   ctx->Driver.ClearDepth	 = sisDDClearDepth;   ctx->Driver.ClearStencil	 = sisDDClearStencil;   ctx->Driver.AlphaFunc	 = sisDDAlphaFunc;   ctx->Driver.BlendFuncSeparate = sisDDBlendFuncSeparate;   ctx->Driver.ColorMask	 = sisDDColorMask;   ctx->Driver.CullFace		 = sisDDCullFace;   ctx->Driver.DepthMask	 = sisDDDepthMask;   ctx->Driver.DepthFunc	 = sisDDDepthFunc;   ctx->Driver.DepthRange	 = sisDDDepthRange;   ctx->Driver.DrawBuffer	 = sisDDDrawBuffer;   ctx->Driver.Enable		 = sisDDEnable;   ctx->Driver.FrontFace	 = sisDDFrontFace;   ctx->Driver.Fogfv		 = sisDDFogfv;   ctx->Driver.Hint		 = NULL;   ctx->Driver.Lightfv		 = NULL;   ctx->Driver.LogicOpcode	 = sisDDLogicOpCode;   ctx->Driver.PolygonMode	 = NULL;   ctx->Driver.PolygonStipple	 = NULL;   ctx->Driver.ReadBuffer	 = NULL;   ctx->Driver.RenderMode	 = NULL;   ctx->Driver.Scissor		 = sisDDScissor;   ctx->Driver.ShadeModel	 = sisDDShadeModel;   ctx->Driver.LightModelfv	 = sisDDLightModelfv;   ctx->Driver.Viewport		 = sisDDViewport;   /* XXX this should go away */   ctx->Driver.ResizeBuffers	 = sisReAllocateBuffers;}

⌨️ 快捷键说明

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