diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
commit | f4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch) | |
tree | 2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/extras/Mesa/src/mesa/swrast_setup | |
parent | a840692edc9c6d19cd7c057f68e39c7d95eb767d (diff) | |
download | nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2 nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip |
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz
Keywords:
Imported nx-X11-3.1.0-1.tar.gz
into Git repository
Diffstat (limited to 'nx-X11/extras/Mesa/src/mesa/swrast_setup')
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES | 65 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms | 39 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c | 250 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h | 45 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c | 314 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h | 39 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h | 222 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h | 38 | ||||
-rw-r--r-- | nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h | 61 |
9 files changed, 1073 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES b/nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES new file mode 100644 index 000000000..c6cb4ab34 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES @@ -0,0 +1,65 @@ +INTRODUCTION + +A helper module which provides glue to bind the software rasterizer to +the software t&l module. The main task of this module is to build +swrast vertices from the t&l vertex_buffer structs, and to use them to +perform triangle setup functions not implemented in the software +rasterizer. + +The module implements a full set of functions to plug into the +t_vb_render.c driver interface (tnl->Driver.Render.*). + +There are strong advantages to decoupling the software rasterizer from +the t&l module, primarily allowing hardware drivers better control +over fallbacks, the removal of implicit knowledge about the software +rasterizer in the t&l module, allowing the two modules to evolve +independently and allowing either to be substituted with equivalent +functionality from another codebase. + +This module implements triangle/quad setup for offset, unfilled and +twoside-lit triangles. The software rasterizer doesn't handle these +primitives directly. + +Hardware rasterization drivers typically use this module in situations +where no hardware rasterization is possible, ie during total +fallbacks. + +STATE + +To create and destroy the module: + + GLboolean _swsetup_CreateContext( GLcontext *ctx ); + void _swsetup_DestroyContext( GLcontext *ctx ); + +The module is not active by default, and must be installed by calling +_swrast_Wakeup(). This function installs internal swrast_setup +functions into all the tnl->Driver.Render driver hooks, thus taking +over the task of rasterization entirely: + + void _swrast_Wakeup( GLcontext *ctx ); + + +This module tracks state changes internally and maintains derived +values based on the current state. For this to work, the driver +ensure the following funciton is called whenever the state changes and +the swsetup module is 'awake': + + void _swsetup_InvalidateState( GLcontext *ctx, GLuint new_state ); + +There is no explicit call to put the swsetup module to sleep. Simply +install other function pointers into all the tnl->Driver.Render.* +hooks, and (optionally) cease calling _swsetup_InvalidateState(). + +DRIVER INTERFACE + +The module offers a minimal driver interface: + + void (*Start)( GLcontext *ctx ); + void (*Finish)( GLcontext *ctx ); + +These are called before and after the completion of all swrast drawing +activity. As swrast doesn't call callbacks during triangle, line or +point rasterization, these are necessary to provide locking hooks for +some drivers. They may otherwise be left null. + + diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms b/nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms new file mode 100644 index 000000000..3b8af930c --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms @@ -0,0 +1,39 @@ +# Makefile for core library for VMS +# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl +# Last revision : 16 June 2003 + +.first + define gl [---.include.gl] + define math [-.math] + define tnl [-.tnl] + define swrast [-.swrast] + define array_cache [-.array_cache] + +.include [---]mms-config. + +##### MACROS ##### + +VPATH = RCS + +INCDIR = [---.include],[-.main],[-.glapi] +LIBDIR = [---.lib] +CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short) + +SOURCES = ss_context.c ss_triangle.c + +OBJECTS = ss_context.obj,ss_triangle.obj +##### RULES ##### + +VERSION=Mesa V3.4 + +##### TARGETS ##### +# Make the library +$(LIBDIR)$(GL_LIB) : $(OBJECTS) + @ library $(LIBDIR)$(GL_LIB) $(OBJECTS) + +clean : + purge + delete *.obj;* + +ss_context.obj : ss_context.c +ss_triangle.obj : ss_triangle.c diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c new file mode 100644 index 000000000..c63646ca9 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c @@ -0,0 +1,250 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "ss_context.h" +#include "ss_triangle.h" +#include "swrast_setup.h" +#include "tnl/tnl.h" +#include "tnl/t_context.h" +#include "tnl/t_pipeline.h" +#include "tnl/t_vertex.h" + +/* Need to check lighting state and vertex program state to know + * if two-sided lighting is in effect. + */ +#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT|_NEW_PROGRAM) + + +GLboolean +_swsetup_CreateContext( GLcontext *ctx ) +{ + SScontext *swsetup = (SScontext *)CALLOC(sizeof(SScontext)); + + if (!swsetup) + return GL_FALSE; + + ctx->swsetup_context = swsetup; + + swsetup->NewState = ~0; + _swsetup_trifuncs_init( ctx ); + + _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, + sizeof(SWvertex) ); + + + return GL_TRUE; +} + +void +_swsetup_DestroyContext( GLcontext *ctx ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + + if (swsetup) { + FREE(swsetup); + ctx->swsetup_context = 0; + } + + _tnl_free_vertices( ctx ); +} + +static void +_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode ) +{ + SWSETUP_CONTEXT(ctx)->render_prim = mode; + _swrast_render_primitive( ctx, mode ); +} + +#define SWZ ((SWvertex *)0) +#define SWOffset(MEMBER) (((char *)&(SWZ->MEMBER)) - ((char *)SWZ)) + +#define EMIT_ATTR( ATTR, STYLE, MEMBER ) \ +do { \ + map[e].attrib = (ATTR); \ + map[e].format = (STYLE); \ + map[e].offset = SWOffset(MEMBER); \ + e++; \ +} while (0) + + +/* + * We patch this function into tnl->Driver.Render.Start. + * It's called when we start rendering a vertex buffer. + */ +static void +_swsetup_RenderStart( GLcontext *ctx ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + GLuint new_state = swsetup->NewState; + + if (new_state & _SWSETUP_NEW_RENDERINDEX) { + _swsetup_choose_trifuncs( ctx ); + } + + swsetup->NewState = 0; + + _swrast_render_start( ctx ); + + /* Important: + */ + VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; + + + if (tnl->render_inputs != swsetup->last_index) { + GLuint index = tnl->render_inputs; + struct tnl_attr_map map[_TNL_ATTRIB_MAX]; + int i, e = 0; + + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, win ); + + if (index & _TNL_BIT_COLOR0) + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); + + if (index & _TNL_BIT_COLOR1) + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4CHAN_4F_RGBA, specular); + + if (index & _TNL_BIT_FOG) + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, fog); + + if (index & _TNL_BITS_TEX_ANY) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { + if (index & _TNL_BIT_TEX(i)) { + EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F, texcoord[i] ); + } + } + } + + if (index & _TNL_BIT_INDEX) + EMIT_ATTR( _TNL_ATTRIB_INDEX, EMIT_1F, index ); + + if (index & _TNL_BIT_POINTSIZE) + EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize ); + + _tnl_install_attrs( ctx, map, e, + ctx->Viewport._WindowMap.m, + sizeof(SWvertex) ); + + swsetup->last_index = index; + } + +} + +/* + * We patch this function into tnl->Driver.Render.Finish. + * It's called when we finish rendering a vertex buffer. + */ +static void +_swsetup_RenderFinish( GLcontext *ctx ) +{ + _swrast_render_finish( ctx ); +} + +void +_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + swsetup->NewState |= new_state; + _tnl_invalidate_vertex_state( ctx, new_state ); +} + + +void +_swsetup_Wakeup( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + + tnl->Driver.Render.Start = _swsetup_RenderStart; + tnl->Driver.Render.Finish = _swsetup_RenderFinish; + tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive; + tnl->Driver.Render.Interp = _tnl_interp; + tnl->Driver.Render.CopyPV = _tnl_copy_pv; + tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; /* new */ + tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; /* new */ + /* points */ + /* line */ + /* triangle */ + /* quad */ + tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; + tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; + tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; + tnl->Driver.Render.Multipass = 0; + + _tnl_invalidate_vertices( ctx, ~0 ); + _tnl_need_projected_coords( ctx, GL_TRUE ); + _swsetup_InvalidateState( ctx, ~0 ); + + swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf; + swsetup->last_index = 0; +} + + + + + +/* Populate a swrast SWvertex from an attrib-style vertex. + */ +void +_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest ) +{ + const GLfloat *m = ctx->Viewport._WindowMap.m; + GLfloat tmp[4]; + GLuint i; + + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POS, tmp ); + + dest->win[0] = m[0] * tmp[0] + m[12]; + dest->win[1] = m[5] * tmp[1] + m[13]; + dest->win[2] = m[10] * tmp[2] + m[14]; + dest->win[3] = tmp[3]; + + + for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i, dest->texcoord[i] ); + + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp ); + UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); + + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp ); + UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->specular, tmp ); + + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp ); + dest->fog = tmp[0]; + + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_INDEX, tmp ); + dest->index = (GLuint) tmp[0]; + + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp ); + dest->pointSize = tmp[0]; +} + diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h new file mode 100644 index 000000000..2c6e4faf3 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h @@ -0,0 +1,45 @@ + +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999-2002 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +#ifndef SS_CONTEXT_H +#define SS_CONTEXT_H + +#include "mtypes.h" +#include "swrast/swrast.h" +#include "swrast_setup.h" + +typedef struct { + GLuint NewState; + GLenum render_prim; + GLuint last_index; + SWvertex *verts; +} SScontext; + +#define SWSETUP_CONTEXT(ctx) ((SScontext *)ctx->swsetup_context) + +#endif diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c new file mode 100644 index 000000000..d37bdf71c --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c @@ -0,0 +1,314 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +#include "glheader.h" +#include "colormac.h" +#include "macros.h" +#include "mtypes.h" + +#include "tnl/t_context.h" + +#include "ss_triangle.h" +#include "ss_context.h" + +#define SS_RGBA_BIT 0x1 +#define SS_OFFSET_BIT 0x2 +#define SS_TWOSIDE_BIT 0x4 +#define SS_UNFILLED_BIT 0x8 +#define SS_MAX_TRIFUNC 0x10 + +static tnl_triangle_func tri_tab[SS_MAX_TRIFUNC]; +static tnl_quad_func quad_tab[SS_MAX_TRIFUNC]; + + +static void _swsetup_render_line_tri( GLcontext *ctx, + GLuint e0, GLuint e1, GLuint e2, + GLuint facing ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte *ef = VB->EdgeFlag; + SWvertex *verts = swsetup->verts; + SWvertex *v0 = &verts[e0]; + SWvertex *v1 = &verts[e1]; + SWvertex *v2 = &verts[e2]; + GLchan c[2][4]; + GLchan s[2][4]; + GLfloat i[2]; + + /* cull testing */ + if (ctx->Polygon.CullFlag) { + if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT) + return; + if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK) + return; + } + + if (ctx->Light.ShadeModel == GL_FLAT) { + COPY_CHAN4(c[0], v0->color); + COPY_CHAN4(c[1], v1->color); + COPY_CHAN4(s[0], v0->specular); + COPY_CHAN4(s[1], v1->specular); + i[0] = v0->index; + i[1] = v1->index; + + COPY_CHAN4(v0->color, v2->color); + COPY_CHAN4(v1->color, v2->color); + COPY_CHAN4(v0->specular, v2->specular); + COPY_CHAN4(v1->specular, v2->specular); + v0->index = v2->index; + v1->index = v2->index; + } + + if (swsetup->render_prim == GL_POLYGON) { + if (ef[e2]) _swrast_Line( ctx, v2, v0 ); + if (ef[e0]) _swrast_Line( ctx, v0, v1 ); + if (ef[e1]) _swrast_Line( ctx, v1, v2 ); + } else { + if (ef[e0]) _swrast_Line( ctx, v0, v1 ); + if (ef[e1]) _swrast_Line( ctx, v1, v2 ); + if (ef[e2]) _swrast_Line( ctx, v2, v0 ); + } + + if (ctx->Light.ShadeModel == GL_FLAT) { + COPY_CHAN4(v0->color, c[0]); + COPY_CHAN4(v1->color, c[1]); + COPY_CHAN4(v0->specular, s[0]); + COPY_CHAN4(v1->specular, s[1]); + v0->index = i[0]; + v1->index = i[1]; + } +} + +static void _swsetup_render_point_tri( GLcontext *ctx, + GLuint e0, GLuint e1, GLuint e2, + GLuint facing ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte *ef = VB->EdgeFlag; + SWvertex *verts = swsetup->verts; + SWvertex *v0 = &verts[e0]; + SWvertex *v1 = &verts[e1]; + SWvertex *v2 = &verts[e2]; + GLchan c[2][4]; + GLchan s[2][4]; + GLfloat i[2]; + + /* cull testing */ + if (ctx->Polygon.CullFlag) { + if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT) + return; + if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK) + return; + } + + if (ctx->Light.ShadeModel == GL_FLAT) { + /* save colors/indexes for v0, v1 vertices */ + COPY_CHAN4(c[0], v0->color); + COPY_CHAN4(c[1], v1->color); + COPY_CHAN4(s[0], v0->specular); + COPY_CHAN4(s[1], v1->specular); + i[0] = v0->index; + i[1] = v1->index; + + /* copy v2 color/indexes to v0, v1 indexes */ + COPY_CHAN4(v0->color, v2->color); + COPY_CHAN4(v1->color, v2->color); + COPY_CHAN4(v0->specular, v2->specular); + COPY_CHAN4(v1->specular, v2->specular); + v0->index = v2->index; + v1->index = v2->index; + } + + if (ef[e0]) _swrast_Point( ctx, v0 ); + if (ef[e1]) _swrast_Point( ctx, v1 ); + if (ef[e2]) _swrast_Point( ctx, v2 ); + + if (ctx->Light.ShadeModel == GL_FLAT) { + /* restore v0, v1 colores/indexes */ + COPY_CHAN4(v0->color, c[0]); + COPY_CHAN4(v1->color, c[1]); + COPY_CHAN4(v0->specular, s[0]); + COPY_CHAN4(v1->specular, s[1]); + v0->index = i[0]; + v1->index = i[1]; + } + _swrast_flush(ctx); +} + +#define SS_COLOR(a,b) UNCLAMPED_FLOAT_TO_RGBA_CHAN(a,b) +#define SS_SPEC(a,b) UNCLAMPED_FLOAT_TO_RGB_CHAN(a,b) +#define SS_IND(a,b) (a = b) + +#define IND (0) +#define TAG(x) x +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT) +#define TAG(x) x##_offset +#include "ss_tritmp.h" + +#define IND (SS_TWOSIDE_BIT) +#define TAG(x) x##_twoside +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT) +#define TAG(x) x##_offset_twoside +#include "ss_tritmp.h" + +#define IND (SS_UNFILLED_BIT) +#define TAG(x) x##_unfilled +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT) +#define TAG(x) x##_offset_unfilled +#include "ss_tritmp.h" + +#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT) +#define TAG(x) x##_twoside_unfilled +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT) +#define TAG(x) x##_offset_twoside_unfilled +#include "ss_tritmp.h" + +#define IND (0|SS_RGBA_BIT) +#define TAG(x) x##_rgba +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_RGBA_BIT) +#define TAG(x) x##_offset_rgba +#include "ss_tritmp.h" + +#define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT) +#define TAG(x) x##_twoside_rgba +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT) +#define TAG(x) x##_offset_twoside_rgba +#include "ss_tritmp.h" + +#define IND (SS_UNFILLED_BIT|SS_RGBA_BIT) +#define TAG(x) x##_unfilled_rgba +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT) +#define TAG(x) x##_offset_unfilled_rgba +#include "ss_tritmp.h" + +#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT) +#define TAG(x) x##_twoside_unfilled_rgba +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT) +#define TAG(x) x##_offset_twoside_unfilled_rgba +#include "ss_tritmp.h" + + +void _swsetup_trifuncs_init( GLcontext *ctx ) +{ + (void) ctx; + + init(); + init_offset(); + init_twoside(); + init_offset_twoside(); + init_unfilled(); + init_offset_unfilled(); + init_twoside_unfilled(); + init_offset_twoside_unfilled(); + + init_rgba(); + init_offset_rgba(); + init_twoside_rgba(); + init_offset_twoside_rgba(); + init_unfilled_rgba(); + init_offset_unfilled_rgba(); + init_twoside_unfilled_rgba(); + init_offset_twoside_unfilled_rgba(); +} + + +static void swsetup_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; + GLuint i; + + if (VB->Elts) { + for (i = first; i < last; i++) + if (VB->ClipMask[VB->Elts[i]] == 0) + _swrast_Point( ctx, &verts[VB->Elts[i]] ); + } + else { + for (i = first; i < last; i++) + if (VB->ClipMask[i] == 0) + _swrast_Point( ctx, &verts[i] ); + } +} + +static void swsetup_line( GLcontext *ctx, GLuint v0, GLuint v1 ) +{ + SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; + _swrast_Line( ctx, &verts[v0], &verts[v1] ); +} + + + +void _swsetup_choose_trifuncs( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + GLuint ind = 0; + + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) + ind |= SS_OFFSET_BIT; + + if ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) || + (ctx->VertexProgram._Enabled && ctx->VertexProgram.TwoSideEnabled)) + ind |= SS_TWOSIDE_BIT; + + /* We piggyback the two-sided stencil front/back determination on the + * unfilled triangle path. + */ + if (ctx->Polygon.FrontMode != GL_FILL || + ctx->Polygon.BackMode != GL_FILL || + (ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide)) + ind |= SS_UNFILLED_BIT; + + if (ctx->Visual.rgbMode) + ind |= SS_RGBA_BIT; + + tnl->Driver.Render.Triangle = tri_tab[ind]; + tnl->Driver.Render.Quad = quad_tab[ind]; + tnl->Driver.Render.Line = swsetup_line; + tnl->Driver.Render.Points = swsetup_points; + + ctx->_Facing = 0; +} diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h new file mode 100644 index 000000000..78833269e --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h @@ -0,0 +1,39 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +#ifndef SS_TRIANGLE_H +#define SS_TRIANGLE_H + +#include "mtypes.h" +#include "ss_context.h" + + +void _swsetup_trifuncs_init( GLcontext *ctx ); +void _swsetup_choose_trifuncs( GLcontext *ctx ); + +#endif diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h new file mode 100644 index 000000000..61c9b2817 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h @@ -0,0 +1,222 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + + +static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) +{ + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; + SWvertex *v[3]; + GLfloat z[3]; + GLfloat offset; + GLenum mode = GL_FILL; + GLuint facing = 0; + GLchan saved_color[3][4]; + GLchan saved_spec[3][4]; + GLfloat saved_index[3]; + + v[0] = &verts[e0]; + v[1] = &verts[e1]; + v[2] = &verts[e2]; + + + if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) + { + GLfloat ex = v[0]->win[0] - v[2]->win[0]; + GLfloat ey = v[0]->win[1] - v[2]->win[1]; + GLfloat fx = v[1]->win[0] - v[2]->win[0]; + GLfloat fy = v[1]->win[1] - v[2]->win[1]; + GLfloat cc = ex*fy - ey*fx; + + if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT)) + { + facing = (cc < 0.0) ^ ctx->Polygon._FrontBit; + if (ctx->Stencil.TestTwoSide) + ctx->_Facing = facing; /* for 2-sided stencil test */ + + if (IND & SS_UNFILLED_BIT) + mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; + + if (facing == 1) { + if (IND & SS_TWOSIDE_BIT) { + if (IND & SS_RGBA_BIT) { + GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; + + COPY_CHAN4(saved_color[0], v[0]->color); + COPY_CHAN4(saved_color[1], v[1]->color); + COPY_CHAN4(saved_color[2], v[2]->color); + + if (VB->ColorPtr[1]->stride) { + SS_COLOR(v[0]->color, vbcolor[e0]); + SS_COLOR(v[1]->color, vbcolor[e1]); + SS_COLOR(v[2]->color, vbcolor[e2]); + } + else { + SS_COLOR(v[0]->color, vbcolor[0]); + SS_COLOR(v[1]->color, vbcolor[0]); + SS_COLOR(v[2]->color, vbcolor[0]); + } + + if (VB->SecondaryColorPtr[1]) { + GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; + + COPY_CHAN4(saved_spec[0], v[0]->specular); + COPY_CHAN4(saved_spec[1], v[1]->specular); + COPY_CHAN4(saved_spec[2], v[2]->specular); + + if (VB->SecondaryColorPtr[1]->stride) { + SS_SPEC(v[0]->specular, vbspec[e0]); + SS_SPEC(v[1]->specular, vbspec[e1]); + SS_SPEC(v[2]->specular, vbspec[e2]); + } + else { + SS_SPEC(v[0]->specular, vbspec[0]); + SS_SPEC(v[1]->specular, vbspec[0]); + SS_SPEC(v[2]->specular, vbspec[0]); + } + } + } else { + GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data; + saved_index[0] = v[0]->index; + saved_index[1] = v[1]->index; + saved_index[2] = v[2]->index; + + SS_IND(v[0]->index, (GLuint) vbindex[e0]); + SS_IND(v[1]->index, (GLuint) vbindex[e1]); + SS_IND(v[2]->index, (GLuint) vbindex[e2]); + } + } + } + } + + if (IND & SS_OFFSET_BIT) + { + offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD; + z[0] = v[0]->win[2]; + z[1] = v[1]->win[2]; + z[2] = v[2]->win[2]; + if (cc * cc > 1e-16) { + const GLfloat ez = z[0] - z[2]; + const GLfloat fz = z[1] - z[2]; + const GLfloat oneOverArea = 1.0F / cc; + const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea); + const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea); + offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; + /* Unfortunately, we need to clamp to prevent negative Zs below. + * Technically, we should do the clamping per-fragment. + */ + offset = MAX2(offset, -v[0]->win[2]); + offset = MAX2(offset, -v[1]->win[2]); + offset = MAX2(offset, -v[2]->win[2]); + } + } + } + + if (mode == GL_POINT) { + if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { + v[0]->win[2] += offset; + v[1]->win[2] += offset; + v[2]->win[2] += offset; + } + _swsetup_render_point_tri( ctx, e0, e1, e2, facing ); + } else if (mode == GL_LINE) { + if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { + v[0]->win[2] += offset; + v[1]->win[2] += offset; + v[2]->win[2] += offset; + } + _swsetup_render_line_tri( ctx, e0, e1, e2, facing ); + } else { + if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { + v[0]->win[2] += offset; + v[1]->win[2] += offset; + v[2]->win[2] += offset; + } + _swrast_Triangle( ctx, v[0], v[1], v[2] ); + } + + if (IND & SS_OFFSET_BIT) { + v[0]->win[2] = z[0]; + v[1]->win[2] = z[1]; + v[2]->win[2] = z[2]; + } + + if (IND & SS_TWOSIDE_BIT) { + if (facing == 1) { + if (IND & SS_RGBA_BIT) { + COPY_CHAN4(v[0]->color, saved_color[0]); + COPY_CHAN4(v[1]->color, saved_color[1]); + COPY_CHAN4(v[2]->color, saved_color[2]); + if (VB->SecondaryColorPtr[1]) { + COPY_CHAN4(v[0]->specular, saved_spec[0]); + COPY_CHAN4(v[1]->specular, saved_spec[1]); + COPY_CHAN4(v[2]->specular, saved_spec[2]); + } + } else { + v[0]->index = saved_index[0]; + v[1]->index = saved_index[1]; + v[2]->index = saved_index[2]; + } + } + } +} + + + +/* Need to fixup edgeflags when decomposing to triangles: + */ +static void TAG(quadfunc)( GLcontext *ctx, GLuint v0, + GLuint v1, GLuint v2, GLuint v3 ) +{ + if (IND & SS_UNFILLED_BIT) { + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte ef1 = VB->EdgeFlag[v1]; + GLubyte ef3 = VB->EdgeFlag[v3]; + VB->EdgeFlag[v1] = 0; + TAG(triangle)( ctx, v0, v1, v3 ); + VB->EdgeFlag[v1] = ef1; + VB->EdgeFlag[v3] = 0; + TAG(triangle)( ctx, v1, v2, v3 ); + VB->EdgeFlag[v3] = ef3; + } else { + TAG(triangle)( ctx, v0, v1, v3 ); + TAG(triangle)( ctx, v1, v2, v3 ); + } +} + + + + +static void TAG(init)( void ) +{ + tri_tab[IND] = TAG(triangle); + quad_tab[IND] = TAG(quadfunc); +} + + +#undef IND +#undef TAG diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h new file mode 100644 index 000000000..6ea0cb1a7 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h @@ -0,0 +1,38 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +#ifndef SS_VB_H +#define SS_VB_H + +#include "mtypes.h" +#include "swrast_setup.h" + +void _swsetup_vb_init( GLcontext *ctx ); +void _swsetup_choose_rastersetup_func( GLcontext *ctx ); + +#endif diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h new file mode 100644 index 000000000..5dcbe2675 --- /dev/null +++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h @@ -0,0 +1,61 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul 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 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 + * BRIAN PAUL 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: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +/* Public interface to the swrast_setup module. This module provides + * an implementation of the driver interface to t_vb_render.c, and uses + * the software rasterizer (swrast) to perform actual rasterization. + * + * The internals of the implementation are private, but can be hooked + * into tnl at any time (except between RenderStart/RenderEnd) by + * calling _swsetup_Wakeup(). + */ + +#ifndef SWRAST_SETUP_H +#define SWRAST_SETUP_H + +#include "swrast/swrast.h" + +extern GLboolean +_swsetup_CreateContext( GLcontext *ctx ); + +extern void +_swsetup_DestroyContext( GLcontext *ctx ); + +extern void +_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state ); + +extern void +_swsetup_Wakeup( GLcontext *ctx ); + +/* Helper function to translate a hardware vertex (as understood by + * the tnl/t_vertex.c code) to a swrast vertex. + */ +extern void +_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest ); + +#endif |