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

📄 sis6326_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 2005 Eric Anholt * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Authors: *    Eric Anholt <anholt@FreeBSD.org> * */#include "sis_context.h"#include "sis_state.h"#include "sis_tris.h"#include "sis_lock.h"#include "sis_tex.h"#include "sis_reg.h"#include "context.h"#include "enums.h"#include "colormac.h"#include "swrast/swrast.h"#include "vbo/vbo.h"#include "tnl/tnl.h"#include "swrast_setup/swrast_setup.h"#include "tnl/t_pipeline.h"/* ============================================================= * Alpha blending */static voidsis6326DDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   GLubyte refbyte;   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   CLAMPED_FLOAT_TO_UBYTE(refbyte, ref);   current->hwAlpha = refbyte << 16;   /* Alpha Test function */   switch (func)   {   case GL_NEVER:      current->hwAlpha |= S_ASET_PASS_NEVER;      break;   case GL_LESS:      current->hwAlpha |= S_ASET_PASS_LESS;      break;   case GL_EQUAL:      current->hwAlpha |= S_ASET_PASS_EQUAL;      break;   case GL_LEQUAL:      current->hwAlpha |= S_ASET_PASS_LEQUAL;      break;   case GL_GREATER:      current->hwAlpha |= S_ASET_PASS_GREATER;      break;   case GL_NOTEQUAL:      current->hwAlpha |= S_ASET_PASS_NOTEQUAL;      break;   case GL_GEQUAL:      current->hwAlpha |= S_ASET_PASS_GEQUAL;      break;   case GL_ALWAYS:      current->hwAlpha |= S_ASET_PASS_ALWAYS;      break;   }   prev->hwAlpha = current->hwAlpha;   smesa->GlobalFlag |= GFLAG_ALPHASETTING;}static voidsis6326DDBlendFuncSeparate( GLcontext *ctx, 			    GLenum sfactorRGB, GLenum dfactorRGB,			    GLenum sfactorA,   GLenum dfactorA ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   current->hwDstSrcBlend = 0;   switch (dfactorRGB)   {   case GL_ZERO:      current->hwDstSrcBlend |= S_DBLEND_ZERO;      break;   case GL_ONE:      current->hwDstSrcBlend |= S_DBLEND_ONE;      break;   case GL_SRC_COLOR:      current->hwDstSrcBlend |= S_DBLEND_SRC_COLOR;      break;   case GL_ONE_MINUS_SRC_COLOR:      current->hwDstSrcBlend |= S_DBLEND_INV_SRC_COLOR;      break;   case GL_SRC_ALPHA:      current->hwDstSrcBlend |= S_DBLEND_SRC_ALPHA;      break;   case GL_ONE_MINUS_SRC_ALPHA:      current->hwDstSrcBlend |= S_DBLEND_INV_SRC_ALPHA;      break;   case GL_DST_ALPHA:      current->hwDstSrcBlend |= S_DBLEND_DST_ALPHA;      break;   case GL_ONE_MINUS_DST_ALPHA:      current->hwDstSrcBlend |= S_DBLEND_INV_DST_ALPHA;      break;   }   switch (sfactorRGB)   {   case GL_ZERO:      current->hwDstSrcBlend |= S_SBLEND_ZERO;      break;   case GL_ONE:      current->hwDstSrcBlend |= S_SBLEND_ONE;      break;   case GL_SRC_ALPHA:      current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA;      break;   case GL_ONE_MINUS_SRC_ALPHA:      current->hwDstSrcBlend |= S_SBLEND_INV_SRC_ALPHA;      break;   case GL_DST_ALPHA:      current->hwDstSrcBlend |= S_SBLEND_DST_ALPHA;      break;   case GL_ONE_MINUS_DST_ALPHA:      current->hwDstSrcBlend |= S_SBLEND_INV_DST_ALPHA;      break;   case GL_DST_COLOR:      current->hwDstSrcBlend |= S_SBLEND_DST_COLOR;      break;   case GL_ONE_MINUS_DST_COLOR:      current->hwDstSrcBlend |= S_SBLEND_INV_DST_COLOR;      break;   case GL_SRC_ALPHA_SATURATE:      current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA_SAT;      break;   }   if (current->hwDstSrcBlend != prev->hwDstSrcBlend) {      prev->hwDstSrcBlend = current->hwDstSrcBlend;      smesa->GlobalFlag |= GFLAG_DSTBLEND;   }}/* ============================================================= * Depth testing */static voidsis6326DDDepthFunc( GLcontext *ctx, GLenum func ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   current->hwZ &= ~MASK_6326_ZTestMode;   switch (func)   {   case GL_LESS:      current->hwZ |= S_ZSET_PASS_LESS;      break;   case GL_GEQUAL:      current->hwZ |= S_ZSET_PASS_GEQUAL;      break;   case GL_LEQUAL:      current->hwZ |= S_ZSET_PASS_LEQUAL;      break;   case GL_GREATER:      current->hwZ |= S_ZSET_PASS_GREATER;      break;   case GL_NOTEQUAL:      current->hwZ |= S_ZSET_PASS_NOTEQUAL;      break;   case GL_EQUAL:      current->hwZ |= S_ZSET_PASS_EQUAL;      break;   case GL_ALWAYS:      current->hwZ |= S_ZSET_PASS_ALWAYS;      break;   case GL_NEVER:      current->hwZ |= S_ZSET_PASS_NEVER;      break;   }   if (current->hwZ != prev->hwZ) {      prev->hwZ = current->hwZ;      smesa->GlobalFlag |= GFLAG_ZSETTING;   }}static voidsis6326DDDepthMask( GLcontext *ctx, GLboolean flag ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *current = &smesa->current;   if (ctx->Depth.Test)      current->hwCapEnable |= S_ENABLE_ZWrite;   else      current->hwCapEnable &= ~S_ENABLE_ZWrite;}/* ============================================================= * Fog */static voidsis6326DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *current = &smesa->current;   __GLSiSHardware *prev = &smesa->prev;   GLint fogColor;   switch(pname)   {   case GL_FOG_COLOR:      fogColor  = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16;      fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8;      fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] );      current->hwFog = 0x01000000 | fogColor;      if (current->hwFog != prev->hwFog) {	 prev->hwFog = current->hwFog;	 smesa->GlobalFlag |= GFLAG_FOGSETTING;      }      break;   }}/* ============================================================= * Clipping */voidsis6326UpdateClipping(GLcontext *ctx){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   GLint x1, y1, x2, y2;   x1 = 0;   y1 = 0;   x2 = smesa->width - 1;   y2 = smesa->height - 1;   if (ctx->Scissor.Enabled) {      if (ctx->Scissor.X > x1)	 x1 = ctx->Scissor.X;      if (ctx->Scissor.Y > y1)	 y1 = ctx->Scissor.Y;      if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2)	 x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;      if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2)	 y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1;   }   y1 = Y_FLIP(y1);   y2 = Y_FLIP(y2);   /*current->clipTopBottom = (y2 << 13) | y1;   current->clipLeftRight = (x1 << 13) | x2;*/ /* XXX */   current->clipTopBottom = (0 << 13) | smesa->height;   current->clipLeftRight = (0 << 13) | smesa->width;   if ((current->clipTopBottom != prev->clipTopBottom) ||       (current->clipLeftRight != prev->clipLeftRight)) {      prev->clipTopBottom = current->clipTopBottom;      prev->clipLeftRight = current->clipLeftRight;      smesa->GlobalFlag |= GFLAG_CLIPPING;   }}static voidsis6326DDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ){   if (ctx->Scissor.Enabled)      sis6326UpdateClipping( ctx );}/* ============================================================= * Culling */static voidsis6326UpdateCull( GLcontext *ctx ){   /* XXX culling */}static voidsis6326DDCullFace( GLcontext *ctx, GLenum mode ){   sis6326UpdateCull( ctx );}static voidsis6326DDFrontFace( GLcontext *ctx, GLenum mode ){   sis6326UpdateCull( ctx );}/* ============================================================= * Masks */static void sis6326DDColorMask( GLcontext *ctx,				GLboolean r, GLboolean g,				GLboolean b, GLboolean a ){   sisContextPtr smesa = SIS_CONTEXT(ctx);	   if (r && g && b && ((ctx->Visual.alphaBits == 0) || a)) {      FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 0);   } else {      FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 1);   }}/* ============================================================= * Rendering attributes */static void sis6326UpdateSpecular(GLcontext *ctx){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *current = &smesa->current;   if (NEED_SECONDARY_COLOR(ctx))      current->hwCapEnable |= S_ENABLE_Specular;   else      current->hwCapEnable &= ~S_ENABLE_Specular;}static void sis6326DDLightModelfv(GLcontext *ctx, GLenum pname,			      const GLfloat *param){   if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {

⌨️ 快捷键说明

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