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

📄 i830_metaops.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************************** *  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * 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, sub license, 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 NON-INFRINGEMENT. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. *  **************************************************************************/#include "glheader.h"#include "enums.h"#include "mtypes.h"#include "macros.h"#include "utils.h"#include "intel_screen.h"#include "intel_batchbuffer.h"#include "intel_ioctl.h"#include "intel_regions.h"#include "i830_context.h"#include "i830_reg.h"/* A large amount of state doesn't need to be uploaded. */#define ACTIVE (I830_UPLOAD_INVARIENT |         \		I830_UPLOAD_CTX |		\		I830_UPLOAD_BUFFERS |		\		I830_UPLOAD_STIPPLE |		\		I830_UPLOAD_TEXBLEND(0) |	\		I830_UPLOAD_TEX(0))#define SET_STATE( i830, STATE )		\do {						\   i830->current->emitted &= ~ACTIVE;			\   i830->current = &i830->STATE;		\   i830->current->emitted &= ~ACTIVE;			\} while (0)static voidset_no_stencil_write(struct intel_context *intel){   struct i830_context *i830 = i830_context(&intel->ctx);   /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )    */   i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_STENCIL_WRITE;   i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE;   i830->meta.emitted &= ~I830_UPLOAD_CTX;}static voidset_no_depth_write(struct intel_context *intel){   struct i830_context *i830 = i830_context(&intel->ctx);   /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )    */   i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;   i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;   i830->meta.emitted &= ~I830_UPLOAD_CTX;}/* Set depth unit to replace. */static voidset_depth_replace(struct intel_context *intel){   struct i830_context *i830 = i830_context(&intel->ctx);   /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )    * ctx->Driver.DepthMask( ctx, GL_TRUE )    */   i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;   i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE;   /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS )    */   i830->meta.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK;   i830->meta.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC |                                          DEPTH_TEST_FUNC                                          (COMPAREFUNC_ALWAYS));   i830->meta.emitted &= ~I830_UPLOAD_CTX;}/* Set stencil unit to replace always with the reference value. */static voidset_stencil_replace(struct intel_context *intel,                    GLuint s_mask, GLuint s_clear){   struct i830_context *i830 = i830_context(&intel->ctx);   /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE )    */   i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST;   i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE;   /* ctx->Driver.StencilMask( ctx, s_mask )    */   i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;   i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |                                          STENCIL_WRITE_MASK((s_mask &                                                              0xff)));   /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE )    */   i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK);   i830->meta.Ctx[I830_CTXREG_STENCILTST] |=      (ENABLE_STENCIL_PARMS |       STENCIL_FAIL_OP(STENCILOP_REPLACE) |       STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE) |       STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_REPLACE));   /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_clear, ~0 )    */   i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;   i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |                                          STENCIL_TEST_MASK(0xff));   i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK |                                               ENABLE_STENCIL_TEST_FUNC_MASK);   i830->meta.Ctx[I830_CTXREG_STENCILTST] |=      (ENABLE_STENCIL_REF_VALUE |       ENABLE_STENCIL_TEST_FUNC |       STENCIL_REF_VALUE((s_clear & 0xff)) |       STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS));   i830->meta.emitted &= ~I830_UPLOAD_CTX;}static voidset_color_mask(struct intel_context *intel, GLboolean state){   struct i830_context *i830 = i830_context(&intel->ctx);   const GLuint mask = ((1 << WRITEMASK_RED_SHIFT) |                        (1 << WRITEMASK_GREEN_SHIFT) |                        (1 << WRITEMASK_BLUE_SHIFT) |                        (1 << WRITEMASK_ALPHA_SHIFT));   i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~mask;   if (state) {      i830->meta.Ctx[I830_CTXREG_ENABLES_2] |=         (i830->state.Ctx[I830_CTXREG_ENABLES_2] & mask);   }   i830->meta.emitted &= ~I830_UPLOAD_CTX;}/* Installs a one-stage passthrough texture blend pipeline.  Is there * more that can be done to turn off texturing? */static voidset_no_texture(struct intel_context *intel){   struct i830_context *i830 = i830_context(&intel->ctx);   static const struct gl_tex_env_combine_state comb = {      GL_NONE, GL_NONE,      {GL_TEXTURE, 0, 0,}, {GL_TEXTURE, 0, 0,},      {GL_SRC_COLOR, 0, 0}, {GL_SRC_ALPHA, 0, 0},      0, 0, 0, 0   };   i830->meta.TexBlendWordsUsed[0] =      i830SetTexEnvCombine(i830, &comb, 0, TEXBLENDARG_TEXEL0,                           i830->meta.TexBlend[0], NULL);   i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE;   i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0);}/* Set up a single element blend stage for 'replace' texturing with no * funny ops. */static voidset_texture_blend_replace(struct intel_context *intel){   struct i830_context *i830 = i830_context(&intel->ctx);   static const struct gl_tex_env_combine_state comb = {      GL_REPLACE, GL_REPLACE,      {GL_TEXTURE, GL_TEXTURE, GL_TEXTURE,}, {GL_TEXTURE, GL_TEXTURE,                                              GL_TEXTURE,},      {GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_COLOR}, {GL_SRC_ALPHA, GL_SRC_ALPHA,                                                   GL_SRC_ALPHA},      0, 0, 1, 1   };   i830->meta.TexBlendWordsUsed[0] =      i830SetTexEnvCombine(i830, &comb, 0, TEXBLENDARG_TEXEL0,                           i830->meta.TexBlend[0], NULL);   i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE;   i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0);

⌨️ 快捷键说明

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