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

📄 sis_tris.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
/* $XFree86*/ /* -*- c-basic-offset: 3 -*- *//**************************************************************************Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.Copyright 2003 Eric AnholtAll Rights Reserved.Permission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the "Software"),to deal in the Software without restriction, including without limitationon the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whomthe Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice (including the nextparagraph) shall be included in all copies or substantial portions of theSoftware.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALLERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OROTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THEUSE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//* * Authors: *   Sung-Ching Lin <sclin@sis.com.tw> *   Eric Anholt <anholt@FreeBSD.org> */#include "glheader.h"#include "mtypes.h"#include "colormac.h"#include "macros.h"#include "swrast/swrast.h"#include "swrast_setup/swrast_setup.h"#include "tnl/t_context.h"#include "tnl/t_pipeline.h"#include "sis_context.h"#include "sis_tris.h"#include "sis_state.h"#include "sis_lock.h"#include "sis_span.h"#include "sis_alloc.h"#include "sis_tex.h"/* 6326 and 300-series shared */static const GLuint hw_prim[GL_POLYGON+1] = {   OP_3D_POINT_DRAW,		/* GL_POINTS */   OP_3D_LINE_DRAW,		/* GL_LINES */   OP_3D_LINE_DRAW,		/* GL_LINE_LOOP */   OP_3D_LINE_DRAW,		/* GL_LINE_STRIP */   OP_3D_TRIANGLE_DRAW,		/* GL_TRIANGLES */   OP_3D_TRIANGLE_DRAW,		/* GL_TRIANGLE_STRIP */   OP_3D_TRIANGLE_DRAW,		/* GL_TRIANGLE_FAN */   OP_3D_TRIANGLE_DRAW,		/* GL_QUADS */   OP_3D_TRIANGLE_DRAW,		/* GL_QUAD_STRIP */   OP_3D_TRIANGLE_DRAW		/* GL_POLYGON */};static const GLuint hw_prim_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = {   OP_3D_FIRE_TSARGBa,   OP_3D_FIRE_TSARGBb,   OP_3D_FIRE_TSARGBc};static const GLuint hw_prim_6326_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = {   OP_6326_3D_FIRE_TSARGBa,   OP_6326_3D_FIRE_TSARGBb,   OP_6326_3D_FIRE_TSARGBc};static const GLuint hw_prim_mmio_shade[OP_3D_TRIANGLE_DRAW+1] = {   SHADE_FLAT_VertexA,   SHADE_FLAT_VertexB,   SHADE_FLAT_VertexC};static const GLuint hw_prim_agp_type[OP_3D_TRIANGLE_DRAW+1] = {   MASK_PsPointList,   MASK_PsLineList,   MASK_PsTriangleList};static const GLuint hw_prim_agp_shade[OP_3D_TRIANGLE_DRAW+1] = {   MASK_PsShadingFlatA,   MASK_PsShadingFlatB,   MASK_PsShadingFlatC};static void sisRasterPrimitive( GLcontext *ctx, GLuint hwprim );static void sisRenderPrimitive( GLcontext *ctx, GLenum prim );/*********************************************************************** *                    Emit primitives as inline vertices               * ***********************************************************************/#define HAVE_QUADS 0#define HAVE_LINES 1#define HAVE_POINTS 1#define CTX_ARG sisContextPtr smesa#define GET_VERTEX_DWORDS() smesa->vertex_size#define ALLOC_VERTS( n, size ) sisAllocDmaLow( smesa, n * size * sizeof(int) )#undef LOCAL_VARS#define LOCAL_VARS						\   sisContextPtr smesa = SIS_CONTEXT(ctx);			\   const char *vertptr = smesa->verts;#define VERT(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int)))#define VERTEX sisVertex #undef TAG#define TAG(x) sis_##x#include "tnl_dd/t_dd_triemit.h"#undef TAG#undef LOCAL_VARS/*********************************************************************** *             Dispatch vertices to hardware through MMIO              * ***********************************************************************//* The ARGB write of the last vertex of the primitive fires the 3d engine, so * save it until the end. */#define SIS_MMIO_WRITE_VERTEX(_v, i, lastvert)			\do {								\   GLuint __color, __i = 0;					\   MMIO(REG_3D_TSXa+(i)*0x30, _v->ui[__i++]);			\   MMIO(REG_3D_TSYa+(i)*0x30, _v->ui[__i++]);			\   MMIO(REG_3D_TSZa+(i)*0x30, _v->ui[__i++]);			\   if (SIS_STATES & VERT_W)					\      MMIO(REG_3D_TSWGa+(i)*0x30, _v->ui[__i++]);		\   __color = _v->ui[__i++];					\   if (SIS_STATES & VERT_SPEC)					\      MMIO(REG_3D_TSFSa+(i)*0x30, _v->ui[__i++]);		\   if (SIS_STATES & VERT_UV0) {					\      MMIO(REG_3D_TSUAa+(i)*0x30, _v->ui[__i++]);		\      MMIO(REG_3D_TSVAa+(i)*0x30, _v->ui[__i++]);		\   }								\   if (SIS_STATES & VERT_UV1) {					\      MMIO(REG_3D_TSUBa+(i)*0x30, _v->ui[__i++]);		\      MMIO(REG_3D_TSVBa+(i)*0x30, _v->ui[__i++]);		\   }								\   if (lastvert || (SIS_STATES & VERT_SMOOTH))			\      MMIO(REG_3D_TSARGBa+(i)*0x30, __color);			\} while (0)#define SIS6326_MMIO_WRITE_VERTEX(_v, i, lastvert)		\do {								\   GLuint __color, __i = 0;					\   MMIO(REG_6326_3D_TSXa+(i)*0x20, _v->ui[__i++]);		\   MMIO(REG_6326_3D_TSYa+(i)*0x20, _v->ui[__i++]);		\   MMIO(REG_6326_3D_TSZa+(i)*0x20, _v->ui[__i++]);		\   if (SIS_STATES & VERT_W)					\      MMIO(REG_6326_3D_TSWa+(i)*0x20, _v->ui[__i++]);		\   __color = _v->ui[__i++];					\   if (SIS_STATES & VERT_SPEC)					\      MMIO(REG_6326_3D_TSFSa+(i)*0x20, _v->ui[__i++]);		\   if (SIS_STATES & VERT_UV0) {					\      MMIO(REG_6326_3D_TSUa+(i)*0x20, _v->ui[__i++]);		\      MMIO(REG_6326_3D_TSVa+(i)*0x20, _v->ui[__i++]);		\   }								\   if (lastvert || (SIS_STATES & VERT_SMOOTH))			\      MMIO(REG_6326_3D_TSARGBa+(i)*0x30, __color);		\} while (0)#define MMIO_VERT_REG_COUNT 10#define VERT_SMOOTH	0x01#define VERT_W		0x02#define VERT_SPEC	0x04#define VERT_UV0	0x08#define VERT_UV1	0x10#define VERT_6326	0x20	/* Right after UV1, but won't have a UV1 set */typedef void (*mmio_draw_func)(sisContextPtr smesa, char *verts);static mmio_draw_func sis_tri_func_mmio[48];static mmio_draw_func sis_line_func_mmio[48];static mmio_draw_func sis_point_func_mmio[48];#define SIS_STATES (0)#define TAG(x) x##_none#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH)#define TAG(x) x##_g#include "sis_tritmp.h"#define SIS_STATES (VERT_W)#define TAG(x) x##_w#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W)#define TAG(x) x##_gw#include "sis_tritmp.h"#define SIS_STATES (VERT_SPEC)#define TAG(x) x##_s#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_SPEC)#define TAG(x) x##_gs#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_SPEC)#define TAG(x) x##_ws#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC)#define TAG(x) x##_gws#include "sis_tritmp.h"#define SIS_STATES (VERT_UV0)#define TAG(x) x##_t0#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_UV0)#define TAG(x) x##_gt0#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_UV0)#define TAG(x) x##_wt0#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0)#define TAG(x) x##_gwt0#include "sis_tritmp.h"#define SIS_STATES (VERT_SPEC | VERT_UV0)#define TAG(x) x##_st0#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0)#define TAG(x) x##_gst0#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0)#define TAG(x) x##_wst0#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0)#define TAG(x) x##_gwst0#include "sis_tritmp.h"#define SIS_STATES (VERT_UV1)#define TAG(x) x##_t1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_UV1)#define TAG(x) x##_gt1#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_UV1)#define TAG(x) x##_wt1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV1)#define TAG(x) x##_gwt1#include "sis_tritmp.h"#define SIS_STATES (VERT_SPEC | VERT_UV1)#define TAG(x) x##_st1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV1)#define TAG(x) x##_gst1#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV1)#define TAG(x) x##_wst1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV1)#define TAG(x) x##_gwst1#include "sis_tritmp.h"#define SIS_STATES (VERT_UV0 | VERT_UV1)#define TAG(x) x##_t0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_UV0 | VERT_UV1)#define TAG(x) x##_gt0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_UV0 | VERT_UV1)#define TAG(x) x##_wt0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0 | VERT_UV1)#define TAG(x) x##_gwt0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_SPEC | VERT_UV0 | VERT_UV1)#define TAG(x) x##_st0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0 | VERT_UV1)#define TAG(x) x##_gst0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1)#define TAG(x) x##_wst0t1#include "sis_tritmp.h"#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1)#define TAG(x) x##_gwst0t1#include "sis_tritmp.h"/*********************************************************************** *          Macros for t_dd_tritmp.h to draw basic primitives          * ***********************************************************************/#define TRI( a, b, c )				\do { 						\   if (DO_FALLBACK)				\      smesa->draw_tri( smesa, a, b, c );	\   else						\      sis_triangle( smesa, a, b, c );		\} while (0)#define QUAD( a, b, c, d )			\do { 						\   if (DO_FALLBACK) {				\      smesa->draw_tri( smesa, a, b, d );	\      smesa->draw_tri( smesa, b, c, d );	\   } else					\      sis_quad( smesa, a, b, c, d );		\} while (0)#define LINE( v0, v1 )				\do { 						\   if (DO_FALLBACK)				\      smesa->draw_line( smesa, v0, v1 );	\   else						\      sis_line( smesa, v0, v1 );		\} while (0)#define POINT( v0 )				\do { 						\   if (DO_FALLBACK)				\      smesa->draw_point( smesa, v0 );		\   else						\      sis_point( smesa, v0 );			\} while (0)/*********************************************************************** *              Build render functions from dd templates               * ***********************************************************************/#define SIS_OFFSET_BIT 		0x01#define SIS_TWOSIDE_BIT		0x02#define SIS_UNFILLED_BIT	0x04#define SIS_FALLBACK_BIT	0x08#define SIS_MAX_TRIFUNC		0x10static struct {   tnl_points_func	        points;   tnl_line_func		line;   tnl_triangle_func	triangle;   tnl_quad_func		quad;} rast_tab[SIS_MAX_TRIFUNC];#define DO_FALLBACK (IND & SIS_FALLBACK_BIT)#define DO_OFFSET   (IND & SIS_OFFSET_BIT)#define DO_UNFILLED (IND & SIS_UNFILLED_BIT)#define DO_TWOSIDE  (IND & SIS_TWOSIDE_BIT)#define DO_FLAT      0#define DO_TRI       1#define DO_QUAD      1#define DO_LINE      1#define DO_POINTS    1#define DO_FULL_QUAD 1#define HAVE_RGBA   1#define HAVE_SPEC   1#define HAVE_BACK_COLORS  0#define HAVE_HW_FLATSHADE 1#define VERTEX sisVertex#define TAB rast_tab

⌨️ 快捷键说明

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