summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa
diff options
context:
space:
mode:
Diffstat (limited to 'xc/extras/Mesa')
-rw-r--r--xc/extras/Mesa/include/GL/gl.h11
-rw-r--r--xc/extras/Mesa/include/GL/glext.h6
-rw-r--r--xc/extras/Mesa/src/FX/X86/fx_3dnow_fastpath.S82
-rw-r--r--xc/extras/Mesa/src/FX/X86/fx_3dnow_fasttmp.h313
-rw-r--r--xc/extras/Mesa/src/FX/fxapi.c1424
-rw-r--r--xc/extras/Mesa/src/FX/fxclip.c554
-rw-r--r--xc/extras/Mesa/src/FX/fxcliptmp.h346
-rw-r--r--xc/extras/Mesa/src/FX/fxcva.c513
-rw-r--r--xc/extras/Mesa/src/FX/fxcva.h70
-rw-r--r--xc/extras/Mesa/src/FX/fxcvatmp.h262
-rw-r--r--xc/extras/Mesa/src/FX/fxdd.c1491
-rw-r--r--xc/extras/Mesa/src/FX/fxddspan.c1825
-rw-r--r--xc/extras/Mesa/src/FX/fxddtex.c1089
-rw-r--r--xc/extras/Mesa/src/FX/fxdrv.h691
-rw-r--r--xc/extras/Mesa/src/FX/fxfastpath.c425
-rw-r--r--xc/extras/Mesa/src/FX/fxfasttmp.h367
-rw-r--r--xc/extras/Mesa/src/FX/fxglidew.c466
-rw-r--r--xc/extras/Mesa/src/FX/fxglidew.h938
-rw-r--r--xc/extras/Mesa/src/FX/fxpipeline.c302
-rw-r--r--xc/extras/Mesa/src/FX/fxrender.c785
-rw-r--r--xc/extras/Mesa/src/FX/fxsanity.c124
-rw-r--r--xc/extras/Mesa/src/FX/fxsdettmp.h161
-rw-r--r--xc/extras/Mesa/src/FX/fxsetup.c2
-rw-r--r--xc/extras/Mesa/src/FX/fxstripdet.c164
-rw-r--r--xc/extras/Mesa/src/FX/fxtexman.c40
-rw-r--r--xc/extras/Mesa/src/FX/fxtrifuncs.c372
-rw-r--r--xc/extras/Mesa/src/FX/fxtritmp.h474
-rw-r--r--xc/extras/Mesa/src/FX/fxvs_tmp.h215
-rw-r--r--xc/extras/Mesa/src/FX/fxvsetup.c575
-rw-r--r--xc/extras/Mesa/src/FX/fxvsetup.h199
-rw-r--r--xc/extras/Mesa/src/FX/fxwgl.c870
-rw-r--r--xc/extras/Mesa/src/OSmesa/osmesa.c1
-rw-r--r--xc/extras/Mesa/src/X/fakeglx.c6
-rw-r--r--xc/extras/Mesa/src/X/xmesa1.c148
-rw-r--r--xc/extras/Mesa/src/X/xmesa2.c10
-rw-r--r--xc/extras/Mesa/src/X/xmesa3.c6
-rw-r--r--xc/extras/Mesa/src/X/xmesa4.c101
-rw-r--r--xc/extras/Mesa/src/X/xmesaP.h3
-rw-r--r--xc/extras/Mesa/src/X86/3dnow.c2
-rw-r--r--xc/extras/Mesa/src/X86/3dnow_norm_raw.S418
-rw-r--r--xc/extras/Mesa/src/X86/katmai.c2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_masked1.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_masked2.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_masked3.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_masked4.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_raw1.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_raw2.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_raw3.S2
-rw-r--r--xc/extras/Mesa/src/X86/katmai_xform_raw4.S2
-rw-r--r--xc/extras/Mesa/src/X86/x86.c9
-rw-r--r--xc/extras/Mesa/src/X86/x86a.S2
-rw-r--r--xc/extras/Mesa/src/accum.c3
-rw-r--r--xc/extras/Mesa/src/attrib.c10
-rw-r--r--xc/extras/Mesa/src/blend.c4
-rw-r--r--xc/extras/Mesa/src/buffers.c9
-rw-r--r--xc/extras/Mesa/src/clip_funcs.h41
-rw-r--r--xc/extras/Mesa/src/colortab.c165
-rw-r--r--xc/extras/Mesa/src/config.c9
-rw-r--r--xc/extras/Mesa/src/config.h4
-rw-r--r--xc/extras/Mesa/src/context.c107
-rw-r--r--xc/extras/Mesa/src/copypix.c13
-rw-r--r--xc/extras/Mesa/src/dd.h59
-rw-r--r--xc/extras/Mesa/src/debug_xform.c23
-rw-r--r--xc/extras/Mesa/src/dlist.c5
-rw-r--r--xc/extras/Mesa/src/drawpix.c129
-rw-r--r--xc/extras/Mesa/src/enums.c25
-rw-r--r--xc/extras/Mesa/src/eval.c53
-rw-r--r--xc/extras/Mesa/src/extensions.c6
-rw-r--r--xc/extras/Mesa/src/fog.c1
-rw-r--r--xc/extras/Mesa/src/get.c44
-rw-r--r--xc/extras/Mesa/src/glapinoop.c13
-rw-r--r--xc/extras/Mesa/src/glheader.h16
-rw-r--r--xc/extras/Mesa/src/image.c22
-rw-r--r--xc/extras/Mesa/src/imaging.c9
-rw-r--r--xc/extras/Mesa/src/light.c282
-rw-r--r--xc/extras/Mesa/src/light.h4
-rw-r--r--xc/extras/Mesa/src/lines.c199
-rw-r--r--xc/extras/Mesa/src/linetemp.h8
-rw-r--r--xc/extras/Mesa/src/lnaatemp.h12
-rw-r--r--xc/extras/Mesa/src/logic.c2
-rw-r--r--xc/extras/Mesa/src/matrix.c25
-rw-r--r--xc/extras/Mesa/src/matrix.h4
-rw-r--r--xc/extras/Mesa/src/mem.c82
-rw-r--r--xc/extras/Mesa/src/mem.h11
-rw-r--r--xc/extras/Mesa/src/mmath.h14
-rw-r--r--xc/extras/Mesa/src/pb.c17
-rw-r--r--xc/extras/Mesa/src/points.c130
-rw-r--r--xc/extras/Mesa/src/readpix.c3
-rw-r--r--xc/extras/Mesa/src/rect.c17
-rw-r--r--xc/extras/Mesa/src/render_tmp.h4
-rw-r--r--xc/extras/Mesa/src/shade.c62
-rw-r--r--xc/extras/Mesa/src/shade_tmp.h273
-rw-r--r--xc/extras/Mesa/src/span.c57
-rw-r--r--xc/extras/Mesa/src/stages.c31
-rw-r--r--xc/extras/Mesa/src/state.c24
-rw-r--r--xc/extras/Mesa/src/texgen_tmp.h8
-rw-r--r--xc/extras/Mesa/src/teximage.c463
-rw-r--r--xc/extras/Mesa/src/teximage.h6
-rw-r--r--xc/extras/Mesa/src/texobj.c61
-rw-r--r--xc/extras/Mesa/src/texstate.c478
-rw-r--r--xc/extras/Mesa/src/texture.c631
-rw-r--r--xc/extras/Mesa/src/texture.h2
-rw-r--r--xc/extras/Mesa/src/texutil.c70
-rw-r--r--xc/extras/Mesa/src/texutil.h8
-rw-r--r--xc/extras/Mesa/src/triangle.c3
-rw-r--r--xc/extras/Mesa/src/tritemp.h11
-rw-r--r--xc/extras/Mesa/src/types.h82
-rw-r--r--xc/extras/Mesa/src/varray.c1
-rw-r--r--xc/extras/Mesa/src/vb.c61
-rw-r--r--xc/extras/Mesa/src/vbcull.c6
-rw-r--r--xc/extras/Mesa/src/vbfill.c81
-rw-r--r--xc/extras/Mesa/src/vbrender.c53
-rw-r--r--xc/extras/Mesa/src/vector.c39
-rw-r--r--xc/extras/Mesa/src/xform.h10
-rw-r--r--xc/extras/Mesa/src/xform_tmp.h194
115 files changed, 3602 insertions, 16577 deletions
diff --git a/xc/extras/Mesa/include/GL/gl.h b/xc/extras/Mesa/include/GL/gl.h
index f7d1224cf..78c5efbd5 100644
--- a/xc/extras/Mesa/include/GL/gl.h
+++ b/xc/extras/Mesa/include/GL/gl.h
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -22,6 +22,7 @@
* 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.
*/
+/* $XFree86: xc/extras/Mesa/include/GL/gl.h,v 1.6 2000/08/11 16:36:41 dawes Exp $ */
#ifndef __gl_h_
@@ -43,11 +44,11 @@
#define OPENSTEP
#endif
-#if defined(_WIN32) && !defined(__WIN32__)
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
#define __WIN32__
#endif
-#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN__))
+#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
# define GLAPI __declspec(dllexport)
# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
@@ -62,7 +63,7 @@
# define GLAPIENTRY
#endif /* WIN32 / CYGWIN bracket */
-#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(__CYGWIN__) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
#include <gl/mesa_wgl.h>
#endif
@@ -850,7 +851,7 @@ typedef double GLclampd; /* double precision float in [0,1] */
#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
-#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
+#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF
diff --git a/xc/extras/Mesa/include/GL/glext.h b/xc/extras/Mesa/include/GL/glext.h
index 3ee1cef05..f721a9fd7 100644
--- a/xc/extras/Mesa/include/GL/glext.h
+++ b/xc/extras/Mesa/include/GL/glext.h
@@ -2712,6 +2712,12 @@ extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum,
extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
+#ifdef VMS
+ #define glGetCombinerOutputParameterfvNV glGetCombinerOutputParameterfvN
+ #define glGetCombinerOutputParameterivNV glGetCombinerOutputParameterivN
+ #define glGetFinalCombinerInputParameterfvNV glGetFinalCombinerInputParafvNV
+ #define glGetFinalCombinerInputParameterivNV glGetFinalCombinerInputParaivNV
+#endif
extern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *);
extern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *);
extern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *);
diff --git a/xc/extras/Mesa/src/FX/X86/fx_3dnow_fastpath.S b/xc/extras/Mesa/src/FX/X86/fx_3dnow_fastpath.S
deleted file mode 100644
index eb426f705..000000000
--- a/xc/extras/Mesa/src/FX/X86/fx_3dnow_fastpath.S
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "../../X86/assyntax.h"
-
-#define SETUP_RGBA 0x1
-#define SETUP_TMU0 0x2
-#define SETUP_TMU1 0x4
-
-
-/* Pack either rgba or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_R 24
-#define CLIP_G 16
-#define CLIP_B 20
-#define CLIP_A 28 /* defined inf fxdrv.h */
-
-#define CLIP_S0 16
-#define CLIP_T0 20
-#define CLIP_S1 24
-#define CLIP_T1 28
-
-#define SIZE 4
-#define TYPE (0)
-#define TAG(x) x
-#include "fx_3dnow_fasttmp.h"
-
-#define SIZE 8
-#define TYPE (SETUP_RGBA)
-#define TAG(x) x##_RGBA
-#include "fx_3dnow_fasttmp.h"
-
-#define SIZE 6
-#define TYPE (SETUP_TMU0)
-#define TAG(x) x##_TMU0
-#include "fx_3dnow_fasttmp.h"
-
-#define SIZE 8
-#define TYPE (SETUP_TMU0|SETUP_TMU1)
-#define TAG(x) x##_TMU0_TMU1
-#include "fx_3dnow_fasttmp.h"
-
-#undef CLIP_S1
-#undef CLIP_T1
-#define CLIP_S1 16
-#define CLIP_T1 20
-
-#define SIZE 6
-#define TYPE (SETUP_TMU1)
-#define TAG(x) x##_TMU1
-#include "fx_3dnow_fasttmp.h"
-
-/* These three need to use a full 64 byte clip-space vertex.
- */
-#undef CLIP_S0
-#undef CLIP_T0
-#undef CLIP_S1
-#undef CLIP_T1
-
-#define CLIP_S0 32
-#define CLIP_T0 36
-#define CLIP_S1 40
-#define CLIP_T1 44
-
-#define SIZE 10
-#define TYPE (SETUP_RGBA|SETUP_TMU0)
-#define TAG(x) x##_RGBA_TMU0
-#include "fx_3dnow_fasttmp.h"
-
-#define SIZE 12
-#define TYPE (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
-#define TAG(x) x##_RGBA_TMU0_TMU1
-#include "fx_3dnow_fasttmp.h"
-
-#undef CLIP_S1
-#undef CLIP_T1
-#define CLIP_S1 32
-#define CLIP_T1 36
-
-#define SIZE 10
-#define TYPE (SETUP_RGBA|SETUP_TMU1)
-#define TAG(x) x##_RGBA_TMU1
-#include "fx_3dnow_fasttmp.h"
-
-
diff --git a/xc/extras/Mesa/src/FX/X86/fx_3dnow_fasttmp.h b/xc/extras/Mesa/src/FX/X86/fx_3dnow_fasttmp.h
deleted file mode 100644
index 78c5fef74..000000000
--- a/xc/extras/Mesa/src/FX/X86/fx_3dnow_fasttmp.h
+++ /dev/null
@@ -1,313 +0,0 @@
-
-#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER)
-#define TAGLLBL(a) TAG(.L##a)
-#else
-#define TAGLLBL(a) TAG(a)
-#endif
-
-#if !GLIDE3
-
-#define GR_VERTEX_X_OFFSET 0
-#define GR_VERTEX_Y_OFFSET 4
-#define GR_VERTEX_Z_OFFSET 8
-#define GR_VERTEX_R_OFFSET 12
-#define GR_VERTEX_G_OFFSET 16
-#define GR_VERTEX_B_OFFSET 20
-#define GR_VERTEX_OOZ_OFFSET 24
-#define GR_VERTEX_A_OFFSET 28
-#define GR_VERTEX_OOW_OFFSET 32
-
-#else /* GLIDE3 */
-
-#define GR_VERTEX_X_OFFSET 0
-#define GR_VERTEX_Y_OFFSET 4
-#define GR_VERTEX_OOZ_OFFSET 8
-#define GR_VERTEX_OOW_OFFSET 12
-#define GR_VERTEX_R_OFFSET 16
-#define GR_VERTEX_G_OFFSET 20
-#define GR_VERTEX_B_OFFSET 24
-#define GR_VERTEX_A_OFFSET 28
-#define GR_VERTEX_Z_OFFSET 32
-
-#endif /* GLIDE3 */
-
-#define GR_VERTEX_SOW_TMU0_OFFSET 36
-#define GR_VERTEX_TOW_TMU0_OFFSET 40
-#define GR_VERTEX_OOW_TMU0_OFFSET 44
-#define GR_VERTEX_SOW_TMU1_OFFSET 48
-#define GR_VERTEX_TOW_TMU1_OFFSET 52
-#define GR_VERTEX_OOW_TMU1_OFFSET 56
-
-
-
-
-/*#define MAT_SX 0 /* accessed by REGIND !! */
-#define MAT_SY 20
-#define MAT_SZ 40
-#define MAT_TX 48
-#define MAT_TY 52
-#define MAT_TZ 56
-
-
-
-
-/* Do viewport map, device scale and perspective projection.
- *
- * void project_verts( GLfloat *first,
- * GLfloat *last,
- * const GLfloat *m,
- * GLuint stride )
- *
- *
- * Rearrange fxVertices to look like grVertices.
- */
-
-GLOBL GLNAME( TAG(fx_3dnow_project_vertices) )
-GLNAME( TAG(fx_3dnow_project_vertices) ):
-
- PUSH_L ( EBP )
-
- MOV_L ( REGOFF(8, ESP), ECX ) /* first_vert */
- MOV_L ( REGOFF(12, ESP), EDX ) /* last_vert */
-
- CMP_L ( ECX, EDX )
- JE ( TAGLLBL(FXPV_end) )
-
- FEMMS
-
- PREFETCH ( REGIND(ECX) ) /* fetch the first vertex */
-
- MOV_L ( REGOFF(16, ESP), EBP ) /* matrix */
- MOV_L ( REGOFF(20, ESP), EAX ) /* stride */
-
- MOVD ( REGOFF(MAT_TX, EBP), MM6 ) /* | tx */
- PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 ) /* ty | tx */
-
-#if !defined(FX_V2)
- MOV_L ( CONST(0x49400000), REGOFF(-8, ESP) ) /* snapper */
- MOV_L ( CONST(0x49400000), REGOFF(-4, ESP) ) /* snapper */
-#endif
-
- MOVQ ( REGOFF(-8, ESP), MM4 ) /* snapper | snapper */
- PFADD ( MM4, MM6 ) /* ty+snapper | tx+snapper */
-
- MOVD ( REGIND(EBP), MM5 )
- PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 ) /* vsy | vsx */
-
- MOVD ( REGOFF(MAT_SZ, EBP), MM1 ) /* | vsz */
-
-
-ALIGNTEXT32
-TAGLLBL(FXPV_loop_start):
-
- PREFETCH ( REGOFF(64, ECX) ) /* fetch the next-ish vertex */
-
-
- MOVD ( REGOFF(12, ECX), MM0 ) /* | f[3] */
- PFRCP ( MM0, MM0 ) /* oow = 1/f[3] */
-
- MOVD ( REGOFF(12, ECX), MM7 ) /* | f[3] */
- PFRCPIT1 ( MM0, MM7 )
- PFRCPIT2 ( MM0, MM7 ) /* oow | oow */
-
- PUNPCKLDQ ( MM7, MM7 )
-
-
-#if (TYPE & SETUP_RGBA)
- MOVD ( REGOFF(CLIP_R, ECX ), MM0 ) /* f[RCOORD] = f[CLIP_R]; */
- MOVD ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
-#endif
-
-#if (TYPE & SETUP_TMU1)
- MOVQ ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow */
- PFMUL ( MM7, MM0 ) /* f[T1COORD] = f[CLIP_T1] * oow */
- MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
-#endif
-
-
-#if (TYPE & SETUP_TMU0)
- MOVQ ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow */
- PFMUL ( MM7, MM0 ) /* f[T0COORD] = f[CLIP_T0] * oow */
- MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
-#endif
-
-
-
-
-
-/* DO_SETUP_XYZ */
-
- MOVQ ( REGIND(ECX), MM2 ) /* f[1] | f[0] */
- PFMUL ( MM7, MM2 ) /* f[1] * oow | f[0] * oow */
-
- MOVD ( REGOFF(8, ECX), MM3 ) /* | f[2] */
- PFMUL ( MM7, MM3 ) /* | f[2] * oow */
-
- MOVD ( REGOFF(MAT_TZ, EBP), MM0 ) /* | vtz */
- PFMUL ( MM1, MM3 ) /* | f[2] *= vsz */
-
- PFADD ( MM0, MM3 ) /* | f[2] += vtz */
- PFMUL ( MM5, MM2 ) /* f[1] *= vsy | f[0] *= vsx */
-
- PFADD ( MM6, MM2 ) /* f[1] += vty | f[0] += vtx */
-
-#if !defined(FX_V2)
- PFSUB ( MM4, MM2 ) /* f[0,1] -= snapper */
-#endif
-
- MOVQ ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
- MOVD ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )
-
-
-/* end of DO_SETUP_XYZ */
-
- MOVD ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
- ADD_L ( EAX, ECX ) /* f += stride */
-
- CMP_L ( ECX, EDX ) /* stall??? */
- JA ( TAGLLBL(FXPV_loop_start) )
-
-TAGLLBL(FXPV_end):
- FEMMS
- POP_L ( EBP )
- RET
-
-
-
-
-
-
-
-/* void project_verts( GLfloat *first,
- * GLfloat *last,
- * const GLfloat *m,
- * GLuint stride,
- * const GLubyte *mask )
- *
- */
-
-GLOBL GLNAME( TAG(fx_3dnow_project_clipped_vertices) )
-GLNAME( TAG(fx_3dnow_project_clipped_vertices) ):
-
- PUSH_L ( EBP )
-
- MOV_L ( REGOFF(8, ESP), ECX ) /* first FXDRIVER(VB)->verts*/
- MOV_L ( REGOFF(12, ESP), EDX ) /* last FXDRIVER(VB)->last_vert */
-
- FEMMS
-
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- PREFETCH ( REGIND(ECX) ) /* fetch the first vertex */
-
- MOV_L ( REGOFF(24, ESP), EBP ) /* mat ctx->Viewport.WindowMap.M */
- MOV_L ( REGOFF(28, ESP), EAX ) /* stride */
- MOV_L ( REGOFF(32, ESP), ESI ) /* VB->ClipMask */
-
- MOVD ( REGOFF(MAT_TX, EBP), MM6 ) /* | tx */
- PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 ) /* ty | tx */
-
-#if !defined(FX_V2)
- MOV_L ( CONST(0x49400000), REGOFF(-8, ESP) ) /* snapper */
- MOV_L ( CONST(0x49400000), REGOFF(-4, ESP) ) /* snapper */
-#endif
-
- MOVQ ( REGOFF(-8, ESP), MM4 ) /* snapper | snapper */
- PFADD ( MM4, MM6 ) /* ty+snapper | tx+snapper */
-
- MOVD ( REGIND(EBP), MM5 )
- PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 ) /* vsy | vsx */
-
- MOVD ( REGOFF(MAT_SZ, EBP), MM1 ) /* | vsz */
-
-
-
-ALIGNTEXT32
-TAGLLBL(FXPCV_loop_start):
-
- PREFETCH ( REGOFF(64, ECX) ) /* fetch the next-ish vertex */
-
- CMP_B ( CONST(0), REGIND(ESI) )
- JNE ( TAGLLBL(FXPCV_skip) )
-
- MOVD ( REGOFF(12, ECX), MM0) /* | f[3] */
- PFRCP ( MM0, MM0 ) /* oow = 1/f[3] */
-
- MOVD ( REGOFF(12, ECX), MM7) /* | f[3] */
- PFRCPIT1 ( MM0, MM7 )
- PFRCPIT2 ( MM0, MM7 ) /* oow | oow */
-
- PUNPCKLDQ ( MM7, MM7 )
-
-
-#if (TYPE & SETUP_RGBA)
- MOVD ( REGOFF(CLIP_R, ECX ), MM0 ) /* f[RCOORD] = f[CLIP_R]; */
- MOVD ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
-#endif
-
-#if (TYPE & SETUP_TMU1)
- MOVQ ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow */
- PFMUL ( MM7, MM0 ) /* f[T1COORD] = f[CLIP_T1] * oow */
- MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
-#endif
-
-
-#if (TYPE & SETUP_TMU0)
- MOVQ ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow */
- PFMUL ( MM7, MM0 ) /* f[T0COORD] = f[CLIP_T0] * oow */
- MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
-#endif
-
-
-
-
-/* DO_SETUP_XYZ */
-
- MOVQ ( REGIND(ECX), MM2 ) /* f[1] | f[0] */
- PFMUL ( MM7, MM2 ) /* f[1] * oow | f[0] * oow */
-
- MOVD ( REGOFF(8, ECX), MM3 ) /* | f[2] */
- PFMUL ( MM7, MM3 ) /* | f[2] * oow */
-
- MOVD ( REGOFF(MAT_TZ, EBP), MM0 ) /* | vtz */
- PFMUL ( MM1, MM3 ) /* | f[2] *= vsz */
-
- PFADD ( MM0, MM3 ) /* | f[2] += vtz */
- PFMUL ( MM5, MM2 ) /* f[1] *= vsy | f[0] *= vsx */
-
- PFADD ( MM6, MM2 ) /* f[1] += vty | f[0] += vtx */
-
-#if !defined(FX_V2)
- PFSUB ( MM4, MM2 ) /* f[0,1] -= snapper */
-#endif
-
- MOVQ ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
- MOVD ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )
-
-
-/* end of DO_SETUP_XYZ */
-
- MOVD ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
-
-TAGLLBL(FXPCV_skip):
- ADD_L ( EAX, ECX ) /* f += stride */
-
- INC_L ( ESI ) /* next ClipMask */
- CMP_L ( ECX, EDX )
- JA ( TAGLLBL(FXPCV_loop_start) )
-
- POP_L ( ESI )
- POP_L ( EDI )
-
-TAGLLBL(FXPCV_end):
- FEMMS
- POP_L ( EBP )
- RET
-
-
-
-#undef TYPE
-#undef TAG
-#undef SIZE
-
diff --git a/xc/extras/Mesa/src/FX/fxapi.c b/xc/extras/Mesa/src/FX/fxapi.c
deleted file mode 100644
index 6d680bcb9..000000000
--- a/xc/extras/Mesa/src/FX/fxapi.c
+++ /dev/null
@@ -1,1424 +0,0 @@
-/* -*- mode: C; tab-width:8; -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxapi.c - 3Dfx VooDoo/Mesa interface */
-
-
-/********************************************************************
- *
- * Function names:
- * fxMesa.... (The driver API)
- * fxDD.... (Mesa device driver functions)
- * fxTM.... (Texture manager functions)
- * fxSetup.... (Voodoo units setup functions)
- * fx.... (Internal driver functions)
- *
- * Data type names:
- * fxMesa.... (Public driver data types)
- * tfx.... (Private driver data types)
- *
- ********************************************************************
- *
- * V0.30 - David Bucciarelli (davibu@tin.it) Humanware s.r.l.
- * - introduced a new MESA_GLX_FX related behavior
- * - the Glide fog table was built in a wrong way (using
- * gu* Glide function). Added the code for building the
- * table following the OpenGL specs. Thanks to Steve Baker
- * for highlighting the problem.
- * - fixed few problems in my and Keith's fxDDClear code
- * - merged my code with the Keith's one
- * - used the new BlendFunc Mesa device driver function
- * - used the new AlphaFunc Mesa device driver function
- * - used the new Enable Mesa device driver function
- * - fixed a bug related to fog in the Mesa core. Fog
- * were applied two times: at vertex level and at fragment
- * level (thanks to Steve Baker for reporting the problem)
- * - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE) now works
- * (thanks to Jiri Pop for reporting the problem)
- * - the driver works fine with OpenGL Unreal
- * - fixed a bug in the Mesa core clipping code (related
- * to the q texture coordinate)
- * - introduced the support for the q texture coordinate
- *
- * Keith Whitwell (keithw@cableinet.co.uk)
- * - optimized the driver and written all the new code
- * required by the new Mesa-3.1 device driver API
- * and by the new Mesa-3.1 core changes
- * - written the cva support and many other stuff
- *
- * Brian Paul (brian_paul@avid.com) Avid Technology
- * - fixed display list share bug for MESA_GLX_FX = window/fullscreen
- * - fixed glClear/gl...Mask related problem
- *
- * Bert Schoenwaelder (bert@prinz-atm.CS.Uni-Magdeburg.De)
- * - the driver is now able to sleep when waiting for the completation
- * of multiple swapbuffer operations instead of wasting
- * CPU time (NOTE: you must uncomment the lines in the
- * fxMesaSwapBuffers function in order to enable this option)
- *
- * Eero Pajarre (epajarre@koti.tpo.fi)
- * - enabled the macro FLOAT_COLOR_TO_UBYTE_COLOR under
- * windows
- * - written an asm x86 optimized float->integer conversions
- * for windows
- *
- * Theodore Jump (tjump@cais.com)
- * - fixed a small problem in the __wglMonitor function of the
- * wgl emulator
- * - written the in-window-rendering hack support for windows
- * and Vooodoo1/2 cards
- *
- * V0.29 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - included in Mesa-3.0
- * - now glGetString(GL_RENDERER) returns more information
- * about the hardware configuration: "Mesa Glide <version>
- * <Voodoo_Graphics|Voodoo_Rush|UNKNOWN> <num> CARD/<num> FB/
- * <num> TM/<num> TMU/<NOSLI|SLI>"
- * where: <num> CARD is the card used for the current context,
- * <num> FB is the number of MB for the framebuffer,
- * <num> TM is the number of MB for the texture memory,
- * <num> TMU is the number of TMU. You can try to run
- * Mesa/demos/glinfo in order to have an example of the
- * output
- * - fixed a problem of the WGL emulator with the
- * OpenGL Optimizer 1.1 (thanks to Erwin Coumans for
- * the bug report)
- * - fixed some bug in the fxwgl.c code (thanks to
- * Peter Pettersson for a patch and a bug report)
- *
- * Theodore Jump (tjump@cais.com)
- * - written the SST_DUALHEAD support in the WGL emulator
- *
- * Daryll Strauss (daryll@harlot.rb.ca.us)
- * - fixed the Voodoo Rush support for the in window rendering
- *
- * V0.28 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - the only supported multitexture functions are GL_MODULATE
- * for texture set 0 and GL_MODULATE for texture set 1. In
- * all other cases, the driver falls back to pure software
- * rendering
- * - written the support for the new GL_EXT_multitexture
- * - written the DD_MAX_TEXTURE_COORD_SETS support in the
- * fxDDGetParameteri() function
- * - the driver falls back to pure software rendering when
- * texture mapping function is GL_BLEND
- *
- * V0.27 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - inluded in the Mesa-3.0beta5
- * - written a smal extension (GL_FXMESA_global_texture_lod_bias) in
- * order to expose the LOD bias related Glide function
- * - fixed a bug fxDDWriteMonoRGBAPixels()
- * - the driver is now able to fallback to software rendering in
- * any case not directly supported by the hardware
- * - written the support for enabling/disabling dithering
- * - the in-window-rendering hack now works with any X11 screen
- * depth
- * - fixed a problem related to color/depth/alpha buffer clears
- * - fixed a problem when clearing buffer for a context with the
- * alpha buffer
- * - fixed a problem in the fxTMReloadSubMipMapLevel() function,
- * I have forget a "break;" (thanks to Joe Waters for the bug report)
- * - fixed a problem in the color format for the in window
- * rendering hack
- * - written the fxDDReadRGBAPixels function
- * - written the fxDDDepthTestPixelsGeneric function
- * - written the fxDDDepthTestSpanGeneric function
- * - written the fxDDWriteMonoRGBAPixels function
- * - written the fxDDWriteRGBAPixels function
- * - removed the multitexture emulation code for Voodoo board
- * with only one TMU
- *
- * Chris Prince <cprince@cs.washington.edu>
- * - fixed a new bug in the wglUseFontBitmaps code
- *
- * Ralf Knoesel (rknoesel@Stormfront.com)
- * - fixed a bug in the wglUseFontBitmaps code
- *
- * Rune Hasvold (runeh@ifi.uio.no)
- * - fixed a problem related to the aux usage in the fxBestResolution
- * function
- * - fixed the order of pixel formats in the WGL emulator
- *
- * Fredrik Hubinette (hubbe@hubbe.net)
- * - the driver shutdown the Glide for most common signals
- *
- * V0.26 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - included in the Mesa-3.0beta4
- * - fixed a problem related to a my optimization for the Rune's
- * pixel-span optimization
- * - fixed a problem related to fxDDSetNearFar() and ctx->ProjectionMatrixType
- * (thanks to Ben "Ctrl-Alt-Delete" and the Raul Alonso's ssystem)
- * - fixed a small bug in the Rune's pixel-span optimization
- * - fixed a problem with GL_CCW (thanks to Curt Olson for and example
- * of the problem)
- * - grVertex setup code is now ready for the internal thread support
- * - fixed a no used optimization with clipped vertices in
- * grVertex setup code
- * - fixed a problem in the GL_LIGHT_MODEL_TWO_SIDE support (thanks
- * to Patrick H. Madden for a complete example of the bug)
- *
- * Rune Hasvold (runeh@ifi.uio.no)
- * - highly optimized the driver functions for writing pixel
- * span (2-3 times faster !)
- *
- * Axel W. Volley (volley@acm.org) Krauss-Maffei Wehrtechnik
- * - written the fxDDReadDepthSpanFloat() and fxDDReadDepthSpanInt()
- * functions
- *
- * V0.25 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - fixed a problem with Voodoo boards with only one TMU
- * - fixed a bug in the fxMesaCreateContext()
- * - now the GL_FRONT_AND_BACK works fine also with
- * the alpha buffer and/or antialiasing
- * - written the support for GL_FRONT_AND_BACK drawing but
- * it doesn't works with the alpha buffer and/or antialiasing
- * - fixed some bug in the Mesa core for glCopyTexSubImage
- * and glCopyTexImage functions (thanks to Mike Connell
- * for an example of the problem)
- * - make some small optimizations in the Mesa core in order
- * to save same driver call and state change for not very
- * well written applications
- * - introduced the NEW_DRVSTATE and make other optimizations
- * for minimizing state changes
- * - made a lot of optimizations in order to minimize state
- * changes
- * - it isn't more possible to create a context with the
- * depth buffer and the stancil buffer (it isn't yet supported)
- * - now the partial support for the Multitexture extension
- * works with Quake2 for windows
- * - vertex snap is not longer used for the Voodoo2 (FX_V2
- * must be defined)
- * - done a lot of cleanup in the fxsetup.c file
- * - now the partial support for the Multitexture extension
- * works with GLQuake for windows
- *
- * Dieter Nuetzel (nuetzel@kogs.informatik.uni-hamburg.de) University of Hamburg
- * - fixed a problem in the asm code for Linux of the fxvsetup.c file
- * highlighted by the binutils-2.8.1.0.29. 'fildw' asm instruction
- * changed in 'fild'
- *
- * Kevin Hester (kevinh@glassworks.net)
- * - written the wglUseFontBitmaps() function in the WGL emulator
- *
- * V0.24 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - now the drive always uses per fragment fog
- * - written a small optimization in the points drawing function
- * - written the support for trilinear filtering with 2 TMUs
- * - written the first partial support for the Multitexture extension.
- * This task is quite hard because the color combine units work after
- * the two texture combine units and not before as required by the
- * Multitexture extension
- * - written a workaround in fxBestResolution() in order to solve a
- * problem with bzflag (it asks for 1x1 window !)
- * - changed the fxBestResolution() behavior. It now returns the larger
- * screen resolution supported by the hardware (instead of 640x480)
- * when it is unable to find an appropriate resolution that is large
- * enough for the requested size
- * - the driver is now able to use also the texture memory attached to
- * second TMU
- * - the texture memory manager is now able to work with two TMUs and
- * store texture maps in the memory attached to TMU0, TMU1 or to split
- * the mimpmap levels across TMUs in order to support trilinear filtering
- * - I have bought a Voodoo2 board !
- * - the amount of frambuffer ram is now doubled when an SLI configuration
- * is detected
- * - solved a problem related to the fxDDTexParam() and fxTexInvalidate()
- * functions (thanks to Rune Hasvold for highlighting the problem)
- * - done some cleanup in the fxvsetup.c file, written
- * the FXVSETUP_FUNC macro
- * - done a lot of cleanup in data types and field names
- *
- * Rune Hasvold (runeh@ifi.uio.no)
- * - written the support for a right management of the auxiliary buffer.
- * You can now use an 800x600 screen without the depth and alpha
- * buffer
- * - written the support for a new pixel format (without the depth
- * and alpha buffer) in the WGL emulator
- * - fixed a bug in the window version of the GLUT (it was ever asking
- * for depth buffer)
- *
- * V0.23 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - included in the Mesa-3.0beta2 release
- * - written the support for the OpenGL 1.2 GL_TEXTURE_BASE_LEVEL
- * and GL_TEXTURE_MAX_LEVEL
- * - rewritten several functions for a more clean support of texture
- * mapping and in order to solve some bug
- * - the accumulation buffer works (it is bit slow beacuase it requires
- * to read/write from/to the Voodoo frame buffer but it works)
- * - fixed a bug in the fxDDReadRGBASpan driver function (the R and
- * B channels were read in the wrong order). Thanks to Jason Heym
- * for highlighting the problem
- * - written the support for multiple contexts on multiple boards.
- * you can now use the Mesa/Voodoo with multiple Voodoo Graphics
- * boards (for example with multiple screens or an HMD)
- * - the fxBestResolution() now check all available resolutions
- * and it is able to check the amount of framebuffer memory
- * before return a resolution
- * - modified the GLX/X11 driver in order to support all the
- * resolution available
- * - changed all function names. They should be now a bit more
- * readable
- * - written the Glide grVertex setup code for two TMU or
- * for Multitexture support with emulationa dn one TMU
- * - written the support for the new Mesa driver
- * function GetParametri
- * - small optimization/clean up in the texbind() function
- * - fixed a FPU precision problem for glOrtho and texture
- * mapping (thanks to Antti Juhani Huovilainen for an example
- * of the problem)
- * - written some small SGI OpenGL emulation code for the wgl,
- * the OpenGL Optimizer and Cosmo3D work fine under windows !
- * - moved the point/line/triangle/quad support in the fxmesa7.c
- * - fixed a bug in the clear_color_depth() (thanks to Henk Kok
- * for an example of the problem)
- * - written a small workaround for Linux GLQuake, it asks
- * for the alpha buffer and the depth buffer at the some time
- * (but it never uses the alpha buffer)
- * - checked the antialiasing points, lines and polygons support.
- * It works fine
- * - written the support for standard OpenGL antialiasing using
- * blending. Lines support works fine (tested with BZflag)
- * while I have still to check the polygons and points support
- * - written the support for the alpha buffer. The driver is now
- * able to use the Voodoo auxiliary buffer as an alpha buffer
- * instead of a depth buffer. Also all the OpenGL blending
- * modes are now supported. But you can't request a context
- * with an alpha buffer AND a depth buffer at the some time
- * (this is an hardware limitation)
- * - written the support for switching between the fullscreen
- * rendering and the in-window-rendering hack on the fly
- *
- * Rune Hasvold (runeh@ifi.uio.no)
- * - fixed a bug in the texparam() function
- *
- * Brian Paul (brianp@elastic.avid.com) Avid Technology
- * - sources accomodated for the new Mesa 3.0beta1
- *
- * V0.22 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - included with some v0.23 bug fix in the final release
- * of the Mesa-2.6
- * - written the support for the MESA_WGL_FX env. var. but
- * not tested because I have only Voodoo Graphics boards
- * - fixed a bug in the backface culling code
- * (thanks to David Farrell for an example of the problem)
- * - fixed the "Quake2 elevator" bug
- * - GL_POLYGONS with 3/4 vertices are now drawn as
- * GL_TRIANLGES/GL_QUADS (a small optimization for GLQuake)
- * - fixed a bug in fxmesa6.h for GL_LINE_LOOP
- * - fixed a NearFarStack bug in the Mesa when applications
- * directly call glLoadMatrix to load a projection matrix
- * - done some cleanup in the fxmesa2.c file
- * - the driver no longer translates the texture maps
- * when the Mesa internal format and the Voodoo
- * format are the some (usefull for 1 byte texture maps
- * where the driver can directly use the Mesa texture
- * map). Also the amount of used memory is halfed
- * - fixed a bug for GL_DECAL and GL_RGBA
- * - fixed a bug in the clear_color_depth()
- * - tested the v0.22 with the Mesa-2.6beta2. Impressive
- * performances improvement thanks to the new Josh's
- * asm code (+10fps in the isosurf demo, +5fps in GLQuake
- * TIMEREFRESH)
- * - written a optimized version of the RenderVB Mesa driver
- * function. The Voodoo driver is now able to upload polygons
- * in the most common cases at a very good speed. Good
- * performance improvement for large set of small polygons
- * - optimized the asm code for setting up the color information
- * in the Glide grVertex structure
- * - fixed a bug in the fxmesa2.c asm code (the ClipMask[]
- * wasn't working)
- *
- * Josh Vanderhoof (joshv@planet.net)
- * - removed the flush() function because it isn't required
- * - limited the maximum number of swapbuffers in the Voodoo
- * commands FIFO (controlled by the env. var. MESA_FX_SWAP_PENDING)
- *
- * Holger Kleemiss (holger.kleemiss@metronet.de) STN Atlas Elektronik GmbH
- * - applied some patch for the Voodoo Rush
- *
- * V0.21 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - the driver is now able to take advantage of the ClipMask[],
- * ClipOrMask and ClipAndMask information also under Windows
- * - introduced a new function in the Mesa driver interface
- * ClearColorAndDepth(). Now the glClear() function is
- * 2 times faster (!) when you have to clear the color buffer
- * and the depth buffer at some time
- * - written the first version of the fxRenderVB() driver
- * function
- * - optimized the glTexImage() path
- * - removed the fxMesaTextureUsePalette() support
- * - fixed a bug in the points support (thanks to David Farrell
- * for an example of the problem)
- * - written the optimized path for glSubTexImage(),
- * introduced a new function in the Mesa driver interface
- * TexSubImage(...)
- * - fixed a bug for glColorMask and glDepthMask
- * - the wbuffer is not more used. The Voodoo driver uses
- * a standard 16bit zbuffer in all cases. It is more consistent
- * and now GLQuake and GLQuake2test work also with a GL_ZTRICK 0
- * - the driver is now able to take advantage of the ClipMask[],
- * ClipOrMask and ClipAndMask information (under Linux);
- * - rewritten the setup_fx_units() function, now the texture
- * mapping support is compliant to the OpenGL specs (GL_BLEND
- * support is still missing). The LinuxGLQuake console correctly
- * fade in/out and transparent water of GLQuake2test works fine
- * - written the support for the env. var. FX_GLIDE_SWAPINTERVAL
- * - found a bug in the Mesa core. There is a roundup problem for
- * color values out of the [0.0,1.0] range
- *
- * Wonko <matt@khm.de>
- * - fixed a Voodoo Rush related problem in the fxwgl.c
- *
- * Daryll Strauss <daryll@harlot.rb.ca.us>
- * - written the scissor test support
- *
- * V0.20 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - written the closetmmanger() function in order to free all the memory
- * allocated by the Texture Memory Manager (it will be useful
- * when the support for multiple contexts/boards will be ready)
- * - now the Voodoo driver runs without printing any information,
- * define the env. var. MESA_FX_INFO if you want to read some
- * information about the hardware and some statistic
- * - written a small workaround for the "GLQuake multiplayer white box bug"
- * in the setup_fx_units() funxtions. I'm already rewriting
- * this function because it is the source of nearly all the current
- * Voodoo driver problems
- * - fixed the GLQuake texture misalignment problem (the texture
- * coordinates must be scaled between 0.0 and 256.0 and not
- * between 0.0 and 255.0)
- * - written the support for the GL_EXT_shared_texture_palette
- * - some small change for supporting the automatic building of the
- * OpenGL32.dll under the Windows platform
- * - the redefinition of a mipmap level is now a LOT faster. This path
- * is used by GLQuake for dynamic lighting with some call to glTexSubImage2D()
- * - the texture memory is now managed a set of 2MB blocks so
- * texture maps can't be allocated on a 2MB boundary. The new Pure3D
- * needs this kind of support (and probably any other Voodoo Graphics
- * board with more than 2MB of texture memory)
- *
- * Brian Paul (brianp@elastic.avid.com) Avid Technology
- * - added write_monocolor_span(), fixed bug in write_color_span()
- * - added test for stenciling in choosepoint/line/triangle functions
- *
- * Joe Waters (falc@attila.aegistech.com) Aegis
- * - written the support for the env. var. SST_SCREENREFRESH
- *
- * V0.19 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - written the 3Dfx Global Palette extension for GLQuake
- * - written the support for the GL_EXT_paletted_texture (it works only with GL_RGBA
- * palettes and the alpha value is ignored ... this is a limitation of the
- * the current Glide version and Voodoo hardware)
- * - fixed the amount of memory allocated for 8bit textures
- * - merged the under construction v0.19 driver with the Mesa 2.5
- * - finally written the support for deleting textures
- * - introduced a new powerful texture memory manager: the texture memory
- * is used as a cache of the set of all defined texture maps. You can
- * now define several MB of texture maps also with a 2MB of texture memory
- * (the texture memory manager will do automatically all the swap out/swap in
- * work). The new texture memory manager has also
- * solved a lot of other bugs/no specs compliance/problems
- * related to the texture memory usage. The texture
- * manager code is inside the new fxmesa3.c file
- * - broken the fxmesa.c file in two files (fxmesa1.c and fxmesa2.c)
- * and done some code cleanup
- * - now is possible to redefine texture mipmap levels already defined
- * - fixed a problem with the amount of texture memory allocated for textures
- * with not all mipmap levels defined
- * - fixed a small problem with single buffer rendering
- *
- * Brian Paul (brianp@elastic.avid.com) Avid Technology
- * - read/write_color_span() now use front/back buffer correctly
- * - create GLvisual with 5,6,5 bits per pixel, not 8,8,8
- * - removed a few ^M characters from fxmesa2.c file
- *
- * V0.18 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - the Mesa-2.4beta3 is finally using the driver quads support (the
- * previous Mesa versions have never taken any advantage from the quads support !)
- * - tested with the Glide 2.4 for Win
- * - ported all asm code to Linux
- * - ported the v0.18 to Linux (without asm code)
- * - back to Linux !!!
- * - optimized the SETUP macro (no more vertex snap for points and lines)
- * - optimized the SETUP macro (added one argument)
- * - the Mesa/Voodoo is now 20/30% for points, lines and small triangles !
- * - performance improvement setting VBSIZE to 72
- * - the GrVertex texture code is now written in asm
- * - the GrVertex zbuffer code is now written in asm
- * - the GrVertex wbuffer code is now written in asm
- * - the GrVertex gouraud code is now written in asm
- * - the GrVertex snap code is now written in asm
- * - changed the 8bit compressed texture maps in 8bit palette texture maps
- * support (it has the some advantage of compressed texture maps without the
- * problem of a fixed NCC table for all mipmap levels)
- * - written the support for 8bit compressed texture maps (but texture maps with
- * more than one mipmap level aren't working fine)
- * - finnaly everthing is working fine in MesaQuake !
- * - fixed a bug in the computation of texture mapping coordinates (I have found
- * the bug thanks to MesaQuake !)
- * - written the GL_REPLACE support (mainly for MesaQuake)
- * - written the support for textures with not all mipmap levels defined
- * - rewritten all the Texture memory stuff
- * - written the MesaQuake support (define MESAQUAKE)
- * - working with a ZBuffer if glOrtho or not int the default glDepthRange,
- * otherwise working with the WBuffer
- * written the glDepthRange support
- *
- * Diego Picciani (d.picciani@novacomp.it) Nova Computer s.r.l.
- * - written the fxCloseHardware() and the fxQuaryHardware() (mainly
- * for the VoodooWGL emulator)
- *
- * Brian Paul (brianp@elastic.avid.com) Avid Technology
- * - implemented read/write_color_span() so glRead/DrawPixels() works
- * - now needs Glide 2.3 or later. Removed GLIDE_FULL_SCREEN and call to grSstOpen()
- *
- * V0.17 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - optimized the bitmap support (66% faster)
- * - tested with the Mesa 2.3beta2
- *
- * Diego Picciani (d.picciani@novacomp.it) Nova Computer s.r.l.
- * - solved a problem with the drawbitmap() and the Voodoo Rush
- * (GR_ORIGIN_LOWER_LEFT did not work with the Stingray)
- *
- * Brian Paul (brianp@elastic.avid.com) Avid Technology
- * - linux stuff
- * - general code clean-up
- * - added attribList parameter to fxMesaCreateContext()
- * - single buffering works now
- * - VB colors are now GLubytes, removed ColorShift stuff
- *
- * Paul Metzger
- * - linux stuff
- *
- * V0.16 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - written the quadfunc support (no performance improvement)
- * - written the support for the new Mesa 2.3beta1 driver interface (Wow ! It is faaaster)
- * - rewritten the glBitmap support for the Glide 2.3 (~35% slower !)
- * - written the glBitmap support for the most common case (fonts)
- *
- * Jack Palevich
- * - Glide 2.3 porting
- *
- * Diego Picciani (d.picciani@novacomp.it) Nova Computer s.r.l.
- * - extended the fxMesaCreateContext() and fxMesaCreateBestContext()
- * functions in order to support also the Voodoo Rush
- * - tested with the Hercules Stingray 128/3D (The rendering in a window works !)
- *
- * V0.15 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - written the GL_LUMINANCE_ALPHA support
- * - written the GL_ALPHA support
- * - written the GL_LUMINANCE support
- * - now SETUP correctly set color for mono color sequences
- * - written the 9x1,10x1,...,1x9,1x10,... texture map ratio support
- * - written the no square texture map support
- * - the fog table is no more rebuilt inside setup_fx_units() each time
- *
- * Henri Fousse (arnaud@pobox.oleane.com) Thomson Training & Simulation
- * - written (not yet finished: no texture mapping) support for glOrtho
- * - some change to setup functions
- * - the fog support is now fully compatible with the standard OpenGL
- * - rewritten several parts of the driver in order to take
- * advantage of meshes (40% faster !!!)
- *
- * V0.14 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - now glAlphaFunc() works
- * - now glDepthMask() works
- * - solved a mipmap problem when using more than one texture
- * - moved ti, texid and wscale inside the fxMesaContext (now we can
- * easy support more ctx and more boards)
- * - the management of the fxMesaContext was completly broken !
- * - solved several problems about Alpha and texture Alpha
- * - 4 (RGBA) texture channels supported
- * - setting the default color to white
- *
- * Henri Fousse (arnaud@pobox.oleane.com) Thomson Training & Simulation
- * - small change to fxMesaCreateContext() and fxMesaMakeCurrent()
- * - written the fog support
- * - setting the default clear color to black
- * - written cleangraphics() for the onexit() function
- * - written fxMesaCreateBestContext()
- *
- * V0.13 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - now glBlendFunc() works for all glBlendFunc without DST_ALPHA
- * (because the alpha buffer is not yet implemented)
- * - now fxMesaCreateContext() accept resolution and refresh rate
- * - fixed a bug for texture mapping: the w (alias z) must be set
- * also without depth buffer
- * - fixed a bug for texture image with width!=256
- * - written texparam()
- * - written all point, line and triangle functions for all possible supported
- * contexts and the driver is slight faster with points, lines and small triangles
- * - fixed a small bug in fx/fxmesa.h (glOrtho)
- *
- * V0.12 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - glDepthFunc supported
- * - introduced a trick to discover the far plane distance
- * (see fxMesaSetFar and fx/fxmesa.h)
- * - now the wbuffer works with homogeneous coordinate (and it
- * doesn't work with a glOrtho projection :)
- * - solved several problems with homogeneous coordinate and texture mapping
- * - fixed a bug in all line functions
- * - fixed a clear framebuffer bug
- * - solved a display list/teximg problem (but use
- * glBindTexture: it is several times faster)
- *
- * V0.11 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - introduced texture mapping support (not yet finished !)
- * - tested with Mesa2.2b6
- * - the driver is faster
- * - written glFlush/glFinish
- * - the driver print a lot of info about the Glide lib
- *
- * v0.1 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
- * - Initial revision
- *
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-#include "fxdrv.h"
-
-static fxMesaContext fxMesaCurrentCtx=NULL;
-
-/*
- * Status of 3Dfx hardware initialization
- */
-
-static int glbGlideInitialized=0;
-static int glb3DfxPresent=0;
-static int glbTotNumCtx=0;
-
-GrHwConfiguration glbHWConfig;
-int glbCurrentBoard=0;
-
-
-#if defined(__WIN32__)
-static int cleangraphics(void)
-{
- glbTotNumCtx=1;
- fxMesaDestroyContext(fxMesaCurrentCtx);
-
- return 0;
-}
-#elif defined(__linux__)
-static void cleangraphics(void)
-{
- glbTotNumCtx=1;
- fxMesaDestroyContext(fxMesaCurrentCtx);
-}
-
-static void cleangraphics_handler(int s)
-{
- fprintf(stderr,"fxmesa: Received a not handled signal %d\n",s);
-
- cleangraphics();
-/* abort(); */
- exit(1);
-}
-#endif
-
-
-/*
- * Select the Voodoo board to use when creating
- * a new context.
- */
-GLboolean GLAPIENTRY fxMesaSelectCurrentBoard(int n)
-{
- fxQueryHardware();
-
- if((n<0) || (n>=glbHWConfig.num_sst))
- return GL_FALSE;
-
- glbCurrentBoard=n;
-
- return GL_TRUE;
-}
-
-
-fxMesaContext GLAPIENTRY fxMesaGetCurrentContext(void)
-{
- return fxMesaCurrentCtx;
-}
-
-
-void GLAPIENTRY fxMesaSetNearFar(GLfloat n, GLfloat f)
-{
- if(fxMesaCurrentCtx)
- fxDDSetNearFar(fxMesaCurrentCtx->glCtx,n,f);
-}
-
-
-/*
- * The 3Dfx Global Palette extension for GLQuake.
- * More a trick than a real extesion, use the shared global
- * palette extension.
- */
-extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */
-void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal)
-{
- fxMesaContext fxMesa =fxMesaCurrentCtx;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- int i;
-
- fprintf(stderr,"fxmesa: gl3DfxSetPaletteEXT()\n");
-
- for(i=0;i<256;i++)
- fprintf(stderr,"%x\n",pal[i]);
- }
-
- if(fxMesa) {
- fxMesa->haveGlobalPaletteTexture=1;
-
- FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
- if (fxMesa->haveTwoTMUs)
- FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
- }
-}
-
-
-static GrScreenResolution_t fxBestResolution(int width, int height, int aux)
-{
- static int resolutions[][5]={
- { 512, 384, GR_RESOLUTION_512x384, 2, 2 },
- { 640, 400, GR_RESOLUTION_640x400, 2, 2 },
- { 640, 480, GR_RESOLUTION_640x480, 2, 2 },
- { 800, 600, GR_RESOLUTION_800x600, 4, 2 },
- { 960, 720, GR_RESOLUTION_960x720, 6, 4 }
-#ifdef GR_RESOLUTION_1024x768
- ,{ 1024, 768, GR_RESOLUTION_1024x768, 8, 4 }
-#endif
-#ifdef GR_RESOLUTION_1280x1024
- ,{ 1024, 768, GR_RESOLUTION_1280x1024, 8, 8 }
-#endif
-#ifdef GR_RESOLUTION_1600x1200
- ,{ 1024, 768, GR_RESOLUTION_1600x1200, 16, 8 }
-#endif
- };
- int NUM_RESOLUTIONS = sizeof(resolutions) / (sizeof(int)*5);
- int i,fbmem;
- GrScreenResolution_t lastvalidres=resolutions[1][2];
-
- fxQueryHardware();
-
- if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
- fbmem=glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam;
-
- if(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect)
- fbmem*=2;
- } else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
- fbmem=glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam;
- else
- fbmem=2;
-
- /* A work around for BZFlag */
-
- if((width==1) && (height==1)) {
- width=640;
- height=480;
- }
-
- for(i=0;i<NUM_RESOLUTIONS;i++)
- if(resolutions[i][4-aux]<=fbmem) {
- if((width<=resolutions[i][0]) && (height<=resolutions[i][1]))
- return resolutions[i][2];
-
- lastvalidres=resolutions[i][2];
- }
-
- return lastvalidres;
-}
-
-
-fxMesaContext GLAPIENTRY fxMesaCreateBestContext(GLuint win,GLint width, GLint height,
- const GLint attribList[])
-{
- GrScreenRefresh_t refresh;
- int i;
- int res,aux;
- refresh=GR_REFRESH_75Hz;
-
- if(getenv("SST_SCREENREFRESH")) {
- if(!strcmp(getenv("SST_SCREENREFRESH"),"60"))
- refresh=GR_REFRESH_60Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"70"))
- refresh=GR_REFRESH_70Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"72"))
- refresh=GR_REFRESH_72Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"75"))
- refresh=GR_REFRESH_75Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"80"))
- refresh=GR_REFRESH_80Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"85"))
- refresh=GR_REFRESH_85Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"90"))
- refresh=GR_REFRESH_90Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"100"))
- refresh=GR_REFRESH_100Hz;
- if(!strcmp(getenv("SST_SCREENREFRESH"),"120"))
- refresh=GR_REFRESH_120Hz;
- }
-
- aux=0;
- for(i=0;attribList[i]!=FXMESA_NONE;i++)
- if((attribList[i]==FXMESA_ALPHA_SIZE) ||
- (attribList[i]==FXMESA_DEPTH_SIZE)) {
- if(attribList[++i]>0) {
- aux=1;
- break;
- }
- }
-
- res=fxBestResolution(width,height,aux);
-
- return fxMesaCreateContext(win,res,refresh,attribList);
-}
-
-
-#if 0
-void fxsignals()
-{
- signal(SIGINT,SIG_IGN);
- signal(SIGHUP,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGFPE,SIG_IGN);
- signal(SIGBUS,SIG_IGN);
- signal(SIGILL,SIG_IGN);
- signal(SIGSEGV,SIG_IGN);
- signal(SIGTERM,SIG_IGN);
-}
-#endif
-
-/*
- * Create a new FX/Mesa context and return a handle to it.
- */
-fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
- GrScreenResolution_t res,
- GrScreenRefresh_t ref,
- const GLint attribList[])
-{
- fxMesaContext fxMesa = NULL;
- int i,type;
- int aux;
- GLboolean doubleBuffer=GL_FALSE;
- GLboolean alphaBuffer=GL_FALSE;
- GLboolean verbose=GL_FALSE;
- GLint depthSize=0;
- GLint stencilSize=0;
- GLint accumSize=0;
- GLcontext *shareCtx = NULL;
- GLcontext *ctx = 0;
- /*FX_GrContext_t glideContext = 0;*/
- char *errorstr;
- GLboolean useBGR;
- char *system = NULL;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n");
- }
-
- if(getenv("MESA_FX_INFO"))
- verbose=GL_TRUE;
-
- aux=0;
- i=0;
- while(attribList[i]!=FXMESA_NONE) {
- switch (attribList[i]) {
- case FXMESA_DOUBLEBUFFER:
- doubleBuffer=GL_TRUE;
- break;
- case FXMESA_ALPHA_SIZE:
- i++;
- alphaBuffer=attribList[i]>0;
- if(alphaBuffer)
- aux=1;
- break;
- case FXMESA_DEPTH_SIZE:
- i++;
- depthSize=attribList[i];
- if(depthSize) {
- aux=1;
- depthSize = 16;
- }
- break;
- case FXMESA_STENCIL_SIZE:
- i++;
- stencilSize=attribList[i];
- break;
- case FXMESA_ACCUM_SIZE:
- i++;
- accumSize=attribList[i];
- break;
- /* XXX ugly hack here for sharing display lists */
-#define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with xmesa1.c! */
- case FXMESA_SHARE_CONTEXT:
- i++;
- {
- const void *vPtr = &attribList[i];
- GLcontext **ctx = (GLcontext **) vPtr;
- shareCtx = *ctx;
- }
- break;
- default:
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
- }
- return NULL;
- }
- i++;
- }
-
- /* A workaround for Linux GLQuake */
- if(depthSize && alphaBuffer)
- alphaBuffer=0;
-
- if ((type=fxQueryHardware()) < 0) {
- fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n");
- return NULL;
- }
-
- if(type==GR_SSTTYPE_VOODOO)
- win=0;
-
- grSstSelect(glbCurrentBoard);
-
- fxMesa=(fxMesaContext)calloc(1,sizeof(struct tfxMesaContext));
- if(!fxMesa) {
- errorstr = "malloc";
- goto errorhandler;
- }
-
- if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO)
- fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx > 1);
- else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
- fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx > 1);
- else
- fxMesa->haveTwoTMUs=GL_FALSE;
-
- fxMesa->haveAlphaBuffer=alphaBuffer;
- fxMesa->haveGlobalPaletteTexture=GL_FALSE;
- fxMesa->verbose=verbose;
- fxMesa->board=glbCurrentBoard;
-
-
- fxMesa->glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
-#if FXMESA_USE_ARGB
- GR_COLORFORMAT_ARGB,
-#else
- GR_COLORFORMAT_ABGR,
-#endif
- GR_ORIGIN_LOWER_LEFT,
- 2,aux);
- if (!fxMesa->glideContext){
- errorstr = "grSstWinOpen";
- goto errorhandler;
- }
-
- /*
- * Pixel tables are use during pixel read-back
- * Either initialize them for RGB or BGR order.
- */
-#if FXMESA_USE_ARGB
- useBGR = GL_FALSE; /* Force RGB pixel order */
- system = "FXMESA_USE_ARGB";
-#else
- if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
- /* jk991130 - Voodoo 3s don't use BGR. Query the # of TMUs
- * as Voodoo3s have 2 TMUs on board, Banshee has only 1
- * bk000413 - another suggestion from Joseph Kain is using
- * VendorID 0x121a for all 3dfx boards
- * DeviceID VG 1/V2 2/VB 3/V3 5
- * For now we cehck for known BGR devices, and presume
- * everything else to be a V3/RGB.
- */
- GrVoodooConfig_t *voodoo;
- voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
-
- if (voodoo->nTexelfx == 1) {
- /* Voodoo1 or Banshee */
- useBGR = GL_TRUE;
- system = "Voodoo1";
- }
- else if (voodoo->nTexelfx == 2 &&
- voodoo->fbiRev == 260 &&
- voodoo->tmuConfig[0].tmuRev == 4 &&
- (voodoo->tmuConfig[0].tmuRam == 2 ||
- voodoo->tmuConfig[0].tmuRam == 4)) {
- /* Voodoo 2 */
- useBGR = GL_TRUE;
- system = "Voodoo2";
- }
- else if (voodoo->nTexelfx == 2 &&
- voodoo->fbiRev == 2 &&
- voodoo->tmuConfig[0].tmuRev == 1 &&
- voodoo->tmuConfig[0].tmuRam == 4) {
- /* Quantum3D Obsidian 50/100 */
- useBGR = GL_TRUE;
- system = "Quantum3D Obsidian";
- }
- else
- /* Brian
- * (voodoo->nTexelfx == 2 &&
- * voodoo->fbiRev == 0 &&
- * voodoo->tmuConfig[0].tmuRev == 148441048 &&
- * voodoo->tmuConfig[0].tmuRam == 3)
- * Bernd
- * (voodoo->nTexelfx == 2 &&
- * voodoo->fbiRev == 69634 &&
- * voodoo->tmuConfig[0].tmuRev == 69634 &&
- * voodoo->tmuConfig[0].tmuRam == 2 )
- */
- {
- /* Presumed Voodoo3 */
- useBGR = GL_FALSE;
- system = "Voodoo3";
- }
- if (getenv("MESA_FX_INFO")) {
- printf("Voodoo: Texelfx: %d / FBI Rev.: %d / TMU Rev.: %d / TMU RAM: %d\n",
- voodoo->nTexelfx,
- voodoo->fbiRev,
- voodoo->tmuConfig[0].tmuRev,
- voodoo->tmuConfig[0].tmuRam );
- }
- }
- else {
- useBGR = GL_FALSE; /* use RGB pixel order otherwise */
- system = "non-voodoo";
- }
-#endif /*FXMESA_USE_ARGB*/
-
- if (getenv("MESA_FX_INFO"))
- printf("Voodoo pixel order: %s (%s)\n", useBGR ? "BGR" : "RGB", system);
-
- fxInitPixelTables(fxMesa, useBGR);
-
- fxMesa->width=FX_grSstScreenWidth();
- fxMesa->height=FX_grSstScreenHeight();
-
- fxMesa->clipMinX = 0;
- fxMesa->clipMaxX = fxMesa->width;
- fxMesa->clipMinY = 0;
- fxMesa->clipMaxY = fxMesa->height;
-
- fxMesa->screen_width = fxMesa->width;
- fxMesa->screen_height = fxMesa->height;
- fxMesa->x_offset = 0;
- fxMesa->y_offset = 0;
- fxMesa->y_delta = 0;
-
- fxMesa->needClip = 0;
-
- if(verbose)
- fprintf(stderr,"Voodoo Glide screen size: %dx%d\n",
- (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight());
-
- fxMesa->glVis=gl_create_visual(GL_TRUE, /* RGB mode */
- alphaBuffer,
- doubleBuffer,
- GL_FALSE, /* stereo */
- depthSize, /* depth_size */
- stencilSize, /* stencil_size */
- accumSize, /* accum_size */
- 0, /* index bits */
- 5,6,5,0); /* RGBA bits */
- if (!fxMesa->glVis) {
- errorstr = "gl_create_visual";
- goto errorhandler;
- }
-
- ctx = fxMesa->glCtx=gl_create_context(fxMesa->glVis,
- shareCtx, /* share list context */
- (void *) fxMesa, GL_TRUE);
- if (!ctx) {
- errorstr = "gl_create_context";
- goto errorhandler;
- }
-
-
- if (!fxDDInitFxMesaContext( fxMesa )) {
- errorstr = "fxDDInitFxMesaContext failed";
- goto errorhandler;
- }
-
-
- fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis,
- GL_FALSE, /* no software depth */
- fxMesa->glVis->StencilBits > 0,
- fxMesa->glVis->AccumRedBits > 0,
- fxMesa->glVis->AlphaBits > 0 );
- if (!fxMesa->glBuffer) {
- errorstr = "gl_create_framebuffer";
- goto errorhandler;
- }
-
- glbTotNumCtx++;
-
- /* install signal handlers */
-#if defined(__linux__)
- /* Only install if environment var. is not set. */
- if (fxMesa->glCtx->CatchSignals && !getenv("MESA_FX_NO_SIGNALS")) {
- signal(SIGINT,cleangraphics_handler);
- signal(SIGHUP,cleangraphics_handler);
- signal(SIGPIPE,cleangraphics_handler);
- signal(SIGFPE,cleangraphics_handler);
- signal(SIGBUS,cleangraphics_handler);
- signal(SIGILL,cleangraphics_handler);
- signal(SIGSEGV,cleangraphics_handler);
- signal(SIGTERM,cleangraphics_handler);
- }
-#endif
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() End\n");
- }
-
- return fxMesa;
-
- errorhandler:
- if (fxMesa) {
- if (fxMesa->glideContext)
- FX_grSstWinClose(fxMesa->glideContext);
- fxMesa->glideContext = 0;
-
- if (fxMesa->state)
- free(fxMesa->state);
- if (fxMesa->fogTable)
- free(fxMesa->fogTable);
- if (fxMesa->glBuffer)
- gl_destroy_framebuffer(fxMesa->glBuffer);
- if (fxMesa->glVis)
- gl_destroy_visual(fxMesa->glVis);
- if (fxMesa->glCtx)
- gl_destroy_context(fxMesa->glCtx);
- free(fxMesa);
- }
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaCreateContext() End (%s)\n",errorstr);
- }
- return NULL;
-}
-
-
-/*
- * Function to set the new window size in the context (mainly for the Voodoo Rush)
- */
-void GLAPIENTRY fxMesaUpdateScreenSize(fxMesaContext fxMesa)
-{
- fxMesa->width=FX_grSstScreenWidth();
- fxMesa->height=FX_grSstScreenHeight();
-}
-
-
-/*
- * Destroy the given FX/Mesa context.
- */
-void GLAPIENTRY fxMesaDestroyContext(fxMesaContext fxMesa)
-{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaDestroyContext()\n");
- }
-
- if(fxMesa) {
- gl_destroy_visual(fxMesa->glVis);
- gl_destroy_context(fxMesa->glCtx);
- gl_destroy_framebuffer(fxMesa->glBuffer);
-
- glbTotNumCtx--;
-
- fxCloseHardware();
- FX_grSstWinClose(fxMesa->glideContext);
-
- if(fxMesa->verbose) {
- fprintf(stderr,"Misc Stats:\n");
- fprintf(stderr," # swap buffer: %u\n",fxMesa->stats.swapBuffer);
-
- if(!fxMesa->stats.swapBuffer)
- fxMesa->stats.swapBuffer=1;
-
- fprintf(stderr,"Textures Stats:\n");
- fprintf(stderr," Free texture memory on TMU0: %d:\n",fxMesa->freeTexMem[FX_TMU0]);
- if(fxMesa->haveTwoTMUs)
- fprintf(stderr," Free texture memory on TMU1: %d:\n",fxMesa->freeTexMem[FX_TMU1]);
- fprintf(stderr," # request to TMM to upload a texture objects: %u\n",
- fxMesa->stats.reqTexUpload);
- fprintf(stderr," # request to TMM to upload a texture objects per swapbuffer: %.2f\n",
- fxMesa->stats.reqTexUpload/(float)fxMesa->stats.swapBuffer);
- fprintf(stderr," # texture objects uploaded: %u\n",
- fxMesa->stats.texUpload);
- fprintf(stderr," # texture objects uploaded per swapbuffer: %.2f\n",
- fxMesa->stats.texUpload/(float)fxMesa->stats.swapBuffer);
- fprintf(stderr," # MBs uploaded to texture memory: %.2f\n",
- fxMesa->stats.memTexUpload/(float)(1<<20));
- fprintf(stderr," # MBs uploaded to texture memory per swapbuffer: %.2f\n",
- (fxMesa->stats.memTexUpload/(float)fxMesa->stats.swapBuffer)/(float)(1<<20));
- }
- if (fxMesa->state)
- free(fxMesa->state);
- if (fxMesa->fogTable)
- free(fxMesa->fogTable);
- fxTMClose(fxMesa);
-
- free(fxMesa);
- }
-
- if(fxMesa==fxMesaCurrentCtx)
- fxMesaCurrentCtx=NULL;
-}
-
-
-/*
- * Make the specified FX/Mesa context the current one.
- */
-void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext fxMesa)
-{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(...) Start\n");
- }
-
- if(!fxMesa) {
- gl_make_current(NULL,NULL);
- fxMesaCurrentCtx=NULL;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(NULL) End\n");
- }
-
- return;
- }
-
- /* if this context is already the current one, we can return early */
- if (fxMesaCurrentCtx == fxMesa
- && fxMesaCurrentCtx->glCtx == gl_get_current_context()) {
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(fxMesaCurrentCtx==fxMesa) End\n");
- }
-
- return;
- }
-
- if(fxMesaCurrentCtx)
- grGlideGetState((GrState*)fxMesaCurrentCtx->state);
-
- fxMesaCurrentCtx=fxMesa;
-
- grSstSelect(fxMesa->board);
- grGlideSetState((GrState*)fxMesa->state);
-
- gl_make_current(fxMesa->glCtx,fxMesa->glBuffer);
-
- fxSetupDDPointers(fxMesa->glCtx);
-
- /* The first time we call MakeCurrent we set the initial viewport size */
- if(fxMesa->glCtx->Viewport.Width==0)
- gl_Viewport(fxMesa->glCtx,0,0,fxMesa->width,fxMesa->height);
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxMesaMakeCurrent(...) End\n");
- }
-}
-
-
-#if 0
-static void QueryCounters(void)
-{
- static GLuint prevPassed = 0;
- static GLuint prevFailed = 0;
- GLuint failed, passed;
- GrSstPerfStats_t st;
-
- FX_grSstPerfStats(&st);
- failed = st.zFuncFail - st.aFuncFail - st.chromaFail;
- passed = st.pixelsIn - failed;
- printf("failed: %d passed: %d\n", failed - prevFailed, passed - prevPassed);
-
- prevPassed = passed;
- prevFailed = failed;
-}
-#endif
-
-
-/*
- * Swap front/back buffers for current context if double buffered.
- */
-void GLAPIENTRY fxMesaSwapBuffers(void)
-{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: ------------------------------- fxMesaSwapBuffers() -------------------------------\n");
- }
-
- if(fxMesaCurrentCtx) {
- FLUSH_VB( fxMesaCurrentCtx->glCtx, "swap buffers" );
-
- if (fxMesaCurrentCtx->glVis->DBflag) {
-
- grBufferSwap(fxMesaCurrentCtx->swapInterval);
-
- /*
- * Don't allow swap buffer commands to build up!
- */
- while(FX_grGetInteger(FX_PENDING_BUFFERSWAPS)>fxMesaCurrentCtx->maxPendingSwapBuffers)
- /* The driver is able to sleep when waiting for the completation
- of multiple swapbuffer operations instead of wasting
- CPU time (NOTE: you must uncomment the following line in the
- in order to enable this option) */
- /* usleep(10000); */
- ;
-
- fxMesaCurrentCtx->stats.swapBuffer++;
- }
- }
-}
-
-
-/*
- * Query 3Dfx hardware presence/kind
- */
-int GLAPIENTRY fxQueryHardware(void)
-{
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxQueryHardware() Start\n");
- }
-
- if (!glbGlideInitialized) {
- grGlideInit();
- if (FX_grSstQueryHardware(&glbHWConfig)) {
- grSstSelect(glbCurrentBoard);
- glb3DfxPresent = 1;
-
- if (getenv("MESA_FX_INFO")) {
- char buf[80];
-
- FX_grGlideGetVersion(buf);
- fprintf(stderr, "Voodoo Using Glide V%s\n", buf);
- fprintf(stderr, "Voodoo Number of boards: %d\n", glbHWConfig.num_sst);
-
- if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
- GrVoodooConfig_t *voodoo;
- voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
-
- fprintf(stderr, "Voodoo Framebuffer RAM: %d\n",
- voodoo->sliDetect ? (voodoo->fbRam*2) : voodoo->fbRam);
- fprintf(stderr, "Voodoo Number of TMUs: %d\n", voodoo->nTexelfx);
- fprintf(stderr, "Voodoo fbRam: %d\n", voodoo->fbRam);
- fprintf(stderr, "Voodoo fbiRev: %d\n", voodoo->fbiRev);
-
- fprintf(stderr,"Voodoo SLI detected: %d\n", voodoo->sliDetect);
- }
- else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96) {
- GrSst96Config_t *sst96;
- sst96 = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
- fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", sst96->fbRam);
- fprintf(stderr, "Voodoo Number of TMUs: %d\n", sst96->nTexelfx);
- }
-
- }
- }
- else {
- glb3DfxPresent = 0;
- }
-
- glbGlideInitialized = 1;
-
-#if defined(__WIN32__)
- onexit((_onexit_t)cleangraphics);
-#elif defined(__linux__)
- /* Only register handler if environment variable is not defined. */
- if (!getenv("MESA_FX_NO_SIGNALS")) {
- atexit(cleangraphics);
- }
-#endif
- }
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxQueryHardware() End (voodooo)\n");
- }
-
- return glbHWConfig.SSTs[glbCurrentBoard].type;
-}
-
-
-/*
- * Shutdown Glide library
- */
-void GLAPIENTRY fxCloseHardware(void)
-{
- if (glbGlideInitialized) {
- if (getenv("MESA_FX_INFO")) {
- GrSstPerfStats_t st;
-
- FX_grSstPerfStats(&st);
- fprintf(stderr,"Pixels Stats:\n");
- fprintf(stderr," # pixels processed (minus buffer clears): %u\n",(unsigned)st.pixelsIn);
- fprintf(stderr," # pixels not drawn due to chroma key test failure: %u\n",(unsigned)st.chromaFail);
- fprintf(stderr," # pixels not drawn due to depth test failure: %u\n",(unsigned)st.zFuncFail);
- fprintf(stderr," # pixels not drawn due to alpha test failure: %u\n",(unsigned)st.aFuncFail);
- fprintf(stderr," # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut);
- }
-
- if (glbTotNumCtx == 0) {
- grGlideShutdown();
- glbGlideInitialized = 0;
- }
- }
-}
-
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-extern int gl_fx_dummy_function_api(void);
-int gl_fx_dummy_function_api(void)
-{
- return 0;
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxclip.c b/xc/extras/Mesa/src/FX/fxclip.c
deleted file mode 100644
index 7067516be..000000000
--- a/xc/extras/Mesa/src/FX/fxclip.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "mmath.h"
-#include "macros.h"
-#include "vector.h"
-#include "types.h"
-
-
-#if 0 && defined(__i386__)
-#define NEGATIVE(f) ((*(int *)&f) < 0)
-#define DIFFERENT_SIGNS(a,b) (((*(int *)&a)^(*(int *)&b)) < 0)
-#else
-#define NEGATIVE(f) (f < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#endif
-
-#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
-
-
-#define CLIP(sgn,v) \
-do { \
- GLuint out = in ^ 1; \
- GLfloat **indata = inlist[in]; \
- GrVertex **inverts = vertlist[in]; \
- GrVertex **outverts = vertlist[out]; \
- GLfloat **outdata = inlist[in = out]; \
- GLfloat *J = indata[n-1]; \
- GLfloat dpJ = (sgn J[v]) + J[3]; \
- GLuint nr = n; \
- \
- for (i = n = 0 ; i < nr ; i++) { \
- GLfloat *I = indata[i]; \
- GLfloat dpI = (sgn I[v]) + I[3]; \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLuint j; \
- GLfloat t = dpI / (dpI - dpJ); \
- outverts[n] = 0; \
- outdata[n++] = store; \
- store[3] = LINTERP(t, I[3], J[3]); \
- store[v] = - sgn store[3]; \
- if (v != 0) store[0] = LINTERP(t, I[0], J[0]); \
- if (v != 1) store[1] = LINTERP(t, I[1], J[1]); \
- if (v != 2) store[2] = LINTERP(t, I[2], J[2]); \
- store += 4; \
- for (j = 4 ; j < sz ; j+=4,store+=4) { \
- store[0] = LINTERP(t, I[j], J[j] ); \
- store[1] = LINTERP(t, I[j+1], J[j+1] ); \
- store[2] = LINTERP(t, I[j+2], J[j+2] ); \
- store[3] = LINTERP(t, I[j+3], J[j+3] ); \
- } \
- } \
- \
- if (!NEGATIVE(dpI)) { \
- outverts[n] = inverts[i]; \
- outdata[n++] = I; \
- } \
- \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if (n < 3) return 0; \
-} while (0)
-
-
-/* Originally used this for the viewclip planes as well, as in
- * CLIP(-1,0,0,1), which was just as fast, but tended to lead to
- * cracks. I haven't figured out exactly why this is, but the above
- * code only really differs in the way it sets store[v] to +- w.
- */
-#define UCLIP(a,b,c,d) \
-do { \
- GLuint out = in ^ 1; \
- GLfloat **indata = inlist[in]; \
- GrVertex **inverts = vertlist[in]; \
- GrVertex **outverts = vertlist[out]; \
- GLfloat **outdata = inlist[in = out]; \
- GLfloat *J = indata[n-1]; \
- GLfloat dpJ = DOT4V(J,a,b,c,d); \
- GLuint nr = n; \
- \
- for (i = n = 0 ; i < nr ; i++) { \
- GLfloat *I = indata[i]; \
- GLfloat dpI = DOT4V(I,a,b,c,d); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLuint j; \
- GLfloat t = dpI / (dpI - dpJ); \
- outverts[n] = 0; \
- outdata[n++] = store; \
- for (j = 0 ; j < sz ; j+=4,store+=4) { \
- store[0] = LINTERP(t, I[j], J[j] ); \
- store[1] = LINTERP(t, I[j+1], J[j+1] ); \
- store[2] = LINTERP(t, I[j+2], J[j+2] ); \
- store[3] = LINTERP(t, I[j+3], J[j+3] ); \
- } \
- } \
- \
- if (!NEGATIVE(dpI)) { \
- outverts[n] = inverts[i]; \
- outdata[n++] = I; \
- } \
- \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if (n < 3) return 0; \
-} while (0)
-
-
-
-/* Data parameter is organized as 4 clip coordinates followed by an
- * arbitary number (sz-4) of additional data. The three original
- * vertices are packed together at the start, and there is room for at
- * least VB_MAX_CLIPPED_VERTS vertices of the same size in this
- * storage.
- *
- */
-static INLINE GLuint fx_clip_triangle( GLcontext *ctx,
- GLfloat *inoutlist[],
- GrVertex **verts,
- GLuint sz,
- GLuint mask )
-{
- GLuint n = 3;
- GLfloat *store = inoutlist[n-1] + sz;
- GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
- GrVertex *verts2[VB_MAX_CLIPPED_VERTS];
- GLfloat **inlist[2];
- GrVertex **vertlist[2];
- GLuint in = 0;
- GLuint i;
-
- inlist[0] = inoutlist;
- inlist[1] = vlist;
-
- vertlist[0] = verts;
- vertlist[1] = verts2;
-
- if (mask & CLIP_ALL_BITS)
- {
- if (mask & CLIP_RIGHT_BIT)
- CLIP(-,0);
-
- if (mask & CLIP_LEFT_BIT)
- CLIP(+,0);
-
- if (mask & CLIP_TOP_BIT)
- CLIP(-,1);
-
- if (mask & CLIP_BOTTOM_BIT)
- CLIP(+,1);
-
- if (mask & CLIP_FAR_BIT)
- CLIP(-,2);
-
- if (mask & CLIP_NEAR_BIT)
- CLIP(+,2);
- }
-
- if (mask & CLIP_USER_BIT) {
- GLuint bit;
- GLfloat (*plane)[4] = &ctx->Transform.ClipUserPlane[0];
- for (bit = 0x100 ; bit < mask ; plane++, bit *= 2) {
- if (mask & bit) {
- GLfloat a = plane[0][0];
- GLfloat b = plane[0][1];
- GLfloat c = plane[0][2];
- GLfloat d = plane[0][3];
- UCLIP(a,b,c,d);
- }
- }
- }
-
- if (inlist[in] != inoutlist)
- for (i = 0 ; i < n ; i++) {
- inoutlist[i] = inlist[in][i];
- verts[i] = verts2[i];
- }
-
- return n;
-}
-
-
-
-static INLINE GLuint fx_view_clip_triangle( GLcontext *ctx,
- GLfloat *inoutlist[],
- GrVertex **verts,
- GLuint sz,
- GLubyte mask )
-{
- GLuint n = 3;
- GLfloat *store = inoutlist[n-1] + sz;
- GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
- GrVertex *verts2[VB_MAX_CLIPPED_VERTS];
- GLfloat **inlist[2];
- GrVertex **vertlist[2];
- GLuint in = 0;
- GLuint i;
-
- inlist[0] = inoutlist;
- inlist[1] = vlist;
-
- vertlist[0] = verts;
- vertlist[1] = verts2;
-
- if (mask & CLIP_RIGHT_BIT)
- CLIP(-,0);
-
- if (mask & CLIP_LEFT_BIT)
- CLIP(+,0);
-
- if (mask & CLIP_TOP_BIT)
- CLIP(-,1);
-
- if (mask & CLIP_BOTTOM_BIT)
- CLIP(+,1);
-
- if (mask & CLIP_FAR_BIT)
- CLIP(-,2);
-
- if (mask & CLIP_NEAR_BIT)
- CLIP(+,2);
-
- if (inlist[in] != inoutlist)
- for (i = 0 ; i < n ; i++) {
- inoutlist[i] = inlist[in][i];
- verts[i] = verts2[i];
- }
-
- return n;
-}
-
-
-
-#undef CLIP
-
-#define CLIP(x,y,z,w) \
-do { \
- GLfloat dpI = DOT4V(I,x,y,z,w); \
- GLfloat dpJ = DOT4V(J,x,y,z,w); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLuint j; \
- GLfloat t = dpI / (dpI - dpJ); \
- GLfloat *tmp = store; \
- \
- for (j = 0 ; j < sz ; j+=2) { \
- *store++ = LINTERP(t, I[j], J[j] ); \
- *store++ = LINTERP(t, I[j+1], J[j+1] ); \
- } \
- \
- if (NEGATIVE(dpI)) \
- I = tmp; \
- else \
- J = tmp; \
- \
- } \
- else if (NEGATIVE(dpI)) \
- return 0; \
- \
-} while (0)
-
-
-static GLuint fx_clip_line( GLcontext *ctx,
- GLfloat *inoutlist[],
- GLuint sz,
- GLubyte clipor )
-{
- GLfloat *I = inoutlist[0];
- GLfloat *J = inoutlist[1];
- GLfloat *store = J + sz;
-
- if (clipor & CLIP_ALL_BITS)
- {
- if (clipor & CLIP_LEFT_BIT)
- CLIP(1,0,0,1);
-
- if (clipor & CLIP_RIGHT_BIT)
- CLIP(-1,0,0,1);
-
- if (clipor & CLIP_TOP_BIT)
- CLIP(0,-1,0,1);
-
- if (clipor & CLIP_BOTTOM_BIT)
- CLIP(0,1,0,1);
-
- if (clipor & CLIP_FAR_BIT)
- CLIP(0,0,-1,1);
-
- if (clipor & CLIP_NEAR_BIT)
- CLIP(0,0,1,1);
- }
-
- if (clipor & CLIP_USER_BIT) {
- GLuint i;
- for (i = 0 ; i < MAX_CLIP_PLANES ; i++) {
- if (ctx->Transform.ClipEnabled[i]) {
- GLfloat a = ctx->Transform.ClipUserPlane[i][0];
- GLfloat b = ctx->Transform.ClipUserPlane[i][1];
- GLfloat c = ctx->Transform.ClipUserPlane[i][2];
- GLfloat d = ctx->Transform.ClipUserPlane[i][3];
- CLIP(a,b,c,d);
- }
- }
- }
-
- inoutlist[0] = I;
- inoutlist[1] = J;
-
- return 2;
-}
-
-
-
-
-
-
-#if defined(FX_V2)
-
-#define VARS_XYZW \
- GLfloat vsx = mat[MAT_SX]; \
- GLfloat vsy = mat[MAT_SY]; \
- GLfloat vsz = mat[MAT_SZ]; \
- GLfloat vtx = mat[MAT_TX]; \
- GLfloat vty = mat[MAT_TY]; \
- GLfloat vtz = mat[MAT_TZ];
-
-#define DO_SETUP_XYZW \
-{ \
- GLfloat oow = 1.0 / data[3]; \
- v->x = data[0]*oow*vsx + vtx; \
- v->y = data[1]*oow*vsy + vty; \
- v->ooz = data[2]*oow*vsz + vtz; \
- v->oow = oow; \
-}
-#else
-
-#if defined(DRIVERTS)
-
-#define VARS_XYZW \
- GLfloat vsx = mat[MAT_SX]; \
- GLfloat vsy = mat[MAT_SY]; \
- GLfloat vsz = mat[MAT_SZ]; \
- GLfloat vtx = mat[MAT_TX]+fxMesa->x_offset; \
- GLfloat vty = mat[MAT_TY]+fxMesa->y_delta; \
- GLfloat vtz = mat[MAT_TZ];
-
-#define DO_SETUP_XYZW \
-{ \
- GLfloat oow = 1.0 / data[3]; \
- v->x = data[0]*oow*vsx + vtx; \
- v->y = data[1]*oow*vsy + vty; \
- v->ooz = data[2]*oow*vsz + vtz; \
- v->oow = oow; \
-}
-
-#else
-#define VARS_XYZW \
- GLfloat vsx = mat[MAT_SX]; \
- GLfloat vsy = mat[MAT_SY]; \
- GLfloat vsz = mat[MAT_SZ]; \
- const GLfloat snapper = (3L << 18); \
- GLfloat snap_tx = mat[MAT_TX] + snapper; \
- GLfloat snap_ty = mat[MAT_TY] + snapper; \
- GLfloat vtz = mat[MAT_TZ];
-
-#define DO_SETUP_XYZW \
-{ \
- GLfloat oow = 1.0 / data[3]; \
- v->x = data[0]*oow*vsx + snap_tx; \
- v->y = data[1]*oow*vsy + snap_ty; \
- v->ooz = data[2]*oow*vsz + vtz; \
- v->oow = oow; \
- v->x -= snapper; \
- v->y -= snapper; \
-}
-
-#endif
-#endif
-
-#define COPY_XYZW_STRIDE \
- { GLfloat *clip = VEC_ELT(VB->ClipPtr, GLfloat, e); \
- COPY_4FV(out, clip); }
-
-#define VARS_RGBA
-
-#define COPY_RGBA_STRIDE \
- { GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, e); \
- UBYTE_RGBA_TO_FLOAT_255_RGBA((out+4), color); }
-
-#if FX_USE_PARGB
-#define DO_SETUP_RGBA \
- GET_PARGB(v) = (((int)data[4+3]) << 24) | \
- (((int)data[4+0]) << 16) | \
- (((int)data[4+1]) << 8) | \
- (((int)data[4+2]) << 0);
-#else
-#define DO_SETUP_RGBA \
- v->r = data[4+0]; \
- v->g = data[4+1]; \
- v->b = data[4+2]; \
- v->a = data[4+3];
-#endif /* FX_USE_PARGB */
-
-#define VARS_TMU0 \
- struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source]; \
- GLfloat sScale0 = fxTMGetTexInfo(t0->Current)->sScale; \
- GLfloat tScale0 = fxTMGetTexInfo(t0->Current)->tScale; \
-
-
-#define COPY_TMU0_STRIDE(offset) \
- { GLfloat *tc0 = VEC_ELT(tc0_vec, GLfloat, e); \
- COPY_2V((out+offset), tc0); }
-
-
-#define DO_SETUP_TMU0(offset) \
- v->tmuvtx[0].sow = data[offset+0]*sScale0*v->oow; \
- v->tmuvtx[0].tow = data[offset+1]*tScale0*v->oow;
-
-#define VARS_TMU1 \
- struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source]; \
- GLfloat sScale1 = fxTMGetTexInfo(t1->Current)->sScale; \
- GLfloat tScale1 = fxTMGetTexInfo(t1->Current)->tScale;
-
-#define COPY_TMU1_STRIDE(offset) \
- { GLfloat *tc1 = VEC_ELT(tc1_vec, GLfloat, e); \
- COPY_2V((out+offset), tc1); }
-
-
-#define DO_SETUP_TMU1(offset) \
- v->tmuvtx[1].sow = data[offset+0]*sScale1*v->oow; \
- v->tmuvtx[1].tow = data[offset+1]*tScale1*v->oow;
-
-#define COPY_NIL(offset) ASSIGN_2V((out+offset), 0, 0);
-
-#define IND 0
-#define TAG(x) x##_nil
-#include "fxcliptmp.h"
-
-#define IND SETUP_RGBA
-#define TAG(x) x##_RGBA
-#include "fxcliptmp.h"
-
-#define IND SETUP_TMU0
-#define TAG(x) x##_TMU0
-#include "fxcliptmp.h"
-
-#define IND (SETUP_TMU0|SETUP_TMU1)
-#define TAG(x) x##_TMU0_TMU1
-#include "fxcliptmp.h"
-
-#define IND (SETUP_RGBA|SETUP_TMU0)
-#define TAG(x) x##_RGBA_TMU0
-#include "fxcliptmp.h"
-
-#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
-#define TAG(x) x##_RGBA_TMU0_TMU1
-#include "fxcliptmp.h"
-
-tfxTriViewClipFunc fxTriViewClipTab[0x8];
-tfxTriClipFunc fxTriClipStrideTab[0x8];
-tfxLineClipFunc fxLineClipTab[0x8];
-
-
-void fxDDClipInit()
-{
- fxTriViewClipTab[0] = fx_tri_view_clip_nil;
- fxTriViewClipTab[SETUP_RGBA] = fx_tri_view_clip_RGBA;
- fxTriViewClipTab[SETUP_TMU0] = fx_tri_view_clip_TMU0;
- fxTriViewClipTab[SETUP_TMU0|SETUP_TMU1] = fx_tri_view_clip_TMU0_TMU1;
- fxTriViewClipTab[SETUP_RGBA|SETUP_TMU0] = fx_tri_view_clip_RGBA_TMU0;
- fxTriViewClipTab[SETUP_RGBA|SETUP_TMU0|SETUP_TMU1] = fx_tri_view_clip_RGBA_TMU0_TMU1;
-
- fxTriClipStrideTab[0] = fx_tri_clip_stride_nil;
- fxTriClipStrideTab[SETUP_RGBA] = fx_tri_clip_stride_RGBA;
- fxTriClipStrideTab[SETUP_TMU0] = fx_tri_clip_stride_TMU0;
- fxTriClipStrideTab[SETUP_TMU0|SETUP_TMU1] = fx_tri_clip_stride_TMU0_TMU1;
- fxTriClipStrideTab[SETUP_RGBA|SETUP_TMU0] = fx_tri_clip_stride_RGBA_TMU0;
- fxTriClipStrideTab[SETUP_RGBA|SETUP_TMU0|SETUP_TMU1] = fx_tri_clip_stride_RGBA_TMU0_TMU1;
-
- fxLineClipTab[0] = fx_line_clip_nil;
- fxLineClipTab[SETUP_RGBA] = fx_line_clip_RGBA;
- fxLineClipTab[SETUP_TMU0] = fx_line_clip_TMU0;
- fxLineClipTab[SETUP_TMU0|SETUP_TMU1] = fx_line_clip_TMU0_TMU1;
- fxLineClipTab[SETUP_RGBA|SETUP_TMU0] = fx_line_clip_RGBA_TMU0;
- fxLineClipTab[SETUP_RGBA|SETUP_TMU0|SETUP_TMU1] = fx_line_clip_RGBA_TMU0_TMU1;
-}
-
-#else
-
-/*
- * Need this to provide at least one external definition.
- */
-int gl_fxclip_dummy(void)
-{
- return 0;
-}
-
-#endif
diff --git a/xc/extras/Mesa/src/FX/fxcliptmp.h b/xc/extras/Mesa/src/FX/fxcliptmp.h
deleted file mode 100644
index 82beeda6a..000000000
--- a/xc/extras/Mesa/src/FX/fxcliptmp.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#define V1 VARS_XYZW
-#define S1 DO_SETUP_XYZW
-#define T1 COPY_XYZW_STRIDE
-#define Z1 4
-
-#if (IND & SETUP_RGBA)
-#define V2 V1 VARS_RGBA
-#define S2 S1 DO_SETUP_RGBA
-#define T2 T1 COPY_RGBA_STRIDE
-#define Z2 (Z1 + 4)
-#else
-#define V2 V1
-#define S2 S1
-#define T2 T1
-#define Z2 Z1
-#endif
-
-#if (IND & SETUP_TMU0)
-#define V3 V2 VARS_TMU0
-#define S3 S2 DO_SETUP_TMU0(Z2)
-#define T3 T2 COPY_TMU0_STRIDE(Z2)
-#define Z3 (Z2 + 2)
-#else
-#define V3 V2
-#define S3 S2
-#define T3 T2
-#define Z3 Z2
-#endif
-
-#if (IND & SETUP_TMU1)
-#define V4 V3 VARS_TMU1
-#define S4 S3 DO_SETUP_TMU1(Z3)
-#define T4 T3 COPY_TMU1_STRIDE(Z3)
-#define Z4 (Z3 + 2)
-#else
-#define V4 V3
-#define S4 S3
-#define T4 T3
-#define Z4 Z3
-#endif
-
-#if (Z4 & 2)
-#define SIZE (Z4+2)
-#define COPY_STRIDE T4 COPY_NIL(Z4)
-#else
-#define SIZE Z4
-#define COPY_STRIDE T4
-#endif
-
-#define VARS V4
-#define SETUP S4
-
-#define DRAW_LINE(tmp0, tmp1, width) \
- do { \
- GrVertex verts[4]; \
- float dx, dy, ix, iy; \
- \
- dx = tmp0->x - tmp1->x; \
- dy = tmp0->y - tmp1->y; \
- \
- if (dx * dx > dy * dy) { \
- iy = width * .5; \
- ix = 0; \
- } else { \
- iy = 0; \
- ix = width * .5; \
- } \
- \
- verts[0] = *tmp0; \
- verts[1] = *tmp0; \
- verts[2] = *tmp1; \
- verts[3] = *tmp1; \
- \
- verts[0].x = tmp0->x - ix; \
- verts[0].y = tmp0->y - iy; \
- \
- verts[1].x = tmp0->x + ix; \
- verts[1].y = tmp0->y + iy; \
- \
- verts[2].x = tmp1->x + ix; \
- verts[2].y = tmp1->y + iy; \
- \
- verts[3].x = tmp1->x - ix; \
- verts[3].y = tmp1->y - iy; \
- \
- FX_grDrawPolygonVertexList(4, verts); \
- } while (0)
-
-static void TAG(fx_tri_view_clip)( struct vertex_buffer *VB,
- GLuint v[],
- GLubyte mask )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLfloat data[VB_MAX_CLIPPED_VERTS*12];
- GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
- GrVertex *verts[VB_MAX_CLIPPED_VERTS];
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLfloat *out = data;
- GLfloat *mat = ctx->Viewport.WindowMap.m;
- GLuint i, n;
- GLubyte *clipmask = VB->ClipMask;
-
- GLuint tmu0_source = fxMesa->tmu_source[0];
- GLuint tmu1_source = fxMesa->tmu_source[1];
- GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
- GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
-
- (void) fxMesa;
- (void) tmu0_source; (void) tc0_vec;
- (void) tmu1_source; (void) tc1_vec;
-
- for (i = 0 ; i < 3 ; i++) {
- GLuint e = v[i];
- verts[i] = 0;
- if (!clipmask[e]) verts[i] = (GrVertex *)gWin[e].f;
- vlist[i] = out;
- COPY_STRIDE;
- out += SIZE;
- }
-
- if ((n = fx_view_clip_triangle( ctx, vlist, verts, SIZE, mask )) >= 3)
- {
- GrVertex tmp[VB_MAX_CLIPPED_VERTS];
- GrVertex *v = tmp, *v2, *v3;
- VARS;
-
- for (i = 0 ; i < n ; i++)
- if (!verts[i]) {
- GLfloat *data = vlist[i];
- SETUP;
- verts[i] = v++;
- }
-
- v = verts[0];
- v2 = verts[1];
- v3 = verts[2];
-
- for (i = 2 ; i < n ; v2 = v3, v3=verts[++i])
- FX_grDrawTriangle(v, v2, v3);
- }
-}
-
-
-
-
-
-static void TAG(fx_tri_clip_stride)( struct vertex_buffer *VB,
- GLuint v[],
- GLuint mask )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLfloat data[VB_MAX_CLIPPED_VERTS*12];
- GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
- GrVertex *verts[VB_MAX_CLIPPED_VERTS];
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLfloat *out = data;
- GLfloat *mat = ctx->Viewport.WindowMap.m;
- GLuint i, n;
- GLubyte *clipmask = VB->ClipMask;
-
- GLuint tmu0_source = fxMesa->tmu_source[0];
- GLuint tmu1_source = fxMesa->tmu_source[1];
- GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
- GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
-
- (void) fxMesa;
- (void) tmu0_source; (void) tc0_vec;
- (void) tmu1_source; (void) tc1_vec;
-
- for (i = 0 ; i < 3 ; i++) {
- GLuint e = v[i];
- verts[i] = 0;
- if (!clipmask[e]) verts[i] = (GrVertex *)gWin[e].f;
- vlist[i] = out;
- COPY_STRIDE;
- out += SIZE;
- }
-
- if (VB->ClipPtr->size < 4) {
- vlist[0][3] = vlist[1][3] = vlist[2][3] = 1.0;
- if (VB->ClipPtr->size == 2)
- vlist[0][2] = vlist[1][2] = vlist[2][2] = 0.0;
- }
-
- if ((n = fx_clip_triangle( ctx, vlist, verts, SIZE, mask )) >= 3)
- {
- GrVertex tmp[VB_MAX_CLIPPED_VERTS];
- GrVertex *v = tmp, *v2, *v3;
- VARS;
-
- for (i = 0 ; i < n ; i++)
- if (!verts[i]) {
- GLfloat *data = vlist[i];
- SETUP;
- verts[i] = v++;
- }
-
- v = verts[0];
- v2 = verts[1];
- v3 = verts[2];
-
- for (i = 2 ; i < n ; v2 = v3, v3=verts[++i])
- FX_grDrawTriangle(v, v2, v3);
- }
-}
-
-
-
-static void TAG(fx_line_clip)( struct vertex_buffer *VB,
- GLuint v1, GLuint v2,
- GLubyte mask )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLfloat data[VB_MAX_CLIPPED_VERTS*12];
- GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
- GLfloat *out = data;
- GLfloat *mat = ctx->Viewport.WindowMap.m;
- GLfloat w = ctx->Line.Width*.5;
- GLuint e, n;
-
- GLuint tmu0_source = fxMesa->tmu_source[0];
- GLuint tmu1_source = fxMesa->tmu_source[1];
- GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
- GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
-
- VARS;
-
- (void) fxMesa;
- (void) tmu0_source; (void) tc0_vec;
- (void) tmu1_source; (void) tc1_vec;
-
- vlist[0] = out;
- e = v1;
- COPY_STRIDE;
- out += SIZE;
-
- vlist[1] = out;
- e = v2;
- COPY_STRIDE;
- out += SIZE;
-
- if (VB->ClipPtr->size < 4) {
- vlist[0][3] = vlist[1][3] = 1.0;
- if (VB->ClipPtr->size == 2)
- vlist[0][2] = vlist[1][2] = 0.0;
- }
-
- if ((n = fx_clip_line( ctx, vlist, SIZE, mask )) != 0)
- {
- GrVertex gWin[2];
- GrVertex *v;
- GLfloat *data;
-
- v = gWin;
- data = vlist[0];
- SETUP;
-
- v++;
- data = vlist[1];
- SETUP;
-
- DRAW_LINE(gWin, v, w);
- }
-}
-
-
-
-#undef V1
-#undef S1
-#undef C1
-#undef Z1
-#undef T1
-
-#undef V2
-#undef S2
-#undef C2
-#undef Z2
-#undef T2
-
-#undef V3
-#undef S3
-#undef C3
-#undef Z3
-#undef T3
-
-#undef V4
-#undef S4
-#undef C4
-#undef Z4
-#undef T4
-
-#undef VARS
-#undef SETUP
-#undef COPY
-#undef COPY_STRIDE
-#undef SIZE
-#undef IND
-#undef TAG
diff --git a/xc/extras/Mesa/src/FX/fxcva.c b/xc/extras/Mesa/src/FX/fxcva.c
deleted file mode 100644
index 188210add..000000000
--- a/xc/extras/Mesa/src/FX/fxcva.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxcva.c - the CVA related code */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "mmath.h"
-#include "vbindirect.h"
-#include "pb.h"
-#include "fxvsetup.h"
-#include "pipeline.h"
-#include "stages.h"
-
-#define PRIM_POINTS 0
-#define PRIM_LINES 1
-#define PRIM_TRIS 2
-#define PRIM_CULLED 3
-
-
-static GLuint reduce_prim[GL_POLYGON+2] = {
- PRIM_POINTS,
- PRIM_LINES,
- PRIM_LINES,
- PRIM_LINES,
- PRIM_TRIS,
- PRIM_TRIS,
- PRIM_TRIS,
- PRIM_TRIS,
- PRIM_TRIS,
- PRIM_TRIS,
- PRIM_CULLED
-};
-
-typedef void (*mergefunc)( struct vertex_buffer *cvaVB,
- struct vertex_buffer *VB,
- const struct gl_prim_state *state,
- GLuint start,
- GLuint count );
-
-static void fxCvaRenderNoop( struct vertex_buffer *cvaVB,
- struct vertex_buffer *VB,
- const struct gl_prim_state *state,
- GLuint start,
- GLuint count )
-{
-}
-
-static INLINE void fxRenderClippedTriangle2( struct vertex_buffer *VB,
- GLuint v1, GLuint v2, GLuint v3 )
-{
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLubyte *clipmask = VB->ClipMask;
- GLubyte mask = clipmask[v1] | clipmask[v2] | clipmask[v3];
-
- if (!mask) {
- FX_grDrawTriangle((GrVertex *)gWin[v1].f,
- (GrVertex *)gWin[v2].f,
- (GrVertex *)gWin[v3].f);
- } else if (!(clipmask[v1]&clipmask[v2]&clipmask[v3]&CLIP_ALL_BITS)) {
- GLuint n;
- GLuint vlist[VB_MAX_CLIPPED_VERTS];
- ASSIGN_3V(vlist, v1, v2, v3);
-
- n = (VB->ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 3, vlist, mask );
- if (n >= 3) {
- GLuint i, j0 = vlist[0];
- for (i=2;i<n;i++) {
- FX_grDrawTriangle((GrVertex *)gWin[j0].f,
- (GrVertex *)gWin[vlist[i-1]].f,
- (GrVertex *)gWin[vlist[i]].f);
- }
- }
- }
-}
-
-
-static mergefunc merge_and_render_tab[2][MAX_MERGABLE][PRIM_CULLED+1];
-
-
-/*
-#define CVA_VARS_RGBA \
- GLubyte (*color)[4] = VB->ColorPtr->data; \
- GLubyte (*cva_color)[4] = (cvaVB->ColorPtr = cvaVB->LitColor[0])->data;
-*/
-
-#define CVA_VARS_RGBA \
- GLubyte (*color)[4] = VB->ColorPtr->data; \
- GLubyte (*cva_color)[4] = cvaVB->ColorPtr->data;
-
-
-
-#undef DO_SETUP_RGBA
-#if FX_USE_PARGB
-#define DO_SETUP_RGBA \
-{ \
- GLubyte *col = color[i]; \
- GET_PARGB(v)= ((col[3] << 24) | \
- (col[0] << 16) | \
- (col[1] << 8) | \
- (col[2])); \
-}
-#else
-#define DO_SETUP_RGBA \
-{ \
- GLubyte *col = color[i]; \
- v[GR_VERTEX_R_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
- v[GR_VERTEX_G_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
- v[GR_VERTEX_B_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
- v[GR_VERTEX_A_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
-}
-#endif /* FX_USE_PARGB */
-
-
-#define CVA_VARS_TMU0 \
- VARS_TMU0 \
- GLfloat (*cva_tex0)[4] = (cvaVB->TexCoordPtr[tmu0_source] = cvaVB->store.TexCoord[tmu0_source])->data;
-
-#define CVA_VARS_TMU1 \
- VARS_TMU1 \
- GLfloat (*cva_tex1)[4] = (cvaVB->TexCoordPtr[tmu1_source] = cvaVB->store.TexCoord[tmu1_source])->data;
-
-
-#define INIT_RGBA (void) cva_color;
-#define INIT_TMU0 (void) cva_tex0; (void) tmu0_stride; (void) tmu0_sz;
-#define INIT_TMU1 (void) cva_tex1; (void) tmu1_stride; (void) tmu1_sz;
-
-
-#define DRAW_POINT FX_grDrawPoint( (GrVertex *)v )
-#define DRAW_LINE FX_grDrawLine( (GrVertex *)v, (GrVertex *)prev_v )
-#define DRAW_TRI FX_grDrawTriangle( (GrVertex *)gWin[l[0]].f, (GrVertex *)gWin[l[1]].f, (GrVertex *)v )
-#define DRAW_TRI2 FX_grDrawTriangle( vl[0], vl[1], vl[2] )
-#define CLIP_LINE fxRenderClippedLine( cvaVB, e, prev )
-#define CLIP_OR_DRAW_TRI fxRenderClippedTriangle2( cvaVB, l[0], l[1], e )
-#define DIRECT 1
-
-#define TAG(x) x
-#define IDX 0
-#define VARS
-#define INIT
-#define INCR
-#define MERGE_RAST
-#define MERGE_VB
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBA
-#define IDX SETUP_RGBA
-#define VARS CVA_VARS_RGBA
-#define INIT INIT_RGBA
-#define INCR
-#define MERGE_RAST DO_SETUP_RGBA
-#define MERGE_VB COPY_4UBV(cva_color[e], color[i])
-#include "fxcvatmp.h"
-
-#define TAG(x) x##T0
-#define IDX SETUP_TMU0
-#define VARS CVA_VARS_TMU0
-#define INIT INIT_TMU0
-#define INCR , tmu0_data+=4
-#define MERGE_RAST DO_SETUP_TMU0
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data)
-#include "fxcvatmp.h"
-
-#define TAG(x) x##T1
-#define IDX SETUP_TMU1
-#define VARS CVA_VARS_TMU1
-#define INIT INIT_TMU1
-#define INCR , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data)
-#include "fxcvatmp.h"
-
-#define TAG(x) x##T0T1
-#define IDX SETUP_TMU0|SETUP_TMU1
-#define VARS CVA_VARS_TMU0 CVA_VARS_TMU1
-#define INIT INIT_TMU0 INIT_TMU1
-#define INCR , tmu0_data+=4 , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_TMU0 DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
- COPY_2FV(cva_tex1[e], tmu1_data);
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBAT0
-#define IDX SETUP_RGBA|SETUP_TMU0
-#define VARS CVA_VARS_RGBA CVA_VARS_TMU0
-#define INIT INIT_RGBA INIT_TMU0
-#define INCR , tmu0_data+=4
-#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
- COPY_4UBV(cva_color[e], color[i]);
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBAT1
-#define IDX SETUP_RGBA|SETUP_TMU1
-#define VARS CVA_VARS_RGBA CVA_VARS_TMU1
-#define INIT INIT_RGBA INIT_TMU1
-#define INCR , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data); \
- COPY_4UBV(cva_color[e], color[i]);
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBAT0T1
-#define IDX SETUP_RGBA|SETUP_TMU0|SETUP_TMU1
-#define VARS CVA_VARS_RGBA CVA_VARS_TMU0 CVA_VARS_TMU1
-#define INIT INIT_RGBA INIT_TMU0 INIT_TMU1
-#define INCR , tmu0_data+=4 , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0 DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
- COPY_2FV(cva_tex1[e], tmu1_data); \
- COPY_4UBV(cva_color[e], color[i]);
-#include "fxcvatmp.h"
-
-
-
-#undef DRAW_POINT
-#undef DRAW_LINE
-#undef DRAW_TRI
-#undef CLIP_LINE
-#undef CLIP_OR_DRAW_TRI
-#undef DIRECT
-
-#define DRAW_POINT ctx->Driver.PointsFunc( ctx, e, e )
-#define DRAW_LINE ctx->Driver.LineFunc( ctx, e, prev, e )
-#define DRAW_TRI ctx->TriangleFunc( ctx, l[0], l[1], e, e )
-#define CLIP_LINE gl_render_clipped_line( ctx, e, prev )
-#define CLIP_OR_DRAW_TRI \
-do { \
- if (clip[l[0]] | clip[l[1]] | clip[e]) { \
- if (!(clip[l[0]] & clip[l[1]] & clip[e] & CLIP_ALL_BITS)) { \
- COPY_3V(vlist, l); \
- gl_render_clipped_triangle( ctx, 3, vlist, e ); \
- } \
- } \
- else ctx->TriangleFunc( ctx, l[0], l[1], e, e ); \
-} while (0)
-
-
-#define DIRECT 0
-
-#define TAG(x) x##_indirect
-#define IDX 0
-#define VARS
-#define INIT
-#define INCR
-#define MERGE_RAST
-#define MERGE_VB
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBA_indirect
-#define IDX SETUP_RGBA
-#define VARS CVA_VARS_RGBA
-#define INIT INIT_RGBA
-#define INCR
-#define MERGE_RAST DO_SETUP_RGBA
-#define MERGE_VB COPY_4UBV(cva_color[e], color[i])
-#include "fxcvatmp.h"
-
-#define TAG(x) x##T0_indirect
-#define IDX SETUP_TMU0
-#define VARS CVA_VARS_TMU0
-#define INIT INIT_TMU0
-#define INCR , tmu0_data+=4
-#define MERGE_RAST DO_SETUP_TMU0
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data)
-#include "fxcvatmp.h"
-
-#define TAG(x) x##T1_indirect
-#define IDX SETUP_TMU1
-#define VARS CVA_VARS_TMU1
-#define INIT INIT_TMU1
-#define INCR , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data)
-#include "fxcvatmp.h"
-
-#define TAG(x) x##T0T1_indirect
-#define IDX SETUP_TMU0|SETUP_TMU1
-#define VARS CVA_VARS_TMU0 CVA_VARS_TMU1
-#define INIT INIT_TMU0 INIT_TMU1
-#define INCR , tmu0_data+=4 , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_TMU0 DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
- COPY_2FV(cva_tex1[e], tmu1_data);
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBAT0_indirect
-#define IDX SETUP_RGBA|SETUP_TMU0
-#define VARS CVA_VARS_RGBA CVA_VARS_TMU0
-#define INIT INIT_RGBA INIT_TMU0
-#define INCR , tmu0_data+=4
-#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
- COPY_4UBV(cva_color[e], color[i]);
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBAT1_indirect
-#define IDX SETUP_RGBA|SETUP_TMU1
-#define VARS CVA_VARS_RGBA CVA_VARS_TMU1
-#define INIT INIT_RGBA INIT_TMU1
-#define INCR , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data); \
- COPY_4UBV(cva_color[e], color[i]);
-#include "fxcvatmp.h"
-
-#define TAG(x) x##RGBAT0T1_indirect
-#define IDX SETUP_RGBA|SETUP_TMU0|SETUP_TMU1
-#define VARS CVA_VARS_RGBA CVA_VARS_TMU0 CVA_VARS_TMU1
-#define INIT INIT_RGBA INIT_TMU0 INIT_TMU1
-#define INCR , tmu0_data+=4 , tmu1_data+=4
-#define MERGE_RAST DO_SETUP_RGBA DO_SETUP_TMU0 DO_SETUP_TMU1
-#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
- COPY_2FV(cva_tex1[e], tmu1_data); \
- COPY_4UBV(cva_color[e], color[i]);
-#include "fxcvatmp.h"
-
-
-
-
-void fxDDCvaInit()
-{
- /* Call grDrawTriangle et al */
- init_cva();
- init_cvaT0();
- init_cvaT1();
- init_cvaT0T1();
- init_cvaRGBA();
- init_cvaRGBAT0();
- init_cvaRGBAT1();
- init_cvaRGBAT0T1();
-
- /* Call ctx->TriangleFunc and friends */
- init_cva_indirect();
- init_cvaT0_indirect();
- init_cvaT1_indirect();
- init_cvaT0T1_indirect();
- init_cvaRGBA_indirect();
- init_cvaRGBAT0_indirect();
- init_cvaRGBAT1_indirect();
- init_cvaRGBAT0T1_indirect();
-}
-
-
-void fxDDCheckMergeAndRender( GLcontext *ctx, struct gl_pipeline_stage *d )
-{
- GLuint inputs = ctx->RenderFlags & ~ctx->CVA.pre.outputs;
-
- if (!(ctx->TriangleCaps & DD_TRI_UNFILLED) &&
- (ctx->Array.Summary & VERT_OBJ_ANY))
- {
- d->inputs = (VERT_SETUP_PART | VERT_ELT | inputs);
- d->outputs = 0;
- d->type = PIPE_IMMEDIATE;
- }
-
-/* gl_print_vert_flags("merge&render inputs", d->inputs); */
-}
-
-
-extern void fxPointSmooth(GLcontext *ctx, GLuint first, GLuint last);
-extern void fxLineSmooth(GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv);
-extern void fxTriangleSmooth(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3,
- GLuint pv);
-extern const char *gl_prim_name[];
-
-
-/* static GLboolean edge_flag[GL_POLYGON+2] = { 0,0,0,0,1,0,0,1,0,1,0 }; */
-
-void fxDDMergeAndRender( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- struct vertex_buffer *cvaVB = ctx->CVA.VB;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLuint i, next, prim;
- GLuint parity = VB->Parity;
- GLuint count = VB->Count;
- const struct gl_prim_state *state;
- mergefunc func;
- struct vertex_buffer *saved_vb = ctx->VB;
- GLuint inputs = ctx->RenderFlags & ~ctx->CVA.pre.outputs;
- GLuint flags = 0;
- GLuint direct = (fxMesa->render_index == 0);
- mergefunc (*tab)[PRIM_CULLED+1] = merge_and_render_tab[direct];
- GLuint p = 0;
-
- if (fxMesa->new_state)
- fxSetupFXUnits(ctx);
-
-
- /* May actually contain elements not present in fxMesa->setupindex,
- * eg RGBA when flat shading. These need to be copied into the cva
- * VB so that funcs like fxTriangleFlat will be able to reach them.
- *
- * This leads to some duplication of effort in the merge funcs.
- */
- if (inputs & VERT_RGBA) {
- cvaVB->ColorPtr = cvaVB->Color[0] = cvaVB->LitColor[0];
- cvaVB->Color[1] = cvaVB->LitColor[1];
- flags |= SETUP_RGBA;
- }
-
- if (inputs & VERT_TEX0_ANY) {
- cvaVB->TexCoordPtr[0] = cvaVB->store.TexCoord[0];
- flags |= fxMesa->tex_dest[0];
- }
-
- if (inputs & VERT_TEX1_ANY) {
- cvaVB->TexCoordPtr[1] = cvaVB->store.TexCoord[1];
- flags |= fxMesa->tex_dest[1];
- }
-#if 0
- fxPrintSetupFlags("FX cva merge & render", flags);
-#endif
-
- if (cvaVB->ClipOrMask)
- gl_import_client_data( cvaVB, ctx->RenderFlags,
- VEC_WRITABLE|VEC_GOOD_STRIDE );
-
- ctx->VB = cvaVB;
-
- do {
- for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
- {
- prim = VB->Primitive[i];
- next = VB->NextPrimitive[i];
-
- state = gl_prim_state_machine[prim][parity];
- func = tab[flags][reduce_prim[prim]];
- func( cvaVB, VB, state, i, next );
-
- if ( ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE )
- {
- cvaVB->Specular = cvaVB->Spec[0];
- cvaVB->ColorPtr = cvaVB->Color[0];
- cvaVB->IndexPtr = cvaVB->Index[0];
- }
- }
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ));
-
-
-
- if (ctx->PB->count > 0)
- gl_flush_pb(ctx);
-
- ctx->VB = saved_vb;
-}
-
-
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-int gl_fx_dummy_function_cva(void)
-{
- return 0;
-}
-
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxcva.h b/xc/extras/Mesa/src/FX/fxcva.h
deleted file mode 100644
index f809ec010..000000000
--- a/xc/extras/Mesa/src/FX/fxcva.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifndef _FXCVA_H_
-#define _FXCVA_H_
-
-
-
-extern GLboolean fxMergeAndRenderCVA( struct vertex_buffer *VB,
- struct vertex_buffer *cvaVB );
-
-
-
-extern void fxRenderCVAElements( struct vertex_buffer *VB,
- GLenum mode,
- GLuint *elts,
- GLuint n );
-
-
-extern GLboolean fxCheckCVA( GLcontext *ctx );
-
-
-extern void fxPrecalcCVA( struct vertex_buffer *VB );
-
-
-
-#endif
-
diff --git a/xc/extras/Mesa/src/FX/fxcvatmp.h b/xc/extras/Mesa/src/FX/fxcvatmp.h
deleted file mode 100644
index 801dc0edd..000000000
--- a/xc/extras/Mesa/src/FX/fxcvatmp.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-static void TAG(cva_render_points)( struct vertex_buffer *cvaVB,
- struct vertex_buffer *VB,
- const struct gl_prim_state *state,
- GLuint start,
- GLuint count )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
- const GLuint *elt = VB->EltPtr->data;
- GLuint i;
-
- VARS;
- INIT;
- (void) fxMesa;
-
- if (cvaVB->ClipOrMask) {
- const GLubyte *clip = cvaVB->ClipMask;
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = elt[i];
- if (!clip[e]) {
- GLfloat *v = gWin[e].f; (void) v;
- if (!DIRECT) { MERGE_VB; }
- MERGE_RAST;
- DRAW_POINT;
- }
- }
- } else {
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = elt[i];
- GLfloat *v = gWin[e].f; (void) v;
- if (!DIRECT) { MERGE_VB; }
- MERGE_RAST;
- DRAW_POINT;
- }
- }
-}
-
-static void TAG(cva_render_lines)( struct vertex_buffer *cvaVB,
- struct vertex_buffer *VB,
- const struct gl_prim_state *state,
- GLuint start,
- GLuint count )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
- const GLuint *elt = VB->EltPtr->data;
- GLuint i;
-
- VARS;
- INIT;
- (void) fxMesa;
-
- if (cvaVB->ClipOrMask) {
- const GLubyte *clip = cvaVB->ClipMask;
- GLuint prev = 0;
- GLfloat *prev_v = 0;
-
- (void) ctx;
-
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = elt[i];
- GLfloat *v = gWin[e].f;
-
- MERGE_VB;
-
- if (!clip[e])
- MERGE_RAST;
-
- if (state->draw) {
- if (clip[e] | clip[prev])
- CLIP_LINE;
- else
- DRAW_LINE;
- }
-
- prev = e;
- prev_v = v;
- state = state->next;
- }
- if (state->finish_loop) {
- GLuint e = elt[start];
- GLfloat *v = gWin[e].f; (void) v;
-
- if (!DIRECT) { MERGE_VB; }
- MERGE_RAST;
-
- if (clip[e] | clip[prev])
- CLIP_LINE;
- else
- DRAW_LINE;
- }
- } else {
- GLuint prev = 0;
- GLfloat *prev_v = 0;
-
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = elt[i];
- GLfloat *v = gWin[e].f;
-
- if (!DIRECT) { MERGE_VB; }
- MERGE_RAST;
- if (state->draw) DRAW_LINE;
- prev = e;
- prev_v = v;
- state = state->next;
- }
- if (state->finish_loop) {
- GLuint e = elt[start];
- GLfloat *v = gWin[e].f; (void) v;
-
- if (!DIRECT) { MERGE_VB; }
- MERGE_RAST;
- DRAW_LINE;
- }
- }
-}
-
-
-static void TAG(cva_render_tris)( struct vertex_buffer *cvaVB,
- struct vertex_buffer *VB,
- const struct gl_prim_state *state,
- GLuint start,
- GLuint count )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
- const GLuint *elt = VB->EltPtr->data;
- GLuint i;
- VARS;
- INIT;
- (void) fxMesa;
-
- if (cvaVB->ClipOrMask) {
- GLuint vlist[VB_MAX_CLIPPED_VERTS];
- GLuint l[3];
- const GLubyte *clip = cvaVB->ClipMask;
-
- (void) vlist;
-
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = l[2] = elt[i];
- GLfloat *v = gWin[e].f; (void) v;
-
- MERGE_VB; /* needed for clip-interp */
-
- if (!clip[e]) {
- MERGE_RAST;
- }
-
- if (state->draw)
- CLIP_OR_DRAW_TRI;
-
-
- l[0] = l[state->v0];
- l[1] = l[state->v1];
- state = state->next;
- }
- } else if (DIRECT) {
- GrVertex *vl[3];
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = elt[i];
- GLfloat *v = gWin[elt[i]].f;
-
- vl[2] = (GrVertex *)v;
-
- (void) v;
- (void) e;
-
- MERGE_RAST;
-
- if (state->draw)
- DRAW_TRI2;
-
- vl[0] = vl[state->v0];
- vl[1] = vl[state->v1];
- state = state->next;
- }
- } else {
- GLuint l[3];
- for (i = start ; i < count ; i++ INCR) {
- GLuint e = l[2] = elt[i];
- GLfloat *v = gWin[e].f; (void) v;
-
- MERGE_VB; /* needed for ctx->trianglefunc? */
- MERGE_RAST;
-
- if (state->draw)
- DRAW_TRI;
-
- l[0] = l[state->v0];
- l[1] = l[state->v1];
- state = state->next;
- }
- }
-}
-
-
-static void TAG(init_cva)( void )
-{
- merge_and_render_tab[DIRECT][IDX][PRIM_POINTS] = TAG(cva_render_points);
- merge_and_render_tab[DIRECT][IDX][PRIM_LINES] = TAG(cva_render_lines);
- merge_and_render_tab[DIRECT][IDX][PRIM_TRIS] = TAG(cva_render_tris);
- merge_and_render_tab[DIRECT][IDX][PRIM_CULLED] = fxCvaRenderNoop;
-}
-
-
-#undef IDX
-#undef MERGE_RAST
-#undef MERGE_VB
-#undef VARS
-#undef INIT
-#undef INCR
-#undef TAG
-
diff --git a/xc/extras/Mesa/src/FX/fxdd.c b/xc/extras/Mesa/src/FX/fxdd.c
deleted file mode 100644
index a21ed31df..000000000
--- a/xc/extras/Mesa/src/FX/fxdd.c
+++ /dev/null
@@ -1,1491 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxdd.c - 3Dfx VooDoo Mesa device driver functions */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include <dlfcn.h>
-#include "image.h"
-#include "types.h"
-#include "fxdrv.h"
-#include "enums.h"
-#include "extensions.h"
-#include "pb.h"
-
-/* These lookup table are used to extract RGB values in [0,255] from
- * 16-bit pixel values.
- */
-GLubyte FX_PixelToR[0x10000];
-GLubyte FX_PixelToG[0x10000];
-GLubyte FX_PixelToB[0x10000];
-
-
-/*
- * Initialize the FX_PixelTo{RGB} arrays.
- * Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order.
- */
-void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
-{
- GLuint pixel;
-
- fxMesa->bgrOrder=bgrOrder;
- for (pixel = 0; pixel <= 0xffff; pixel++) {
- GLuint r, g, b;
- if (bgrOrder) {
- r = (pixel & 0x001F) << 3;
- g = (pixel & 0x07E0) >> 3;
- b = (pixel & 0xF800) >> 8;
- }
- else {
- r = (pixel & 0xF800) >> 8;
- g = (pixel & 0x07E0) >> 3;
- b = (pixel & 0x001F) << 3;
- }
- r = r * 255 / 0xF8; /* fill in low-order bits */
- g = g * 255 / 0xFC;
- b = b * 255 / 0xF8;
- FX_PixelToR[pixel] = r;
- FX_PixelToG[pixel] = g;
- FX_PixelToB[pixel] = b;
- }
-}
-
-
-/**********************************************************************/
-/***** Miscellaneous functions *****/
-/**********************************************************************/
-
-
-/* Return buffer size information */
-static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDBufferSize(...) Start\n");
- }
-
- *width = fxMesa->width;
- *height = fxMesa->height;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDBufferSize(...) End\n");
- }
-}
-
-
-/* Set current drawing color */
-static void fxDDSetColor(GLcontext *ctx, GLubyte red, GLubyte green,
- GLubyte blue, GLubyte alpha )
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLubyte col[4];
- ASSIGN_4V( col, red, green, blue, alpha );
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDSetColor(%d,%d,%d,%d)\n",red,green,blue,alpha);
- }
- fxMesa->color = FXCOLOR4(col);
-}
-
-
-/* Implements glClearColor() */
-static void fxDDClearColor(GLcontext *ctx, GLubyte red, GLubyte green,
- GLubyte blue, GLubyte alpha )
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLubyte col[4];
- ASSIGN_4V( col, red, green, blue, 255 );
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",red,green,blue,alpha);
- }
- fxMesa->clearC = FXCOLOR4( col );
- fxMesa->clearA = alpha;
-}
-
-
-/* Clear the color and/or depth buffers */
-static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- const FxU32 clearD = (FxU32) (ctx->Depth.Clear * fxMesa->depthClear);
- const FxU32 clearS = (FxU32) (ctx->Stencil.Clear);
- GLbitfield softwareMask = mask & (DD_ACCUM_BIT);
-
- /* we can't clear accum buffers */
- mask &= ~(DD_ACCUM_BIT);
-
- if ((mask & DD_STENCIL_BIT) && !fxMesa->haveHwStencil) {
- /* software stencil buffer */
- mask &= ~(DD_STENCIL_BIT);
- softwareMask |= DD_STENCIL_BIT;
- }
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y,
- (int) width, (int) height);
- }
-
- if (colorMask != 0xffffffff) {
- /* do masked color buffer clears in software */
- softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
- mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
- }
-
-
- /* disable stencil ops if enabled (it screws up clearing) */
- if (fxMesa->haveHwStencil) {
- if (ctx->Stencil.Enabled)
- FX_grDisable(GR_STENCIL_MODE_EXT);
-
- if (mask & DD_STENCIL_BIT) {
- FX_grStencilMask(0xff);
- /* set stencil ref value = desired clear value */
- FX_grStencilFunc(GR_CMP_ALWAYS, ctx->Stencil.Clear, 0xff);
- }
- else {
- FX_grStencilMask(0x00);
- }
- }
-
- /*
- * This could probably be done fancier but doing each possible case
- * explicitly is less error prone.
- */
- switch (mask & ~DD_STENCIL_BIT) {
- case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
- /* back buffer & depth */
- FX_grDepthMask(FXTRUE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- if (!ctx->Depth.Mask) {
- FX_grDepthMask(FXFALSE);
- }
- break;
- case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT:
- /* XXX it appears that the depth buffer isn't cleared when
- * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
- * This is a work-around/
- */
- /* clear depth */
- FX_grDepthMask(FXTRUE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grColorMask(FXFALSE,FXFALSE);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- /* clear front */
- FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- break;
- case DD_BACK_LEFT_BIT:
- /* back buffer only */
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- if (ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
- }
- break;
- case DD_FRONT_LEFT_BIT:
- /* front buffer only */
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- if (ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
- }
- break;
- case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
- /* front and back */
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- if (ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
- }
- break;
- case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
- /* clear front */
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- /* clear back and depth */
- FX_grDepthMask(FXTRUE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- if (!ctx->Depth.Mask) {
- FX_grDepthMask(FXFALSE);
- }
- break;
- case DD_DEPTH_BIT:
- /* just the depth buffer */
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grColorMask(FXFALSE,FXFALSE);
- FX_grDepthMask(FXTRUE);
- if (mask & DD_STENCIL_BIT)
- FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS);
- else
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD);
- FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
- if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT)
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- break;
- default:
- /* error */
- ;
- }
-
- if (fxMesa->haveHwStencil && ctx->Stencil.Enabled) {
- /* restore stencil state to as it was before the clear */
- FX_grEnable(GR_STENCIL_MODE_EXT);
- FX_grStencilMask(ctx->Stencil.WriteMask);
- FX_grStencilFunc(ctx->Stencil.Function - GL_NEVER,
- ctx->Stencil.Ref, ctx->Stencil.ValueMask);
- }
-
- return softwareMask;
-}
-
-
-/* Set the buffer used for drawing */
-/* XXX support for separate read/draw buffers hasn't been tested */
-static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
- }
-
- if (mode == GL_FRONT_LEFT) {
- fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- return GL_TRUE;
- }
- else if (mode == GL_BACK_LEFT) {
- fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- return GL_TRUE;
- }
- else if (mode == GL_NONE) {
- FX_grColorMask(FXFALSE,FXFALSE);
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-/* Set the buffer used for reading */
-/* XXX support for separate read/draw buffers hasn't been tested */
-static void fxDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
- GLenum mode )
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- (void) buffer;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
- }
-
- if (mode == GL_FRONT_LEFT) {
- fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- }
- else if (mode == GL_BACK_LEFT) {
- fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
- FX_grRenderBuffer(fxMesa->currentFB);
- }
-}
-
-
-/*
- * These functions just set new-state flags. The exact state
- * values will be evaluated later.
- */
-static void
-fxDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- (void) func; (void) ref; (void) mask;
- fxMesa->new_state |= FX_NEW_STENCIL;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-static void
-fxDDStencilMask(GLcontext *ctx, GLuint mask)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- (void) mask;
- fxMesa->new_state |= FX_NEW_STENCIL;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-static void
-fxDDStencilOp(GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- (void) sfail; (void) zfail; (void) zpass;
- fxMesa->new_state |= FX_NEW_STENCIL;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-static void
-fxDDDepthFunc(GLcontext *ctx, GLenum func)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- (void) func;
- fxMesa->new_state |= FX_NEW_DEPTH;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-static void
-fxDDDepthMask(GLcontext *ctx, GLboolean mask)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- (void) mask;
- fxMesa->new_state |= FX_NEW_DEPTH;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-
-
-
-#ifdef XF86DRI
-/* test if window coord (px,py) is visible */
-static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py)
-{
- int i;
- for (i=0; i<fxMesa->numClipRects; i++) {
- if ((px>=fxMesa->pClipRects[i].x1) &&
- (px<fxMesa->pClipRects[i].x2) &&
- (py>=fxMesa->pClipRects[i].y1) &&
- (py<fxMesa->pClipRects[i].y2)) return GL_TRUE;
- }
- return GL_FALSE;
-}
-#endif
-
-
-
-static GLboolean
-bitmap_R5G6B5(GLcontext *ctx, GLint px, GLint py,
- GLsizei width, GLsizei height,
- const struct gl_pixelstore_attrib *unpack,
- const GLubyte *bitmap)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrLfbInfo_t info;
- FxU16 color;
- const struct gl_pixelstore_attrib *finalUnpack;
- struct gl_pixelstore_attrib scissoredUnpack;
-
- /* check if there's any raster operations enabled which we can't handle */
- if (ctx->RasterMask & (ALPHATEST_BIT |
- BLEND_BIT |
- DEPTH_BIT |
- FOG_BIT |
- LOGIC_OP_BIT |
- SCISSOR_BIT |
- STENCIL_BIT |
- MASKING_BIT |
- ALPHABUF_BIT |
- MULTI_DRAW_BIT))
- return GL_FALSE;
-
- if (ctx->Scissor.Enabled) {
- /* This is a bit tricky, but by carefully adjusting the px, py,
- * width, height, skipPixels and skipRows values we can do
- * scissoring without special code in the rendering loop.
- */
-
- /* we'll construct a new pixelstore struct */
- finalUnpack = &scissoredUnpack;
- scissoredUnpack = *unpack;
- if (scissoredUnpack.RowLength == 0)
- scissoredUnpack.RowLength = width;
-
- /* clip left */
- if (px < ctx->Scissor.X) {
- scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
- width -= (ctx->Scissor.X - px);
- px = ctx->Scissor.X;
- }
- /* clip right */
- if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
- width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
- }
- /* clip bottom */
- if (py < ctx->Scissor.Y) {
- scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
- height -= (ctx->Scissor.Y - py);
- py = ctx->Scissor.Y;
- }
- /* clip top */
- if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
- height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
- }
-
- if (width <= 0 || height <= 0)
- return GL_TRUE; /* totally scissored away */
- }
- else {
- finalUnpack = unpack;
- }
-
- /* compute pixel value */
- {
- GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
- GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
- GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
- /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f);*/
- if (fxMesa->bgrOrder)
- color = (FxU16)
- ( ((FxU16)0xf8 & b) << (11-3)) |
- ( ((FxU16)0xfc & g) << (5-3+1)) |
- ( ((FxU16)0xf8 & r) >> 3);
- else
- color = (FxU16)
- ( ((FxU16)0xf8 & r) << (11-3)) |
- ( ((FxU16)0xfc & g) << (5-3+1)) |
- ( ((FxU16)0xf8 & b) >> 3);
- }
-
- info.size = sizeof(info);
- if (!FX_grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- GR_LFBWRITEMODE_565,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
-#ifndef FX_SILENT
- fprintf(stderr,"fx Driver: error locking the linear frame buffer\n");
-#endif
- return GL_TRUE;
- }
-
-#ifdef XF86DRI
-#define INSIDE(c, x, y) inClipRects((c), (x), (y))
-#else
-#define INSIDE(c, x, y) (1)
-#endif
-
- {
- const GLint winX = fxMesa->x_offset;
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- /* The dest stride depends on the hardware and whether we're drawing
- * to the front or back buffer. This compile-time test seems to do
- * the job for now.
- */
-#ifdef XF86DRI
- const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- ? (fxMesa->screen_width) : (info.strideInBytes / 2);
-#else
- const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
-#endif
- GLint row;
- /* compute dest address of bottom-left pixel in bitmap */
- GLushort *dst = (GLushort *) info.lfbPtr
- + (winY - py) * dstStride
- + (winX + px);
-
- for (row = 0; row < height; row++) {
- const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack,
- bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
- if (finalUnpack->LsbFirst) {
- /* least significan bit first */
- GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
- GLint col;
- for (col=0; col<width; col++) {
- if (*src & mask) {
- if (INSIDE(fxMesa, winX + px + col, winY - py - row))
- dst[col] = color;
- }
- if (mask == 128U) {
- src++;
- mask = 1U;
- }
- else {
- mask = mask << 1;
- }
- }
- if (mask != 1)
- src++;
- }
- else {
- /* most significan bit first */
- GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
- GLint col;
- for (col=0; col<width; col++) {
- if (*src & mask) {
- if (INSIDE(fxMesa, winX + px + col, winY - py - row))
- dst[col] = color;
- }
- if (mask == 1U) {
- src++;
- mask = 128U;
- }
- else {
- mask = mask >> 1;
- }
- }
- if (mask != 128)
- src++;
- }
- dst -= dstStride;
- }
- }
-
-#undef INSIDE
-
- FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
- return GL_TRUE;
-}
-
-
-static GLboolean
-bitmap_R8G8B8A8(GLcontext *ctx, GLint px, GLint py,
- GLsizei width, GLsizei height,
- const struct gl_pixelstore_attrib *unpack,
- const GLubyte *bitmap)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrLfbInfo_t info;
- GrLfbWriteMode_t mode;
- /*FxU16 color;*/
- GLuint color;
- const struct gl_pixelstore_attrib *finalUnpack;
- struct gl_pixelstore_attrib scissoredUnpack;
-
- /* check if there's any raster operations enabled which we can't handle */
- if (ctx->RasterMask & (ALPHATEST_BIT |
- BLEND_BIT |
- DEPTH_BIT |
- FOG_BIT |
- LOGIC_OP_BIT |
- SCISSOR_BIT |
- STENCIL_BIT |
- MASKING_BIT |
- ALPHABUF_BIT |
- MULTI_DRAW_BIT))
- return GL_FALSE;
-
- if (ctx->Scissor.Enabled) {
- /* This is a bit tricky, but by carefully adjusting the px, py,
- * width, height, skipPixels and skipRows values we can do
- * scissoring without special code in the rendering loop.
- */
-
- /* we'll construct a new pixelstore struct */
- finalUnpack = &scissoredUnpack;
- scissoredUnpack = *unpack;
- if (scissoredUnpack.RowLength == 0)
- scissoredUnpack.RowLength = width;
-
- /* clip left */
- if (px < ctx->Scissor.X) {
- scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
- width -= (ctx->Scissor.X - px);
- px = ctx->Scissor.X;
- }
- /* clip right */
- if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
- width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
- }
- /* clip bottom */
- if (py < ctx->Scissor.Y) {
- scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
- height -= (ctx->Scissor.Y - py);
- py = ctx->Scissor.Y;
- }
- /* clip top */
- if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
- height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
- }
-
- if (width <= 0 || height <= 0)
- return GL_TRUE; /* totally scissored away */
- }
- else {
- finalUnpack = unpack;
- }
-
- /* compute pixel value */
- {
- GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
- GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
- GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
- GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0f);
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- color = PACK_BGRA32(r, g, b, a);
- else
- color = PACK_RGBA32(r, g, b, a);
- }
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_8888;
- else
- mode = GR_LFBWRITEMODE_888;
-
- info.size = sizeof(info);
- if (!FX_grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
-#ifndef FX_SILENT
- fprintf(stderr,"fx Driver: error locking the linear frame buffer\n");
-#endif
- return GL_TRUE;
- }
-
-#ifdef XF86DRI
-#define INSIDE(c, x, y) inClipRects((c), (x), (y))
-#else
-#define INSIDE(c, x, y) (1)
-#endif
-
- {
- const GLint winX = fxMesa->x_offset;
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- GLint dstStride;
- GLuint *dst;
- GLint row;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- dstStride = fxMesa->screen_width;
- dst = (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + px);
- }
- else {
- dstStride = info.strideInBytes / 4;
- dst = (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + px);
- }
-
- /* compute dest address of bottom-left pixel in bitmap */
- for (row = 0; row < height; row++) {
- const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack,
- bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
- if (finalUnpack->LsbFirst) {
- /* least significan bit first */
- GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
- GLint col;
- for (col=0; col<width; col++) {
- if (*src & mask) {
- if (INSIDE(fxMesa, winX + px + col, winY - py - row))
- dst[col] = color;
- }
- if (mask == 128U) {
- src++;
- mask = 1U;
- }
- else {
- mask = mask << 1;
- }
- }
- if (mask != 1)
- src++;
- }
- else {
- /* most significan bit first */
- GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
- GLint col;
- for (col=0; col<width; col++) {
- if (*src & mask) {
- if (INSIDE(fxMesa, winX + px + col, winY - py - row))
- dst[col] = color;
- }
- if (mask == 1U) {
- src++;
- mask = 128U;
- }
- else {
- mask = mask >> 1;
- }
- }
- if (mask != 128)
- src++;
- }
- dst -= dstStride;
- }
- }
-
-#undef INSIDE
-
- FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB);
- return GL_TRUE;
-}
-
-
-static GLboolean
-readpixels_R5G6B5( GLcontext *ctx, GLint x, GLint y,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *packing,
- GLvoid *dstImage )
-{
- if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
- return GL_FALSE; /* can't do this */
- }
- else {
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GrLfbInfo_t info;
- GLboolean result = GL_FALSE;
-
- BEGIN_BOARD_LOCK();
- info.size=sizeof(info);
- if (grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->currentFB,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winX = fxMesa->x_offset;
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
-#ifdef XF86DRI
- const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- ? (fxMesa->screen_width) : (info.strideInBytes / 2);
-#else
- const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
-#endif
- const GLushort *src = (const GLushort *) info.lfbPtr
- + (winY - y) * srcStride + (winX + x);
- GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
- width, height, format, type, 0, 0, 0);
- GLint dstStride = _mesa_image_row_stride(packing, width, format, type);
-
- if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
- /* convert 5R6G5B into 8R8G8B */
- GLint row, col;
- const GLint halfWidth = width >> 1;
- const GLint extraPixel = (width & 1);
- for (row = 0; row < height; row++) {
- GLubyte *d = dst;
- for (col = 0; col < halfWidth; col++) {
- const GLuint pixel = ((const GLuint *) src)[col];
- const GLint pixel0 = pixel & 0xffff;
- const GLint pixel1 = pixel >> 16;
- *d++ = FX_PixelToR[pixel0];
- *d++ = FX_PixelToG[pixel0];
- *d++ = FX_PixelToB[pixel0];
- *d++ = FX_PixelToR[pixel1];
- *d++ = FX_PixelToG[pixel1];
- *d++ = FX_PixelToB[pixel1];
- }
- if (extraPixel) {
- GLushort pixel = src[width-1];
- *d++ = FX_PixelToR[pixel];
- *d++ = FX_PixelToG[pixel];
- *d++ = FX_PixelToB[pixel];
- }
- dst += dstStride;
- src -= srcStride;
- }
- result = GL_TRUE;
- }
- else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
- /* convert 5R6G5B into 8R8G8B8A */
- GLint row, col;
- const GLint halfWidth = width >> 1;
- const GLint extraPixel = (width & 1);
- for (row = 0; row < height; row++) {
- GLubyte *d = dst;
- for (col = 0; col < halfWidth; col++) {
- const GLuint pixel = ((const GLuint *) src)[col];
- const GLint pixel0 = pixel & 0xffff;
- const GLint pixel1 = pixel >> 16;
- *d++ = FX_PixelToR[pixel0];
- *d++ = FX_PixelToG[pixel0];
- *d++ = FX_PixelToB[pixel0];
- *d++ = 255;
- *d++ = FX_PixelToR[pixel1];
- *d++ = FX_PixelToG[pixel1];
- *d++ = FX_PixelToB[pixel1];
- *d++ = 255;
- }
- if (extraPixel) {
- const GLushort pixel = src[width-1];
- *d++ = FX_PixelToR[pixel];
- *d++ = FX_PixelToG[pixel];
- *d++ = FX_PixelToB[pixel];
- *d++ = 255;
- }
- dst += dstStride;
- src -= srcStride;
- }
- result = GL_TRUE;
- }
- else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
- /* directly memcpy 5R6G5B pixels into client's buffer */
- const GLint widthInBytes = width * 2;
- GLint row;
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, widthInBytes);
- dst += dstStride;
- src -= srcStride;
- }
- result = GL_TRUE;
- }
- else {
- result = GL_FALSE;
- }
-
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
- return result;
- }
-}
-
-
-
-static void fxDDFinish(GLcontext *ctx)
-{
- FX_grFlush();
-}
-
-
-static GLint fxDDGetParameteri(const GLcontext *ctx, GLint param)
-{
- switch(param) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- fprintf(stderr,"fx Driver: internal error in fxDDGetParameteri(): %x\n", (int) param);
- fxCloseHardware();
- exit(-1);
- return 0;
- }
-}
-
-
-void fxDDSetNearFar(GLcontext *ctx, GLfloat n, GLfloat f)
-{
- FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-/* KW: Put the word Mesa in the render string because quakeworld
- * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
- * Why?
- */
-static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
-{
-#if defined(GLX_DIRECT_RENDERING)
- /* Building for DRI driver */
- switch (name) {
- case GL_RENDERER:
- {
- static char buffer[100];
- char hardware[100];
- strcpy(hardware, grGetString(GR_HARDWARE));
- if (strcmp(hardware, "Voodoo3 (tm)") == 0)
- strcpy(hardware, "Voodoo3");
- else if (strcmp(hardware, "Voodoo Banshee (tm)") == 0)
- strcpy(hardware, "VoodooBanshee");
- else {
- /* unexpected result: replace spaces with hyphens */
- int i;
- for (i = 0; hardware[i]; i++) {
- if (hardware[i] == ' ' || hardware[i] == '\t')
- hardware[i] = '-';
- }
- }
- /* now make the GL_RENDERER string */
- sprintf(buffer, "Mesa DRI %s 20000616", hardware);
- return buffer;
- }
- case GL_VENDOR:
- return "Precision Insight, Inc.";
- default:
- return NULL;
- }
-
-#else
-
- /* Building for Voodoo1/2 stand-alone Mesa */
- switch (name) {
- case GL_RENDERER:
- {
- static char buf[80];
-
- if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
- GrVoodooConfig_t *vc =
- &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
-
- sprintf(buf,
- "Mesa Glide v0.30 Voodoo_Graphics %d "
- "CARD/%d FB/%d TM/%d TMU/%s",
- glbCurrentBoard,
- (vc->sliDetect ? (vc->fbRam*2) : vc->fbRam),
- (vc->tmuConfig[GR_TMU0].tmuRam +
- ((vc->nTexelfx>1) ? vc->tmuConfig[GR_TMU1].tmuRam : 0)),
- vc->nTexelfx,
- (vc->sliDetect ? "SLI" : "NOSLI"));
- }
- else if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) {
- GrSst96Config_t *sc =
- &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config;
-
- sprintf(buf,
- "Glide v0.30 Voodoo_Rush %d "
- "CARD/%d FB/%d TM/%d TMU/NOSLI",
- glbCurrentBoard,
- sc->fbRam,
- sc->tmuConfig.tmuRam,
- sc->nTexelfx);
- }
- else {
- strcpy(buf, "Glide v0.30 UNKNOWN");
- }
- return (GLubyte *) buf;
- }
- default:
- return NULL;
- }
-#endif
-}
-
-
-int fxDDInitFxMesaContext( fxMesaContext fxMesa )
-{
- /* Get Glide3vn function pointers */
- {
- void *handle;
- handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
- if (!handle)
- return 0;
- grStencilFuncPtr = dlsym(handle, "grStencilFunc");
- grStencilMaskPtr = dlsym(handle, "grStencilMask");
- grStencilOpPtr = dlsym(handle, "grStencilOp");
- grBufferClearExtPtr = dlsym(handle, "grBufferClearExt");
- /* call dlclose()? */
- }
-
-
- FX_setupGrVertexLayout();
-
- if (getenv("FX_EMULATE_SINGLE_TMU"))
- fxMesa->haveTwoTMUs = GL_FALSE;
-
- fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs;
-
- if (!getenv("FX_DONT_FAKE_MULTITEX"))
- fxMesa->emulateTwoTMUs = GL_TRUE;
-
- if(getenv("FX_GLIDE_SWAPINTERVAL"))
- fxMesa->swapInterval=atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
- else
- fxMesa->swapInterval=1;
-
- if(getenv("MESA_FX_SWAP_PENDING"))
- fxMesa->maxPendingSwapBuffers=atoi(getenv("MESA_FX_SWAP_PENDING"));
- else
- fxMesa->maxPendingSwapBuffers=2;
-
- if(getenv("MESA_FX_INFO"))
- fxMesa->verbose=GL_TRUE;
- else
- fxMesa->verbose=GL_FALSE;
-
- fxMesa->depthClear = FX_grGetInteger(FX_ZDEPTH_MAX);
-
- fxMesa->color=0xffffffff;
- fxMesa->clearC=0;
- fxMesa->clearA=0;
-
- fxMesa->stats.swapBuffer=0;
- fxMesa->stats.reqTexUpload=0;
- fxMesa->stats.texUpload=0;
- fxMesa->stats.memTexUpload=0;
-
- fxMesa->tmuSrc=FX_TMU_NONE;
- fxTMInit(fxMesa);
-
- /* FX units setup */
-
- fxMesa->unitsState.alphaTestEnabled=GL_FALSE;
- fxMesa->unitsState.alphaTestFunc=GR_CMP_ALWAYS;
- fxMesa->unitsState.alphaTestRefValue=0;
-
- fxMesa->unitsState.blendEnabled=GL_FALSE;
- fxMesa->unitsState.blendSrcFuncRGB=GR_BLEND_ONE;
- fxMesa->unitsState.blendDstFuncRGB=GR_BLEND_ZERO;
- fxMesa->unitsState.blendSrcFuncAlpha=GR_BLEND_ONE;
- fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO;
-
- /*
- fxMesa->unitsState.depthTestEnabled =GL_FALSE;
- fxMesa->unitsState.depthMask =GL_TRUE;
- fxMesa->unitsState.depthTestFunc =GR_CMP_LESS;
- */
-
- FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
- if (fxMesa->glVis->DBflag) {
- fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- }
- else {
- fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- }
-
- fxMesa->state = NULL;
- fxMesa->fogTable = NULL;
-
- fxMesa->state = malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
- fxMesa->fogTable = malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES)*sizeof(GrFog_t));
-
- if (!fxMesa->state || !fxMesa->fogTable) {
- if (fxMesa->state) free(fxMesa->state);
- if (fxMesa->fogTable) free(fxMesa->fogTable);
- return 0;
- }
-
- if (fxMesa->glVis->DepthBits > 0)
- FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
-
-#if (!FXMESA_USE_ARGB)
- FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */
-#endif
-
- fxMesa->textureAlign=FX_grGetInteger(FX_TEXTURE_ALIGN);
- fxMesa->glCtx->Const.MaxTextureLevels=9;
- fxMesa->glCtx->Const.MaxTextureSize=256;
- fxMesa->glCtx->Const.MaxTextureUnits=fxMesa->emulateTwoTMUs ? 2 : 1;
- fxMesa->glCtx->NewState|=NEW_DRVSTATE1;
- fxMesa->new_state = NEW_ALL;
-
- fxDDSetupInit();
- fxDDCvaInit();
- fxDDClipInit();
- fxDDTrifuncInit();
- fxDDFastPathInit();
-
- fxSetupDDPointers(fxMesa->glCtx);
- fxDDRenderInit(fxMesa->glCtx);
- fxDDInitExtensions(fxMesa->glCtx);
-
- fxDDSetNearFar(fxMesa->glCtx,1.0,100.0);
-
- FX_grGlideGetState((GrState*)fxMesa->state);
-
- /* XXX Fix me: callback not registered when main VB is created.
- */
- if (fxMesa->glCtx->VB)
- fxDDRegisterVB( fxMesa->glCtx->VB );
-
- /* XXX Fix me too: need to have the 'struct dd' prepared prior to
- * creating the context... The below is broken if you try to insert
- * new stages.
- */
- if (fxMesa->glCtx->NrPipelineStages)
- fxMesa->glCtx->NrPipelineStages = fxDDRegisterPipelineStages(
- fxMesa->glCtx->PipelineStage,
- fxMesa->glCtx->PipelineStage,
- fxMesa->glCtx->NrPipelineStages);
-
- /* this little bit ensures that all Glide state gets initialized */
- fxMesa->new_state = NEW_ALL;
- fxMesa->glCtx->Driver.RenderStart = fxSetupFXUnits;
-
- /* Run the config file */
- gl_context_initialize( fxMesa->glCtx );
-
- return 1;
-}
-
-
-#if 0
-/* Example extension function */
-static void fxFooBarEXT(GLint i)
-{
- printf("You called glFooBarEXT(%d)\n", i);
-}
-#endif
-
-
-void fxDDInitExtensions( GLcontext *ctx )
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
-
- gl_extensions_disable(ctx, "GL_EXT_blend_logic_op");
- gl_extensions_disable(ctx, "GL_EXT_blend_minmax");
- gl_extensions_disable(ctx, "GL_EXT_blend_subtract");
- gl_extensions_disable(ctx, "GL_EXT_blend_color");
-
- gl_extensions_add(ctx, DEFAULT_ON, "3DFX_set_global_palette", 0);
-
- if (!fxMesa->haveTwoTMUs)
- gl_extensions_disable(ctx, "GL_EXT_texture_env_add");
-
- if (!fxMesa->emulateTwoTMUs)
- gl_extensions_disable(ctx, "GL_ARB_multitexture");
-
-
- /* Example of hooking in an extension function.
- * For DRI-based drivers, also see __driRegisterExtensions in the
- * tdfx_xmesa.c file.
- */
-#if 0
- {
- void **dispatchTable = (void **) ctx->Exec;
- const int _gloffset_FooBarEXT = 555; /* just an example number! */
- const int tabSize = _glapi_get_dispatch_table_size();
- assert(_gloffset_FooBarEXT < tabSize);
- dispatchTable[_gloffset_FooBarEXT] = (void *) fxFooBarEXT;
- /* XXX You would also need to hook into the display list dispatch
- * table. Really, the implementation of extensions might as well
- * be in the core of Mesa since core Mesa and the device driver
- * is one big shared lib.
- */
- }
-#endif
-}
-
-
-/************************************************************************/
-/************************************************************************/
-/************************************************************************/
-
-/* Check if the hardware supports the current context
- *
- * Performs similar work to fxDDChooseRenderState() - should be merged.
- */
-static GLboolean fxIsInHardware(GLcontext *ctx)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
-
- if (!ctx->Hint.AllowDrawMem)
- return GL_TRUE; /* you'll take it and like it */
-
- if(((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) ||
- ((ctx->Color.ColorLogicOpEnabled) && (ctx->Color.LogicOp!=GL_COPY)) ||
- (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) ||
- (!((ctx->Color.ColorMask[RCOMP]==ctx->Color.ColorMask[GCOMP]) &&
- (ctx->Color.ColorMask[GCOMP]==ctx->Color.ColorMask[BCOMP]) &&
- (ctx->Color.ColorMask[ACOMP]==ctx->Color.ColorMask[ACOMP])))
- )
- {
- return GL_FALSE;
- }
- /* Unsupported texture/multitexture cases */
-
- if(fxMesa->emulateTwoTMUs) {
- if((ctx->Enabled & (TEXTURE0_3D | TEXTURE1_3D)) ||
- /* Not very well written ... */
- ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) &&
- ((ctx->Enabled & (TEXTURE0_2D | TEXTURE1_2D))!=(TEXTURE0_2D | TEXTURE1_2D)))
- ) {
- return GL_FALSE;
- }
-
- if (ctx->Texture.ReallyEnabled & TEXTURE0_2D) {
- if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
- (ctx->Texture.ReallyEnabled & TEXTURE1_2D ||
- ctx->Texture.Unit[0].EnvColor[0] != 0 ||
- ctx->Texture.Unit[0].EnvColor[1] != 0 ||
- ctx->Texture.Unit[0].EnvColor[2] != 0 ||
- ctx->Texture.Unit[0].EnvColor[3] != 1)) {
- return GL_FALSE;
- }
- if (ctx->Texture.Unit[0].Current->Image[0]->Border > 0)
- return GL_FALSE;
- }
-
- if (ctx->Texture.ReallyEnabled & TEXTURE1_2D) {
- if (ctx->Texture.Unit[1].EnvMode == GL_BLEND)
- return GL_FALSE;
- if (ctx->Texture.Unit[0].Current->Image[0]->Border > 0)
- return GL_FALSE;
- }
-
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
- fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n",
- gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
- gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
-
- /* KW: This was wrong (I think) and I changed it... which doesn't mean
- * it is now correct...
- */
- if((ctx->Enabled & (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D)) &&
- (ctx->Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)))
- {
- /* Can't use multipass to blend a multitextured triangle - fall
- * back to software.
- */
- if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
- return GL_FALSE;
- }
-
- if ((ctx->Texture.Unit[0].EnvMode!=ctx->Texture.Unit[1].EnvMode) &&
- (ctx->Texture.Unit[0].EnvMode!=GL_MODULATE) &&
- (ctx->Texture.Unit[0].EnvMode!=GL_REPLACE)) /* q2, seems ok... */
- {
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr, "fxMesa: unsupported multitex env mode\n");
- return GL_FALSE;
- }
- }
- } else {
- if((ctx->Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) ||
- /* Not very well written ... */
- ((ctx->Enabled & TEXTURE0_1D) &&
- (!(ctx->Enabled & TEXTURE0_2D)))
- ) {
- return GL_FALSE;
- }
-
-
- if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) &&
- (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) {
- return GL_FALSE;
- }
- }
-
- if (ctx->Stencil.Enabled && !fxMesa->haveHwStencil)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-
-
-#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|NEW_PROJECTION|NEW_TEXTURE_MATRIX|NEW_USER_CLIP|NEW_CLIENT_STATE|NEW_TEXTURE_ENABLE))
-
-static void fxDDUpdateDDPointers(GLcontext *ctx)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint new_state = ctx->NewState;
-
- if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_STATE))
- fprintf(stderr,"fxmesa: fxDDUpdateDDPointers(...)\n");
-
- if (new_state & (NEW_RASTER_OPS|NEW_TEXTURING))
- fxMesa->is_in_hardware = fxIsInHardware(ctx);
-
- if (fxMesa->is_in_hardware) {
- if (fxMesa->new_state)
- fxSetupFXUnits(ctx);
-
- if(new_state & INTERESTED) {
- fxDDChooseRenderState( ctx );
- fxMesa->RenderVBTables=fxDDChooseRenderVBTables(ctx);
- fxMesa->RenderVBClippedTab=fxMesa->RenderVBTables[0];
- fxMesa->RenderVBCulledTab=fxMesa->RenderVBTables[1];
- fxMesa->RenderVBRawTab=fxMesa->RenderVBTables[2];
-
- ctx->Driver.RasterSetup=fxDDChooseSetupFunction(ctx);
- }
-
- ctx->Driver.PointsFunc=fxMesa->PointsFunc;
- ctx->Driver.LineFunc=fxMesa->LineFunc;
- ctx->Driver.TriangleFunc=fxMesa->TriangleFunc;
- ctx->Driver.QuadFunc=fxMesa->QuadFunc;
- } else {
- fxMesa->render_index = FX_FALLBACK;
- }
-}
-
-static void fxDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
-{
- if (ctx->Polygon.CullFlag) {
- if (ctx->PB->primitive != GL_POLYGON) { /* Lines or Points */
- FX_grCullMode(GR_CULL_DISABLE);
- FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE;
- }
- }
-}
-
-
-void fxSetupDDPointers(GLcontext *ctx)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxSetupDDPointers()\n");
- }
- ctx->Driver.UpdateState = fxDDUpdateDDPointers;
- ctx->Driver.ClearIndex = NULL;
- ctx->Driver.ClearColor = fxDDClearColor;
- ctx->Driver.Clear = fxDDClear;
- ctx->Driver.Index = NULL;
- ctx->Driver.Color = fxDDSetColor;
- ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer = fxDDSetReadBuffer;
- ctx->Driver.GetBufferSize = fxDDBufferSize;
- ctx->Driver.Finish = fxDDFinish;
- ctx->Driver.Flush = NULL;
- ctx->Driver.GetString = fxDDGetString;
- ctx->Driver.NearFar = fxDDSetNearFar;
- ctx->Driver.GetParameteri = fxDDGetParameteri;
-
- ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan;
- ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels;
- ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan;
- ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels;
-
- if (ctx->Visual->RedBits == 8 &&
- ctx->Visual->GreenBits == 8 &&
- ctx->Visual->BlueBits == 8 &&
- ctx->Visual->AlphaBits == 8) {
- ctx->Driver.Bitmap = bitmap_R8G8B8A8;
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.ReadPixels = NULL;
- }
- else {
- ctx->Driver.Bitmap = bitmap_R5G6B5;
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.ReadPixels = readpixels_R5G6B5;
- }
-
- ctx->Driver.RenderStart=NULL;
- ctx->Driver.RenderFinish=NULL;
-
- ctx->Driver.TexImage2D = fxDDTexImage2D;
- ctx->Driver.TexSubImage2D = fxDDTexSubImage2D;
- ctx->Driver.GetTexImage = fxDDGetTexImage;
- ctx->Driver.TexEnv=fxDDTexEnv;
- ctx->Driver.TexParameter=fxDDTexParam;
- ctx->Driver.BindTexture=fxDDTexBind;
- ctx->Driver.DeleteTexture=fxDDTexDel;
- ctx->Driver.UpdateTexturePalette=fxDDTexPalette;
-
- ctx->Driver.RectFunc=NULL;
-
- if (fxMesa->haveHwStencil) {
- ctx->Driver.StencilFunc = fxDDStencilFunc;
- ctx->Driver.StencilMask = fxDDStencilMask;
- ctx->Driver.StencilOp = fxDDStencilOp;
- }
-
- ctx->Driver.AlphaFunc=fxDDAlphaFunc;
- ctx->Driver.BlendFunc=fxDDBlendFunc;
- ctx->Driver.DepthFunc=fxDDDepthFunc;
- ctx->Driver.DepthMask=fxDDDepthMask;
- ctx->Driver.ColorMask=fxDDColorMask;
- ctx->Driver.Fogfv=fxDDFogfv;
- ctx->Driver.Scissor=fxDDScissor;
- ctx->Driver.FrontFace=fxDDFrontFace;
- ctx->Driver.CullFace=fxDDCullFace;
- ctx->Driver.ShadeModel=fxDDShadeModel;
- ctx->Driver.Enable=fxDDEnable;
- ctx->Driver.ReducedPrimitiveChange=fxDDReducedPrimitiveChange;
-
- ctx->Driver.RegisterVB=fxDDRegisterVB;
- ctx->Driver.UnregisterVB=fxDDUnregisterVB;
-
- ctx->Driver.RegisterPipelineStages = fxDDRegisterPipelineStages;
-
- ctx->Driver.OptimizeImmediatePipeline = 0; /* nothing done yet */
- ctx->Driver.OptimizePrecalcPipeline = 0;
-
-/* if (getenv("MESA_USE_FAST") || getenv("FX_USE_FAST")) */
-/* ctx->Driver.OptimizePrecalcPipeline = fxDDOptimizePrecalcPipeline; */
-
- if (!getenv("FX_NO_FAST"))
- ctx->Driver.BuildPrecalcPipeline = fxDDBuildPrecalcPipeline;
-
- ctx->Driver.TriangleCaps = DD_TRI_CULL|DD_TRI_OFFSET|DD_TRI_LIGHT_TWOSIDE;
-
- fxSetupDDSpanPointers(ctx);
-
- FX_CONTEXT(ctx)->render_index = 1; /* force an update */
- fxDDUpdateDDPointers(ctx);
-}
-
-
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-int gl_fx_dummy_function_dd(void)
-{
- return 0;
-}
-
-#endif /* FX */
-
diff --git a/xc/extras/Mesa/src/FX/fxddspan.c b/xc/extras/Mesa/src/FX/fxddspan.c
deleted file mode 100644
index 1a273785a..000000000
--- a/xc/extras/Mesa/src/FX/fxddspan.c
+++ /dev/null
@@ -1,1825 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
-
-
-#include "fxdrv.h"
-
-
-
-/*
- * Examine the cliprects to generate an array of flags to indicate
- * which pixels in a span are visible. Note: (x,y) is a screen
- * coordinate.
- */
-static void
-generate_vismask(const fxMesaContext fxMesa, GLint x, GLint y, GLint n,
- GLubyte vismask[])
-{
- GLboolean initialized = GL_FALSE;
- GLint i, j;
-
- /* turn on flags for all visible pixels */
- for (i = 0; i < fxMesa->numClipRects; i++) {
- const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
-
- if (y >= rect->y1 && y < rect->y2) {
- if (x >= rect->x1 && x + n <= rect->x2) {
- /* common case, whole span inside cliprect */
- MEMSET(vismask, 1, n);
- return;
- }
- if (x < rect->x2 && x + n >= rect->x1) {
- /* some of the span is inside the rect */
- GLint start, end;
- if (!initialized) {
- MEMSET(vismask, 0, n);
- initialized = GL_TRUE;
- }
- if (x < rect->x1)
- start = rect->x1 - x;
- else
- start = 0;
- if (x + n > rect->x2)
- end = rect->x2 - x;
- else
- end = n;
- assert(start >= 0);
- assert(end <= n);
- for (j = start; j < end; j++)
- vismask[j] = 1;
- }
- }
- }
-}
-
-
-/*
- * Examine cliprects and determine if the given screen pixel is visible.
- */
-static GLboolean
-visible_pixel(const fxMesaContext fxMesa, int scrX, int scrY)
-{
- int i;
- for (i = 0; i < fxMesa->numClipRects; i++) {
- const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
- if (scrX >= rect->x1 &&
- scrX < rect->x2 &&
- scrY >= rect->y1 &&
- scrY < rect->y2)
- return GL_TRUE;
- }
- return GL_FALSE;
-}
-
-
-
-typedef enum { FBS_READ, FBS_WRITE } FBS_DIRECTION;
-/*
- * Read or write a single span from the frame buffer.
- * Input Parameters:
- * fxMesa: The context
- * target_buffer: Which buffer to read from.
- * xpos, ypos: Starting Coordinates.
- * xlength: Length of the span.
- * data_size: Size of data elements: 1, 2, or 4.
- * buffer: Pointer to the buffer to read
- * to or write from. This needs
- * to be turned into a pointer.
- * direction: Read or Write.
- */
-static void
-rw_fb_span(fxMesaContext fxMesa,
- GrBuffer_t target_buffer,
- FxU32 xpos,
- FxU32 ypos,
- FxU32 xlength,
- FxU32 data_size,
- void *buffer,
- FBS_DIRECTION direction)
-{
- GrLfbInfo_t info;
- BEGIN_BOARD_LOCK();
- info.size=sizeof(info);
-
- if (grLfbLock(direction == FBS_READ ? GR_LFB_READ_ONLY : GR_LFB_WRITE_ONLY,
- target_buffer,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winX = fxMesa->x_offset;
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
-#ifdef XF86DRI
- /* stride in data elements */
- const GLint srcStride =
- (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- ? (fxMesa->screen_width)
- : (info.strideInBytes / data_size);
-#else
- /* stride in data elements */
- const GLint srcStride = info.strideInBytes / data_size;
-#endif
- GLushort *data16 = (GLushort *) info.lfbPtr
- + (winY - ypos) * srcStride
- + (winX + xpos);
- GLubyte *target16 = (GLubyte *) buffer;
- GLubyte *data8 = (GLubyte *) data16;
- GLubyte *target8 = (GLubyte *) buffer;
- GLuint *data32 = (GLuint *) data16;
- GLuint *target32 = (GLuint *) buffer;
- GLuint i, j;
-
- for (i = j = 0; i < xlength; i += 1, j += 1) {
- switch (data_size) {
- case 1:
- switch (direction) {
- case FBS_READ:
- *target8++ = *data8++;
- break;
- case FBS_WRITE:
- *data8++ = *target8++;
- break;
- }
- break;
- case 2:
- switch (direction) {
- case FBS_READ:
- *target16++ = *data16++;
- break;
- case FBS_WRITE:
- *data16++ = *target16++;
- break;
- }
- break;
- case 4:
- switch (direction) {
- case FBS_READ:
- *target32++ = *data32++;
- break;
- case FBS_WRITE:
- *data32++ = *target32++;
- break;
- }
- break;
- }
- }
- grLfbUnlock(direction == FBS_READ ? GR_LFB_READ_ONLY : GR_LFB_WRITE_ONLY,
- target_buffer);
- }
- END_BOARD_LOCK();
-}
-
-static FxBool
-fb_point_is_clipped(fxMesaContext fxMesa,
- FxU32 dst_x, FxU32 dst_y)
-{
- int i;
- for (i=0; i<fxMesa->numClipRects; i++) {
- if ((dst_x>=fxMesa->pClipRects[i].x1) &&
- (dst_x<fxMesa->pClipRects[i].x2) &&
- (dst_y>=fxMesa->pClipRects[i].y1) &&
- (dst_y<fxMesa->pClipRects[i].y2)) {
- return GL_FALSE;
- }
- }
- return GL_TRUE;
-}
-
-static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
- FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
- FxU32 src_width, FxU32 src_height, FxI32 src_stride,
- void *src_data)
-{
- int i, x, w, srcElt;
- void *data;
-
- if (src_width==1 && src_height==1) { /* Easy case writing a point */
- for (i=0; i<fxMesa->numClipRects; i++) {
- if ((dst_x>=fxMesa->pClipRects[i].x1) &&
- (dst_x<fxMesa->pClipRects[i].x2) &&
- (dst_y>=fxMesa->pClipRects[i].y1) &&
- (dst_y<fxMesa->pClipRects[i].y2)) {
- FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
- 1, 1, src_stride, src_data);
- return GL_TRUE;
- }
- }
- } else if (src_height==1) { /* Writing a span */
- if (src_format==GR_LFB_SRC_FMT_8888) srcElt=4;
- else if (src_format==GR_LFB_SRC_FMT_ZA16) srcElt=2;
- else {
- fprintf(stderr, "Unknown src_format passed to writeRegionClipped\n");
- return GL_FALSE;
- }
- for (i=0; i<fxMesa->numClipRects; i++) {
- if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
- if (dst_x<fxMesa->pClipRects[i].x1) {
- x=fxMesa->pClipRects[i].x1;
- data=((char*)src_data)+srcElt*(x - dst_x);
- w=src_width-(x-dst_x);
- } else {
- x=dst_x;
- data=src_data;
- w=src_width;
- }
- if (x+w>fxMesa->pClipRects[i].x2) {
- w=fxMesa->pClipRects[i].x2-x;
- }
- FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1,
- src_stride, data);
- }
- }
- } else { /* Punt on the case of arbitrary rectangles */
- return GL_FALSE;
- }
- return GL_TRUE;
-}
-
-
-
-/* KW: Rearranged the args in the call to grLfbWriteRegion().
- */
-#define LFB_WRITE_SPAN_MESA(dst_buffer, \
- dst_x, \
- dst_y, \
- src_width, \
- src_stride, \
- src_data) \
- writeRegionClipped(fxMesa, dst_buffer, \
- dst_x, \
- dst_y, \
- GR_LFB_SRC_FMT_8888, \
- src_width, \
- 1, \
- src_stride, \
- src_data) \
-
-
-
-
-/*
- * 16bpp span/pixel functions
- */
-
-static void
-write_R5G6B5_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
- }
-
- x+=fxMesa->x_offset;
- if (mask) {
- int span=0;
-
- for (i=0;i<n;i++) {
- if (mask[i]) {
- ++span;
- } else {
- if (span > 0) {
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
- /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] );
- span = 0;
- }
- }
- }
-
- if (span > 0)
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
- /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] );
- } else
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
- n,/* 1,*/ 0, (void *) rgba );
-}
-
-
-static void
-write_R5G6B5_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
- GLubyte rgba[MAX_WIDTH][4];
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
- }
-
- x+=fxMesa->x_offset;
- if (mask) {
- int span=0;
-
- for (i=0;i<n;i++) {
- if (mask[i]) {
- rgba[span][RCOMP] = rgb[i][0];
- rgba[span][GCOMP] = rgb[i][1];
- rgba[span][BCOMP] = rgb[i][2];
- rgba[span][ACOMP] = 255;
- ++span;
- } else {
- if (span > 0) {
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
- /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
- span = 0;
- }
- }
- }
-
- if (span > 0)
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
- /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
- } else {
- for (i=0;i<n;i++) {
- rgba[i][RCOMP]=rgb[i][0];
- rgba[i][GCOMP]=rgb[i][1];
- rgba[i][BCOMP]=rgb[i][2];
- rgba[i][ACOMP]=255;
- }
-
- LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
- n,/* 1,*/ 0, (void *) rgba );
- }
-}
-
-
-static void
-write_R5G6B5_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte mask[])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
- GLuint data[MAX_WIDTH];
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
- }
-
- x+=fxMesa->x_offset;
- if (mask) {
- int span=0;
-
- for (i=0;i<n;i++) {
- if (mask[i]) {
- data[span] = (GLuint) fxMesa->color;
- ++span;
- } else {
- if (span > 0) {
- writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y,
- GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data );
- span = 0;
- }
- }
- }
-
- if (span > 0)
- writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y,
- GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data );
- } else {
- for (i=0;i<n;i++) {
- data[i]=(GLuint) fxMesa->color;
- }
-
- writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
- n, 1, 0, (void *) data );
- }
-}
-
-
-/*
- * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
- * since OpenGL says obscured pixels have undefined values.
- */
-static void
-read_R5G6B5_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbInfo_t info;
- BEGIN_BOARD_LOCK();
- info.size=sizeof(info);
- if (grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->currentFB,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winX = fxMesa->x_offset;
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
-#ifdef XF86DRI
- const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- ? (fxMesa->screen_width) : (info.strideInBytes / 2);
-#else
- const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
-#endif
- const GLushort *data16 = (const GLushort *) info.lfbPtr
- + (winY - y) * srcStride
- + (winX + x);
- const GLuint *data32 = (const GLuint *) data16;
- GLuint i, j;
- GLuint extraPixel = (n & 1);
- n -= extraPixel;
- for (i = j = 0; i < n; i += 2, j++) {
- GLuint pixel = data32[j];
- GLuint pixel0 = pixel & 0xffff;
- GLuint pixel1 = pixel >> 16;
- rgba[i][RCOMP] = FX_PixelToR[pixel0];
- rgba[i][GCOMP] = FX_PixelToG[pixel0];
- rgba[i][BCOMP] = FX_PixelToB[pixel0];
- rgba[i][ACOMP] = 255;
- rgba[i+1][RCOMP] = FX_PixelToR[pixel1];
- rgba[i+1][GCOMP] = FX_PixelToG[pixel1];
- rgba[i+1][BCOMP] = FX_PixelToB[pixel1];
- rgba[i+1][ACOMP] = 255;
- }
- if (extraPixel) {
- GLushort pixel = data16[n];
- rgba[n][RCOMP] = FX_PixelToR[pixel];
- rgba[n][GCOMP] = FX_PixelToG[pixel];
- rgba[n][BCOMP] = FX_PixelToB[pixel];
- rgba[n][ACOMP] = 255;
- }
-
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-}
-
-
-static void
-write_R5G6B5_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
- }
-
- for(i=0;i<n;i++)
- if(mask[i])
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i],
- 1, 1, (void *)rgba[i]);
-}
-
-
-static void
-write_R5G6B5_mono_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte mask[])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
- }
-
- for(i=0;i<n;i++)
- if(mask[i])
- writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i],
- GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color);
-}
-
-static void
-read_R5G6B5_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
- }
-
- for(i=0;i<n;i++) {
- if(mask[i]) {
- GLushort pixel;
- FX_grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&pixel);
- rgba[i][RCOMP] = FX_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
- }
- }
-}
-
-
-/*
- * 24bpp span/pixel functions
- */
-
-static void
-write_R8G8B8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_888;
- else
- mode = GR_LFBWRITEMODE_888;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x;
- const GLint scrY = winY - y;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- /*GLint dstStride = fxMesa->screen_width * 3;*/
- GLint dstStride = info.strideInBytes / 1;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 1;
- GLuint *dst32 = (GLuint *) dst;
- GLubyte visMask[MAX_WIDTH];
- GLuint i;
- generate_vismask(fxMesa, scrX, scrY, n, visMask);
- for (i = 0; i < n; i++) {
- if (visMask[i] && (!mask || mask[i])) {
- dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
- }
- }
- }
- else {
- /* back buffer */
- GLint dstStride = info.strideInBytes;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- GLuint *dst32 = (GLuint *) dst;
- if (mask) {
- GLuint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < n; i++) {
- dst32[i] = PACK_RGBA32(rgb[i][2], rgb[i][1], rgb[i][0], 255);
- }
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-}
-
-
-
-static void
-write_R8G8B8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_8888;
- else
- mode = GR_LFBWRITEMODE_888 /*565*/;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x;
- const GLint scrY = winY - y;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- /* XXX have to do cliprect clipping! */
- GLint dstStride = fxMesa->screen_width * 4;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- GLuint *dst32 = (GLuint *) dst;
- GLubyte visMask[MAX_WIDTH];
- GLuint i;
- generate_vismask(fxMesa, scrX, scrY, n, visMask);
- for (i = 0; i < n; i++) {
- if (visMask[i] && (!mask || mask[i])) {
- dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
- }
- }
- }
- else {
- /* back buffer */
- GLint dstStride = info.strideInBytes;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- if (mask) {
- const GLuint *src32 = (const GLuint *) rgba;
- GLuint *dst32 = (GLuint *) dst;
- GLuint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- dst32[i] = src32[i];
- }
- }
- }
- else {
- /* no mask, write all pixels */
- MEMCPY(dst, rgba, 4 * n);
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-}
-
-
-static void
-write_R8G8B8_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLubyte rgba[MAX_WIDTH][4];
- GLuint *data = (GLuint *) rgba;
- GLuint i;
-
- /* XXX this is a simple-minded implementation but good enough for now */
- for (i = 0; i < n; i++) {
- data[i] = (GLuint) fxMesa->color;
- }
- write_R8G8B8_rgba_span(ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask);
-}
-
-
-static void
-read_R8G8B8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (1 || fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- mode = GR_LFBWRITEMODE_8888;
- }
- else {
- mode = GR_LFBWRITEMODE_565; /*888*/ /*565*/;
- }
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->currentFB,
- mode, /*GR_LFBWRITEMODE_ANY,*/
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- GLint srcStride = fxMesa->screen_width * 4;
- const GLubyte *src = (const GLubyte *) info.lfbPtr
- + (winY - y) * srcStride + (winX + x) * 4;
- GLuint i;
- for (i = 0; i < n; i++) {
- rgba[i][0] = src[i * 4 + 2];
- rgba[i][1] = src[i * 4 + 1];
- rgba[i][2] = src[i * 4 + 0];
- rgba[i][3] = src[i * 4 + 3];
- }
- }
- else {
- /* back buffer */
- GLint srcStride = /*info.strideInBytes;*/ 8192 / 2; /* XXX a hack! */
- const GLubyte *src = (const GLubyte *) info.lfbPtr
- + (winY - y) * srcStride + (winX + x) * 4;
- GLuint i;
- for (i = 0; i < n; i++) {
- rgba[i][0] = src[i * 4 + 2];
- rgba[i][1] = src[i * 4 + 1];
- rgba[i][2] = src[i * 4 + 0];
- rgba[i][3] = src[i * 4 + 3];
- }
- }
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-}
-
-
-static void
-write_R8G8B8_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[])
-{
-#if 00
- GLuint i;
- for (i = 0; i < n; i++) {
- write_R8G8B8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i);
- }
-
-#else
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_8888;
- else
- mode = GR_LFBWRITEMODE_888 /*565*/;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- GLuint i;
- for (i = 0; i < n; i++) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x[i];
- const GLint scrY = winY - y[i];
- if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
- GLint dstStride = fxMesa->screen_width * 4;
- GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
- GLuint *dst32 = (GLuint *) dst;
- *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
- rgba[i][2], rgba[i][3]);
- }
- }
- }
- else {
- /* back buffer */
- GLuint i;
- for (i = 0; i < n; i++) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x[i];
- const GLint scrY = winY - y[i];
- if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
- GLint dstStride = info.strideInBytes;
- GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
- GLuint *dst32 = (GLuint *) dst;
- const GLuint *src32 = (const GLuint *) rgba;
- *dst32 = src32[i];
- }
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-#endif
-}
-
-
-static void
-write_R8G8B8_mono_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte mask[])
-{
-}
-
-
-static void
-read_R8G8B8_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[])
-{
- printf("read_R8G8B8_pixels %d\n", n);
-}
-
-
-
-/*
- * 32bpp span/pixel functions
- */
-
-static void
-write_R8G8B8A8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_8888;
- else
- mode = GR_LFBWRITEMODE_888 /*565*/;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x;
- const GLint scrY = winY - y;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- GLint dstStride = fxMesa->screen_width * 4;
- GLubyte * dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- GLuint *dst32 = (GLuint *) dst;
- GLubyte visMask[MAX_WIDTH];
- GLuint i;
- generate_vismask(fxMesa, scrX, scrY, n, visMask);
- for (i = 0; i < n; i++) {
- if (visMask[i] && (!mask || mask[i])) {
- dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
- }
- }
- }
- else {
- /* back buffer */
- GLint dstStride = info.strideInBytes;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- if (mask) {
- GLuint *dst32 = (GLuint *) dst;
- GLuint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
- }
- }
- }
- else {
- GLuint *dst32 = (GLuint *) dst;
- GLuint i;
- for (i = 0; i < n; i++) {
- dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
- }
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-}
-
-
-/*
- *XXX test of grLfbWriteRegion in 32bpp mode. Doesn't seem to work!
- */
-#if 0
-static void
-write_R8G8B8A8_rgb_span2(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLint x2 = fxMesa->x_offset +x;
- GLint y2 = bottom - y;
-
- FX_grLfbWriteRegion(fxMesa->currentFB, x2, y2, GR_LFB_SRC_FMT_888,
- n, 1, 0, rgb);
-}
-#endif
-
-
-static void
-write_R8G8B8A8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_8888;
- else
- mode = GR_LFBWRITEMODE_888 /*565*/;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x;
- const GLint scrY = winY - y;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- GLint dstStride = fxMesa->screen_width * 4;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- GLuint *dst32 = (GLuint *) dst;
- GLubyte visMask[MAX_WIDTH];
- GLuint i;
- generate_vismask(fxMesa, scrX, scrY, n, visMask);
- for (i = 0; i < n; i++) {
- if (visMask[i] && (!mask || mask[i])) {
- dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
- }
- }
- }
- else {
- /* back buffer */
- GLint dstStride = 8192; /* XXX a hack info.strideInBytes; */
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- if (mask) {
- const GLuint *src32 = (const GLuint *) rgba;
- GLuint *dst32 = (GLuint *) dst;
- GLuint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- dst32[i] = src32[i];
- }
- }
- }
- else {
- /* no mask, write all pixels */
- MEMCPY(dst, rgba, 4 * n);
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
- }
- else {
- info.strideInBytes = -1;
- }
- END_BOARD_LOCK();
-}
-
-
-static void
-write_R8G8B8A8_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLubyte rgba[MAX_WIDTH][4];
- GLuint *data = (GLuint *) rgba;
- GLuint i;
-
- /* XXX this is a simple-minded implementation but good enough for now */
- for (i = 0; i < n; i++) {
- data[i] = (GLuint) fxMesa->color;
- }
- write_R8G8B8A8_rgba_span(ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask);
-}
-
-
-static void
-read_R8G8B8A8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- mode = GR_LFBWRITEMODE_8888;
- }
- else {
- mode = GR_LFBWRITEMODE_8888; /*565;*/
- }
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- GLint srcStride = fxMesa->screen_width;
- const GLuint *src32 = (const GLuint *) info.lfbPtr
- + (winY - y) * srcStride + (winX + x);
- GLuint i;
- for (i = 0; i < n; i++) {
- const GLuint p = src32[i];
- rgba[i][0] = (p >> 16) & 0xff;
- rgba[i][1] = (p >> 8) & 0xff;
- rgba[i][2] = (p >> 0) & 0xff;
- rgba[i][3] = (p >> 24) & 0xff;
- }
- }
- else {
- /* back buffer */
- GLint srcStride = 1024; /* XXX a hack */
- const GLuint *src32 = (const GLuint *) info.lfbPtr
- + (winY - y) * srcStride + (winX + x);
- GLuint i;
- for (i = 0; i < n; i++) {
- GLuint p = src32[i];
- rgba[i][0] = (p >> 16) & 0xff;
- rgba[i][1] = (p >> 8) & 0xff;
- rgba[i][2] = (p >> 0) & 0xff;
- rgba[i][3] = (p >> 24) & 0xff;
- }
- }
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- else
- info.strideInBytes = -1;
- END_BOARD_LOCK();
-}
-
-
-static void
-write_R8G8B8A8_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[])
-{
-#if 00
- GLuint i;
- for (i = 0; i < n; i++) {
- write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i);
- }
-
-#else
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbWriteMode_t mode;
- GrLfbInfo_t info;
-
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
- mode = GR_LFBWRITEMODE_8888;
- else
- mode = GR_LFBWRITEMODE_888 /*565*/;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->currentFB,
- mode,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
- GLuint i;
- for (i = 0; i < n; i++) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x[i];
- const GLint scrY = winY - y[i];
- if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
- GLint dstStride = fxMesa->screen_width * 4;
- GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
- GLuint *dst32 = (GLuint *) dst;
- *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
- rgba[i][2], rgba[i][3]);
- }
- }
- }
- else {
- /* back buffer */
- GLuint i;
- for (i = 0; i < n; i++) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x[i];
- const GLint scrY = winY - y[i];
- if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
- GLint dstStride = info.strideInBytes;
- GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
- GLuint *dst32 = (GLuint *) dst;
- const GLuint *src32 = (const GLuint *) rgba;
- *dst32 = src32[i];
- }
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-#endif
-}
-
-
-static void
-write_R8G8B8A8_mono_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLubyte mask[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLuint i;
- GLuint color = fxMesa->color;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i],
- (const GLubyte (*)[4]) &color, mask + i);
- }
- }
-}
-
-
-
-static void
-read_R8G8B8A8_pixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[])
-{
- GLuint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- read_R8G8B8A8_span(ctx, 1, x[i], y[i], rgba + i);
- }
- }
- printf("read_R8G8B8A8_pixels %d\n", n);
-}
-
-
-
-/*
- * Depth buffer read/write functions.
- */
-
-void fxDDWriteDepthSpan(GLcontext *ctx,
- GLuint n, GLint x, GLint y, const GLdepth depth[],
- const GLubyte mask[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint depth_size = fxMesa->glVis->DepthBits;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
- }
-
- x += fxMesa->x_offset;
-
- if (mask) {
- GLint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- GLshort d16;
- GLuint d32;
- switch (depth_size) {
- case 16:
- d16 = depth[i];
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d16);
- break;
- case 32:
- if (!fb_point_is_clipped(fxMesa, x+i, bottom-y)) {
- if (stencil_size > 0) {
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- x + i, bottom - y,
- 1,
- sizeof(GLdepth),
- &d32,
- FBS_READ);
- d32 = depth[i] & 0xFF000000;
- break;
- } else {
- d32 = depth[i];
- }
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- x + i, bottom - y,
- 1,
- sizeof(GLdepth),
- &d32,
- FBS_WRITE);
- }
- }
- }
- }
- } else {
- GLushort depth16[MAX_WIDTH];
- GLint i;
- GLuint d32;
- switch (depth_size) {
- case 16:
- for (i = 0; i < n; i++) {
- depth16[i] = depth[i];
- }
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
- GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
- break;
- case 32:
- for (i = 0; i < n; i++) {
- if (fb_point_is_clipped(fxMesa, x+i, bottom-y)) {
- if (stencil_size > 0) {
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- x + i, bottom - y,
- 1,
- sizeof(GLdepth),
- &d32,
- FBS_READ);
- d32 = (d32 & 0xFF0000) | (depth[i] & 0x00FFFFFF);
- } else {
- d32 = depth[i];
- }
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- x + i, bottom - y,
- 1,
- sizeof(GLdepth),
- &d32,
- FBS_WRITE);
- }
- }
- }
- }
-}
-
-
-void fxDDReadDepthSpan(GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLdepth depth[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLushort depth16[MAX_WIDTH];
- GLuint i;
- GLuint depth_size = fxMesa->glVis->DepthBits;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
- }
-
- x += fxMesa->x_offset;
- switch (depth_size) {
- case 16:
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
- for (i = 0; i < n; i++) {
- depth[i] = depth16[i];
- }
- break;
- case 32:
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- x, bottom - y,
- n,
- sizeof(GLdepth),
- depth,
- FBS_READ);
- if (stencil_size > 0) {
- for (i = 0; i < n; i++) {
- depth[i] &= 0xFFFFFF;
- }
- }
- }
-}
-
-
-
-void fxDDWriteDepthPixels(GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth depth[], const GLubyte mask[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint i;
- GLuint d32;
- GLuint depth_size = fxMesa->glVis->DepthBits;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
- }
-
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- int xpos = x[i] + fxMesa->x_offset;
- int ypos = bottom - y[i];
- GLushort d16 = depth[i];
- switch (depth_size) {
- case 16:
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0,
- (void *) &d16);
- break;
- case 32:
- if (!fb_point_is_clipped(fxMesa, xpos, ypos)) {
- if (stencil_size > 0) {
- /*
- * Should I sign extend this? I don't
- * believe so, since GLdepth is unsigned.
- */
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d32,
- FBS_READ);
- d32 = (d32 &~ 0xFF000000) | (depth[i] & 0x00FFFFFF);
- } else {
- d32 = depth[i];
- }
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d32,
- FBS_WRITE);
- }
- break;
- }
- }
- }
-}
-
-
-void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[], GLdepth depth[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint i;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
- }
-
- for (i = 0; i < n; i++) {
- int xpos = x[i] + fxMesa->x_offset;
- int ypos = bottom - y[i];
- GLushort d16;
- GLuint d32;
- GLuint depth_size = fxMesa->glVis->DepthBits;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
-
- assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32));
- switch (depth_size) {
- case 16:
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d16);
- depth[i] = d16;
- break;
- case 24:
- case 32:
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- depth_size/8,
- &d32,
- FBS_READ);
- /*
- * Get rid of the stencil bits. Should I sign
- * extend this? I don't believe so, since GLdepth
- * is unsigned.
- */
- if (stencil_size > 0) {
- d32 &= 0xFFFFFF;
- }
- depth[i] = d32;
- break;
- default:
- assert(0);
- }
- }
-}
-
-
-/*
- * Stencil buffer read/write functions.
- */
-
-#define DEPTH_VALUE_TO_STENCIL_VALUE(d) (((d) >> 24) & 0xFF)
-#define STENCIL_VALUE_TO_DEPTH_VALUE(s,d) \
- ((((s) & 0xFF) << 24) | ((d) & 0xFFFFFF))
-#define ASSEMBLE_STENCIL_VALUE(os, ns, mask) \
- (((os) &~ (mask)) | ((ns) & (mask)))
-
-#if 00
-/*
- * Read a horizontal span of stencil values from the stencil buffer.
- */
-void
-fxDDReadStencilSpan( GLcontext *ctx,
- GLuint n,
- GLint x,
- GLint y,
- GLstencil stencil[] )
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint i;
- int xpos = x + fxMesa->x_offset;
- int ypos = bottom - y;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadStencilSpan(...)\n");
- }
-
- for (i = 0; i < n; i++, ypos += 1) {
- GLuint d;
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d,
- FBS_READ);
- stencil[i] = DEPTH_VALUE_TO_STENCIL_VALUE(d);
- }
-}
-
-/*
- * Write a horizontal span of stencil values into the stencil buffer.
- * If mask is NULL, write all stencil values.
- * Else, only write stencil[i] if mask[i] is non-zero.
- */
-void
-fxDDWriteStencilSpan( GLcontext *ctx,
- GLuint n,
- GLint x,
- GLint y,
- const GLstencil stencil[],
- const GLubyte mask[] )
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint i;
- int xpos = x + fxMesa->x_offset;
- int ypos = bottom - y;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteStencilSpan(...)\n");
- }
-
- for (i = 0; i < n; i++, ypos += 1) {
- GLdepth d;
- GLstencil ns;
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d,
- FBS_READ);
- /*
- * Find the old stencil value, and strip off the bits
- * we are going to write.
- */
- ns = ASSEMBLE_STENCIL_VALUE(DEPTH_VALUE_TO_STENCIL_VALUE(d),
- stencil[i],
- mask[i]);
- /*
- * Now, assemble the new StenDepth value, with the old
- * depth value, the old stencil value in the bits
- * where mask is 0, and the new stencil value in the bits
- * where mask is 1.
- */
- d = STENCIL_VALUE_TO_DEPTH_VALUE(ns, d);
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d,
- FBS_WRITE);
- }
-}
-
-/* Write an array of stencil values into the stencil buffer.
- * If mask is NULL, write all stencil values.
- * Else, only write stencil[i] if mask[i] is non-zero.
- */
-void
-fxDDReadStencilPixels( GLcontext *ctx,
- GLuint n,
- const GLint x[],
- const GLint y[],
- GLstencil stencil[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint i;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDReadStencilPixels(...)\n");
- }
-
- for (i = 0; i < n; i++) {
- int xpos = x[i] + fxMesa->x_offset;
- int ypos = bottom - y[i];
- GLuint d;
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d,
- FBS_READ);
- stencil[i] = DEPTH_VALUE_TO_STENCIL_VALUE(d);
- }
-}
-
-/*
- * Read an array of stencil values from the stencil buffer.
- */
-void
-fxDDWriteStencilPixels( GLcontext *ctx,
- GLuint n,
- const GLint x[],
- const GLint y[],
- const GLstencil stencil[],
- const GLstencil mask[])
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- GLuint i;
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDWriteStencilPixels(...)\n");
- }
-
- for (i = 0; i < n; i++) {
- int xpos = x[i] + fxMesa->x_offset;
- int ypos = bottom - y[i];
- GLuint d;
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d,
- FBS_READ);
- d = STENCIL_VALUE_TO_DEPTH_VALUE(stencil[i], d);
- rw_fb_span(fxMesa,
- GR_BUFFER_AUXBUFFER,
- xpos, ypos,
- 1,
- sizeof(GLdepth),
- &d,
- FBS_WRITE);
- }
-}
-#endif /* disable fxddStencil* funcs */
-
-
-#define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF)
-#define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff)
-#define BUILD_ZS(z, s) (((s) << 24) | (z))
-
-static void write_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLstencil stencil[],
- const GLubyte mask[] )
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbInfo_t info;
- int s;
- void *d;
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_WRITE_ONLY,
- GR_BUFFER_AUXBUFFER,
- GR_LFBWRITEMODE_Z32,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- const GLint scrX = winX + x;
- const GLint scrY = winY - y;
-
- GLint dstStride = info.strideInBytes;
- GLubyte *dst = (GLubyte *) info.lfbPtr
- + (winY - y) * dstStride + (winX + x) * 4;
- GLuint *dst32 = (GLuint *) dst;
- GLubyte visMask[MAX_WIDTH];
- GLuint i;
- generate_vismask(fxMesa, scrX, scrY, n, visMask);
- s = dstStride;
- d = dst32;
- for (i = 0; i < n; i++) {
- if (visMask[i] && (!mask || mask[i])) {
- GLuint zs = dst32[i];
- GLuint z = EXTRACT_Z_FROM_ZS(zs);
- zs = BUILD_ZS(z, stencil[i]);
- dst32[i] = /*zs;*/ stencil[i];
- }
- }
- grLfbUnlock(GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER);
- }
- else {
- s = -1;
- d = 0;
- }
- END_BOARD_LOCK();
- /*
- printf("write stencil span %d %p\n", s, d);
- printf("info: size=%d lfbPtr=%p stride=%x writeMode=%x origin=%x\n",
- info.size, info.lfbPtr, info.strideInBytes, info.writeMode, info.origin);
- */
-}
-
-
-static void
-read_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLstencil stencil[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrLfbInfo_t info;
- /*
- int s;
- void *d;
- */
-
- BEGIN_BOARD_LOCK();
- info.size = sizeof(info);
- if (grLfbLock(GR_LFB_READ_ONLY,
- GR_BUFFER_AUXBUFFER,
- GR_LFBWRITEMODE_Z32,
- GR_ORIGIN_UPPER_LEFT,
- FXFALSE,
- &info)) {
- const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
- const GLint winX = fxMesa->x_offset;
- GLint srcStride = /*info.strideInBytes;*/ 8192 ; /* XXX a hack! */
- const GLubyte *src = (const GLubyte *) info.lfbPtr
- + (winY - y) * srcStride + (winX + x) * 4;
- const GLuint *src32 = (const GLuint *) src;
- GLuint i;
- /*
- s = srcStride;
- d = src32;
- */
- for (i = 0; i < n; i++) {
- stencil[i] = EXTRACT_S_FROM_ZS(src32[i]);
- }
- grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER);
- }
- END_BOARD_LOCK();
- /*
- printf("read stencil span %d %p\n", s, d);
- printf("info: size=%d lfbPtr=%p stride=%x writeMode=%x origin=%x\n",
- info.size, info.lfbPtr, info.strideInBytes, info.writeMode, info.origin);
- */
-}
-
-
-static void
-write_stencil_pixels( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLstencil stencil[], const GLubyte mask[])
-{
- /* XXX optimize this */
- GLuint i;
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- write_stencil_span(ctx, 1, x[i], y[i], stencil + i, mask + i);
- }
- }
-}
-
-
-static void
-read_stencil_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
- GLstencil stencil[])
-{
- /* XXX optimize this */
- GLuint i;
- for (i = 0; i < n; i++) {
- read_stencil_span(ctx, 1, x[i], y[i], stencil + i);
- }
-}
-
-
-
-void fxSetupDDSpanPointers(GLcontext *ctx)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (ctx->Visual->RedBits == 5 &&
- ctx->Visual->GreenBits == 6 &&
- ctx->Visual->BlueBits == 5 &&
- ctx->Visual->AlphaBits == 0) {
- /* 16bpp mode */
- ctx->Driver.WriteRGBASpan = write_R5G6B5_rgba_span;
- ctx->Driver.WriteRGBSpan = write_R5G6B5_rgb_span;
- ctx->Driver.WriteMonoRGBASpan = write_R5G6B5_mono_span;
- ctx->Driver.WriteRGBAPixels = write_R5G6B5_pixels;
- ctx->Driver.WriteMonoRGBAPixels = write_R5G6B5_mono_pixels;
- ctx->Driver.ReadRGBASpan = read_R5G6B5_span;
- ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels;
- }
- else if (ctx->Visual->RedBits == 8 &&
- ctx->Visual->GreenBits == 8 &&
- ctx->Visual->BlueBits == 8 &&
- ctx->Visual->AlphaBits == 0) {
- /* 24bpp mode */
- ctx->Driver.WriteRGBASpan = write_R8G8B8_rgba_span;
- ctx->Driver.WriteRGBSpan = write_R8G8B8_rgb_span;
- ctx->Driver.WriteMonoRGBASpan = write_R8G8B8_mono_span;
- ctx->Driver.WriteRGBAPixels = write_R8G8B8_pixels;
- ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8_mono_pixels;
- ctx->Driver.ReadRGBASpan = read_R8G8B8_span;
- ctx->Driver.ReadRGBAPixels = read_R8G8B8_pixels;
- }
- else if (ctx->Visual->RedBits == 8 &&
- ctx->Visual->GreenBits == 8 &&
- ctx->Visual->BlueBits == 8 &&
- ctx->Visual->AlphaBits == 8) {
- /* 32bpp mode */
- ctx->Driver.WriteRGBASpan = write_R8G8B8A8_rgba_span;
- ctx->Driver.WriteRGBSpan = write_R8G8B8A8_rgb_span;
- ctx->Driver.WriteMonoRGBASpan = write_R8G8B8A8_mono_span;
- ctx->Driver.WriteRGBAPixels = write_R8G8B8A8_pixels;
- ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8A8_mono_pixels;
- ctx->Driver.ReadRGBASpan = read_R8G8B8A8_span;
- ctx->Driver.ReadRGBAPixels = read_R8G8B8A8_pixels;
- }
- else {
- abort();
- }
-
- if (fxMesa->haveHwStencil) {
- ctx->Driver.WriteStencilSpan = write_stencil_span;
- ctx->Driver.ReadStencilSpan = read_stencil_span;
- ctx->Driver.WriteStencilPixels = write_stencil_pixels;
- ctx->Driver.ReadStencilPixels = read_stencil_pixels;
- }
-
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
-}
diff --git a/xc/extras/Mesa/src/FX/fxddtex.c b/xc/extras/Mesa/src/FX/fxddtex.c
deleted file mode 100644
index 3c3caa4ee..000000000
--- a/xc/extras/Mesa/src/FX/fxddtex.c
+++ /dev/null
@@ -1,1089 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "image.h"
-#include "texutil.h"
-
-
-void fxPrintTextureData(tfxTexInfo *ti)
-{
- fprintf(stderr, "Texture Data:\n");
- if (ti->tObj) {
- fprintf(stderr, "\tName: %d\n", ti->tObj->Name);
- fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel);
- fprintf(stderr, "\tSize: %d x %d\n",
- ti->tObj->Image[ti->tObj->BaseLevel]->Width,
- ti->tObj->Image[ti->tObj->BaseLevel]->Height);
- } else
- fprintf(stderr, "\tName: UNNAMED\n");
- fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
- fprintf(stderr, "\tTMU: %ld\n", ti->whichTMU);
- fprintf(stderr, "\t%s\n", (ti->isInTM)?"In TMU":"Not in TMU");
- if (ti->tm[0])
- fprintf(stderr, "\tMem0: %x-%x\n", (unsigned) ti->tm[0]->startAddr,
- (unsigned) ti->tm[0]->endAddr);
- if (ti->tm[1])
- fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr,
- (unsigned) ti->tm[1]->endAddr);
- fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
- fprintf(stderr, "\tFilters: min %d min %d\n",
- (int) ti->minFilt, (int) ti->maxFilt);
- fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp, (int) ti->tClamp);
- fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale);
- fprintf(stderr, "\tInt Scales: s %d t %d\n",
- ti->int_sScale/0x800000, ti->int_tScale/0x800000);
- fprintf(stderr, "\t%s\n", (ti->fixedPalette)?"Fixed palette":"Non fixed palette");
- fprintf(stderr, "\t%s\n", (ti->validated)?"Validated":"Not validated");
-}
-
-
-/************************************************************************/
-/*************************** Texture Mapping ****************************/
-/************************************************************************/
-
-static void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxTexInfo *ti;
-
- ti=fxTMGetTexInfo(tObj);
- if (ti->isInTM) fxTMMoveOutTM(fxMesa,tObj); /* TO DO: SLOW but easy to write */
-
- ti->validated=GL_FALSE;
- fxMesa->new_state|=FX_NEW_TEXTURING;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-static tfxTexInfo *fxAllocTexObjData(fxMesaContext fxMesa)
-{
- tfxTexInfo *ti;
- int i;
-
- if(!(ti=CALLOC(sizeof(tfxTexInfo)))) {
- fprintf(stderr,"fx Driver: out of memory !\n");
- fxCloseHardware();
- exit(-1);
- }
-
- ti->validated=GL_FALSE;
- ti->isInTM=GL_FALSE;
-
- ti->whichTMU=FX_TMU_NONE;
-
- ti->tm[FX_TMU0]=NULL;
- ti->tm[FX_TMU1]=NULL;
-
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->maxFilt=GR_TEXTUREFILTER_BILINEAR;
-
- ti->sClamp=GR_TEXTURECLAMP_WRAP;
- ti->tClamp=GR_TEXTURECLAMP_WRAP;
-
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXFALSE;
-
- for(i=0;i<MAX_TEXTURE_LEVELS;i++) {
- ti->mipmapLevel[i].data=NULL;
- }
-
- return ti;
-}
-
-void fxDDTexBind(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- tfxTexInfo *ti;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDTexBind(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData);
- }
-
- if(target!=GL_TEXTURE_2D)
- return;
-
- if (!tObj->DriverData) {
- tObj->DriverData=fxAllocTexObjData(fxMesa);
- }
-
- ti=fxTMGetTexInfo(tObj);
-
- fxMesa->texBindNumber++;
- ti->lastTimeUsed=fxMesa->texBindNumber;
-
- fxMesa->new_state|=FX_NEW_TEXTURING;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-void fxDDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- if(param)
- fprintf(stderr,"fxmesa: texenv(%x,%x)\n",pname,(GLint)(*param));
- else
- fprintf(stderr,"fxmesa: texenv(%x)\n",pname);
- }
-
- /* apply any lod biasing right now */
- if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
- FX_grTexLodBiasValue(GR_TMU0,*param);
-
- if(fxMesa->haveTwoTMUs) {
- FX_grTexLodBiasValue(GR_TMU1,*param);
- }
-
- }
-
- fxMesa->new_state|=FX_NEW_TEXTURING;
- ctx->Driver.RenderStart = fxSetupFXUnits;
-}
-
-void fxDDTexParam(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLenum param=(GLenum)(GLint)params[0];
- tfxTexInfo *ti;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDTexParam(%d,%x,%x,%x)\n",tObj->Name,(GLuint)tObj->DriverData,pname,param);
- }
-
- if(target!=GL_TEXTURE_2D)
- return;
-
- if (!tObj->DriverData)
- tObj->DriverData=fxAllocTexObjData(fxMesa);
-
- ti=fxTMGetTexInfo(tObj);
-
- switch(pname) {
-
- case GL_TEXTURE_MIN_FILTER:
- switch(param) {
- case GL_NEAREST:
- ti->mmMode=GR_MIPMAP_DISABLE;
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->LODblend=FXFALSE;
- break;
- case GL_LINEAR:
- ti->mmMode=GR_MIPMAP_DISABLE;
- ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
- ti->LODblend=FXFALSE;
- break;
- case GL_NEAREST_MIPMAP_NEAREST:
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->LODblend=FXFALSE;
- break;
- case GL_LINEAR_MIPMAP_NEAREST:
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
- ti->LODblend=FXFALSE;
- break;
- case GL_NEAREST_MIPMAP_LINEAR:
- if(fxMesa->haveTwoTMUs) {
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXTRUE;
- } else {
- ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
- ti->LODblend=FXFALSE;
- }
- ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- break;
- case GL_LINEAR_MIPMAP_LINEAR:
- if(fxMesa->haveTwoTMUs) {
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXTRUE;
- } else {
- ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
- ti->LODblend=FXFALSE;
- }
- ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
- break;
- default:
- break;
- }
- fxTexInvalidate(ctx,tObj);
- break;
-
- case GL_TEXTURE_MAG_FILTER:
- switch(param) {
- case GL_NEAREST:
- ti->maxFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
- break;
- case GL_LINEAR:
- ti->maxFilt=GR_TEXTUREFILTER_BILINEAR;
- break;
- default:
- break;
- }
- fxTexInvalidate(ctx,tObj);
- break;
-
- case GL_TEXTURE_WRAP_S:
- switch(param) {
- case GL_CLAMP:
- ti->sClamp=GR_TEXTURECLAMP_CLAMP;
- break;
- case GL_REPEAT:
- ti->sClamp=GR_TEXTURECLAMP_WRAP;
- break;
- default:
- break;
- }
- fxMesa->new_state|=FX_NEW_TEXTURING;
- ctx->Driver.RenderStart = fxSetupFXUnits;
- break;
-
- case GL_TEXTURE_WRAP_T:
- switch(param) {
- case GL_CLAMP:
- ti->tClamp=GR_TEXTURECLAMP_CLAMP;
- break;
- case GL_REPEAT:
- ti->tClamp=GR_TEXTURECLAMP_WRAP;
- break;
- default:
- break;
- }
- fxMesa->new_state|=FX_NEW_TEXTURING;
- ctx->Driver.RenderStart = fxSetupFXUnits;
- break;
-
- case GL_TEXTURE_BORDER_COLOR:
- /* TO DO */
- break;
-
- case GL_TEXTURE_MIN_LOD:
- /* TO DO */
- break;
- case GL_TEXTURE_MAX_LOD:
- /* TO DO */
- break;
- case GL_TEXTURE_BASE_LEVEL:
- fxTexInvalidate(ctx,tObj);
- break;
- case GL_TEXTURE_MAX_LEVEL:
- fxTexInvalidate(ctx,tObj);
- break;
-
- default:
- break;
- }
-}
-
-void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- tfxTexInfo *ti = fxTMGetTexInfo(tObj);
-
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDTexDel(%d,%p)\n", tObj->Name, ti);
- }
-
- if (!ti)
- return;
-
- fxTMFreeTexture(fxMesa, tObj);
-
- FREE(ti);
- tObj->DriverData = NULL;
-
- ctx->NewState |= NEW_TEXTURING;
-}
-
-
-
-/*
- * Convert a gl_color_table texture palette to Glide's format.
- */
-static void
-convertPalette(FxU32 data[256], const struct gl_color_table *table)
-{
- const GLubyte *tableUB = (const GLubyte *) table->Table;
- GLint width = table->Size;
- FxU32 r, g, b, a;
- GLint i;
-
- ASSERT(table->TableType == GL_UNSIGNED_BYTE);
-
- switch (table->Format) {
- case GL_INTENSITY:
- for (i = 0; i < width; i++) {
- r = tableUB[i];
- g = tableUB[i];
- b = tableUB[i];
- a = tableUB[i];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- break;
- case GL_LUMINANCE:
- for (i = 0; i < width; i++) {
- r = tableUB[i];
- g = tableUB[i];
- b = tableUB[i];
- a = 255;
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- break;
- case GL_ALPHA:
- for (i = 0; i < width; i++) {
- r = g = b = 255;
- a = tableUB[i];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- for (i = 0; i < width; i++) {
- r = g = b = tableUB[i*2+0];
- a = tableUB[i*2+1];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- break;
- case GL_RGB:
- for (i = 0; i < width; i++) {
- r = tableUB[i*3+0];
- g = tableUB[i*3+1];
- b = tableUB[i*3+2];
- a = 255;
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- break;
- case GL_RGBA:
- for (i = 0; i < width; i++) {
- r = tableUB[i*4+0];
- g = tableUB[i*4+1];
- b = tableUB[i*4+2];
- a = tableUB[i*4+3];
- data[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- break;
- }
-}
-
-
-void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (tObj) {
- /* per-texture palette */
- tfxTexInfo *ti;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDTexPalette(%d,%x)\n",
- tObj->Name, (GLuint) tObj->DriverData);
- }
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
- ti = fxTMGetTexInfo(tObj);
- convertPalette(ti->palette.data, &tObj->Palette);
- fxTexInvalidate(ctx, tObj);
- }
- else {
- /* global texture palette */
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDTexPalette(global)\n");
- }
- convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette);
- fxMesa->new_state |= FX_NEW_TEXTURING;
- ctx->Driver.RenderStart = fxSetupFXUnits;
- }
-}
-
-
-void fxDDTexUseGlbPalette(GLcontext *ctx, GLboolean state)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDTexUseGlbPalette(%d)\n",state);
- }
-
- if (state) {
- fxMesa->haveGlobalPaletteTexture = 1;
-
- FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE, &(fxMesa->glbPalette));
- if (fxMesa->haveTwoTMUs)
- FX_grTexDownloadTable(GR_TMU1, GR_TEXTABLE_PALETTE, &(fxMesa->glbPalette));
- }
- else {
- fxMesa->haveGlobalPaletteTexture = 0;
-
- if ((ctx->Texture.Unit[0].Current == ctx->Texture.Unit[0].CurrentD[2]) &&
- (ctx->Texture.Unit[0].Current != NULL)) {
- struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current;
-
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
-
- fxTexInvalidate(ctx, tObj);
- }
- }
-}
-
-
-static int logbase2(int n)
-{
- GLint i = 1;
- GLint log2 = 0;
-
- if (n<0) {
- return -1;
- }
-
- while (n > i) {
- i *= 2;
- log2++;
- }
- if (i != n) {
- return -1;
- }
- else {
- return log2;
- }
-}
-
-/* Need different versions for different cpus.
- */
-#define INT_TRICK(l2) (0x800000 * (l2))
-int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel,
- GrAspectRatio_t *aspectratio,
- float *sscale, float *tscale,
- int *i_sscale, int *i_tscale,
- int *wscale, int *hscale)
-{
- int logw, logh, ar, l, is, it, ws, hs;
- float s, t;
-
- logw=logbase2(w);
- logh=logbase2(h);
- ar=logw-logh;
- /* Hardware only allows a maximum aspect ratio of 8x1, so handle
- |ar|>3 by scaling the image and using an 8x1 aspect ratio */
- if (ar>=0) {
- l=logw;
- s=256.0;
- is=INT_TRICK(8);
- ws=1;
- if (ar<3) {
- t=256>>ar;
- it=INT_TRICK(8-ar);
- hs=1;
- } else {
- t=32.0;
- it=INT_TRICK(5);
- hs=1<<(ar-3);
- }
- } else {
- l=logh;
- t=256.0;
- it=INT_TRICK(8);
- hs=1;
- if (-ar<3) {
- s=256>>-ar;
- is=INT_TRICK(8+ar);
- ws=1;
- } else {
- s=32.0;
- is=INT_TRICK(5);
- ws=1<<(-ar-3);
- }
- }
- if (ar<-3) ar=-3;
- if (ar>3) ar=3;
-
- /* The above numbers are calculated sensibly and work for Glide3, but
- we change them to the whacky glide2 values if needed. */
-#ifdef FX_GLIDE3
- if (lodlevel) *lodlevel=l;
- if (aspectratio) *aspectratio=ar;
-#else
- if (lodlevel) *lodlevel=8-l;
- if (aspectratio) *aspectratio=3-ar;
-#endif
- if (sscale) *sscale=s;
- if (tscale) *tscale=t;
- if (wscale) *wscale=ws;
- if (hscale) *hscale=hs;
- if (i_sscale) *i_sscale = is;
- if (i_tscale) *i_tscale = it;
- return 1;
-}
-
-/*
- * Given an OpenGL internal texture format, return the corresponding
- * Glide internal texture format and base texture format.
- */
-void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
-{
- switch(glformat) {
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_INTENSITY_8;
- if(ifmt)
- (*ifmt)=GL_LUMINANCE;
- break;
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88;
- if(ifmt)
- (*ifmt)=GL_LUMINANCE_ALPHA;
- break;
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ALPHA_8;
- if(ifmt)
- (*ifmt)=GL_INTENSITY;
- break;
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ALPHA_8;
- if(ifmt)
- (*ifmt)=GL_ALPHA;
- break;
- case 3:
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_RGB_565;
- if(ifmt)
- (*ifmt)=GL_RGB;
- break;
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_8888;
- if(ifmt)
- (*ifmt)=GL_RGB;
- break;
- case 4:
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_4444;
- if(ifmt)
- (*ifmt)=GL_RGBA;
- break;
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_8888;
- if(ifmt)
- (*ifmt)=GL_RGBA;
- break;
- case GL_RGB5_A1:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_1555;
- if(ifmt)
- (*ifmt)=GL_RGBA;
- break;
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_P_8;
- if(ifmt)
- (*ifmt)=GL_RGBA; /* XXX why is this RGBA? */
- break;
- default:
- fprintf(stderr,
- "fx Driver: unsupported internalFormat in fxTexGetFormat()\n");
- fxCloseHardware();
- exit(-1);
- break;
- }
-}
-
-static GLboolean fxIsTexSupported(GLenum target, GLint internalFormat,
- const struct gl_texture_image *image)
-{
- if(target != GL_TEXTURE_2D)
- return GL_FALSE;
-
- if(!fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
- NULL,NULL))
- return GL_FALSE;
-
- if (image->Border > 0)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-
-/**********************************************************************/
-/**** NEW TEXTURE IMAGE FUNCTIONS ****/
-/**********************************************************************/
-
-GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy)
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
-
- if (target != GL_TEXTURE_2D)
- return GL_FALSE;
-
- if (!texObj->DriverData)
- texObj->DriverData = fxAllocTexObjData(fxMesa);
-
- if (fxIsTexSupported(target, texImage->IntFormat, texImage)) {
- GrTextureFormat_t gldformat;
- tfxTexInfo *ti = fxTMGetTexInfo(texObj);
- tfxMipMapLevel *mml = &ti->mipmapLevel[level];
- GLint dstWidth, dstHeight, wScale, hScale, texelSize, dstStride;
- MesaIntTexFormat intFormat;
-
- fxTexGetFormat(texImage->IntFormat, &gldformat, NULL);
-
- fxTexGetInfo(texImage->Width, texImage->Height, NULL,NULL,NULL,NULL,
- NULL,NULL, &wScale, &hScale);
-
- dstWidth = texImage->Width * wScale;
- dstHeight = texImage->Height * hScale;
-
- switch (texImage->IntFormat) {
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- texelSize = 1;
- intFormat = MESA_I8;
- break;
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- texelSize = 1;
- intFormat = MESA_L8;
- break;
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- texelSize = 1;
- intFormat = MESA_A8;
- break;
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- texelSize = 1;
- intFormat = MESA_C8;
- break;
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- texelSize = 2;
- intFormat = MESA_A8_L8;
- break;
- case 3:
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- texelSize = 2;
- intFormat = MESA_R5_G6_B5;
- break;
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- texelSize = 4;
- intFormat = MESA_A8_R8_G8_B8;
- break;
- case 4:
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- texelSize = 2;
- intFormat = MESA_A4_R4_G4_B4;
- break;
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- texelSize = 4;
- intFormat = MESA_A8_R8_G8_B8;
- break;
- case GL_RGB5_A1:
- texelSize = 2;
- intFormat = MESA_A1_R5_G5_B5;
- break;
- default:
- gl_problem(NULL, "tdfx driver: texbuildimagemap() bad format");
- return GL_FALSE;
- }
-
- _mesa_set_teximage_component_sizes(intFormat, texImage);
-
- /*printf("teximage:\n");*/
- /* allocate new storage for texture image, if needed */
- if (!mml->data || mml->glideFormat != gldformat ||
- mml->width != dstWidth || mml->height != dstHeight) {
- if (mml->data)
- FREE(mml->data);
- mml->data = MALLOC(dstWidth * dstHeight * texelSize);
- if (!mml->data)
- return GL_FALSE;
- mml->texelSize = texelSize;
- mml->glideFormat = gldformat;
- mml->width = dstWidth;
- mml->height = dstHeight;
- fxTexInvalidate(ctx, texObj);
- }
-
- dstStride = dstWidth * texelSize;
-
- /* store the texture image */
- if (!_mesa_convert_teximage(intFormat, dstWidth, dstHeight, mml->data,
- dstStride,
- texImage->Width, texImage->Height,
- format, type, pixels, packing)) {
- return GL_FALSE;
- }
-
- if (ti->validated && ti->isInTM) {
- /*printf("reloadmipmaplevels\n");*/
- fxTMReloadMipMapLevel(fxMesa, texObj, level);
- }
- else {
- /*printf("invalidate2\n");*/
- fxTexInvalidate(ctx,texObj);
- }
-
- *retainInternalCopy = GL_FALSE;
- return GL_TRUE;
- }
- else {
- gl_problem(NULL, "fx Driver: unsupported texture in fxDDTexImg()\n");
- return GL_FALSE;
- }
-}
-
-
-GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- tfxTexInfo *ti;
- GLint wscale, hscale, dstStride;
- tfxMipMapLevel *mml;
- GLboolean result;
-
- if (target != GL_TEXTURE_2D)
- return GL_FALSE;
-
- if (!texObj->DriverData)
- return GL_FALSE;
-
- ti = fxTMGetTexInfo(texObj);
- mml = &ti->mipmapLevel[level];
-
- fxTexGetInfo( texImage->Width, texImage->Height, NULL,NULL,NULL,NULL,
- NULL,NULL, &wscale, &hscale);
-
- assert(mml->data); /* must have an existing texture image! */
-
- switch (mml->glideFormat) {
- case GR_TEXFMT_INTENSITY_8:
- dstStride = mml->width;
- result = _mesa_convert_texsubimage(MESA_I8, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_ALPHA_8:
- dstStride = mml->width;
- result = _mesa_convert_texsubimage(MESA_A8, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_P_8:
- dstStride = mml->width;
- result = _mesa_convert_texsubimage(MESA_C8, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_ALPHA_INTENSITY_88:
- dstStride = mml->width * 2;
- result = _mesa_convert_texsubimage(MESA_A8_L8, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_RGB_565:
- dstStride = mml->width * 2;
- result = _mesa_convert_texsubimage(MESA_R5_G6_B5, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_ARGB_4444:
- dstStride = mml->width * 2;
- result = _mesa_convert_texsubimage(MESA_A4_R4_G4_B4, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_ARGB_8888:
- dstStride = mml->width * 4;
- result = _mesa_convert_texsubimage(MESA_A8_R8_G8_B8, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- case GR_TEXFMT_ARGB_1555:
- dstStride = mml->width * 2;
- result = _mesa_convert_texsubimage(MESA_A1_R5_G5_B5, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
- default:
- gl_problem(NULL, "tdfx driver: fxTexBuildSubImageMap() bad format");
- result = GL_FALSE;
- }
-
- if (!result) {
- return GL_FALSE;
- }
-
- if (ti->validated && ti->isInTM)
- /* Don't use this, it's very broken. Download whole image for now.
- fxTMReloadSubMipMapLevel(fxMesa, texObj, level, yoffset, height);
- */
- fxTMReloadMipMapLevel(fxMesa, texObj, level);
- else
- fxTexInvalidate(ctx, texObj);
-
- return GL_TRUE;
-}
-
-
-static void PrintTexture(int w, int h, int c, const GLubyte *data)
-{
- int i, j;
- for (i = 0; i < h; i++) {
- for (j = 0; j < w; j++) {
- if (c==2)
- printf("%02x %02x ", data[0], data[1]);
- else if (c==3)
- printf("%02x %02x %02x ", data[0], data[1], data[2]);
- data += c;
- }
- printf("\n");
- }
-}
-
-
-GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level,
- const struct gl_texture_object *texObj,
- GLenum *formatOut, GLenum *typeOut,
- GLboolean *freeImageOut )
-{
- tfxTexInfo *ti;
- tfxMipMapLevel *mml;
-
- if (target != GL_TEXTURE_2D)
- return NULL;
-
- if (!texObj->DriverData)
- return NULL;
-
- ti = fxTMGetTexInfo(texObj);
- mml = &ti->mipmapLevel[level];
- if (mml->data) {
- MesaIntTexFormat mesaFormat;
- GLenum glFormat;
- struct gl_texture_image *texImage = texObj->Image[level];
- GLint srcStride;
-
- GLubyte *data = (GLubyte *) MALLOC(texImage->Width * texImage->Height * 4);
- if (!data)
- return NULL;
-
- switch (mml->glideFormat) {
- case GR_TEXFMT_INTENSITY_8:
- mesaFormat = MESA_I8;
- glFormat = GL_INTENSITY;
- srcStride = mml->width;
- break;
- case GR_TEXFMT_ALPHA_INTENSITY_88:
- mesaFormat = MESA_A8_L8;
- glFormat = GL_LUMINANCE_ALPHA;
- srcStride = mml->width;
- break;
- case GR_TEXFMT_ALPHA_8:
- mesaFormat = MESA_A8;
- glFormat = GL_ALPHA;
- srcStride = mml->width;
- break;
- case GR_TEXFMT_RGB_565:
- mesaFormat = MESA_R5_G6_B5;
- glFormat = GL_RGB;
- srcStride = mml->width * 2;
- break;
- case GR_TEXFMT_ARGB_8888:
- mesaFormat = MESA_A8_R8_G8_B8;
- glFormat = GL_RGBA;
- srcStride = mml->width * 4;
- break;
- case GR_TEXFMT_ARGB_4444:
- mesaFormat = MESA_A4_R4_G4_B4;
- glFormat = GL_RGBA;
- srcStride = mml->width * 2;
- break;
- case GR_TEXFMT_ARGB_1555:
- mesaFormat = MESA_A1_R5_G5_B5;
- glFormat = GL_RGBA;
- srcStride = mml->width * 2;
- break;
- case GR_TEXFMT_P_8:
- mesaFormat = MESA_C8;
- glFormat = GL_COLOR_INDEX;
- srcStride = mml->width;
- break;
- default:
- gl_problem(NULL, "Bad glideFormat in fxDDGetTexImage");
- return NULL;
- }
- _mesa_unconvert_teximage(mesaFormat, mml->width, mml->height, mml->data,
- srcStride, texImage->Width, texImage->Height,
- glFormat, data);
- *formatOut = glFormat;
- *typeOut = GL_UNSIGNED_BYTE;
- *freeImageOut = GL_TRUE;
- return data;
- }
- else {
- return NULL;
- }
-}
-
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-int gl_fx_dummy_function_ddtex(void)
-{
- return 0;
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxdrv.h b/xc/extras/Mesa/src/FX/fxdrv.h
deleted file mode 100644
index eea75fc56..000000000
--- a/xc/extras/Mesa/src/FX/fxdrv.h
+++ /dev/null
@@ -1,691 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifndef FXDRV_H
-#define FXDRV_H
-
-/* If you comment out this define, a variable takes its place, letting
- * you turn debugging on/off from the debugger.
- */
-
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#else
-#include "glheader.h"
-#endif
-
-
-#if defined(__linux__)
-#include <signal.h>
-#endif
-
-#include "context.h"
-#include "macros.h"
-#include "matrix.h"
-#include "mem.h"
-#include "texture.h"
-#include "types.h"
-#include "vb.h"
-#include "xform.h"
-#include "clip.h"
-#include "vbrender.h"
-
-#ifdef XF86DRI
-typedef struct tfxMesaContext *fxMesaContext;
-#else
-#include "GL/fxmesa.h"
-#endif
-#include "fxglidew.h"
-/* use gl/gl.h GLAPI/GLAPIENTRY/GLCALLBACK in place of WINGDIAPI/APIENTRY/CALLBACK, */
-/* these are defined in mesa gl/gl.h - tjump@spgs.com */
-
-
-
-extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * );
-#if defined(MESA_DEBUG) && 0
-#define grDrawTriangle fx_sanity_triangle
-#endif
-
-
-/* Define some shorter names for these things.
- */
-#define XCOORD GR_VERTEX_X_OFFSET
-#define YCOORD GR_VERTEX_Y_OFFSET
-#define ZCOORD GR_VERTEX_OOZ_OFFSET
-#define OOWCOORD GR_VERTEX_OOW_OFFSET
-
-#define RCOORD GR_VERTEX_R_OFFSET
-#define GCOORD GR_VERTEX_G_OFFSET
-#define BCOORD GR_VERTEX_B_OFFSET
-#define ACOORD GR_VERTEX_A_OFFSET
-
-#define S0COORD GR_VERTEX_SOW_TMU0_OFFSET
-#define T0COORD GR_VERTEX_TOW_TMU0_OFFSET
-#define S1COORD GR_VERTEX_SOW_TMU1_OFFSET
-#define T1COORD GR_VERTEX_TOW_TMU1_OFFSET
-
-
-#if FX_USE_PARGB
-
-#define CLIP_XCOORD 0 /* normal place */
-#define CLIP_YCOROD 1 /* normal place */
-#define CLIP_ZCOORD 2 /* normal place */
-#define CLIP_WCOORD 3 /* normal place */
-#define CLIP_GCOORD 4 /* GR_VERTEX_PARGB_OFFSET */
-#define CLIP_BCOORD 5 /* GR_VERTEX_SOW_TMU0_OFFSET */
-#define CLIP_RCOORD 6 /* GR_VERTEX_TOW_TMU0_OFFSET */
-#define CLIP_ACOORD 7 /* GR_VERTEX_OOW_TMU0_OFFSET */
-
-#else
-
-#define CLIP_XCOORD 0 /* normal place */
-#define CLIP_YCOROD 1 /* normal place */
-#define CLIP_ZCOORD 2 /* GR_VERTEX_Z_OFFSET */
-#define CLIP_WCOORD 3 /* GR_VERTEX_R_OFFSET */
-#define CLIP_GCOORD 4 /* normal place */
-#define CLIP_BCOORD 5 /* normal place */
-#define CLIP_RCOORD 6 /* GR_VERTEX_OOZ_OFFSET */
-#define CLIP_ACOORD 7 /* normal place */
-
-
-#endif
-
-/* Should have size == 16 * sizeof(float).
- */
-typedef struct {
- GLfloat f[15]; /* Same layout as GrVertex */
- GLubyte mask; /* Unsued */
- GLubyte usermask; /* Unused */
-} fxVertex;
-
-
-
-
-#if defined(FXMESA_USE_ARGB)
-#define FXCOLOR4( c ) ( \
- ( ((unsigned int)(c[3]))<<24 ) | \
- ( ((unsigned int)(c[0]))<<16 ) | \
- ( ((unsigned int)(c[1]))<<8 ) | \
- ( (unsigned int)(c[2])) )
-
-#else
-#ifdef __i386__
-#define FXCOLOR4( c ) (* (int *)c)
-#else
-#define FXCOLOR4( c ) ( \
- ( ((unsigned int)(c[3]))<<24 ) | \
- ( ((unsigned int)(c[2]))<<16 ) | \
- ( ((unsigned int)(c[1]))<<8 ) | \
- ( (unsigned int)(c[0])) )
-#endif
-#endif
-
-
-#define FX_VB_COLOR(fxm, color) \
- do { \
- if (sizeof(GLint) == 4*sizeof(GLubyte)) { \
- if (fxm->constColor != *(GLuint*)color) { \
- fxm->constColor = *(GLuint*)color; \
- FX_grConstantColorValue(FXCOLOR4(color)); \
- } \
- } else { \
- FX_grConstantColorValue(FXCOLOR4(color)); \
- } \
- } while (0)
-
-#define GOURAUD(x) { \
- GLubyte *col = VB->ColorPtr->data[(x)]; \
- gWin[(x)].v.r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
- gWin[(x)].v.g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
- gWin[(x)].v.b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
- gWin[(x)].v.a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
-}
-
-#if FX_USE_PARGB
-#define GOURAUD2(v, c) { \
- GLubyte *col = c; \
- v->argb=MESACOLOR2PARGB(col); \
-}
-#else
-#define GOURAUD2(v, c) { \
- GLubyte *col = c; \
- v->r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]); \
- v->g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]); \
- v->b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]); \
- v->a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]); \
-}
-#endif
-
-
-/* Mergable items first
- */
-#define SETUP_RGBA 0x1
-#define SETUP_TMU0 0x2
-#define SETUP_TMU1 0x4
-#define SETUP_XY 0x8
-#define SETUP_Z 0x10
-#define SETUP_W 0x20
-
-#define MAX_MERGABLE 0x8
-
-
-#define FX_NUM_TMU 2
-
-#define FX_TMU0 GR_TMU0
-#define FX_TMU1 GR_TMU1
-#define FX_TMU_SPLIT 98
-#define FX_TMU_BOTH 99
-#define FX_TMU_NONE 100
-
-/* Used for fxMesa->lastUnitsMode */
-
-#define FX_UM_NONE 0x00000000
-
-#define FX_UM_E0_REPLACE 0x00000001
-#define FX_UM_E0_MODULATE 0x00000002
-#define FX_UM_E0_DECAL 0x00000004
-#define FX_UM_E0_BLEND 0x00000008
-#define FX_UM_E0_ADD 0x00000010
-
-#define FX_UM_E1_REPLACE 0x00000020
-#define FX_UM_E1_MODULATE 0x00000040
-#define FX_UM_E1_DECAL 0x00000080
-#define FX_UM_E1_BLEND 0x00000100
-#define FX_UM_E1_ADD 0x00000200
-
-#define FX_UM_E_ENVMODE 0x000003ff
-
-#define FX_UM_E0_ALPHA 0x00001000
-#define FX_UM_E0_LUMINANCE 0x00002000
-#define FX_UM_E0_LUMINANCE_ALPHA 0x00004000
-#define FX_UM_E0_INTENSITY 0x00008000
-#define FX_UM_E0_RGB 0x00010000
-#define FX_UM_E0_RGBA 0x00020000
-
-#define FX_UM_E1_ALPHA 0x00040000
-#define FX_UM_E1_LUMINANCE 0x00080000
-#define FX_UM_E1_LUMINANCE_ALPHA 0x00100000
-#define FX_UM_E1_INTENSITY 0x00200000
-#define FX_UM_E1_RGB 0x00400000
-#define FX_UM_E1_RGBA 0x00800000
-
-#define FX_UM_E_IFMT 0x00fff000
-
-#define FX_UM_COLOR_ITERATED 0x01000000
-#define FX_UM_COLOR_CONSTANT 0x02000000
-#define FX_UM_ALPHA_ITERATED 0x04000000
-#define FX_UM_ALPHA_CONSTANT 0x08000000
-
-
-#define PACK_BGRA32(R, G, B, A) \
- ( (((GLuint) (R)) << 16) | \
- (((GLuint) (G)) << 8) | \
- (((GLuint) (B)) ) | \
- (((GLuint) (A)) << 24) )
-
-#define PACK_RGBA32(R, G, B, A) \
- ( (((GLuint) (R)) ) | \
- (((GLuint) (G)) << 8) | \
- (((GLuint) (B)) << 16) | \
- (((GLuint) (A)) << 24) )
-
-
-typedef void (*tfxRenderVBFunc)(GLcontext *);
-
-/*
- Memory range from startAddr to endAddr-1
-*/
-typedef struct MemRange_t {
- struct MemRange_t *next;
- FxU32 startAddr, endAddr;
-} MemRange;
-
-typedef struct {
- GLsizei width, height; /* image size */
- GLint texelSize; /* How many bytes to a texel */
- GrTextureFormat_t glideFormat; /* Glide image format */
- unsigned short *data; /* Glide-formated texture image */
-} tfxMipMapLevel;
-
-typedef struct tfxTexInfo_t {
- struct tfxTexInfo *next;
- struct gl_texture_object *tObj;
-
- GLuint lastTimeUsed;
- FxU32 whichTMU;
- GLboolean isInTM;
-
- tfxMipMapLevel mipmapLevel[MAX_TEXTURE_LEVELS];
-
- MemRange *tm[FX_NUM_TMU];
-
- GLint minLevel, maxLevel;
- GLint baseLevelInternalFormat;
-
- GrTexInfo info;
-
- GrTextureFilterMode_t minFilt;
- GrTextureFilterMode_t maxFilt;
- FxBool LODblend;
-
- GrTextureClampMode_t sClamp;
- GrTextureClampMode_t tClamp;
-
- GrMipMapMode_t mmMode;
-
- GLfloat sScale, tScale;
- GLint int_sScale, int_tScale; /* x86 floating point trick for
- * multiplication by powers of 2.
- * Used in fxfasttmp.h
- */
-
- GuTexPalette palette;
-
- GLboolean fixedPalette;
- GLboolean validated;
-} tfxTexInfo;
-
-typedef struct {
- GLuint swapBuffer;
- GLuint reqTexUpload;
- GLuint texUpload;
- GLuint memTexUpload;
-} tfxStats;
-
-
-typedef void (*tfxTriViewClipFunc)( struct vertex_buffer *VB,
- GLuint v[],
- GLubyte mask );
-
-typedef void (*tfxTriClipFunc)( struct vertex_buffer *VB,
- GLuint v[],
- GLuint mask );
-
-
-typedef void (*tfxLineClipFunc)( struct vertex_buffer *VB,
- GLuint v1, GLuint v2,
- GLubyte mask );
-
-
-extern tfxTriViewClipFunc fxTriViewClipTab[0x8];
-extern tfxTriClipFunc fxTriClipStrideTab[0x8];
-extern tfxLineClipFunc fxLineClipTab[0x8];
-
-typedef struct {
- /* Alpha test */
- GLboolean alphaTestEnabled;
- GrCmpFnc_t alphaTestFunc;
- GrAlpha_t alphaTestRefValue;
-
- /* Blend function */
- GLboolean blendEnabled;
- GrAlphaBlendFnc_t blendSrcFuncRGB;
- GrAlphaBlendFnc_t blendDstFuncRGB;
- GrAlphaBlendFnc_t blendSrcFuncAlpha;
- GrAlphaBlendFnc_t blendDstFuncAlpha;
-} tfxUnitsState;
-
-
-
-/* Flags for render_index.
- */
-#define FX_OFFSET 0x1
-#define FX_TWOSIDE 0x2
-#define FX_FRONT_BACK 0x4
-#define FX_FLAT 0x8
-#define FX_ANTIALIAS 0x10
-#define FX_FALLBACK 0x20
-
-
-/* Flags for fxMesa->new_state
- */
-#define FX_NEW_TEXTURING 0x1
-#define FX_NEW_BLEND 0x2
-#define FX_NEW_ALPHA 0x4
-#define FX_NEW_DEPTH 0x8
-#define FX_NEW_FOG 0x10
-#define FX_NEW_SCISSOR 0x20
-#define FX_NEW_COLOR_MASK 0x40
-#define FX_NEW_CULL 0x80
-#define FX_NEW_STENCIL 0x100
-
-/* FX struct stored in VB->driver_data.
- */
-struct tfxMesaVertexBuffer {
- GLvector1ui clipped_elements;
-
- fxVertex *verts;
- fxVertex *last_vert;
- void *vert_store;
-#if defined(FX_GLIDE3)
- GrVertex **triangle_b; /* Triangle buffer */
- GrVertex **strips_b; /* Strips buffer */
-#endif
-
- GLuint size;
-};
-
-#define FX_DRIVER_DATA(vb) ((struct tfxMesaVertexBuffer *)((vb)->driver_data))
-#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
-#define FX_TEXTURE_DATA(t) fxTMGetTexInfo((t)->Current)
-
-#if defined(XFree86Server) || defined(GLX_DIRECT_RENDERING)
-#include "tdfx_init.h"
-#else
-#define DRI_FX_CONTEXT
-#define BEGIN_BOARD_LOCK()
-#define END_BOARD_LOCK()
-#define BEGIN_CLIP_LOOP()
-#define END_CLIP_LOOP()
-#endif
-
-
-/* These lookup table are used to extract RGB values in [0,255] from
- * 16-bit pixel values.
- */
-extern GLubyte FX_PixelToR[0x10000];
-extern GLubyte FX_PixelToG[0x10000];
-extern GLubyte FX_PixelToB[0x10000];
-
-
-struct tfxMesaContext {
- GLcontext *glCtx; /* the core Mesa context */
- GLvisual *glVis; /* describes the color buffer */
- GLframebuffer *glBuffer; /* the ancillary buffers */
-
- GLint board; /* the board used for this context */
- GLint width, height; /* size of color buffer */
-
- GrBuffer_t currentFB;
-
- GLboolean bgrOrder;
- GLuint depthClear;
- GrColor_t color;
- GrColor_t clearC;
- GrAlpha_t clearA;
- GLuint constColor;
- GrCullMode_t cullMode;
-
- tfxUnitsState unitsState;
- tfxUnitsState restoreUnitsState; /* saved during multipass */
-
- GuTexPalette glbPalette;
-
- GLuint tmu_source[FX_NUM_TMU];
- GLuint tex_dest[MAX_TEXTURE_UNITS];
- GLuint setupindex;
- GLuint partial_setup_index;
- GLuint setupdone;
- GLuint mergeindex;
- GLuint mergeinputs;
- GLuint render_index;
- GLuint last_tri_caps;
- GLuint stw_hint_state; /* for grHints */
- GLuint is_in_hardware;
- GLuint new_state;
- GLuint using_fast_path, passes, multipass;
-
- tfxLineClipFunc clip_line;
- tfxTriClipFunc clip_tri_stride;
- tfxTriViewClipFunc view_clip_tri;
-
-
- /* Texture Memory Manager Data */
-
- GLuint texBindNumber;
- GLint tmuSrc;
- GLuint freeTexMem[FX_NUM_TMU];
- MemRange *tmPool;
- MemRange *tmFree[FX_NUM_TMU];
-
- GLenum fogTableMode;
- GLfloat fogDensity;
- GLfloat fogStart, fogEnd;
- GrFog_t *fogTable;
- GLint textureAlign;
-
- /* Acc. functions */
-
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
-
- render_func **RenderVBTables;
-
- render_func *RenderVBClippedTab;
- render_func *RenderVBCulledTab;
- render_func *RenderVBRawTab;
-
-
- tfxStats stats;
-
- void *state;
-
- /* Options */
-
- GLboolean verbose;
- GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
- GLboolean emulateTwoTMUs; /* True if we present 2 tmu's to mesa. */
- GLboolean haveAlphaBuffer;
- GLboolean haveHwStencil;
- GLboolean haveGlobalPaletteTexture;
- GLint swapInterval;
- GLint maxPendingSwapBuffers;
-
- FX_GrContext_t glideContext;
-
- int x_offset;
- int y_offset;
- int y_delta;
- int screen_width;
- int screen_height;
- int initDone;
- int clipMinX;
- int clipMaxX;
- int clipMinY;
- int clipMaxY;
- int needClip;
-
- DRI_FX_CONTEXT
-};
-
-typedef void (*tfxSetupFunc)(struct vertex_buffer *, GLuint, GLuint);
-
-extern GrHwConfiguration glbHWConfig;
-extern int glbCurrentBoard;
-
-extern void fxPrintSetupFlags( const char *msg, GLuint flags );
-extern void fxSetupFXUnits(GLcontext *);
-extern void fxSetupDDPointers(GLcontext *);
-extern void fxDDSetNearFar(GLcontext *, GLfloat, GLfloat);
-
-extern void fxDDSetupInit(void);
-extern void fxDDCvaInit(void);
-extern void fxDDTrifuncInit(void);
-extern void fxDDFastPathInit(void);
-
-extern void fxDDChooseRenderState( GLcontext *ctx );
-
-extern void fxRenderClippedLine( struct vertex_buffer *VB,
- GLuint v1, GLuint v2 );
-
-extern void fxRenderClippedTriangle( struct vertex_buffer *VB,
- GLuint n, GLuint vlist[] );
-
-
-extern tfxSetupFunc fxDDChooseSetupFunction(GLcontext *);
-
-extern points_func fxDDChoosePointsFunction(GLcontext *);
-extern line_func fxDDChooseLineFunction(GLcontext *);
-extern triangle_func fxDDChooseTriangleFunction(GLcontext *);
-extern quad_func fxDDChooseQuadFunction(GLcontext *);
-extern render_func **fxDDChooseRenderVBTables(GLcontext *);
-
-extern void fxDDRenderInit(GLcontext *);
-extern void fxDDClipInit(void);
-
-extern void fxUpdateDDSpanPointers(GLcontext *);
-extern void fxSetupDDSpanPointers(GLcontext *);
-
-extern void fxPrintTextureData(tfxTexInfo *ti);
-extern GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy);
-extern GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
-extern GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level,
- const struct gl_texture_object *texObj,
- GLenum *formatOut, GLenum *typeOut,
- GLboolean *freeImageOut );
-extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
-extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
- GLenum, const GLfloat *);
-extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
-extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
-extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
-extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
-
-extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
-extern void fxDDAlphaFunc(GLcontext *, GLenum, GLclampf);
-extern void fxDDBlendFunc(GLcontext *, GLenum, GLenum);
-
-extern void fxDDRegisterVB( struct vertex_buffer *VB );
-extern void fxDDUnregisterVB( struct vertex_buffer *VB );
-extern void fxDDResizeVB( struct vertex_buffer *VB, GLuint size );
-
-extern void fxDDCheckMergeAndRender( GLcontext *ctx,
- struct gl_pipeline_stage *d );
-
-extern void fxDDMergeAndRender( struct vertex_buffer *VB );
-
-extern void fxDDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d );
-
-extern void fxDDPartialRasterSetup( struct vertex_buffer *VB );
-
-extern void fxDDDoRasterSetup( struct vertex_buffer *VB );
-
-extern GLuint fxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
-
-extern GLboolean fxDDBuildPrecalcPipeline( GLcontext *ctx );
-
-extern void fxDDOptimizePrecalcPipeline( GLcontext *ctx,
- struct gl_pipeline *pipe );
-
-extern void fxDDRenderElementsDirect( struct vertex_buffer *VB );
-extern void fxDDRenderVBIndirectDirect( struct vertex_buffer *VB );
-
-extern void fxDDInitExtensions( GLcontext *ctx );
-
-#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
-extern void fxTMInit(fxMesaContext ctx);
-extern void fxTMClose(fxMesaContext ctx);
-extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
-extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
-extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
-#define fxTMMoveOutTM_NoLock fxTMMoveOutTM
-extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
-extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *, GLint);
-extern void fxTMReloadSubMipMapLevel(fxMesaContext, struct gl_texture_object *,
- GLint, GLint, GLint);
-
-extern void fxTexGetFormat(GLenum, GrTextureFormat_t *, GLint *);
-extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
- float *, float *, int *, int *, int *, int *);
-
-extern void fxDDScissor( GLcontext *ctx,
- GLint x, GLint y, GLsizei w, GLsizei h );
-extern void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params );
-extern GLboolean fxDDColorMask(GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a );
-
-extern void fxDDWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLdepth depth[], const GLubyte mask[]);
-
-extern void fxDDReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLdepth depth[]);
-
-extern void fxDDWriteDepthPixels(GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLdepth depth[], const GLubyte mask[]);
-
-extern void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- GLdepth depth[]);
-
-extern void fxDDFastPath( struct vertex_buffer *VB );
-
-extern void fxDDShadeModel(GLcontext *ctx, GLenum mode);
-
-extern void fxDDCullFace(GLcontext *ctx, GLenum mode);
-extern void fxDDFrontFace(GLcontext *ctx, GLenum mode);
-
-extern void fxPrintRenderState( const char *msg, GLuint state );
-extern void fxPrintHintState( const char *msg, GLuint state );
-
-extern void fxDDDoRenderVB( struct vertex_buffer *VB );
-
-extern int fxDDInitFxMesaContext( fxMesaContext fxMesa );
-
-
-extern void fxSetScissorValues(GLcontext *ctx);
-extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
- struct gl_texture_object *tObj,
- GLint where);
-extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
-
-#endif
diff --git a/xc/extras/Mesa/src/FX/fxfastpath.c b/xc/extras/Mesa/src/FX/fxfastpath.c
deleted file mode 100644
index 605dd8d34..000000000
--- a/xc/extras/Mesa/src/FX/fxfastpath.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-
-#if defined(FX)
-
-#include "types.h"
-#include "cva.h"
-#include "mmath.h"
-#include "fxdrv.h"
-#include "vertices.h"
-#include "X86/common_x86asm.h"
-
-
-#if 0 && defined(__i386__)
-#define NEGATIVE(f) ((*(int *)&f) < 0)
-#define DIFFERENT_SIGNS(a,b) (((*(int *)&a)^(*(int *)&b)) < 0)
-#else
-#define NEGATIVE(f) (f < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#endif
-
-#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
-
-
-#define CLIP(sgn,v,PLANE) \
-if (mask & PLANE) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]].f; \
- GLfloat dpJ = (sgn J[v]) + J[CLIP_WCOORD]; \
- \
- inlist[0] = vlist1; \
- for (i = n = 0 ; i < nr ; i++) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i].f; \
- GLfloat dpI = (sgn I[v]) + I[CLIP_WCOORD]; \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- GLuint j; \
- \
- clipmask[next_vert] = 0; \
- outdata[n++] = next_vert++; \
- \
- for (j = 0 ; j < SIZE ; j += 2) { \
- O[j] = LINTERP(t, I[j], J[j]); \
- O[j+1] = LINTERP(t, I[j+1], J[j+1]); \
- } \
- } \
- \
- clipmask[elt_i] |= PLANE; /* don't set up */ \
- \
- if (!NEGATIVE(dpI)) { \
- outdata[n++] = elt_i; \
- clipmask[elt_i] &= ~PLANE; /* set up after all */ \
- } \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if (n < 3) return; \
-}
-
-#define LINE_CLIP(x,y,z,w,PLANE) \
-if (mask & PLANE) { \
- GLfloat dpI = DOT4V(I,x,y,z,w); \
- GLfloat dpJ = DOT4V(J,x,y,z,w); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- GLuint j; \
- \
- for (j = 0 ; j < SIZE ; j += 2) { \
- O[j] = LINTERP(t, I[j], J[j]); \
- O[j+1] = LINTERP(t, I[j+1], J[j+1]); \
- } \
- \
- clipmask[next_vert] = 0; \
- \
- if (NEGATIVE(dpI)) { \
- clipmask[elts[0]] |= PLANE; \
- I = O; elts[0] = next_vert++; \
- } else { \
- clipmask[elts[1]] |= PLANE; \
- J = O; elts[1] = next_vert++; \
- } \
- } \
- else if (NEGATIVE(dpI)) \
- return; \
-}
-
-
-#define CLIP_POINT( e ) \
- if (mask[e]) \
- *out++ = e
-
-#define CLIP_LINE( e1, e0 ) \
-do { \
- GLubyte ormask = mask[e0] | mask[e1]; \
- out[0] = e1; \
- out[1] = e0; \
- out+=2; \
- if (ormask) { \
- out-=2; \
- if (!(mask[e0] & mask[e1])) { \
- TAG(fx_line_clip)( &out, verts, mask, &next_vert, ormask); \
- } \
- } \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask; \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- out += 3; \
- ormask = mask[e2] | mask[e1] | mask[e0]; \
- if (ormask) { \
- out -= 3; \
- if ( !(mask[e2] & mask[e1] & mask[e0])) { \
- TAG(fx_tri_clip)( &out, verts, mask, &next_vert, ormask ); \
- } \
- } \
-} while (0)
-
-#if defined(FX_V2) || defined(DRIVERTS)
-
-#define VARS_XYZ \
- GLfloat vsx = mat[MAT_SX]; \
- GLfloat vsy = mat[MAT_SY]; \
- GLfloat vsz = mat[MAT_SZ]; \
- GLfloat vtx = mat[MAT_TX]; \
- GLfloat vty = mat[MAT_TY]; \
- GLfloat vtz = mat[MAT_TZ];
-
-#define DO_SETUP_XYZ \
- f[XCOORD] = f[0] * oow * vsx + vtx; \
- f[YCOORD] = f[1] * oow * vsy + vty; \
- f[ZCOORD] = f[2] * oow * vsz + vtz;
-
-#else
-#if defined(HAVE_FAST_MATH)
-
-#define VARS_XYZ \
- GLfloat vsx = mat[MAT_SX]; \
- GLfloat vsy = mat[MAT_SY]; \
- GLfloat vsz = mat[MAT_SZ]; \
- const GLfloat snapper = (3L << 18); \
- GLfloat vtx = mat[MAT_TX] + snapper; \
- GLfloat vty = mat[MAT_TY] + snapper; \
- GLfloat vtz = mat[MAT_TZ];
-
-#define DO_SETUP_XYZ \
- f[XCOORD] = f[0] * oow * vsx + vtx; \
- f[XCOORD] -= snapper; \
- f[YCOORD] = f[1] * oow * vsy + vty; \
- f[YCOORD] -= snapper; \
- f[ZCOORD] = f[2] * oow * vsz + vtz;
-
-#else
-
-#define VARS_XYZ \
- GLfloat vsx = mat[MAT_SX] * 16.0f; \
- GLfloat vsy = mat[MAT_SY] * 16.0f; \
- GLfloat vsz = mat[MAT_SZ]; \
- GLfloat vtx = mat[MAT_TX] * 16.0f; \
- GLfloat vty = mat[MAT_TY] * 16.0f; \
- GLfloat vtz = mat[MAT_TZ];
-
-#define DO_SETUP_XYZ \
- f[XCOORD] = ((int)(f[0]*oow*vsx+vtx)) * (1.0f/16.0f); \
- f[YCOORD] = ((int)(f[1]*oow*vsy+vty)) * (1.0f/16.0f); \
- f[ZCOORD] = f[2]*oow*vsz + vtz;
-
-
-#endif
-#endif
-
-
-
-struct fx_fast_tab
-{
- void (*build_vertices)( struct vertex_buffer *VB, GLuint do_clip );
-
- void (*clip[GL_POLYGON+1])( struct vertex_buffer *VB,
- GLuint start,
- GLuint count,
- GLuint parity );
-
- void (*project_clipped_vertices)( GLfloat *first,
- GLfloat *last,
- const GLfloat *mat,
- GLuint stride,
- const GLubyte *mask );
-
- void (*project_vertices)( GLfloat *first,
- GLfloat *last,
- const GLfloat *mat,
- GLuint stride );
-};
-
-/* Pack either rgba or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_R CLIP_RCOORD
-#define CLIP_G CLIP_GCOORD
-#define CLIP_B CLIP_BCOORD
-#define CLIP_A CLIP_ACOORD
-#define CLIP_S0 4
-#define CLIP_T0 5
-#define CLIP_S1 6
-#define CLIP_T1 7
-
-#define SIZE 4
-#define TYPE (0)
-#define TAG(x) x
-#include "fxfasttmp.h"
-
-#define SIZE 8
-#define TYPE (SETUP_RGBA)
-#define TAG(x) x##_RGBA
-#include "fxfasttmp.h"
-
-#define SIZE 6
-#define TYPE (SETUP_TMU0)
-#define TAG(x) x##_TMU0
-#include "fxfasttmp.h"
-
-#define SIZE 8
-#define TYPE (SETUP_TMU0|SETUP_TMU1)
-#define TAG(x) x##_TMU0_TMU1
-#include "fxfasttmp.h"
-
-#undef CLIP_S1
-#undef CLIP_T1
-#define CLIP_S1 4
-#define CLIP_T1 5
-
-#define SIZE 6
-#define TYPE (SETUP_TMU1)
-#define TAG(x) x##_TMU1
-#include "fxfasttmp.h"
-
-/* These three need to use a full 64 byte clip-space vertex.
- */
-#undef CLIP_S0
-#undef CLIP_T0
-#undef CLIP_S1
-#undef CLIP_T1
-
-#define CLIP_S0 8
-#define CLIP_T0 9
-#define CLIP_S1 10
-#define CLIP_T1 11
-
-#define SIZE 10
-#define TYPE (SETUP_RGBA|SETUP_TMU0)
-#define TAG(x) x##_RGBA_TMU0
-#include "fxfasttmp.h"
-
-#define SIZE 12
-#define TYPE (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
-#define TAG(x) x##_RGBA_TMU0_TMU1
-#include "fxfasttmp.h"
-
-#undef CLIP_S1
-#undef CLIP_T1
-#define CLIP_S1 8
-#define CLIP_T1 9
-
-#define SIZE 10
-#define TYPE (SETUP_RGBA|SETUP_TMU1)
-#define TAG(x) x##_RGBA_TMU1
-#include "fxfasttmp.h"
-
-static struct fx_fast_tab fxFastTab[0x8];
-
-void fxDDFastPathInit()
-{
- fx_init_fastpath( &fxFastTab[0] );
- fx_init_fastpath_RGBA( &fxFastTab[SETUP_RGBA] );
- fx_init_fastpath_TMU0( &fxFastTab[SETUP_TMU0] );
- fx_init_fastpath_TMU1( &fxFastTab[SETUP_TMU1] );
- fx_init_fastpath_RGBA_TMU0( &fxFastTab[SETUP_RGBA|SETUP_TMU0] );
- fx_init_fastpath_RGBA_TMU1( &fxFastTab[SETUP_RGBA|SETUP_TMU1] );
- fx_init_fastpath_TMU0_TMU1( &fxFastTab[SETUP_TMU0|SETUP_TMU1] );
- fx_init_fastpath_RGBA_TMU0_TMU1( &fxFastTab[SETUP_RGBA|SETUP_TMU0|
- SETUP_TMU1] );
-}
-
-
-
-void fxDDFastPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- struct tfxMesaContext *fxMesa = FX_CONTEXT(ctx);
- struct fx_fast_tab *tab = &fxFastTab[fxMesa->setupindex & 0x7];
- GLuint do_clip = 1;
- struct tfxMesaVertexBuffer *fxVB = FX_DRIVER_DATA(VB);
-#ifdef DRIVERTS
- GLfloat tx, ty;
-#endif
-
- fxVertex *first;
- GLfloat *mat = ctx->Viewport.WindowMap.m;
-
- gl_prepare_arrays_cva( VB ); /* still need this */
-
- if (VB->EltPtr->count * 12 > fxVB->size) {
- fxDDResizeVB( VB, VB->EltPtr->count * 12 );
- do_clip = 1;
- }
-
- tab->build_vertices( VB, do_clip ); /* object->clip space */
-
- first = FX_DRIVER_DATA(VB)->verts;
-
-#ifdef DRIVERTS
- tx=mat[MAT_TX];
- ty=mat[MAT_TY];
- mat[MAT_TX]=tx+fxMesa->x_offset;
- mat[MAT_TY]=ty+fxMesa->y_delta;
-#endif
-
- if (VB->ClipOrMask) {
- if (!VB->ClipAndMask) {
- GLubyte tmp = VB->ClipOrMask;
-
- tab->clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* clip */
-
- tab->project_clipped_vertices( fxVB->verts->f,
- fxVB->last_vert->f,
- mat, 16 * 4,
- VB->ClipMask );
-
- ctx->CVA.elt_mode = gl_reduce_prim[prim];
- VB->EltPtr = &(FX_DRIVER_DATA(VB)->clipped_elements);
-
- VB->ClipOrMask = 0;
- fxDDRenderElementsDirect( VB ); /* render using new list */
- VB->ClipOrMask = tmp;
- }
- } else {
- tab->project_vertices( fxVB->verts->f,
- fxVB->last_vert->f,
- mat, 16 * 4 );
-
- fxDDRenderElementsDirect( VB ); /* render using orig list */
- }
-
-#ifdef DRIVERTS
- mat[MAT_TX]=tx;
- mat[MAT_TY]=ty;
-#endif
-
- /* This indicates that there is no cached data to reuse.
- */
- VB->pipeline->data_valid = 0;
- VB->pipeline->pipeline_valid = 0;
-}
-
-
-#else
-
-/*
- * Need this to provide at least one external definition.
- */
-int gl_fxfastpath_dummy(void)
-{
- return 0;
-}
-
-#endif
diff --git a/xc/extras/Mesa/src/FX/fxfasttmp.h b/xc/extras/Mesa/src/FX/fxfasttmp.h
deleted file mode 100644
index f97b8108f..000000000
--- a/xc/extras/Mesa/src/FX/fxfasttmp.h
+++ /dev/null
@@ -1,367 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* Build clip space vertices from object space data.
- */
-static void TAG(fx_setup_full)( struct vertex_buffer *VB, GLuint do_clip )
-{
- GLcontext *ctx = VB->ctx;
- GLfloat *f = (GLfloat *) FX_DRIVER_DATA(VB)->verts;
- fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
- GLuint count = VB->Count;
- GLuint i;
-
- const GLfloat * const m = ctx->ModelProjectMatrix.m;
-
-#if (TYPE & SETUP_RGBA)
- GLubyte *color = (GLubyte *)VB->ColorPtr->data;
- GLuint color_stride = VB->ColorPtr->stride;
-#endif
-
-#if (TYPE & SETUP_TMU0)
- GLuint tmu0_source = fxMesa->tmu_source[0];
- struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];
- GLint s0scale = FX_TEXTURE_DATA(t0)->int_sScale;
- GLint t0scale = FX_TEXTURE_DATA(t0)->int_tScale;
- GLint *tmu0_int_data = (GLint *)VB->TexCoordPtr[tmu0_source]->data;
- GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride;
-#endif
-
-#if (TYPE & SETUP_TMU1)
- GLuint tmu1_source = fxMesa->tmu_source[1];
- struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];
- GLint s1scale = FX_TEXTURE_DATA(t1)->int_sScale;
- GLint t1scale = FX_TEXTURE_DATA(t1)->int_tScale;
- GLint *tmu1_int_data = (GLint *)VB->TexCoordPtr[tmu1_source]->data;
- GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride;
-#endif
-
- (void) fxMesa;
- (void) ctx;
- (void) i;
- (void) f;
-
- /* Use 3 seperate loops because it's easier for assembly. A
- * best-case solution might be to do all three in a single assembly
- * loop.
- */
- gl_xform_points3_v16_general(FX_DRIVER_DATA(VB)->verts[0].f,
- m,
- VB->ObjPtr->start,
- VB->ObjPtr->stride,
- count);
-
- if (do_clip)
- {
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- gl_cliptest_points4_v16(FX_DRIVER_DATA(VB)->verts[0].f,
- FX_DRIVER_DATA(VB)->verts[count].f,
- &(VB->ClipOrMask),
- &(VB->ClipAndMask),
- VB->ClipMask);
- }
-
-
-#if (TYPE)
- for (i = 0 ; i < count ; i++, f += 16) {
-#if (TYPE & SETUP_RGBA)
- GLubyte *col = color; color += color_stride;
- UBYTE_COLOR_TO_FLOAT_255_COLOR2( f[CLIP_R], col[0] );
- UBYTE_COLOR_TO_FLOAT_255_COLOR2( f[CLIP_G], col[1] );
- UBYTE_COLOR_TO_FLOAT_255_COLOR2( f[CLIP_B], col[2] );
- UBYTE_COLOR_TO_FLOAT_255_COLOR2( f[CLIP_A], col[3] );
-#endif
-#if (TYPE & SETUP_TMU0)
- * (int *) &f[CLIP_S0] = s0scale + tmu0_int_data[0];
- * (int *) &f[CLIP_T0] = t0scale + tmu0_int_data[1];
- STRIDE_T(tmu0_int_data, GLint, tmu0_stride);
-#endif
-#if (TYPE & SETUP_TMU1)
- * (int *) &f[CLIP_S1] = s1scale + tmu1_int_data[0];
- * (int *) &f[CLIP_T1] = t1scale + tmu1_int_data[1];
- STRIDE_T(tmu1_int_data, GLint, tmu1_stride);
-#endif
- }
-#endif
-
- FX_DRIVER_DATA(VB)->last_vert = &(FX_DRIVER_DATA(VB)->verts[count]);
-}
-
-
-/* Do viewport map, device scale and perspective projection.
- *
- * Rearrange fxVertices to look like grVertices.
- */
-static void TAG(fx_project_vertices)( GLfloat *first,
- GLfloat *last,
- const GLfloat *mat,
- GLuint stride )
-{
- GLfloat *f;
- VARS_XYZ;
-
- for ( f = first ; f != last ; STRIDE_F(f, stride))
- {
- GLfloat oow = 1.0f/f[CLIP_WCOORD]; /* urp! */
-
-#if FX_USE_PARGB
- if (TYPE & SETUP_RGBA) {
- PACK_4F_ARGB(GET_PARGB(f),f[CLIP_A],f[CLIP_R],f[CLIP_G],f[CLIP_B]);
- }
-#else
- if (TYPE & SETUP_RGBA) {
- f[RCOORD]=f[CLIP_R];
- }
-#endif
- if (TYPE & SETUP_TMU1) {
- f[S1COORD] = f[CLIP_S1] * oow;
- f[T1COORD] = f[CLIP_T1] * oow;
- }
-
- if (TYPE & SETUP_TMU0) {
- f[T0COORD] = f[CLIP_T0] * oow;
- f[S0COORD] = f[CLIP_S0] * oow;
- }
-
- DO_SETUP_XYZ;
-
- f[OOWCOORD] = oow;
- }
-}
-
-static void TAG(fx_project_clipped_vertices)( GLfloat *first,
- GLfloat *last,
- const GLfloat *mat,
- GLuint stride,
- const GLubyte *mask )
-{
- GLfloat *f;
- VARS_XYZ;
-
- for ( f = first ; f != last ; STRIDE_F(f, stride), mask++) {
- if (!*mask) {
-
- GLfloat oow = 1.0f / f[CLIP_WCOORD];
-#if FX_USE_PARGB
- if (TYPE & SETUP_RGBA) {
- const GLuint r = f[CLIP_R];
- const GLuint g = f[CLIP_G];
- const GLuint b = f[CLIP_B];
- const GLuint a = f[CLIP_A];
- /* ToDo Optimize */
- GET_PARGB(f) = a << 24 | r << 16 | g << 8 | b;
- }
-#else
- if (TYPE & SETUP_RGBA) {
- f[RCOORD]=f[CLIP_R];
- }
-#endif
-
- if (TYPE & SETUP_TMU1) {
- f[S1COORD] = f[CLIP_S1] * oow;
- f[T1COORD] = f[CLIP_T1] * oow;
- }
-
- if (TYPE & SETUP_TMU0) {
- f[T0COORD] = f[CLIP_T0] * oow;
- f[S0COORD] = f[CLIP_S0] * oow;
- }
-
- DO_SETUP_XYZ;
-
- f[OOWCOORD] = oow;
- }
- }
-}
-
-
-static
-#if (SIZE <= 8)
-INLINE
-#endif
-void TAG(fx_tri_clip)( GLuint **p_elts,
- fxVertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask )
-{
- GLuint *elts = *p_elts;
- GLuint next_vert = *p_next_vert;
- GLuint vlist1[VB_MAX_CLIPPED_VERTS];
- GLuint vlist2[VB_MAX_CLIPPED_VERTS];
- GLuint *inlist[2];
- GLuint *out;
- GLuint in = 0;
- GLuint n = 3;
- GLuint i;
-
- inlist[0] = elts;
- inlist[1] = vlist2;
-
- CLIP(-,0,CLIP_RIGHT_BIT);
- CLIP(+,0,CLIP_LEFT_BIT);
- CLIP(-,1,CLIP_TOP_BIT);
- CLIP(+,1,CLIP_BOTTOM_BIT);
- CLIP(-,2,CLIP_FAR_BIT);
- CLIP(+,2,CLIP_NEAR_BIT);
-
- /* Convert the planar polygon to a list of triangles.
- */
- out = inlist[in];
-
- for (i = 2 ; i < n ; i++) {
- elts[0] = out[0];
- elts[1] = out[i-1];
- elts[2] = out[i];
- elts += 3;
- }
-
- *p_next_vert = next_vert;
- *p_elts = elts;
-}
-
-
-static INLINE void TAG(fx_line_clip)( GLuint **p_elts,
- fxVertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask )
-{
- GLuint *elts = *p_elts;
- GLfloat *I = verts[elts[0]].f;
- GLfloat *J = verts[elts[1]].f;
- GLuint next_vert = *p_next_vert;
-
- LINE_CLIP(1,0,0,-1,CLIP_LEFT_BIT);
- LINE_CLIP(-1,0,0,1,CLIP_RIGHT_BIT);
- LINE_CLIP(0,1,0,-1,CLIP_TOP_BIT);
- LINE_CLIP(0,-1,0,1,CLIP_BOTTOM_BIT);
- LINE_CLIP(0,0,1,-1,CLIP_FAR_BIT);
- LINE_CLIP(0,0,-1,1,CLIP_NEAR_BIT);
-
- *p_next_vert = next_vert;
- *p_elts += 2;
-}
-
-
-/* Build a table of functions to clip each primitive type.
- */
-#define LOCAL_VARS \
- GLuint *elt = VB->EltPtr->data; \
- fxVertex *verts = FX_DRIVER_DATA(VB)->verts; \
- GLuint next_vert = VB->Count; \
- GLuint *out = FX_DRIVER_DATA(VB)->clipped_elements.data; \
- GLubyte *mask = VB->ClipMask; \
-
-
-#define POSTFIX \
- FX_DRIVER_DATA(VB)->clipped_elements.count = \
- out - FX_DRIVER_DATA(VB)->clipped_elements.data; \
- FX_DRIVER_DATA(VB)->last_vert = &verts[next_vert];
-
-#define INIT(x)
-
-#define RENDER_POINTS(start, count) \
-do { \
- GLuint i; \
- for (i = start ; i < count ; i++ ) \
- CLIP_POINT( elt[i] ); \
-} while (0)
-
-#define RENDER_LINE(i1, i0) \
- CLIP_LINE(elt[i1], elt[i0])
-
-#define RENDER_TRI(i2, i1, i0, pv, parroty) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if (parroty) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD(i3, i2, i1, i0, pv) \
- CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]); \
- CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0])
-
-#define PRESERVE_TAG
-#include "render_tmp.h"
-
-
-static void TAG(fx_init_fastpath)( struct fx_fast_tab *tab )
-{
- GLuint i;
-
- /* Use the render templates to do clipping.
- */
- TAG(render_init)();
- for (i = 0 ; i < GL_POLYGON+2 ; i++)
- tab->clip[i] = TAG(render_tab)[i];
-
- tab->build_vertices = TAG(fx_setup_full);
- tab->project_vertices = TAG(fx_project_vertices);
- tab->project_clipped_vertices = TAG(fx_project_clipped_vertices);
-
-#if defined(USE_3DNOW_ASM)
- if (gl_x86_cpu_features & GL_CPU_3Dnow) {
- extern void TAG(fx_3dnow_project_vertices)( GLfloat *first,
- GLfloat *last,
- const GLfloat *mat,
- GLuint stride );
-
- extern void TAG(fx_3dnow_project_clipped_vertices)( GLfloat *first,
- GLfloat *last,
- const GLfloat *mat,
- GLuint stride,
- const GLubyte *mask );
-
- tab->project_vertices = TAG(fx_3dnow_project_vertices);
- tab->project_clipped_vertices = TAG(fx_3dnow_project_clipped_vertices);
- }
-#endif
-}
-
-#undef TYPE
-#undef TAG
-#undef SIZE
diff --git a/xc/extras/Mesa/src/FX/fxglidew.c b/xc/extras/Mesa/src/FX/fxglidew.c
deleted file mode 100644
index f01644a60..000000000
--- a/xc/extras/Mesa/src/FX/fxglidew.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-#include "glide.h"
-#include "fxglidew.h"
-#include "fxdrv.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-
-grStencilFunc_t grStencilFuncPtr = NULL;
-grStencilMask_t grStencilMaskPtr = NULL;
-grStencilOp_t grStencilOpPtr = NULL;
-grBufferClearExt_t grBufferClearExtPtr = NULL;
-
-
-FxI32 FX_grGetInteger_NoLock(FxU32 pname)
-{
-#if !defined(FX_GLIDE3)
- switch (pname)
- {
- case FX_FOG_TABLE_ENTRIES:
- return GR_FOG_TABLE_SIZE;
- case FX_GLIDE_STATE_SIZE:
- return sizeof(GrState);
- case FX_LFB_PIXEL_PIPE:
- return FXFALSE;
- case FX_PENDING_BUFFERSWAPS:
- return grBufferNumPending();
- case FX_TEXTURE_ALIGN:
- /* This is a guess from reading the glide3 docs */
- return 8;
- case FX_ZDEPTH_MAX:
- return 0xFFFF;
- default:
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
- }
- return -1;
- }
-#else
- FxU32 grname;
- FxI32 result;
-
- switch (pname)
- {
- case FX_FOG_TABLE_ENTRIES:
- case FX_GLIDE_STATE_SIZE:
- case FX_LFB_PIXEL_PIPE:
- case FX_PENDING_BUFFERSWAPS:
- case FX_TEXTURE_ALIGN:
- grname = pname;
- break;
- case FX_ZDEPTH_MAX: {
- int zvals[2];
-
- grGet(GR_ZDEPTH_MIN_MAX, 8, zvals);
- return zvals[0];
- }
- default:
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
- }
- return -1;
- }
-
- grGet(grname,4,&result);
- return result;
-#endif
-}
-
-FxI32 FX_grGetInteger(FxU32 pname)
-{
- int result;
-
- BEGIN_BOARD_LOCK();
- result=FX_grGetInteger_NoLock(pname);
- END_BOARD_LOCK();
- return result;
-}
-
-
-FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
- GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
- FxBool pixelPipeline, GrLfbInfo_t *info ) {
- FxBool result;
-
- BEGIN_BOARD_LOCK();
- result=grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
- END_BOARD_LOCK();
- return result;
-}
-
-FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info) {
- FxU32 result;
-
- BEGIN_BOARD_LOCK();
- result=grTexTextureMemRequired(evenOdd, info);
- END_BOARD_LOCK();
- return result;
-}
-
-FxU32 FX_grTexMinAddress(GrChipID_t tmu) {
- FxU32 result;
-
- BEGIN_BOARD_LOCK();
- result=grTexMinAddress(tmu);
- END_BOARD_LOCK();
- return result;
-}
-
-extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) {
- FxU32 result;
-
- BEGIN_BOARD_LOCK();
- result=grTexMaxAddress(tmu);
- END_BOARD_LOCK();
- return result;
-}
-
-FxBool FX_grSstControl(FxU32 code)
-{
-#if defined(FX_GLIDE3)
- /* The glide 3 sources call for grEnable/grDisable to be called in exchange
- * for grSstControl. */
- switch(code) {
- case GR_CONTROL_ACTIVATE:
- grEnable(GR_PASSTHRU);
- break;
- case GR_CONTROL_DEACTIVATE:
- grDisable(GR_PASSTHRU);
- break;
- }
- /* Appearently GR_CONTROL_RESIZE can be ignored. */
- return 1; /* OK? */
-#else
- FxU32 result;
- BEGIN_BOARD_LOCK();
- result = grSstControl(code);
- END_BOARD_LOCK();
- return result;
-#endif
-}
-
-
-#if defined(FX_GLIDE3)
-
-void FX_grGammaCorrectionValue(float val)
-{
- (void)val;
-/* ToDo */
-}
-
-int FX_getFogTableSize(void)
-{
- int result;
- BEGIN_BOARD_LOCK();
- grGet(GR_FOG_TABLE_ENTRIES,sizeof(int),(void*)&result);
- END_BOARD_LOCK();
- return result;
-}
-
-int FX_getGrStateSize(void)
-{
- int result;
- BEGIN_BOARD_LOCK();
- grGet(GR_GLIDE_STATE_SIZE,sizeof(int),(void*)&result);
- END_BOARD_LOCK();
-
- return result;
-
-}
-
-int FX_grSstScreenWidth()
-{
- FxI32 result[4];
-
- BEGIN_BOARD_LOCK();
- grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
- END_BOARD_LOCK();
-
- return result[2];
-}
-
-int FX_grSstScreenHeight()
-{
- FxI32 result[4];
-
- BEGIN_BOARD_LOCK();
- grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
- END_BOARD_LOCK();
-
- return result[3];
-}
-
-void FX_grGlideGetVersion(char *buf)
-{
- BEGIN_BOARD_LOCK();
- strcpy(buf,grGetString(GR_VERSION));
- END_BOARD_LOCK();
-}
-
-void FX_grSstPerfStats(GrSstPerfStats_t *st)
-{
- FxI32 n;
- grGet(GR_STATS_PIXELS_IN, 4, &n); st->pixelsIn = n;
- grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n); st->chromaFail = n;
- grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n); st->zFuncFail = n;
- grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n); st->aFuncFail = n;
- grGet(GR_STATS_PIXELS_OUT, 4, &n); st->pixelsOut = n;
-}
-
-void FX_grAADrawLine(GrVertex *a,GrVertex *b)
-{
- /* ToDo */
- BEGIN_CLIP_LOOP();
- grDrawLine(a,b);
- END_CLIP_LOOP();
-}
-
-void FX_grAADrawPoint(GrVertex *a)
-{
- BEGIN_CLIP_LOOP();
- grDrawPoint(a);
- END_CLIP_LOOP();
-}
-
-void FX_grDrawPolygonVertexList(int n, GrVertex *verts)
-{
- BEGIN_CLIP_LOOP();
- grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
- END_CLIP_LOOP();
-}
-
-#if FX_USE_PARGB
-void FX_setupGrVertexLayout(void)
-{
- BEGIN_BOARD_LOCK();
- grReset(GR_VERTEX_PARAMETER);
-
- grCoordinateSpace(GR_WINDOW_COORDS);
- grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- END_BOARD_LOCK();
-}
-#else /* FX_USE_PARGB */
-void FX_setupGrVertexLayout(void)
-{
- BEGIN_BOARD_LOCK();
- grReset(GR_VERTEX_PARAMETER);
-
- grCoordinateSpace(GR_WINDOW_COORDS);
- grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- END_BOARD_LOCK();
-}
-#endif
-
-void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
-{
- switch(hintType) {
- case GR_HINT_STWHINT:
- {
- if (hintMask & GR_STWHINT_W_DIFF_TMU0)
- grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- else
- grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
-
- if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
- grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
- else
- grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
-
- if (hintMask & GR_STWHINT_W_DIFF_TMU1)
- grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
- else
- grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
-
- }
- }
-}
-
-void FX_grHints(GrHint_t hintType, FxU32 hintMask) {
- BEGIN_BOARD_LOCK();
- FX_grHints_NoLock(hintType, hintMask);
- END_BOARD_LOCK();
-}
-
-int FX_grSstQueryHardware(GrHwConfiguration *config)
-{
- int i,j;
- int numFB;
-
- BEGIN_BOARD_LOCK();
- grGet(GR_NUM_BOARDS,4,(void*)&(config->num_sst));
- if (config->num_sst == 0)
- return 0;
- for (i = 0; i< config->num_sst; i++)
- {
- config->SSTs[i].type = GR_SSTTYPE_VOODOO;
- grSstSelect(i);
- grGet(GR_MEMORY_FB,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.fbRam));
- config->SSTs[i].sstBoard.VoodooConfig.fbRam/= 1024*1024;
-
- grGet(GR_NUM_TMU,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.nTexelfx));
-
-
- grGet(GR_NUM_FB,4,(void*)&numFB);
- if (numFB > 1)
- config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXTRUE;
- else
- config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXFALSE;
- for (j = 0; j < config->SSTs[i].sstBoard.VoodooConfig.nTexelfx; j++)
- {
- grGet(GR_MEMORY_TMU,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam));
- config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam /= 1024*1024;
- }
- }
- END_BOARD_LOCK();
- return 1;
-}
-
-#else
-
-int FX_grSstScreenWidth()
-{
- int i;
- BEGIN_BOARD_LOCK();
- i = grSstScreenWidth();
- END_BOARD_LOCK();
- return i;
-}
-
-int FX_grSstScreenHeight()
-{
- int i;
- BEGIN_BOARD_LOCK();
- i = grSstScreenHeight();
- END_BOARD_LOCK();
- return i;
-}
-
-int FX_grSstQueryHardware(GrHwConfiguration *c)
-{
- int i;
- BEGIN_BOARD_LOCK();
- i = grSstQueryHardware(c);
- END_BOARD_LOCK();
- return i;
-}
-
-
-#endif /* FX_GLIDE3 */
-
-/* It appears to me that this function is needed either way. */
-FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
- GrScreenResolution_t screen_resolution,
- GrScreenRefresh_t refresh_rate,
- GrColorFormat_t color_format,
- GrOriginLocation_t origin_location,
- int nColBuffers,
- int nAuxBuffers)
-{
- FX_GrContext_t i;
- BEGIN_BOARD_LOCK();
- i = grSstWinOpen( hWnd,
- screen_resolution,
- refresh_rate,
- color_format,
- origin_location,
- nColBuffers,
- nAuxBuffers );
-
- /*
- fprintf(stderr,
- "grSstWinOpen( win %d res %d ref %d fmt %d\n"
- " org %d ncol %d naux %d )\n"
- " ==> %d\n",
- hWnd,
- screen_resolution,
- refresh_rate,
- color_format,
- origin_location,
- nColBuffers,
- nAuxBuffers,
- i);
- */
- END_BOARD_LOCK();
- return i;
-}
-
-
-
-#else
-
-/*
- * Need this to provide at least one external definition.
- */
-
-int gl_fx_dummy_function_glidew(void)
-{
- return 0;
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxglidew.h b/xc/extras/Mesa/src/FX/fxglidew.h
deleted file mode 100644
index 4ad2942af..000000000
--- a/xc/extras/Mesa/src/FX/fxglidew.h
+++ /dev/null
@@ -1,938 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifndef __FX_GLIDE_WARPER__
-#define __FX_GLIDE_WARPER__
-
-#include <glide.h>
-#include <g3ext.h>
-
-/*
- * These are glide extension definitions. These are not
- * defined in glide.h. They should really be defined in
- * g3ext.h, but they are not.
- */
-#if 0
-FX_ENTRY void FX_CALL
-grStencilFunc(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
-
-FX_ENTRY void FX_CALL
-grStencilMask(GrStencil_t write_mask);
-
-FX_ENTRY void FX_CALL
-grStencilOp(
- GrStencilOp_t stencil_fail,
- GrStencilOp_t depth_fail,
- GrStencilOp_t depth_pass);
-
-FX_ENTRY void FX_CALL
-grBufferClearExt(
- GrColor_t color,
- GrAlpha_t alpha,
- FxU32 depth,
- GrStencil_t stencil);
-#endif
-
-
-typedef void (*grStencilFunc_t)(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
-typedef void (*grStencilMask_t)(GrStencil_t write_mask);
-typedef void (*grStencilOp_t)(GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass);
-typedef void (*grBufferClearExt_t)(GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil);
-
-extern grStencilFunc_t grStencilFuncPtr;
-extern grStencilMask_t grStencilMaskPtr;
-extern grStencilOp_t grStencilOpPtr;
-extern grBufferClearExt_t grBufferClearExtPtr;
-
-
-FX_ENTRY void FX_CALL
-grEnable(GrEnableMode_t mode);
-
-FX_ENTRY void FX_CALL
-grEnable(GrEnableMode_t mode);
-/*
- * General context:
- */
-#if !defined(FX_GLIDE3)
- typedef FxU32 FX_GrContext_t; /* Not used in Glide2 */
-#else
- typedef GrContext_t FX_GrContext_t;
-#endif
-
-/*
- * Glide3 emulation on Glide2:
- */
-#if !defined(FX_GLIDE3)
- /* Constanst for FX_grGetInteger( ) */
- #define FX_FOG_TABLE_ENTRIES 0x0004 /* The number of entries in the hardware fog table. */
- #define FX_GLIDE_STATE_SIZE 0x0006 /* Size of buffer, in bytes, needed to save Glide state. */
- #define FX_LFB_PIXEL_PIPE 0x0009 /* 1 if LFB writes can go through the 3D pixel pipe. */
- #define FX_PENDING_BUFFERSWAPS 0x0014 /* The number of buffer swaps pending. */
- #define FX_TEXTURE_ALIGN 0x0024 /* The required alignment for textures */
-#else
- #define FX_FOG_TABLE_ENTRIES GR_FOG_TABLE_ENTRIES
- #define FX_GLIDE_STATE_SIZE GR_GLIDE_STATE_SIZE
- #define FX_LFB_PIXEL_PIPE GR_LFB_PIXEL_PIPE
- #define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS
- #define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN
-#endif
-#define FX_ZDEPTH_MAX 0x100
-
-/*
- * Genral warper functions for Glide2/Glide3:
- */
-extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
-extern FxI32 FX_grGetInteger(FxU32 pname);
-
-/*
- * Glide2 emulation on Glide3:
- */
-#if defined(FX_GLIDE3)
-
-#define GR_ASPECT_1x1 GR_ASPECT_LOG2_1x1
-#define GR_ASPECT_2x1 GR_ASPECT_LOG2_2x1
-#define GR_ASPECT_4x1 GR_ASPECT_LOG2_4x1
-#define GR_ASPECT_8x1 GR_ASPECT_LOG2_8x1
-#define GR_ASPECT_1x2 GR_ASPECT_LOG2_1x2
-#define GR_ASPECT_1x4 GR_ASPECT_LOG2_1x4
-#define GR_ASPECT_1x8 GR_ASPECT_LOG2_1x8
-
-#define GR_LOD_256 GR_LOD_LOG2_256
-#define GR_LOD_128 GR_LOD_LOG2_128
-#define GR_LOD_64 GR_LOD_LOG2_64
-#define GR_LOD_32 GR_LOD_LOG2_32
-#define GR_LOD_16 GR_LOD_LOG2_16
-#define GR_LOD_8 GR_LOD_LOG2_8
-#define GR_LOD_4 GR_LOD_LOG2_4
-#define GR_LOD_2 GR_LOD_LOG2_2
-#define GR_LOD_1 GR_LOD_LOG2_1
-
-#define GR_FOG_WITH_TABLE GR_FOG_WITH_TABLE_ON_Q
-
-typedef int GrSstType;
-
-#define MAX_NUM_SST 4
-
-#define GR_SSTTYPE_VOODOO 0
-#define GR_SSTTYPE_SST96 1
-#define GR_SSTTYPE_AT3D 2
-#define GR_SSTTYPE_Voodoo2 3
-
-typedef struct GrTMUConfig_St {
- int tmuRev; /* Rev of Texelfx chip */
- int tmuRam; /* 1, 2, or 4 MB */
-} GrTMUConfig_t;
-
-typedef struct GrVoodooConfig_St {
- int fbRam; /* 1, 2, or 4 MB */
- int fbiRev; /* Rev of Pixelfx chip */
- int nTexelfx; /* How many texelFX chips are there? */
- FxBool sliDetect; /* Is it a scan-line interleaved board? */
- GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
-} GrVoodooConfig_t;
-
-typedef struct GrSst96Config_St {
- int fbRam; /* How much? */
- int nTexelfx;
- GrTMUConfig_t tmuConfig;
-} GrSst96Config_t;
-
-typedef GrVoodooConfig_t GrVoodoo2Config_t;
-
-typedef struct GrAT3DConfig_St {
- int rev;
-} GrAT3DConfig_t;
-
-typedef struct {
- int num_sst; /* # of HW units in the system */
- struct {
- GrSstType type; /* Which hardware is it? */
- union SstBoard_u {
- GrVoodooConfig_t VoodooConfig;
- GrSst96Config_t SST96Config;
- GrAT3DConfig_t AT3DConfig;
- GrVoodoo2Config_t Voodoo2Config;
- } sstBoard;
- } SSTs[MAX_NUM_SST]; /* configuration for each board */
-} GrHwConfiguration;
-
-typedef FxU32 GrHint_t;
-#define GR_HINTTYPE_MIN 0
-#define GR_HINT_STWHINT 0
-
-typedef FxU32 GrSTWHint_t;
-#define GR_STWHINT_W_DIFF_FBI FXBIT(0)
-#define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
-#define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
-#define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
-#define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
-#define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
-#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
-
-#define GR_CONTROL_ACTIVATE 1
-#define GR_CONTROL_DEACTIVATE 0
-
-#define GrState void
-
-/*
-** move the vertex layout defintion to application
-*/
-typedef struct {
- float sow; /* s texture ordinate (s over w) */
- float tow; /* t texture ordinate (t over w) */
- float oow; /* 1/w (used mipmapping - really 0xfff/w) */
-} GrTmuVertex;
-
-
-#if FX_USE_PARGB
-
-typedef struct
-{
- float x, y; /* X and Y in screen space */
- float ooz; /* 65535/Z (used for Z-buffering) */
- float oow; /* 1/W (used for W-buffering, texturing) */
- FxU32 argb; /* R, G, B, A [0..255.0] */
- GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
- float z; /* Z is ignored */
-} GrVertex;
-
-#define GR_VERTEX_X_OFFSET 0
-#define GR_VERTEX_Y_OFFSET 1
-#define GR_VERTEX_OOZ_OFFSET 2
-#define GR_VERTEX_OOW_OFFSET 3
-#define GR_VERTEX_PARGB_OFFSET 4
-#define GR_VERTEX_SOW_TMU0_OFFSET 5
-#define GR_VERTEX_TOW_TMU0_OFFSET 6
-#define GR_VERTEX_OOW_TMU0_OFFSET 7
-#define GR_VERTEX_SOW_TMU1_OFFSET 8
-#define GR_VERTEX_TOW_TMU1_OFFSET 9
-#define GR_VERTEX_OOW_TMU1_OFFSET 10
-#define GR_VERTEX_Z_OFFSET 11
-
-#define GET_PARGB(v) ((FxU32*)(v))[GR_VERTEX_PARGB_OFFSET]
-/* GET_PA: returns the alpha component */
-#if GLIDE_ENDIAN == GLIDE_ENDIAN_BIG
- #define GET_PA(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4]
-#else
- #define GET_PA(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
-#endif
-#define MESACOLOR2PARGB(c) (c[ACOMP] << 24 | c[GCOMP] << 16 | c[GCOMP] << 8 | c[BCOMP])
-#define PACK_4F_ARGB(dest,a,r,g,b) { \
- const GLuint cr = (int)r; \
- const GLuint cg = (int)g; \
- const GLuint ca = (int)a; \
- const GLuint cb = (int)b; \
- dest = ca << 24 | cr << 16 | cg << 8 | cb; \
- }
-
-#else /* FX_USE_PARGB */
-
-typedef struct
-{
- float x, y, z; /* X, Y, and Z of scrn space -- Z is ignored */
- float r, g, b; /* R, G, B, ([0..255.0]) */
- float ooz; /* 65535/Z (used for Z-buffering) */
- float a; /* Alpha [0..255.0] */
- float oow; /* 1/W (used for W-buffering, texturing) */
- GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
-} GrVertex;
-
-#define GR_VERTEX_X_OFFSET 0
-#define GR_VERTEX_Y_OFFSET 1
-#define GR_VERTEX_Z_OFFSET 2
-#define GR_VERTEX_R_OFFSET 3
-#define GR_VERTEX_G_OFFSET 4
-#define GR_VERTEX_B_OFFSET 5
-#define GR_VERTEX_OOZ_OFFSET 6
-#define GR_VERTEX_A_OFFSET 7
-#define GR_VERTEX_OOW_OFFSET 8
-#define GR_VERTEX_SOW_TMU0_OFFSET 9
-#define GR_VERTEX_TOW_TMU0_OFFSET 10
-#define GR_VERTEX_OOW_TMU0_OFFSET 11
-#define GR_VERTEX_SOW_TMU1_OFFSET 12
-#define GR_VERTEX_TOW_TMU1_OFFSET 13
-#define GR_VERTEX_OOW_TMU1_OFFSET 14
-#endif /* FX_USE_PARGB */
-
-#endif
-
-/*
- * Glide2 functions for Glide3
- */
-#if defined(FX_GLIDE3)
-#define FX_grTexDownloadTable(TMU,type,data) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexDownloadTable(type,data); \
- END_BOARD_LOCK(); \
- } while (0);
-#define FX_grTexDownloadTable_NoLock(TMU,type,data) \
- grTexDownloadTable(type, data)
-#else
-#define FX_grTexDownloadTable(TMU,type,data) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexDownloadTable(TMU,type,data); \
- END_BOARD_LOCK(); \
- } while (0);
-#define FX_grTexDownloadTable_NoLock grTexDownloadTable
-#endif
-
-/*
- * Flush
- */
-#if defined(FX_GLIDE3)
-#define FX_grFlush() \
- do { \
- BEGIN_BOARD_LOCK(); \
- grFlush(); \
- END_BOARD_LOCK(); \
- } while (0)
-#else
-#define FX_grFlush() \
- do { \
- BEGIN_BOARD_LOCK(); \
- grSstIdle(); \
- END_BOARD_LOCK(); \
- } while (0)
-#endif
-
-#define FX_grFinish() \
- do { \
- BEGIN_BOARD_LOCK(); \
- grFinish(); \
- END_BOARD_LOCK(); \
- } while (0)
-
-/*
- * Write region: ToDo possible exploit the PixelPipe parameter.
- */
-#if defined(FX_GLIDE3)
-#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
- END_BOARD_LOCK(); \
- } while(0)
-#else
-#define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data); \
- END_BOARD_LOCK(); \
- } while (0)
-#endif
-
-/*
- * Read region
- */
-#define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
- END_BOARD_LOCK(); \
- } while (0);
-
-/*
- * Draw triangle
- */
-#define FX_grDrawTriangle(a,b,c) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grDrawTriangle(a,b,c); \
- END_CLIP_LOOP(); \
- } while (0)
-
-/*
- * For Lod/LodLog2 conversion.
- */
-#if defined(FX_GLIDE3)
- #define FX_largeLodLog2(info) (info).largeLodLog2
-#else
- #define FX_largeLodLog2(info) (info).largeLod
-#endif
-
-#if defined(FX_GLIDE3)
- #define FX_aspectRatioLog2(info) (info).aspectRatioLog2
-#else
- #define FX_aspectRatioLog2(info) (info).aspectRatio
-#endif
-
-#if defined(FX_GLIDE3)
- #define FX_smallLodLog2(info) (info).smallLodLog2
-#else
- #define FX_smallLodLog2(info) (info).smallLod
-#endif
-
-#if defined(FX_GLIDE3)
- #define FX_lodToValue(val) ((int)(GR_LOD_256-val))
-#else
- #define FX_lodToValue(val) ((int)(val))
-#endif
-
-#if defined(FX_GLIDE3)
- #define FX_largeLodValue(info) ((int)(GR_LOD_256-(info).largeLodLog2))
-#else
- #define FX_largeLodValue(info) ((int)(info).largeLod)
-#endif
-#define FX_largeLodValue_NoLock FX_largeLodValue
-
-#if defined(FX_GLIDE3)
- #define FX_smallLodValue(info) ((int)(GR_LOD_256-(info).smallLodLog2))
-#else
- #define FX_smallLodValue(info) ((int)(info).smallLod)
-#endif
-#define FX_smallLodValue_NoLock FX_smallLodValue
-
-#if defined(FX_GLIDE3)
- #define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_256-val))
-#else
- #define FX_valueToLod(val) ((GrLOD_t)(val))
-#endif
-
-/*
- * ScreenWidth/Height stuff.
- */
- extern int FX_grSstScreenWidth(void);
- extern int FX_grSstScreenHeight(void);
-
-
-
-/*
- * Version string.
- */
-#if defined(FX_GLIDE3)
- extern void FX_grGlideGetVersion(char *buf);
-#else
- #define FX_grGlideGetVersion(b) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grGlideGetVersion(b); \
- END_BOARD_LOCK(); \
- } while (0)
-#endif
-/*
- * Performance statistics
- */
-#if defined(FX_GLIDE3)
- extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
-#else
- #define FX_grSstPerfStats(s) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grSstPerfStats(s); \
- END_BOARD_LOCK(); \
- } while (0)
-#endif
-
-/*
- * Hardware Query
- */
- extern int FX_grSstQueryHardware(GrHwConfiguration *config);
-
-/*
- * GrHints
- */
-#if defined(FX_GLIDE3)
- extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
- extern void FX_grHints(GrHint_t hintType, FxU32 hintMask);
-#else
- #define FX_grHints(t,m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grHints(t, m); \
- END_BOARD_LOCK(); \
- } while(0)
- #define FX_grHints_NoLock grHints
-#endif
-/*
- * Antialiashed line+point drawing.
- */
-#if defined(FX_GLIDE3)
- extern void FX_grAADrawLine(GrVertex *a,GrVertex *b);
-#else
- #define FX_grAADrawLine(a,b) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grAADrawLine(a,b); \
- END_CLIP_LOOP(); \
- } while (0)
-#endif
-
-#if defined(FX_GLIDE3)
- extern void FX_grAADrawPoint(GrVertex *a);
-#else
- #define FX_grAADrawPoint(a) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grAADrawPoint(a); \
- END_CLIP_LOOP(); \
- } while (0)
-#endif
-
-/*
- * Needed for Glide3 only, to set up Glide2 compatible vertex layout.
- */
-#if defined(FX_GLIDE3)
- extern void FX_setupGrVertexLayout(void);
-#else
- #define FX_setupGrVertexLayout() do {} while (0)
-#endif
-/*
- * grSstControl stuff
- */
-extern FxBool FX_grSstControl(FxU32 code);
-
-/*
- * grGammaCorrectionValue
- */
-#if defined(FX_GLIDE3)
- extern void FX_grGammaCorrectionValue(float val);
-#else
- #define FX_grGammaCorrectionValue(v) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grGammaCorrectionValue(v) \
- END_BOARD_LOCK(); \
- } while (0)
-#endif
-
-#if defined(FX_GLIDE3)
-#define FX_grSstWinClose(w) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grSstWinClose(w); \
- END_BOARD_LOCK(); \
- } while (0)
-#else
-#define FX_grSstWinClose(w) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grSstWinClose(); \
- END_BOARD_LOCK(); \
- } while (0)
-#endif
-
-
-extern FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
- GrScreenResolution_t screen_resolution,
- GrScreenRefresh_t refresh_rate,
- GrColorFormat_t color_format,
- GrOriginLocation_t origin_location,
- int nColBuffers,
- int nAuxBuffers);
-
-
-#define FX_grDrawLine(v1, v2) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grDrawLine(v1, v2); \
- END_CLIP_LOOP(); \
- } while (0)
-
-#define FX_grDrawPoint(p) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grDrawPoint(p); \
- END_CLIP_LOOP(); \
- } while (0)
-
-#if defined(FX_GLIDE3)
-extern void FX_grDrawPolygonVertexList(int n, GrVertex *v);
-#else
-#define FX_grDrawPolygonVertexList(n, v) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grDrawPolygonVertexList(n, v); \
- END_CLIP_LOOP(); \
- } while (0)
-#endif
-
-#define FX_grDitherMode(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDitherMode(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grRenderBuffer(b) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grRenderBuffer(b); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grBufferClear(c, a, d) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grBufferClear(c, a, d); \
- END_CLIP_LOOP(); \
- } while (0)
-
-#define FX_grBufferClearExt(c, a, d, s) \
- do { \
- BEGIN_CLIP_LOOP(); \
- (*grBufferClearExtPtr)(c, a, d, s); \
- END_CLIP_LOOP(); \
- } while (0)
-
-/*
- * Enable/Disable
- */
-#define FX_grEnable(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grEnable(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grDisable(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDisable(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-/*
- * Stencil operations.
- */
-#define FX_grStencilFunc(fnc, ref, mask) \
- do { \
- BEGIN_BOARD_LOCK(); \
- (*grStencilFuncPtr)((fnc), (ref), (mask)); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grStencilMask(write_mask) \
- do { \
- BEGIN_BOARD_LOCK(); \
- (*grStencilMaskPtr)(write_mask); \
- END_BOARD_LOCK(); \
- } while (0)
-
-
-#define FX_grStencilOp(stencil_fail, depth_fail, depth_pass) \
- do { \
- BEGIN_BOARD_LOCK(); \
- (*grStencilOpPtr)((stencil_fail), (depth_fail), (depth_pass)); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grDepthMask(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDepthMask(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grColorMask(c, a) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grColorMask(c, a); \
- END_BOARD_LOCK(); \
- } while (0)
-
-extern FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
- GrLfbWriteMode_t writeMode,
- GrOriginLocation_t origin, FxBool pixelPipeline,
- GrLfbInfo_t *info );
-
-#define FX_grLfbUnlock(t, b) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grLfbUnlock(t, b); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grConstantColorValue(v) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grConstantColorValue(v); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grConstantColorValue_NoLock grConstantColorValue
-
-#define FX_grAADrawTriangle(a, b, c, ab, bc, ca) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grAADrawTriangle(a, b, c, ab, bc, ca); \
- END_CLIP_LOOP(); \
- } while (0)
-
-#define FX_grAlphaBlendFunction(rs, rd, as, ad) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grAlphaBlendFunction(rs, rd, as, ad); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grAlphaCombine(func, fact, loc, oth, inv) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grAlphaCombine(func, fact, loc, oth, inv); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grAlphaCombine_NoLock grAlphaCombine
-
-#define FX_grAlphaTestFunction(f) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grAlphaTestFunction(f); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grAlphaTestReferenceValue(v) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grAlphaTestReferenceValue(v); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grClipWindow(minx, miny, maxx, maxy) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grClipWindow(minx, miny, maxx, maxy); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grClipWindow_NoLock grClipWindow
-
-#define FX_grColorCombine(func, fact, loc, oth, inv) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grColorCombine(func, fact, loc, oth, inv); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grColorCombine_NoLock grColorCombine
-
-#define FX_grCullMode(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grCullMode(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grDepthBiasLevel(lev) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDepthBiasLevel(lev); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grDepthBufferFunction(func) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDepthBufferFunction(func); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grFogColorValue(c) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grFogColorValue(c); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grFogMode(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grFogMode(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grFogTable(t) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grFogTable(t); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexClampMode(t, sc, tc) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexClampMode(t, sc, tc); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexClampMode_NoLock grTexClampMode
-
-#define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexCombine_NoLock grTexCombine
-
-#define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel
-
-#define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexFilterMode(t, minf, magf) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexFilterMode(t, minf, magf); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexFilterMode_NoLock grTexFilterMode
-
-extern FxU32 FX_grTexMinAddress(GrChipID_t tmu);
-extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu);
-
-#define FX_grTexMipMapMode(t, m, lod) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexMipMapMode(t, m, lod); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexMipMapMode_NoLock grTexMipMapMode
-
-#define FX_grTexSource(t, sa, eo, i) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexSource(t, sa, eo, i); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexSource_NoLock grTexSource
-
-extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info);
-#define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
-
-#define FX_grGlideGetState(s) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grGlideGetState(s); \
- END_BOARD_LOCK(); \
- } while (0)
-#define FX_grGlideGetState_NoLock(s) grGlideGetState(s);
-
-#define FX_grDRIBufferSwap(i) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDRIBufferSwap(i); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grSstSelect(b) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grSstSelect(b); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grSstSelect_NoLock grSstSelect
-
-#define FX_grGlideSetState(s) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grGlideSetState(s); \
- END_BOARD_LOCK(); \
- } while (0)
-#define FX_grGlideSetState_NoLock(s) grGlideSetState(s);
-
-#define FX_grDepthBufferMode(m) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grDepthBufferMode(m); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grLfbWriteColorFormat(f) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grLfbWriteColorFormat(f); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grDrawVertexArray(m, c, p) \
- do { \
- BEGIN_CLIP_LOOP(); \
- grDrawVertexArray(m, c, p); \
- END_CLIP_LOOP(); \
- } while (0)
-
-#define FX_grGlideShutdown() \
- do { \
- BEGIN_BOARD_LOCK(); \
- grGlideShutdown(); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grTexLodBiasValue_NoLock(t, v) grTexLodBiasValue(t, v)
-
-#define FX_grTexLodBiasValue(t, v) \
- do { \
- BEGIN_BOARD_LOCK(); \
- grTexLodBiasValue(t, v); \
- END_BOARD_LOCK(); \
- } while (0)
-
-#define FX_grGlideInit_NoLock grGlideInit
-#define FX_grSstWinOpen_NoLock grSstWinOpen
-
-extern int FX_getFogTableSize(void);
-extern int FX_getGrStateSize(void);
-
-#endif /* __FX_GLIDE_WARPER__ */
-
diff --git a/xc/extras/Mesa/src/FX/fxpipeline.c b/xc/extras/Mesa/src/FX/fxpipeline.c
deleted file mode 100644
index cf4c9ebbc..000000000
--- a/xc/extras/Mesa/src/FX/fxpipeline.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "vbindirect.h"
-
-
-/* We don't handle texcoord-4 in the safe clip routines - maybe we should.
- */
-static void fxDDRenderElements( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
-
- if (fxMesa->render_index != 0 ||
- ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size>2) ||
- ((ctx->Texture.ReallyEnabled & 0xf0) && VB->TexCoordPtr[1]->size>2) ||
- (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise */
- gl_render_elts( VB );
- else
- fxDDRenderElementsDirect( VB );
-}
-
-static void fxDDCheckRenderVBIndirect( GLcontext *ctx,
- struct gl_pipeline_stage *d )
-{
- d->type = 0;
-
- if ((ctx->IndirectTriangles & DD_SW_SETUP) == 0 &&
- ctx->Driver.MultipassFunc == 0)
- {
- d->type = PIPE_IMMEDIATE;
- d->inputs = VERT_SETUP_FULL | VERT_ELT | VERT_PRECALC_DATA;
- }
-}
-
-static void fxDDRenderVBIndirect( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- struct vertex_buffer *cvaVB = ctx->CVA.VB;
-
- if (fxMesa->render_index != 0 ||
- ((ctx->Texture.ReallyEnabled & 0xf) && cvaVB->TexCoordPtr[0]->size>2) ||
- ((ctx->Texture.ReallyEnabled & 0xf0) && cvaVB->TexCoordPtr[1]->size>2) ||
- (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise */
- gl_render_vb_indirect( VB );
- else
- fxDDRenderVBIndirectDirect( VB );
-}
-
-
-static void fxDDRenderVB( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
-
- if ((fxMesa->render_index != 0) ||
- ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size>2) ||
- ((ctx->Texture.ReallyEnabled & 0xf0) && VB->TexCoordPtr[1]->size>2))
- gl_render_vb( VB );
- else
- fxDDDoRenderVB( VB );
-}
-
-
-
-
-/* This sort of driver-based reconfiguration of the pipeline could be
- * used to support accelerated transformation and lighting on capable
- * hardware.
- *
- */
-GLuint fxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr )
-{
- GLuint i, o;
-
- for (i = o = 0 ; i < nr ; i++) {
- switch (in[i].ops) {
- case PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER:
- out[o] = in[i];
- out[o].state_change = NEW_CLIENT_STATE;
- out[o].check = fxDDCheckMergeAndRender;
- out[o].run = fxDDMergeAndRender;
- o++;
- break;
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
- out[o].state_change = ~0;
- out[o].check = fxDDCheckPartialRasterSetup;
- out[o].run = fxDDPartialRasterSetup;
- o++;
- break;
- case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].run = fxDDDoRasterSetup;
- o++;
- break;
- case PIPE_OP_RENDER:
- out[o] = in[i];
- if (in[i].run == gl_render_elts) {
- out[o].run = fxDDRenderElements;
- } else if (in[i].run == gl_render_vb_indirect) {
- out[o].check = fxDDCheckRenderVBIndirect;
- out[o].run = fxDDRenderVBIndirect;
- } else if (in[i].run == gl_render_vb) {
- out[o].run = fxDDRenderVB;
- }
-
- o++;
- break;
- default:
- out[o++] = in[i];
- break;
- }
- }
-
- return o;
-}
-
-#define ILLEGAL_ENABLES (TEXTURE0_3D| \
- TEXTURE1_3D| \
- ENABLE_TEXMAT0 | \
- ENABLE_TEXMAT1 | \
- ENABLE_TEXGEN0 | \
- ENABLE_TEXGEN1 | \
- ENABLE_USERCLIP | \
- ENABLE_LIGHT | \
- ENABLE_FOG)
-
-
-
-/* Because this is slotted in by the OptimizePipeline function, most
- * of the information here is just for gl_print_pipeline(). Only the
- * run member is required.
- */
-static struct gl_pipeline_stage fx_fast_stage = {
- "FX combined vertex transform, setup and rasterization stage",
- PIPE_OP_VERT_XFORM|PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER,
- PIPE_PRECALC,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0, /* never called */
- fxDDFastPath
-};
-
-
-
-
-/* Better than optimizing the pipeline, we can do the whole build very
- * quickly with the aid of a new flags member.
- */
-GLboolean fxDDBuildPrecalcPipeline( GLcontext *ctx )
-{
- struct gl_pipeline *pipe = &ctx->CVA.pre;
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
-
- if (fxMesa->is_in_hardware &&
- fxMesa->render_index == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
- (ctx->Array.Flags & (VERT_OBJ_234|
- VERT_TEX0_4|
- VERT_TEX1_4|
- VERT_ELT)) == (VERT_OBJ_23|VERT_ELT))
- {
- if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER))
- if (!fxMesa->using_fast_path)
- fprintf(stderr, "fxMesa: using fast path\n");
-
- pipe->stages[0] = &fx_fast_stage;
- pipe->stages[1] = 0;
- pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
- pipe->ops = pipe->stages[0]->ops;
- fxMesa->using_fast_path = 1;
- return 1;
- }
-
- if (fxMesa->using_fast_path)
- {
- if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER))
- fprintf(stderr, "fxMesa: fall back to full pipeline %x %x %x %x %x\n",
- fxMesa->is_in_hardware,
- fxMesa->render_index,
- (ctx->Enabled & ILLEGAL_ENABLES),
- (ctx->Array.Summary & (VERT_OBJ_23)),
- (ctx->Array.Summary & (VERT_OBJ_4|VERT_TEX0_4|VERT_TEX1_4)));
-
- fxMesa->using_fast_path = 0;
- ctx->CVA.VB->ClipOrMask = 0;
- ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
- ctx->Array.NewArrayState |= ctx->Array.Summary;
- return 0;
- }
-
- return 0;
-}
-
-
-
-
-
-
-/* Perform global optimizations to the pipeline. The fx driver
- * implements a single such fast path, which corresponds to the standard
- * quake3 cva pipeline.
- *
- * This is now handled by the 'build' function above.
- */
-void fxDDOptimizePrecalcPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- if (fxMesa->is_in_hardware &&
- fxMesa->render_index == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
- (ctx->Array.Summary & VERT_ELT))
- {
- pipe->stages[0] = &fx_fast_stage;
- pipe->stages[1] = 0;
- }
-}
-
-
-
-/* unused?
-void fxDDOptimizeEltPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
-{
- (void) ctx;
- (void) pipe;
-}
-*/
-
-#else
-
-/*
- * Need this to provide at least one external definition.
- */
-int gl_fxpipeline_dummy(void)
-{
- return 0;
-}
-
-#endif
diff --git a/xc/extras/Mesa/src/FX/fxrender.c b/xc/extras/Mesa/src/FX/fxrender.c
deleted file mode 100644
index 5935998f8..000000000
--- a/xc/extras/Mesa/src/FX/fxrender.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxrender.c - 3Dfx VooDoo RenderVB driver function support */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "vbcull.h"
-
-/*
- * Render a line segment from VB[v1] to VB[v2] when either one or both
- * endpoints must be clipped.
- */
-#if !defined(__MWERKS__)
-INLINE
-#endif
-void fxRenderClippedLine( struct vertex_buffer *VB,
- GLuint v1, GLuint v2 )
-{
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
-
- if (!mask || (VB->ctx->line_clip_tab[VB->ClipPtr->size])(VB, &v1, &v2, mask))
- FX_grDrawLine((GrVertex *)gWin[v1].f,(GrVertex *)gWin[v2].f);
-}
-
-
-
-
-/* This is legal for Quads as well as triangles, hence the 'n' parameter.
- */
-INLINE void fxRenderClippedTriangle( struct vertex_buffer *VB,
- GLuint n, GLuint vlist[] )
-{
- GLubyte mask = 0;
- GLuint i;
-
- for (i = 0 ; i < n ; i++)
- mask |= VB->ClipMask[vlist[i]];
-
- if (mask & CLIP_USER_BIT) {
- GLubyte *userclipmask = VB->UserClipMask;
- if (userclipmask[vlist[0]] & userclipmask[vlist[1]] & userclipmask[vlist[2]])
- return;
- }
-
- n = (VB->ctx->poly_clip_tab[VB->ClipPtr->size])( VB, n, vlist, mask );
- if (n >= 3) {
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GrVertex *i0 = (GrVertex *)gWin[vlist[0]].f;
- GrVertex *i1 = (GrVertex *)gWin[vlist[1]].f;
- GrVertex *i2 = (GrVertex *)gWin[vlist[2]].f;
- GLuint i;
-
- for (i=2;i<n;i++, i1 = i2, i2 = (GrVertex *)gWin[vlist[i]].f) {
- FX_grDrawTriangle(i0,i1,i2);
- }
- }
-}
-
-
-
-
-
-static INLINE void fxSafeClippedLine( struct vertex_buffer *VB,
- GLuint v1, GLuint v2 )
-{
- GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
-
- if (!mask) {
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- FX_grDrawLine((GrVertex *)gWin[v1].f,(GrVertex *)gWin[v2].f);
- } else {
- fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;
- fxLineClipTab[fxMesa->setupindex & 0x7]( VB, v1, v2, mask );
- }
-}
-
-
-static INLINE void fxSafeClippedTriangle( struct vertex_buffer *VB,
- fxVertex *gWin,
- tfxTriClipFunc cliptri,
- GLuint v2, GLuint v1, GLuint v )
-{
- GLubyte *clipmask = VB->ClipMask;
- GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
-
- if (!mask) {
- FX_grDrawTriangle((GrVertex *)gWin[v2].f,
- (GrVertex *)gWin[v1].f,
- (GrVertex *)gWin[v].f);
- return;
- }
-
- if (!(clipmask[v2] & clipmask[v1] & clipmask[v] & CLIP_ALL_BITS))
- {
- GLuint vl[3];
- GLuint imask = mask;
-
- if (imask & CLIP_USER_BIT) {
- GLubyte *userclipmask = VB->UserClipMask;
- if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
- return;
- imask |= (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
- }
-
- ASSIGN_3V(vl, v2, v1, v );
- cliptri( VB, vl, imask );
- }
-}
-
-
-static INLINE void fxSafeClippedTriangle2( struct vertex_buffer *VB,
- fxVertex *gWin,
- tfxTriViewClipFunc cliptri,
- GLuint v2, GLuint v1, GLuint v )
-{
- GLubyte *clipmask = VB->ClipMask;
- GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
-
- if (!mask) {
- FX_grDrawTriangle((GrVertex *)gWin[v2].f,(GrVertex *)gWin[v1].f,
- (GrVertex *)gWin[v].f);
- } else if (!(clipmask[v2] & clipmask[v1] & clipmask[v])) {
- GLuint vl[3];
- ASSIGN_3V(vl, v2, v1, v );
- cliptri( VB, vl, mask );
- }
-}
-
-
-static INLINE void fxSafeClippedTriangle3( struct vertex_buffer *VB,
- fxVertex *gWin,
- tfxTriClipFunc cliptri,
- GLuint v2, GLuint v1, GLuint v )
-{
- GLubyte *clipmask = VB->ClipMask;
- GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
- GLuint imask = mask;
-
- if (imask & CLIP_USER_BIT) {
- GLubyte *userclipmask = VB->UserClipMask;
- if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
- return;
- imask |= (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
- }
-
- {
- GLuint vl[3];
- ASSIGN_3V(vl, v2, v1, v );
- cliptri( VB, vl, imask );
- }
-}
-
-
-
-
-
-/************************************************************************/
-/************************ RenderVB functions ****************************/
-/************************************************************************/
-
-
-/* Render front-facing, non-clipped primitives.
- */
-
-#define RENDER_POINTS( start, count ) \
- (void) gWin; \
- (void) VB; \
- (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count-1 )
-
-#define RENDER_LINE( i1, i ) \
- do { \
- RVB_COLOR(i); \
- FX_grDrawLine((GrVertex *)gWin[i1].f, \
- (GrVertex *)gWin[i].f); \
- } while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
- do { \
- RVB_COLOR(pv); \
- if (parity) { \
- FX_grDrawTriangle((GrVertex *)gWin[i1].f, \
- (GrVertex *)gWin[i2].f, \
- (GrVertex *)gWin[i].f); \
- } else { \
- FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
- (GrVertex *)gWin[i1].f, \
- (GrVertex *)gWin[i].f); \
- } \
- } while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
- do { \
- RVB_COLOR(pv); \
- FX_grDrawTriangle((GrVertex *)gWin[i3].f, \
- (GrVertex *)gWin[i2].f, \
- (GrVertex *)gWin[i].f); \
- FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
- (GrVertex *)gWin[i1].f, \
- (GrVertex *)gWin[i].f); \
- } while (0)
-
-
-
-#define LOCAL_VARS \
- fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- (void) fxMesa;
-
-#define INIT(x)
-
-#define TAG(x) x##_fx_flat_raw
-#undef RVB_COLOR
-#define RVB_COLOR(pv) FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
-#define PRESERVE_VB_DEFS
-
-#include "render_tmp.h"
-
-#define TAG(x) x##_fx_smooth_raw
-#undef RVB_COLOR
-#define RVB_COLOR(x)
-
-#include "render_tmp.h"
-
-
-
-/* Render with clipped and/or culled primitives with cullmask information.
- */
-#define RENDER_POINTS( start, count ) \
- (void) gWin; \
- (void) cullmask; \
- (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count-1 )
-
-
-#define RENDER_LINE( i1, i ) \
- do { \
- const GLubyte flags = cullmask[i]; \
- \
- if (!(flags & PRIM_NOT_CULLED)) \
- continue; \
- \
- RVB_COLOR(i); \
- if (flags & PRIM_ANY_CLIP) \
- fxRenderClippedLine( VB, i1, i ); \
- else \
- FX_grDrawLine( (GrVertex *)gWin[i1].f, (GrVertex *)gWin[i].f ); \
- } while (0)
-
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
- do { \
- const GLubyte flags = cullmask[i]; \
- GLuint e2,e1; \
- \
- if (!(flags & PRIM_NOT_CULLED)) \
- continue; \
- \
- e2=i2, e1=i1; \
- if (parity) { e2=i1; e1=i2; } \
- \
- RVB_COLOR(pv); \
- if (flags & PRIM_ANY_CLIP) { \
- fxSafeClippedTriangle3(VB,gWin,cliptri,e2,e1,i); \
- } else { \
- FX_grDrawTriangle((GrVertex *)gWin[e2].f, \
- (GrVertex *)gWin[e1].f, \
- (GrVertex *)gWin[i].f); \
- } \
- } while (0)
-
-
-#define RENDER_QUAD(i3, i2, i1, i, pv) \
- do { \
- const GLubyte flags = cullmask[i]; \
- \
- if (!(flags & PRIM_NOT_CULLED)) \
- continue; \
- \
- RVB_COLOR(pv); \
- if (flags&PRIM_ANY_CLIP) { \
- fxSafeClippedTriangle3(VB,gWin,cliptri,i3,i2,i); \
- fxSafeClippedTriangle3(VB,gWin,cliptri,i2,i1,i); \
- } else { \
- FX_grDrawTriangle((GrVertex *)gWin[i3].f, \
- (GrVertex *)gWin[i2].f, \
- (GrVertex *)gWin[i].f); \
- FX_grDrawTriangle((GrVertex *)gWin[i2].f, \
- (GrVertex *)gWin[i1].f, \
- (GrVertex *)gWin[i].f); \
- } \
- } while (0)
-
-
-
-
-
-#define LOCAL_VARS \
- fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- const GLubyte *cullmask = VB->CullMask; \
- tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
-
-
-
-
-#define INIT(x) (void) cliptri; (void) fxMesa;
-
-#define TAG(x) x##_fx_smooth_culled
-#undef RVB_COLOR
-#define RVB_COLOR(x)
-#define PRESERVE_VB_DEFS
-#include "render_tmp.h"
-
-#define TAG(x) x##_fx_flat_culled
-#undef RVB_COLOR
-#define RVB_COLOR(pv) FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
-
-#include "render_tmp.h"
-
-
-
-
-/* Direct, with the possibility of clipping.
- */
-#define RENDER_POINTS( start, count ) \
- do { \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- GLubyte *clipmask = VB->ClipMask; \
- GLuint i; \
- for (i = start ; i <= count ; i++) \
- if (clipmask[i] == 0) { \
- RVB_COLOR(i); \
- FX_grDrawPoint( (GrVertex *)gWin[i].f );\
- } \
- } while (0)
-
-#define RENDER_LINE( i1, i ) \
- do { \
- RVB_COLOR(i); \
- fxSafeClippedLine( VB, i1, i ); \
- } while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
- do { \
- GLuint e2=i2, e1=i1; \
- if (parity) { GLuint t=e2; e2=e1; e1=t; } \
- RVB_COLOR(pv); \
- fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,i); \
- } while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
- do { \
- RVB_COLOR(pv); \
- fxSafeClippedTriangle(VB,gWin,cliptri,i3,i2,i); \
- fxSafeClippedTriangle(VB,gWin,cliptri,i2,i1,i); \
- } while (0)
-
-#define LOCAL_VARS \
- fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
-
-#define INIT(x) (void) cliptri; (void) gWin;
-
-#define TAG(x) x##_fx_smooth_clipped
-#undef RVB_COLOR
-#define RVB_COLOR(x)
-#define PRESERVE_VB_DEFS
-#include "render_tmp.h"
-
-
-#define TAG(x) x##_fx_flat_clipped
-#undef RVB_COLOR
-#define RVB_COLOR(pv) FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
-#include "render_tmp.h"
-
-
-
-
-
-
-/* Indirect, with the possibility of clipping.
- */
-#define RENDER_POINTS( start, count ) \
- do { \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- GLuint e; \
- GLubyte *clipmask = VB->ClipMask; \
- for(e=start;e<=count;e++) \
- if(clipmask[elt[e]]==0) { \
- FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \
- } \
- } while (0)
-
-#define RENDER_LINE( i1, i ) \
- do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- RVB_COLOR(e); \
- fxSafeClippedLine( VB, e1, e ); \
- } while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
- do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if (parity) { GLuint t=e2; e2=e1; e1=t; } \
- fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e); \
- } while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
- do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
- fxSafeClippedTriangle(VB,gWin,cliptri,e3,e2,e); \
- fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e); \
- } while (0)
-
-#define LOCAL_VARS const GLuint *elt = VB->EltPtr->data; \
- fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx; \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
-
-#define INIT(x) (void) cliptri; (void) gWin;
-
-#define TAG(x) x##_fx_smooth_indirect_clipped
-#undef RVB_COLOR
-#define RVB_COLOR(x)
-#include "render_tmp.h"
-
-
-/* Indirect, clipped, but no user clip.
- */
-#define RENDER_POINTS( start, count ) \
- do { \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- GLuint e; \
- GLubyte *clipmask = VB->ClipMask; \
- for(e=start;e<=count;e++) \
- if(clipmask[elt[e]]==0) { \
- FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \
- } \
- } while (0)
-
-#define RENDER_LINE( i1, i ) \
- do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- RVB_COLOR(e); \
- fxSafeClippedLine( VB, e1, e ); \
- } while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
- do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if (parity) { GLuint t=e2; e2=e1; e1=t; } \
- fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e); \
- } while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
- do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
- fxSafeClippedTriangle2(VB,gWin,cliptri,e3,e2,e); \
- fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e); \
- } while (0)
-
-#define LOCAL_VARS const GLuint *elt = VB->EltPtr->data; \
- fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx; \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- tfxTriViewClipFunc cliptri = fxMesa->view_clip_tri;
-
-#define INIT(x) (void) cliptri; (void) gWin;
-
-#define TAG(x) x##_fx_smooth_indirect_view_clipped
-#undef RVB_COLOR
-#define RVB_COLOR(x)
-#include "render_tmp.h"
-
-
-
-
-
-
-
-/* Indirect, and no clipping required.
- */
-#define RENDER_POINTS( start, count ) \
- do { \
- GLuint e; \
- for(e=start;e<=count;e++) { \
- FX_grDrawPoint((GrVertex *)gWin[elt[e]].f); \
- } \
- } while (0)
-
-#define RENDER_LINE( i1, i ) \
- do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- FX_grDrawLine((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f); \
- } while (0)
-
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
- do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} \
- FX_grDrawTriangle((GrVertex *)gWin[e2].f, \
- (GrVertex *)gWin[e1].f, \
- (GrVertex *)gWin[e].f); \
- } while (0)
-
-
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
- do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
- FX_grDrawTriangle((GrVertex *)gWin[e3].f, \
- (GrVertex *)gWin[e2].f, \
- (GrVertex *)gWin[e].f); \
- FX_grDrawTriangle((GrVertex *)gWin[e2].f, \
- (GrVertex *)gWin[e1].f, \
- (GrVertex *)gWin[e].f); \
- } while (0)
-
-#define LOCAL_VARS \
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; \
- const GLuint *elt = VB->EltPtr->data;
-
-#define INIT(x)
-
-#define TAG(x) x##_fx_smooth_indirect
-#undef RVB_COLOR
-#define RVB_COLOR(x)
-#include "render_tmp.h"
-
-
-
-
-
-/* Direct in this context means that triangles, lines, points can be
- * rendered simply by calling grDrawTriangle, etc., without any
- * additional setup (such as calling grConstantColor). We also use a
- * 'safe' set of clipping routines which don't require write-access to
- * the arrays in the vertex buffer, and don't care about array
- * stride.
- *
- * Thus there is no call to gl_import_arrays() in this function.
- *
- * This safe clipping should be generalized to call driver->trianglefunc
- * under the appropriate conditions.
- *
- * We don't handle texcoord-4 in the safe clip routines - maybe we should.
- *
- */
-void fxDDRenderElementsDirect( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- struct vertex_buffer *saved_vb = ctx->VB;
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = render_tab_fx_smooth_indirect[prim];
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint p = 0;
-
- if (!nr)
- return;
-
- if (fxMesa->new_state)
- fxSetupFXUnits(ctx);
-
- if (!nr) return;
-
- if (VB->ClipOrMask) {
- func = render_tab_fx_smooth_indirect_view_clipped[prim];
- if (VB->ClipOrMask & CLIP_USER_BIT)
- func = render_tab_fx_smooth_indirect_clipped[prim];
- }
-
- ctx->VB = VB; /* kludge */
-
- do {
- func( VB, 0, nr, 0 );
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ));
-
-
- ctx->VB = saved_vb;
-}
-
-
-void fxDDRenderVBIndirectDirect( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- struct vertex_buffer *cvaVB = ctx->CVA.VB;
- struct vertex_buffer *saved_vb = ctx->VB;
- GLuint i, next, count = VB->Count;
- render_func *tab = render_tab_fx_smooth_indirect;
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint p = 0;
-
- if (cvaVB->ClipOrMask)
- tab = render_tab_fx_smooth_indirect_clipped;
-
- if (!VB->CullDone)
- gl_fast_copy_vb( VB );
-
- if (fxMesa->new_state)
- fxSetupFXUnits( ctx );
-
- ctx->VB = cvaVB;
- cvaVB->EltPtr = VB->EltPtr;
-
- do {
- GLuint parity = VB->Parity;
-
- for (i = VB->CopyStart ; i < count ; parity = 0, i = next)
- {
- GLuint prim = VB->Primitive[i];
- next = VB->NextPrimitive[i];
- tab[prim]( cvaVB, i, next, parity );
- }
- /* loop never taken */
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( cvaVB, ++p ));
-
- cvaVB->EltPtr = 0;
- ctx->VB = saved_vb;
-}
-
-
-static render_func *fxDDRenderVBSmooth_tables[3] = {
- render_tab_fx_smooth_clipped,
- render_tab_fx_smooth_culled,
- render_tab_fx_smooth_raw
-};
-
-static render_func *fxDDRenderVBFlat_tables[3] = {
- render_tab_fx_flat_clipped,
- render_tab_fx_flat_culled,
- render_tab_fx_flat_raw
-};
-
-
-static render_func *null_tables[3] = {
- 0,
- 0,
- 0
-};
-
-#if defined(FX_GLIDE3)
-#include "fxstripdet.c"
-#endif
-
-void fxDDRenderInit( GLcontext *ctx )
-{
- render_init_fx_smooth_indirect_view_clipped();
- render_init_fx_smooth_indirect_clipped();
- render_init_fx_smooth_indirect();
- render_init_fx_smooth_raw();
- render_init_fx_smooth_culled();
- render_init_fx_smooth_clipped();
- render_init_fx_flat_raw();
- render_init_fx_flat_culled();
- render_init_fx_flat_clipped();
-#if defined(FX_GLIDE3)
- fxDDRenderInitGlide3(ctx);
-#endif
-}
-
-
-/* Now used to set an internal var in fxMesa - we hook out at the
- * level of gl_render_vb() instead.
- */
-render_func **fxDDChooseRenderVBTables(GLcontext *ctx)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
-
- if (ctx->IndirectTriangles & DD_SW_SETUP)
- return null_tables;
-
- switch (fxMesa->render_index) {
-/* case FX_FLAT: */
-/* return fxDDRenderVBFlat_tables; */
- case 0:
- return fxDDRenderVBSmooth_tables;
- default:
- return null_tables;
- }
-}
-
-
-void fxDDDoRenderVB( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint i, next, prim;
- GLuint parity = VB->Parity;
- render_func *tab;
- GLuint count = VB->Count;
- GLint p = 0;
-
- if (fxMesa->new_state)
- fxSetupFXUnits(ctx);
-
- if (VB->Indirect) {
- return;
- } else if (VB->CullMode & CLIP_MASK_ACTIVE) {
- tab = fxMesa->RenderVBClippedTab;
- } else {
- tab = fxMesa->RenderVBRawTab;
- }
-
- if (!VB->CullDone)
- gl_fast_copy_vb( VB );
-
- do
- {
- for ( i= VB->CopyStart ; i < count ; parity = 0, i = next )
- {
- prim = VB->Primitive[i];
- next = VB->NextPrimitive[i];
- tab[prim]( VB, i, next, parity );
- }
-
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ));
-}
-
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-int gl_fx_dummy_function_render(void)
-{
- return 0;
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxsanity.c b/xc/extras/Mesa/src/FX/fxsanity.c
deleted file mode 100644
index 9f815012e..000000000
--- a/xc/extras/Mesa/src/FX/fxsanity.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-
-
-#if defined(FX)
-#include "fxdrv.h"
-
-/* I have found this quite useful in tracking down transformation &
- * clipping bugs. If you get a random graphics card freeze, running
- * your triangles through this will probably catch the problem.
- */
-
-#define WID 640
-#define HI 480
-
-#undef grDrawTriangle
-
-void fx_sanity_triangle( GrVertex *v1, GrVertex *v2, GrVertex *v3 )
-{
- GLuint rv = 1, print = 0;
-
- GLfloat area = ((v1->x - v3->x) * (v2->y - v3->y) -
- (v1->y - v3->y) * (v2->x - v3->x));
-
- if (v1->x < 0 || v1->y < 0 || v1->x > WID || v1->y > HI ||
- v2->x < 0 || v2->y < 0 || v2->x > WID || v2->y > HI ||
- v3->x < 0 || v3->y < 0 || v3->x > WID || v3->y > HI)
- {
- fprintf(stderr,"not clipped/set up!!!!!\n");
- rv = 0;
- print = 1;
- }
-
- if (area > (WID*HI)) {
- fprintf(stderr,"too big\n");
- rv = 0;
- }
- if (v1->oow == 0 || v2->oow == 0 || v3->oow == 0) {
- fprintf(stderr,"zero oow\n");
- rv = 0;
- }
- if (0 && area == 0) {
- fprintf(stderr,"zero area %p %p %p\n", v1,v2,v3);
- rv =0;
- }
-
- if (print) {
- fprintf(stderr,"v1: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
- v1->x, v1->y, v1->ooz, v1->oow,
- v1->r, v1->g, v1->b, v1->a,
- v1->tmuvtx[0].sow, v1->tmuvtx[0].tow, v1->tmuvtx[0].oow,
- v1->tmuvtx[1].sow, v1->tmuvtx[1].tow, v1->tmuvtx[1].oow);
- fprintf(stderr,"v2: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
- v2->x, v2->y, v2->ooz, v2->oow,
- v2->r, v2->g, v2->b, v2->a,
- v2->tmuvtx[0].sow, v2->tmuvtx[0].tow, v2->tmuvtx[0].oow,
- v2->tmuvtx[1].sow, v2->tmuvtx[1].tow, v2->tmuvtx[1].oow);
- fprintf(stderr,"v3: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
- v3->x, v3->y, v3->ooz, v3->oow,
- v3->r, v3->g, v3->b, v3->a,
- v3->tmuvtx[0].sow, v3->tmuvtx[0].tow, v3->tmuvtx[0].oow,
- v3->tmuvtx[1].sow, v3->tmuvtx[1].tow, v3->tmuvtx[1].oow);
- }
-
- if (1)
- FX_grDrawTriangle(v1,v2,v3);
- else
- fprintf(stderr, "\n\n\n");
-}
-
-#else
-
-void gl_fxsanity_dummy()
-{
-}
-
-#endif
diff --git a/xc/extras/Mesa/src/FX/fxsdettmp.h b/xc/extras/Mesa/src/FX/fxsdettmp.h
deleted file mode 100644
index 7b77b36c2..000000000
--- a/xc/extras/Mesa/src/FX/fxsdettmp.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/*
- * Notes: the folowing code works only if count is > start.
- * Corrently we are looking for the pattern:
- * v0,v1,v2 v2,v1,v3, v2,v3,v4....
- *
- * For this:
- * #define STRIP0 ((u1 == v1) && (u2 == v0))
- * #define STRIP1 ((u0 == v0) && (u2 == v1))
- *
- */
-
-
-static void TAG(render_vb_triangles_smooth_indirect_sd)
- ( struct vertex_buffer *VB,
- GLuint start,
- GLuint count,
- GLuint parity)
-{
- GLint u0,u1,u2;
- GLint v0,v1,v2;
- GLuint *elt = VB->EltPtr->data;
-
- int i;
- LOCAL_VARS
-
- INIT(GL_TRIANGLES);
-
- elt = &elt[start-1];
- u0 = *(++elt);
- u1 = *(++elt);
- u2 = *(++elt);
- i = start+3;
- while (i < count)
- {
- v0 = *(++elt);
- v1 = *(++elt);
- v2 = *(++elt);
-
- if (CLIPPED(u0,u1,u2))
- {
- if (!CULLED(u0,u1,u2)) SENDCLIPTRI(u0,u1,u2);
- }
- else
- {
- if (STRIP0(u,v))
- {
- int is_strips = 1;
- int parity = 0;
- STRIPSLOCAL_VAR
-
- FLUSHTRI();
- STARTSTRIPS(u0,u1,u2);
- while (is_strips && i < count)
- {
- SENDSTRIPS(v2);
-
- u0 = v0; u1 = v1; u2 = v2; i+= 3;
- v0 = *(++elt);
- v1 = *(++elt);
- v2 = *(++elt);
-
- if (parity) {
- is_strips = STRIP0(u,v);
- parity = 0;
- } else {
- is_strips = STRIP1(u,v);
- parity = 1;
- }
- }
- FLUSHSTRIPS();
-
- if (i >= count)
- return;
- }
- else
- {
- SENDTRI(u0,u1,u2);
- }
- }
- u0 = v0; u1 = v1; u2 = v2; i+= 3;
- }
- if (CLIPPED(u0,u1,u2))
- {
- if (!CULLED(u0,u1,u2)) SENDCLIPTRI(u0,u1,u2);
- }
- else
- {
- SENDTRI(u0,u1,u2);
- }
- FLUSHTRI();
-
-}
-
-#ifndef PRESERVE_VB_DEFS
-#undef SENDTRI
-#undef STRIP0
-#undef STRIP1
-#undef LOCAL_VARS
-#undef STRIPSLOCAL_VAR
-#undef INIT
-#undef SENDTRI
-#undef FLUSHTRI
-#undef STARTSTRIPS
-#undef SENDSTRIPS
-#undef FLUSHSTRIPS
-#undef CLIPPED
-#undef CULLED
-#undef SENDCLIPTRI
-#endif
-
-#ifndef PRESERVE_TAG
-#undef TAG
-#endif
-
-#undef PRESERVE_VB_DEFS
-#undef PRESERVE_TAG
diff --git a/xc/extras/Mesa/src/FX/fxsetup.c b/xc/extras/Mesa/src/FX/fxsetup.c
index 245dbd1db..7ba8ee6f7 100644
--- a/xc/extras/Mesa/src/FX/fxsetup.c
+++ b/xc/extras/Mesa/src/FX/fxsetup.c
@@ -1228,8 +1228,6 @@ static void fxSetupBlend(GLcontext *ctx)
fxMesaContext fxMesa = FX_CONTEXT(ctx);
tfxUnitsState *us = &fxMesa->unitsState;
- assert(us->blendEnabled == ctx->Color.BlendEnabled);
-
if (us->blendEnabled)
FX_grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB,
us->blendSrcFuncAlpha, us->blendDstFuncAlpha);
diff --git a/xc/extras/Mesa/src/FX/fxstripdet.c b/xc/extras/Mesa/src/FX/fxstripdet.c
deleted file mode 100644
index bc21234b6..000000000
--- a/xc/extras/Mesa/src/FX/fxstripdet.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-#if defined(FX) && defined(FX_GLIDE3)
-
-#include "fxdrv.h"
-#include "vbcull.h"
-
-
-#define STRIP0(u,v) ((u1 == v1) && (u2 == v0))
-#define STRIP1(u,v) ((u0 == v0) && (u2 == v1))
-
-#define LOCAL_VARS fxVertex* gWin = FX_DRIVER_DATA(VB)->verts; \
- GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;
-
-#define STRIPSLOCAL_VAR int sc = 0;
-
-#define INIT(a)
-
-#define SENDTRI(u0,u1,u2) FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
-#define FLUSHTRI() /* No-Op */
-#define STARTSTRIPS(u0,u1,u2) { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
-#define SENDSTRIPS(v2) { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
-#define FLUSHSTRIPS() FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
-
-#define CLIPPED(a,b,c) 0
-#define CULLED(a,b,c) 0
-#define SENDCLIPTRI(a,b,c) /* NoOp */
-
-#define TAG(x) x##_fx
-
-#include "fxsdettmp.h"
-
-
-/* Clipped but no userclip */
-#define STRIP0(u,v) ((u1 == v1) && (u2 == v0)) && !clipmask[v2]
-#define STRIP1(u,v) ((u0 == v0) && (u2 == v1)) && !clipmask[v2]
-
-#define LOCAL_VARS fxVertex* gWin = FX_DRIVER_DATA(VB)->verts; \
- GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b; \
- const GLubyte *const clipmask = VB->ClipMask; \
- const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
- const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
-
-#define STRIPSLOCAL_VAR int sc = 0;
-
-#define INIT(a)
-
-#define SENDTRI(u0,u1,u2) FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
-#define FLUSHTRI() /* No-Op */
-#define STARTSTRIPS(u0,u1,u2) { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
-#define SENDSTRIPS(v2) { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
-#define FLUSHSTRIPS() FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
-
-#define CLIPPED(u0,u1,u2) (clipmask[u0] | clipmask[u1] | clipmask[u2])
-#define CULLED(u0,u1,u2) (clipmask[u0] & clipmask[u1] & clipmask[u2])
-#define SENDCLIPTRI(u0,u1,u2) { \
- GLuint vl[3]; \
- ASSIGN_3V(vl, u0, u1, u2 ); \
- cliptri(VB,vl,clipmask[u0] | clipmask[u1] | clipmask[u2]); \
- }
-
-#define TAG(x) x##_fx_view_clipped
-
-#include "fxsdettmp.h"
-
-/* Clipped and might be userclip */
-#define STRIP0(u,v) ((u1 == v1) && (u2 == v0)) && !clipmask[v2]
-#define STRIP1(u,v) ((u0 == v0) && (u2 == v1)) && !clipmask[v2]
-
-#define LOCAL_VARS fxVertex* gWin = FX_DRIVER_DATA(VB)->verts; \
- GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b; \
- const GLubyte *const clipmask = VB->ClipMask; \
- const GLubyte *userclipmask = VB->UserClipMask; \
- const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx; \
- const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
-
-#define STRIPSLOCAL_VAR int sc = 0;
-
-#define INIT(a)
-
-#define SENDTRI(u0,u1,u2) FX_grDrawTriangle((GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
-#define FLUSHTRI() /* No-Op */
-#define STARTSTRIPS(u0,u1,u2) { sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
-#define SENDSTRIPS(v2) { sb[sc++] = (GrVertex*)&(gWin[v2].f); }
-#define FLUSHSTRIPS() FX_grDrawVertexArray(GR_TRIANGLE_STRIP,sc,sb)
-
-#define CLIPPED(u0,u1,u2) (clipmask[u0] | clipmask[u1] | clipmask[u2])
-#define CULLED(u0,u1,u2) (clipmask[u0] & clipmask[u1] & clipmask[u2] & CLIP_ALL_BITS)
-#define SENDCLIPTRI(u0,u1,u2) { \
- GLuint vl[3]; \
- GLuint imask = (clipmask[u0] | clipmask[u1] | clipmask[u2]); \
- \
- if (imask & CLIP_USER_BIT) { \
- if (!(userclipmask[u2] & userclipmask[u1] & userclipmask[u0])) \
- { ASSIGN_3V(vl, u2, u1, u0 ); \
- imask |= (userclipmask[u2] | userclipmask[u1] | userclipmask[u0]) << 8; \
- cliptri( VB, vl, imask );} \
- } \
- else { ASSIGN_3V(vl, u2, u1, u0 ); \
- cliptri( VB, vl, imask ); } \
- }
-
-#define TAG(x) x##_fx_clipped
-
-#include "fxsdettmp.h"
-
-
-void fxDDRenderInitGlide3(GLcontext *ctx)
-{
-#if 0
- render_tab_fx_smooth_indirect[GL_TRIANGLES] = render_vb_triangles_smooth_indirect_sd_fx;
- render_tab_fx_smooth_indirect_view_clipped[GL_TRIANGLES] = render_vb_triangles_smooth_indirect_sd_fx_view_clipped;
- render_tab_fx_smooth_indirect_clipped[GL_TRIANGLES] = render_vb_triangles_smooth_indirect_sd_fx_clipped;
-#endif
-}
-
-
-#endif /* defined(FX) && FX_GLIDE3 */
diff --git a/xc/extras/Mesa/src/FX/fxtexman.c b/xc/extras/Mesa/src/FX/fxtexman.c
index 5066efa55..ae38d2d76 100644
--- a/xc/extras/Mesa/src/FX/fxtexman.c
+++ b/xc/extras/Mesa/src/FX/fxtexman.c
@@ -128,6 +128,7 @@ static MemRange *fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end)
}
result->startAddr=start;
result->endAddr=end;
+ result->next=0;
return result;
}
@@ -166,7 +167,6 @@ static void fxTMUInit(fxMesaContext fxMesa, int tmu)
(unsigned int)blockstart,(unsigned int)blockend);
tmn=fxTMNewRangeNode(fxMesa, blockstart, blockend);
- tmn->next=0;
if (last) last->next=tmn;
else fxMesa->tmFree[tmu]=tmn;
@@ -181,11 +181,19 @@ static int fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
MemRange *prev, *tmp;
int result;
struct gl_texture_object *obj;
+ int blockCount, deleteCount;
+ int largestBlock = 0;
while (1) {
prev=0;
tmp=fxMesa->tmFree[tmu];
+ blockCount = 0;
+ deleteCount = 0;
while (tmp) {
+ blockCount++;
+ if (tmp->endAddr - tmp->startAddr > largestBlock)
+ largestBlock = tmp->endAddr - tmp->startAddr;
+
if (tmp->endAddr-tmp->startAddr>=size) { /* Fits here */
result=tmp->startAddr;
tmp->startAddr+=size;
@@ -196,6 +204,7 @@ static int fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
fxMesa->tmFree[tmu]=tmp->next;
}
fxTMDeleteRangeNode(fxMesa, tmp);
+ deleteCount++;
}
fxMesa->freeTexMem[tmu]-=size;
return result;
@@ -207,6 +216,11 @@ static int fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
obj=fxTMFindOldestObject(fxMesa, tmu);
if (!obj) {
fprintf(stderr, "fx Driver: No space for texture\n");
+ fprintf(stderr, " requested size = %d\n", size);
+ fprintf(stderr, " largest block = %d\n", largestBlock);
+ fprintf(stderr, " tmu = %d\n", tmu);
+ fprintf(stderr, " block count = %d\n", blockCount);
+ fprintf(stderr, " delete count = %d\n", deleteCount);
return -1;
}
fxTMMoveOutTM(fxMesa, obj);
@@ -261,6 +275,7 @@ static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
GLuint age, old, lasttime, bindnumber;
tfxTexInfo *info;
struct gl_texture_object *obj, *tmp;
+ int wrap = 0, anyFound = 0, inTmuCount = 0;
tmp=fxMesa->glCtx->Shared->TexObjectList;
if (!tmp) return 0;
@@ -271,13 +286,19 @@ static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
while (tmp) {
info=fxTMGetTexInfo(tmp);
+ if (info && info->isInTM)
+ inTmuCount++;
+
if (info && info->isInTM &&
((info->whichTMU==tmu) || (info->whichTMU==FX_TMU_BOTH) ||
(info->whichTMU==FX_TMU_SPLIT))) {
lasttime=info->lastTimeUsed;
+ anyFound = 1;
- if (lasttime>bindnumber)
+ if (lasttime>bindnumber) {
age=bindnumber+(UINT_MAX-lasttime+1); /* TO DO: check wrap around */
+ wrap = 1;
+ }
else
age=bindnumber-lasttime;
@@ -288,6 +309,10 @@ static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
}
tmp=tmp->Next;
}
+ if (!obj) {
+ fprintf(stderr, " wrap = %d anyFound = %d inTmuCount = %d\n",
+ wrap, anyFound, inTmuCount);
+ }
return obj;
}
@@ -299,7 +324,16 @@ static MemRange *fxTMAddObj(fxMesaContext fxMesa,
MemRange *range;
startAddr=fxTMFindStartAddr(fxMesa, tmu, texmemsize);
- if (startAddr<0) return 0;
+ if (startAddr<0 || startAddr > 0xffffff00) {
+ tfxTexInfo *ti=fxTMGetTexInfo(tObj);
+ GrTexInfo *info = &(ti->info);
+ fprintf(stderr, " smallLodLog2 = %d\n", (int) info->smallLodLog2);
+ fprintf(stderr, " largeLodLog2 = %d\n", (int) info->largeLodLog2);
+ fprintf(stderr, " aspectRatioLog2 = %d\n", (int) info->aspectRatioLog2);
+ fprintf(stderr, " format = 0x%x\n", (unsigned int) info->format);
+ fprintf(stderr, " data = %p\n", info->data);
+ return 0;
+ }
range=fxTMNewRangeNode(fxMesa, startAddr, startAddr+texmemsize);
return range;
}
diff --git a/xc/extras/Mesa/src/FX/fxtrifuncs.c b/xc/extras/Mesa/src/FX/fxtrifuncs.c
deleted file mode 100644
index 4b349b31b..000000000
--- a/xc/extras/Mesa/src/FX/fxtrifuncs.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxtris.c - 3Dfx VooDoo triangle functions */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "../mmath.h"
-
-
-
-/* Is this enough? Do we need more triangle funcs?
- */
-static triangle_func tri_tab[0x40]; /* only 0x20 actually used */
-static quad_func quad_tab[0x40]; /* only 0x20 actually used */
-static line_func line_tab[0x40]; /* less than 0x20 used */
-static points_func points_tab[0x40]; /* less than 0x20 used */
-
-#define IND (0)
-#define TAG(x) x
-#include "fxtritmp.h"
-
-#define IND (FX_OFFSET)
-#define TAG(x) x##_offset
-#include "fxtritmp.h"
-
-#define IND (FX_TWOSIDE)
-#define TAG(x) x##_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_twoside_offset
-#include "fxtritmp.h"
-
-#define IND (FX_FRONT_BACK)
-#define TAG(x) x##_front_back
-#include "fxtritmp.h"
-
-#define IND (FX_FRONT_BACK|FX_OFFSET)
-#define TAG(x) x##_front_back_offset
-#include "fxtritmp.h"
-
-#define IND (FX_FRONT_BACK|FX_TWOSIDE)
-#define TAG(x) x##_front_back_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_front_back_twoside_offset
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT)
-#define TAG(x) x##_flat
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_OFFSET)
-#define TAG(x) x##_flat_offset
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_TWOSIDE)
-#define TAG(x) x##_flat_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_flat_twoside_offset
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_FRONT_BACK)
-#define TAG(x) x##_flat_front_back
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_FRONT_BACK|FX_OFFSET)
-#define TAG(x) x##_flat_front_back_offset
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE)
-#define TAG(x) x##_flat_front_back_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_flat_front_back_twoside_offset
-#include "fxtritmp.h"
-
-/* We don't actually do antialiasing correctly. Geometry has to be
- sorted for glide's antialiasing to operate */
-#if 0
-#define IND (FX_ANTIALIAS)
-#define TAG(x) x##_aa
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_OFFSET)
-#define TAG(x) x##_aa_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_TWOSIDE)
-#define TAG(x) x##_aa_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_aa_twoside_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FRONT_BACK)
-#define TAG(x) x##_aa_front_back
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_OFFSET)
-#define TAG(x) x##_aa_front_back_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_TWOSIDE)
-#define TAG(x) x##_aa_front_back_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_aa_front_back_twoside_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT)
-#define TAG(x) x##_aa_flat
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_OFFSET)
-#define TAG(x) x##_aa_flat_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_TWOSIDE)
-#define TAG(x) x##_aa_flat_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_aa_flat_twoside_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK)
-#define TAG(x) x##_aa_flat_front_back
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_OFFSET)
-#define TAG(x) x##_aa_flat_front_back_offset
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE)
-#define TAG(x) x##_aa_flat_front_back_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
-#define TAG(x) x##_aa_flat_front_back_twoside_offset
-#include "fxtritmp.h"
-#endif
-
-void fxDDTrifuncInit()
-{
- init();
- init_offset();
- init_twoside();
- init_twoside_offset();
- init_front_back();
- init_front_back_offset();
- init_front_back_twoside();
- init_front_back_twoside_offset();
- init_flat();
- init_flat_offset();
- init_flat_twoside();
- init_flat_twoside_offset();
- init_flat_front_back();
- init_flat_front_back_offset();
- init_flat_front_back_twoside();
- init_flat_front_back_twoside_offset();
-#if 0
- init_aa();
- init_aa_offset();
- init_aa_twoside();
- init_aa_twoside_offset();
- init_aa_front_back();
- init_aa_front_back_offset();
- init_aa_front_back_twoside();
- init_aa_front_back_twoside_offset();
- init_aa_flat();
- init_aa_flat_offset();
- init_aa_flat_twoside();
- init_aa_flat_twoside_offset();
- init_aa_flat_front_back();
- init_aa_flat_front_back_offset();
- init_aa_flat_front_back_twoside();
- init_aa_flat_front_back_twoside_offset();
-#endif
-}
-
-void fxPrintRenderState( const char *msg, GLuint state )
-{
- fprintf(stderr, "%s: (%x) %s%s%s%s%s%s\n",
- msg, state,
- (state & FX_ANTIALIAS) ? "antialias, " : "",
- (state & FX_FLAT) ? "flat, " : "",
- (state & FX_TWOSIDE) ? "twoside, " : "",
- (state & FX_OFFSET) ? "offset, " : "",
- (state & FX_FRONT_BACK) ? "front-back, " : "",
- (state & FX_FALLBACK) ? "fallback" : "");
-}
-
-
-void fxPrintHintState( const char *msg, GLuint state )
-{
- fprintf(stderr, "%s: (%x) %s %s%s %s%s\n",
- msg, state,
- (state & GR_STWHINT_W_DIFF_FBI) ? "w-fbi, " : "",
- (state & GR_STWHINT_W_DIFF_TMU0) ? "w-tmu0, " : "",
- (state & GR_STWHINT_ST_DIFF_TMU0) ? "st-tmu0, " : "",
- (state & GR_STWHINT_W_DIFF_TMU1) ? "w-tmu1, " : "",
- (state & GR_STWHINT_ST_DIFF_TMU1) ? "st-tmu1, " : "");
-
-}
-
-
-void fxDDChooseRenderState( GLcontext *ctx )
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLuint ind = 0;
- GLuint flags = ctx->TriangleCaps;
-
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
-
- if (flags) {
- if (fxMesa->render_index & FX_OFFSET)
- FX_grDepthBiasLevel(0);
-
- if (flags & (DD_SELECT|DD_FEEDBACK)) {
- fxMesa->PointsFunc = 0;
- fxMesa->LineFunc = 0;
- fxMesa->TriangleFunc = 0;
- fxMesa->QuadFunc = 0;
- fxMesa->render_index = FX_FALLBACK;
- ctx->IndirectTriangles |= DD_SW_RASTERIZE;
-#if 0
- fprintf(stderr, "Fallback select|feeback\n");
-#endif
- return;
- }
-
- if (flags & DD_FLATSHADE) ind |= FX_FLAT;
- if (flags & DD_TRI_LIGHT_TWOSIDE) ind |= FX_TWOSIDE;
- if (flags & DD_MULTIDRAW) ind |= FX_FRONT_BACK;
- if (flags & (DD_POINT_ATTEN|DD_POINT_SMOOTH)) {
- ind |= FX_FALLBACK;
-#if 0
- if (flags&DD_POINT_ATTEN)
- fprintf(stderr, "Fallback point atten\n");
- if (flags&DD_POINT_SMOOTH)
- fprintf(stderr, "Fallback point smooth\n");
-#endif
- }
-
- fxMesa->render_index = ind;
- fxMesa->PointsFunc = points_tab[ind];
- if (ind&FX_FALLBACK)
- ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
- ind &= ~(FX_ANTIALIAS|FX_FALLBACK);
-
- if (flags & (DD_LINE_STIPPLE|DD_LINE_SMOOTH)) {
- ind |= FX_FALLBACK;
-#if 0
- if (flags&DD_LINE_STIPPLE)
- fprintf(stderr, "Fallback line stipple\n");
- if (flags&DD_LINE_SMOOTH)
- fprintf(stderr, "Fallback line smooth\n");
-#endif
- }
-
- fxMesa->render_index |= ind;
- fxMesa->LineFunc = line_tab[ind];
- if (ind&FX_FALLBACK)
- ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
- ind &= ~(FX_ANTIALIAS|FX_FALLBACK);
-
- if (flags & DD_TRI_OFFSET) ind |= FX_OFFSET;
- if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE|DD_TRI_SMOOTH)) {
- ind |= FX_FALLBACK;
-#if 0
- if (flags&DD_TRI_UNFILLED)
- fprintf(stderr, "Fallback tri unfilled\n");
- if (flags&DD_TRI_STIPPLE)
- fprintf(stderr, "Fallback tri stippled\n");
- if (flags&DD_TRI_SMOOTH)
- fprintf(stderr, "Fallback tri smooth\n");
-#endif
- }
-
- fxMesa->render_index |= ind;
- fxMesa->TriangleFunc = tri_tab[ind];
- fxMesa->QuadFunc = quad_tab[ind];
-
- if (ind&FX_FALLBACK)
- ctx->IndirectTriangles |= DD_TRI_SW_RASTERIZE | DD_QUAD_SW_RASTERIZE;
- }
- else if (fxMesa->render_index)
- {
- if (fxMesa->render_index & FX_OFFSET)
- FX_grDepthBiasLevel(0);
-
- fxMesa->render_index = 0;
- fxMesa->PointsFunc = points_tab[0];
- fxMesa->LineFunc = line_tab[0];
- fxMesa->TriangleFunc = tri_tab[0];
- fxMesa->QuadFunc = quad_tab[0];
- }
-
- if (MESA_VERBOSE&(VERBOSE_STATE|VERBOSE_DRIVER))
- fxPrintRenderState("fxmesa: Render state", fxMesa->render_index);
-}
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-extern int gl_fx_dummy_function_tris(void);
-int gl_fx_dummy_function_tris(void)
-{
- return 0;
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxtritmp.h b/xc/extras/Mesa/src/FX/fxtritmp.h
deleted file mode 100644
index 6411d167a..000000000
--- a/xc/extras/Mesa/src/FX/fxtritmp.h
+++ /dev/null
@@ -1,474 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-static void TAG(fx_tri)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint pv)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- struct vertex_buffer *VB=ctx->VB;
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GrVertex *v1 = (GrVertex *)gWin[e1].f;
- GrVertex *v2 = (GrVertex *)gWin[e2].f;
- GrVertex *v3 = (GrVertex *)gWin[e3].f;
-
- (void) fxMesa;
-
- if (IND & (FX_TWOSIDE|FX_OFFSET))
- {
- GLfloat ex = v1->x - v3->x;
- GLfloat ey = v1->y - v3->y;
- GLfloat fx = v2->x - v3->x;
- GLfloat fy = v2->y - v3->y;
- GLfloat c = ex*fy-ey*fx;
-
- if (IND & FX_TWOSIDE) {
- GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
- GLubyte (*color)[4] = VB->Color[facing]->data;
- if (IND & FX_FLAT) {
- GOURAUD2(v1,color[pv]);
- GOURAUD2(v2,color[pv]);
- GOURAUD2(v3,color[pv]);
- } else {
- GOURAUD2(v1,color[e1]);
- GOURAUD2(v2,color[e2]);
- GOURAUD2(v3,color[e3]);
- }
- }
-
- /* Should apply a factor to ac to compensate for different x/y
- * scaling introduced in the Viewport matrix.
- *
- * The driver should supply scaling factors for 'factor' and 'units'.
- */
- if (IND & FX_OFFSET) {
- GLfloat offset = ctx->Polygon.OffsetUnits;
-
- if (c * c > 1e-16) {
- GLfloat factor = ctx->Polygon.OffsetFactor;
- GLfloat ez = v1->ooz - v3->ooz;
- GLfloat fz = v2->ooz - v3->ooz;
- GLfloat a = ey*fz-ez*fy;
- GLfloat b = ez*fx-ex*fz;
- GLfloat ic = 1.0 / c;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if (ac<0.0F) ac = -ac;
- if (bc<0.0F) bc = -bc;
- offset += MAX2( ac, bc ) * factor;
- }
- /* Probably a lot quicker just to nudge the z values and put
- * them back afterwards.
- */
- FX_grDepthBiasLevel((int)offset);
- }
- }
- else if (IND & FX_FLAT) {
- GLubyte (*color)[4] = VB->Color[0]->data;
- GOURAUD2(v1,color[pv]);
- GOURAUD2(v2,color[pv]);
- GOURAUD2(v3,color[pv]);
- }
-
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- FXFALSE);
-
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- }
-
- if (IND & FX_ANTIALIAS)
- FX_grAADrawTriangle(v1, v2, v3, FXTRUE, FXTRUE, FXTRUE);
- else
- FX_grDrawTriangle(v1, v2, v3);
-
- /* Might be quicker to do two passes, one for each buffer?
- */
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
-
- if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE);
-
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
-
- if (IND & FX_ANTIALIAS)
- FX_grAADrawTriangle(v1,v2,v3, FXTRUE,FXTRUE,FXTRUE);
- else
- FX_grDrawTriangle(v1, v2, v3);
- }
-}
-
-
-/* Not worth the space?
- */
-static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3,
- GLuint e4, GLuint pv)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- struct vertex_buffer *VB=ctx->VB;
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GrVertex *v1 = (GrVertex *)gWin[e1].f;
- GrVertex *v2 = (GrVertex *)gWin[e2].f;
- GrVertex *v3 = (GrVertex *)gWin[e3].f;
- GrVertex *v4 = (GrVertex *)gWin[e4].f;
-
- (void) fxMesa;
-
- if (IND & (FX_TWOSIDE|FX_OFFSET))
- {
- GLfloat ex = v3->x - v1->x;
- GLfloat ey = v3->y - v1->y;
- GLfloat fx = v4->x - v2->x;
- GLfloat fy = v4->y - v2->y;
- GLfloat c = ex*fy-ey*fx;
-
- if (IND & FX_TWOSIDE) {
- GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit;
- GLubyte (*color)[4] = VB->Color[facing]->data;
- if (IND & FX_FLAT) {
- GOURAUD2(v1,color[pv]);
- GOURAUD2(v2,color[pv]);
- GOURAUD2(v3,color[pv]);
- GOURAUD2(v4,color[pv]);
- } else {
- GOURAUD2(v1,color[e1]);
- GOURAUD2(v2,color[e2]);
- GOURAUD2(v3,color[e3]);
- GOURAUD2(v4,color[e4]);
- }
- }
-
- /* Should apply a factor to ac to compensate for different x/y
- * scaling introduced in the Viewport matrix.
- *
- * The driver should supply scaling factors for 'factor' and 'units'.
- */
- if (IND & FX_OFFSET) {
- GLfloat offset = ctx->Polygon.OffsetUnits;
-
- if (c * c > 1e-16) {
- GLfloat factor = ctx->Polygon.OffsetFactor;
- GLfloat ez = v3->ooz - v1->ooz;
- GLfloat fz = v4->ooz - v2->ooz;
- GLfloat a = ey*fz-ez*fy;
- GLfloat b = ez*fx-ex*fz;
- GLfloat ic = 1.0 / c;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if (ac<0.0F) ac = -ac;
- if (bc<0.0F) bc = -bc;
- offset += MAX2( ac, bc ) * factor;
- }
- /* Probably a lot quicker just to nudge the z values and put
- * them back afterwards.
- */
- FX_grDepthBiasLevel((int)offset);
- }
- }
- else if (IND & FX_FLAT) {
- GLubyte (*color)[4] = VB->Color[0]->data;
- GOURAUD2(v1,color[pv]);
- GOURAUD2(v2,color[pv]);
- GOURAUD2(v3,color[pv]);
- GOURAUD2(v4,color[pv]);
- }
-
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- FXFALSE);
-
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- }
-
- if (IND & FX_ANTIALIAS) {
- FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
- FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
- } else {
- FX_grDrawTriangle(v1, v2, v4);
- FX_grDrawTriangle(v2, v3, v4);
- }
-
- /* Might be quicker to do two passes, one for each buffer?
- */
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
-
- if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE);
-
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
-
- if (IND & FX_ANTIALIAS) {
- FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
- FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
- } else {
- FX_grDrawTriangle(v1, v2, v4);
- FX_grDrawTriangle(v2, v3, v4);
- }
- }
-}
-
-#define DRAW_LINE(tmp0, tmp1, width) \
- do { \
- const float xoff = 0.125, yoff = 0.125; \
- GrVertex verts[4]; \
- float dx, dy, wx, wy; \
- \
- dx = tmp0->x - tmp1->x; \
- dy = tmp0->y - tmp1->y; \
- \
- if (dx * dx > dy * dy) { \
- wx = 0; \
- wy = width; \
- } else { \
- wx = width; \
- wy = 0; \
- } \
- \
- verts[0] = *tmp0; \
- verts[1] = *tmp0; \
- verts[2] = *tmp1; \
- verts[3] = *tmp1; \
- \
- verts[0].x = tmp0->x - wx + xoff; \
- verts[0].y = tmp0->y - wy + yoff; \
- \
- verts[1].x = tmp0->x + wx + xoff; \
- verts[1].y = tmp0->y + wy + yoff; \
- \
- verts[2].x = tmp1->x + wx + xoff; \
- verts[2].y = tmp1->y + wy + yoff; \
- \
- verts[3].x = tmp1->x - wx + xoff; \
- verts[3].y = tmp1->y - wy + yoff; \
- \
- FX_grDrawPolygonVertexList(4, verts); \
- } while (0)
-
-#if (IND & FX_OFFSET) == 0
-static void TAG(fx_line)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint pv)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- struct vertex_buffer *VB=ctx->VB;
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLubyte (* const color)[4] = VB->ColorPtr->data;
- GrVertex *v1 = (GrVertex *)gWin[e1].f;
- GrVertex *v2 = (GrVertex *)gWin[e2].f;
- GLfloat w = ctx->Line.Width*.5;
-
- if (IND & FX_FLAT) {
- v1->r = v2->r = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][0]);
- v1->g = v2->g = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][1]);
- v1->b = v2->b = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][2]);
- v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]);
- }
- else if (IND & FX_TWOSIDE)
- {
- /* XXX use signed area of the polygon to determine front/back color choice */
- GOURAUD2(v1,color[e1]);
- GOURAUD2(v2,color[e2]);
- }
-
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- FXFALSE);
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- }
-
- if (IND & FX_ANTIALIAS)
- FX_grAADrawLine(v1,v2);
- else
- DRAW_LINE(v1,v2,w);
-
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
-
- if(ctx->Depth.Mask)
- FX_grDepthMask(FXTRUE);
-
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
-
- if (IND & FX_ANTIALIAS)
- FX_grAADrawLine(v1,v2);
- else
- DRAW_LINE(v1,v2,w);
- }
-}
-#endif
-
-
-#if (IND & FX_OFFSET) == 0
-
-#if IND & FX_FLAT
-# if IND & FX_ANTIALIAS
-#if FX_USE_PARGB
-# define FLAT_COLOR(x,y) GET_PA(gWin[i].f) = y[3];
-#else
-# define FLAT_COLOR(x,y) gWin[i].f[ACOORD] = y[3]; \
- FX_VB_COLOR(x, y)
-#endif
-# else
-# define FLAT_COLOR(x,y) FX_VB_COLOR(x, y)
-# endif
-#else
-#define FLAT_COLOR(x,y)
-#endif
-
-
-#define DRAW_POINT(i, sz) \
- do { \
- GrVertex verts[4], *tmp; \
- \
- tmp = (GrVertex*)gWin[i].f; \
- verts[0] = *tmp; \
- verts[1] = *tmp; \
- verts[2] = *tmp; \
- verts[3] = *tmp; \
- verts[0].x = verts[3].x = tmp->x + sz; \
- verts[0].y = verts[1].y = tmp->y + sz; \
- verts[2].x = verts[1].x = tmp->x - sz; \
- verts[2].y = verts[3].y = tmp->y - sz; \
- \
- FX_grDrawPolygonVertexList(4, verts); \
- } while (0)
-
-static void TAG(fx_points)(GLcontext *ctx, GLuint first, GLuint last)
-{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- struct vertex_buffer *VB = ctx->VB;
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLubyte (*color)[4] = VB->ColorPtr->data;
- GLuint i;
- GLfloat sz = ctx->Point.Size * .5;
-
- (void) color; (void) fxMesa;
-
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- FXFALSE);
-
- FX_grDepthMask(FXFALSE);
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- }
-
- if(!VB->ClipOrMask) {
- for(i=first;i<=last;i++) {
- FLAT_COLOR(fxMesa, color[i]);
- DRAW_POINT(i, sz);
- }
- } else {
- for(i=first;i<=last;i++) {
- if(VB->ClipMask[i]==0) {
- FLAT_COLOR(fxMesa, color[i]);
- DRAW_POINT(i, sz);
- }
- }
- }
-
- if (IND & FX_FRONT_BACK) {
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
- if(ctx->Depth.Mask)
- FX_grDepthMask(FXTRUE);
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
-
-
- if(!VB->ClipOrMask) {
- for(i=first;i<=last;i++) {
- FLAT_COLOR(fxMesa, color[i]);
- DRAW_POINT(i, sz);
- }
- } else {
- for(i=first;i<=last;i++) {
- if(VB->ClipMask[i]==0) {
- FLAT_COLOR(fxMesa, color[i]);
- DRAW_POINT(i, sz);
- }
- }
- }
- }
-}
-
-#endif
-
-
-
-static void TAG(init)( void )
-{
- tri_tab[IND] = TAG(fx_tri);
- quad_tab[IND] = TAG(fx_quad);
-
-#if ((IND & FX_OFFSET) == 0)
- line_tab[IND] = TAG(fx_line);
- points_tab[IND] = TAG(fx_points);
-#else
- line_tab[IND] = line_tab[IND & ~FX_OFFSET];
- points_tab[IND] = points_tab[IND & ~FX_OFFSET];
-#endif
-}
-
-#undef IND
-#undef TAG
-#undef FLAT_COLOR
-#undef DRAW_POINT
diff --git a/xc/extras/Mesa/src/FX/fxvs_tmp.h b/xc/extras/Mesa/src/FX/fxvs_tmp.h
deleted file mode 100644
index d9001db5e..000000000
--- a/xc/extras/Mesa/src/FX/fxvs_tmp.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#if (IND & (SETUP_XY|SETUP_W|SETUP_Z))
-#define V1 VARS_XY
-#define I1 , INCR_XY
-#else
-#define V1
-#define I1
-#endif
-
-#if (IND & SETUP_XY)
-#define S1 DO_SETUP_XY
-#else
-#define S1
-#endif
-
-#if (IND & SETUP_W)
-#define S2 S1 DO_SETUP_W
-#define V2 V1 VARS_W
-#else
-#define S2 S1
-#define V2 V1
-#endif
-
-#if (IND & SETUP_Z)
-#define S3 S2 DO_SETUP_Z
-#else
-#define S3 S2
-#endif
-
-#if (IND & SETUP_RGBA)
-#define V4 V2 VARS_RGBA
-#define S4 S3 DO_SETUP_RGBA
-#define I4 I1 , INCR_RGBA
-#else
-#define V4 V2
-#define S4 S3
-#define I4 I1
-#endif
-
-#if (IND & SETUP_TMU0)
-#define V5 V4 VARS_TMU0
-#define S5 S4 DO_SETUP_TMU0
-#define I5 I4 , INCR_TMU0
-#define F5 FIXUP_TMU0
-#else
-#define V5 V4
-#define S5 S4
-#define I5 I4
-#define F5
-#endif
-
-#if (IND & SETUP_TMU1)
-#define V6 V5 VARS_TMU1
-#define S6 S5 DO_SETUP_TMU1
-#define I6 I5 , INCR_TMU1
-#define F6 F5 FIXUP_TMU1
-#else
-#define V6 V5
-#define S6 S5
-#define I6 I5
-#define F6 F5
-#endif
-
-#if (IND & SETUP_TMU0) && (IND & SETUP_TMU1)
-#define F7 FIXUP_TMU01
-#else
-#define F7 F6
-#endif
-
-#define VARS V6
-#define DO_SETUP S6
-#define INCR I6
-#define FIXUP F7
-
-static void NAME(struct vertex_buffer *VB, GLuint start, GLuint end)
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
-
- if (fxMesa->new_state)
- fxSetupFXUnits( ctx );
-
- {
- const float snapper = (3L<<18);
- fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
- GLfloat *v = gWin[start].f;
- GLfloat *vend = gWin[end].f;
- VARS;
-
- (void) gWin;
- (void) fxMesa;
- (void) snapper;
-
- if (VB->ClipOrMask) {
- GLubyte *clipmask = &VB->ClipMask[start];
- for (;v!=vend;v+=16,clipmask++ INCR) {
- if (*clipmask == 0) {
- DO_SETUP;
- }
- }
- }
- else {
- for (;v!=vend;v+=16 INCR) {
- DO_SETUP;
- }
- }
-
- if (ctx->FogMode == FOG_FRAGMENT && ctx->ProjectionMatrix.m[15] != 0.0F) {
- /* need to compute W values for fogging purposes */
- const GLfloat m10 = ctx->ProjectionMatrix.m[10];
- const GLfloat m14 = ctx->ProjectionMatrix.m[14];
- const GLfloat v10 = ctx->Viewport.WindowMap.m[10];
- const GLfloat v14 = ctx->Viewport.WindowMap.m[14];
- GLfloat *v = gWin[start].f;
- GLfloat *win = VB->Win.data[start];
- if (VB->ClipOrMask) {
- GLubyte *clipmask = &VB->ClipMask[start];
- for (;v!=vend;v+=16,clipmask++, win+=4) {
- if (*clipmask == 0) {
- GLfloat zNDC = (win[2] - v14) / v10;
- GLfloat zEye = (zNDC - m14) / m10;
- v[OOWCOORD] = -1.0F / zEye;
- }
- }
- }
- else {
- for (;v!=vend;v+=16, win+=4) {
- GLfloat zNDC = (win[2] - v14) / v10;
- GLfloat zEye = (zNDC - m14) / m10;
- v[OOWCOORD] = -1.0F / zEye;
- }
- }
- }
-
- /* rare - I hope */
- FIXUP;
- }
-}
-
-
-#undef V1
-#undef V2
-#undef V3
-#undef V4
-#undef V5
-#undef V6
-#undef VARS
-
-#undef S1
-#undef S2
-#undef S3
-#undef S4
-#undef S5
-#undef S6
-#undef DO_SETUP
-
-#undef I1
-#undef I4
-#undef I5
-#undef I6
-#undef INCR
-
-#undef F5
-#undef F6
-#undef F7
-#undef FIXUP
-
-
-#undef IND
-#undef NAME
-
diff --git a/xc/extras/Mesa/src/FX/fxvsetup.c b/xc/extras/Mesa/src/FX/fxvsetup.c
deleted file mode 100644
index ec7b3cfa1..000000000
--- a/xc/extras/Mesa/src/FX/fxvsetup.c
+++ /dev/null
@@ -1,575 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-/* fxvsetup.c - 3Dfx VooDoo vertices setup functions */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
-#include "mmath.h"
-#include "pipeline.h"
-#include "fxvsetup.h"
-
-void fxPrintSetupFlags( const char *msg, GLuint flags )
-{
- fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
- msg,
- flags,
- (flags & SETUP_XY) ? " xy," : "",
- (flags & SETUP_Z) ? " z," : "",
- (flags & SETUP_W) ? " w," : "",
- (flags & SETUP_RGBA) ? " rgba," : "",
- (flags & SETUP_TMU0) ? " tmu0," : "",
- (flags & SETUP_TMU1) ? " tmu1," : "");
-}
-
-static void project_texcoords( struct vertex_buffer *VB,
- GLuint tmu_nr, GLuint tc_nr,
- GLuint start, GLuint count )
-{
- fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
- GrTmuVertex *tmu = &(((GrVertex *)v->f)->tmuvtx[tmu_nr]);
- GLvector4f *vec = VB->TexCoordPtr[tc_nr];
-
- GLuint i;
- GLuint stride = vec->stride;
- GLfloat *data = VEC_ELT(vec, GLfloat, start);
-
- for (i = start ; i < count ; i++, STRIDE_F(data, stride), v++) {
- tmu->oow = v->f[OOWCOORD] * data[3];
- tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
- }
-}
-
-
-static void copy_w( struct vertex_buffer *VB,
- GLuint tmu_nr,
- GLuint start, GLuint count )
-{
- fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
- GrTmuVertex *tmu = &(((GrVertex *)v->f)->tmuvtx[tmu_nr]);
- GLuint i;
-
- for (i = start ; i < count ; i++, v++) {
- tmu->oow = v->f[OOWCOORD];
- tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
- }
-}
-
-
-static tfxSetupFunc setupfuncs[0x40];
-
-
-
-
-#define IND SETUP_XY
-#define NAME fxsetupXY
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_XY|SETUP_Z)
-#define NAME fxsetupXYZ
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_XY|SETUP_W)
-#define NAME fxsetupXYW
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_XY|SETUP_Z|SETUP_W)
-#define NAME fxsetupXYZW
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_RGBA|SETUP_XY)
-#define NAME fxsetupXYRGBA
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_RGBA|SETUP_XY|SETUP_Z)
-#define NAME fxsetupXYZRGBA
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_RGBA|SETUP_XY|SETUP_W)
-#define NAME fxsetupXYWRGBA
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
-#define NAME fxsetupXYZWRGBA
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU0|SETUP_XY|SETUP_W)
-#define NAME fxsetupXYWT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W)
-#define NAME fxsetupXYZWT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_W)
-#define NAME fxsetupXYWT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W)
-#define NAME fxsetupXYZWT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W)
-#define NAME fxsetupXYWRGBAT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
-#define NAME fxsetupXYZWRGBAT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W)
-#define NAME fxsetupXYWRGBAT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
-#define NAME fxsetupXYZWRGBAT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_RGBA)
-#define NAME fxsetupRGBA
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU0)
-#define NAME fxsetupT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1)
-#define NAME fxsetupT1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_TMU0)
-#define NAME fxsetupT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU0|SETUP_RGBA)
-#define NAME fxsetupRGBAT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_RGBA)
-#define NAME fxsetupRGBAT1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
-#define NAME fxsetupRGBAT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_RGBA)
-#define NAME fxsetupWRGBA
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_TMU0)
-#define NAME fxsetupWT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_TMU1)
-#define NAME fxsetupWT1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_TMU1|SETUP_TMU0)
-#define NAME fxsetupWT0T1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_TMU0|SETUP_RGBA)
-#define NAME fxsetupWRGBAT0
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_TMU1|SETUP_RGBA)
-#define NAME fxsetupWRGBAT1
-#include "fxvs_tmp.h"
-
-#define IND (SETUP_W|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
-#define NAME fxsetupWRGBAT0T1
-#include "fxvs_tmp.h"
-
-
-
-void fxDDSetupInit( void )
-{
- setupfuncs[SETUP_XY] = fxsetupXY;
- setupfuncs[SETUP_XY|SETUP_Z] = fxsetupXYZ;
- setupfuncs[SETUP_XY|SETUP_W] = fxsetupXYW;
- setupfuncs[SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZW;
-
- setupfuncs[SETUP_RGBA|SETUP_XY] = fxsetupXYRGBA;
- setupfuncs[SETUP_RGBA|SETUP_XY|SETUP_Z] = fxsetupXYZRGBA;
- setupfuncs[SETUP_RGBA|SETUP_XY|SETUP_W] = fxsetupXYWRGBA;
- setupfuncs[SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWRGBA;
-
- /* If we have texture and xy then we must have w.
- * If we have texture1 and w then we must have texture 0.
- */
- setupfuncs[SETUP_TMU0|SETUP_XY|SETUP_W] = fxsetupXYWT0;
- setupfuncs[SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWT0;
-
- setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_W] = fxsetupXYWT0T1;
- setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWT0T1;
-
- setupfuncs[SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W] = fxsetupXYWRGBAT0;
- setupfuncs[SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWRGBAT0;
-
- setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W] = fxsetupXYWRGBAT0T1;
- setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWRGBAT0T1;
-
- /* If we don't have xy then we can't have z... w is still a possibility.
- */
- setupfuncs[SETUP_RGBA] = fxsetupRGBA;
- setupfuncs[SETUP_TMU0] = fxsetupT0;
- setupfuncs[SETUP_TMU1] = fxsetupT1;
- setupfuncs[SETUP_TMU1|SETUP_TMU0] = fxsetupT0T1;
- setupfuncs[SETUP_TMU0|SETUP_RGBA] = fxsetupRGBAT0;
- setupfuncs[SETUP_TMU1|SETUP_RGBA] = fxsetupRGBAT1;
- setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] = fxsetupRGBAT0T1;
-
- setupfuncs[SETUP_W|SETUP_RGBA] = fxsetupWRGBA;
- setupfuncs[SETUP_W|SETUP_TMU0] = fxsetupWT0;
- setupfuncs[SETUP_W|SETUP_TMU1] = fxsetupWT1;
- setupfuncs[SETUP_W|SETUP_TMU1|SETUP_TMU0] = fxsetupWT0T1;
- setupfuncs[SETUP_W|SETUP_TMU0|SETUP_RGBA] = fxsetupWRGBAT0;
- setupfuncs[SETUP_W|SETUP_TMU1|SETUP_RGBA] = fxsetupWRGBAT1;
- setupfuncs[SETUP_W|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] = fxsetupWRGBAT0T1;
-
-}
-
-
-
-tfxSetupFunc fxDDChooseSetupFunction(GLcontext *ctx)
-{
- GLuint setupindex = SETUP_XY|SETUP_Z;
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
-
- fxMesa->setupindex = 0;
-
- if (ctx->RenderMode != GL_RENDER)
- return 0;
-
- fxMesa->tmu_source[0] = 0;
- fxMesa->tmu_source[1] = 1;
-
- fxMesa->tex_dest[0] = SETUP_TMU0;
- fxMesa->tex_dest[1] = SETUP_TMU1;
-
- if (ctx->Light.ShadeModel == GL_SMOOTH && !ctx->Light.Model.TwoSide)
- setupindex |= SETUP_RGBA;
-
- if (ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT)
- setupindex |= SETUP_RGBA|SETUP_W;
-
- if ((ctx->Texture.ReallyEnabled & (TEXTURE0_2D|TEXTURE0_3D)) == TEXTURE0_2D)
- {
- /* This doesn't work for non-RGBA textures
- if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
- setupindex &= ~SETUP_RGBA;
- */
- setupindex |= SETUP_TMU0|SETUP_W;
- }
-
- if ((ctx->Texture.ReallyEnabled & (TEXTURE1_2D|TEXTURE1_3D)) == TEXTURE1_2D)
- {
- setupindex |= SETUP_TMU1|SETUP_W;
- if (setupindex & SETUP_TMU0) { /* both TMUs in use */
- struct gl_texture_object *tObj=ctx->Texture.Unit[0].CurrentD[2];
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
-
- if (ti->whichTMU!=FX_TMU0) { /* TMU0 and TMU1 are swapped */
- fxMesa->tmu_source[0] = 1; fxMesa->tex_dest[1] = SETUP_TMU0;
- fxMesa->tmu_source[1] = 0; fxMesa->tex_dest[0] = SETUP_TMU1;
- }
- }
- }
-
- if (ctx->Color.BlendEnabled)
- setupindex |= SETUP_RGBA;
-
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_STATE))
- fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
-
- fxMesa->setupindex = setupindex;
- fxMesa->view_clip_tri = fxTriViewClipTab[setupindex&0x7];
- fxMesa->clip_tri_stride = fxTriClipStrideTab[setupindex&0x7];
- return setupfuncs[setupindex];
-}
-
-void fxDDDoRasterSetup( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count;
-
-#if 0 /* leaving this out fixes the Heretic2 stray polygon bug */
- if ((ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE) {
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- fxMesa->setupdone = 0;
- return;
- }
-#endif
-
- if (VB->Type == VB_CVA_PRECALC)
- fxDDPartialRasterSetup( VB );
- else if (ctx->Driver.RasterSetup) /* NULL if in feedback/selection mode */
- ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
-
-}
-
-
-/*
- * Need to check that merge&render will work before allowing this to
- * happen here. Therefore - need to know that this will be fired when
- * we get a forbidden input in the elt pipeline - and therefore need to check
- * whether we have one *now*. Similarly need to know if state changes cause
- * size4 texcoords to be introduced.
- */
-void fxDDCheckPartialRasterSetup( GLcontext *ctx, struct gl_pipeline_stage *d )
-{
- fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
- GLuint tmp = fxMesa->setupdone;
-
- d->type = 0;
- d->pre_forbidden_inputs = 0;
- fxMesa->setupdone = 0; /* cleared if we return */
-
- /* Indirect triangles must be rendered via the immediate pipeline.
- * If all rasterization is software, no need to set up.
- */
- if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
- return;
-
- if ((ctx->IndirectTriangles & DD_SW_SETUP) ||
- (ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE)
- return;
-
- if ((ctx->Texture.ReallyEnabled & 0xf) &&
- !(ctx->Array.Flags & VERT_TEX0_ANY))
- {
- if (ctx->TextureMatrix[0].type == MATRIX_GENERAL ||
- ctx->TextureMatrix[0].type == MATRIX_PERSPECTIVE ||
- (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
- return;
-
- d->pre_forbidden_inputs |= VERT_TEX0_4;
- }
-
- if ((ctx->Texture.ReallyEnabled & 0xf0) &&
- !(ctx->Array.Flags & VERT_TEX1_ANY))
- {
- if (ctx->TextureMatrix[1].type == MATRIX_GENERAL ||
- ctx->TextureMatrix[1].type == MATRIX_PERSPECTIVE ||
- (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
- return;
-
- d->pre_forbidden_inputs |= VERT_TEX1_4;
- }
-
-
- fxMesa->setupdone = tmp;
- d->inputs = 0;
- d->outputs = VERT_SETUP_PART;
- d->type = PIPE_PRECALC;
-}
-
-
-/* Will be different every time - no point in trying to precalc the
- * function to call.
- */
-void fxDDPartialRasterSetup( struct vertex_buffer *VB )
-{
- GLuint new = VB->pipeline->new_outputs;
- fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;
- GLuint ind = 0;
-
- FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count;
-
- if (new & VERT_WIN) {
- new = VB->pipeline->outputs;
- ind |= SETUP_XY|SETUP_W|SETUP_Z;
- }
-
- if (new & VERT_TEX0_ANY)
- ind |= SETUP_W | fxMesa->tex_dest[0];
-
- if (new & VERT_TEX1_ANY)
- ind |= SETUP_W | fxMesa->tex_dest[1];
-
- if (new & VERT_RGBA)
- ind |= SETUP_W|SETUP_RGBA;
-
- if ((new & VERT_WIN) == 0)
- ind &= ~(fxMesa->setupdone & SETUP_W);
-
- fxMesa->setupdone &= ~ind;
- ind &= fxMesa->setupindex;
- fxMesa->setupdone |= ind;
-
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE)) {
- gl_print_vert_flags("new outputs", VB->pipeline->new_outputs);
- fxPrintSetupFlags("fxmesa: partial setup function", ind);
- }
-
- if (ind)
- setupfuncs[ind]( VB, VB->Start, VB->Count );
-}
-
-/* Almost certainly never called.
- */
-void fxDDResizeVB( struct vertex_buffer *VB, GLuint size )
-{
- struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
-
- while (fvb->size < size)
- fvb->size *= 2;
-
- FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * fvb->size);
-
- FREE( fvb->vert_store );
- fvb->vert_store = MALLOC( sizeof(fxVertex) * fvb->size + 31);
- if (!fvb->vert_store || !VB->ClipMask)
- {
- fprintf(stderr,"fx Driver: out of memory !\n");
- fxCloseHardware();
- exit(-1);
- }
- fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
-
- gl_vector1ui_free( &fvb->clipped_elements );
- gl_vector1ui_alloc( &fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32 );
-
- if (!fvb->clipped_elements.start) goto memerror;
-
- return;
-memerror:
- fprintf(stderr,"fx Driver: out of memory !\n");
- fxCloseHardware();
- exit(-1);
-}
-
-
-void fxDDRegisterVB( struct vertex_buffer *VB )
-{
- struct tfxMesaVertexBuffer *fvb;
-
- fvb = (struct tfxMesaVertexBuffer *)calloc( 1, sizeof(*fvb) );
-
- /* This looks like it allocates a lot of memory, but it basically
- * just sets an upper limit on how much can be used - nothing like
- * this amount will ever be turned into 'real' memory.
- */
- if (VB->Type == VB_CVA_PRECALC) {
- fvb->size = VB->Size * 5;
- fvb->vert_store = MALLOC( sizeof(fxVertex) * fvb->size + 31);
- if (!fvb->vert_store) goto memerror;
-#if defined(FX_GLIDE3)
- fvb->triangle_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
- if (!fvb->triangle_b) goto memerror;
- fvb->strips_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
- if (!fvb->strips_b ) goto memerror;
-#endif
- fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
- gl_vector1ui_alloc( &fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32 );
- if (!fvb->clipped_elements.start) goto memerror;
-
- FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * fvb->size);
- if (!VB->ClipMask) goto memerror;
-
- } else {
- fvb->vert_store = MALLOC( sizeof(fxVertex) * (VB->Size + 12) + 31);
- if (!fvb->vert_store) goto memerror;
-#if defined(FX_GLIDE3)
- fvb->triangle_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
- if (!fvb->triangle_b) goto memerror;
- fvb->strips_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
- if (!fvb->strips_b ) goto memerror;
-#endif
- fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
- fvb->size = VB->Size + 12;
- }
-
-
- VB->driver_data = fvb;
- return;
-memerror:
- fprintf(stderr,"fx Driver: out of memory !\n");
- fxCloseHardware();
- exit(-1);
-}
-
-void fxDDUnregisterVB( struct vertex_buffer *VB )
-{
- struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
-
- if (fvb) {
- if (fvb->vert_store) FREE(fvb->vert_store);
- gl_vector1ui_free( &fvb->clipped_elements );
- FREE(fvb);
-#if defined(FX_GLIDE3)
- if (fvb->strips_b)
- FREE(fvb->strips_b);
- if (fvb->triangle_b)
- FREE(fvb->triangle_b);
-#endif
- VB->driver_data = 0;
- }
-}
-
-
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-int gl_fx_dummy_function_vsetup(void)
-{
- return 0;
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/FX/fxvsetup.h b/xc/extras/Mesa/src/FX/fxvsetup.h
deleted file mode 100644
index 48123c46b..000000000
--- a/xc/extras/Mesa/src/FX/fxvsetup.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-#ifndef _FXVSETUP_H_
-#define _FXVSETUP_H_
-
-
-#define VARS_W
-
-#define VARS_Z
-
-#define VARS_TMU0 \
- GLuint tmu0_source = fxMesa->tmu_source[0]; \
- GLfloat *tmu0_data = VEC_ELT(VB->TexCoordPtr[tmu0_source], \
- GLfloat, start); \
- GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride; \
- GLuint tmu0_sz = VB->TexCoordPtr[tmu0_source]->size; \
- struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source]; \
- GLfloat sscale0 = FX_TEXTURE_DATA(t0)->sScale; \
- GLfloat tscale0 = FX_TEXTURE_DATA(t0)->tScale;
-
-#define VARS_TMU1 \
- GLuint tmu1_source = fxMesa->tmu_source[1]; \
- GLfloat *tmu1_data = VEC_ELT(VB->TexCoordPtr[tmu1_source], \
- GLfloat, start); \
- GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride; \
- GLuint tmu1_sz = VB->TexCoordPtr[tmu1_source]->size; \
- struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source]; \
- GLfloat sscale1 = FX_TEXTURE_DATA(t1)->sScale; \
- GLfloat tscale1 = FX_TEXTURE_DATA(t1)->tScale;
-
-#define VARS_RGBA \
- GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, start); \
- GLuint col_stride = VB->ColorPtr->stride;
-
-#define VARS_XY GLfloat *win = VB->Win.data[start];
-
-#define INCR_XY win += 4
-
-
-#ifdef FX_V2
-# define DO_SETUP_XY \
- v[XCOORD]=win[0]; \
- v[YCOORD]=win[1];
-#else
-#ifdef DRIVERTS
-# define DO_SETUP_XY \
- v[XCOORD]=win[0]+fxMesa->x_offset; \
- v[YCOORD]=win[1]+fxMesa->y_delta;
-#else
-# if (defined(__linux__) && defined(__i386__)) || defined(macintosh)
-# define DO_SETUP_XY { \
- GLfloat t1 = win[0] + snapper; \
- GLfloat t2 = win[1] + snapper; \
- v[XCOORD] = t1 - snapper; \
- v[YCOORD] = t2 - snapper; \
- }
-# else
-# define DO_SETUP_XY { \
- /* trunc (x,y) to multiple of 1/16 */ \
- v[XCOORD]=((int)(win[0]*16.0f))*(1.0f/16.0f); \
- v[YCOORD]=((int)(win[1]*16.0f))*(1.0f/16.0f); \
- }
-# endif
-#endif
-#endif
-
-
-#define DO_SETUP_W { \
- v[OOWCOORD]=win[3]; \
-}
-
-#define DO_SETUP_Z v[ZCOORD]=win[2];
-
-#define DO_SETUP_TMU0 \
-{ \
- v[S0COORD]=sscale0*tmu0_data[0]*v[OOWCOORD]; \
- v[T0COORD]=tscale0*tmu0_data[1]*v[OOWCOORD]; \
-}
-
-#define INCR_TMU0 STRIDE_F(tmu0_data, tmu0_stride)
-
-#define DO_SETUP_TMU1 \
-{ \
- v[S1COORD]=sscale1*tmu1_data[0]*v[OOWCOORD]; \
- v[T1COORD]=tscale1*tmu1_data[1]*v[OOWCOORD]; \
-}
-
-#define INCR_TMU1 STRIDE_F(tmu1_data, tmu1_stride)
-
-#if FX_USE_PARGB
-#define DO_SETUP_RGBA \
- { GET_PARGB(v) = color[ACOMP] << 24 | color[RCOMP] << 16 | color[GCOMP] << 8 | color[BCOMP];}
-
-#else
-#define DO_SETUP_RGBA \
-{ \
- UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[RCOORD], color[0]); \
- UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[GCOORD], color[1]); \
- UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[BCOORD], color[2]); \
- UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[ACOORD], color[3]); \
-}
-#endif
-
-#define INCR_RGBA color += col_stride
-
-
-#define _FIXUP_PRE \
- GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 | \
- GR_STWHINT_W_DIFF_TMU1);
-
-#define _FIXUP_TMU0 \
- if (tmu0_sz == 4) { \
- project_texcoords( VB, 0, tmu0_source, start, end ); \
- hs |= GR_STWHINT_W_DIFF_TMU0; \
- }
-
-
-#define _FIXUP_TMU1 \
- if (tmu1_sz == 4) { \
- project_texcoords( VB, 1, tmu1_source, start, end ); \
- hs |= GR_STWHINT_W_DIFF_TMU1; \
- }
-
-
-#define _FIXUP_TMU01 \
- if (tmu0_sz == 4) { \
- project_texcoords( VB, 0, tmu0_source, start, end ); \
- if (tmu1_sz == 4) \
- project_texcoords( VB, 1, tmu1_source, start, end ); \
- else \
- copy_w( VB, 1, start, end ); \
- hs |= (GR_STWHINT_W_DIFF_TMU0|GR_STWHINT_W_DIFF_TMU1); \
- } else if (tmu1_sz == 4) { \
- project_texcoords( VB, 1, tmu1_source, start, end ); \
- hs |= GR_STWHINT_W_DIFF_TMU1; \
- }
-
-#define _FIXUP_POST \
- if (hs != fxMesa->stw_hint_state) { \
- fxMesa->stw_hint_state = hs; \
- FX_grHints(GR_HINT_STWHINT, hs); \
- }
-
-
-#define FIXUP_TMU0 { _FIXUP_PRE _FIXUP_TMU0 _FIXUP_POST }
-#define FIXUP_TMU1 { _FIXUP_PRE _FIXUP_TMU1 _FIXUP_POST }
-#define FIXUP_TMU01 { _FIXUP_PRE _FIXUP_TMU01 _FIXUP_POST }
-
-
-/* v - pointer to destination GrVertex
- * VB - source of data
- * i - index into vb for data
- */
-
-
-#endif
diff --git a/xc/extras/Mesa/src/FX/fxwgl.c b/xc/extras/Mesa/src/FX/fxwgl.c
deleted file mode 100644
index 1f0e16a95..000000000
--- a/xc/extras/Mesa/src/FX/fxwgl.c
+++ /dev/null
@@ -1,870 +0,0 @@
-/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-
-
-
-/* fxwgl.c - Microsoft wgl functions emulation for
- * 3Dfx VooDoo/Mesa interface
- */
-
-
-#ifdef __WIN32__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <windows.h>
-#include "GL/gl.h"
-
-#ifdef __cplusplus
- }
-#endif
-
-#include <stdio.h>
-#include "GL/fxmesa.h"
-#include "fxdrv.h"
-
-#define MAX_MESA_ATTRS 20
-
-struct __extensions__
-{
- PROC proc;
- char *name;
-};
-
-struct __pixelformat__
-{
- PIXELFORMATDESCRIPTOR pfd;
- GLint mesaAttr[MAX_MESA_ATTRS];
-};
-
-WINGDIAPI void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *);
-
-static struct __extensions__ ext[] = {
-
-#ifdef GL_EXT_polygon_offset
- { (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" },
-#endif
- { (PROC)glBlendEquationEXT, "glBlendEquationEXT" },
- { (PROC)glBlendColorEXT, "glBlendColorExt" },
- { (PROC)glVertexPointerEXT, "glVertexPointerEXT" },
- { (PROC)glNormalPointerEXT, "glNormalPointerEXT" },
- { (PROC)glColorPointerEXT, "glColorPointerEXT" },
- { (PROC)glIndexPointerEXT, "glIndexPointerEXT" },
- { (PROC)glTexCoordPointerEXT, "glTexCoordPointer" },
- { (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" },
- { (PROC)glGetPointervEXT, "glGetPointervEXT" },
- { (PROC)glArrayElementEXT, "glArrayElementEXT" },
- { (PROC)glDrawArraysEXT, "glDrawArrayEXT" },
- { (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" },
- { (PROC)glBindTextureEXT, "glBindTextureEXT" },
- { (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" },
- { (PROC)glGenTexturesEXT, "glGenTexturesEXT" },
- { (PROC)glIsTextureEXT, "glIsTextureEXT" },
- { (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" },
- { (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" },
- { (PROC)glTexImage3DEXT, "glTexImage3DEXT" },
- { (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" },
- { (PROC)gl3DfxSetPaletteEXT, "3DFX_set_global_palette" },
- { (PROC)glColorTableEXT, "glColorTableEXT" },
- { (PROC)glColorSubTableEXT, "glColorSubTableEXT" },
- { (PROC)glGetColorTableEXT, "glGetColorTableEXT" },
- { (PROC)glGetColorTableParameterfvEXT, "glGetColorTableParameterfvEXT" },
- { (PROC)glGetColorTableParameterivEXT, "glGetColorTableParameterivEXT" },
- { (PROC)glPointParameterfEXT, "glPointParameterfEXT" },
- { (PROC)glPointParameterfvEXT, "glPointParameterfvEXT" },
- { (PROC)glBlendFuncSeparateINGR, "glBlendFuncSeparateINGR" },
- { (PROC)glActiveTextureARB, "glActiveTextureARB" },
- { (PROC)glClientActiveTextureARB, "glClientActiveTextureARB" },
- { (PROC)glMultiTexCoord1dARB, "glMultiTexCoord1dARB" },
- { (PROC)glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB" },
- { (PROC)glMultiTexCoord1fARB, "glMultiTexCoord1fARB" },
- { (PROC)glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB" },
- { (PROC)glMultiTexCoord1iARB, "glMultiTexCoord1iARB" },
- { (PROC)glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB" },
- { (PROC)glMultiTexCoord1sARB, "glMultiTexCoord1sARB" },
- { (PROC)glMultiTexCoord1svARB, "glMultiTexCoord1svARB" },
- { (PROC)glMultiTexCoord2dARB, "glMultiTexCoord2dARB" },
- { (PROC)glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB" },
- { (PROC)glMultiTexCoord2fARB, "glMultiTexCoord2fARB" },
- { (PROC)glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB" },
- { (PROC)glMultiTexCoord2iARB, "glMultiTexCoord2iARB" },
- { (PROC)glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB" },
- { (PROC)glMultiTexCoord2sARB, "glMultiTexCoord2sARB" },
- { (PROC)glMultiTexCoord2svARB, "glMultiTexCoord2svARB" },
- { (PROC)glMultiTexCoord3dARB, "glMultiTexCoord3dARB" },
- { (PROC)glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB" },
- { (PROC)glMultiTexCoord3fARB, "glMultiTexCoord3fARB" },
- { (PROC)glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB" },
- { (PROC)glMultiTexCoord3iARB, "glMultiTexCoord3iARB" },
- { (PROC)glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB" },
- { (PROC)glMultiTexCoord3sARB, "glMultiTexCoord3sARB" },
- { (PROC)glMultiTexCoord3svARB, "glMultiTexCoord3svARB" },
- { (PROC)glMultiTexCoord4dARB, "glMultiTexCoord4dARB" },
- { (PROC)glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB" },
- { (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4fARB" },
- { (PROC)glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB" },
- { (PROC)glMultiTexCoord4iARB, "glMultiTexCoord4iARB" },
- { (PROC)glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB" },
- { (PROC)glMultiTexCoord4sARB, "glMultiTexCoord4sARB" },
- { (PROC)glMultiTexCoord4svARB, "glMultiTexCoord4svARB" },
- { (PROC)glLockArraysEXT, "glLockArraysEXT" },
- { (PROC)glUnlockArraysEXT, "glUnlockArraysEXT" }
-};
-
-static int qt_ext = sizeof(ext) / sizeof(ext[0]);
-
-struct __pixelformat__ pix[] =
-{
- /* None */
- {
- {
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 32,
- 8,0,8,8,8,16,0,24,
- 0,0,0,0,0,
- 0,
- 0,
- 0,
- PFD_MAIN_PLANE,
- 0,0,0,0
- },
- {
- FXMESA_DOUBLEBUFFER,
- FXMESA_ALPHA_SIZE, 0,
- FXMESA_DEPTH_SIZE, 0,
- FXMESA_STENCIL_SIZE, 0,
- FXMESA_ACCUM_SIZE, 0,
- FXMESA_NONE
- }
- },
-
- /* Alpha */
- {
- {
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 32,
- 8,0,8,8,8,16,8,24,
- 0,0,0,0,0,
- 0,
- 0,
- 0,
- PFD_MAIN_PLANE,
- 0,0,0,0
- },
- {
- FXMESA_DOUBLEBUFFER,
- FXMESA_ALPHA_SIZE, 8,
- FXMESA_DEPTH_SIZE, 0,
- FXMESA_STENCIL_SIZE, 0,
- FXMESA_ACCUM_SIZE, 0,
- FXMESA_NONE
- }
- },
-
- /* Depth */
- {
- {
- sizeof(PIXELFORMATDESCRIPTOR), 1,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
- PFD_TYPE_RGBA,
- 32,
- 8,0,8,8,8,16,0,24,
- 0,0,0,0,0,
- 16,
- 0,
- 0,
- PFD_MAIN_PLANE,
- 0,0,0,0
- },
- {
- FXMESA_DOUBLEBUFFER,
- FXMESA_ALPHA_SIZE, 0,
- FXMESA_DEPTH_SIZE, 16,
- FXMESA_STENCIL_SIZE, 0,
- FXMESA_ACCUM_SIZE, 0,
- FXMESA_NONE
- }
- }
-};
-static int qt_pix = sizeof(pix) / sizeof(pix[0]);
-
-static fxMesaContext ctx = NULL;
-static WNDPROC hWNDOldProc;
-static int curPFD = 0;
-static HDC hDC;
-static HWND hWND;
-
-static GLboolean haveDualHead;
-
-/* For the in-window-rendering hack */
-
-static GLboolean gdiWindowHack;
-static GLboolean gdiWindowHackEna;
-static void *dibSurfacePtr;
-static BITMAPINFO *dibBMI;
-static HBITMAP dibHBM;
-static HWND dibWnd;
-
-LONG GLAPIENTRY __wglMonitor(HWND hwnd,UINT message,UINT wParam,LONG lParam)
-
-{
- long ret; /* Now gives the resized window at the end to hWNDOldProc */
-
- if(ctx && hwnd == hWND) {
- switch(message) {
- case WM_PAINT:
- case WM_MOVE:
- break;
- case WM_DISPLAYCHANGE:
- case WM_SIZE:
- if (wParam != SIZE_MINIMIZED) {
- static int moving = 0;
- if (!moving) {
- if(fxQueryHardware()!=GR_SSTTYPE_VOODOO) {
- if(!FX_grSstControl(GR_CONTROL_RESIZE)) {
- moving = 1;
- SetWindowPos(hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER);
- moving = 0;
- if(!FX_grSstControl(GR_CONTROL_RESIZE)) {
- /*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK);*/
- PostMessage(hWND,WM_CLOSE,0,0);
- }
- }
- }
-
- /* Do the clipping in the glide library */
- FX_grClipWindow(0,0,FX_grSstScreenWidth(),FX_grSstScreenHeight());
- /* And let the new size set in the context */
- fxMesaUpdateScreenSize(ctx);
- }
- }
- break;
- case WM_ACTIVATE:
- if((fxQueryHardware()==GR_SSTTYPE_VOODOO) &&
- (!gdiWindowHack) &&
- (!haveDualHead)) {
- WORD fActive = LOWORD(wParam);
- BOOL fMinimized = (BOOL) HIWORD(wParam);
-
- if((fActive == WA_INACTIVE) || fMinimized)
- FX_grSstControl(GR_CONTROL_DEACTIVATE);
- else
- FX_grSstControl(GR_CONTROL_ACTIVATE);
- }
- break;
- case WM_SHOWWINDOW:
- break;
- case WM_SYSKEYDOWN:
- case WM_SYSCHAR:
- if(gdiWindowHackEna && (VK_RETURN == wParam)) {
- if(gdiWindowHack) {
- gdiWindowHack = GL_FALSE;
- FX_grSstControl(GR_CONTROL_ACTIVATE);
- } else {
- gdiWindowHack = GL_TRUE;
- FX_grSstControl(GR_CONTROL_DEACTIVATE);
- }
- }
- break;
- }
- }
-
- /* Finaly call the hWNDOldProc, which handles the resize witch the
- now changed window sizes */
- ret = CallWindowProc( hWNDOldProc, hwnd, message, wParam, lParam );
-
- return(ret);
-}
-
-BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,HGLRC hglrcDst,UINT mask)
-{
- return(FALSE);
-}
-
-HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
-{
- HWND hWnd;
- WNDPROC oldProc;
- int error;
-
- if(ctx) {
- SetLastError(0);
- return(NULL);
- }
-
- if(!(hWnd = WindowFromDC(hdc))) {
- SetLastError(0);
- return(NULL);
- }
-
- if(curPFD == 0) {
- SetLastError(0);
- return(NULL);
- }
-
- if((oldProc = (WNDPROC)GetWindowLong(hWnd,GWL_WNDPROC)) != __wglMonitor) {
- hWNDOldProc = oldProc;
- SetWindowLong(hWnd,GWL_WNDPROC,(LONG)__wglMonitor);
- }
-
-#ifndef FX_SILENT
- freopen("MESA.LOG","w",stderr);
-#endif
-
- ShowWindow(hWnd, SW_SHOWNORMAL);
- SetForegroundWindow(hWnd);
- Sleep(100); /* an hack for win95 */
-
- if(fxQueryHardware() == GR_SSTTYPE_VOODOO) {
- RECT cliRect;
-
- GetClientRect(hWnd,&cliRect);
- error = !(ctx = fxMesaCreateBestContext((GLuint)hWnd,cliRect.right,cliRect.bottom,
- pix[curPFD - 1].mesaAttr));
-
- if(!error) {
- /* create the DIB section for windowed rendering */
- DWORD *p;
-
- dibWnd = hWnd;
-
- hDC = GetDC(dibWnd);
-
- dibBMI = (BITMAPINFO*) MALLOC( sizeof(BITMAPINFO) + (256*sizeof(RGBQUAD)));
-
- memset(dibBMI,0,sizeof(BITMAPINFO) + (256*sizeof(RGBQUAD)));
-
- dibBMI->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dibBMI->bmiHeader.biWidth = ctx->width;
- dibBMI->bmiHeader.biHeight = -ctx->height;
- dibBMI->bmiHeader.biPlanes = (short)1;
- dibBMI->bmiHeader.biBitCount = (short)16;
- dibBMI->bmiHeader.biCompression = BI_BITFIELDS;
- dibBMI->bmiHeader.biSizeImage = 0;
- dibBMI->bmiHeader.biXPelsPerMeter = 0;
- dibBMI->bmiHeader.biYPelsPerMeter = 0;
- dibBMI->bmiHeader.biClrUsed = 3;
- dibBMI->bmiHeader.biClrImportant = 3;
-
- p = (DWORD*)dibBMI->bmiColors;
- p[0] = 0xF800;
- p[1] = 0x07E0;
- p[2] = 0x001F;
-
- dibHBM = CreateDIBSection(hDC, dibBMI, DIB_RGB_COLORS, &dibSurfacePtr, NULL, 0);
-
- ReleaseDC(dibWnd, hDC);
-
- gdiWindowHackEna = (dibHBM != NULL ? GL_TRUE : GL_FALSE);
-
- if (!getenv("MESA_WGL_FX") || !strcmp(getenv("MESA_WGL_FX"),"fullscreen"))
- gdiWindowHack = GL_FALSE;
- else {
- gdiWindowHack = GL_TRUE;
- FX_grSstControl(GR_CONTROL_DEACTIVATE);
- }
- }
- } else {
- /* For the Voodoo Rush */
-
- if(getenv("MESA_WGL_FX") && !strcmp(getenv("MESA_WGL_FX"),"fullscreen")) {
- RECT cliRect;
-
- GetClientRect(hWnd,&cliRect);
- error = !(ctx = fxMesaCreateBestContext((GLuint)hWnd,cliRect.right,cliRect.bottom,
- pix[curPFD - 1].mesaAttr));
- } else
- error = !(ctx = fxMesaCreateContext((GLuint)hWnd,GR_RESOLUTION_NONE,GR_REFRESH_75Hz,
- pix[curPFD - 1].mesaAttr));
- }
-
- if(getenv("SST_DUALHEAD"))
- haveDualHead=((atoi(getenv("SST_DUALHEAD"))==1) ? GL_TRUE:GL_FALSE);
- else
- haveDualHead=GL_FALSE;
-
- if(error) {
- SetLastError(0);
- return(NULL);
- }
-
- hDC = hdc;
- hWND = hWnd;
-
- /* Required by the OpenGL Optimizer 1.1 (is it a Optimizer bug ?) */
- wglMakeCurrent(hdc,(HGLRC)1);
-
- return((HGLRC)1);
-}
-
-HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,int iLayerPlane)
-{
- SetLastError(0);
- return(NULL);
-}
-
-BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
-{
- if(ctx && hglrc == (HGLRC)1) {
- if (gdiWindowHackEna) {
- DeleteObject(dibHBM);
- FREE(dibBMI);
-
- dibSurfacePtr = NULL;
- dibBMI = NULL;
- dibHBM = NULL;
- dibWnd = NULL;
- }
-
- fxMesaDestroyContext(ctx);
-
- SetWindowLong(WindowFromDC(hDC),GWL_WNDPROC,(LONG)hWNDOldProc);
-
- ctx = NULL;
- hDC = 0;
- return(TRUE);
- }
-
- SetLastError(0);
-
- return(FALSE);
-}
-
-HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
-{
- if(ctx)
- return((HGLRC)1);
-
- SetLastError(0);
- return(NULL);
-}
-
-HDC GLAPIENTRY wglGetCurrentDC(VOID)
-{
- if(ctx)
- return(hDC);
-
- SetLastError(0);
- return(NULL);
-}
-
-PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc)
-{
- int i;
-
- /*fprintf(stderr,"fxMesa: looking for extension %s\n",lpszProc);
- fflush(stderr);*/
-
- for(i = 0;i < qt_ext;i++)
- if(!strcmp(lpszProc,ext[i].name)) {
- /*fprintf(stderr,"fxMesa: found extension %s\n",lpszProc);
- fflush(stderr);*/
-
- return(ext[i].proc);
- }
- SetLastError(0);
- return(NULL);
-}
-
-BOOL GLAPIENTRY wglMakeCurrent(HDC hdc,HGLRC hglrc)
-{
- if((hdc==NULL) && (hglrc==NULL))
- return(TRUE);
-
- if(!ctx || hglrc != (HGLRC)1 || WindowFromDC(hdc) != hWND) {
- SetLastError(0);
- return(FALSE);
- }
-
- hDC = hdc;
-
- fxMesaMakeCurrent(ctx);
-
- return(TRUE);
-}
-
-BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,HGLRC hglrc2)
-{
- if(!ctx || hglrc1 != (HGLRC)1 || hglrc1 != hglrc2) {
- SetLastError(0);
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-BOOL GLAPIENTRY wglUseFontBitmaps(HDC fontDevice, DWORD firstChar, DWORD numChars, DWORD listBase)
-{
-#define VERIFY(a) a
-
- TEXTMETRIC metric;
- BITMAPINFO *dibInfo;
- HDC bitDevice;
- COLORREF tempColor;
- int i;
-
- VERIFY(GetTextMetrics(fontDevice, &metric));
-
- dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
- dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dibInfo->bmiHeader.biPlanes = 1;
- dibInfo->bmiHeader.biBitCount = 1;
- dibInfo->bmiHeader.biCompression = BI_RGB;
-
- bitDevice = CreateCompatibleDC(fontDevice);
- // HDC bitDevice = CreateDC("DISPLAY", NULL, NULL, NULL);
- // VERIFY(bitDevice);
-
- // Swap fore and back colors so the bitmap has the right polarity
- tempColor = GetBkColor(bitDevice);
- SetBkColor(bitDevice, GetTextColor(bitDevice));
- SetTextColor(bitDevice, tempColor);
-
- // Place chars based on base line
- VERIFY(SetTextAlign(bitDevice, TA_BASELINE) >= 0 ? 1 : 0);
-
- for(i = 0; i < numChars; i++) {
- SIZE size;
- char curChar;
- int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res;
- HBITMAP bitObject;
- HGDIOBJ origBmap;
- unsigned char *bmap;
-
- curChar = i + firstChar;
-
- // Find how high/wide this character is
- VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
-
- // Create the output bitmap
- charWidth = size.cx;
- charHeight = size.cy;
- bmapWidth = ((charWidth + 31) / 32) * 32; // Round up to the next multiple of 32 bits
- bmapHeight = charHeight;
- bitObject = CreateCompatibleBitmap(bitDevice,
- bmapWidth,
- bmapHeight);
- //VERIFY(bitObject);
-
- // Assign the output bitmap to the device
- origBmap = SelectObject(bitDevice, bitObject);
- VERIFY(origBmap);
-
- VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) );
-
- // Use our source font on the device
- VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT)));
-
- // Draw the character
- VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
-
- // Unselect our bmap object
- VERIFY(SelectObject(bitDevice, origBmap));
-
- // Convert the display dependant representation to a 1 bit deep DIB
- numBytes = (bmapWidth * bmapHeight) / 8;
- bmap = MALLOC(numBytes);
- dibInfo->bmiHeader.biWidth = bmapWidth;
- dibInfo->bmiHeader.biHeight = bmapHeight;
- res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
- dibInfo,
- DIB_RGB_COLORS);
- //VERIFY(res);
-
- // Create the GL object
- glNewList(i + listBase, GL_COMPILE);
- glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent,
- charWidth, 0.0,
- bmap);
- glEndList();
- // CheckGL();
-
- // Destroy the bmap object
- DeleteObject(bitObject);
-
- // Deallocate the bitmap data
- FREE(bmap);
- }
-
- // Destroy the DC
- VERIFY(DeleteDC(bitDevice));
-
- FREE(dibInfo);
-
- return TRUE;
-#undef VERIFY
-}
-
-BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,DWORD first,DWORD count,DWORD listBase)
-{
- return(FALSE);
-}
-
-BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,DWORD first,DWORD count,
- DWORD listBase,FLOAT deviation,
- FLOAT extrusion,int format,
- LPGLYPHMETRICSFLOAT lpgmf)
-{
- SetLastError(0);
- return(FALSE);
-}
-
-BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,DWORD first,DWORD count,
- DWORD listBase,FLOAT deviation,
- FLOAT extrusion,int format,
- LPGLYPHMETRICSFLOAT lpgmf)
-{
- SetLastError(0);
- return(FALSE);
-}
-
-
-BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc,UINT fuPlanes)
-{
- if(ctx && WindowFromDC(hdc) == hWND) {
- fxMesaSwapBuffers();
-
- return(TRUE);
- }
-
- SetLastError(0);
- return(FALSE);
-}
-
-int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
-{
- int i,best=-1,qt_valid_pix;
-
- qt_valid_pix = qt_pix;
-
- if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) {
- SetLastError(0);
- return(0);
- }
-
- for(i = 0;i < qt_valid_pix;i++) {
- if((ppfd->dwFlags & PFD_DRAW_TO_WINDOW) && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW))
- continue;
- if((ppfd->dwFlags & PFD_DRAW_TO_BITMAP) && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP))
- continue;
- if((ppfd->dwFlags & PFD_SUPPORT_GDI) && !(pix[i].pfd.dwFlags & PFD_SUPPORT_GDI))
- continue;
- if((ppfd->dwFlags & PFD_SUPPORT_OPENGL) && !(pix[i].pfd.dwFlags & PFD_SUPPORT_OPENGL))
- continue;
- if(!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
- ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != (pix[i].pfd.dwFlags & PFD_DOUBLEBUFFER)))
- continue;
- if(!(ppfd->dwFlags & PFD_STEREO_DONTCARE) &&
- ((ppfd->dwFlags & PFD_STEREO) != (pix[i].pfd.dwFlags & PFD_STEREO)))
- continue;
-
- if (ppfd->cDepthBits > 0 && pix[i].pfd.cDepthBits == 0)
- continue; /* need depth buffer */
-
- if (ppfd->cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0)
- continue; /* need alpha buffer */
-
- if(ppfd->iPixelType == pix[i].pfd.iPixelType) {
- best = i + 1;
- break;
- }
- }
-
- if(best == -1) {
- SetLastError(0);
- return(0);
- }
-
- return(best);
-}
-
-int GLAPIENTRY ChoosePixelFormat(HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
-{
- return wglChoosePixelFormat(hdc,ppfd);
-}
-
-int GLAPIENTRY wglDescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd)
-{
- int qt_valid_pix;
-
- qt_valid_pix = qt_pix;
-
- if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix ||
- ((nBytes != sizeof(PIXELFORMATDESCRIPTOR)) && (nBytes != 0))) {
- SetLastError(0);
- return(0);
- }
-
- if(nBytes != 0)
- *ppfd = pix[iPixelFormat - 1].pfd;
-
- return(qt_valid_pix);
-}
-
-int GLAPIENTRY DescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd)
-{
- return wglDescribePixelFormat(hdc,iPixelFormat,nBytes,ppfd);
-}
-
-int GLAPIENTRY wglGetPixelFormat(HDC hdc)
-{
- if(curPFD == 0) {
- SetLastError(0);
- return(0);
- }
-
- return(curPFD);
-}
-
-int GLAPIENTRY GetPixelFormat(HDC hdc)
-{
- return wglGetPixelFormat(hdc);
-}
-
-BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
-{
- int qt_valid_pix;
-
- qt_valid_pix = qt_pix;
-
- if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
- SetLastError(0);
- return(FALSE);
- }
- curPFD = iPixelFormat;
-
- return(TRUE);
-}
-
-BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
-{
- if(!ctx) {
- SetLastError(0);
- return(FALSE);
- }
-
- fxMesaSwapBuffers();
-
- if(gdiWindowHack) {
- GLuint width=ctx->width;
- GLuint height=ctx->height;
-
- HDC hdcScreen = GetDC(dibWnd);
- HDC hdcDIBSection = CreateCompatibleDC(hdcScreen);
- HBITMAP holdBitmap = (HBITMAP) SelectObject(hdcDIBSection, dibHBM);
-
- FX_grLfbReadRegion(GR_BUFFER_FRONTBUFFER, 0, 0,
- width, height,
- width * 2,
- dibSurfacePtr);
-
- /* Since the hardware is configured for GR_COLORFORMAT_ABGR the pixel data is
- * going to come out as BGR 565, which is reverse of what we need for blitting
- * to screen, so we need to convert it here pixel-by-pixel (ick). This loop would NOT
- * be required if the color format was changed to GR_COLORFORMAT_ARGB, but I do
- * not know the ramifications of that, so this will work until that is resolved.
- *
- * This routine CRIES out for MMX implementation, however since that's not
- * guaranteed to be running on MMX enabled hardware so I'm not going to do
- * that. I'm just going to try to make a reasonably efficient C
- * version. -TAJ
- *
- * This routine drops frame rate by <1 fps on a 200Mhz MMX processor with a 640x480
- * display. Obviously, it's performance hit will be higher on larger displays and
- * less on smaller displays. To support the window-hack display this is probably fine.
- */
-#if FXMESA_USE_ARGB
- {
- unsigned long *pixel = dibSurfacePtr;
- unsigned long count = (width * height) / 2;
-
- while (count--)
- {
- *pixel++ = (*pixel & 0x07e007e0) /* greens */
- | ((*pixel & 0xf800f800) >> 11) /* swap blues */
- | ((*pixel & 0x001f001f) << 11) /* swap reds */
- ;
- }
- }
-#endif
-
- BitBlt(hdcScreen, 0, 0,
- width, height,
- hdcDIBSection,
- 0, 0, SRCCOPY);
-
- ReleaseDC(dibWnd, hdcScreen);
- SelectObject(hdcDIBSection, holdBitmap);
- DeleteDC(hdcDIBSection);
- }
-
- return(TRUE);
-}
-
-BOOL GLAPIENTRY SetPixelFormat(HDC hdc, int iPixelFormat,
- CONST PIXELFORMATDESCRIPTOR *ppfd)
-{
- return wglSetPixelFormat(hdc,iPixelFormat,ppfd);
-}
-
-BOOL GLAPIENTRY SwapBuffers(HDC hdc)
-{
- return wglSwapBuffers(hdc);
-}
-
-#endif /* FX */
diff --git a/xc/extras/Mesa/src/OSmesa/osmesa.c b/xc/extras/Mesa/src/OSmesa/osmesa.c
index 62b18f9e6..13ff0a16c 100644
--- a/xc/extras/Mesa/src/OSmesa/osmesa.c
+++ b/xc/extras/Mesa/src/OSmesa/osmesa.c
@@ -225,6 +225,7 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist )
}
gl_extensions_enable(&(osmesa->gl_ctx),"GL_HP_occlusion_test");
gl_extensions_enable(&(osmesa->gl_ctx), "GL_ARB_texture_cube_map");
+ gl_extensions_enable(&(osmesa->gl_ctx), "GL_EXT_texture_env_combine");
osmesa->gl_buffer = gl_create_framebuffer( osmesa->gl_visual,
osmesa->gl_visual->DepthBits > 0,
diff --git a/xc/extras/Mesa/src/X/fakeglx.c b/xc/extras/Mesa/src/X/fakeglx.c
index 67e49aba5..2c5866489 100644
--- a/xc/extras/Mesa/src/X/fakeglx.c
+++ b/xc/extras/Mesa/src/X/fakeglx.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -30,7 +30,7 @@
*
* Thanks to the contributors:
*
- * Initial version: Philip Brown (philb@CSUA.Berkeley.EDU)
+ * Initial version: Philip Brown (phil@bolthole.com)
* Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
* Further visual-handling refinements: Wolfram Gloger
* (wmglo@Dent.MED.Uni-Muenchen.DE).
@@ -64,7 +64,7 @@
#define SERVER_MINOR_VERSION 3
/* This is appended onto the glXGetClient/ServerString version strings. */
-#define MESA_GLX_VERSION "Mesa 3.3"
+#define MESA_GLX_VERSION "Mesa 3.4"
/* Who implemented this GLX? */
#define VENDOR "Brian Paul"
diff --git a/xc/extras/Mesa/src/X/xmesa1.c b/xc/extras/Mesa/src/X/xmesa1.c
index 20ad79b81..662cae85e 100644
--- a/xc/extras/Mesa/src/X/xmesa1.c
+++ b/xc/extras/Mesa/src/X/xmesa1.c
@@ -22,6 +22,7 @@
* 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.
*/
+/* $XFree86: xc/extras/Mesa/src/X/xmesa1.c,v 1.6 2000/08/09 23:40:10 dawes Exp $ */
/*
@@ -59,12 +60,17 @@
*
*/
+#ifdef __CYGWIN__
+#undef WIN32
+#undef __WIN32__
+#endif
#include "glxheader.h"
#include "GL/xmesa.h"
#include "xmesaP.h"
#include "context.h"
#include "extensions.h"
+#include "glthread.h"
#include "matrix.h"
#include "mem.h"
#include "types.h"
@@ -79,9 +85,9 @@
/*
- * Current X/Mesa context pointer:
+ * Global X driver lock
*/
-static XMesaContext XMesa = NULL;
+_glthread_Mutex _xmesa_lock;
/*
@@ -237,7 +243,9 @@ static void get_drawable_size( XMesaDisplay *dpy, XMesaDrawable d,
int x, y;
unsigned int bw, depth;
+ _glthread_LOCK_MUTEX(_xmesa_lock);
XGetGeometry( dpy, d, &root, &x, &y, width, height, &bw, &depth );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
#endif
}
@@ -1459,10 +1467,14 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
/* For debugging only */
if (getenv("MESA_XSYNC")) {
+ /* This makes debugging X easier.
+ * In your debugger, set a breakpoint on _XError to stop when an
+ * X protocol error is generated.
+ */
#ifdef XFree86Server
/* NOT_NEEDED */
#else
- XSynchronize( display, 1 ); /* This makes debugging X easier */
+ XSynchronize( display, 1 );
#endif
}
@@ -1553,6 +1565,9 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
}
}
+ if (alpha_flag && alpha_bits == 0)
+ alpha_bits = 8;
+
v->gl_visual = _mesa_create_visual( rgb_flag, db_flag, stereo_flag,
red_bits, green_bits,
blue_bits, alpha_bits,
@@ -1603,6 +1618,12 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
XMesaContext c;
GLboolean direct = GL_TRUE; /* XXXX */
/* NOT_DONE: should this be GL_FALSE??? */
+ static GLboolean firstTime = GL_TRUE;
+
+ if (firstTime) {
+ _glthread_INIT_MUTEX(_xmesa_lock);
+ firstTime = GL_FALSE;
+ }
c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
if (!c) {
@@ -1619,6 +1640,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
gl_extensions_enable(c->gl_ctx, "GL_HP_occlusion_test");
gl_extensions_enable(c->gl_ctx, "GL_ARB_texture_cube_map");
+ gl_extensions_enable(c->gl_ctx, "GL_EXT_texture_env_combine");
if (CHECK_BYTE_ORDER(v)) {
c->swapbytes = GL_FALSE;
@@ -1682,10 +1704,6 @@ void XMesaDestroyContext( XMesaContext c )
}
}
- /* Set current context ptr to NULL if we freed it */
- if (XMesa == c)
- XMesa = NULL;
-
FREE( c );
}
@@ -2012,7 +2030,6 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
#ifdef FX
if (drawBuffer->FXctx) {
fxMesaMakeCurrent(drawBuffer->FXctx);
- XMesa = c;
/* Disassociate old buffer from this context */
if (c->xm_buffer)
@@ -2046,7 +2063,6 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
c->use_read_buffer = (drawBuffer != readBuffer);
gl_make_current2(c->gl_ctx, drawBuffer->gl_buffer, readBuffer->gl_buffer);
- XMesa = c;
if (c->gl_ctx->Viewport.Width == 0) {
/* initialize viewport to window size */
@@ -2078,7 +2094,6 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
else {
/* Detach */
gl_make_current2( NULL, NULL, NULL );
- XMesa = NULL;
}
return GL_TRUE;
}
@@ -2096,14 +2111,23 @@ GLboolean XMesaUnbindContext( XMesaContext c )
XMesaContext XMesaGetCurrentContext( void )
{
- return XMesa;
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ return xmesa;
+ }
+ else {
+ return 0;
+ }
}
XMesaBuffer XMesaGetCurrentBuffer( void )
{
- if (XMesa) {
- return XMesa->xm_buffer;
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ return xmesa->xm_buffer;
}
else {
return 0;
@@ -2114,8 +2138,10 @@ XMesaBuffer XMesaGetCurrentBuffer( void )
/* New in Mesa 3.1 */
XMesaBuffer XMesaGetCurrentReadBuffer( void )
{
- if (XMesa) {
- return XMesa->xm_buffer;
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ return xmesa->xm_buffer;
}
else {
return 0;
@@ -2128,12 +2154,10 @@ GLboolean XMesaForceCurrent(XMesaContext c)
if (c) {
if (c->gl_ctx != gl_get_current_context()) {
gl_make_current(c->gl_ctx, c->xm_buffer->gl_buffer);
- XMesa = c;
}
}
else {
gl_make_current(NULL, NULL);
- XMesa = NULL;
}
return GL_TRUE;
}
@@ -2143,7 +2167,6 @@ GLboolean XMesaLoseCurrent(XMesaContext c)
{
(void) c;
gl_make_current(NULL, NULL);
- XMesa = NULL;
return GL_TRUE;
}
@@ -2156,6 +2179,7 @@ GLboolean XMesaSetFXmode( GLint mode )
#ifdef FX
const char *fx = getenv("MESA_GLX_FX");
if (fx && fx[0] != 'd') {
+ GET_CURRENT_CONTEXT(ctx);
GrHwConfiguration hw;
if (!FX_grSstQueryHardware(&hw)) {
/*fprintf(stderr, "!grSstQueryHardware\n");*/
@@ -2165,17 +2189,18 @@ GLboolean XMesaSetFXmode( GLint mode )
/*fprintf(stderr, "hw.num_sst < 1\n");*/
return GL_FALSE;
}
- if (XMesa) {
+ if (ctx) {
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (mode == XMESA_FX_WINDOW) {
- if (XMesa->xm_buffer->FXisHackUsable) {
+ if (xmesa->xm_buffer->FXisHackUsable) {
FX_grSstControl(GR_CONTROL_DEACTIVATE);
- XMesa->xm_buffer->FXwindowHack = GL_TRUE;
+ xmesa->xm_buffer->FXwindowHack = GL_TRUE;
return GL_TRUE;
}
}
else if (mode == XMESA_FX_FULLSCREEN) {
FX_grSstControl(GR_CONTROL_ACTIVATE);
- XMesa->xm_buffer->FXwindowHack = GL_FALSE;
+ xmesa->xm_buffer->FXwindowHack = GL_FALSE;
return GL_TRUE;
}
else {
@@ -2202,8 +2227,9 @@ static void FXgetImage( XMesaBuffer b )
int x, y;
XMesaWindow root;
unsigned int bw, depth, width, height;
+ XMesaContext xmesa = (XMesaContext) b->xm_context->gl_ctx->DriverCtx;
- assert(XMesa->xm_buffer->FXctx);
+ assert(xmesa->xm_buffer->FXctx);
#ifdef XFree86Server
x = b->frontbuffer->x;
@@ -2212,30 +2238,29 @@ static void FXgetImage( XMesaBuffer b )
height = b->frontbuffer->height;
depth = b->frontbuffer->depth;
#else
- XGetGeometry( XMesa->xm_visual->display, b->frontbuffer,
+ XGetGeometry( xmesa->xm_visual->display, b->frontbuffer,
&root, &x, &y, &width, &height, &bw, &depth);
#endif
if (b->width != width || b->height != height) {
- b->width = MIN2((int)width, XMesa->xm_buffer->FXctx->width);
- b->height = MIN2((int)height, XMesa->xm_buffer->FXctx->height);
+ b->width = MIN2((int)width, xmesa->xm_buffer->FXctx->width);
+ b->height = MIN2((int)height, xmesa->xm_buffer->FXctx->height);
if (b->width & 1)
b->width--; /* prevent odd width */
xmesa_alloc_back_buffer( b );
}
grLfbWriteColorFormat(GR_COLORFORMAT_ARGB);
- if (XMesa->xm_visual->undithered_pf==PF_5R6G5B) {
+ if (xmesa->xm_visual->undithered_pf==PF_5R6G5B) {
/* Special case: 16bpp RGB */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */
- 0, XMesa->xm_buffer->FXctx->height - b->height, /*pos*/
+ 0, xmesa->xm_buffer->FXctx->height - b->height, /*pos*/
b->width, b->height, /* size */
b->width * sizeof(GLushort), /* stride */
b->backimage->data); /* dest buffer */
}
- else if (XMesa->xm_visual->dithered_pf==PF_DITHER
- && GET_VISUAL_DEPTH(XMesa->xm_visual)==8) {
+ else if (xmesa->xm_visual->dithered_pf==PF_DITHER
+ && GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
/* Special case: 8bpp RGB */
- XMesaContext xmesa = XMesa; /* Needed for DITHER macros */
for (y=0;y<b->height;y++) {
GLubyte *ptr = (GLubyte*) xmesa->xm_buffer->backimage->data
+ xmesa->xm_buffer->backimage->bytes_per_line * y;
@@ -2243,7 +2268,7 @@ static void FXgetImage( XMesaBuffer b )
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
- 0, XMesa->xm_buffer->FXctx->height-(b->height-y),
+ 0, xmesa->xm_buffer->FXctx->height-(b->height-y),
b->width, 1,
0,
pixbuf );
@@ -2262,7 +2287,7 @@ static void FXgetImage( XMesaBuffer b )
for (y=0;y<b->height;y++) {
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
- 0, XMesa->xm_buffer->FXctx->height-(b->height-y),
+ 0, xmesa->xm_buffer->FXctx->height-(b->height-y),
b->width, 1,
0,
pixbuf );
@@ -2270,11 +2295,11 @@ static void FXgetImage( XMesaBuffer b )
/* write to XImage back buffer */
for (x=0;x<b->width;x++) {
XMesaPutPixel(b->backimage,x,y,
- xmesa_color_to_pixel(XMesa,
+ xmesa_color_to_pixel(xmesa,
(pixbuf[x] & 0xf800) >> 8,
(pixbuf[x] & 0x07e0) >> 3,
(pixbuf[x] & 0x001f) << 3,
- 0xff, XMesa->pixelformat));
+ 0xff, xmesa->pixelformat));
}
}
}
@@ -2289,18 +2314,20 @@ static void FXgetImage( XMesaBuffer b )
*/
void XMesaSwapBuffers( XMesaBuffer b )
{
-#ifdef PROFILE
- GLdouble t0 = gl_time();
-#endif
+ GET_CURRENT_CONTEXT(ctx);
- _mesa_swapbuffers(XMesa->gl_ctx);
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ if (b->xm_context && b->xm_context->gl_ctx == ctx)
+ _mesa_swapbuffers(ctx);
if (b->db_state) {
#ifdef FX
- if (XMesa->xm_buffer->FXctx) {
+ if (b->FXctx) {
fxMesaSwapBuffers();
- if (XMesa->xm_buffer->FXwindowHack)
+ if (b->FXwindowHack)
FXgetImage(b);
else
return;
@@ -2310,11 +2337,12 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
+ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XShmPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->backimage, 0, 0,
0, 0, b->width, b->height, False );
- /* wait for finished event??? */
+ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
else
#endif
@@ -2322,15 +2350,18 @@ void XMesaSwapBuffers( XMesaBuffer b )
#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
XMesaDriSwapBuffers( b );
#else
+ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XMesaPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->backimage, 0, 0,
0, 0, b->width, b->height );
+ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
#endif
}
}
else {
/* Copy pixmap to window on server */
+ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XMesaCopyArea( b->xm_visual->display,
b->backpixmap, /* source drawable */
b->frontbuffer, /* dest. drawable */
@@ -2338,17 +2369,12 @@ void XMesaSwapBuffers( XMesaBuffer b )
0, 0, b->width, b->height, /* source region */
0, 0 /* dest region */
);
+ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
}
-#if defined(GLX_DIRECT_RENDERING) || defined(XFree86Server)
- /* NOT_NEEDED */
-#else
+#if !defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
XSync( b->xm_visual->display, False );
#endif
-#ifdef PROFILE
- XMesa->gl_ctx->SwapCount++;
- XMesa->gl_ctx->SwapTime += gl_time() - t0;
-#endif
}
@@ -2358,18 +2384,20 @@ void XMesaSwapBuffers( XMesaBuffer b )
*/
void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
{
-#ifdef PROFILE
- GLdouble t0 = gl_time();
-#endif
+ GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB( XMesa->gl_ctx, "swap buffers" );
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ if (b->xm_context->gl_ctx == ctx)
+ _mesa_swapbuffers(ctx);
if (b->db_state) {
int yTop = b->bottom - y - height;
#ifdef FX
- if (XMesa->xm_buffer->FXctx) {
+ if (b->FXctx) {
fxMesaSwapBuffers();
- if (XMesa->xm_buffer->FXwindowHack)
+ if (b->FXwindowHack)
FXgetImage(b);
else
return;
@@ -2407,15 +2435,6 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
);
}
}
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
- XSync( b->xm_visual->display, False );
-#endif
-#ifdef PROFILE
- XMesa->gl_ctx->SwapCount++;
- XMesa->gl_ctx->SwapTime += gl_time() - t0;
-#endif
}
@@ -2545,7 +2564,6 @@ void XMesaReset( void )
XMesaDestroyBuffer(XMesaBufferList);
XMesaBufferList = NULL;
- XMesa = NULL;
}
diff --git a/xc/extras/Mesa/src/X/xmesa2.c b/xc/extras/Mesa/src/X/xmesa2.c
index 77b8d4b05..e1b5b69f4 100644
--- a/xc/extras/Mesa/src/X/xmesa2.c
+++ b/xc/extras/Mesa/src/X/xmesa2.c
@@ -150,8 +150,10 @@ static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
int winx, winy;
unsigned int bw, d;
+ _glthread_LOCK_MUTEX(_xmesa_lock);
XGetGeometry( xmesa->display, xmesa->xm_buffer->frontbuffer, &root,
&winx, &winy, &winwidth, &winheight, &bw, &d );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
#else
winwidth = xmesa->xm_buffer->frontbuffer->width;
@@ -209,7 +211,9 @@ static void finish( GLcontext *ctx )
#else
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (xmesa) {
+ _glthread_LOCK_MUTEX(_xmesa_lock);
XSync( xmesa->display, False );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
}
#endif
}
@@ -222,7 +226,9 @@ static void flush( GLcontext *ctx )
#else
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (xmesa) {
+ _glthread_LOCK_MUTEX(_xmesa_lock);
XFlush( xmesa->display );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
}
#endif
}
@@ -353,8 +359,10 @@ static void clear_color( GLcontext *ctx,
xmesa->clearcolor[3] = a;
xmesa->clearpixel = xmesa_color_to_pixel( xmesa, r, g, b, a,
xmesa->xm_visual->undithered_pf );
+ _glthread_LOCK_MUTEX(_xmesa_lock);
XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
xmesa->clearpixel );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
}
@@ -528,8 +536,10 @@ static GLboolean logicop( GLcontext *ctx, GLenum op )
case GL_OR_INVERTED: func = GXorInverted; break;
default: return GL_FALSE;
}
+ _glthread_LOCK_MUTEX(_xmesa_lock);
XMesaSetFunction( xmesa->display, xmesa->xm_buffer->gc1, func );
XMesaSetFunction( xmesa->display, xmesa->xm_buffer->gc2, func );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
return GL_TRUE;
}
diff --git a/xc/extras/Mesa/src/X/xmesa3.c b/xc/extras/Mesa/src/X/xmesa3.c
index c7e4c21c8..7e81e4ba4 100644
--- a/xc/extras/Mesa/src/X/xmesa3.c
+++ b/xc/extras/Mesa/src/X/xmesa3.c
@@ -731,9 +731,15 @@ line_func xmesa_get_line_func( GLcontext *ctx )
return NULL;
}
}
+#if 0
+ /* XXX have to disable this because X's rasterization rules don't match
+ * software Mesa's. This causes the linehv.c conformance test to fail.
+ * In the future, we might provide a config option to enable this.
+ */
if (xmesa->xm_buffer->buffer!=XIMAGE && ctx->RasterMask==0) {
setup_x_line_options( ctx );
return flat_pixmap_line;
}
+#endif
return NULL;
}
diff --git a/xc/extras/Mesa/src/X/xmesa4.c b/xc/extras/Mesa/src/X/xmesa4.c
index 195a531f0..350922008 100644
--- a/xc/extras/Mesa/src/X/xmesa4.c
+++ b/xc/extras/Mesa/src/X/xmesa4.c
@@ -1439,6 +1439,98 @@ static void setup_x_polygon_options( GLcontext *ctx )
}
+#ifdef DEBUG
+void
+_xmesa_print_triangle_func( triangle_func triFunc )
+{
+ printf("XMesa tri func = ");
+ if (triFunc ==smooth_TRUECOLOR_z_triangle)
+ printf("smooth_TRUECOLOR_z_triangle\n");
+ else if (triFunc ==smooth_8A8B8G8R_z_triangle)
+ printf("smooth_8A8B8G8R_z_triangle\n");
+ else if (triFunc ==smooth_8R8G8B_z_triangle)
+ printf("smooth_8R8G8B_z_triangle\n");
+ else if (triFunc ==smooth_8R8G8B24_z_triangle)
+ printf("smooth_8R8G8B24_z_triangle\n");
+ else if (triFunc ==smooth_TRUEDITHER_z_triangle)
+ printf("smooth_TRUEDITHER_z_triangle\n");
+ else if (triFunc ==smooth_5R6G5B_z_triangle)
+ printf("smooth_5R6G5B_z_triangle\n");
+ else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle)
+ printf("smooth_DITHER_5R6G5B_z_triangle\n");
+ else if (triFunc ==smooth_HPCR_z_triangle)
+ printf("smooth_HPCR_z_triangle\n");
+ else if (triFunc ==smooth_DITHER8_z_triangle)
+ printf("smooth_DITHER8_z_triangle\n");
+ else if (triFunc ==smooth_LOOKUP8_z_triangle)
+ printf("smooth_LOOKUP8_z_triangle\n");
+ else if (triFunc ==flat_TRUECOLOR_z_triangle)
+ printf("flat_TRUECOLOR_z_triangle\n");
+ else if (triFunc ==flat_8A8B8G8R_z_triangle)
+ printf("flat_8A8B8G8R_z_triangle\n");
+ else if (triFunc ==flat_8R8G8B_z_triangle)
+ printf("flat_8R8G8B_z_triangle\n");
+ else if (triFunc ==flat_8R8G8B24_z_triangle)
+ printf("flat_8R8G8B24_z_triangle\n");
+ else if (triFunc ==flat_TRUEDITHER_z_triangle)
+ printf("flat_TRUEDITHER_z_triangle\n");
+ else if (triFunc ==flat_5R6G5B_z_triangle)
+ printf("flat_5R6G5B_z_triangle\n");
+ else if (triFunc ==flat_DITHER_5R6G5B_z_triangle)
+ printf("flat_DITHER_5R6G5B_z_triangle\n");
+ else if (triFunc ==flat_HPCR_z_triangle)
+ printf("flat_HPCR_z_triangle\n");
+ else if (triFunc ==flat_DITHER8_z_triangle)
+ printf("flat_DITHER8_z_triangle\n");
+ else if (triFunc ==flat_LOOKUP8_z_triangle)
+ printf("flat_LOOKUP8_z_triangle\n");
+ else if (triFunc ==smooth_TRUECOLOR_triangle)
+ printf("smooth_TRUECOLOR_triangle\n");
+ else if (triFunc ==smooth_8A8B8G8R_triangle)
+ printf("smooth_8A8B8G8R_triangle\n");
+ else if (triFunc ==smooth_8R8G8B_triangle)
+ printf("smooth_8R8G8B_triangle\n");
+ else if (triFunc ==smooth_8R8G8B24_triangle)
+ printf("smooth_8R8G8B24_triangle\n");
+ else if (triFunc ==smooth_TRUEDITHER_triangle)
+ printf("smooth_TRUEDITHER_triangle\n");
+ else if (triFunc ==smooth_5R6G5B_triangle)
+ printf("smooth_5R6G5B_triangle\n");
+ else if (triFunc ==smooth_DITHER_5R6G5B_triangle)
+ printf("smooth_DITHER_5R6G5B_triangle\n");
+ else if (triFunc ==smooth_HPCR_triangle)
+ printf("smooth_HPCR_triangle\n");
+ else if (triFunc ==smooth_DITHER8_triangle)
+ printf("smooth_DITHER8_triangle\n");
+ else if (triFunc ==smooth_LOOKUP8_triangle)
+ printf("smooth_LOOKUP8_triangle\n");
+ else if (triFunc ==flat_TRUECOLOR_triangle)
+ printf("flat_TRUECOLOR_triangle\n");
+ else if (triFunc ==flat_TRUEDITHER_triangle)
+ printf("flat_TRUEDITHER_triangle\n");
+ else if (triFunc ==flat_8A8B8G8R_triangle)
+ printf("flat_8A8B8G8R_triangle\n");
+ else if (triFunc ==flat_8R8G8B_triangle)
+ printf("flat_8R8G8B_triangle\n");
+ else if (triFunc ==flat_8R8G8B24_triangle)
+ printf("flat_8R8G8B24_triangle\n");
+ else if (triFunc ==flat_5R6G5B_triangle)
+ printf("flat_5R6G5B_triangle\n");
+ else if (triFunc ==flat_DITHER_5R6G5B_triangle)
+ printf("flat_DITHER_5R6G5B_triangle\n");
+ else if (triFunc ==flat_HPCR_triangle)
+ printf("flat_HPCR_triangle\n");
+ else if (triFunc ==flat_DITHER8_triangle)
+ printf("flat_DITHER8_triangle\n");
+ else if (triFunc ==flat_LOOKUP8_triangle)
+ printf("flat_LOOKUP8_triangle\n");
+ else if (triFunc ==flat_pixmap_triangle)
+ printf("flat_pixmap_triangle\n");
+ else
+ printf("???\n");
+}
+#endif
+
triangle_func xmesa_get_triangle_func( GLcontext *ctx )
{
@@ -1578,13 +1670,20 @@ triangle_func xmesa_get_triangle_func( GLcontext *ctx )
return NULL;
}
else {
- /* pixmap */
+ /* draw to pixmap */
+#if 0
+ /* XXX have to disable this because X's rasterization rules
+ * don't match software Mesa's. This causes a buffer invariance
+ * test failure in the conformance tests.
+ * In the future, we might provide a config option to enable this.
+ */
if (ctx->Light.ShadeModel==GL_FLAT && ctx->RasterMask==0) {
if (ctx->Color.DitherFlag && depth < 24)
return NULL;
setup_x_polygon_options( ctx );
return flat_pixmap_triangle;
}
+#endif
return NULL;
}
}
diff --git a/xc/extras/Mesa/src/X/xmesaP.h b/xc/extras/Mesa/src/X/xmesaP.h
index 987877509..0886fa3dc 100644
--- a/xc/extras/Mesa/src/X/xmesaP.h
+++ b/xc/extras/Mesa/src/X/xmesaP.h
@@ -56,6 +56,9 @@
#endif
+extern _glthread_Mutex _xmesa_lock;
+
+
/* for PF_8R8G8B24 pixel format */
typedef struct {
GLubyte b;
diff --git a/xc/extras/Mesa/src/X86/3dnow.c b/xc/extras/Mesa/src/X86/3dnow.c
index 5255a8c7f..c252f70ea 100644
--- a/xc/extras/Mesa/src/X86/3dnow.c
+++ b/xc/extras/Mesa/src/X86/3dnow.c
@@ -49,7 +49,7 @@
#define XFORM_ARGS GLvector4f *to_vec, \
- const GLmatrix *mat, \
+ const GLfloat m[16], \
const GLvector4f *from_vec, \
const GLubyte *mask, \
const GLubyte flag
diff --git a/xc/extras/Mesa/src/X86/3dnow_norm_raw.S b/xc/extras/Mesa/src/X86/3dnow_norm_raw.S
index 7d4eed85b..427ba295c 100644
--- a/xc/extras/Mesa/src/X86/3dnow_norm_raw.S
+++ b/xc/extras/Mesa/src/X86/3dnow_norm_raw.S
@@ -61,7 +61,7 @@
#define V3F_COUNT 8
#define V3F_STRIDE 12
-#define MAT_INV 64
+#define MAT_INV 4
#define M(i) REGOFF(i * 4, ECX)
#define STRIDE REGOFF(12, ESI)
@@ -72,28 +72,24 @@ GLOBL GLNAME(gl_3dnow_transform_normalize_normals_raw)
GLNAME(gl_3dnow_transform_normalize_normals_raw):
#define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L ( ARG_LENGTHS, EDI )
- MOV_L ( ARG_IN, EAX )
- MOV_L ( ARG_DEST, EDX )
- MOV_L ( REGOFF(V3F_COUNT, EAX), EAX ) /* dest->count = in->count */
- MOV_L ( EAX, REGOFF(V3F_COUNT, EDX) )
- MOV_L ( ARG_IN, ESI )
- MOV_L ( ARG_MAT, ECX )
- MOV_L ( REGOFF(V3F_START, EDX), EAX ) /* dest->start */
- MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
- MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
-ALIGNTEXT32
-
- CMP_L ( CONST(0), REGOFF (V3F_COUNT, ESI ) ) /* count > 0 ?? */
+ MOV_L ( ARG_LENGTHS, EDI )
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
+
+ CMP_L ( CONST(0), EBP ) /* count > 0 ?? */
JE ( LLBL (G3TN_end) )
- PUSH_L ( EBP )
MOV_L ( REGOFF (V3F_COUNT, ESI), EBP )
FEMMS
@@ -101,7 +97,8 @@ ALIGNTEXT32
PUSH_L ( EAX )
PUSH_L ( EDX ) /* save counter & pointer for */
/* the normalize pass */
-
+ #undef FRAME_OFFSET
+ #define FRAME_OFFSET 24
MOVQ ( M(0), MM3 ) /* m1 | m0 */
MOVQ ( M(4), MM4 ) /* m5 | m4 */
@@ -115,8 +112,6 @@ ALIGNTEXT32
CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */
JNE ( LLBL (G3TN_scale_end ) )
- #undef FRAME_OFFSET
- #define FRAME_OFFSET 28
MOVD ( ARG_SCALE, MM0 ) /* | scale */
PUNPCKLDQ ( MM0, MM0 ) /* scale | scale */
@@ -138,6 +133,8 @@ LLBL (G3TN_transform):
PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */
ADD_L ( CONST(12), EAX ) /* next r */
+ PREFETCHW ( REGIND(EAX) )
+
PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */
PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */
@@ -156,6 +153,8 @@ LLBL (G3TN_transform):
PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m*/
ADD_L ( STRIDE, EDX ) /* next normal */
+ PREFETCH ( REGIND(EDX) )
+
MOVD ( MM1, REGOFF(-4, EAX) ) /* write r2 */
MOVQ ( REGIND (EDX), MM0 ) /* x1 | x0 */
@@ -177,19 +176,24 @@ LLBL (G3TN_transform):
ALIGNTEXT32
LLBL (G3TN_norm_w_lengths):
+
+ PREFETCHW ( REGOFF(12,EAX) )
+
MOVD ( REGIND (EDI), MM3 ) /* | length (x) */
PFMUL ( MM3, MM1 ) /* | x2 (normalize*/
PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */
PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalize*/
+ ADD_L ( STRIDE, EDX ) /* next normal */
+ ADD_L ( CONST(4), EDI ) /* next length */
+
+ PREFETCH ( REGIND(EDI) )
+
MOVQ ( MM0, REGIND(EAX) ) /* write new x0, x1 */
MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */
- ADD_L ( STRIDE, EDX ) /* next normal */
ADD_L ( CONST(12), EAX ) /* next r */
-
- ADD_L ( CONST(4), EDI ) /* next length */
DEC_L ( EBP ) /* decrement normal counter */
MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
@@ -199,6 +203,9 @@ LLBL (G3TN_norm_w_lengths):
ALIGNTEXT32
LLBL (G3TN_norm):
+
+ PREFETCHW ( REGIND(EAX) )
+
MOVQ ( MM0, MM3 ) /* x1 | x0 */
MOVQ ( MM1, MM4 ) /* | x2 */
@@ -233,46 +240,39 @@ LLBL (G3TN_norm):
LLBL (G3TN_exit_3dnow):
FEMMS
- POP_L ( EBP )
LLBL (G3TN_end):
+ POP_L ( EBP )
POP_L ( ESI )
POP_L ( EDI )
- POP_L ( ECX )
RET
ALIGNTEXT16
-
GLOBL GLNAME(gl_3dnow_transform_normalize_normals_no_rot_raw)
GLNAME(gl_3dnow_transform_normalize_normals_no_rot_raw):
#undef FRAME_OFFSET
#define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L ( ARG_LENGTHS, EDI )
- MOV_L ( ARG_IN, EAX )
- MOV_L ( ARG_DEST, EDX )
- MOV_L ( REGOFF(V3F_COUNT, EAX), EAX ) /* dest->count = in->count */
- MOV_L ( EAX, REGOFF(V3F_COUNT, EDX) )
- MOV_L ( ARG_IN, ESI )
- MOV_L ( ARG_MAT, ECX )
- MOV_L ( REGOFF(V3F_START, EDX), EAX ) /* dest->start */
- MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
- MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
-ALIGNTEXT32
-
- CMP_L ( CONST(0), REGOFF (V3F_COUNT, ESI ) ) /* count > 0 ?? */
+ MOV_L ( ARG_LENGTHS, EDI )
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
+ MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+
+ CMP_L ( CONST(0), EBP ) /* count > 0 ?? */
JE ( LLBL (G3TNNR_end) )
- PUSH_L ( EBP )
- MOV_L ( REGOFF (V3F_COUNT, ESI), EBP )
FEMMS
MOVD ( M(0), MM0 ) /* | m0 */
@@ -284,14 +284,13 @@ ALIGNTEXT32
CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */
JNE ( LLBL (G3TNNR_scale_end ) )
- #undef FRAME_OFFSET
- #define FRAME_OFFSET 16
MOVD ( ARG_SCALE, MM7 ) /* | scale */
PUNPCKLDQ ( MM7, MM7 ) /* scale | scale */
PFMUL ( MM7, MM0 ) /* scale * m5 | scale * m0 */
PFMUL ( MM7, MM2 ) /* scale * m10 | scale * m10 */
+ALIGNTEXT32
LLBL (G3TNNR_scale_end):
MOVQ ( REGIND(EDX), MM6 ) /* x1 | x0 */
MOVD ( REGOFF(8, EDX), MM7 ) /* | x2 */
@@ -302,10 +301,16 @@ LLBL (G3TNNR_scale_end):
MOVD ( REGIND(EDI), MM3 ) /* | length (x) */
+ALIGNTEXT32
LLBL (G3TNNR_norm_w_lengths): /* use precalculated lengths */
+
+ PREFETCHW ( REGIND(EAX) )
+
PFMUL ( MM0, MM6 ) /* x1*m5 | x0*m0 */
ADD_L ( STRIDE, EDX ) /* next normal */
+ PREFETCH ( REGIND(EDX) )
+
PFMUL ( MM2, MM7 ) /* | x2*m10 */
ADD_L ( CONST(12), EAX ) /* next r */
@@ -327,7 +332,11 @@ LLBL (G3TNNR_norm_w_lengths): /* use precalculated lengths */
JA ( LLBL (G3TNNR_norm_w_lengths) )
JMP ( LLBL (G3TNNR_exit_3dnow) )
+ALIGNTEXT32
LLBL (G3TNNR_norm): /* need to calculate lengths */
+
+ PREFETCHW ( REGIND(EAX) )
+
PFMUL ( MM0, MM6 ) /* x1*m5 | x0*m0 */
ADD_L ( CONST(12), EAX ) /* next r */
@@ -337,12 +346,15 @@ LLBL (G3TNNR_norm): /* need to calculate lengths */
MOVQ ( MM7, MM4 ) /* | x2 (transformed) */
PFMUL ( MM6, MM3 ) /* x1*x1 | x0*x0 */
+
PFMUL ( MM7, MM4 ) /* | x2*x2 */
PFACC ( MM3, MM3 ) /* **not used** | x0*x0+x1*x1 */
PFADD ( MM4, MM3 ) /* | x0*x0+x1*x1+x2*x2*/
ADD_L ( STRIDE, EDX ) /* next normal */
+ PREFETCH ( REGIND(EDX) )
+
PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */
MOVQ ( MM5, MM4 )
@@ -367,12 +379,11 @@ LLBL (G3TNNR_norm): /* need to calculate lengths */
LLBL (G3TNNR_exit_3dnow):
FEMMS
- POP_L ( EBP )
LLBL (G3TNNR_end):
+ POP_L ( EBP )
POP_L ( ESI )
POP_L ( EDI )
- POP_L ( ECX )
RET
@@ -381,38 +392,31 @@ LLBL (G3TNNR_end):
ALIGNTEXT16
-
GLOBL GLNAME(gl_3dnow_transform_rescale_normals_no_rot_raw)
GLNAME(gl_3dnow_transform_rescale_normals_no_rot_raw):
#undef FRAME_OFFSET
#define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L ( ARG_IN, EAX )
- MOV_L ( ARG_DEST, EDX )
- MOV_L ( REGOFF(V3F_COUNT, EAX), EAX ) /* dest->count = in->count */
- MOV_L ( EAX, REGOFF(V3F_COUNT, EDX) )
- MOV_L ( ARG_IN, ESI )
- MOV_L ( ARG_MAT, ECX )
- MOV_L ( REGOFF(V3F_START, EDX), EAX ) /* dest->start */
- MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
- MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
-ALIGNTEXT32
-
- CMP_L ( CONST(0), REGOFF (V3F_COUNT, ESI) )
+ MOV_L ( ARG_IN, EAX )
+ MOV_L ( ARG_DEST, EDX )
+ MOV_L ( REGOFF(V3F_COUNT, EAX), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V3F_COUNT, EDX) )
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
+ MOV_L ( REGOFF(V3F_START, EDX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+
+ CMP_L ( CONST(0), EBP )
JE ( LLBL (G3TRNR_end) )
- PUSH_L ( EBP )
- MOV_L ( REGOFF (V3F_COUNT, ESI), EBP )
FEMMS
- #undef FRAME_OFFSET
- #define FRAME_OFFSET 16
MOVD ( ARG_SCALE, MM6 ) /* | scale */
PUNPCKLDQ ( MM6, MM6 ) /* scale | scale */
@@ -428,11 +432,15 @@ ALIGNTEXT32
MOVD ( REGOFF(8, EDX), MM5 ) /* | x2 */
ALIGNTEXT32
-
LLBL (G3TRNR_rescale):
+
+ PREFETCHW ( REGIND(EAX) )
+
PFMUL ( MM0, MM4 ) /* x1*m5 | x0*m0 */
ADD_L ( STRIDE, EDX ) /* next normal */
+ PREFETCH ( REGIND(EDX) )
+
PFMUL ( MM2, MM5 ) /* | x2*m10 */
ADD_L ( CONST(12), EAX ) /* next r */
@@ -446,12 +454,11 @@ LLBL (G3TRNR_rescale):
JA ( LLBL (G3TRNR_rescale) ) /* cnt > 0 ? -> process next normal */
FEMMS
- POP_L ( EBP )
LLBL (G3TRNR_end):
+ POP_L ( EBP )
POP_L ( ESI )
POP_L ( EDI )
- POP_L ( ECX )
RET
@@ -463,24 +470,19 @@ GLOBL GLNAME(gl_3dnow_transform_rescale_normals_raw)
GLNAME(gl_3dnow_transform_rescale_normals_raw):
#undef FRAME_OFFSET
- #define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L (REGOFF(24,ESP), EAX)
- MOV_L (REGOFF(36,ESP), EDX)
- MOV_L (REGOFF(8,EAX), EAX)
- MOV_L (EAX, REGOFF(8,EDX))
- MOV_L (REGOFF(24,ESP), EDI)
- MOV_L (REGOFF(4,EDX), EAX)
- MOV_L (REGOFF(16,ESP), ECX)
- MOV_L (REGOFF(24,ESP), ESI)
- MOV_L (REGOFF(64,ECX), ECX)
- MOV_L (REGOFF(4,EDI), EDX)
- MOV_L (REGOFF(8,EDI), EDI)
+ #define FRAME_OFFSET 8
-ALIGNTEXT32
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EDI ) /* dest->count = in->count */
+ MOV_L ( EDI, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
CMP_L ( CONST(0), EDI )
JE ( LLBL (G3TR_end) )
@@ -490,12 +492,12 @@ ALIGNTEXT32
MOVQ ( REGIND(ECX), MM3 ) /* m1 | m0 */
MOVQ ( REGOFF(16,ECX), MM4 ) /* m5 | m4 */
- MOVD ( REGOFF(20, ESP), MM0 ) /* scale */
+ MOVD ( ARG_SCALE, MM0 ) /* scale */
MOVD ( REGOFF(8,ECX), MM5 ) /* | m2 */
PUNPCKLDQ ( MM0, MM0 ) /* scale | scale */
- PUNPCKLDQ ( REGOFF(24, ECX), MM5 )
+ PUNPCKLDQ ( REGOFF(24, ECX), MM5 )
PFMUL ( MM0, MM3 ) /* scale*m1 | scale*m0 */
MOVQ ( REGOFF(32, ECX), MM6 ) /* m9 | m8*/
@@ -510,7 +512,11 @@ ALIGNTEXT32
PFMUL ( MM0, MM7 ) /* | scale*m10 */
MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
+ALIGNTEXT32
LLBL (G3TR_rescale):
+
+ PREFETCHW ( REGIND(EAX) )
+
MOVQ ( MM0, MM1 ) /* x1 | x0 */
PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */
@@ -520,25 +526,28 @@ LLBL (G3TR_rescale):
PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */
PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */
+ MOVQ ( REGIND(EDX), MM1 ) /* x1 | x0 */
+
PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */
PFADD ( MM2, MM0 ) /* x0*m4...+x2*m6| x0*m0+x1*m1+x2*m2 */
- MOVQ ( REGIND(EDX), MM1 ) /* x1 | x0 */
- MOVQ ( MM0, REGOFF(-12, EAX) ) /* write r0, r1 */
+ MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+ MOVQ ( MM0, REGOFF(-12, EAX) ) /* write r0, r1 */
PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */
- MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
PFMUL ( MM7, MM2 ) /* | x2*m10 */
PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */
PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m10 */
- ADD_L ( REGOFF(12, ESI), EDX ) /* next normal */
-
MOVD ( MM1, REGOFF(-4, EAX) ) /* write r2 */
- MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
+ MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+
DEC_L ( EDI ) /* decrement normal counter */
JA ( LLBL (G3TR_rescale) )
@@ -547,7 +556,6 @@ LLBL (G3TR_rescale):
LLBL (G3TR_end):
POP_L ( ESI )
POP_L ( EDI )
- POP_L ( ECX )
RET
@@ -560,25 +568,20 @@ ALIGNTEXT16
GLOBL GLNAME(gl_3dnow_transform_normals_no_rot_raw)
GLNAME(gl_3dnow_transform_normals_no_rot_raw):
- #define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L (REGOFF(24,ESP), EAX)
- MOV_L (REGOFF(36,ESP), EDX)
- MOV_L (REGOFF(8,EAX), EAX)
- MOV_L (EAX, REGOFF(8,EDX))
- MOV_L (REGOFF(24,ESP), EDI)
- MOV_L (REGOFF(4,EDX), EAX)
- MOV_L (REGOFF(16,ESP), ECX)
- MOV_L (REGOFF(24,ESP), ESI)
- MOV_L (REGOFF(64,ECX), ECX)
- MOV_L (REGOFF(4,EDI), EDX)
- MOV_L (REGOFF(8,EDI), EDI)
-
-
-ALIGNTEXT32
+ #undef FRAME_OFFSET
+ #define FRAME_OFFSET 8
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EDI ) /* dest->count = in->count */
+ MOV_L ( EDI, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
CMP_L ( CONST(0), EDI )
JE ( LLBL (G3TNR_end) )
@@ -595,10 +598,14 @@ ALIGNTEXT32
MOVD ( REGOFF(8, EDX), MM5 ) /* | x2 */
ALIGNTEXT32
-
LLBL (G3TNR_transform):
+
+ PREFETCHW ( REGIND(EAX) )
+
PFMUL ( MM0, MM4 ) /* x1*m5 | x0*m0 */
- ADD_L ( REGOFF(12, ESI), EDX) /* next normal */
+ ADD_L ( STRIDE, EDX) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
PFMUL ( MM2, MM5 ) /* | x2*m10 */
ADD_L ( CONST(12), EAX ) /* next r */
@@ -617,7 +624,6 @@ LLBL (G3TNR_transform):
LLBL (G3TNR_end):
POP_L ( ESI )
POP_L ( EDI )
- POP_L ( ECX )
RET
@@ -631,24 +637,20 @@ ALIGNTEXT16
GLOBL GLNAME(gl_3dnow_transform_normals_raw)
GLNAME(gl_3dnow_transform_normals_raw):
- #define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L (REGOFF(24,ESP), EAX)
- MOV_L (REGOFF(36,ESP), EDX)
- MOV_L (REGOFF(8,EAX), EAX)
- MOV_L (EAX, REGOFF(8,EDX))
- MOV_L (REGOFF(24,ESP), EDI)
- MOV_L (REGOFF(4,EDX), EAX)
- MOV_L (REGOFF(16,ESP), ECX)
- MOV_L (REGOFF(24,ESP), ESI)
- MOV_L (REGOFF(64,ECX), ECX)
- MOV_L (REGOFF(4,EDI), EDX)
- MOV_L (REGOFF(8,EDI), EDI)
-
-ALIGNTEXT32
+ #undef FRAME_OFFSET
+ #define FRAME_OFFSET 8
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EDI ) /* dest->count = in->count */
+ MOV_L ( EDI, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V3F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(MAT_INV, ECX), ECX ) /* mat->inv */
CMP_L ( CONST(0), EDI ) /* count > 0 ?? */
JE ( LLBL (G3T_end) )
@@ -659,15 +661,19 @@ ALIGNTEXT32
MOVQ ( REGOFF(16, ECX), MM4 ) /* m5 | m4 */
MOVD ( REGOFF(8, ECX), MM5 ) /* | m2 */
- PUNPCKLDQ ( REGOFF(24, ECX), MM5 ) /* m6 | m2*/
+ PUNPCKLDQ ( REGOFF(24, ECX), MM5 ) /* m6 | m2 */
- MOVQ ( REGOFF(32,ECX), MM6 ) /* m9 | m8 */
- MOVD ( REGOFF(40,ECX), MM7 ) /* | m10 */
+ MOVQ ( REGOFF(32, ECX), MM6 ) /* m9 | m8 */
+ MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */
MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+ALIGNTEXT32
LLBL (G3T_transform):
+
+ PREFETCHW ( REGIND(EAX) )
+
MOVQ ( MM0, MM1 ) /* x1 | x0 */
PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */
@@ -687,10 +693,12 @@ LLBL (G3T_transform):
MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
PFMUL ( MM7, MM2 ) /* | x2*m10 */
- PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */
+ ADD_L ( STRIDE, EDX ) /* next normal */
+ PREFETCH ( REGIND(EDX) )
+
+ PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */
PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m10 */
- ADD_L ( REGOFF(12, ESI), EDX ) /* next normal */
MOVD ( MM1, REGOFF(-4, EAX) ) /* write r2 */
MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
@@ -704,7 +712,6 @@ LLBL (G3T_transform):
LLBL (G3T_end):
POP_L ( ESI )
POP_L ( EDI )
- POP_L ( ECX )
RET
@@ -716,30 +723,23 @@ ALIGNTEXT16
GLOBL GLNAME(gl_3dnow_normalize_normals_raw)
GLNAME(gl_3dnow_normalize_normals_raw):
+ #undef FRAME_OFFSET
#define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L (REGOFF(16,ESP), ESI)
- MOV_L (REGOFF(24,ESP), EAX)
- MOV_L (REGOFF(36,ESP), EDX)
- MOV_L (REGOFF(8,EAX), EAX)
- MOV_L (EAX, REGOFF(8,EDX))
- MOV_L (REGOFF(4,EDX), EAX)
- MOV_L (REGOFF(24,ESP), ECX)
- MOV_L (REGOFF(28,ESP), EDX)
- MOV_L (REGOFF(24,ESP), EDI)
- MOV_L (REGOFF(4,ECX), ECX)
-
-
-ALIGNTEXT32
-
- CMP_L ( CONST(0), REGOFF(8, EDI) ) /* count > 0 ?? */
- JE ( LLBL (G3N_end) )
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
PUSH_L ( EBP )
- MOV_L (REGOFF(8,EDI), EBP)
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V3F_START, ESI), ECX ) /* in->start */
+ MOV_L ( ARG_LENGTHS, EDX )
+
+ CMP_L ( CONST(0), EBP ) /* count > 0 ?? */
+ JE ( LLBL (G3N_end) )
FEMMS
@@ -749,17 +749,23 @@ ALIGNTEXT32
CMP_L ( CONST(0), EDX ) /* lengths == 0 ? */
JE ( LLBL (G3N_norm2) ) /* calculate lengths */
+ALIGNTEXT32
LLBL (G3N_norm1): /* use precalculated lengths */
+
+ PREFETCH ( REGIND(EAX) )
+
MOVD ( REGIND(EDX), MM3 ) /* | length (x) */
PFMUL ( MM3, MM1 ) /* | x2 (normalized) */
PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */
- PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalized) */
+ ADD_L ( STRIDE, ECX ) /* next normal */
+
+ PREFETCH ( REGIND(ECX) )
+ PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalized) */
MOVQ ( MM0, REGIND(EAX) ) /* write new x0, x1 */
- MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */
- ADD_L ( REGOFF(12, EDI), ECX ) /* next normal */
+ MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */
ADD_L ( CONST(12), EAX ) /* next r */
ADD_L ( CONST(4), EDX ) /* next length */
@@ -771,10 +777,15 @@ LLBL (G3N_norm1): /* use precalculated lengths */
JMP ( LLBL (G3N_end1) )
-LLBL (G3N_norm2):
- /* need to calculate lengths */
+ALIGNTEXT32
+LLBL (G3N_norm2): /* need to calculate lengths */
+
+ PREFETCHW ( REGIND(EAX) )
+
MOVQ ( MM0, MM3 ) /* x1 | x0 */
- ADD_L ( REGOFF(12, EDI), ECX ) /* next normal */
+ ADD_L ( STRIDE, ECX ) /* next normal */
+
+ PREFETCH ( REGIND(ECX) )
PFMUL ( MM0, MM3 ) /* x1*x1 | x0*x0 */
MOVQ ( MM1, MM4 ) /* | x2 */
@@ -808,12 +819,11 @@ LLBL (G3N_norm2):
LLBL (G3N_end1):
FEMMS
- POP_L ( EBP )
LLBL (G3N_end):
- POP_L ( ESI )
- POP_L ( EDI )
- POP_L ( ECX )
+ POP_L ( EBP )
+ POP_L ( ESI )
+ POP_L ( EDI )
RET
@@ -825,48 +835,46 @@ ALIGNTEXT16
GLOBL GLNAME(gl_3dnow_rescale_normals_raw)
GLNAME(gl_3dnow_rescale_normals_raw):
- #define FRAME_OFFSET 12
- SUB_L ( CONST(4), ESP )
- PUSH_L ( EDI )
- PUSH_L ( ESI )
-
- MOV_L (REGOFF(20,ESP), ESI)
- MOV_L (REGOFF(24,ESP), EAX)
- MOV_L (REGOFF(36,ESP), EDX)
- MOV_L (REGOFF(8,EAX), EAX)
- MOV_L (EAX, REGOFF(8,EDX))
- MOV_L (REGOFF(24,ESP), EDI)
- MOV_L (EDI, ECX)
- MOV_L (REGOFF(4,EDX), EAX)
- MOV_L (REGOFF(4,ECX), ECX)
- MOV_L (REGOFF(8,EDI), EDX)
+ #undef FRAME_OFFSET
+ #define FRAME_OFFSET 8
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
-ALIGNTEXT32
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V3F_COUNT, ESI), EDX ) /* dest->count = in->count */
+ MOV_L ( EDX, REGOFF(V3F_COUNT, EAX) )
+ MOV_L ( REGOFF(V3F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V3F_START, ESI), ECX ) /* in->start */
CMP_L ( CONST(0), EDX )
JE ( LLBL (G3R_end) )
FEMMS
- MOVD ( ESI, MM0 ) /* scale */
+ MOVD ( ARG_SCALE, MM0 ) /* scale */
PUNPCKLDQ ( MM0, MM0 )
MOVQ ( REGIND(ECX), MM1 ) /* x1 | x0 */
MOVD ( REGOFF(8, ECX), MM2 ) /* | x2 */
ALIGNTEXT32
-
LLBL (G3R_rescale):
+
+ PREFETCHW ( REGIND(EAX) )
+
PFMUL ( MM0, MM1 ) /* x1*scale | x0*scale */
- ADD_L ( REGOFF(12, EDI), ECX ) /* next normal */
+ ADD_L ( STRIDE, ECX ) /* next normal */
+
+ PREFETCH ( REGIND(ECX) )
PFMUL ( MM0, MM2 ) /* | x2*scale */
ADD_L ( CONST(12), EAX ) /* next r */
- DEC_L ( EDX ) /* decrement normal counter */
MOVQ ( MM1, REGOFF(-12, EAX) ) /* write r0, r1 */
-
MOVD ( MM2, REGOFF(-4, EAX) ) /* write r2 */
+
+ DEC_L ( EDX ) /* decrement normal counter */
MOVQ ( REGIND(ECX), MM1 ) /* x1 | x0 */
MOVD ( REGOFF(8, ECX), MM2 ) /* | x2 */
@@ -875,17 +883,9 @@ LLBL (G3R_rescale):
FEMMS
LLBL (G3R_end):
- POP_L ( ESI )
- POP_L ( EDI )
- POP_L ( ECX )
+ POP_L ( ESI )
+ POP_L ( EDI )
RET
-
-
-
-
-
-
-
diff --git a/xc/extras/Mesa/src/X86/katmai.c b/xc/extras/Mesa/src/X86/katmai.c
index 1dfa0f7fc..d27f89b2d 100644
--- a/xc/extras/Mesa/src/X86/katmai.c
+++ b/xc/extras/Mesa/src/X86/katmai.c
@@ -49,7 +49,7 @@
#define XFORM_ARGS GLvector4f *to_vec, \
- const GLmatrix *mat, \
+ const GLfloat m[16], \
const GLvector4f *from_vec, \
const GLubyte *mask, \
const GLubyte flag
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_masked1.S b/xc/extras/Mesa/src/X86/katmai_xform_masked1.S
index f3e11c803..235ac4e57 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_masked1.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_masked1.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_masked2.S b/xc/extras/Mesa/src/X86/katmai_xform_masked2.S
index a4936fa6a..45193f19c 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_masked2.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_masked2.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_masked3.S b/xc/extras/Mesa/src/X86/katmai_xform_masked3.S
index 10f3c41b5..3258f521e 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_masked3.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_masked3.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_masked4.S b/xc/extras/Mesa/src/X86/katmai_xform_masked4.S
index 4a0bf5c05..82d960c02 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_masked4.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_masked4.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_raw1.S b/xc/extras/Mesa/src/X86/katmai_xform_raw1.S
index 4ca992d2c..e6ff089e2 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_raw1.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_raw1.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_raw2.S b/xc/extras/Mesa/src/X86/katmai_xform_raw2.S
index 61845034c..993880885 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_raw2.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_raw2.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_raw3.S b/xc/extras/Mesa/src/X86/katmai_xform_raw3.S
index 49918de95..35f95f511 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_raw3.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_raw3.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/katmai_xform_raw4.S b/xc/extras/Mesa/src/X86/katmai_xform_raw4.S
index d0867da7c..5a38a2f4e 100644
--- a/xc/extras/Mesa/src/X86/katmai_xform_raw4.S
+++ b/xc/extras/Mesa/src/X86/katmai_xform_raw4.S
@@ -32,7 +32,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/X86/x86.c b/xc/extras/Mesa/src/X86/x86.c
index 1b24811d4..606ec7051 100644
--- a/xc/extras/Mesa/src/X86/x86.c
+++ b/xc/extras/Mesa/src/X86/x86.c
@@ -36,23 +36,23 @@
#include "x86.h"
#ifdef USE_X86_ASM
-extern void _ASMAPI gl_v16_x86_cliptest_points4(GLfloat *first_vert,
+extern void _ASMAPI gl_v16_x86_cliptest_points4( GLfloat *first_vert,
GLfloat *last_vert,
GLubyte *or_mask,
GLubyte *and_mask,
GLubyte *clip_mask );
-extern void _ASMAPI gl_v16_x86_general_xform(GLfloat *dest,
+extern void _ASMAPI gl_v16_x86_general_xform( GLfloat *dest,
const GLfloat *m,
const GLfloat *src,
GLuint src_stride,
- GLuint count);
+ GLuint count );
#endif
#define XFORM_ARGS GLvector4f *to_vec, \
- const GLmatrix *mat, \
+ const GLfloat m[16], \
const GLvector4f *from_vec, \
const GLubyte *mask, \
const GLubyte flag
@@ -117,7 +117,6 @@ void gl_init_x86_asm_transforms( void )
gl_test_all_transform_functions("x86");
#endif
-
gl_cliptest_points4_v16 = gl_v16_x86_cliptest_points4;
gl_xform_points3_v16_general = gl_v16_x86_general_xform;
#endif
diff --git a/xc/extras/Mesa/src/X86/x86a.S b/xc/extras/Mesa/src/X86/x86a.S
index 621bc1f1a..bae1e8f65 100644
--- a/xc/extras/Mesa/src/X86/x86a.S
+++ b/xc/extras/Mesa/src/X86/x86a.S
@@ -28,7 +28,7 @@
* Offsets for transform_func arguments
*
* typedef void (*transform_func)( GLvector4f *to_vec,
- * const GLmatrix *mat,
+ * const GLfloat m[16],
* const GLvector4f *from_vec,
* const GLubyte *clipmask,
* const GLubyte flag );
diff --git a/xc/extras/Mesa/src/accum.c b/xc/extras/Mesa/src/accum.c
index 71475eefb..5161c9f31 100644
--- a/xc/extras/Mesa/src/accum.c
+++ b/xc/extras/Mesa/src/accum.c
@@ -353,9 +353,8 @@ _mesa_Accum( GLenum op, GLfloat value )
static GLchan multTable[32768];
static GLfloat prevMult = 0.0;
GLuint j;
- const GLint max = (GLint) (256 / mult);
+ const GLint max = MIN2((GLint) (256 / mult), 32767);
if (mult != prevMult) {
- assert(max <= 32768);
for (j = 0; j < max; j++)
multTable[j] = (GLint) ((GLfloat) j * mult + 0.5F);
prevMult = mult;
diff --git a/xc/extras/Mesa/src/attrib.c b/xc/extras/Mesa/src/attrib.c
index 2e750ffdb..cc736bdc5 100644
--- a/xc/extras/Mesa/src/attrib.c
+++ b/xc/extras/Mesa/src/attrib.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -358,6 +358,7 @@ _mesa_PushAttrib(GLbitfield mask)
copy_texobj_state(&attr->Unit[u].Saved1D, attr->Unit[u].CurrentD[1]);
copy_texobj_state(&attr->Unit[u].Saved2D, attr->Unit[u].CurrentD[2]);
copy_texobj_state(&attr->Unit[u].Saved3D, attr->Unit[u].CurrentD[3]);
+ copy_texobj_state(&attr->Unit[u].SavedCubeMap, attr->Unit[u].CurrentCubeMap);
}
newnode = new_attrib_node( GL_TEXTURE_BIT );
newnode->data = attr;
@@ -473,11 +474,14 @@ _mesa_PopAttrib(void)
break;
case GL_DEPTH_BUFFER_BIT:
{
+ GLboolean oldDepthTest = ctx->Depth.Test;
GLenum oldDepthFunc = ctx->Depth.Func;
GLboolean oldDepthMask = ctx->Depth.Mask;
GLfloat oldDepthClear = ctx->Depth.Clear;
MEMCPY( &ctx->Depth, attr->data,
sizeof(struct gl_depthbuffer_attrib) );
+ if (ctx->Depth.Test != oldDepthTest && ctx->Driver.Enable)
+ (*ctx->Driver.Enable)( ctx, GL_DEPTH_TEST, ctx->Depth.Test);
if (ctx->Depth.Func != oldDepthFunc && ctx->Driver.DepthFunc)
(*ctx->Driver.DepthFunc)( ctx, ctx->Depth.Func );
if (ctx->Depth.Mask != oldDepthMask && ctx->Driver.DepthMask)
@@ -769,9 +773,13 @@ _mesa_PopAttrib(void)
&(ctx->Texture.Unit[u].Saved2D) );
copy_texobj_state( ctx->Texture.Unit[u].CurrentD[3],
&(ctx->Texture.Unit[u].Saved3D) );
+ copy_texobj_state( ctx->Texture.Unit[u].CurrentCubeMap,
+ &(ctx->Texture.Unit[u].SavedCubeMap) );
+
gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[1] );
gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[2] );
gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[3] );
+ gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentCubeMap );
}
}
diff --git a/xc/extras/Mesa/src/blend.c b/xc/extras/Mesa/src/blend.c
index 9419393f6..46f846939 100644
--- a/xc/extras/Mesa/src/blend.c
+++ b/xc/extras/Mesa/src/blend.c
@@ -663,7 +663,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[],
dR = dG = dB = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
- dR = dG = dB = 1.0F - ctx->Color.BlendColor[3] * ascale;
+ dR = dG = dB = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_DST_COLOR: /* GL_NV_blend_square */
dR = (GLfloat) Rd * rscale;
@@ -717,7 +717,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[],
dA = ctx->Color.BlendColor[3];
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
- dA = 1.0F - ctx->Color.BlendColor[3] * ascale;
+ dA = 1.0F - ctx->Color.BlendColor[3];
break;
case GL_DST_COLOR: /* GL_NV_blend_square */
dA = (GLfloat) Ad * ascale;
diff --git a/xc/extras/Mesa/src/buffers.c b/xc/extras/Mesa/src/buffers.c
index 086dc9345..566afed92 100644
--- a/xc/extras/Mesa/src/buffers.c
+++ b/xc/extras/Mesa/src/buffers.c
@@ -151,10 +151,9 @@ clear_color_buffer(GLcontext *ctx)
const GLubyte a = (GLint) (ctx->Color.ClearColor[3] * 255.0F);
GLubyte span[MAX_WIDTH][4];
GLint i;
- ASSERT(ctx->Color.ColorMask[0] &&
- ctx->Color.ColorMask[1] &&
- ctx->Color.ColorMask[2] &&
- ctx->Color.ColorMask[3]);
+
+ ASSERT(!ctx->Color.SWmasking);
+
for (i = 0; i < width; i++) {
span[i][RCOMP] = r;
span[i][GCOMP] = g;
@@ -299,7 +298,7 @@ _mesa_Clear( GLbitfield mask )
/* clear software-based alpha buffer(s) */
if ( (mask & GL_COLOR_BUFFER_BIT)
&& ctx->DrawBuffer->UseSoftwareAlphaBuffers
- && ctx->Color.ColorMask[RCOMP]) {
+ && ctx->Color.ColorMask[ACOMP]) {
_mesa_clear_alpha_buffers( ctx );
}
diff --git a/xc/extras/Mesa/src/clip_funcs.h b/xc/extras/Mesa/src/clip_funcs.h
index 5f0591872..e0003bf3d 100644
--- a/xc/extras/Mesa/src/clip_funcs.h
+++ b/xc/extras/Mesa/src/clip_funcs.h
@@ -162,14 +162,18 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
clipmask[idxPrev] |= (PLANE&CLIP_ALL_BITS); \
\
if (!NEGATIVE(dpPrev)) { \
+ if (IND&CLIP_TAB_EDGEFLAG) { \
+ if (outcount) \
+ VB->EdgeFlagPtr->data[outlist[outcount-1]] &= ~2; \
+ } \
outlist[outcount++] = idxPrev; \
clipmask[idxPrev] &= ~(PLANE&CLIP_ALL_BITS); \
} \
\
if (DIFFERENT_SIGNS(dp, dpPrev)) { \
- if (NEGATIVE(dp)) { \
- /* Coming back in. Avoid division by zero as we know \
- * dp != dpPrev from DIFFERENT_SIGNS, above. \
+ if (NEGATIVE(dp)) { \
+ /* Going out of bounds. Avoid division by zero as we \
+ * know dp != dpPrev from DIFFERENT_SIGNS, above. \
*/ \
GLfloat t = dp / (dp - dpPrev); \
INTERP_SZ( t, VB->ClipPtr->data, vb_free, \
@@ -177,26 +181,26 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
interp( VB, vb_free, t, idx, idxPrev ); \
\
if (IND&CLIP_TAB_EDGEFLAG) \
- VB->EdgeFlagPtr->data[vb_free] = \
- VB->EdgeFlagPtr->data[idxPrev]; \
+ VB->EdgeFlagPtr->data[vb_free] = 3; \
} else { \
- /* Going out of bounds \
+ /* Coming back in. \
*/ \
GLfloat t = dpPrev / (dpPrev - dp); \
- INTERP_SZ( t, VB->ClipPtr->data, vb_free, \
+ INTERP_SZ( t, VB->ClipPtr->data, vb_free, \
idxPrev, idx, SIZE ); \
interp( VB, vb_free, t, idxPrev, idx ); \
\
- if (IND&CLIP_TAB_EDGEFLAG) \
- VB->EdgeFlagPtr->data[vb_free] = 3; \
+ if (IND&CLIP_TAB_EDGEFLAG) { \
+ VB->EdgeFlagPtr->data[vb_free] = \
+ VB->EdgeFlagPtr->data[idxPrev]; \
+ } \
} \
\
- if (IND&CLIP_TAB_EDGEFLAG) { \
/* Demote trailing edge to internal edge. \
*/ \
- if (outcount && \
- (VB->EdgeFlagPtr->data[outlist[outcount-1]] & 0x2)) \
- VB->EdgeFlagPtr->data[outlist[outcount-1]] = 1; \
+ if (IND&CLIP_TAB_EDGEFLAG) { \
+ if (outcount) \
+ VB->EdgeFlagPtr->data[outlist[outcount-1]] &= ~2; \
} \
\
outlist[outcount++] = vb_free; \
@@ -210,6 +214,7 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
if (outcount < 3) \
return 0; \
\
+ \
{ \
GLuint *tmp = inlist; \
inlist = outlist; \
@@ -218,7 +223,6 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
} \
}
-
#include "general_clip.h"
if (inlist != vlist)
@@ -365,6 +369,8 @@ static GLuint TAG(userclip_polygon)( struct vertex_buffer *VB,
GLuint flagI = INSIDE(dpI);
if (flagJ) {
+ if ((IND&CLIP_TAB_EDGEFLAG) && outcount)
+ VB->EdgeFlagPtr->data[outlist[outcount-1]] &= ~2;
outlist[outcount++] = prevj;
} else {
VB->ClipMask[prevj] |= CLIP_USER_BIT;
@@ -392,12 +398,11 @@ static GLuint TAG(userclip_polygon)( struct vertex_buffer *VB,
VB->EdgeFlagPtr->data[vb_free] = 3;
}
- if (IND&CLIP_TAB_EDGEFLAG) {
/* Demote trailing edge to internal edge.
*/
- if (outcount &&
- (VB->EdgeFlagPtr->data[outlist[outcount-1]] & 0x2))
- VB->EdgeFlagPtr->data[outlist[outcount-1]] = 1;
+ if (IND&CLIP_TAB_EDGEFLAG) {
+ if (outcount)
+ VB->EdgeFlagPtr->data[outlist[outcount-1]] &= ~2;
}
INTERP_SZ( t, coord, vb_free, in, out, SIZE );
diff --git a/xc/extras/Mesa/src/colortab.c b/xc/extras/Mesa/src/colortab.c
index e15014dfe..3b6cb37ec 100644
--- a/xc/extras/Mesa/src/colortab.c
+++ b/xc/extras/Mesa/src/colortab.c
@@ -300,7 +300,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
assert(table);
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type) ||
+ format == GL_INTENSITY) {
gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)");
return;
}
@@ -311,17 +312,30 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
return;
}
- if (width < 1 || width > ctx->Const.MaxColorTableSize
- || _mesa_bitcount(width) != 1) {
- if (width > ctx->Const.MaxColorTableSize)
- gl_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)");
- else
+ if (width < 0 || _mesa_bitcount(width) != 1) {
+ if (proxy) {
+ table->Size = 0;
+ table->IntFormat = (GLenum) 0;
+ table->Format = (GLenum) 0;
+ }
+ else {
gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)");
+ }
+ return;
+ }
+
+ if (width > ctx->Const.MaxColorTableSize) {
if (proxy) {
table->Size = 0;
table->IntFormat = (GLenum) 0;
table->Format = (GLenum) 0;
}
+ else {
+ if (width > ctx->Const.MaxColorTableSize)
+ gl_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)");
+ else
+ gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)");
+ }
return;
}
@@ -339,14 +353,14 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
FREE(table->Table);
}
if (floatTable) {
- GLubyte tableUB[MAX_COLOR_TABLE_SIZE * 4];
+ GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
GLfloat *tableF;
GLuint i;
- _mesa_unpack_ubyte_color_span(ctx, width, table->Format,
- tableUB, /* dest */
+ _mesa_unpack_float_color_span(ctx, width, table->Format,
+ tempTab, /* dest */
format, type, data,
- &ctx->Unpack, GL_TRUE);
+ &ctx->Unpack, GL_TRUE, GL_FALSE);
table->TableType = GL_FLOAT;
table->Table = MALLOC(comps * width * sizeof(GLfloat));
@@ -355,50 +369,43 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
return;
}
- /* Apply scale and bias and convert GLubyte values to GLfloats
- * in [0, 1]. Store results in the tableF[].
- */
- rScale /= 255.0;
- gScale /= 255.0;
- bScale /= 255.0;
- aScale /= 255.0;
tableF = (GLfloat *) table->Table;
switch (table->Format) {
case GL_INTENSITY:
for (i = 0; i < width; i++) {
- tableF[i] = tableUB[i] * rScale + rBias;
+ tableF[i] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
}
break;
case GL_LUMINANCE:
for (i = 0; i < width; i++) {
- tableF[i] = tableUB[i] * rScale + rBias;
+ tableF[i] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
}
break;
case GL_ALPHA:
for (i = 0; i < width; i++) {
- tableF[i] = tableUB[i] * aScale + aBias;
+ tableF[i] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F);
}
break;
case GL_LUMINANCE_ALPHA:
for (i = 0; i < width; i++) {
- tableF[i*2+0] = tableUB[i*2+0] * rScale + rBias;
- tableF[i*2+1] = tableUB[i*2+1] * aScale + aBias;
+ tableF[i*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[i*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F);
}
break;
case GL_RGB:
for (i = 0; i < width; i++) {
- tableF[i*3+0] = tableUB[i*3+0] * rScale + rBias;
- tableF[i*3+1] = tableUB[i*3+1] * gScale + gBias;
- tableF[i*3+2] = tableUB[i*3+2] * bScale + bBias;
+ tableF[i*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[i*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F);
+ tableF[i*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F);
}
break;
case GL_RGBA:
for (i = 0; i < width; i++) {
- tableF[i*4+0] = tableUB[i*4+0] * rScale + rBias;
- tableF[i*4+1] = tableUB[i*4+1] * gScale + gBias;
- tableF[i*4+2] = tableUB[i*4+2] * bScale + bBias;
- tableF[i*4+3] = tableUB[i*4+3] * aScale + aBias;
+ tableF[i*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[i*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F);
+ tableF[i*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F);
+ tableF[i*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F);
}
break;
default:
@@ -440,6 +447,8 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_texture_object *texObj = NULL;
struct gl_color_table *table = NULL;
+ GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
+ GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
GLint comps;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable");
@@ -462,12 +471,36 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
break;
case GL_COLOR_TABLE:
table = &ctx->ColorTable;
+ rScale = ctx->Pixel.ColorTableScale[0];
+ gScale = ctx->Pixel.ColorTableScale[1];
+ bScale = ctx->Pixel.ColorTableScale[2];
+ aScale = ctx->Pixel.ColorTableScale[3];
+ rBias = ctx->Pixel.ColorTableBias[0];
+ gBias = ctx->Pixel.ColorTableBias[1];
+ bBias = ctx->Pixel.ColorTableBias[2];
+ aBias = ctx->Pixel.ColorTableBias[3];
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
+ rScale = ctx->Pixel.PCCTscale[0];
+ gScale = ctx->Pixel.PCCTscale[1];
+ bScale = ctx->Pixel.PCCTscale[2];
+ aScale = ctx->Pixel.PCCTscale[3];
+ rBias = ctx->Pixel.PCCTbias[0];
+ gBias = ctx->Pixel.PCCTbias[1];
+ bBias = ctx->Pixel.PCCTbias[2];
+ aBias = ctx->Pixel.PCCTbias[3];
break;
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
table = &ctx->PostColorMatrixColorTable;
+ rScale = ctx->Pixel.PCMCTscale[0];
+ gScale = ctx->Pixel.PCMCTscale[1];
+ bScale = ctx->Pixel.PCMCTscale[2];
+ aScale = ctx->Pixel.PCMCTscale[3];
+ rBias = ctx->Pixel.PCMCTbias[0];
+ gBias = ctx->Pixel.PCMCTbias[1];
+ bBias = ctx->Pixel.PCMCTbias[2];
+ aBias = ctx->Pixel.PCMCTbias[3];
break;
default:
gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
@@ -476,7 +509,8 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
assert(table);
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type) ||
+ format == GL_INTENSITY) {
gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)");
return;
}
@@ -505,11 +539,66 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
format, type, data, &ctx->Unpack, GL_TRUE);
}
else {
- GLfloat *dest = (GLfloat *) table->Table + start * comps * sizeof(GLfloat);
+ GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
+ GLfloat *tableF;
+ GLuint i;
+
ASSERT(table->TableType == GL_FLOAT);
- _mesa_unpack_float_color_span(ctx, count, table->Format, dest,
- format, type, data, &ctx->Unpack,
- GL_FALSE, GL_TRUE);
+
+ _mesa_unpack_float_color_span(ctx, count, table->Format,
+ tempTab, /* dest */
+ format, type, data,
+ &ctx->Unpack, GL_TRUE, GL_FALSE);
+
+ tableF = (GLfloat *) table->Table;
+
+ switch (table->Format) {
+ case GL_INTENSITY:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_ALPHA:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[j*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_RGB:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[j*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F);
+ tableF[j*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_RGBA:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[j*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F);
+ tableF[j*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F);
+ tableF[j*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F);
+ }
+ break;
+ default:
+ gl_problem(ctx, "Bad format in _mesa_ColorSubTable");
+ return;
+ }
}
if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
@@ -725,10 +814,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
if (table->TableType == GL_FLOAT) {
const GLfloat *tableF = (const GLfloat *) table->Table;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * 255.0F);
- rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * 255.0F);
- rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * 255.0F);
- rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * 255.0F);
+ rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * 255.0F + 0.5F);
+ rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * 255.0F + 0.5F);
+ rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * 255.0F + 0.5F);
+ rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * 255.0F + 0.5F);
}
}
else {
diff --git a/xc/extras/Mesa/src/config.c b/xc/extras/Mesa/src/config.c
index 575ec7219..7dc4d9613 100644
--- a/xc/extras/Mesa/src/config.c
+++ b/xc/extras/Mesa/src/config.c
@@ -22,6 +22,7 @@
* 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.
*/
+/* $XFree86: xc/extras/Mesa/src/config.c,v 1.5 2000/08/09 23:40:10 dawes Exp $ */
/* Mesa config file parse and execute code.
@@ -403,7 +404,7 @@ void gl_read_config_file( GLcontext *ctx )
{
const char *default_config = "mesa3.1beta1";
-#if defined(__WIN32__) || defined(__MSDOS__)
+#if (defined(__WIN32__) && !defined(__CYGWIN__)) || defined(__MSDOS__)
const char *filename = "mesa.cnf";
#else
const char *filename = "/etc/mesa.conf";
@@ -446,8 +447,10 @@ void gl_read_config_file( GLcontext *ctx )
if (!run_init( ctx, default_config, list )) {
- fprintf(stderr, "No default configuration '%s' in init file\n",
- default_config);
+ if (getenv("MESA_DEBUG")) {
+ fprintf(stderr, "No default configuration '%s' in init file\n",
+ default_config);
+ }
}
free_list( list );
diff --git a/xc/extras/Mesa/src/config.h b/xc/extras/Mesa/src/config.h
index 3ff5e5f78..07ff841f6 100644
--- a/xc/extras/Mesa/src/config.h
+++ b/xc/extras/Mesa/src/config.h
@@ -104,8 +104,8 @@
/* Number of texture units - GL_ARB_multitexture */
#define MAX_TEXTURE_UNITS 2
-/* Maximum viewport size: */
-#define MAX_WIDTH 1600
+/* Maximum viewport/image size: */
+#define MAX_WIDTH 2048
#define MAX_HEIGHT 1200
/* Maxmimum size for CVA. May be overridden by the drivers. */
diff --git a/xc/extras/Mesa/src/context.c b/xc/extras/Mesa/src/context.c
index 0138ae6b3..5548e8c26 100644
--- a/xc/extras/Mesa/src/context.c
+++ b/xc/extras/Mesa/src/context.c
@@ -593,12 +593,34 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
texUnit->EnvMode = GL_MODULATE;
+ texUnit->CombineModeRGB = GL_MODULATE;
+ texUnit->CombineModeA = GL_MODULATE;
+ texUnit->CombineSourceRGB[0] = GL_TEXTURE;
+ texUnit->CombineSourceRGB[1] = GL_PREVIOUS_EXT;
+ texUnit->CombineSourceRGB[2] = GL_CONSTANT_EXT;
+ texUnit->CombineSourceA[0] = GL_TEXTURE;
+ texUnit->CombineSourceA[1] = GL_PREVIOUS_EXT;
+ texUnit->CombineSourceA[2] = GL_CONSTANT_EXT;
+ texUnit->CombineOperandRGB[0] = GL_SRC_COLOR;
+ texUnit->CombineOperandRGB[1] = GL_SRC_COLOR;
+ texUnit->CombineOperandRGB[2] = GL_SRC_ALPHA;
+ texUnit->CombineOperandA[0] = GL_SRC_ALPHA;
+ texUnit->CombineOperandA[1] = GL_SRC_ALPHA;
+ texUnit->CombineOperandA[2] = GL_SRC_ALPHA;
+ texUnit->CombineScaleShiftRGB = 0;
+ texUnit->CombineScaleShiftA = 0;
+
ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
texUnit->TexGenEnabled = 0;
texUnit->GenModeS = GL_EYE_LINEAR;
texUnit->GenModeT = GL_EYE_LINEAR;
texUnit->GenModeR = GL_EYE_LINEAR;
texUnit->GenModeQ = GL_EYE_LINEAR;
+ texUnit->GenBitS = TEXGEN_EYE_LINEAR;
+ texUnit->GenBitT = TEXGEN_EYE_LINEAR;
+ texUnit->GenBitR = TEXGEN_EYE_LINEAR;
+ texUnit->GenBitQ = TEXGEN_EYE_LINEAR;
+
/* Yes, these plane coefficients are correct! */
ASSIGN_4V( texUnit->ObjectPlaneS, 1.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( texUnit->ObjectPlaneT, 0.0, 1.0, 0.0, 0.0 );
@@ -762,10 +784,11 @@ init_attrib_groups( GLcontext *ctx )
}
/* Texture matrix */
- for (i=0; i<MAX_TEXTURE_UNITS; i++) {
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
gl_matrix_ctr( &ctx->TextureMatrix[i] );
ctx->TextureStackDepth[i] = 0;
for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
+ gl_matrix_ctr( &ctx->TextureStack[i][j] );
ctx->TextureStack[i][j].inv = 0;
}
}
@@ -987,6 +1010,11 @@ init_attrib_groups( GLcontext *ctx )
ctx->ShineTable[i]->refcount++;
}
+ gl_compute_shine_table( ctx, 0, ctx->Light.Material[0].Shininess );
+ gl_compute_shine_table( ctx, 2, ctx->Light.Material[0].Shininess * .5 );
+ gl_compute_shine_table( ctx, 1, ctx->Light.Material[1].Shininess );
+ gl_compute_shine_table( ctx, 3, ctx->Light.Material[1].Shininess * .5 );
+
/* Line group */
ctx->Line.SmoothFlag = GL_FALSE;
@@ -1049,6 +1077,10 @@ init_attrib_groups( GLcontext *ctx )
ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0);
ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0);
ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0);
+ ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0);
+ ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0);
+ ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0);
+ ASSIGN_4V(ctx->Pixel.PCMCTbias, 0.0, 0.0, 0.0, 0.0);
ctx->Pixel.ColorTableEnabled = GL_FALSE;
ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE;
ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE;
@@ -1066,6 +1098,7 @@ init_attrib_groups( GLcontext *ctx )
/* Point group */
ctx->Point.SmoothFlag = GL_FALSE;
+ ctx->Point.UserSize = 1.0;
ctx->Point.Size = 1.0;
ctx->Point.Params[0] = 1.0;
ctx->Point.Params[1] = 0.0;
@@ -1342,7 +1375,8 @@ alloc_proxy_textures( GLcontext *ctx )
/*
- * Initialize a GLcontext struct.
+ * Initialize a GLcontext struct. This includes allocating all the
+ * other structs and arrays which hang off of the context by pointers.
*/
GLboolean
_mesa_initialize_context( GLcontext *ctx,
@@ -1365,15 +1399,13 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->VB = gl_vb_create_for_immediate( ctx );
if (!ctx->VB) {
- FREE( ctx );
return GL_FALSE;
}
ctx->input = ctx->VB->IM;
ctx->PB = gl_alloc_pb();
if (!ctx->PB) {
- FREE( ctx->VB );
- FREE( ctx );
+ ALIGN_FREE( ctx->VB );
return GL_FALSE;
}
@@ -1385,9 +1417,8 @@ _mesa_initialize_context( GLcontext *ctx,
/* allocate new group of display lists */
ctx->Shared = alloc_shared_state();
if (!ctx->Shared) {
- FREE(ctx->VB);
- FREE(ctx->PB);
- FREE(ctx);
+ ALIGN_FREE( ctx->VB );
+ FREE( ctx->PB );
return GL_FALSE;
}
}
@@ -1417,9 +1448,8 @@ _mesa_initialize_context( GLcontext *ctx,
if (!alloc_proxy_textures(ctx)) {
free_shared_state(ctx, ctx->Shared);
- FREE(ctx->VB);
- FREE(ctx->PB);
- FREE(ctx);
+ ALIGN_FREE( ctx->VB );
+ FREE( ctx->PB );
return GL_FALSE;
}
@@ -1446,11 +1476,10 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
if (!ctx->Exec || !ctx->Save) {
free_shared_state(ctx, ctx->Shared);
- FREE(ctx->VB);
- FREE(ctx->PB);
+ ALIGN_FREE( ctx->VB );
+ FREE( ctx->PB );
if (ctx->Exec)
- FREE(ctx->Exec);
- FREE(ctx);
+ FREE( ctx->Exec );
}
_mesa_init_exec_table(ctx->Exec, dispatchSize);
_mesa_init_dlist_table(ctx->Save, dispatchSize);
@@ -1593,7 +1622,7 @@ gl_free_context_data( GLcontext *ctx )
/* Free cache of immediate buffers. */
while (ctx->nr_im_queued-- > 0) {
struct immediate * next = ctx->freed_im_queue->next;
- FREE( ctx->freed_im_queue );
+ ALIGN_FREE( ctx->freed_im_queue );
ctx->freed_im_queue = next;
}
gl_extensions_dtr(ctx);
@@ -1896,57 +1925,63 @@ void gl_compile_error( GLcontext *ctx, GLenum error, const char *s )
* of the current error value. If Mesa is compiled with -DDEBUG or if the
* environment variable "MESA_DEBUG" is defined then a real error message
* is printed to stderr.
- * Input: error - the error value
- * s - a diagnostic string
+ * Input: ctx - the GL context
+ * error - the error value
+ * where - usually the name of function where error was detected
*/
-void gl_error( GLcontext *ctx, GLenum error, const char *s )
+void
+gl_error( GLcontext *ctx, GLenum error, const char *where )
{
+ const char *debugEnv = getenv("MESA_DEBUG");
GLboolean debug;
#ifdef DEBUG
- debug = GL_TRUE;
+ if (debugEnv && strstr(debugEnv, "silent"))
+ debug = GL_FALSE;
+ else
+ debug = GL_TRUE;
#else
- if (getenv("MESA_DEBUG")) {
+ if (debugEnv)
debug = GL_TRUE;
- }
- else {
+ else
debug = GL_FALSE;
- }
#endif
if (debug) {
- char errstr[1000];
-
+ const char *errstr;
switch (error) {
case GL_NO_ERROR:
- strcpy( errstr, "GL_NO_ERROR" );
+ errstr = "GL_NO_ERROR";
break;
case GL_INVALID_VALUE:
- strcpy( errstr, "GL_INVALID_VALUE" );
+ errstr = "GL_INVALID_VALUE";
break;
case GL_INVALID_ENUM:
- strcpy( errstr, "GL_INVALID_ENUM" );
+ errstr = "GL_INVALID_ENUM";
break;
case GL_INVALID_OPERATION:
- strcpy( errstr, "GL_INVALID_OPERATION" );
+ errstr = "GL_INVALID_OPERATION";
break;
case GL_STACK_OVERFLOW:
- strcpy( errstr, "GL_STACK_OVERFLOW" );
+ errstr = "GL_STACK_OVERFLOW";
break;
case GL_STACK_UNDERFLOW:
- strcpy( errstr, "GL_STACK_UNDERFLOW" );
+ errstr = "GL_STACK_UNDERFLOW";
break;
case GL_OUT_OF_MEMORY:
- strcpy( errstr, "GL_OUT_OF_MEMORY" );
+ errstr = "GL_OUT_OF_MEMORY";
break;
+ case GL_TABLE_TOO_LARGE:
+ errstr = "GL_TABLE_TOO_LARGE";
+ break;
default:
- strcpy( errstr, "unknown" );
+ errstr = "unknown";
break;
}
- fprintf( stderr, "Mesa user error: %s in %s\n", errstr, s );
+ fprintf(stderr, "Mesa user error: %s in %s\n", errstr, where);
}
- if (ctx->ErrorValue==GL_NO_ERROR) {
+ if (ctx->ErrorValue == GL_NO_ERROR) {
ctx->ErrorValue = error;
}
diff --git a/xc/extras/Mesa/src/copypix.c b/xc/extras/Mesa/src/copypix.c
index e76c170f6..6fbfbfee4 100644
--- a/xc/extras/Mesa/src/copypix.c
+++ b/xc/extras/Mesa/src/copypix.c
@@ -166,6 +166,7 @@ static void copy_rgba_pixels( GLcontext *ctx,
ctx->Pixel.ScaleOrBiasRGBApcm ||
ctx->Pixel.ColorTableEnabled ||
ctx->Pixel.PostColorMatrixColorTableEnabled ||
+ ctx->Pixel.PostConvolutionColorTableEnabled ||
ctx->Pixel.MinMaxEnabled ||
ctx->Pixel.HistogramEnabled;
@@ -224,6 +225,11 @@ static void copy_rgba_pixels( GLcontext *ctx,
if (ctx->Pixel.ColorTableEnabled) {
_mesa_lookup_rgba(&ctx->ColorTable, width, rgbaFloat);
}
+ /* XXX convolution here */
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostConvolutionColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, width, rgbaFloat);
+ }
/* color matrix */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
@@ -256,12 +262,17 @@ static void copy_rgba_pixels( GLcontext *ctx,
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
+ GLubyte primary_rgba[MAX_WIDTH][4];
GLuint unit;
/* XXX not sure how multitexture is supposed to work here */
+
+ MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLubyte));
+
for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
_mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
s, t, r, q);
- gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba);
+ gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
+ primary_rgba, rgba);
}
}
diff --git a/xc/extras/Mesa/src/dd.h b/xc/extras/Mesa/src/dd.h
index ad389df4a..d2dfc9464 100644
--- a/xc/extras/Mesa/src/dd.h
+++ b/xc/extras/Mesa/src/dd.h
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -641,17 +641,20 @@ struct dd_function_table {
*/
GLboolean (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
- GLint level, const GLvoid *data,
+ GLint level, GLsizei imageSize,
+ const GLvoid *data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage,
GLboolean *retainInternalCopy);
GLboolean (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
- GLint level, const GLvoid *data,
+ GLint level, GLsizei imageSize,
+ const GLvoid *data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage,
GLboolean *retainInternalCopy);
GLboolean (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
- GLint level, const GLvoid *data,
+ GLint level, GLsizei imageSize,
+ const GLvoid *data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage,
GLboolean *retainInternalCopy);
@@ -699,6 +702,42 @@ struct dd_function_table {
* should do the job.
*/
+ GLint (*BaseCompressedTexFormat)(GLcontext *ctx,
+ GLint internalFormat);
+ /* Called to compute the base format for a specific compressed
+ * format. Return -1 if the internalFormat is not a specific
+ * compressed format that the driver recognizes. Note the
+ * return value differences between this function and
+ * SpecificCompressedTexFormat below.
+ */
+
+ GLint (*SpecificCompressedTexFormat)(GLcontext *ctx,
+ GLint internalFormat,
+ GLint numDimensions);
+ /* Called to turn a generic texture format into a specific
+ * texture format. For example, if a driver implements
+ * GL_3DFX_texture_compression_FXT1, this would map
+ * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
+ *
+ * If the driver does not know how to handle the compressed
+ * format, then just return the generic format, and Mesa will
+ * do the right thing with it.
+ */
+
+ GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat);
+ /* Called to tell if a format is a compressed format.
+ */
+
+ GLsizei (*CompressedImageSize)(GLcontext *ctx,
+ GLenum internalFormat,
+ GLuint numDimensions,
+ GLuint width,
+ GLuint height,
+ GLuint depth);
+ /* Calculate the size of a compressed image, given the image's
+ * format and dimensions.
+ */
+
void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target,
GLint lod, void *image,
const struct gl_texture_object *texObj,
@@ -759,7 +798,7 @@ struct dd_function_table {
/***
- *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
+ *** Accelerated point, line, polygon, quad and rect functions:
***/
points_func PointsFunc;
@@ -906,6 +945,16 @@ struct dd_function_table {
void (*StencilMask)(GLcontext *ctx, GLuint mask);
void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+
+ /* State-query functions
+ *
+ * Return GL_TRUE if query was completed, GL_FALSE otherwise.
+ */
+ GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
+ GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
+ GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
+ GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
+ GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
};
diff --git a/xc/extras/Mesa/src/debug_xform.c b/xc/extras/Mesa/src/debug_xform.c
index 28d1b9625..cd3442a58 100644
--- a/xc/extras/Mesa/src/debug_xform.c
+++ b/xc/extras/Mesa/src/debug_xform.c
@@ -30,6 +30,7 @@
#include "glheader.h"
#include "context.h"
#include "types.h"
+#include "mem.h"
#include "xform.h"
#include "debug_xform.h"
#endif
@@ -234,7 +235,7 @@ static int test_transform_function( transform_func fn, int psize, int mtype,
GLvector4f source[1], dest[1], ref[1];
GLmatrix mat[1];
GLfloat s[TEST_COUNT][5], d[TEST_COUNT][4], r[TEST_COUNT][4];
- GLfloat *m = mat->m;
+ GLfloat *m;
GLubyte mask[TEST_COUNT];
int i, j;
#ifdef RUN_XFORM_BENCHMARK
@@ -248,8 +249,11 @@ static int test_transform_function( transform_func fn, int psize, int mtype,
return 0;
}
+ mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
mat->type = mtypes[mtype];
+ m = mat->m;
+
m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0;
m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0;
m[2] = 44.0; m[6] = 9.0; m[10] = 7.0; m[14] = 3.0;
@@ -311,19 +315,19 @@ static int test_transform_function( transform_func fn, int psize, int mtype,
if (mesa_profile) {
if (masked) {
BEGIN_RACE (*cycles);
- fn(dest, mat, source, mask, 1);
+ fn(dest, mat->m, source, mask, 1);
END_RACE (*cycles);
} else {
BEGIN_RACE (*cycles);
- fn(dest, mat, source, NULL, 0);
+ fn(dest, mat->m, source, NULL, 0);
END_RACE (*cycles);
}
}
else {
if (masked) {
- fn(dest, mat, source, mask, 1);
+ fn(dest, mat->m, source, mask, 1);
} else {
- fn(dest, mat, source, NULL, 0);
+ fn(dest, mat->m, source, NULL, 0);
}
}
@@ -351,6 +355,8 @@ static int test_transform_function( transform_func fn, int psize, int mtype,
}
}
}
+
+ ALIGN_FREE( mat->m );
return 1;
}
@@ -583,7 +589,7 @@ static int test_norm_function( normal_func fn, int mtype,
GLfloat s [TEST_COUNT][5], d [TEST_COUNT][3], r [TEST_COUNT][3];
GLfloat d2 [TEST_COUNT][3], r2 [TEST_COUNT][3], length [TEST_COUNT];
GLfloat scale;
- GLfloat *m = mat->m;
+ GLfloat *m;
GLubyte mask[TEST_COUNT];
int i, j;
#ifdef RUN_XFORM_BENCHMARK
@@ -592,7 +598,8 @@ static int test_norm_function( normal_func fn, int mtype,
(void) cycles;
- mat->inv = mat->m;
+ mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+ mat->inv = m = mat->m;
m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0;
m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0;
@@ -728,6 +735,8 @@ static int test_norm_function( normal_func fn, int mtype,
}
}
}
+
+ ALIGN_FREE( mat->m );
return 1;
}
diff --git a/xc/extras/Mesa/src/dlist.c b/xc/extras/Mesa/src/dlist.c
index e56593887..ff23ee951 100644
--- a/xc/extras/Mesa/src/dlist.c
+++ b/xc/extras/Mesa/src/dlist.c
@@ -4055,7 +4055,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_VERTEX_CASSETTE: {
struct immediate *IM;
-
+
if (ctx->NewState)
gl_update_state(ctx);
if (ctx->CompileCVAFlag) {
@@ -4515,6 +4515,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_RECTF:
(*ctx->Exec->Rectf)( n[1].f, n[2].f, n[3].f, n[4].f );
+ FLUSH_VB( ctx, "dlist rectf" );
break;
case OPCODE_RESET_HISTOGRAM:
(*ctx->Exec->ResetHistogram)( n[1].e );
@@ -4968,8 +4969,6 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
ctx->CurrentDispatch = ctx->Save;
_glapi_set_dispatch( ctx->CurrentDispatch );
}
-
-/* RESET_IMMEDIATE( ctx ); */
}
diff --git a/xc/extras/Mesa/src/drawpix.c b/xc/extras/Mesa/src/drawpix.c
index 7fb93abcc..dad8ada33 100644
--- a/xc/extras/Mesa/src/drawpix.c
+++ b/xc/extras/Mesa/src/drawpix.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -121,6 +121,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
&& ctx->ColorMatrix.type == MATRIX_IDENTITY
&& !ctx->Pixel.ColorTableEnabled
&& !ctx->Pixel.PostColorMatrixColorTableEnabled
+ && !ctx->Pixel.PostConvolutionColorTableEnabled
&& !ctx->Pixel.MinMaxEnabled
&& !ctx->Pixel.HistogramEnabled
&& ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0
@@ -138,7 +139,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
GLint skipRows = unpack->SkipRows;
GLint rowLength;
GLdepth zSpan[MAX_WIDTH]; /* only used when zooming */
- GLint zoomY0;
+ GLint zoomY0 = 0;
if (unpack->RowLength > 0)
rowLength = unpack->RowLength;
@@ -171,14 +172,36 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
drawHeight -= (destY + drawHeight - ctx->DrawBuffer->Ymax - 1);
if (drawHeight <= 0)
return GL_TRUE;
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down image */
+ /* horizontal clipping */
+ if (destX < ctx->DrawBuffer->Xmin) {
+ skipPixels += (ctx->DrawBuffer->Xmin - destX);
+ drawWidth -= (ctx->DrawBuffer->Xmin - destX);
+ destX = ctx->DrawBuffer->Xmin;
+ }
+ if (destX + drawWidth > ctx->DrawBuffer->Xmax)
+ drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax - 1);
+ if (drawWidth <= 0)
+ return GL_TRUE;
- zoomY0 = 0; /* not used - silence compiler warning */
+ /* vertical clipping */
+ if (destY > ctx->DrawBuffer->Ymax) {
+ skipRows += (destY - ctx->DrawBuffer->Ymax - 1);
+ drawHeight -= (destY - ctx->DrawBuffer->Ymax - 1);
+ destY = ctx->DrawBuffer->Ymax + 1;
+ }
+ if (destY - drawHeight < ctx->DrawBuffer->Ymin)
+ drawHeight -= (ctx->DrawBuffer->Ymin - (destY - drawHeight));
+ if (drawHeight <= 0)
+ return GL_TRUE;
}
else {
/* setup array of fragment Z value to pass to zoom function */
GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
for (i=0; i<drawWidth; i++)
zSpan[i] = z;
@@ -209,6 +232,16 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
destY++;
}
}
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ destY--;
+ (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (void *) src, NULL);
+ src += rowLength * 4;
+ }
+ }
else {
/* with zooming */
GLint row;
@@ -235,6 +268,16 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
destY++;
}
}
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ destY--;
+ (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+ (void *) src, NULL);
+ src += rowLength * 3;
+ }
+ }
else {
/* with zooming */
GLint row;
@@ -255,7 +298,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
GLint row;
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
@@ -269,10 +312,27 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
destY++;
}
}
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ ASSERT(drawWidth < MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ for (i=0;i<drawWidth;i++) {
+ rgb[i][0] = src[i];
+ rgb[i][1] = src[i];
+ rgb[i][2] = src[i];
+ }
+ destY--;
+ (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+ (void *) rgb, NULL);
+ src += rowLength;
+ }
+ }
else {
/* with zooming */
GLint row;
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
@@ -296,7 +356,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
GLint row;
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLint i;
GLubyte *ptr = src;
@@ -312,10 +372,29 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
destY++;
}
}
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ ASSERT(drawWidth < MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ GLubyte *ptr = src;
+ for (i=0;i<drawWidth;i++) {
+ rgba[i][0] = *ptr;
+ rgba[i][1] = *ptr;
+ rgba[i][2] = *ptr++;
+ rgba[i][3] = *ptr++;
+ }
+ destY--;
+ (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (void *) rgba, NULL);
+ src += rowLength*2;
+ }
+ }
else {
/* with zooming */
GLint row;
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
for (row=0; row<drawHeight; row++) {
GLubyte *ptr = src;
GLint i;
@@ -342,7 +421,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
/* no zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(const GLubyte (*)[4])rgba,
@@ -352,11 +431,25 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
}
return GL_TRUE;
}
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ ASSERT(drawWidth < MAX_WIDTH);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
+ destY--;
+ (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (const GLubyte (*)[4])rgba,
+ NULL);
+ src += rowLength;
+ }
+ return GL_TRUE;
+ }
else {
/* with zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
- assert(drawWidth < MAX_WIDTH);
+ ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
zSpan, (void *) rgba, zoomY0);
@@ -511,11 +604,11 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLuint ispan[MAX_WIDTH];
GLint drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
- if (type != GL_UNSIGNED_BYTE
+ if (type != GL_BYTE
&& type != GL_UNSIGNED_BYTE
+ && type != GL_SHORT
&& type != GL_UNSIGNED_SHORT
- && type != GL_UNSIGNED_SHORT
- && type != GL_UNSIGNED_INT
+ && type != GL_INT
&& type != GL_UNSIGNED_INT
&& type != GL_FLOAT) {
gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels(type)");
@@ -652,17 +745,23 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
pixels, width, height, format, type, 0, row, 0);
_mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba,
format, type, source, unpack, GL_TRUE);
- if (ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink)
+ if ((ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) ||
+ (ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
+ GLubyte primary_rgba[MAX_WIDTH][4];
GLuint unit;
/* XXX not sure how multitexture is supposed to work here */
+
+ MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLubyte));
+
for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
_mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
s, t, r, q);
- gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba);
+ gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
+ primary_rgba, rgba);
}
}
diff --git a/xc/extras/Mesa/src/enums.c b/xc/extras/Mesa/src/enums.c
index a9daa3569..f28c61a03 100644
--- a/xc/extras/Mesa/src/enums.c
+++ b/xc/extras/Mesa/src/enums.c
@@ -804,7 +804,30 @@ enum_elt all_enums[] =
{ "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", 0x81A9},
/* GL_EXT_clip_volume_hint */
- { "GL_CLIP_VOLUME_CLIPPING_HINT_EXT", 0x80F0}
+ { "GL_CLIP_VOLUME_CLIPPING_HINT_EXT", 0x80F0},
+
+ /* GL_EXT_texture_env_combine */
+ { "GL_COMBINE_EXT", 0x8570 },
+ { "GL_COMBINE_RGB_EXT", 0x8571 },
+ { "GL_COMBINE_ALPHA_EXT", 0x8572 },
+ { "GL_SOURCE0_RGB_EXT", 0x8580 },
+ { "GL_SOURCE1_RGB_EXT", 0x8581 },
+ { "GL_SOURCE2_RGB_EXT", 0x8582 },
+ { "GL_SOURCE0_ALPHA_EXT", 0x8588 },
+ { "GL_SOURCE1_ALPHA_EXT", 0x8589 },
+ { "GL_SOURCE2_ALPHA_EXT", 0x858A },
+ { "GL_OPERAND0_RGB_EXT", 0x8590 },
+ { "GL_OPERAND1_RGB_EXT", 0x8591 },
+ { "GL_OPERAND2_RGB_EXT", 0x8592 },
+ { "GL_OPERAND0_ALPHA_EXT", 0x8598 },
+ { "GL_OPERAND1_ALPHA_EXT", 0x8599 },
+ { "GL_OPERAND2_ALPHA_EXT", 0x859A },
+ { "GL_RGB_SCALE_EXT", 0x8573 },
+ { "GL_ADD_SIGNED_EXT", 0x8574 },
+ { "GL_INTERPOLATE_EXT", 0x8575 },
+ { "GL_CONSTANT_EXT", 0x8576 },
+ { "GL_PRIMARY_COLOR_EXT", 0x8577 },
+ { "GL_PREVIOUS_EXT", 0x8578 }
};
diff --git a/xc/extras/Mesa/src/eval.c b/xc/extras/Mesa/src/eval.c
index 2b9d8e8e9..a88c6dc85 100644
--- a/xc/extras/Mesa/src/eval.c
+++ b/xc/extras/Mesa/src/eval.c
@@ -2452,7 +2452,7 @@ void gl_eval_vb( struct vertex_buffer *VB )
if (ctx->Eval.Map1Color4 && any_eval1)
VB->ColorPtr = eval1_color( out_color, coord, flags, IM->Start,
- &ctx->EvalMap.Map1Color4 );
+ &ctx->EvalMap.Map1Color4 );
if (ctx->Eval.Map2Color4 && any_eval2)
VB->ColorPtr = eval2_color( out_color, coord, flags, IM->Start,
@@ -2481,8 +2481,9 @@ void gl_eval_vb( struct vertex_buffer *VB )
VB->NormalPtr = eval2_norm( out_normal, coord, flags, IM->Start,
&ctx->EvalMap.Map2Normal );
+ new_flags |= VERT_NORM;
+
if (VB->NormalPtr != in_normal) {
- new_flags |= VERT_NORM;
if (!all_eval)
VB->NormalPtr = copy_3f( out_normal, in_normal, flags, IM->Start );
}
@@ -2550,26 +2551,42 @@ void gl_eval_vb( struct vertex_buffer *VB )
}
if (any_eval2) {
+ GLvector3f *in_normal = VB->NormalPtr;
+ GLvector3f *out_normal = &IM->v.Normal;
+
if (ctx->Eval.Map2Vertex4)
{
- if (ctx->Eval.AutoNormal && (req & VERT_NORM))
- obj = eval2_obj_norm( out, VB->NormalPtr, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map2Vertex4 );
+ if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
+ obj = eval2_obj_norm( out, out_normal, coord, flags,
+ IM->Start, 4, &ctx->EvalMap.Map2Vertex4 );
+ VB->NormalPtr = out_normal;
+ new_flags |= VERT_NORM;
+ }
else
obj = eval2_4f( out, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map2Vertex4);
+ 4, &ctx->EvalMap.Map2Vertex4 );
}
else if (ctx->Eval.Map2Vertex3)
{
- if (ctx->Eval.AutoNormal && (req & VERT_NORM))
- obj = eval2_obj_norm( out, VB->NormalPtr, coord, flags, IM->Start,
- 3, &ctx->EvalMap.Map2Vertex3 );
+ if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
+ obj = eval2_obj_norm( out, out_normal, coord, flags,
+ IM->Start, 3, &ctx->EvalMap.Map2Vertex3 );
+ VB->NormalPtr = out_normal;
+ new_flags |= VERT_NORM;
+ }
else
obj = eval2_4f( out, coord, flags, IM->Start,
3, &ctx->EvalMap.Map2Vertex3 );
}
- }
+
+ if (VB->NormalPtr != in_normal) {
+ if (!all_eval)
+ VB->NormalPtr = copy_3f( out_normal, in_normal, flags,
+ IM->Start );
+ }
+ }
+
if (obj != in && !all_eval)
obj = copy_4f( out, in, flags, IM->Start );
@@ -2581,6 +2598,7 @@ void gl_eval_vb( struct vertex_buffer *VB )
GLuint *flags = VB->Flag = VB->EvaluatedFlags;
GLuint i;
GLuint count = VB->Count;
+ GLuint andflag = VB->IM->AndFlag;
if (!flags) {
VB->EvaluatedFlags = (GLuint *) MALLOC(VB->Size * sizeof(GLuint));
@@ -2588,16 +2606,21 @@ void gl_eval_vb( struct vertex_buffer *VB )
}
if (all_eval) {
- for (i = 0 ; i < count ; i++)
+ for (i = 0 ; i <= count ; i++)
flags[i] = oldflags[i] | new_flags;
+ andflag |= new_flags;
} else {
- GLuint andflag = ~0;
- for (i = 0 ; i < count ; i++) {
- if (oldflags[i] & VERT_EVAL_ANY)
- flags[i] = oldflags[i] | new_flags;
+ andflag = ~0;
+ for (i = 0 ; i <= count ; i++) {
+ flags[i] = oldflags[i];
+ if (flags[i] & VERT_EVAL_ANY)
+ flags[i] |= new_flags;
andflag &= flags[i];
}
}
+
+ VB->OrFlag |= new_flags;
+ VB->CullMode = (GLubyte) ((andflag & VERT_NORM) ? 0 : COMPACTED_NORMALS);
}
}
diff --git a/xc/extras/Mesa/src/extensions.c b/xc/extras/Mesa/src/extensions.c
index d242b2a7d..f3e771c98 100644
--- a/xc/extras/Mesa/src/extensions.c
+++ b/xc/extras/Mesa/src/extensions.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -50,7 +50,7 @@ struct extension {
static struct { int enabled; const char *name; } default_extensions[] = {
{ DEFAULT_OFF, "GL_ARB_imaging" }, /* in progress */
{ DEFAULT_ON, "GL_ARB_multitexture" },
- { DEFAULT_OFF, "GL_ARB_texture_compression" }, /* in progress */
+ { DEFAULT_OFF, "GL_ARB_texture_compression" },
{ DEFAULT_OFF, "GL_ARB_texture_cube_map" }, /* in progress */
{ ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" },
{ ALWAYS_ENABLED, "GL_EXT_abgr" },
@@ -74,6 +74,7 @@ static struct { int enabled; const char *name; } default_extensions[] = {
{ DEFAULT_OFF, "GL_EXT_texture_compression_s3tc" },
{ DEFAULT_OFF, "GL_EXT_texture_env" },
{ DEFAULT_ON, "GL_EXT_texture_env_add" },
+ { DEFAULT_OFF, "GL_EXT_texture_env_combine" },
{ ALWAYS_ENABLED, "GL_EXT_texture_object" },
{ DEFAULT_ON, "GL_EXT_texture_lod_bias" },
{ ALWAYS_ENABLED, "GL_EXT_vertex_array" },
@@ -102,6 +103,7 @@ update_extension_flags( GLcontext *ctx )
{
/* Update flags */
ctx->Extensions.HaveTextureEnvAdd = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add");
+ ctx->Extensions.HaveTextureEnvCombine = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_combine");
ctx->Extensions.HaveTextureLodBias = gl_extension_is_enabled(ctx, "GL_EXT_texture_lod_bias");
ctx->Extensions.HaveHpOcclusionTest = gl_extension_is_enabled(ctx, "GL_HP_occlusion_test");
ctx->Extensions.HaveTextureCubeMap = gl_extension_is_enabled(ctx, "GL_ARB_texture_cube_map");
diff --git a/xc/extras/Mesa/src/fog.c b/xc/extras/Mesa/src/fog.c
index d21711805..1a7ca2546 100644
--- a/xc/extras/Mesa/src/fog.c
+++ b/xc/extras/Mesa/src/fog.c
@@ -426,4 +426,3 @@ _mesa_fog_ci_pixels( const GLcontext *ctx,
return;
}
}
-
diff --git a/xc/extras/Mesa/src/get.c b/xc/extras/Mesa/src/get.c
index 21b5b639a..59e86056a 100644
--- a/xc/extras/Mesa/src/get.c
+++ b/xc/extras/Mesa/src/get.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -91,9 +91,16 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetBooleanv");
+ if (!params)
+ return;
+
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glGetBooleanv %s\n", gl_lookup_enum_by_nr(pname));
+ if (ctx->Driver.GetBooleanv
+ && (*ctx->Driver.GetBooleanv)(ctx, pname, params))
+ return;
+
switch (pname) {
case GL_ACCUM_RED_BITS:
*params = INT_TO_BOOL(ctx->Visual->AccumRedBits);
@@ -1234,9 +1241,15 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetDoublev");
+ if (!params)
+ return;
+
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glGetDoublev %s\n", gl_lookup_enum_by_nr(pname));
+ if (ctx->Driver.GetDoublev && (*ctx->Driver.GetDoublev)(ctx, pname, params))
+ return;
+
switch (pname) {
case GL_ACCUM_RED_BITS:
*params = (GLdouble) ctx->Visual->AccumRedBits;
@@ -2377,9 +2390,15 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetFloatv");
+ if (!params)
+ return;
+
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glGetFloatv %s\n", gl_lookup_enum_by_nr(pname));
+ if (ctx->Driver.GetFloatv && (*ctx->Driver.GetFloatv)(ctx, pname, params))
+ return;
+
switch (pname) {
case GL_ACCUM_RED_BITS:
*params = (GLfloat) ctx->Visual->AccumRedBits;
@@ -3491,9 +3510,16 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetIntegerv");
+ if (!params)
+ return;
+
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glGetIntegerv %s\n", gl_lookup_enum_by_nr(pname));
+ if (ctx->Driver.GetIntegerv
+ && (*ctx->Driver.GetIntegerv)(ctx, pname, params))
+ return;
+
switch (pname) {
case GL_ACCUM_RED_BITS:
*params = (GLint) ctx->Visual->AccumRedBits;
@@ -4628,11 +4654,19 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
{
GET_CURRENT_CONTEXT(ctx);
GLuint texUnit = ctx->Texture.CurrentUnit;
- /*GLuint texTransformUnit = ctx->Texture.CurrentTransformUnit;*/
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetPointerv");
+
+ if (!params)
+ return;
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glGetPointerv %s\n", gl_lookup_enum_by_nr(pname));
+ if (ctx->Driver.GetPointerv
+ && (*ctx->Driver.GetPointerv)(ctx, pname, params))
+ return;
+
switch (pname) {
case GL_VERTEX_ARRAY_POINTER:
*params = ctx->Array.Vertex.Ptr;
@@ -4670,9 +4704,9 @@ const GLubyte *
_mesa_GetString( GLenum name )
{
GET_CURRENT_CONTEXT(ctx);
- static char *vendor = "Brian Paul";
- static char *renderer = "Mesa";
- static char *version = "1.2 Mesa 3.3 beta";
+ static const char *vendor = "Brian Paul";
+ static const char *renderer = "Mesa";
+ static const char *version = "1.2 Mesa 3.4";
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGetString", 0);
diff --git a/xc/extras/Mesa/src/glapinoop.c b/xc/extras/Mesa/src/glapinoop.c
index 94d4a11f1..a48509d6b 100644
--- a/xc/extras/Mesa/src/glapinoop.c
+++ b/xc/extras/Mesa/src/glapinoop.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -690,7 +690,16 @@ void *__glapi_noop_table[] = {
(void *) NoOpGetColorTableEXT,
(void *) NoOpGetColorTableParameterivEXT,
(void *) NoOpGetColorTableParameterfvEXT,
-
+ /* GL_3DFX_tbuffer */
+ (void *) NoOpTbufferMask3DFX,
+ /* GL_ARB_texture_compression */
+ (void *) NoOpCompressedTexImage3DARB,
+ (void *) NoOpCompressedTexImage2DARB,
+ (void *) NoOpCompressedTexImage1DARB,
+ (void *) NoOpCompressedTexSubImage3DARB,
+ (void *) NoOpCompressedTexSubImage2DARB,
+ (void *) NoOpCompressedTexSubImage1DARB,
+ (void *) NoOpGetCompressedTexImageARB,
/* A whole bunch of no-op functions. These might be called
* when someone tries to call a dynamically-registered extension
* function without a current rendering context.
diff --git a/xc/extras/Mesa/src/glheader.h b/xc/extras/Mesa/src/glheader.h
index e34ec9cfb..5094ce2ed 100644
--- a/xc/extras/Mesa/src/glheader.h
+++ b/xc/extras/Mesa/src/glheader.h
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -22,6 +22,7 @@
* 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.
*/
+/* $XFree86: xc/extras/Mesa/src/glheader.h,v 1.8 2000/08/11 17:01:49 dawes Exp $ */
#ifndef GLHEADER_H
@@ -77,11 +78,11 @@
* the new src/glheader.h file.
*/
-#if defined(_WIN32) && !defined(__WIN32__)
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
# define __WIN32__
#endif
-#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN__))
+#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
# pragma warning( disable : 4068 ) /* unknown pragma */
# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
@@ -128,7 +129,7 @@
/* compatability guard so we don't need to change client code */
-#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP)
+#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__)
#if 0
# define CALLBACK GLCALLBACK
#endif
@@ -138,6 +139,11 @@ typedef void *HDC;
typedef unsigned long COLORREF;
#endif
+
+/* Make sure we include glext.h from gl.h */
+#define GL_GLEXT_PROTOTYPES
+
+
#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
# define WGL_FONT_LINES 0
# define WGL_FONT_POLYGONS 1
@@ -159,8 +165,6 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
-/* Make sure we include glext.h */
-#define GL_GLEXT_PROTOTYPES
#include "GL/gl.h"
#include "GL/glext.h"
diff --git a/xc/extras/Mesa/src/image.c b/xc/extras/Mesa/src/image.c
index 825ce7ed5..11703a5d0 100644
--- a/xc/extras/Mesa/src/image.c
+++ b/xc/extras/Mesa/src/image.c
@@ -329,6 +329,7 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
+ case GL_INTENSITY:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
case GL_DEPTH_COMPONENT:
@@ -617,6 +618,7 @@ _mesa_pack_rgba_span( GLcontext *ctx,
ctx->Pixel.ScaleOrBiasRGBApcm ||
ctx->Pixel.ColorTableEnabled ||
ctx->Pixel.PostColorMatrixColorTableEnabled ||
+ ctx->Pixel.PostConvolutionColorTableEnabled ||
ctx->Pixel.MinMaxEnabled ||
ctx->Pixel.HistogramEnabled);
@@ -673,8 +675,11 @@ _mesa_pack_rgba_span( GLcontext *ctx,
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
}
/* XXX convolution here */
- /* XXX post-convolution color table look-up here */
- /* color matrix */
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostConvolutionColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
+ }
+ /* color matrix transform */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
_mesa_transform_rgba(ctx, n, rgba);
@@ -2200,6 +2205,7 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
ctx->Pixel.ScaleOrBiasRGBApcm ||
ctx->Pixel.ColorTableEnabled ||
ctx->Pixel.PostColorMatrixColorTableEnabled ||
+ ctx->Pixel.PostConvolutionColorTableEnabled ||
ctx->Pixel.MinMaxEnabled ||
ctx->Pixel.HistogramEnabled);
@@ -2317,7 +2323,10 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
}
/* XXX convolution here */
- /* XXX post-convolution color table look-up here */
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostConvolutionColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
+ }
/* color matrix transform */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
@@ -2515,6 +2524,7 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
ctx->Pixel.ScaleOrBiasRGBApcm ||
ctx->Pixel.ColorTableEnabled ||
ctx->Pixel.PostColorMatrixColorTableEnabled ||
+ ctx->Pixel.PostConvolutionColorTableEnabled ||
ctx->Pixel.MinMaxEnabled ||
ctx->Pixel.HistogramEnabled);
@@ -2582,7 +2592,10 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
_mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
}
/* XXX convolution here */
- /* XXX post-convolution color table look-up here */
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostConvolutionColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
+ }
/* color matrix transform */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
@@ -2994,6 +3007,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest,
break;
default:
gl_problem(NULL, "bad type in _mesa_unpack_depth_span()");
+ FREE(depth);
return;
}
diff --git a/xc/extras/Mesa/src/imaging.c b/xc/extras/Mesa/src/imaging.c
index 1dd37112d..ebc1b7487 100644
--- a/xc/extras/Mesa/src/imaging.c
+++ b/xc/extras/Mesa/src/imaging.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -938,6 +938,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G
format == GL_COLOR_INDEX ||
format == GL_STENCIL_INDEX ||
format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
type == GL_BITMAP) {
gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(format or type)");
return;
@@ -1007,6 +1008,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G
format == GL_COLOR_INDEX ||
format == GL_STENCIL_INDEX ||
format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
type == GL_BITMAP) {
gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(format or type)");
return;
@@ -1353,6 +1355,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im
format == GL_COLOR_INDEX ||
format == GL_STENCIL_INDEX ||
format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
type == GL_BITMAP) {
gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)");
return;
@@ -1460,7 +1463,7 @@ _mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
params[3] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][3]);
break;
case GL_CONVOLUTION_BORDER_MODE:
- *params = (GLint) ctx->Pixel.ConvolutionBorderMode;
+ *params = (GLint) ctx->Pixel.ConvolutionBorderMode[c];
break;
case GL_CONVOLUTION_FILTER_SCALE:
params[0] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][0];
@@ -1511,6 +1514,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
format == GL_COLOR_INDEX ||
format == GL_STENCIL_INDEX ||
format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
type == GL_BITMAP) {
gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)");
return;
@@ -1554,6 +1558,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs
format == GL_COLOR_INDEX ||
format == GL_STENCIL_INDEX ||
format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
type == GL_BITMAP) {
gl_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(format or type)");
return;
diff --git a/xc/extras/Mesa/src/light.c b/xc/extras/Mesa/src/light.c
index ed41e2311..138aefb08 100644
--- a/xc/extras/Mesa/src/light.c
+++ b/xc/extras/Mesa/src/light.c
@@ -512,9 +512,6 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname,
-
-
-
/*
* Check if the global material has to be updated with info that was
* associated with a vertex via glMaterial.
@@ -522,6 +519,8 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname,
* glBegin/glEnd either by calling glMaterial() or by calling glColor()
* when GL_COLOR_MATERIAL is enabled.
*
+ * src[0] is front material, src[1] is back material
+ *
* KW: Added code here to keep the precomputed variables uptodate.
* This means we can use the faster shade functions when using
* GL_COLOR_MATERIAL, and we can also now use the precomputed
@@ -529,41 +528,62 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname,
* the cost of doing this here.
*/
void gl_update_material( GLcontext *ctx,
- struct gl_material *src,
+ const struct gl_material src[2],
GLuint bitmask )
{
struct gl_light *light, *list = &ctx->Light.EnabledList;
- GLfloat tmp[4];
if (ctx->Light.ColorMaterialEnabled)
bitmask &= ~ctx->Light.ColorMaterialBitmask;
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
- fprintf(stderr, "gl_update_material, mask %x\n", bitmask);
+ fprintf(stderr, "gl_update_material, mask 0x%x\n", bitmask);
if (!bitmask)
return;
+ /* update material emission */
+ if (bitmask & FRONT_EMISSION_BIT) {
+ struct gl_material *mat = &ctx->Light.Material[0];
+ COPY_4FV( mat->Emission, src[0].Emission );
+ }
+ if (bitmask & BACK_EMISSION_BIT) {
+ struct gl_material *mat = &ctx->Light.Material[1];
+ COPY_4FV( mat->Emission, src[1].Emission );
+ }
+
+ /* update material ambience */
if (bitmask & FRONT_AMBIENT_BIT) {
struct gl_material *mat = &ctx->Light.Material[0];
- SUB_3V( tmp, src[0].Ambient, mat->Ambient );
- ACC_SCALE_3V( ctx->Light.BaseColor[0], ctx->Light.Model.Ambient, tmp);
+ COPY_4FV( mat->Ambient, src[0].Ambient );
foreach (light, list) {
- ACC_SCALE_3V( ctx->Light.BaseColor[0], light->Ambient, tmp );
+ SCALE_3V( light->MatAmbient[0], light->Ambient, src[0].Ambient);
}
- COPY_4FV( mat->Ambient, src[0].Ambient );
}
if (bitmask & BACK_AMBIENT_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
- SUB_3V( tmp, src[1].Ambient, mat->Ambient );
- ACC_SCALE_3V( ctx->Light.BaseColor[1], ctx->Light.Model.Ambient, tmp);
+ COPY_4FV( mat->Ambient, src[1].Ambient );
foreach (light, list) {
- ACC_SCALE_3V( ctx->Light.BaseColor[0], light->Ambient, tmp );
+ SCALE_3V( light->MatAmbient[1], light->Ambient, src[1].Ambient);
}
- COPY_4FV( mat->Ambient, src[1].Ambient );
}
+
+ /* update BaseColor = emission + scene's ambience * material's ambience */
+ if (bitmask & (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT)) {
+ struct gl_material *mat = &ctx->Light.Material[0];
+ COPY_3V( ctx->Light.BaseColor[0], mat->Emission );
+ ACC_SCALE_3V( ctx->Light.BaseColor[0], mat->Ambient, ctx->Light.Model.Ambient );
+ }
+ if (bitmask & (BACK_EMISSION_BIT | BACK_AMBIENT_BIT)) {
+ struct gl_material *mat = &ctx->Light.Material[1];
+ COPY_3V( ctx->Light.BaseColor[1], mat->Emission );
+ ACC_SCALE_3V( ctx->Light.BaseColor[1], mat->Ambient, ctx->Light.Model.Ambient );
+ }
+
+ /* update material diffuse values */
if (bitmask & FRONT_DIFFUSE_BIT) {
struct gl_material *mat = &ctx->Light.Material[0];
+ GLfloat tmp[4];
SUB_3V( tmp, src[0].Diffuse, mat->Diffuse );
foreach (light, list) {
ACC_SCALE_3V( light->MatDiffuse[0], light->Diffuse, tmp );
@@ -573,6 +593,7 @@ void gl_update_material( GLcontext *ctx,
}
if (bitmask & BACK_DIFFUSE_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
+ GLfloat tmp[4];
SUB_3V( tmp, src[1].Diffuse, mat->Diffuse );
foreach (light, list) {
ACC_SCALE_3V( light->MatDiffuse[1], light->Diffuse, tmp );
@@ -580,8 +601,11 @@ void gl_update_material( GLcontext *ctx,
COPY_4FV( mat->Diffuse, src[1].Diffuse );
FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Light.BaseAlpha[1], mat->Diffuse[3]);
}
+
+ /* update material specular values */
if (bitmask & FRONT_SPECULAR_BIT) {
struct gl_material *mat = &ctx->Light.Material[0];
+ GLfloat tmp[4];
SUB_3V( tmp, src[0].Specular, mat->Specular );
foreach (light, list) {
if (light->Flags & LIGHT_SPECULAR) {
@@ -594,6 +618,7 @@ void gl_update_material( GLcontext *ctx,
}
if (bitmask & BACK_SPECULAR_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
+ GLfloat tmp[4];
SUB_3V( tmp, src[1].Specular, mat->Specular );
foreach (light, list) {
if (light->Flags & LIGHT_SPECULAR) {
@@ -604,18 +629,7 @@ void gl_update_material( GLcontext *ctx,
}
COPY_4FV( mat->Specular, src[1].Specular );
}
- if (bitmask & FRONT_EMISSION_BIT) {
- struct gl_material *mat = &ctx->Light.Material[0];
- SUB_3V( tmp, src[0].Emission, mat->Emission );
- ACC_3V( ctx->Light.BaseColor[0], tmp );
- COPY_4FV( mat->Emission, src[0].Emission );
- }
- if (bitmask & BACK_EMISSION_BIT) {
- struct gl_material *mat = &ctx->Light.Material[1];
- SUB_3V( tmp, src[1].Emission, mat->Emission );
- ACC_3V( ctx->Light.BaseColor[1], tmp );
- COPY_4FV( mat->Emission, src[1].Emission );
- }
+
if (bitmask & FRONT_SHININESS_BIT) {
GLfloat shininess = ctx->Light.Material[0].Shininess = src[0].Shininess;
gl_compute_shine_table( ctx, 0, shininess );
@@ -626,6 +640,7 @@ void gl_update_material( GLcontext *ctx,
gl_compute_shine_table( ctx, 1, shininess );
gl_compute_shine_table( ctx, 3, shininess * .5 );
}
+
if (bitmask & FRONT_INDEXES_BIT) {
ctx->Light.Material[0].AmbientIndex = src[0].AmbientIndex;
ctx->Light.Material[0].DiffuseIndex = src[0].DiffuseIndex;
@@ -662,43 +677,68 @@ void gl_update_material( GLcontext *ctx,
-
-
+/*
+ * Update the current materials from the given rgba color
+ * according to the bitmask in ColorMaterialBitmask, which is
+ * set by glColorMaterial().
+ */
void gl_update_color_material( GLcontext *ctx,
const GLubyte rgba[4] )
{
struct gl_light *light, *list = &ctx->Light.EnabledList;
GLuint bitmask = ctx->Light.ColorMaterialBitmask;
- GLfloat tmp[4], color[4];
+ GLfloat color[4];
UBYTE_RGBA_TO_FLOAT_RGBA( color, rgba );
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
- fprintf(stderr, "gl_update_color_material, mask %x\n", bitmask);
+ fprintf(stderr, "gl_update_color_material, mask 0x%x\n", bitmask);
+
+ /* update emissive colors */
+ if (bitmask & FRONT_EMISSION_BIT) {
+ struct gl_material *mat = &ctx->Light.Material[0];
+ COPY_4FV( mat->Emission, color );
+ }
+ if (bitmask & BACK_EMISSION_BIT) {
+ struct gl_material *mat = &ctx->Light.Material[1];
+ COPY_4FV( mat->Emission, color );
+ }
+ /* update light->MatAmbient = light's ambient * material's ambient */
if (bitmask & FRONT_AMBIENT_BIT) {
struct gl_material *mat = &ctx->Light.Material[0];
- SUB_3V( tmp, color, mat->Ambient );
- ACC_SCALE_3V( ctx->Light.BaseColor[0], ctx->Light.Model.Ambient, tmp);
foreach (light, list) {
- ACC_SCALE_3V( ctx->Light.BaseColor[0], light->Ambient, tmp );
+ SCALE_3V( light->MatAmbient[0], light->Ambient, color);
}
COPY_4FV( mat->Ambient, color );
}
if (bitmask & BACK_AMBIENT_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
- SUB_3V( tmp, color, mat->Ambient );
- ACC_SCALE_3V( ctx->Light.BaseColor[1], ctx->Light.Model.Ambient, tmp);
foreach (light, list) {
- ACC_SCALE_3V( ctx->Light.BaseColor[0], light->Ambient, tmp );
+ SCALE_3V( light->MatAmbient[1], light->Ambient, color);
}
COPY_4FV( mat->Ambient, color );
}
+ /* update BaseColor = emission + scene's ambience * material's ambience */
+ if (bitmask & (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT)) {
+ struct gl_material *mat = &ctx->Light.Material[0];
+ COPY_3V( ctx->Light.BaseColor[0], mat->Emission );
+ ACC_SCALE_3V( ctx->Light.BaseColor[0], mat->Ambient, ctx->Light.Model.Ambient );
+ }
+
+ if (bitmask & (BACK_EMISSION_BIT | BACK_AMBIENT_BIT)) {
+ struct gl_material *mat = &ctx->Light.Material[1];
+ COPY_3V( ctx->Light.BaseColor[1], mat->Emission );
+ ACC_SCALE_3V( ctx->Light.BaseColor[1], mat->Ambient, ctx->Light.Model.Ambient );
+ }
+
+ /* update light->MatDiffuse = light's diffuse * material's diffuse */
if (bitmask & FRONT_DIFFUSE_BIT) {
struct gl_material *mat = &ctx->Light.Material[0];
+ GLfloat tmp[4];
SUB_3V( tmp, color, mat->Diffuse );
foreach (light, list) {
ACC_SCALE_3V( light->MatDiffuse[0], light->Diffuse, tmp );
@@ -709,6 +749,7 @@ void gl_update_color_material( GLcontext *ctx,
if (bitmask & BACK_DIFFUSE_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
+ GLfloat tmp[4];
SUB_3V( tmp, color, mat->Diffuse );
foreach (light, list) {
ACC_SCALE_3V( light->MatDiffuse[1], light->Diffuse, tmp );
@@ -717,8 +758,10 @@ void gl_update_color_material( GLcontext *ctx,
FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Light.BaseAlpha[1], mat->Diffuse[3]);
}
+ /* update light->MatSpecular = light's specular * material's specular */
if (bitmask & FRONT_SPECULAR_BIT) {
struct gl_material *mat = &ctx->Light.Material[0];
+ GLfloat tmp[4];
SUB_3V( tmp, color, mat->Specular );
foreach (light, list) {
if (light->Flags & LIGHT_SPECULAR) {
@@ -729,8 +772,10 @@ void gl_update_color_material( GLcontext *ctx,
}
COPY_4FV( mat->Specular, color );
}
+
if (bitmask & BACK_SPECULAR_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
+ GLfloat tmp[4];
SUB_3V( tmp, color, mat->Specular );
foreach (light, list) {
if (light->Flags & LIGHT_SPECULAR) {
@@ -741,18 +786,6 @@ void gl_update_color_material( GLcontext *ctx,
}
COPY_4FV( mat->Specular, color );
}
- if (bitmask & FRONT_EMISSION_BIT) {
- struct gl_material *mat = &ctx->Light.Material[0];
- SUB_3V( tmp, color, mat->Emission );
- ACC_3V( ctx->Light.BaseColor[0], tmp );
- COPY_4FV( mat->Emission, color );
- }
- if (bitmask & BACK_EMISSION_BIT) {
- struct gl_material *mat = &ctx->Light.Material[1];
- SUB_3V( tmp, color, mat->Emission );
- ACC_3V( ctx->Light.BaseColor[1], tmp );
- COPY_4FV( mat->Emission, color );
- }
if (0)
{
@@ -1085,26 +1118,27 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
* Whenever the spotlight exponent for a light changes we must call
* this function to recompute the exponent lookup table.
*/
-void gl_compute_spot_exp_table( struct gl_light *l )
+void
+gl_compute_spot_exp_table( struct gl_light *l )
{
- int i;
- double exponent = l->SpotExponent;
- double tmp = 0;
- int clamp = 0;
+ GLint i;
+ GLdouble exponent = l->SpotExponent;
+ GLdouble tmp = 0;
+ GLint clamp = 0;
l->SpotExpTable[0][0] = 0.0;
- for (i=EXP_TABLE_SIZE-1;i>0;i--) {
+ for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) {
if (clamp == 0) {
- tmp = pow(i/(double)(EXP_TABLE_SIZE-1), exponent);
- if (tmp < FLT_MIN*100.0) {
+ tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent);
+ if (tmp < FLT_MIN * 100.0) {
tmp = 0.0;
clamp = 1;
}
}
l->SpotExpTable[i][0] = tmp;
}
- for (i=0;i<EXP_TABLE_SIZE-1;i++) {
+ for (i = 0; i < EXP_TABLE_SIZE - 1; i++) {
l->SpotExpTable[i][1] = l->SpotExpTable[i+1][0] - l->SpotExpTable[i][0];
}
l->SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0;
@@ -1117,30 +1151,36 @@ void gl_compute_spot_exp_table( struct gl_light *l )
* lighting, and the cost of doing it early may be partially offset
* by keeping a MRU cache of shine tables for various shine values.
*/
-static void compute_shine_table( struct gl_shine_tab *tab, GLfloat shininess )
+static void
+compute_shine_table( struct gl_shine_tab *tab, GLfloat shininess )
{
- int i;
+ GLint i;
GLfloat *m = tab->tab;
- m[0] = 0;
- if (shininess == 0) {
+ m[0] = 0.0;
+ if (shininess == 0.0) {
for (i = 1 ; i <= SHINE_TABLE_SIZE ; i++)
- m[i] = 1;
- } else {
- for (i = 1 ; i <= SHINE_TABLE_SIZE ; i++) {
- double t = pow( i/(GLfloat)SHINE_TABLE_SIZE, shininess );
- m[i] = 0;
- if (t > 1e-20) m[i] = t;
+ m[i] = 1.0;
+ }
+ else {
+ for (i = 1 ; i < SHINE_TABLE_SIZE ; i++) {
+ GLdouble t = pow(i / (GLfloat) (SHINE_TABLE_SIZE - 1), shininess);
+ if (t > 1e-20)
+ m[i] = t;
+ else
+ m[i] = 0.0;
}
+ m[SHINE_TABLE_SIZE] = 1.0;
}
tab->shininess = shininess;
}
-#define DISTSQR(a,b) ((a-b)*(a-b))
-void gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
+void
+gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
{
+#define DISTSQR(a,b) ((a-b)*(a-b))
struct gl_shine_tab *list = ctx->ShineTabList;
struct gl_shine_tab *s;
@@ -1148,10 +1188,10 @@ void gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
if ( DISTSQR(s->shininess, shininess) < 1e-4 )
break;
- if (s == list)
- {
+ if (s == list) {
foreach(s, list)
- if (s->refcount == 0) break;
+ if (s->refcount == 0)
+ break;
compute_shine_table( s, shininess );
}
@@ -1160,12 +1200,14 @@ void gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
ctx->ShineTable[i] = s;
move_to_tail( list, s );
s->refcount++;
+#undef DISTSQR
}
#if 0
-static void gl_reinit_light_attrib( GLcontext *ctx, struct gl_light_attrib *l )
+static void
+gl_reinit_light_attrib( GLcontext *ctx, struct gl_light_attrib *l )
{
GLuint i;
@@ -1194,7 +1236,8 @@ static void gl_reinit_light_attrib( GLcontext *ctx, struct gl_light_attrib *l )
* Also, precompute some lighting values such as the products of light
* source and material ambient, diffuse and specular coefficients.
*/
-void gl_update_lighting( GLcontext *ctx )
+void
+gl_update_lighting( GLcontext *ctx )
{
struct gl_light *light;
@@ -1224,13 +1267,12 @@ void gl_update_lighting( GLcontext *ctx )
/* Precompute some shading values.
*/
- if (ctx->Visual->RGBAflag)
- {
+ if (ctx->Visual->RGBAflag) {
GLuint sides = ((ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) ? 2 : 1);
GLuint side;
for (side=0; side < sides; side++) {
struct gl_material *mat = &ctx->Light.Material[side];
-
+
COPY_3V(ctx->Light.BaseColor[side], mat->Emission);
ACC_SCALE_3V(ctx->Light.BaseColor[side],
ctx->Light.Model.Ambient,
@@ -1242,12 +1284,10 @@ void gl_update_lighting( GLcontext *ctx )
foreach (light, &ctx->Light.EnabledList) {
for (side=0; side< sides; side++) {
- struct gl_material *mat = &ctx->Light.Material[side];
- SCALE_3V( light->MatDiffuse[side], light->Diffuse, mat->Diffuse );
- SCALE_3V( light->MatAmbient[side], light->Ambient, mat->Ambient );
- ACC_3V( ctx->Light.BaseColor[side], light->MatAmbient[side] );
- if (light->Flags & LIGHT_SPECULAR)
- {
+ const struct gl_material *mat = &ctx->Light.Material[side];
+ SCALE_3V( light->MatDiffuse[side], light->Diffuse, mat->Diffuse );
+ SCALE_3V( light->MatAmbient[side], light->Ambient, mat->Ambient );
+ if (light->Flags & LIGHT_SPECULAR) {
SCALE_3V( light->MatSpecular[side], light->Specular,
mat->Specular);
light->IsMatSpecular[side] =
@@ -1258,10 +1298,8 @@ void gl_update_lighting( GLcontext *ctx )
}
}
}
- else
- {
- static GLfloat ci[3] = { .30, .59, .11 };
-
+ else {
+ static const GLfloat ci[3] = { .30, .59, .11 };
foreach(light, &ctx->Light.EnabledList) {
light->dli = DOT3(ci, light->Diffuse);
light->sli = DOT3(ci, light->Specular);
@@ -1269,52 +1307,54 @@ void gl_update_lighting( GLcontext *ctx )
}
}
+
+
/* Need to seriously restrict the circumstances under which these
* calc's are performed.
*/
-void gl_compute_light_positions( GLcontext *ctx )
+void
+gl_compute_light_positions( GLcontext *ctx )
{
struct gl_light *light;
- if (ctx->Light.NeedVertices && !ctx->Light.Model.LocalViewer) {
- GLfloat eye_z[3] = { 0, 0, 1 };
- if (!ctx->NeedEyeCoords) {
- TRANSFORM_NORMAL( ctx->EyeZDir, eye_z, ctx->ModelView.m );
- } else {
+ if (1 /*ctx->Light.NeedVertices && !ctx->Light.Model.LocalViewer*/) {
+ static const GLfloat eye_z[3] = { 0, 0, 1 };
+ if (ctx->NeedEyeCoords) {
COPY_3V( ctx->EyeZDir, eye_z );
}
+ else {
+ TRANSFORM_NORMAL( ctx->EyeZDir, eye_z, ctx->ModelView.m );
+ }
}
foreach (light, &ctx->Light.EnabledList) {
- if (!ctx->NeedEyeCoords) {
+ if (ctx->NeedEyeCoords) {
+ COPY_4FV( light->Position, light->EyePosition );
+ }
+ else {
TRANSFORM_POINT( light->Position, ctx->ModelView.inv,
light->EyePosition );
- } else {
- COPY_4FV( light->Position, light->EyePosition );
}
- if (!(light->Flags & LIGHT_POSITIONAL))
- {
+ if (!(light->Flags & LIGHT_POSITIONAL)) {
/* VP (VP) = Normalize( Position ) */
COPY_3V( light->VP_inf_norm, light->Position );
NORMALIZE_3FV( light->VP_inf_norm );
- if (!ctx->Light.Model.LocalViewer)
- {
+ if (!ctx->Light.Model.LocalViewer) {
/* h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
ADD_3V( light->h_inf_norm, light->VP_inf_norm, ctx->EyeZDir);
NORMALIZE_3FV( light->h_inf_norm );
}
-
light->VP_inf_spot_attenuation = 1.0;
}
- if (light->Flags & LIGHT_SPOT)
- {
+ if (light->Flags & LIGHT_SPOT) {
if (ctx->NeedEyeNormals) {
COPY_3V( light->NormDirection, light->EyeDirection );
- } else {
+ }
+ else {
TRANSFORM_NORMAL( light->NormDirection,
light->EyeDirection,
ctx->ModelView.m);
@@ -1336,18 +1376,17 @@ void gl_compute_light_positions( GLcontext *ctx )
(light->SpotExpTable[k][0] +
(x-k)*light->SpotExpTable[k][1]);
}
- else
+ else {
light->VP_inf_spot_attenuation = 0;
+ }
}
}
}
}
-
-
-
-void gl_update_normal_transform( GLcontext *ctx )
+void
+gl_update_normal_transform( GLcontext *ctx )
{
GLuint new_flag = 0;
normal_func *last = ctx->NormalTransform;
@@ -1368,20 +1407,18 @@ void gl_update_normal_transform( GLcontext *ctx )
new_flag = ctx->NewState & NEW_MODELVIEW;
ctx->vb_rescale_factor = ctx->rescale_factor;
- if (ctx->Transform.Normalize)
- {
+ if (ctx->Transform.Normalize) {
ctx->NormalTransform = gl_normal_tab[transform | NORM_NORMALIZE];
}
else if (ctx->Transform.RescaleNormals &&
- ctx->rescale_factor != 1.0)
- {
+ ctx->rescale_factor != 1.0) {
ctx->NormalTransform = gl_normal_tab[transform | NORM_RESCALE];
}
- else
- {
+ else {
ctx->NormalTransform = gl_normal_tab[transform];
}
- } else {
+ }
+ else {
ctx->NormalTransform = 0;
}
}
@@ -1389,20 +1426,18 @@ void gl_update_normal_transform( GLcontext *ctx )
if (ctx->NeedNormals) {
ctx->vb_rescale_factor = 1.0/ctx->rescale_factor;
- if (ctx->Transform.Normalize)
- {
+ if (ctx->Transform.Normalize) {
ctx->NormalTransform = gl_normal_tab[NORM_NORMALIZE];
}
else if (!ctx->Transform.RescaleNormals &&
- ctx->rescale_factor != 1.0)
- {
+ ctx->rescale_factor != 1.0) {
ctx->NormalTransform = gl_normal_tab[NORM_RESCALE];
}
- else
- {
+ else {
ctx->NormalTransform = 0;
}
- } else {
+ }
+ else {
ctx->NormalTransform = 0;
}
}
@@ -1410,4 +1445,3 @@ void gl_update_normal_transform( GLcontext *ctx )
if (last != ctx->NormalTransform || new_flag)
ctx->NewState |= NEW_NORMAL_TRANSFORM;
}
-
diff --git a/xc/extras/Mesa/src/light.h b/xc/extras/Mesa/src/light.h
index aa7ded40c..8edcac801 100644
--- a/xc/extras/Mesa/src/light.h
+++ b/xc/extras/Mesa/src/light.h
@@ -3,7 +3,7 @@
* Mesa 3-D graphics library
* Version: 3.3
*
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2000 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"),
@@ -114,7 +114,7 @@ extern void gl_compute_light_positions( GLcontext *ctx );
extern void gl_update_normal_transform( GLcontext *ctx );
extern void gl_update_material( GLcontext *ctx,
- struct gl_material *m,
+ const struct gl_material src[2],
GLuint bitmask );
extern void gl_update_color_material( GLcontext *ctx, const GLubyte rgba[4] );
diff --git a/xc/extras/Mesa/src/lines.c b/xc/extras/Mesa/src/lines.c
index dd0649ba0..7b3b51112 100644
--- a/xc/extras/Mesa/src/lines.c
+++ b/xc/extras/Mesa/src/lines.c
@@ -556,13 +556,8 @@ static void general_smooth_rgba_line( GLcontext *ctx,
static void general_flat_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
{
- GLint count;
- GLint *pbx = ctx->PB->x;
- GLint *pby = ctx->PB->y;
- GLdepth *pbz = ctx->PB->z;
- GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+ const GLubyte *color = ctx->VB->ColorPtr->data[pvert];
PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
- count = ctx->PB->count;
if (ctx->Line.StippleFlag) {
/* stippled */
@@ -570,12 +565,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
#define INTERP_Z 1
#define WIDE 1
#define STIPPLE 1
-#define PLOT(X,Y) \
- pbx[count] = X; \
- pby[count] = Y; \
- pbz[count] = Z; \
- count++; \
- CHECK_FULL(count);
+#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
#include "linetemp.h"
}
else {
@@ -584,18 +574,10 @@ static void general_flat_rgba_line( GLcontext *ctx,
/* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
-#define XMAJOR_PLOT(X,Y) \
- pbx[count] = X; pbx[count+1] = X; \
- pby[count] = Y; pby[count+1] = Y+1; \
- pbz[count] = Z; pbz[count+1] = Z; \
- count += 2; \
- CHECK_FULL(count);
-#define YMAJOR_PLOT(X,Y) \
- pbx[count] = X; pbx[count+1] = X+1; \
- pby[count] = Y; pby[count+1] = Y; \
- pbz[count] = Z; pbz[count+1] = Z; \
- count += 2; \
- CHECK_FULL(count);
+#define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); \
+ PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z);
+#define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); \
+ PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z);
#include "linetemp.h"
}
else {
@@ -603,17 +585,11 @@ static void general_flat_rgba_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
#define WIDE 1
-#define PLOT(X,Y) \
- pbx[count] = X; \
- pby[count] = Y; \
- pbz[count] = Z; \
- count++; \
- CHECK_FULL(count);
+#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
#include "linetemp.h"
}
}
- ctx->PB->count = count;
gl_flush_pb(ctx);
}
@@ -847,6 +823,104 @@ static void smooth_multitextured_line( GLcontext *ctx,
}
+/* Flat-shaded, multitextured, any width, maybe stippled, separate specular
+ * color interpolation.
+ */
+static void flat_multitextured_line( GLcontext *ctx,
+ GLuint vert0, GLuint vert1, GLuint pvert )
+{
+ GLint count = ctx->PB->count;
+ GLint *pbx = ctx->PB->x;
+ GLint *pby = ctx->PB->y;
+ GLdepth *pbz = ctx->PB->z;
+ GLfloat *pbs = ctx->PB->s[0];
+ GLfloat *pbt = ctx->PB->t[0];
+ GLfloat *pbu = ctx->PB->u[0];
+ GLfloat *pbs1 = ctx->PB->s[1];
+ GLfloat *pbt1 = ctx->PB->t[1];
+ GLfloat *pbu1 = ctx->PB->u[1];
+ GLubyte (*pbrgba)[4] = ctx->PB->rgba;
+ GLubyte (*pbspec)[3] = ctx->PB->spec;
+ GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+ GLubyte sRed = ctx->VB->Specular ? ctx->VB->Specular[pvert][0] : 0;
+ GLubyte sGreen = ctx->VB->Specular ? ctx->VB->Specular[pvert][1] : 0;
+ GLubyte sBlue = ctx->VB->Specular ? ctx->VB->Specular[pvert][2] : 0;
+
+ (void) pvert;
+
+ ctx->PB->mono = GL_FALSE;
+
+ if (ctx->Line.StippleFlag) {
+ /* stippled */
+#define INTERP_XY 1
+#define INTERP_Z 1
+#define INTERP_ALPHA 1
+#define INTERP_STUV0 1
+#define INTERP_STUV1 1
+#define WIDE 1
+#define STIPPLE 1
+#define PLOT(X,Y) \
+ { \
+ pbx[count] = X; \
+ pby[count] = Y; \
+ pbz[count] = Z; \
+ pbs[count] = s; \
+ pbt[count] = t; \
+ pbu[count] = u; \
+ pbs1[count] = s1; \
+ pbt1[count] = t1; \
+ pbu1[count] = u1; \
+ pbrgba[count][RCOMP] = color[0]; \
+ pbrgba[count][GCOMP] = color[1]; \
+ pbrgba[count][BCOMP] = color[2]; \
+ pbrgba[count][ACOMP] = color[3]; \
+ pbspec[count][RCOMP] = sRed; \
+ pbspec[count][GCOMP] = sGreen; \
+ pbspec[count][BCOMP] = sBlue; \
+ count++; \
+ CHECK_FULL(count); \
+ }
+#include "linetemp.h"
+ }
+ else {
+ /* unstippled */
+#define INTERP_XY 1
+#define INTERP_Z 1
+#define INTERP_ALPHA 1
+#define INTERP_STUV0 1
+#define INTERP_STUV1 1
+#define WIDE 1
+#define PLOT(X,Y) \
+ { \
+ pbx[count] = X; \
+ pby[count] = Y; \
+ pbz[count] = Z; \
+ pbs[count] = s; \
+ pbt[count] = t; \
+ pbu[count] = u; \
+ pbs1[count] = s1; \
+ pbt1[count] = t1; \
+ pbu1[count] = u1; \
+ pbrgba[count][RCOMP] = color[0]; \
+ pbrgba[count][GCOMP] = color[1]; \
+ pbrgba[count][BCOMP] = color[2]; \
+ pbrgba[count][ACOMP] = color[3]; \
+ pbspec[count][RCOMP] = sRed; \
+ pbspec[count][GCOMP] = sGreen; \
+ pbspec[count][BCOMP] = sBlue; \
+ count++; \
+ CHECK_FULL(count); \
+ }
+#include "linetemp.h"
+ }
+
+ ctx->PB->count = count;
+ gl_flush_pb(ctx);
+}
+
+
+
+
/*
* Antialiased RGBA line
*
@@ -934,6 +1008,61 @@ static void null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
}
+
+#ifdef DEBUG
+void
+_mesa_print_line_function(GLcontext *ctx)
+{
+ printf("Line Func == ");
+ if (ctx->Driver.LineFunc == flat_ci_line)
+ printf("flat_ci_line\n");
+ else if (ctx->Driver.LineFunc == flat_ci_z_line)
+ printf("flat_ci_z_line\n");
+ else if (ctx->Driver.LineFunc == flat_rgba_line)
+ printf("flat_rgba_line\n");
+ else if (ctx->Driver.LineFunc == flat_rgba_z_line)
+ printf("flat_rgba_z_line\n");
+ else if (ctx->Driver.LineFunc == smooth_ci_line)
+ printf("smooth_ci_line\n");
+ else if (ctx->Driver.LineFunc == smooth_ci_z_line)
+ printf("smooth_ci_z_line\n");
+ else if (ctx->Driver.LineFunc == smooth_rgba_line)
+ printf("smooth_rgba_line\n");
+ else if (ctx->Driver.LineFunc == smooth_rgba_z_line)
+ printf("smooth_rgba_z_line\n");
+ else if (ctx->Driver.LineFunc == general_smooth_ci_line)
+ printf("general_smooth_ci_line\n");
+ else if (ctx->Driver.LineFunc == general_flat_ci_line)
+ printf("general_flat_ci_line\n");
+ else if (ctx->Driver.LineFunc == general_smooth_rgba_line)
+ printf("general_smooth_rgba_line\n");
+ else if (ctx->Driver.LineFunc == general_flat_rgba_line)
+ printf("general_flat_rgba_line\n");
+ else if (ctx->Driver.LineFunc == flat_textured_line)
+ printf("flat_textured_line\n");
+ else if (ctx->Driver.LineFunc == smooth_textured_line)
+ printf("smooth_textured_line\n");
+ else if (ctx->Driver.LineFunc == smooth_multitextured_line)
+ printf("smooth_multitextured_line\n");
+ else if (ctx->Driver.LineFunc == flat_multitextured_line)
+ printf("flat_multitextured_line\n");
+ else if (ctx->Driver.LineFunc == aa_rgba_line)
+ printf("aa_rgba_line\n");
+ else if (ctx->Driver.LineFunc == aa_tex_rgba_line)
+ printf("aa_tex_rgba_line\n");
+ else if (ctx->Driver.LineFunc == aa_multitex_rgba_line)
+ printf("aa_multitex_rgba_line\n");
+ else if (ctx->Driver.LineFunc == aa_ci_line)
+ printf("aa_ci_line\n");
+ else if (ctx->Driver.LineFunc == null_line)
+ printf("null_line\n");
+ else
+ printf("Driver func %p\n", ctx->Driver.PointsFunc);
+}
+#endif
+
+
+
/*
* Determine which line drawing function to use given the current
* rendering context.
@@ -975,7 +1104,10 @@ void gl_set_line_function( GLcontext *ctx )
if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D
|| ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
/* multi-texture and/or separate specular color */
- ctx->Driver.LineFunc = smooth_multitextured_line;
+ if (ctx->Light.ShadeModel==GL_SMOOTH)
+ ctx->Driver.LineFunc = smooth_multitextured_line;
+ else
+ ctx->Driver.LineFunc = flat_multitextured_line;
}
else {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
@@ -1041,5 +1173,6 @@ void gl_set_line_function( GLcontext *ctx )
/* GL_SELECT mode */
ctx->Driver.LineFunc = gl_select_line;
}
-}
+ /*_mesa_print_line_function(ctx);*/
+}
diff --git a/xc/extras/Mesa/src/linetemp.h b/xc/extras/Mesa/src/linetemp.h
index 9e0fbd301..9d427ad32 100644
--- a/xc/extras/Mesa/src/linetemp.h
+++ b/xc/extras/Mesa/src/linetemp.h
@@ -223,12 +223,12 @@
zPtr = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, x0, y0);
# endif
if (depthBits <= 16) {
- z0 = FloatToFixed(VB->Win.data[vert0][2]);
- z1 = FloatToFixed(VB->Win.data[vert1][2]);
+ z0 = FloatToFixed(VB->Win.data[vert0][2] + ctx->LineZoffset);
+ z1 = FloatToFixed(VB->Win.data[vert1][2] + ctx->LineZoffset);
}
else {
- z0 = (int) VB->Win.data[vert0][2];
- z1 = (int) VB->Win.data[vert1][2];
+ z0 = (int) VB->Win.data[vert0][2] + ctx->LineZoffset;
+ z1 = (int) VB->Win.data[vert1][2] + ctx->LineZoffset;
}
#endif
#ifdef PIXEL_ADDRESS
diff --git a/xc/extras/Mesa/src/lnaatemp.h b/xc/extras/Mesa/src/lnaatemp.h
index 118ffb675..1a96a811f 100644
--- a/xc/extras/Mesa/src/lnaatemp.h
+++ b/xc/extras/Mesa/src/lnaatemp.h
@@ -1,9 +1,9 @@
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2000 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"),
@@ -103,12 +103,12 @@
ctx->PB->mono = GL_FALSE;
if (depthBits <= 16) {
- z0 = FloatToFixed(VB->Win.data[vert0][2]);
- z1 = FloatToFixed(VB->Win.data[vert1][2]);
+ z0 = FloatToFixed(VB->Win.data[vert0][2] + ctx->LineZoffset);
+ z1 = FloatToFixed(VB->Win.data[vert1][2] + ctx->LineZoffset);
}
else {
- z0 = (int) VB->Win.data[vert0][2];
- z1 = (int) VB->Win.data[vert1][2];
+ z0 = (int) VB->Win.data[vert0][2] + ctx->LineZoffset;
+ z1 = (int) VB->Win.data[vert1][2] + ctx->LineZoffset;
}
#ifdef INTERP_STUV0
diff --git a/xc/extras/Mesa/src/logic.c b/xc/extras/Mesa/src/logic.c
index 1078cca68..872cb48d6 100644
--- a/xc/extras/Mesa/src/logic.c
+++ b/xc/extras/Mesa/src/logic.c
@@ -63,7 +63,7 @@ _mesa_LogicOp( GLenum opcode )
case GL_OR_INVERTED:
ctx->Color.LogicOp = opcode;
ctx->NewState |= NEW_RASTER_OPS;
- return;
+ break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
return;
diff --git a/xc/extras/Mesa/src/matrix.c b/xc/extras/Mesa/src/matrix.c
index 5c66ef0e3..ed3175536 100644
--- a/xc/extras/Mesa/src/matrix.c
+++ b/xc/extras/Mesa/src/matrix.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -596,7 +596,7 @@ void gl_rotation_matrix( GLfloat angle, GLfloat x, GLfloat y, GLfloat z,
mag = GL_SQRT( x*x + y*y + z*z );
- if (mag == 0.0) {
+ if (mag <= 1.0e-4) {
/* generate an identity matrix and return */
MEMCPY(m, Identity, sizeof(GLfloat)*16);
return;
@@ -1561,16 +1561,23 @@ void gl_calculate_model_project_matrix( GLcontext *ctx )
void gl_matrix_ctr( GLmatrix *m )
{
+ if ( m->m == 0 ) {
+ m->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+ }
+ MEMCPY( m->m, Identity, sizeof(Identity) );
m->inv = 0;
- MEMCPY( m->m, Identity, sizeof(Identity));
m->type = MATRIX_IDENTITY;
m->flags = MAT_DIRTY_DEPENDENTS;
}
void gl_matrix_dtr( GLmatrix *m )
{
- if (m->inv != 0) {
- FREE(m->inv);
+ if ( m->m != 0 ) {
+ ALIGN_FREE( m->m );
+ m->m = 0;
+ }
+ if ( m->inv != 0 ) {
+ ALIGN_FREE( m->inv );
m->inv = 0;
}
}
@@ -1578,7 +1585,7 @@ void gl_matrix_dtr( GLmatrix *m )
#if 0
void gl_matrix_set_identity( GLmatrix *m )
{
- MEMCPY( m->m, Identity, sizeof(Identity));
+ MEMCPY( m->m, Identity, sizeof(Identity) );
m->type = MATRIX_IDENTITY;
m->flags = MAT_DIRTY_DEPENDENTS;
}
@@ -1586,15 +1593,15 @@ void gl_matrix_set_identity( GLmatrix *m )
void gl_matrix_alloc_inv( GLmatrix *m )
{
- if (m->inv == 0) {
- m->inv = (GLfloat *)MALLOC(16*sizeof(GLfloat));
+ if ( m->inv == 0 ) {
+ m->inv = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
MEMCPY( m->inv, Identity, 16 * sizeof(GLfloat) );
}
}
void gl_matrix_copy( GLmatrix *to, const GLmatrix *from )
{
- MEMCPY( to->m, from->m, sizeof(Identity));
+ MEMCPY( to->m, from->m, sizeof(Identity) );
to->flags = from->flags | MAT_DIRTY_DEPENDENTS;
to->type = from->type;
diff --git a/xc/extras/Mesa/src/matrix.h b/xc/extras/Mesa/src/matrix.h
index 44d7cefab..6d989abd1 100644
--- a/xc/extras/Mesa/src/matrix.h
+++ b/xc/extras/Mesa/src/matrix.h
@@ -33,8 +33,8 @@
typedef struct {
- GLfloat m[16];
- GLfloat *inv; /* optional */
+ GLfloat *m; /* 16-byte aligned */
+ GLfloat *inv; /* optional, 16-byte aligned */
GLuint flags;
GLuint type;
} GLmatrix;
diff --git a/xc/extras/Mesa/src/mem.c b/xc/extras/Mesa/src/mem.c
index fff2bb163..9334b63c4 100644
--- a/xc/extras/Mesa/src/mem.c
+++ b/xc/extras/Mesa/src/mem.c
@@ -36,6 +36,7 @@
#include "all.h"
#else
#include "glheader.h"
+#include "macros.h"
#include "mem.h"
#endif
@@ -71,3 +72,84 @@ _mesa_free(void *ptr)
}
+
+/*
+ * N-byte aligned memory allocation functions. Called via the ALIGN_MALLOC,
+ * ALIGN_CALLOC and ALIGN_FREE macros. Debug versions?
+ * These functions allow dynamically allocated memory to be correctly
+ * aligned for improved cache utilization and specialized assembly
+ * support.
+ */
+
+
+/*
+ * Allocate N-byte aligned memory (uninitialized)
+ */
+void *
+_mesa_align_malloc(size_t bytes, unsigned long alignment)
+{
+ unsigned long ptr, buf;
+
+ ASSERT( alignment > 0 );
+
+ ptr = (unsigned long) MALLOC( bytes + alignment );
+
+ buf = (ptr + alignment) & ~(unsigned long)(alignment - 1);
+ *(unsigned long *)(buf - sizeof(void *)) = ptr;
+
+#ifdef DEBUG
+ /* mark the non-aligned area */
+ while ( ptr < buf - sizeof(void *) ) {
+ *(unsigned long *)ptr = 0xcdcdcdcd;
+ ptr += sizeof(unsigned long);
+ }
+#endif
+
+ return (void *)buf;
+}
+
+
+/*
+ * Allocate N-byte aligned memory and initialize to zero
+ */
+void *
+_mesa_align_calloc(size_t bytes, unsigned long alignment)
+{
+ unsigned long ptr, buf;
+
+ ASSERT( alignment > 0 );
+
+ ptr = (unsigned long) CALLOC( bytes + alignment );
+
+ buf = (ptr + alignment) & ~(unsigned long)(alignment - 1);
+ *(unsigned long *)(buf - sizeof(void *)) = ptr;
+
+#ifdef DEBUG
+ /* mark the non-aligned area */
+ while ( ptr < buf - sizeof(void *) ) {
+ *(unsigned long *)ptr = 0xcdcdcdcd;
+ ptr += sizeof(unsigned long);
+ }
+#endif
+
+ return (void *)buf;
+}
+
+
+/*
+ * Free N-byte aligned memory
+ */
+void
+_mesa_align_free(void *ptr)
+{
+#if 0
+ FREE( (void *)(*(unsigned long *)((unsigned long)ptr - sizeof(void *))) );
+#else
+ /* The actuall address to free is stuffed in the word immediately
+ * before the address the client sees.
+ */
+ void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
+ void *realAddr = *cubbyHole;
+ FREE(realAddr);
+#endif
+}
diff --git a/xc/extras/Mesa/src/mem.h b/xc/extras/Mesa/src/mem.h
index 794aa13ef..8935cb1aa 100644
--- a/xc/extras/Mesa/src/mem.h
+++ b/xc/extras/Mesa/src/mem.h
@@ -38,6 +38,10 @@ extern void *_mesa_malloc(size_t bytes);
extern void *_mesa_calloc(size_t bytes);
extern void _mesa_free(void *ptr);
+extern void *_mesa_align_malloc(size_t bytes, unsigned long alignment);
+extern void *_mesa_align_calloc(size_t bytes, unsigned long alignment);
+extern void _mesa_align_free(void *ptr);
+
#ifdef DEBUG
@@ -59,6 +63,13 @@ extern void _mesa_free(void *ptr);
#endif
+/* call Mesa N-byte aligned memory functions */
+#define ALIGN_MALLOC(BYTES, N) (void *) _mesa_align_malloc(BYTES, N)
+#define ALIGN_CALLOC(BYTES, N) (void *) _mesa_align_calloc(BYTES, N)
+#define ALIGN_MALLOC_STRUCT(T, N) (struct T *) _mesa_align_malloc(sizeof(struct T), N)
+#define ALIGN_CALLOC_STRUCT(T, N) (struct T *) _mesa_align_calloc(sizeof(struct T), N)
+#define ALIGN_FREE(PTR) _mesa_align_free(PTR)
+
/* Memory copy: */
#ifdef SUNOS4
diff --git a/xc/extras/Mesa/src/mmath.h b/xc/extras/Mesa/src/mmath.h
index 28d90bb6d..c0144c924 100644
--- a/xc/extras/Mesa/src/mmath.h
+++ b/xc/extras/Mesa/src/mmath.h
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -22,7 +22,7 @@
* 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.
*/
-/* $XFree86: xc/extras/Mesa/src/mmath.h,v 1.5 2000/06/17 00:02:14 martin Exp $ */
+/* $XFree86: xc/extras/Mesa/src/mmath.h,v 1.6 2000/08/09 23:40:10 dawes Exp $ */
/*
* Faster arithmetic functions. If the FAST_MATH preprocessor symbol is
@@ -47,7 +47,7 @@
* In the worst case, we force the compiler to use a memory access to
* truncate the float, by specifying the 'volatile' keyword.
*/
-#if defined(__linux__) && defined(__i386__)
+#if defined(__linux__) && defined(__i386__)
#include <fpu_control.h>
#if !defined(_FPU_SETCW)
@@ -158,7 +158,7 @@ static __inline__ int FloatToInt(float f)
__asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
return r;
}
-#elif defined(__MSC__) && defined(__WIN32__)
+#elif defined(__MSC__) && defined(__WIN32__) && !defined(__CYGWIN__)
static __inline int FloatToInt(float f)
{
int r;
@@ -232,14 +232,14 @@ do { \
* GLubyte b = FloatToInt(CLAMP(f, 0, 1) * 255)
*/
-#if defined(__i386__) || defined(__sparc__)
+#if defined(__i386__) || defined(__sparc__) || ( defined(__alpha__) && \
+ ( defined( __IEEE_FLOAT ) || !defined( VMS ) ) )
#define USE_IEEE
+#define IEEE_ONE 0x3f7f0000
#endif
#if defined(USE_IEEE) && !defined(DEBUG)
-#define IEEE_ONE 0x3f7f0000
-
#define CLAMP_FLOAT_COLOR(f) \
do { \
if (*(GLuint *)&f >= IEEE_ONE) \
diff --git a/xc/extras/Mesa/src/pb.c b/xc/extras/Mesa/src/pb.c
index 78ff5d07e..4cfbfa674 100644
--- a/xc/extras/Mesa/src/pb.c
+++ b/xc/extras/Mesa/src/pb.c
@@ -254,17 +254,22 @@ void gl_flush_pb( GLcontext *ctx )
if ((ctx->RasterMask & modBits) || !PB->mono) {
if (ctx->Texture.ReallyEnabled) {
- int texUnit;
+ GLubyte primary_rgba[PB_SIZE][4];
+ GLint texUnit;
+
+ /* must make a copy of primary colors since they may be modified */
+ MEMCPY(primary_rgba, PB->rgba, 4 * PB->count * sizeof(GLubyte));
+
for (texUnit=0;texUnit<MAX_TEXTURE_UNITS;texUnit++) {
- gl_texture_pixels( ctx, texUnit,
- PB->count, PB->s[texUnit], PB->t[texUnit],
- PB->u[texUnit], PB->lambda[texUnit],
- PB->rgba);
+ gl_texture_pixels( ctx, texUnit,
+ PB->count, PB->s[texUnit], PB->t[texUnit],
+ PB->u[texUnit], PB->lambda[texUnit],
+ primary_rgba, PB->rgba );
}
}
if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR
- && ctx->Light.Enabled) {
+ && ctx->Light.Enabled && ctx->Texture.ReallyEnabled) {
/* add specular color to primary color */
add_colors( PB->count, PB->rgba, (const GLubyte (*)[3]) PB->spec );
}
diff --git a/xc/extras/Mesa/src/points.c b/xc/extras/Mesa/src/points.c
index 77d1e0de0..41cd06022 100644
--- a/xc/extras/Mesa/src/points.c
+++ b/xc/extras/Mesa/src/points.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -358,7 +358,7 @@ textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
green = VB->ColorPtr->data[i][1];
blue = VB->ColorPtr->data[i][2];
alpha = VB->ColorPtr->data[i][3];
-
+
switch (VB->TexCoordPtr[0]->size) {
case 4:
s = VB->TexCoordPtr[0]->data[i][0]/VB->TexCoordPtr[0]->data[i][3];
@@ -386,15 +386,13 @@ textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
gl_problem(ctx, "unexpected texcoord size in textured_rgba_points()");
}
-/* don't think this is needed
- PB_SET_COLOR( red, green, blue, alpha );
-*/
-
for (iy = y0; iy <= y1; iy++) {
for (ix = x0; ix <= x1; ix++) {
- PB_WRITE_TEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u );
+ PB_WRITE_TEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha,
+ s, t, u );
}
}
+
PB_CHECK_FLUSH(ctx, PB);
}
}
@@ -417,6 +415,7 @@ multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
GLint ix, iy;
GLint radius;
GLint red, green, blue, alpha;
+ GLint sRed, sGreen, sBlue;
GLfloat s, t, u;
GLfloat s1, t1, u1;
@@ -449,6 +448,9 @@ multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
green = VB->ColorPtr->data[i][1];
blue = VB->ColorPtr->data[i][2];
alpha = VB->ColorPtr->data[i][3];
+ sRed = VB->Specular ? VB->Specular[i][0] : 0;
+ sGreen = VB->Specular ? VB->Specular[i][1] : 0;
+ sBlue = VB->Specular ? VB->Specular[i][2] : 0;
switch (VB->TexCoordPtr[0]->size) {
case 4:
@@ -506,8 +508,10 @@ multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
for (iy=y0;iy<=y1;iy++) {
for (ix=x0;ix<=x1;ix++) {
- PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha,
- s, t, u, s1, t1, u1 );
+ PB_WRITE_MULTITEX_SPEC_PIXEL( PB, ix, iy, z,
+ red, green, blue, alpha,
+ sRed, sGreen, sBlue,
+ s, t, u, s1, t1, u1 );
}
}
PB_CHECK_FLUSH(ctx, PB);
@@ -516,6 +520,17 @@ multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
+/*
+ * NOTES on aa point rasterization:
+ *
+ * Let d = distance of fragment center from vertex.
+ * if d < rmin2 then
+ * fragment has 100% coverage
+ * else if d > rmax2 then
+ * fragment has 0% coverage
+ * else
+ * fragement has % coverage = (d - rmin2) / (rmax2 - rmin2)
+ */
/*
@@ -529,7 +544,7 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
const GLfloat radius = ctx->Point.Size * 0.5F;
const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
const GLfloat rmax = radius + 0.7071F;
- const GLfloat rmin2 = rmin * rmin;
+ const GLfloat rmin2 = MAX2(0.0, rmin * rmin);
const GLfloat rmax2 = rmax * rmax;
const GLfloat cscale = 256.0F / (rmax2 - rmin2);
GLuint i;
@@ -539,13 +554,15 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
if (VB->ClipMask[i] == 0) {
GLint x, y;
GLint red, green, blue, alpha;
- GLfloat s, t, u;
- GLfloat s1, t1, u1;
-
- GLint xmin = (GLint) (VB->Win.data[i][0] - radius);
- GLint xmax = (GLint) (VB->Win.data[i][0] + radius);
- GLint ymin = (GLint) (VB->Win.data[i][1] - radius);
- GLint ymax = (GLint) (VB->Win.data[i][1] + radius);
+ GLfloat s = 0.0F, t = 0.0F, u = 0.0F;
+ GLfloat s1 = 0.0F, t1 = 0.0F, u1 = 0.0F;
+ GLfloat vx = VB->Win.data[i][0];
+ GLfloat vy = VB->Win.data[i][1];
+
+ GLint xmin = (GLint) (vx - radius);
+ GLint xmax = (GLint) (vx + radius);
+ GLint ymin = (GLint) (vy - radius);
+ GLint ymax = (GLint) (vy + radius);
GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
red = VB->ColorPtr->data[i][0];
@@ -616,15 +633,19 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
}
- for (y=ymin;y<=ymax;y++) {
- for (x=xmin;x<=xmax;x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx*dx + dy*dy;
- if (dist2<rmax2) {
+ /* translate by a half pixel to simplify math below */
+ vx -= 0.5F;
+ vx -= 0.5F;
+
+ for (y = ymin; y <= ymax; y++) {
+ for (x = xmin; x <= xmax; x++) {
+ const GLfloat dx = x - vx;
+ const GLfloat dy = y - vy;
+ const GLfloat dist2 = dx*dx + dy*dy;
+ if (dist2 < rmax2) {
alpha = VB->ColorPtr->data[i][3];
- if (dist2>=rmin2) {
- GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale);
+ if (dist2 >= rmin2) {
+ GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
/* coverage is in [0,256] */
alpha = (alpha * coverage) >> 8;
}
@@ -651,25 +672,29 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
GLint x, y, z;
GLint red, green, blue, alpha;
- xmin = (GLint) (VB->Win.data[i][0] - radius);
- xmax = (GLint) (VB->Win.data[i][0] + radius);
- ymin = (GLint) (VB->Win.data[i][1] - radius);
- ymax = (GLint) (VB->Win.data[i][1] + radius);
+ xmin = (GLint) (VB->Win.data[i][0] - 0.0 - radius);
+ xmax = (GLint) (VB->Win.data[i][0] - 0.0 + radius);
+ ymin = (GLint) (VB->Win.data[i][1] - 0.0 - radius);
+ ymax = (GLint) (VB->Win.data[i][1] - 0.0 + radius);
z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
red = VB->ColorPtr->data[i][0];
green = VB->ColorPtr->data[i][1];
blue = VB->ColorPtr->data[i][2];
- for (y=ymin;y<=ymax;y++) {
- for (x=xmin;x<=xmax;x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx*dx + dy*dy;
- if (dist2<rmax2) {
+ /*
+ printf("point %g, %g\n", VB->Win.data[i][0], VB->Win.data[i][1]);
+ printf("%d..%d X %d..%d\n", xmin, xmax, ymin, ymax);
+ */
+ for (y = ymin; y <= ymax; y++) {
+ for (x = xmin; x <= xmax; x++) {
+ const GLfloat dx = x + 0.5F - VB->Win.data[i][0];
+ const GLfloat dy = y + 0.5F - VB->Win.data[i][1];
+ const GLfloat dist2 = dx*dx + dy*dy;
+ if (dist2 < rmax2) {
alpha = VB->ColorPtr->data[i][3];
- if (dist2>=rmin2) {
- GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale);
+ if (dist2 >= rmin2) {
+ GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
/* coverage is in [0,256] */
alpha = (alpha * coverage) >> 8;
}
@@ -936,8 +961,8 @@ dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
GLint ix, iy;
GLint isize, radius;
GLint red, green, blue, alpha;
- GLfloat s, t, u;
- GLfloat s1, t1, u1;
+ GLfloat s = 0.0F, t = 0.0F, u = 0.0F;
+ GLfloat s1 = 0.0F, t1 = 0.0F, u1 = 0.0F;
GLint x = (GLint) VB->Win.data[i][0];
GLint y = (GLint) VB->Win.data[i][1];
@@ -1084,8 +1109,8 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
GLint xmin, ymin, xmax, ymax;
GLint x, y, z;
GLint red, green, blue, alpha;
- GLfloat s, t, u;
- GLfloat s1, t1, u1;
+ GLfloat s = 0.0F, t = 0.0F, u = 0.0F;
+ GLfloat s1 = 0.0F, t1 = 0.0F, u1 = 0.0F;
GLfloat dsize = psize * dist[i];
if (dsize >= ctx->Point.Threshold) {
@@ -1099,9 +1124,9 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
rmax = radius + 0.7071F;
- rmin2 = rmin*rmin;
- rmax2 = rmax*rmax;
- cscale = 256.0F / (rmax2-rmin2);
+ rmin2 = MAX2(0.0, rmin * rmin);
+ rmax2 = rmax * rmax;
+ cscale = 256.0F / (rmax2 - rmin2);
xmin = (GLint) (VB->Win.data[i][0] - radius);
xmax = (GLint) (VB->Win.data[i][0] + radius);
@@ -1179,9 +1204,9 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
for (y = ymin; y <= ymax; y++) {
for (x = xmin; x <= xmax; x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx*dx + dy*dy;
+ const GLfloat dx = x + 0.5F - VB->Win.data[i][0];
+ const GLfloat dy = y + 0.5F - VB->Win.data[i][1];
+ const GLfloat dist2 = dx*dx + dy*dy;
if (dist2 < rmax2) {
alpha = VB->ColorPtr->data[i][3];
if (dist2 >= rmin2) {
@@ -1225,7 +1250,7 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
rmax = radius + 0.7071F;
- rmin2 = rmin * rmin;
+ rmin2 = MAX2(0.0, rmin * rmin);
rmax2 = rmax * rmax;
cscale = 256.0F / (rmax2 - rmin2);
@@ -1241,9 +1266,9 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
for (y = ymin; y <= ymax; y++) {
for (x = xmin; x <= xmax; x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx * dx + dy * dy;
+ const GLfloat dx = x + 0.5F - VB->Win.data[i][0];
+ const GLfloat dy = y + 0.5F - VB->Win.data[i][1];
+ const GLfloat dist2 = dx * dx + dy * dy;
if (dist2 < rmax2) {
alpha = VB->ColorPtr->data[i][3];
if (dist2 >= rmin2) {
@@ -1324,7 +1349,8 @@ void gl_set_point_function( GLcontext *ctx )
ctx->Driver.PointsFunc = antialiased_rgba_points;
}
else if (ctx->Texture.ReallyEnabled) {
- if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
+ if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D ||
+ ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
ctx->Driver.PointsFunc = multitextured_rgba_points;
}
else {
diff --git a/xc/extras/Mesa/src/readpix.c b/xc/extras/Mesa/src/readpix.c
index 4f4ad90a3..f2520b6af 100644
--- a/xc/extras/Mesa/src/readpix.c
+++ b/xc/extras/Mesa/src/readpix.c
@@ -638,7 +638,8 @@ static void read_rgba_pixels( GLcontext *ctx,
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type) ||
+ format == GL_INTENSITY) {
gl_error(ctx, GL_INVALID_OPERATION, "glReadPixels(format or type)");
return;
}
diff --git a/xc/extras/Mesa/src/rect.c b/xc/extras/Mesa/src/rect.c
index 4acaf6770..502498c01 100644
--- a/xc/extras/Mesa/src/rect.c
+++ b/xc/extras/Mesa/src/rect.c
@@ -43,13 +43,6 @@
void
_mesa_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
- /*
- * TODO: we could examine a bunch of state variables and ultimately
- * call the Driver->RectFunc() function to draw a screen-aligned
- * filled rectangle. Someday...
- *
- * KW: What happens to cull mode here?
- */
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx, "glRect");
RESET_IMMEDIATE(ctx);
@@ -59,6 +52,16 @@ _mesa_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
gl_Vertex2f( ctx, x2, y2 );
gl_Vertex2f( ctx, x1, y2 );
gl_End( ctx );
+
+ /* If compiling, flush these vertices so that they aren't saved
+ * by the normal vertex compilation methods.
+ */
+ if (ctx->CompileFlag)
+ {
+ ctx->CompileFlag = 0;
+ ctx->input->maybe_transform_vb( ctx->input );
+ ctx->CompileFlag = GL_TRUE;
+ }
}
diff --git a/xc/extras/Mesa/src/render_tmp.h b/xc/extras/Mesa/src/render_tmp.h
index 572a06c8c..bcc60d42b 100644
--- a/xc/extras/Mesa/src/render_tmp.h
+++ b/xc/extras/Mesa/src/render_tmp.h
@@ -210,13 +210,15 @@ static void TAG(render_vb_poly)( struct vertex_buffer *VB,
RENDER_TRI( start, j-1, j, start, 0 );
EDGEFLAG_POLY_TRI_POST( start, j-1, j, start );
}
+ if (VB->Flag[count] & VERT_END) {
+ RESET_STIPPLE;
+ }
}
else {
for (j=start+2;j<count;j++) {
RENDER_TRI( start, j-1, j, start, 0 );
}
}
- RESET_STIPPLE;
POSTFIX;
}
diff --git a/xc/extras/Mesa/src/shade.c b/xc/extras/Mesa/src/shade.c
index 97ddf37ac..5fa94258a 100644
--- a/xc/extras/Mesa/src/shade.c
+++ b/xc/extras/Mesa/src/shade.c
@@ -39,29 +39,39 @@
#endif
+/* Lerp between adjacent values in the f(x) lookup table, giving a
+ * continuous function, with adequeate overall accuracy. (Though
+ * still pretty good compared to a straight lookup).
+ */
+#define GET_SHINE_TAB_ENTRY( table, dp, result ) \
+do { \
+ struct gl_shine_tab *_tab = table; \
+ if (dp>1.0) \
+ result = pow( dp, _tab->shininess ); \
+ else { \
+ float f = (dp * (SHINE_TABLE_SIZE-1)); \
+ int k = (int) f; \
+ result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
+ } \
+} while (0)
-#define GET_SHINE_TAB_ENTRY( tab, dp, result ) \
-do { \
- int k = (int) (dp * SHINE_TABLE_SIZE); \
- result = tab->tab[k]; \
-} while(0)
-
-
/* Combinatorics:
- * rgba_spec/rgba/rgba_fast/ci
+ * rgba_spec/rgba/rgba_fast/rgba_fast_single/ci
* one_side/two_side
* compacted_normals/ordinary_normals
* cull_mask/no_cull_mask
- *
- * We end up with an award-winning 32 seperate lighting functions.
*/
/* Table of all the shading functions.
*/
-gl_shade_func gl_shade_func_tab[0x20];
+gl_shade_func gl_shade_tab[0x10];
+gl_shade_func gl_shade_fast_tab[0x10];
+gl_shade_func gl_shade_fast_single_tab[0x10];
+gl_shade_func gl_shade_spec_tab[0x10];
+gl_shade_func gl_shade_ci_tab[0x10];
/* The original case where the normal for vertex[j] is normal[j],
@@ -190,28 +200,32 @@ void gl_init_shade( void )
void gl_update_lighting_function( GLcontext *ctx )
{
- GLuint idx;
+ gl_shade_func *tab;
if (ctx->Visual->RGBAflag) {
if (ctx->Light.NeedVertices) {
if (ctx->Texture.Enabled &&
ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
- idx = SHADE_RGBA_SPEC;
+ tab = gl_shade_spec_tab;
else
- idx = SHADE_RGBA_VERTICES;
+ tab = gl_shade_tab;
}
- else
- idx = SHADE_RGBA_NORMALS;
+ else {
+ if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev &&
+ !ctx->Light.ColorMaterialEnabled)
+ tab = gl_shade_fast_single_tab;
+ else
+ tab = gl_shade_fast_tab;
+ }
}
else
- idx = 0;
+ tab = gl_shade_ci_tab;
if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
- idx |= SHADE_TWOSIDE;
+ tab += SHADE_TWOSIDE;
}
-
- ctx->shade_func_flags = idx;
+ ctx->shade_func_tab = tab;
}
@@ -326,13 +340,7 @@ void gl_shade_rastpos( GLcontext *ctx,
shininess *= .5;
}
- if (n_dot_h>1.0) {
- spec_coef = (GLfloat) pow( n_dot_h, shininess );
- }
- else {
- struct gl_shine_tab *tab = ctx->ShineTable[0];
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
- }
+ GET_SHINE_TAB_ENTRY( ctx->ShineTable[0], n_dot_h, spec_coef );
if (spec_coef > 1.0e-10) {
ACC_SCALE_SCALAR_3V( contrib, spec_coef,
diff --git a/xc/extras/Mesa/src/shade_tmp.h b/xc/extras/Mesa/src/shade_tmp.h
index 189a91d4f..f6ec08cb7 100644
--- a/xc/extras/Mesa/src/shade_tmp.h
+++ b/xc/extras/Mesa/src/shade_tmp.h
@@ -1,9 +1,9 @@
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2000 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"),
@@ -38,8 +38,6 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
GLuint vstride = VB->Unprojected->stride;
const GLfloat *vertex = VB->Unprojected->start;
- GLuint vertex_size = VB->Unprojected->size;
-
GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = VB->NormalPtr->start;
CONST GLfloat (*first_normal)[3] = (CONST GLfloat (*)[3]) VB->NormalPtr->start;
@@ -82,8 +80,7 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
VB->Specular = VB->Spec[0];
- for ( j=0 ; j<nr ; j++,STRIDE_F(vertex,vstride),NEXT_VERTEX_NORMAL)
- {
+ for ( j=0 ; j<nr ; j++,STRIDE_F(vertex,vstride),NEXT_VERTEX_NORMAL) {
GLfloat sum[2][3], spec[2][3];
struct gl_light *light;
@@ -127,12 +124,7 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
else {
GLfloat d; /* distance from vertex to light */
- if (vertex_size == 2) {
- SUB_2V(VP, light->Position, vertex);
- VP[2] = light->Position[2];
- } else {
- SUB_3V(VP, light->Position, vertex);
- }
+ SUB_3V(VP, light->Position, vertex);
d = (GLfloat) LEN_3FV( VP );
@@ -146,8 +138,7 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
light->QuadraticAttenuation));
/* spotlight attenuation */
- if (light->Flags & LIGHT_SPOT)
- {
+ if (light->Flags & LIGHT_SPOT) {
GLfloat PV_dot_dir = - DOT3(VP, light->NormDirection);
if (PV_dot_dir<light->CosCutoff) {
@@ -181,7 +172,8 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
side = 1;
correction = -1;
n_dot_VP = -n_dot_VP;
- } else {
+ }
+ else {
if (LIGHT_REAR(*mask)) {
ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->MatAmbient[1]);
}
@@ -204,7 +196,6 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
if (ctx->Light.Model.LocalViewer) {
GLfloat v[3];
COPY_3V(v, vertex);
- if (vertex_size == 2) v[2] = 0;
NORMALIZE_3FV(v);
SUB_3V(VP, VP, v); /* h = VP + VPe */
h = VP;
@@ -214,15 +205,15 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
h = VP;
ACC_3V(h, ctx->EyeZDir);
normalized = 0;
- } else {
+ }
+ else {
h = light->h_inf_norm;
normalized = 1;
}
n_dot_h = correction * DOT3(normal, h);
- if (n_dot_h > 0.0F)
- {
+ if (n_dot_h > 0.0F) {
GLfloat spec_coef;
struct gl_shine_tab *tab = ctx->ShineTable[side];
@@ -232,11 +223,8 @@ static void TAG(shade_rgba_spec)( struct vertex_buffer *VB )
tab = ctx->ShineTable[side+2];
}
- if (n_dot_h>1.0) {
- spec_coef = (GLfloat) pow( n_dot_h, tab->shininess );
- } else
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
-
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
+
if (spec_coef > 1.0e-10) {
spec_coef *= attenuation;
ACC_SCALE_SCALAR_3V( spec[side], spec_coef,
@@ -276,8 +264,6 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
GLuint vstride = VB->Unprojected->stride;
const GLfloat *vertex = (GLfloat *)VB->Unprojected->start;
- GLuint vertex_size = VB->Unprojected->size;
-
GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = VB->NormalPtr->start;
CONST GLfloat (*first_normal)[3] = (CONST GLfloat (*)[3])VB->NormalPtr->start;
@@ -312,8 +298,7 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
VB->Color[0] = VB->LitColor[0];
VB->Color[1] = VB->LitColor[1];
- for ( j=0 ; j<nr ; j++,STRIDE_F(vertex,vstride),NEXT_VERTEX_NORMAL)
- {
+ for ( j=0 ; j<nr ; j++,STRIDE_F(vertex,vstride),NEXT_VERTEX_NORMAL) {
GLfloat sum[2][3];
struct gl_light *light;
@@ -354,13 +339,7 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
GLfloat d; /* distance from vertex to light */
- /* KW: fix me */
- if (vertex_size == 2) {
- SUB_2V(VP, light->Position, vertex);
- VP[2] = light->Position[2];
- } else {
- SUB_3V(VP, light->Position, vertex);
- }
+ SUB_3V(VP, light->Position, vertex);
d = LEN_3FV( VP );
@@ -368,14 +347,13 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
GLfloat invd = 1.0F / d;
SELF_SCALE_SCALAR_3V(VP, invd);
}
-/* if (light->Flags & LIGHT_ATTENUATED) */
- attenuation = 1.0F / (light->ConstantAttenuation + d *
- (light->LinearAttenuation + d *
- light->QuadraticAttenuation));
+
+ attenuation = 1.0F / (light->ConstantAttenuation + d *
+ (light->LinearAttenuation + d *
+ light->QuadraticAttenuation));
/* spotlight attenuation */
- if (light->Flags & LIGHT_SPOT)
- {
+ if (light->Flags & LIGHT_SPOT) {
GLfloat PV_dot_dir = - DOT3(VP, light->NormDirection);
if (PV_dot_dir<light->CosCutoff) {
@@ -410,7 +388,8 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
side = 1;
correction = -1;
n_dot_VP = -n_dot_VP;
- } else {
+ }
+ else {
if (LIGHT_REAR(*mask)) {
ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->MatAmbient[1]);
}
@@ -426,12 +405,10 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->MatDiffuse[side]);
/* specular term - cannibalize VP... */
- if (light->IsMatSpecular[side])
- {
+ if (light->IsMatSpecular[side]) {
if (ctx->Light.Model.LocalViewer) {
GLfloat v[3];
COPY_3V(v, vertex);
- if (vertex_size == 2) v[2] = 0;
NORMALIZE_3FV(v);
SUB_3V(VP, VP, v); /* h = VP + VPe */
h = VP;
@@ -441,7 +418,8 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
h = VP;
ACC_3V(h, ctx->EyeZDir);
normalized = 0;
- } else {
+ }
+ else {
h = light->h_inf_norm;
normalized = 1;
}
@@ -459,11 +437,7 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
tab = ctx->ShineTable[side+2];
}
- if (n_dot_h>1.0) {
- spec_coef = pow( n_dot_h, tab->shininess );
- } else {
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
- }
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
ACC_SCALE_SCALAR_3V( contrib, spec_coef,
light->MatSpecular[side]);
@@ -494,12 +468,129 @@ static void TAG(shade_rgba)( struct vertex_buffer *VB )
+/* As below, but with just a single light and no colormaterial.
+ */
+static void TAG(shade_fast_rgba_single)( struct vertex_buffer *VB )
+{
+ GLcontext *ctx = VB->ctx;
+ GLuint nstride = VB->NormalPtr->stride;
+ const GLfloat *normal = VB->NormalPtr->start;
+ CONST GLfloat (*first_normal)[3] =
+ (CONST GLfloat (*)[3])VB->NormalPtr->start;
+ GLubyte (*Fcolor)[4] = (GLubyte (*)[4])VB->LitColor[0]->start;
+ GLubyte (*Bcolor)[4] = (GLubyte (*)[4])VB->LitColor[1]->start;
+ GLubyte *mask = VB->NormCullStart;
+ struct gl_light *light = ctx->Light.EnabledList.next;
+ GLubyte *cullmask = mask;
+ GLuint *flags = VB->Flag + VB->Start;
+ GLubyte baseubyte[2][4];
+ GLuint j = 0;
+ struct gl_material (*new_material)[2] = VB->Material + VB->Start;
+ GLuint *new_material_mask = VB->MaterialMask + VB->Start;
+ GLfloat base[2][3];
+
+ (void) cullmask;
+ (void) first_normal;
+ (void) nstride;
+
+ if ( flags[j] & VERT_MATERIAL )
+ gl_update_material( ctx, new_material[j], new_material_mask[j] );
+
+ /* No attenuation, so incoporate MatAmbient into base color.
+ */
+ {
+ COPY_3V(base[0], light->MatAmbient[0]);
+ ACC_3V(base[0], ctx->Light.BaseColor[0] );
+ FLOAT_RGB_TO_UBYTE_RGB( baseubyte[0], base[0] );
+ baseubyte[0][3] = ctx->Light.BaseAlpha[0];
+
+ if (NR_SIDES == 2) {
+ COPY_3V(base[1], light->MatAmbient[1]);
+ ACC_3V(base[1], ctx->Light.BaseColor[1]);
+ FLOAT_RGB_TO_UBYTE_RGB( baseubyte[1], base[1]);
+ baseubyte[1][3] = ctx->Light.BaseAlpha[1];
+ }
+ }
+
+ VB->ColorPtr = VB->LitColor[0];
+ VB->Color[0] = VB->LitColor[0];
+ VB->Color[1] = VB->LitColor[1];
+
+ do {
+ do {
+ if ( !CULL(*mask) ) {
+ GLfloat n_dot_VP = DOT3(normal, light->VP_inf_norm);
+
+ COPY_4UBV(Fcolor[j], baseubyte[0]);
+ if (NR_SIDES == 2) COPY_4UBV(Bcolor[j], baseubyte[1]);
+
+ if (n_dot_VP < 0.0F) {
+ if (LIGHT_REAR(*mask)) {
+ GLfloat n_dot_h = -DOT3(normal, light->h_inf_norm);
+ if (n_dot_h > 0.0F) {
+ GLfloat spec, sum[3];
+ GET_SHINE_TAB_ENTRY( ctx->ShineTable[1], n_dot_h, spec );
+ COPY_3V(sum, base[1]);
+ ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->MatDiffuse[1]);
+ ACC_SCALE_SCALAR_3V(sum, spec, light->MatSpecular[1]);
+ FLOAT_RGB_TO_UBYTE_RGB(Bcolor[j], sum );
+ }
+ }
+ } else {
+ if (LIGHT_FRONT(*mask)) {
+ GLfloat n_dot_h = DOT3(normal, light->h_inf_norm);
+ if (n_dot_h > 0.0F) {
+ GLfloat spec, sum[3];
+ GET_SHINE_TAB_ENTRY( ctx->ShineTable[0], n_dot_h, spec );
+ COPY_3V(sum, base[0]);
+ ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->MatDiffuse[0]);
+ ACC_SCALE_SCALAR_3V(sum, spec, light->MatSpecular[0]);
+ FLOAT_RGB_TO_UBYTE_RGB(Fcolor[j], sum );
+ }
+ }
+ }
+ }
+ j++;
+ NEXT_NORMAL;
+ } while ((flags[j] & (VERT_MATERIAL|VERT_END_VB|VERT_NORM)) == VERT_NORM);
+
+
+ if (COMPACTED) {
+ GLuint last = j-1;
+ for ( ; !(flags[j] & (VERT_MATERIAL|VERT_END_VB|VERT_NORM)) ; j++ ) {
+ COPY_4UBV(Fcolor[j], Fcolor[last]);
+ if (NR_SIDES==2)
+ COPY_4UBV(Bcolor[j], Bcolor[last]);
+ }
+ NEXT_NORMAL;
+ }
+
+ /* Have to recompute our base colors on material change.
+ */
+ if ( flags[j] & VERT_MATERIAL ) {
+ gl_update_material( ctx, new_material[j], new_material_mask[j] );
+
+ COPY_3V(base[0], light->MatAmbient[0]);
+ ACC_3V(base[0], ctx->Light.BaseColor[0] );
+ FLOAT_RGB_TO_UBYTE_RGB( baseubyte[0], base[0] );
+
+ if (NR_SIDES == 2) {
+ COPY_3V(base[1], light->MatAmbient[1]);
+ ACC_3V(base[1], ctx->Light.BaseColor[1]);
+ FLOAT_RGB_TO_UBYTE_RGB( baseubyte[1], base[1]);
+ }
+ }
+
+ } while (!(flags[j] & VERT_END_VB));
+}
+
+
/* Vertex size doesn't matter - yay!
*/
static void TAG(shade_fast_rgba)( struct vertex_buffer *VB )
{
GLcontext *ctx = VB->ctx;
- GLfloat (*base)[3] = ctx->Light.BaseColor;
+ GLfloat base[2][3];
GLubyte *sumA = ctx->Light.BaseAlpha;
GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = VB->NormalPtr->start;
@@ -515,6 +606,7 @@ static void TAG(shade_fast_rgba)( struct vertex_buffer *VB )
GLuint j = 0;
struct gl_material (*new_material)[2] = VB->Material + VB->Start;
GLuint *new_material_mask = VB->MaterialMask + VB->Start;
+ struct gl_light *light;
(void) cullmask;
(void) first_normal;
@@ -534,19 +626,20 @@ static void TAG(shade_fast_rgba)( struct vertex_buffer *VB )
}
+ if ( flags[j] & VERT_MATERIAL )
+ gl_update_material( ctx, new_material[j], new_material_mask[j] );
+
+ COPY_3V(base[0], ctx->Light.BaseColor[0]);
+ if (NR_SIDES == 2) COPY_3V(base[1], ctx->Light.BaseColor[1]);
+
interesting = cm_flags | VERT_MATERIAL | VERT_END_VB | VERT_NORM;
VB->ColorPtr = VB->LitColor[0];
VB->Color[0] = VB->LitColor[0];
VB->Color[1] = VB->LitColor[1];
- if ( flags[j] & VERT_MATERIAL )
- gl_update_material( ctx, new_material[j], new_material_mask[j] );
-
do {
do {
- if ( !CULL(*mask) )
- {
- struct gl_light *light;
+ if ( !CULL(*mask) ) {
GLfloat sum[2][3];
GLfloat spec;
@@ -563,14 +656,18 @@ static void TAG(shade_fast_rgba)( struct vertex_buffer *VB )
GLfloat n_dot_h;
GLint side = 0;
GLfloat n_dot_VP = DOT3(normal, light->VP_inf_norm);
-
+
+ ACC_3V(sum[0], light->MatAmbient[0]);
+ if (NR_SIDES == 2) ACC_3V(sum[1], light->MatAmbient[1]);
+
if (n_dot_VP < 0.0F) {
if ( !LIGHT_REAR(*mask) ) continue;
ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->MatDiffuse[1]);
if (!light->IsMatSpecular[1]) continue;
n_dot_h = -DOT3(normal, light->h_inf_norm);
side = 1;
- } else {
+ }
+ else {
if ( !LIGHT_FRONT(*mask) ) continue;
ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->MatDiffuse[0]);
if (!light->IsMatSpecular[0]) continue;
@@ -579,11 +676,7 @@ static void TAG(shade_fast_rgba)( struct vertex_buffer *VB )
if (n_dot_h > 0.0F) {
struct gl_shine_tab *tab = ctx->ShineTable[side];
- if (n_dot_h > 1.0)
- spec = pow( n_dot_h, tab->shininess );
- else
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
-
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
ACC_SCALE_SCALAR_3V( sum[side], spec,
light->MatSpecular[side]);
}
@@ -646,8 +739,6 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
GLcontext *ctx = VB->ctx;
GLuint vstride = VB->Unprojected->stride;
const GLfloat *vertex = (GLfloat *)VB->Unprojected->start;
- GLuint vertex_size = VB->Unprojected->size;
-
GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = VB->NormalPtr->start;
CONST GLfloat (*first_normal)[3] = (CONST GLfloat (*)[3])VB->NormalPtr->start;
@@ -686,8 +777,7 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
CMcolor = (GLubyte (*)[4])VB->ColorPtr->start;
}
- for ( j=0 ; j<nr ; j++,STRIDE_F(vertex,vstride),NEXT_VERTEX_NORMAL)
- {
+ for ( j=0 ; j<nr ; j++,STRIDE_F(vertex,vstride),NEXT_VERTEX_NORMAL) {
GLfloat diffuse[2], specular[2];
GLuint side = 0;
struct gl_light *light;
@@ -724,12 +814,7 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
else {
GLfloat d; /* distance from vertex to light */
- if (vertex_size == 2) {
- SUB_2V(VP, light->Position, vertex);
- VP[2] = light->Position[2];
- } else {
- SUB_3V(VP, light->Position, vertex);
- }
+ SUB_3V(VP, light->Position, vertex);
d = LEN_3FV( VP );
if ( d > 1e-6) {
@@ -742,8 +827,7 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
light->QuadraticAttenuation));
/* spotlight attenuation */
- if (light->Flags & LIGHT_SPOT)
- {
+ if (light->Flags & LIGHT_SPOT) {
GLfloat PV_dot_dir = - DOT3(VP, light->NormDirection);
if (PV_dot_dir<light->CosCutoff) {
continue; /* this light makes no contribution */
@@ -770,7 +854,8 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
side = 1;
correction = -1;
n_dot_VP = -n_dot_VP;
- } else {
+ }
+ else {
if (!LIGHT_FRONT(*mask))
continue;
}
@@ -785,7 +870,6 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
if (ctx->Light.Model.LocalViewer) {
GLfloat v[3];
COPY_3V(v, vertex);
- if (vertex_size == 2) v[2] = 0;
NORMALIZE_3FV(v);
SUB_3V(VP, VP, v); /* h = VP + VPe */
h = VP;
@@ -795,7 +879,8 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
h = VP;
ACC_3V(h, ctx->EyeZDir);
normalized = 0;
- } else {
+ }
+ else {
h = light->h_inf_norm;
normalized = 1;
}
@@ -813,18 +898,14 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
tab = ctx->ShineTable[side+2];
}
- if (n_dot_h>1.0) {
- spec_coef = pow( n_dot_h, tab->shininess );
- } else {
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef);
- }
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef);
+
specular[side] += spec_coef * light->sli * attenuation;
}
} /*loop over lights*/
/* Now compute final color index */
- for (side = 0 ; side < NR_SIDES ; side++)
- {
+ for (side = 0 ; side < NR_SIDES ; side++) {
GLfloat index;
struct gl_material *mat;
@@ -850,22 +931,22 @@ static void TAG(shade_ci)( struct vertex_buffer *VB )
}
} /*for vertex*/
- if ( flags[j] & cm_flags )
- gl_update_color_material( ctx, CMcolor[j] );
+ if ( flags[j] & cm_flags )
+ gl_update_color_material( ctx, CMcolor[j] );
- if ( flags[j] & VERT_MATERIAL )
- gl_update_material( ctx, new_material[j], new_material_mask[j] );
-
+ if ( flags[j] & VERT_MATERIAL )
+ gl_update_material( ctx, new_material[j], new_material_mask[j] );
}
static void TAG(init_shade_tab)( void )
{
- gl_shade_func_tab[IDX|SHADE_RGBA_VERTICES] = TAG(shade_rgba);
- gl_shade_func_tab[IDX|SHADE_RGBA_NORMALS] = TAG(shade_fast_rgba);
- gl_shade_func_tab[IDX|SHADE_RGBA_SPEC] = TAG(shade_rgba_spec);
- gl_shade_func_tab[IDX] = TAG(shade_ci);
+ gl_shade_tab[IDX] = TAG(shade_rgba);
+ gl_shade_fast_tab[IDX] = TAG(shade_fast_rgba);
+ gl_shade_fast_single_tab[IDX] = TAG(shade_fast_rgba_single);
+ gl_shade_spec_tab[IDX] = TAG(shade_rgba_spec);
+ gl_shade_ci_tab[IDX] = TAG(shade_ci);
}
diff --git a/xc/extras/Mesa/src/span.c b/xc/extras/Mesa/src/span.c
index 598834047..77d2d80b5 100644
--- a/xc/extras/Mesa/src/span.c
+++ b/xc/extras/Mesa/src/span.c
@@ -151,6 +151,8 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n,
_mesa_logicop_ci_span( ctx, n, x, y, indexTmp, mask );
}
if (ctx->Color.SWmasking) {
+ if (ctx->Color.IndexMask == 0)
+ break;
_mesa_mask_index_span( ctx, n, x, y, indexTmp );
}
(*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask );
@@ -241,6 +243,8 @@ void gl_write_index_span( GLcontext *ctx,
_mesa_logicop_ci_span( ctx, n, x, y, index, mask );
}
if (ctx->Color.SWmasking) {
+ if (ctx->Color.IndexMask == 0)
+ return;
_mesa_mask_index_span( ctx, n, x, y, index );
}
@@ -315,10 +319,6 @@ void gl_write_monoindex_span( GLcontext *ctx,
_mesa_logicop_ci_span( ctx, n, x, y, indexes, mask );
}
- if (ctx->Color.SWmasking) {
- _mesa_mask_index_span( ctx, n, x, y, indexes );
- }
-
if (ctx->RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */
multi_write_index_span( ctx, n, x, y, indexes, mask );
@@ -329,6 +329,8 @@ void gl_write_monoindex_span( GLcontext *ctx,
_mesa_logicop_ci_span( ctx, n, x, y, indexes, mask );
}
if (ctx->Color.SWmasking) {
+ if (ctx->Color.IndexMask == 0)
+ return;
_mesa_mask_index_span( ctx, n, x, y, indexes );
}
(*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexes, mask );
@@ -399,6 +401,8 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n,
_mesa_blend_span( ctx, n, x, y, rgbaTmp, mask );
}
if (ctx->Color.SWmasking) {
+ if (*((GLuint *) ctx->Color.ColorMask) == 0)
+ break;
_mesa_mask_rgba_span( ctx, n, x, y, rgbaTmp );
}
@@ -499,9 +503,7 @@ void gl_write_rgba_span( GLcontext *ctx,
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
- multi_write_rgba_span( ctx, n, x, y,
- (const GLubyte (*)[4]) rgba,
- write_all ? Null : mask );
+ multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask );
}
else {
/* normal: write to exactly one buffer */
@@ -515,6 +517,8 @@ void gl_write_rgba_span( GLcontext *ctx,
/* Color component masking */
if (ctx->Color.SWmasking) {
+ if (*((GLuint *) ctx->Color.ColorMask) == 0)
+ return;
_mesa_mask_rgba_span( ctx, n, x, y, rgba );
}
@@ -616,8 +620,8 @@ void gl_write_monocolor_span( GLcontext *ctx,
return;
}
- if (ctx->Color.BlendEnabled || ctx->Color.SWLogicOpEnabled
- || ctx->Color.SWmasking) {
+ if (ctx->Color.SWLogicOpEnabled || ctx->Color.SWmasking ||
+ (ctx->RasterMask & (BLEND_BIT | FOG_BIT))) {
/* assign same color to each pixel */
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -625,9 +629,15 @@ void gl_write_monocolor_span( GLcontext *ctx,
}
}
+ /* Per-pixel fog */
+ if (ctx->Fog.Enabled &&
+ (primitive==GL_BITMAP || ctx->FogMode==FOG_FRAGMENT)) {
+ _mesa_fog_rgba_pixels( ctx, n, z, rgba );
+ }
+
if (ctx->RasterMask & MULTI_DRAW_BIT) {
- multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba,
- mask );
+ multi_write_rgba_span( ctx, n, x, y,
+ (const GLubyte (*)[4]) rgba, mask );
}
else {
/* normal: write to exactly one buffer */
@@ -640,6 +650,8 @@ void gl_write_monocolor_span( GLcontext *ctx,
/* Color component masking */
if (ctx->Color.SWmasking) {
+ if (*((GLuint *) ctx->Color.ColorMask) == 0)
+ return;
_mesa_mask_rgba_span( ctx, n, x, y, rgba );
}
@@ -667,8 +679,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
}
}
multi_write_rgba_span( ctx, n, x, y,
- (const GLubyte (*)[4]) rgba,
- mask );
+ (const GLubyte (*)[4]) rgba, mask );
}
else {
(*ctx->Driver.WriteMonoRGBASpan)( ctx, n, x, y, mask );
@@ -748,7 +759,7 @@ void gl_write_texture_span( GLcontext *ctx,
/* Texture */
ASSERT(ctx->Texture.ReallyEnabled);
- gl_texture_pixels( ctx, 0, n, s, t, u, lambda, rgba );
+ gl_texture_pixels( ctx, 0, n, s, t, u, lambda, rgba, rgba );
/* Add base and specular colors */
if (spec && ctx->Light.Enabled
@@ -804,8 +815,7 @@ void gl_write_texture_span( GLcontext *ctx,
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
- multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4])rgba,
- write_all ? Null : mask );
+ multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask );
}
else {
/* normal: write to exactly one buffer */
@@ -816,6 +826,8 @@ void gl_write_texture_span( GLcontext *ctx,
_mesa_blend_span( ctx, n, x, y, rgba, mask );
}
if (ctx->Color.SWmasking) {
+ if (*((GLuint *) ctx->Color.ColorMask) == 0)
+ return;
_mesa_mask_rgba_span( ctx, n, x, y, rgba );
}
@@ -864,7 +876,8 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
}
- if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)) {
+ if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)
+ || texUnits > 1) {
/* must make a copy of the colors since they may be modified */
MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLubyte));
rgba = rgbaBackup;
@@ -876,9 +889,8 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
/* Texture */
ASSERT(ctx->Texture.ReallyEnabled);
ASSERT(texUnits <= MAX_TEXTURE_UNITS);
- for (i=0;i<texUnits;i++) {
- gl_texture_pixels( ctx, i, n, s[i], t[i], u[i], lambda[i], rgba );
- }
+ for (i=0;i<texUnits;i++)
+ gl_texture_pixels( ctx, i, n, s[i], t[i], u[i], lambda[i], rgbaIn, rgba );
/* Add base and specular colors */
if (spec && ctx->Light.Enabled
@@ -934,8 +946,7 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
- multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba,
- write_all ? Null : mask );
+ multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask );
}
else {
/* normal: write to exactly one buffer */
@@ -947,6 +958,8 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
_mesa_blend_span( ctx, n, x, y, rgba, mask );
}
if (ctx->Color.SWmasking) {
+ if (*((GLuint *) ctx->Color.ColorMask) == 0)
+ return;
_mesa_mask_rgba_span( ctx, n, x, y, rgba );
}
diff --git a/xc/extras/Mesa/src/stages.c b/xc/extras/Mesa/src/stages.c
index 43aff42c2..8741b69cf 100644
--- a/xc/extras/Mesa/src/stages.c
+++ b/xc/extras/Mesa/src/stages.c
@@ -185,11 +185,18 @@ static void clean_texcoord( struct vertex_buffer *VB, GLuint i )
tc->stride = 4 * sizeof(GLfloat);
}
+static void clean_unprojected( struct vertex_buffer *VB )
+{
+ (void) Transform( &VB->Eye,
+ &gl_identity_mat,
+ VB->Unprojected,
+ 0,
+ 0);
+ VB->Unprojected = &VB->Eye;
+}
static void clean_clip( struct vertex_buffer *VB )
{
-/* printf("clean clip, stride %d, not writable\n", VB->ClipPtr->stride); */
-
(void) Transform( &VB->Clip,
&gl_identity_mat,
VB->ClipPtr,
@@ -329,7 +336,11 @@ static void do_vertex_pipeline( struct vertex_buffer *VB )
}
if (VB->ClipAndMask) {
+ if (MESA_VERBOSE&VERBOSE_CULL)
+ fprintf(stderr, "Culled in clip\n");
+
VB->Culled = 1;
+ gl_dont_cull_vb( VB );
gl_update_materials(VB);
return;
}
@@ -344,6 +355,7 @@ static void do_vertex_pipeline( struct vertex_buffer *VB )
if (MESA_VERBOSE&VERBOSE_CULL)
fprintf(stderr, "Culled in userclip\n");
+ gl_dont_cull_vb( VB );
gl_update_materials(VB);
return;
}
@@ -436,12 +448,23 @@ static void do_normal_transform( struct vertex_buffer *VB )
static void do_lighting( struct vertex_buffer *VB )
{
- GLubyte flags = (GLubyte) (VB->CullMode & (CULL_MASK_ACTIVE|COMPACTED_NORMALS));
+ GLubyte flags = (GLubyte) (VB->CullMode &
+ (CULL_MASK_ACTIVE|COMPACTED_NORMALS));
if ((flags&CULL_MASK_ACTIVE) && !VB->NormCullStart)
gl_make_normal_cullmask( VB );
- gl_shade_func_tab[VB->ctx->shade_func_flags | flags]( VB );
+ /* Make sure we can talk about elements 0..2 in the vector we are
+ * lighting.
+ */
+ if (VB->Unprojected->size == 2) {
+ if (VB->Unprojected->flags & VEC_WRITABLE)
+ gl_vector4f_clean_elem(VB->Unprojected, VB->Count, 2);
+ else
+ clean_unprojected( VB );
+ }
+
+ VB->ctx->shade_func_tab[flags]( VB );
}
diff --git a/xc/extras/Mesa/src/state.c b/xc/extras/Mesa/src/state.c
index ccf0d9091..3ae304d8d 100644
--- a/xc/extras/Mesa/src/state.c
+++ b/xc/extras/Mesa/src/state.c
@@ -845,17 +845,15 @@ static void update_rasterflags( GLcontext *ctx )
ctx->RasterMask |= MULTI_DRAW_BIT;
ctx->TriangleCaps |= DD_MULTIDRAW;
}
- else if (ctx->Visual->RGBAflag && ctx->Color.ColorMask==0) {
+ else if (ctx->Visual->RGBAflag && *((GLuint *) ctx->Color.ColorMask) == 0) {
/* all RGBA channels disabled */
ctx->RasterMask |= MULTI_DRAW_BIT;
ctx->TriangleCaps |= DD_MULTIDRAW;
- ctx->Color.DrawDestMask = 0;
}
else if (!ctx->Visual->RGBAflag && ctx->Color.IndexMask==0) {
/* all color index bits disabled */
ctx->RasterMask |= MULTI_DRAW_BIT;
ctx->TriangleCaps |= DD_MULTIDRAW;
- ctx->Color.DrawDestMask = 0;
}
}
@@ -1062,11 +1060,6 @@ void gl_update_state( GLcontext *ctx )
ctx->Polygon.OffsetLine ||
ctx->Polygon.OffsetFill)
ctx->TriangleCaps |= DD_TRI_OFFSET;
-
- /* reset Z offsets now */
- ctx->PointZoffset = 0.0;
- ctx->LineZoffset = 0.0;
- ctx->PolygonZoffset = 0.0;
}
}
@@ -1183,14 +1176,13 @@ void gl_update_state( GLcontext *ctx )
ctx->NeedEyeNormals = GL_FALSE;
if (ctx->Light.Enabled) {
- if (ctx->Light.Flags & LIGHT_POSITIONAL) {
- /* Need length for attenuation */
- if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING))
- ctx->NeedEyeCoords = GL_TRUE;
- } else if (ctx->Light.NeedVertices) {
- /* Need angle for spot calculations */
- if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_ANGLE_PRESERVING))
- ctx->NeedEyeCoords = GL_TRUE;
+ if ((ctx->Light.Flags & LIGHT_POSITIONAL) ||
+ ctx->Light.NeedVertices ||
+ !TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING)) {
+ /* Need length for attenuation or need angle for spotlights
+ * or non-uniform scale matrix
+ */
+ ctx->NeedEyeCoords = GL_TRUE;
}
ctx->NeedEyeNormals = ctx->NeedEyeCoords;
}
diff --git a/xc/extras/Mesa/src/texgen_tmp.h b/xc/extras/Mesa/src/texgen_tmp.h
index 0324493cf..c1fa50816 100644
--- a/xc/extras/Mesa/src/texgen_tmp.h
+++ b/xc/extras/Mesa/src/texgen_tmp.h
@@ -290,10 +290,10 @@ static void TAG(texgen_sphere_map)( struct vertex_buffer *VB,
GLfloat (*f)[3], *m;
if (!VB->tmp_f)
- VB->tmp_f = (GLfloat (*)[3])malloc(VB->Size * sizeof(GLfloat) * 3);
+ VB->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3);
if (!VB->tmp_m)
- VB->tmp_m = (GLfloat *)malloc(VB->Size * sizeof(GLfloat));
+ VB->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat));
f = VB->tmp_f;
m = VB->tmp_m;
@@ -349,10 +349,10 @@ static void TAG(texgen)( struct vertex_buffer *VB, GLuint textureUnit )
LOCAL_VARS;
if (!VB->tmp_f)
- VB->tmp_f = (GLfloat (*)[3])malloc(VB->Size * sizeof(GLfloat) * 3);
+ VB->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3);
if (!VB->tmp_m)
- VB->tmp_m = (GLfloat *)malloc(VB->Size * sizeof(GLfloat));
+ VB->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat));
f = VB->tmp_f;
m = VB->tmp_m;
diff --git a/xc/extras/Mesa/src/teximage.c b/xc/extras/Mesa/src/teximage.c
index f5a2047b3..05520e4eb 100644
--- a/xc/extras/Mesa/src/teximage.c
+++ b/xc/extras/Mesa/src/teximage.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -139,21 +139,23 @@ logbase2( int n )
GLint
_mesa_base_tex_format( GLcontext *ctx, GLint format )
{
+ /*
+ * Ask the driver for the base format, if it doesn't
+ * know, it will return -1;
+ */
+ if (ctx->Driver.BaseCompressedTexFormat) {
+ GLint ifmt = (*ctx->Driver.BaseCompressedTexFormat)(ctx, format);
+ if (ifmt >= 0) {
+ return ifmt;
+ }
+ }
switch (format) {
- case GL_COMPRESSED_ALPHA_ARB:
- if (ctx && !ctx->Extensions.HaveTextureCompression)
- return -1;
- /* fall-through */
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA8:
case GL_ALPHA12:
case GL_ALPHA16:
return GL_ALPHA;
- case GL_COMPRESSED_LUMINANCE_ARB:
- if (ctx && !ctx->Extensions.HaveTextureCompression)
- return -1;
- /* fall-through */
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
@@ -161,10 +163,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format )
case GL_LUMINANCE12:
case GL_LUMINANCE16:
return GL_LUMINANCE;
- case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
- if (ctx && !ctx->Extensions.HaveTextureCompression)
- return -1;
- /* fall-through */
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
@@ -174,31 +172,12 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format )
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
return GL_LUMINANCE_ALPHA;
- case GL_COMPRESSED_INTENSITY_ARB:
- if (ctx && !ctx->Extensions.HaveTextureCompression)
- return -1;
- /* fall-through */
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
return GL_INTENSITY;
- case GL_COMPRESSED_RGB_ARB:
- if (ctx && ctx->Extensions.HaveTextureCompression)
- return GL_RGB;
- else
- return -1;
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- if (ctx && ctx->Extensions.HaveTextureCompressionFXT1)
- return GL_RGB;
- else
- return -1;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- if (ctx && ctx->Extensions.HaveTextureCompressionS3TC)
- return GL_RGB;
- else
- return -1;
case 3:
case GL_RGB:
case GL_R3_G3_B2:
@@ -209,23 +188,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format )
case GL_RGB12:
case GL_RGB16:
return GL_RGB;
- case GL_COMPRESSED_RGBA_ARB:
- if (ctx && ctx->Extensions.HaveTextureCompression)
- return GL_RGBA;
- else
- return -1;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- if (ctx && ctx->Extensions.HaveTextureCompressionFXT1)
- return GL_RGBA;
- else
- return -1;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (ctx && ctx->Extensions.HaveTextureCompressionS3TC)
- return GL_RGBA;
- else
- return -1;
case 4:
case GL_RGBA:
case GL_RGBA2:
@@ -328,25 +290,12 @@ components_in_intformat( GLint format )
* otherwise.
*/
static GLboolean
-is_compressed_format(GLenum internalFormat)
+is_compressed_format(GLcontext *ctx, GLenum internalFormat)
{
- switch (internalFormat) {
- case GL_COMPRESSED_ALPHA_ARB:
- case GL_COMPRESSED_LUMINANCE_ARB:
- case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
- case GL_COMPRESSED_INTENSITY_ARB:
- case GL_COMPRESSED_RGB_ARB:
- case GL_COMPRESSED_RGBA_ARB:
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
+ if (ctx->Driver.IsCompressedFormat) {
+ return (*ctx->Driver.IsCompressedFormat)(ctx, internalFormat);
+ }
+ return GL_FALSE;
}
@@ -511,13 +460,14 @@ _mesa_alloc_texture_image( void )
* Initialize most fields of a gl_texture_image struct.
*/
static void
-init_texture_image( struct gl_texture_image *img,
+init_texture_image( GLcontext *ctx,
+ struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum internalFormat )
{
ASSERT(img);
ASSERT(!img->Data);
- img->Format = (GLenum) _mesa_base_tex_format(NULL, internalFormat);
+ img->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
set_teximage_component_sizes( img );
img->IntFormat = (GLenum) internalFormat;
img->Border = border;
@@ -537,7 +487,7 @@ init_texture_image( struct gl_texture_image *img,
img->Height2 = 1 << img->HeightLog2;
img->Depth2 = 1 << img->DepthLog2;
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
- img->IsCompressed = is_compressed_format(internalFormat);
+ img->IsCompressed = is_compressed_format(ctx, internalFormat);
}
@@ -556,13 +506,26 @@ _mesa_free_texture_image( struct gl_texture_image *teximage )
/*
* Return number of bytes of storage needed to store a compressed texture
- * image.
+ * image. Only the driver knows for sure. If the driver can't help us,
+ * we must return 0.
*/
GLuint
-_mesa_compressed_image_size(GLenum internalFormat,
- GLint width, GLint height, GLint depth)
+_mesa_compressed_image_size(GLcontext *ctx,
+ GLenum internalFormat,
+ GLint numDimensions,
+ GLint width,
+ GLint height,
+ GLint depth)
{
- return 0;
+ if (ctx->Driver.CompressedImageSize) {
+ return (*ctx->Driver.CompressedImageSize)(ctx, internalFormat,
+ numDimensions,
+ width, height, depth);
+ }
+ else {
+ /* Shouldn't this be an internal error of some sort? */
+ return 0;
+ }
}
@@ -878,6 +841,40 @@ make_null_texture( struct gl_texture_image *texImage )
/*
+ * This is called when a proxy texture test fails, we set all the
+ * image members (except DriverData) to zero.
+ */
+static void
+clear_proxy_teximage(struct gl_texture_image *img)
+{
+ ASSERT(img);
+ img->Format = 0;
+ img->IntFormat = 0;
+ img->RedBits = 0;
+ img->GreenBits = 0;
+ img->BlueBits = 0;
+ img->AlphaBits = 0;
+ img->IntensityBits = 0;
+ img->LuminanceBits = 0;
+ img->IndexBits = 0;
+ img->Border = 0;
+ img->Width = 0;
+ img->Height = 0;
+ img->Depth = 0;
+ img->Width2 = 0;
+ img->Height2 = 0;
+ img->Depth2 = 0;
+ img->WidthLog2 = 0;
+ img->HeightLog2 = 0;
+ img->DepthLog2 = 0;
+ img->Data = NULL;
+ img->IsCompressed = 0;
+ img->CompressedSize = 0;
+}
+
+
+
+/*
* Test glTexImage[123]D() parameters for errors.
* Input:
* dimensions - must be 1 or 2 or 3
@@ -999,7 +996,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
return GL_TRUE;
}
- if (!is_compressed_format(internalFormat)) {
+ if (!is_compressed_format(ctx, internalFormat)) {
if (!_mesa_is_legal_format_and_type( format, type )) {
/* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
* is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
@@ -1125,7 +1122,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
}
}
- if (!is_compressed_format(destTex->IntFormat)) {
+ if (!is_compressed_format(ctx, destTex->IntFormat)) {
if (!_mesa_is_legal_format_and_type(format, type)) {
char message[100];
sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
@@ -1344,6 +1341,105 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
/*
+ * Turn generic compressed formats into specific compressed format.
+ * Some of the compressed formats we don't support, so we
+ * fall back to the uncompressed format. (See issue 15 of
+ * the GL_ARB_texture_compression specification.)
+ */
+static GLint
+get_specific_compressed_tex_format(GLcontext *ctx,
+ GLint ifmt, GLint numDimensions)
+{
+ char message[100];
+ GLint internalFormat = ifmt;
+
+ if (ctx->Extensions.HaveTextureCompression
+ && ctx->Driver.SpecificCompressedTexFormat) {
+ /*
+ * First, ask the driver for the specific format.
+ */
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ case GL_COMPRESSED_INTENSITY_ARB:
+ case GL_COMPRESSED_RGB_ARB:
+ case GL_COMPRESSED_RGBA_ARB:
+ internalFormat = (*ctx->Driver.SpecificCompressedTexFormat)
+ (ctx, internalFormat, numDimensions);
+ /* XXX shouldn't we return now? */
+ break;
+ default:
+ /* silence compiler warnings */
+ ;
+ }
+ }
+
+ /*
+ * Now, convert any generic format left to an uncompressed
+ * specific format. If the driver does not support compression
+ * of the format, we must drop back to the uncompressed format.
+ * See issue 15 of the GL_ARB_texture_compression specification.
+ */
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ if (ctx && !ctx->Extensions.HaveTextureCompression) {
+ sprintf(message, "glTexImage%dD(internalFormat)", numDimensions);
+ gl_error(ctx, GL_INVALID_VALUE, message);
+ return -1;
+ }
+ internalFormat = GL_ALPHA;
+ break;
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ if (ctx && !ctx->Extensions.HaveTextureCompression) {
+ sprintf(message, "glTexImage%dD(internalFormat)", numDimensions);
+ gl_error(ctx, GL_INVALID_VALUE, message);
+ return -1;
+ }
+ internalFormat = GL_LUMINANCE;
+ break;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ if (ctx && !ctx->Extensions.HaveTextureCompression) {
+ sprintf(message, "glTexImage%dD(internalFormat)", numDimensions);
+ gl_error(ctx, GL_INVALID_VALUE, message);
+ return -1;
+ }
+ internalFormat = GL_LUMINANCE_ALPHA;
+ break;
+ case GL_COMPRESSED_INTENSITY_ARB:
+ if (ctx && !ctx->Extensions.HaveTextureCompression) {
+ sprintf(message, "glTexImage%dD(internalFormat)", numDimensions);
+ gl_error(ctx, GL_INVALID_VALUE, message);
+ return -1;
+ }
+ internalFormat = GL_INTENSITY;
+ break;
+ case GL_COMPRESSED_RGB_ARB:
+ if (ctx && !ctx->Extensions.HaveTextureCompression) {
+ sprintf(message, "glTexImage%dD(internalFormat)", numDimensions);
+ gl_error(ctx, GL_INVALID_VALUE, message);
+ return -1;
+ }
+ internalFormat = GL_RGB;
+ break;
+ case GL_COMPRESSED_RGBA_ARB:
+ if (ctx && !ctx->Extensions.HaveTextureCompression) {
+ sprintf(message, "glTexImage%dD(internalFormat)", numDimensions);
+ gl_error(ctx, GL_INVALID_VALUE, message);
+ return -1;
+ }
+ internalFormat = GL_RGBA;
+ break;
+ default:
+ /* silence compiler warning */
+ ;
+ }
+ return internalFormat;
+}
+
+
+
+/*
* Called from the API. Note that width includes the border.
*/
void
@@ -1358,6 +1454,19 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLint ifmt;
+
+ ifmt = get_specific_compressed_tex_format(ctx, internalFormat, 1);
+ if (ifmt < 0) {
+ /*
+ * The error here is that we were sent a generic compressed
+ * format, but the extension is not supported.
+ */
+ return;
+ }
+ else {
+ internalFormat = ifmt;
+ }
if (texture_error_check(ctx, target, level, internalFormat,
format, type, 1, width, 1, 1, border)) {
@@ -1382,7 +1491,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
}
/* setup the teximage struct's fields */
- init_texture_image(texImage, width, 1, 1, border, internalFormat);
+ init_texture_image(ctx, texImage, width, 1, 1, border, internalFormat);
/* process the texture image */
if (pixels) {
@@ -1433,13 +1542,12 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
format, type, 1, width, 1, 1, border)) {
/* if error, clear all proxy texture image parameters */
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
- MEMSET( ctx->Texture.Proxy1D->Image[level], 0,
- sizeof(struct gl_texture_image) );
+ clear_proxy_teximage(ctx->Texture.Proxy1D->Image[level]);
}
}
else {
/* if no error, update proxy texture image parameters */
- init_texture_image(ctx->Texture.Proxy1D->Image[level],
+ init_texture_image(ctx, ctx->Texture.Proxy1D->Image[level],
width, 1, 1, border, internalFormat);
}
}
@@ -1466,6 +1574,19 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLint ifmt;
+
+ ifmt = get_specific_compressed_tex_format(ctx, internalFormat, 2);
+ if (ifmt < 0) {
+ /*
+ * The error here is that we were sent a generic compressed
+ * format, but the extension is not supported.
+ */
+ return;
+ }
+ else {
+ internalFormat = ifmt;
+ }
if (texture_error_check(ctx, target, level, internalFormat,
format, type, 2, width, height, 1, border)) {
@@ -1491,7 +1612,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
}
/* setup the teximage struct's fields */
- init_texture_image(texImage, width, height, 1, border, internalFormat);
+ init_texture_image(ctx, texImage, width, height,
+ 1, border, internalFormat);
/* process the texture image */
if (pixels) {
@@ -1551,13 +1673,13 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
format, type, 2, width, height, 1, border)) {
/* if error, clear all proxy texture image parameters */
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
- MEMSET( ctx->Texture.Proxy2D->Image[level], 0,
- sizeof(struct gl_texture_image) );
+ clear_proxy_teximage(ctx->Texture.Proxy2D->Image[level]);
}
}
else {
/* if no error, update proxy texture image parameters */
- init_texture_image(ctx->Texture.Proxy1D->Image[level],
+ init_texture_image(ctx,
+ ctx->Texture.Proxy2D->Image[level],
width, height, 1, border, internalFormat);
}
}
@@ -1586,6 +1708,20 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLint ifmt;
+
+ ifmt = get_specific_compressed_tex_format(ctx, internalFormat, 3);
+ if (ifmt < 0) {
+ /*
+ * The error here is that we were sent a generic compressed
+ * format, but the extension is not supported.
+ */
+ return;
+ }
+ else {
+ internalFormat = ifmt;
+ }
+
if (texture_error_check(ctx, target, level, internalFormat,
format, type, 3, width, height, depth, border)) {
return; /* error in texture image was detected */
@@ -1609,7 +1745,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
}
/* setup the teximage struct's fields */
- init_texture_image(texImage, width, height, depth,
+ init_texture_image(ctx, texImage, width, height, depth,
border, internalFormat);
/* process the texture image */
@@ -1661,13 +1797,12 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
format, type, 3, width, height, depth, border)) {
/* if error, clear all proxy texture image parameters */
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
- MEMSET( ctx->Texture.Proxy3D->Image[level], 0,
- sizeof(struct gl_texture_image) );
+ clear_proxy_teximage(ctx->Texture.Proxy3D->Image[level]);
}
}
else {
/* if no error, update proxy texture image parameters */
- init_texture_image(ctx->Texture.Proxy1D->Image[level],
+ init_texture_image(ctx, ctx->Texture.Proxy3D->Image[level],
width, height, depth, border, internalFormat);
}
}
@@ -2511,10 +2646,25 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage1DARB");
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ case GL_COMPRESSED_INTENSITY_ARB:
+ case GL_COMPRESSED_RGB_ARB:
+ case GL_COMPRESSED_RGBA_ARB:
+ gl_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB");
+ return;
+ default:
+ /* silence compiler warning */
+ ;
+ }
+
if (target == GL_TEXTURE_1D) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLsizei computedImageSize;
if (texture_error_check(ctx, target, level, internalFormat,
GL_NONE, GL_NONE, 1, width, 1, 1, border)) {
@@ -2539,23 +2689,32 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
}
/* setup the teximage struct's fields */
- init_texture_image(texImage, width, 1, 1, border, internalFormat);
+ init_texture_image(ctx, texImage, width, 1, 1,
+ border, internalFormat);
/* process the texture image */
if (data) {
GLboolean retain = GL_TRUE;
GLboolean success = GL_FALSE;
if (ctx->Driver.CompressedTexImage1D) {
- success = (*ctx->Driver.CompressedTexImage1D)( ctx, target, level,
- data, texObj, texImage, &retain);
+ success = (*ctx->Driver.CompressedTexImage1D)(ctx, target, level,
+ imageSize, data, texObj, texImage, &retain);
}
if (retain || !success) {
/* make internal copy of the texture image */
- GLuint imageSize = _mesa_compressed_image_size(internalFormat,
- width, 1, 1);
- texImage->Data = MALLOC(imageSize);
+ computedImageSize = _mesa_compressed_image_size(ctx,
+ internalFormat,
+ 1, /* num dims */
+ width,
+ 1, /* height */
+ 1); /* depth */
+ if (computedImageSize != imageSize) {
+ gl_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage1DARB(imageSize)");
+ return;
+ }
+ texImage->Data = MALLOC(computedImageSize);
if (texImage->Data) {
- MEMCPY(texImage->Data, data, imageSize);
+ MEMCPY(texImage->Data, data, computedImageSize);
}
}
if (!retain && texImage->Data) {
@@ -2567,8 +2726,9 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
make_null_texture(texImage);
if (ctx->Driver.CompressedTexImage1D) {
GLboolean retain;
- (*ctx->Driver.CompressedTexImage1D)( ctx, target, level,
- texImage->Data, texObj, texImage, &retain);
+ (*ctx->Driver.CompressedTexImage1D)(ctx, target, level, 0,
+ texImage->Data, texObj,
+ texImage, &retain);
}
}
@@ -2582,13 +2742,12 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
GL_NONE, GL_NONE, 1, width, 1, 1, border)) {
/* if error, clear all proxy texture image parameters */
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
- MEMSET( ctx->Texture.Proxy1D->Image[level], 0,
- sizeof(struct gl_texture_image) );
+ clear_proxy_teximage(ctx->Texture.Proxy1D->Image[level]);
}
}
else {
/* if no error, update proxy texture image parameters */
- init_texture_image(ctx->Texture.Proxy1D->Image[level],
+ init_texture_image(ctx, ctx->Texture.Proxy1D->Image[level],
width, 1, 1, border, internalFormat);
}
}
@@ -2608,6 +2767,20 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage2DARB");
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ case GL_COMPRESSED_INTENSITY_ARB:
+ case GL_COMPRESSED_RGB_ARB:
+ case GL_COMPRESSED_RGBA_ARB:
+ gl_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB");
+ return;
+ default:
+ /* silence compiler warning */
+ ;
+ }
+
if (target==GL_TEXTURE_2D ||
(ctx->Extensions.HaveTextureCubeMap &&
target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
@@ -2615,6 +2788,7 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLsizei computedImageSize;
if (texture_error_check(ctx, target, level, internalFormat,
GL_NONE, GL_NONE, 1, width, height, 1, border)) {
@@ -2639,23 +2813,37 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
}
/* setup the teximage struct's fields */
- init_texture_image(texImage, width, height, 1, border, internalFormat);
+ init_texture_image(ctx, texImage, width, height, 1, border, internalFormat);
/* process the texture image */
if (data) {
GLboolean retain = GL_TRUE;
GLboolean success = GL_FALSE;
if (ctx->Driver.CompressedTexImage2D) {
- success = (*ctx->Driver.CompressedTexImage2D)( ctx, target, level,
- data, texObj, texImage, &retain);
+ success = (*ctx->Driver.CompressedTexImage2D)( ctx,
+ target,
+ level,
+ imageSize,
+ data,
+ texObj,
+ texImage,
+ &retain);
}
if (retain || !success) {
/* make internal copy of the texture image */
- GLuint imageSize = _mesa_compressed_image_size(internalFormat,
- width, height, 1);
- texImage->Data = MALLOC(imageSize);
+ computedImageSize = _mesa_compressed_image_size(ctx,
+ internalFormat,
+ 2, /* num dims */
+ width,
+ height,
+ 1); /* depth */
+ if (computedImageSize != imageSize) {
+ gl_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage2DARB(imageSize)");
+ return;
+ }
+ texImage->Data = MALLOC(computedImageSize);
if (texImage->Data) {
- MEMCPY(texImage->Data, data, imageSize);
+ MEMCPY(texImage->Data, data, computedImageSize);
}
}
if (!retain && texImage->Data) {
@@ -2667,8 +2855,9 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
make_null_texture(texImage);
if (ctx->Driver.CompressedTexImage2D) {
GLboolean retain;
- (*ctx->Driver.CompressedTexImage2D)( ctx, target, level,
- texImage->Data, texObj, texImage, &retain);
+ (*ctx->Driver.CompressedTexImage2D)( ctx, target, level, 0,
+ texImage->Data, texObj,
+ texImage, &retain);
}
}
@@ -2682,13 +2871,12 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
GL_NONE, GL_NONE, 1, width, 1, 1, border)) {
/* if error, clear all proxy texture image parameters */
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
- MEMSET( ctx->Texture.Proxy2D->Image[level], 0,
- sizeof(struct gl_texture_image) );
+ clear_proxy_teximage(ctx->Texture.Proxy2D->Image[level]);
}
}
else {
/* if no error, update proxy texture image parameters */
- init_texture_image(ctx->Texture.Proxy2D->Image[level],
+ init_texture_image(ctx, ctx->Texture.Proxy2D->Image[level],
width, 1, 1, border, internalFormat);
}
}
@@ -2708,10 +2896,25 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage3DARB");
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ case GL_COMPRESSED_INTENSITY_ARB:
+ case GL_COMPRESSED_RGB_ARB:
+ case GL_COMPRESSED_RGBA_ARB:
+ gl_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB");
+ return;
+ default:
+ /* silence compiler warning */
+ ;
+ }
+
if (target == GL_TEXTURE_3D) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLsizei computedImageSize;
if (texture_error_check(ctx, target, level, internalFormat,
GL_NONE, GL_NONE, 1, width, height, depth, border)) {
@@ -2736,23 +2939,34 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
}
/* setup the teximage struct's fields */
- init_texture_image(texImage, width, height, depth, border, internalFormat);
+ init_texture_image(ctx, texImage, width, height, depth,
+ border, internalFormat);
/* process the texture image */
if (data) {
GLboolean retain = GL_TRUE;
GLboolean success = GL_FALSE;
if (ctx->Driver.CompressedTexImage3D) {
- success = (*ctx->Driver.CompressedTexImage3D)( ctx, target, level,
- data, texObj, texImage, &retain);
+ success = (*ctx->Driver.CompressedTexImage3D)(ctx, target, level,
+ imageSize, data,
+ texObj, texImage,
+ &retain);
}
if (retain || !success) {
/* make internal copy of the texture image */
- GLuint imageSize = _mesa_compressed_image_size(internalFormat,
- width, height, depth);
- texImage->Data = MALLOC(imageSize);
+ computedImageSize = _mesa_compressed_image_size(ctx,
+ internalFormat,
+ 3, /* num dims */
+ width,
+ height,
+ depth);
+ if (computedImageSize != imageSize) {
+ gl_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage3DARB(imageSize)");
+ return;
+ }
+ texImage->Data = MALLOC(computedImageSize);
if (texImage->Data) {
- MEMCPY(texImage->Data, data, imageSize);
+ MEMCPY(texImage->Data, data, computedImageSize);
}
}
if (!retain && texImage->Data) {
@@ -2764,8 +2978,9 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
make_null_texture(texImage);
if (ctx->Driver.CompressedTexImage3D) {
GLboolean retain;
- (*ctx->Driver.CompressedTexImage3D)( ctx, target, level,
- texImage->Data, texObj, texImage, &retain);
+ (*ctx->Driver.CompressedTexImage3D)( ctx, target, level, 0,
+ texImage->Data, texObj,
+ texImage, &retain);
}
}
@@ -2779,13 +2994,12 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
GL_NONE, GL_NONE, 1, width, height, depth, border)) {
/* if error, clear all proxy texture image parameters */
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
- MEMSET( ctx->Texture.Proxy3D->Image[level], 0,
- sizeof(struct gl_texture_image) );
+ clear_proxy_teximage(ctx->Texture.Proxy3D->Image[level]);
}
}
else {
/* if no error, update proxy texture image parameters */
- init_texture_image(ctx->Texture.Proxy3D->Image[level],
+ init_texture_image(ctx, ctx->Texture.Proxy3D->Image[level],
width, 1, 1, border, internalFormat);
}
}
@@ -2829,7 +3043,6 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
gl_problem(ctx, "glCompressedTexSubImage1DARB failed!");
return;
}
-
}
diff --git a/xc/extras/Mesa/src/teximage.h b/xc/extras/Mesa/src/teximage.h
index b63649eac..98fae39a8 100644
--- a/xc/extras/Mesa/src/teximage.h
+++ b/xc/extras/Mesa/src/teximage.h
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -47,7 +47,9 @@ _mesa_free_texture_image( struct gl_texture_image *teximage );
extern GLuint
-_mesa_compressed_image_size(GLenum internalFormat,
+_mesa_compressed_image_size(GLcontext *ctx,
+ GLenum internalFormat,
+ GLint numDimensions,
GLint width, GLint height, GLint depth);
diff --git a/xc/extras/Mesa/src/texobj.c b/xc/extras/Mesa/src/texobj.c
index e55428408..d7572d86b 100644
--- a/xc/extras/Mesa/src/texobj.c
+++ b/xc/extras/Mesa/src/texobj.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -65,6 +65,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
obj->RefCount = 1;
obj->Name = name;
obj->Dimensions = dimensions;
+ obj->Priority = 1.0F;
obj->WrapS = GL_REPEAT;
obj->WrapT = GL_REPEAT;
obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
@@ -391,11 +392,13 @@ _mesa_GenTextures( GLsizei n, GLuint *texName )
GLint i;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGenTextures");
- if (n<0) {
+ if (n < 0) {
gl_error( ctx, GL_INVALID_VALUE, "glGenTextures" );
return;
}
+ if (!texName)
+ return;
/*
* This must be atomic (generation and allocation of texture IDs)
@@ -432,6 +435,9 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *texName)
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteTextures");
+ if (!texName)
+ return;
+
for (i=0;i<n;i++) {
struct gl_texture_object *t;
if (texName[i]>0) {
@@ -610,19 +616,20 @@ _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
GLint i;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPrioritizeTextures");
- if (n<0) {
+ if (n < 0) {
gl_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" );
return;
}
- for (i=0;i<n;i++) {
- struct gl_texture_object *t;
- if (texName[i]>0) {
- t = (struct gl_texture_object *)
+ if (!priorities)
+ return;
+
+ for (i = 0; i < n; i++) {
+ if (texName[i] > 0) {
+ struct gl_texture_object *t = (struct gl_texture_object *)
_mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
if (t) {
t->Priority = CLAMP( priorities[i], 0.0F, 1.0F );
-
if (ctx->Driver.PrioritizeTexture)
ctx->Driver.PrioritizeTexture( ctx, t, t->Priority );
}
@@ -636,41 +643,47 @@ _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
* Execute glAreTexturesResident
*/
GLboolean
-_mesa_AreTexturesResident( GLsizei n, const GLuint *texName,
- GLboolean *residences )
+_mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
+ GLboolean *residences)
{
GET_CURRENT_CONTEXT(ctx);
- GLboolean resident = GL_TRUE;
+ GLboolean allResident = GL_TRUE;
GLint i;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx,
- "glAreTexturesResident",
- GL_FALSE);
- if (n<0) {
- gl_error( ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)" );
+ "glAreTexturesResident", GL_FALSE);
+ if (n < 0) {
+ gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)");
return GL_FALSE;
}
- for (i=0;i<n;i++) {
+ if (!texName || !residences)
+ return GL_FALSE;
+
+ for (i = 0; i < n; i++) {
struct gl_texture_object *t;
- if (texName[i]==0) {
- gl_error( ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)" );
+ if (texName[i] == 0) {
+ gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
return GL_FALSE;
}
t = (struct gl_texture_object *)
_mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
if (t) {
- if (ctx->Driver.IsTextureResident)
- residences[i] = ctx->Driver.IsTextureResident( ctx, t );
- else
+ if (ctx->Driver.IsTextureResident) {
+ residences[i] = ctx->Driver.IsTextureResident(ctx, t);
+ if (!residences[i])
+ allResident = GL_FALSE;
+ }
+ else {
residences[i] = GL_TRUE;
+ }
}
else {
- gl_error( ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)" );
+ gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
return GL_FALSE;
}
}
- return resident;
+ return allResident;
}
@@ -684,7 +697,7 @@ _mesa_IsTexture( GLuint texture )
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glIsTextures",
GL_FALSE);
- if (texture>0 && _mesa_HashLookup(ctx->Shared->TexObjects, texture)) {
+ if (texture > 0 && _mesa_HashLookup(ctx->Shared->TexObjects, texture)) {
return GL_TRUE;
}
else {
diff --git a/xc/extras/Mesa/src/texstate.c b/xc/extras/Mesa/src/texstate.c
index a51a7f873..8d8a8a20e 100644
--- a/xc/extras/Mesa/src/texstate.c
+++ b/xc/extras/Mesa/src/texstate.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -70,64 +70,284 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv");
if (target==GL_TEXTURE_ENV) {
-
- if (pname==GL_TEXTURE_ENV_MODE) {
- GLenum mode = (GLenum) (GLint) *param;
- switch (mode) {
- case GL_ADD:
- if (!ctx->Extensions.HaveTextureEnvAdd) {
- gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
- return;
- }
- /* FALL-THROUGH */
- case GL_MODULATE:
- case GL_BLEND:
- case GL_DECAL:
- case GL_REPLACE:
- /* A small optimization for drivers */
- if (texUnit->EnvMode == mode)
- return;
-
- if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
- fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
- gl_lookup_enum_by_nr(texUnit->EnvMode),
- gl_lookup_enum_by_nr(mode));
-
- texUnit->EnvMode = mode;
- ctx->NewState |= NEW_TEXTURE_ENV;
- break;
- default:
- gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
- return;
- }
- }
- else if (pname==GL_TEXTURE_ENV_COLOR) {
- texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
- texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
- texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
- texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
- }
- else {
- gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
- return;
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_MODULATE:
+ case GL_BLEND:
+ case GL_DECAL:
+ case GL_REPLACE:
+ case GL_ADD:
+ case GL_COMBINE_EXT:
+ if (mode == GL_ADD &&
+ !ctx->Extensions.HaveTextureEnvAdd) {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+ return;
+ }
+ if (mode == GL_COMBINE_EXT &&
+ !ctx->Extensions.HaveTextureEnvCombine) {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+ return;
+ }
+ if (texUnit->EnvMode == mode)
+ return; /* no change */
+ texUnit->EnvMode = mode;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+ return;
+ }
+ }
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
+ texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
+ texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
+ texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
+ break;
+ case GL_COMBINE_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED_EXT:
+ case GL_INTERPOLATE_EXT:
+ if (texUnit->CombineModeRGB == mode)
+ return; /* no change */
+ texUnit->CombineModeRGB = mode;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_COMBINE_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED_EXT:
+ case GL_INTERPOLATE_EXT:
+ if (texUnit->CombineModeA == mode)
+ return; /* no change */
+ texUnit->CombineModeA = mode;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_SOURCE0_RGB_EXT:
+ case GL_SOURCE1_RGB_EXT:
+ case GL_SOURCE2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum source = (GLenum) (GLint) *param;
+ GLuint s = pname - GL_SOURCE0_RGB_EXT;
+ switch (source) {
+ case GL_TEXTURE:
+ case GL_CONSTANT_EXT:
+ case GL_PRIMARY_COLOR_EXT:
+ case GL_PREVIOUS_EXT:
+ if (texUnit->CombineSourceRGB[s] == source)
+ return; /* no change */
+ texUnit->CombineSourceRGB[s] = source;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_SOURCE0_ALPHA_EXT:
+ case GL_SOURCE1_ALPHA_EXT:
+ case GL_SOURCE2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum source = (GLenum) (GLint) *param;
+ GLuint s = pname - GL_SOURCE0_ALPHA_EXT;
+ switch (source) {
+ case GL_TEXTURE:
+ case GL_CONSTANT_EXT:
+ case GL_PRIMARY_COLOR_EXT:
+ case GL_PREVIOUS_EXT:
+ if (texUnit->CombineSourceA[s] == source) return;
+ texUnit->CombineSourceA[s] = source;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND0_RGB_EXT:
+ case GL_OPERAND1_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum operand = (GLenum) (GLint) *param;
+ GLuint s = pname - GL_OPERAND0_RGB_EXT;
+ switch (operand) {
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ texUnit->CombineOperandRGB[s] = operand;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND0_ALPHA_EXT:
+ case GL_OPERAND1_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum operand = (GLenum) (GLint) *param;
+ switch (operand) {
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ texUnit->CombineOperandA[pname-GL_OPERAND0_ALPHA_EXT]
+ = operand;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if ((GLenum) (GLint) *param == GL_SRC_ALPHA) {
+ texUnit->CombineOperandRGB[2] = (GLenum) (GLint) *param;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if ((GLenum) (GLint) *param == GL_SRC_ALPHA) {
+ texUnit->CombineOperandA[2] = (GLenum) (GLint) *param;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_RGB_SCALE_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (*param == 1.0) {
+ texUnit->CombineScaleShiftRGB = 0;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 2.0) {
+ texUnit->CombineScaleShiftRGB = 1;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 4.0) {
+ texUnit->CombineScaleShiftRGB = 2;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (*param == 1.0) {
+ texUnit->CombineScaleShiftA = 0;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 2.0) {
+ texUnit->CombineScaleShiftA = 1;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 4.0) {
+ texUnit->CombineScaleShiftA = 2;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+ return;
}
-
}
else if (target==GL_TEXTURE_FILTER_CONTROL_EXT) {
-
if (!ctx->Extensions.HaveTextureLodBias) {
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
return;
}
-
- if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
texUnit->LodBias = param[0];
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
return;
}
-
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
@@ -183,7 +403,7 @@ void
_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexEnvfv");
@@ -191,6 +411,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
return;
}
+
switch (pname) {
case GL_TEXTURE_ENV_MODE:
*params = ENUM_TO_FLOAT(texUnit->EnvMode);
@@ -198,6 +419,34 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_TEXTURE_ENV_COLOR:
COPY_4FV( params, texUnit->EnvColor );
break;
+ case GL_RGB_SCALE_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (texUnit->CombineScaleShiftRGB == 0)
+ *params = 1.0;
+ else if (texUnit->CombineScaleShiftRGB == 1)
+ *params = 2.0;
+ else
+ *params = 4.0;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (texUnit->CombineScaleShiftA == 0)
+ *params = 1.0;
+ else if (texUnit->CombineScaleShiftA == 1)
+ *params = 2.0;
+ else
+ *params = 4.0;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ return;
+ }
+ break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
}
@@ -208,14 +457,15 @@ void
_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexEnviv");
- if (target!=GL_TEXTURE_ENV) {
+ if (target != GL_TEXTURE_ENV) {
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
return;
}
+
switch (pname) {
case GL_TEXTURE_ENV_MODE:
*params = (GLint) texUnit->EnvMode;
@@ -225,6 +475,118 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] );
params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
+ break;
+ case GL_COMBINE_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineModeRGB;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_COMBINE_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineModeA;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE0_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceRGB[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE1_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceRGB[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceRGB[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE0_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceA[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE1_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceA[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceA[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND0_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandRGB[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND1_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandRGB[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandRGB[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND0_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandA[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND1_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandA[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandA[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
@@ -608,7 +970,14 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
params[3] = obj->BorderColor[3] / 255.0F;
break;
case GL_TEXTURE_RESIDENT:
- *params = ENUM_TO_FLOAT(GL_TRUE);
+ {
+ GLboolean resident;
+ if (ctx->Driver.IsTextureResident)
+ resident = ctx->Driver.IsTextureResident(ctx, obj);
+ else
+ resident = GL_TRUE;
+ *params = ENUM_TO_FLOAT(resident);
+ }
break;
case GL_TEXTURE_PRIORITY:
*params = obj->Priority;
@@ -676,7 +1045,14 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_TEXTURE_RESIDENT:
- *params = (GLint) GL_TRUE;
+ {
+ GLboolean resident;
+ if (ctx->Driver.IsTextureResident)
+ resident = ctx->Driver.IsTextureResident(ctx, obj);
+ else
+ resident = GL_TRUE;
+ *params = (GLint) resident;
+ }
break;
case GL_TEXTURE_PRIORITY:
*params = (GLint) obj->Priority;
diff --git a/xc/extras/Mesa/src/texture.c b/xc/extras/Mesa/src/texture.c
index 0106ab86b..9d83efd79 100644
--- a/xc/extras/Mesa/src/texture.c
+++ b/xc/extras/Mesa/src/texture.c
@@ -31,6 +31,7 @@
#include "context.h"
#include "macros.h"
#include "mmath.h"
+#include "mem.h"
#include "pb.h"
#include "teximage.h"
#include "texture.h"
@@ -370,6 +371,36 @@ static void palette_sample(const struct gl_texture_object *tObj,
/*
+ * Compute linear mipmap levels for given lambda.
+ */
+#define COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level) \
+{ \
+ if (lambda < 0.0F) \
+ lambda = 0.0F; \
+ else if (lambda > tObj->M) \
+ lambda = tObj->M; \
+ level = (GLint) (tObj->BaseLevel + lambda); \
+}
+
+
+/*
+ * Compute nearest mipmap level for given lambda.
+ */
+#define COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level) \
+{ \
+ if (lambda <= 0.5F) \
+ lambda = 0.0F; \
+ else if (lambda > tObj->M + 0.4999F) \
+ lambda = tObj->M + 0.4999F; \
+ level = (GLint) (tObj->BaseLevel + lambda + 0.5F); \
+ if (level > tObj->P) \
+ level = tObj->P; \
+}
+
+
+
+
+/*
* Bitflags for texture border color sampling.
*/
#define I0BIT 1
@@ -578,14 +609,7 @@ sample_1d_nearest_mipmap_nearest( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda <= 0.5F)
- lambda = 0.0F;
- else if (lambda > tObj->M + 0.4999F)
- lambda = tObj->M + 0.4999F;
- level = (GLint) (tObj->BaseLevel + lambda + 0.5F);
- if (level > tObj->P)
- level = tObj->P;
-
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
sample_1d_nearest( tObj, tObj->Image[level], s, rgba );
}
@@ -596,14 +620,7 @@ sample_1d_linear_mipmap_nearest( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda <= 0.5F)
- lambda = 0.0F;
- else if (lambda > tObj->M + 0.4999F)
- lambda = tObj->M + 0.4999F;
- level = (GLint) (tObj->BaseLevel + lambda + 0.5F);
- if (level > tObj->P)
- level = tObj->P;
-
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
sample_1d_linear( tObj, tObj->Image[level], s, rgba );
}
@@ -615,11 +632,8 @@ sample_1d_nearest_mipmap_linear( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda < 0.0F)
- lambda = 0.0F;
- else if (lambda > tObj->M)
- lambda = tObj->M;
- level = (GLint) (tObj->BaseLevel + lambda);
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_1d_nearest( tObj, tObj->Image[tObj->P], s, rgba );
@@ -644,11 +658,8 @@ sample_1d_linear_mipmap_linear( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda < 0.0F)
- lambda = 0.0F;
- else if (lambda > tObj->M)
- lambda = tObj->M;
- level = (GLint) (tObj->BaseLevel + lambda);
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_1d_linear( tObj, tObj->Image[tObj->P], s, rgba );
@@ -971,14 +982,7 @@ sample_2d_nearest_mipmap_nearest( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda <= 0.5F)
- lambda = 0.0F;
- else if (lambda > tObj->M + 0.4999F)
- lambda = tObj->M + 0.4999F;
- level = (GLint) (tObj->BaseLevel + lambda + 0.5F);
- if (level > tObj->P)
- level = tObj->P;
-
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
sample_2d_nearest( tObj, tObj->Image[level], s, t, rgba );
}
@@ -990,14 +994,7 @@ sample_2d_linear_mipmap_nearest( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda <= 0.5F)
- lambda = 0.0F;
- else if (lambda > tObj->M + 0.4999F)
- lambda = tObj->M + 0.4999F;
- level = (GLint) (tObj->BaseLevel + lambda + 0.5F);
- if (level > tObj->P)
- level = tObj->P;
-
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
sample_2d_linear( tObj, tObj->Image[level], s, t, rgba );
}
@@ -1009,11 +1006,8 @@ sample_2d_nearest_mipmap_linear( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda < 0.0F)
- lambda = 0.0F;
- else if (lambda > tObj->M)
- lambda = tObj->M;
- level = (GLint) (tObj->BaseLevel + lambda);
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_2d_nearest( tObj, tObj->Image[tObj->P], s, t, rgba );
@@ -1038,11 +1032,8 @@ sample_2d_linear_mipmap_linear( const struct gl_texture_object *tObj,
GLubyte rgba[4] )
{
GLint level;
- if (lambda < 0.0F)
- lambda = 0.0F;
- else if (lambda > tObj->M)
- lambda = tObj->M;
- level = (GLint) (tObj->BaseLevel + lambda);
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_2d_linear( tObj, tObj->Image[tObj->P], s, t, rgba );
@@ -1490,14 +1481,7 @@ sample_3d_nearest_mipmap_nearest( const struct gl_texture_object *tObj,
GLfloat lambda, GLubyte rgba[4] )
{
GLint level;
- if (lambda <= 0.5F)
- lambda = 0.0F;
- else if (lambda > tObj->M + 0.4999F)
- lambda = tObj->M + 0.4999F;
- level = (GLint) (tObj->BaseLevel + lambda + 0.5F);
- if (level > tObj->P)
- level = tObj->P;
-
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
sample_3d_nearest( tObj, tObj->Image[level], s, t, r, rgba );
}
@@ -1508,14 +1492,7 @@ sample_3d_linear_mipmap_nearest( const struct gl_texture_object *tObj,
GLfloat lambda, GLubyte rgba[4] )
{
GLint level;
- if (lambda <= 0.5F)
- lambda = 0.0F;
- else if (lambda > tObj->M + 0.4999F)
- lambda = tObj->M + 0.4999F;
- level = (GLint) (tObj->BaseLevel + lambda + 0.5F);
- if (level > tObj->P)
- level = tObj->P;
-
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
sample_3d_linear( tObj, tObj->Image[level], s, t, r, rgba );
}
@@ -1526,11 +1503,8 @@ sample_3d_nearest_mipmap_linear( const struct gl_texture_object *tObj,
GLfloat lambda, GLubyte rgba[4] )
{
GLint level;
- if (lambda < 0.0F)
- lambda = 0.0F;
- else if (lambda > tObj->M)
- lambda = tObj->M;
- level = (GLint) (tObj->BaseLevel + lambda);
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_3d_nearest( tObj, tObj->Image[tObj->P], s, t, r, rgba );
@@ -1554,11 +1528,8 @@ sample_3d_linear_mipmap_linear( const struct gl_texture_object *tObj,
GLfloat lambda, GLubyte rgba[4] )
{
GLint level;
- if (lambda < 0.0F)
- lambda = 0.0F;
- else if (lambda > tObj->M)
- lambda = tObj->M;
- level = (GLint) (tObj->BaseLevel + lambda);
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_3d_linear( tObj, tObj->Image[tObj->P], s, t, r, rgba );
@@ -1664,10 +1635,14 @@ static void sample_lambda_3d( const struct gl_texture_object *tObj, GLuint n,
/* Texture Cube Map Sampling Functions */
/**********************************************************************/
-static struct gl_texture_image *
+/*
+ * Choose one of six sides of a texture cube map given the texture
+ * coord (rx,ry,rz). Return pointer to corresponding array of texture
+ * images.
+ */
+static const struct gl_texture_image **
choose_cube_face(const struct gl_texture_object *texObj,
- const GLfloat texcoord[4],
- GLint level,
+ GLfloat rx, GLfloat ry, GLfloat rz,
GLfloat *newS, GLfloat *newT)
{
/*
@@ -1681,20 +1656,19 @@ choose_cube_face(const struct gl_texture_object *texObj,
+rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz
-rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz
*/
- struct gl_texture_image *texImg;
- const GLfloat rx = texcoord[0], ry = texcoord[1], rz = texcoord[2];
+ const struct gl_texture_image **imgArray;
const GLfloat arx = ABSF(rx), ary = ABSF(ry), arz = ABSF(rz);
GLfloat sc, tc, ma;
if (arx > ary && arx > arz) {
if (rx >= 0.0F) {
- texImg = texObj->Image[level];
+ imgArray = (const struct gl_texture_image **) texObj->Image;
sc = -rz;
tc = -ry;
ma = arx;
}
else {
- texImg = texObj->NegX[level];
+ imgArray = (const struct gl_texture_image **) texObj->NegX;
sc = rz;
tc = -ry;
ma = arx;
@@ -1702,13 +1676,13 @@ choose_cube_face(const struct gl_texture_object *texObj,
}
else if (ary > arx && ary > arz) {
if (ry >= 0.0F) {
- texImg = texObj->PosY[level];
+ imgArray = (const struct gl_texture_image **) texObj->PosY;
sc = rx;
tc = rz;
ma = ary;
}
else {
- texImg = texObj->NegY[level];
+ imgArray = (const struct gl_texture_image **) texObj->NegY;
sc = rx;
tc = -rz;
ma = ary;
@@ -1716,13 +1690,13 @@ choose_cube_face(const struct gl_texture_object *texObj,
}
else {
if (rz > 0.0F) {
- texImg = texObj->PosZ[level];
+ imgArray = (const struct gl_texture_image **) texObj->PosZ;
sc = rx;
tc = -ry;
ma = arz;
}
else {
- texImg = texObj->NegZ[level];
+ imgArray = (const struct gl_texture_image **) texObj->NegZ;
sc = -rx;
tc = -ry;
ma = arz;
@@ -1731,7 +1705,7 @@ choose_cube_face(const struct gl_texture_object *texObj,
*newS = ( sc / ma + 1.0F ) * 0.5F;
*newT = ( tc / ma + 1.0F ) * 0.5F;
- return texImg;
+ return imgArray;
}
@@ -1744,17 +1718,14 @@ sample_nearest_cube(const struct gl_texture_object *tObj, GLuint n,
GLuint i;
(void) lambda;
for (i = 0; i < n; i++) {
- struct gl_texture_image *image;
+ const struct gl_texture_image **images;
GLfloat newS, newT;
- GLfloat coord[4];
- coord[0] = s[i];
- coord[1] = t[i];
- coord[2] = u[i];
- image = choose_cube_face(tObj, coord, 0, &newS, &newT);
- sample_2d_nearest( tObj, image, newS, newT, rgba[i] );
+ images = choose_cube_face(tObj, s[i], t[i], u[i], &newS, &newT);
+ sample_2d_nearest( tObj, images[tObj->BaseLevel], newS, newT, rgba[i] );
}
}
+
static void
sample_linear_cube(const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
@@ -1764,17 +1735,104 @@ sample_linear_cube(const struct gl_texture_object *tObj, GLuint n,
GLuint i;
(void) lambda;
for (i = 0; i < n; i++) {
- struct gl_texture_image *image;
+ const struct gl_texture_image **images;
GLfloat newS, newT;
- GLfloat coord[4];
- coord[0] = s[i];
- coord[1] = t[i];
- coord[2] = u[i];
- image = choose_cube_face(tObj, coord, 0, &newS, &newT);
- sample_2d_linear( tObj, image, newS, newT, rgba[i] );
+ images = choose_cube_face(tObj, s[i], t[i], u[i], &newS, &newT);
+ sample_2d_linear( tObj, images[tObj->BaseLevel], newS, newT, rgba[i] );
}
}
+
+static void
+sample_cube_nearest_mipmap_nearest( const struct gl_texture_object *tObj,
+ GLfloat s, GLfloat t, GLfloat u,
+ GLfloat lambda, GLubyte rgba[4] )
+{
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ GLint level;
+
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
+
+ images = choose_cube_face(tObj, s, t, u, &newS, &newT);
+ sample_2d_nearest( tObj, images[level], newS, newT, rgba );
+}
+
+
+static void
+sample_cube_linear_mipmap_nearest( const struct gl_texture_object *tObj,
+ GLfloat s, GLfloat t, GLfloat u,
+ GLfloat lambda, GLubyte rgba[4] )
+{
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ GLint level;
+
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level);
+
+ images = choose_cube_face(tObj, s, t, u, &newS, &newT);
+ sample_2d_linear( tObj, images[level], newS, newT, rgba );
+}
+
+
+static void
+sample_cube_nearest_mipmap_linear( const struct gl_texture_object *tObj,
+ GLfloat s, GLfloat t, GLfloat u,
+ GLfloat lambda, GLubyte rgba[4] )
+{
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ GLint level;
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
+
+ images = choose_cube_face(tObj, s, t, u, &newS, &newT);
+
+ if (level >= tObj->P) {
+ sample_2d_nearest( tObj, images[tObj->P], newS, newT, rgba );
+ }
+ else {
+ GLubyte t0[4], t1[4]; /* texels */
+ const GLfloat f = myFrac(lambda);
+ sample_2d_nearest( tObj, images[level ], newS, newT, t0 );
+ sample_2d_nearest( tObj, images[level+1], newS, newT, t1 );
+ rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[GCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[BCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[ACOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+}
+
+
+static void
+sample_cube_linear_mipmap_linear( const struct gl_texture_object *tObj,
+ GLfloat s, GLfloat t, GLfloat u,
+ GLfloat lambda, GLubyte rgba[4] )
+{
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ GLint level;
+
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
+
+ images = choose_cube_face(tObj, s, t, u, &newS, &newT);
+
+ if (level >= tObj->P) {
+ sample_2d_linear( tObj, images[tObj->P], newS, newT, rgba );
+ }
+ else {
+ GLubyte t0[4], t1[4];
+ const GLfloat f = myFrac(lambda);
+ sample_2d_linear( tObj, images[level ], newS, newT, t0 );
+ sample_2d_linear( tObj, images[level+1], newS, newT, t1 );
+ rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[GCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[BCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[ACOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+}
+
+
static void
sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
@@ -1784,42 +1842,44 @@ sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n,
GLuint i;
for (i = 0; i < n; i++) {
- struct gl_texture_image *image;
- GLfloat newS, newT;
- GLfloat coord[4];
- coord[0] = s[i];
- coord[1] = t[i];
- coord[2] = u[i];
- image = choose_cube_face(tObj, coord, 0, &newS, &newT);
-
if (lambda[i] > tObj->MinMagThresh) {
/* minification */
switch (tObj->MinFilter) {
case GL_NEAREST:
- sample_2d_nearest( tObj, image, newS, newT, rgba[i] );
+ {
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ images = choose_cube_face(tObj, s[i], t[i], u[i],
+ &newS, &newT);
+ sample_2d_nearest( tObj, images[tObj->BaseLevel],
+ newS, newT, rgba[i] );
+ }
break;
case GL_LINEAR:
- sample_2d_linear( tObj, image, newS, newT, rgba[i] );
+ {
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ images = choose_cube_face(tObj, s[i], t[i], u[i],
+ &newS, &newT);
+ sample_2d_linear( tObj, images[tObj->BaseLevel],
+ newS, newT, rgba[i] );
+ }
break;
case GL_NEAREST_MIPMAP_NEAREST:
- /*
- sample_3d_nearest_mipmap_nearest( tObj, s[i], t[i], u[i], lambda[i], rgba[i] );
- */
+ sample_cube_nearest_mipmap_nearest( tObj, s[i], t[i], u[i],
+ lambda[i], rgba[i] );
break;
case GL_LINEAR_MIPMAP_NEAREST:
- /*
- sample_3d_linear_mipmap_nearest( tObj, s[i], t[i], u[i], lambda[i], rgba[i] );
- */
+ sample_cube_linear_mipmap_nearest( tObj, s[i], t[i], u[i],
+ lambda[i], rgba[i] );
break;
case GL_NEAREST_MIPMAP_LINEAR:
- /*
- sample_3d_nearest_mipmap_linear( tObj, s[i], t[i], u[i], lambda[i], rgba[i] );
- */
+ sample_cube_nearest_mipmap_linear( tObj, s[i], t[i], u[i],
+ lambda[i], rgba[i] );
break;
case GL_LINEAR_MIPMAP_LINEAR:
- /*
- sample_3d_linear_mipmap_linear( tObj, s[i], t[i], u[i], lambda[i], rgba[i] );
- */
+ sample_cube_linear_mipmap_linear( tObj, s[i], t[i], u[i],
+ lambda[i], rgba[i] );
break;
default:
gl_problem(NULL, "Bad min filter in sample_lambda_cube");
@@ -1827,12 +1887,18 @@ sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n,
}
else {
/* magnification */
+ const struct gl_texture_image **images;
+ GLfloat newS, newT;
+ images = choose_cube_face(tObj, s[i], t[i], u[i],
+ &newS, &newT);
switch (tObj->MagFilter) {
case GL_NEAREST:
- sample_2d_nearest( tObj, image, newS, newT, rgba[i] );
+ sample_2d_nearest( tObj, images[tObj->BaseLevel],
+ newS, newT, rgba[i] );
break;
case GL_LINEAR:
- sample_2d_linear( tObj, image, newS, newT, rgba[i] );
+ sample_2d_linear( tObj, images[tObj->BaseLevel],
+ newS, newT, rgba[i] );
break;
default:
gl_problem(NULL, "Bad mag filter in sample_lambda_cube");
@@ -1936,6 +2002,256 @@ _mesa_set_texture_sampler( struct gl_texture_object *t )
}
+#define PROD(A,B) ( (GLuint)(A) * ((GLuint)(B)+1) )
+
+static INLINE void
+_mesa_texture_combine(CONST GLcontext *ctx,
+ CONST struct gl_texture_unit *textureUnit,
+ GLuint n,
+ GLubyte (*primary_rgba)[4],
+ GLubyte (*texel)[4],
+ GLubyte (*rgba)[4])
+{
+ GLubyte ccolor [3][3*MAX_WIDTH][4];
+ GLubyte (*argRGB [3])[4];
+ GLubyte (*argA [3])[4];
+ GLuint i, j;
+ GLuint RGBshift = textureUnit->CombineScaleShiftRGB;
+ GLuint Ashift = textureUnit->CombineScaleShiftA;
+
+ ASSERT(ctx->Extensions.HaveTextureEnvCombine);
+
+ for (j = 0; j < 3; j++) {
+ switch (textureUnit->CombineSourceA[j]) {
+ case GL_TEXTURE:
+ argA[j] = texel;
+ break;
+ case GL_PRIMARY_COLOR_EXT:
+ argA[j] = primary_rgba;
+ break;
+ case GL_PREVIOUS_EXT:
+ argA[j] = rgba;
+ break;
+ case GL_CONSTANT_EXT:
+ {
+ GLubyte (*c)[4] = ccolor[j];
+ GLubyte col = FLOAT_TO_UBYTE(textureUnit->EnvColor[3]);
+ for (i = 0; i < n; i++)
+ c[i][ACOMP] = col;
+ argA[j] = ccolor[j];
+ }
+ break;
+ default:
+ gl_problem(NULL, "invalid combine source");
+ }
+
+ if (textureUnit->CombineOperandA[j] == GL_ONE_MINUS_SRC_ALPHA) {
+ GLubyte (*src)[4] = argA[j];
+ GLubyte (*dst)[4] = ccolor[j];
+ argA[j] = ccolor[j];
+ for (i = 0; i < n; i++)
+ dst[i][ACOMP] = 255 - src[i][ACOMP];
+ }
+
+ if (j == 2) /* arg2 has no color component in specification. */
+ break;
+
+ switch (textureUnit->CombineSourceRGB[j]) {
+ case GL_TEXTURE:
+ argRGB[j] = texel;
+ break;
+ case GL_PRIMARY_COLOR_EXT:
+ argRGB[j] = primary_rgba;
+ break;
+ case GL_PREVIOUS_EXT:
+ argRGB[j] = rgba;
+ break;
+ case GL_CONSTANT_EXT:
+ {
+ GLubyte (*c)[4] = ccolor[j];
+ GLubyte col[4];
+
+ col[RCOMP] = FLOAT_TO_UBYTE(textureUnit->EnvColor[0]);
+ col[GCOMP] = FLOAT_TO_UBYTE(textureUnit->EnvColor[1]);
+ col[BCOMP] = FLOAT_TO_UBYTE(textureUnit->EnvColor[2]);
+
+ for (i = 0; i < n; i++) {
+ c[i][RCOMP] = col[RCOMP];
+ c[i][GCOMP] = col[GCOMP];
+ c[i][BCOMP] = col[BCOMP];
+ }
+ argRGB[j] = ccolor[j];
+ }
+ break;
+ default:
+ gl_problem(NULL, "invalid combine source");
+ }
+
+ if (textureUnit->CombineOperandRGB[j] != GL_SRC_COLOR) {
+ GLubyte (*src)[4] = argRGB[j];
+ GLubyte (*dst)[4] = ccolor[j];
+
+ argRGB[j] = ccolor[j];
+
+ if (textureUnit->CombineOperandRGB[j] == GL_ONE_MINUS_SRC_COLOR) {
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = 255 - src[i][RCOMP];
+ dst[i][GCOMP] = 255 - src[i][GCOMP];
+ dst[i][BCOMP] = 255 - src[i][BCOMP];
+ }
+ } else if (textureUnit->CombineOperandRGB[j] == GL_SRC_ALPHA) {
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = src[i][ACOMP];
+ dst[i][GCOMP] = src[i][ACOMP];
+ dst[i][BCOMP] = src[i][ACOMP];
+ }
+ } else { /* GL_ONE_MINUS_SRC_ALPHA */
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = 255 - src[i][ACOMP];
+ dst[i][GCOMP] = 255 - src[i][ACOMP];
+ dst[i][BCOMP] = 255 - src[i][ACOMP];
+ }
+ }
+ }
+
+ if (textureUnit->CombineModeRGB == GL_REPLACE &&
+ textureUnit->CombineModeA == GL_REPLACE) {
+ break; /* done, we need only arg0 */
+ }
+
+ if (j == 1 &&
+ textureUnit->CombineModeRGB != GL_INTERPOLATE_EXT &&
+ textureUnit->CombineModeA != GL_INTERPOLATE_EXT) {
+ break; /* arg0 and arg1 are done. we don't need arg2. */
+ }
+ }
+
+ switch (textureUnit->CombineModeRGB) {
+ case GL_REPLACE:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = arg0[i][RCOMP] << RGBshift;
+ rgba[i][GCOMP] = arg0[i][GCOMP] << RGBshift;
+ rgba[i][BCOMP] = arg0[i][BCOMP] << RGBshift;
+ }
+ }
+ break;
+ case GL_MODULATE:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argRGB[1];
+ RGBshift = 8 - RGBshift;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = (GLubyte) (PROD(arg0[i][0], arg1[i][RCOMP]) >> RGBshift);
+ rgba[i][GCOMP] = (GLubyte) (PROD(arg0[i][1], arg1[i][GCOMP]) >> RGBshift);
+ rgba[i][BCOMP] = (GLubyte) (PROD(arg0[i][2], arg1[i][BCOMP]) >> RGBshift);
+ }
+ }
+ break;
+ case GL_ADD:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+ GLint r = ((GLuint) arg0[i][RCOMP] + arg1[i][RCOMP]) << RGBshift;
+ GLint g = ((GLuint) arg0[i][GCOMP] + arg1[i][GCOMP]) << RGBshift;
+ GLint b = ((GLuint) arg0[i][BCOMP] + arg1[i][BCOMP]) << RGBshift;
+ rgba[i][RCOMP] = (r > 255) ? 255 : (GLubyte) r;
+ rgba[i][GCOMP] = (g > 255) ? 255 : (GLubyte) g;
+ rgba[i][BCOMP] = (b > 255) ? 255 : (GLubyte) b;
+ }
+ }
+ break;
+ case GL_ADD_SIGNED_EXT:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+ GLint r = (GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP] - 128;
+ GLint g = (GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP] - 128;
+ GLint b = (GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP] - 128;
+ r = (r < 0) ? 0 : r << RGBshift;
+ b = (b < 0) ? 0 : b << RGBshift;
+ g = (g < 0) ? 0 : g << RGBshift;
+ rgba[i][RCOMP] = (r > 255) ? 255 : (GLubyte) r;
+ rgba[i][GCOMP] = (g > 255) ? 255 : (GLubyte) g;
+ rgba[i][BCOMP] = (b > 255) ? 255 : (GLubyte) b;
+ }
+ }
+ break;
+ case GL_INTERPOLATE_EXT:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argRGB[1];
+ const GLubyte (*arg2)[4] = (const GLubyte (*)[4]) argRGB[2];
+ RGBshift = 8 - RGBshift;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = (GLubyte) ((PROD(arg0[i][RCOMP], arg2[i][ACOMP]) + PROD(arg1[i][RCOMP], 255 - arg2[i][ACOMP])) >> RGBshift);
+ rgba[i][GCOMP] = (GLubyte) ((PROD(arg0[i][GCOMP], arg2[i][ACOMP]) + PROD(arg1[i][GCOMP], 255 - arg2[i][ACOMP])) >> RGBshift);
+ rgba[i][BCOMP] = (GLubyte) ((PROD(arg0[i][BCOMP], arg2[i][ACOMP]) + PROD(arg1[i][BCOMP], 255 - arg2[i][ACOMP])) >> RGBshift);
+ }
+ }
+ break;
+ default:
+ gl_problem(NULL, "invalid combine mode");
+ }
+
+ switch (textureUnit->CombineModeA) {
+ case GL_REPLACE:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argA[0];
+ for (i = 0; i < n; i++)
+ rgba[i][ACOMP] = arg0[i][ACOMP] << Ashift;
+ }
+ break;
+ case GL_MODULATE:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argA[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argA[1];
+ Ashift = 8 - Ashift;
+ for (i = 0; i < n; i++)
+ rgba[i][ACOMP] = (GLubyte) (PROD(arg0[i][ACOMP], arg1[i][ACOMP]) >> Ashift);
+ }
+ break;
+ case GL_ADD:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argA[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argA[1];
+ for (i = 0; i < n; i++) {
+ GLint a = ((GLint) arg0[i][ACOMP] + arg1[i][ACOMP]) << Ashift;
+ rgba[i][ACOMP] = (a > 255) ? 255 : (GLubyte) a;
+ }
+ }
+ break;
+ case GL_ADD_SIGNED_EXT:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argA[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argA[1];
+ for (i = 0; i < n; i++) {
+ GLint a = (GLint) arg0[i][ACOMP] + (GLint) arg1[i][ACOMP] - 128;
+ a = (a < 0) ? 0 : a << Ashift;
+ rgba[i][ACOMP] = (a > 255) ? 255 : (GLubyte) a;
+ }
+ }
+ break;
+ case GL_INTERPOLATE_EXT:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argA[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argA[1];
+ const GLubyte (*arg2)[4] = (const GLubyte (*)[4]) argA[2];
+ Ashift = 8 - Ashift;
+ for (i=0; i<n; i++)
+ rgba[i][ACOMP] = (GLubyte) ((PROD(arg0[i][ACOMP], arg2[i][ACOMP]) + PROD(arg1[i][ACOMP], 255 - arg2[i][ACOMP])) >> Ashift);
+ }
+ break;
+ default:
+ gl_problem(NULL, "invalid combine mode");
+ }
+}
+#undef PROD
+
+
/**********************************************************************/
/* Texture Application */
@@ -1947,14 +2263,16 @@ _mesa_set_texture_sampler( struct gl_texture_object *t )
* Input: textureUnit - pointer to texture unit to apply
* format - base internal texture format
* n - number of fragments
+ * primary_rgba - primary colors (may be rgba for single texture)
* texels - array of texel colors
* InOut: rgba - incoming fragment colors modified by texel colors
* according to the texture environment mode.
*/
-static void apply_texture( const GLcontext *ctx,
- const struct gl_texture_unit *texUnit,
+static void apply_texture( CONST GLcontext *ctx,
+ CONST struct gl_texture_unit *texUnit,
GLuint n,
- GLubyte rgba[][4], CONST GLubyte texel[][4] )
+ GLubyte primary_rgba[][4], GLubyte texel[][4],
+ GLubyte rgba[][4] )
{
GLint baseLevel;
GLuint i;
@@ -2284,6 +2602,52 @@ static void apply_texture( const GLcontext *ctx,
}
break;
+ case GL_COMBINE_EXT: /* GL_EXT_combine_ext; we modify texel array */
+ switch (format) {
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ texel[i][RCOMP] = texel[i][GCOMP] = texel[i][BCOMP] = 0;
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++) {
+ /* Cv = Lt */
+ GLubyte Lt = texel[i][RCOMP];
+ texel[i][GCOMP] = texel[i][BCOMP] = Lt;
+ /* Av = 1 */
+ texel[i][ACOMP] = 255;
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ GLubyte Lt = texel[i][RCOMP];
+ /* Cv = Lt */
+ texel[i][GCOMP] = texel[i][BCOMP] = Lt;
+ }
+ break;
+ case GL_INTENSITY:
+ for (i=0;i<n;i++) {
+ /* Cv = It */
+ GLubyte It = texel[i][RCOMP];
+ texel[i][GCOMP] = texel[i][BCOMP] = It;
+ /* Av = It */
+ texel[i][ACOMP] = It;
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ /* Av = 1 */
+ texel[i][ACOMP] = 255;
+ }
+ break;
+ case GL_RGBA: /* do nothing. */
+ break;
+ default:
+ gl_problem(ctx, "Bad format in apply_texture (GL_COMBINE_EXT)");
+ return;
+ }
+ _mesa_texture_combine (ctx, texUnit, n, primary_rgba, texel, rgba);
+ break;
+
default:
gl_problem(ctx, "Bad env mode in apply_texture");
return;
@@ -2299,7 +2663,7 @@ static void apply_texture( const GLcontext *ctx,
void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat r[], GLfloat lambda[],
- GLubyte rgba[][4] )
+ GLubyte primary_rgba[][4], GLubyte rgba[][4] )
{
GLuint mask = (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE) << (texUnit * 4);
if (ctx->Texture.Enabled & mask) {
@@ -2369,8 +2733,7 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n,
(*textureUnit->Current->SampleFunc)( textureUnit->Current, n,
s, t, r, lambda, texel );
- apply_texture( ctx, textureUnit, n,
- rgba, (const GLubyte (*)[4])texel );
+ apply_texture( ctx, textureUnit, n, primary_rgba, texel, rgba );
}
}
}
diff --git a/xc/extras/Mesa/src/texture.h b/xc/extras/Mesa/src/texture.h
index 58bc13136..113602bf7 100644
--- a/xc/extras/Mesa/src/texture.h
+++ b/xc/extras/Mesa/src/texture.h
@@ -46,7 +46,7 @@ extern void gl_update_texture_unit( GLcontext *ctx,
extern void gl_texture_pixels( GLcontext *ctx, GLuint texSet, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat r[], GLfloat lambda[],
- GLubyte rgba[][4] );
+ GLubyte primary_rgba[][4], GLubyte rgba[][4] );
#endif
diff --git a/xc/extras/Mesa/src/texutil.c b/xc/extras/Mesa/src/texutil.c
index 67805c8d7..eb310ee55 100644
--- a/xc/extras/Mesa/src/texutil.c
+++ b/xc/extras/Mesa/src/texutil.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -586,6 +586,7 @@ _mesa_convert_teximage(MesaIntTexFormat dstFormat,
break;
case MESA_A8_R8_G8_B8:
+ case MESA_FF_R8_G8_B8:
/* 32-bit texels */
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV){
/* special, optimized case */
@@ -661,13 +662,63 @@ _mesa_convert_teximage(MesaIntTexFormat dstFormat,
}
}
}
+ else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
+ /* general case */
+ if (wScale == 1 && hScale == 1) {
+ const GLubyte *src = _mesa_image_address(packing, srcImage,
+ srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLint srcStride = _mesa_image_row_stride(packing,
+ srcWidth, srcFormat, srcType);
+ GLuint *dst = dstImage;
+ GLint row;
+ for (row = 0; row < dstHeight; row++) {
+ GLint col, col3;
+ for (col = col3 = 0; col < dstWidth; col++, col3 += 3) {
+ GLubyte r = src[col3 + 0];
+ GLubyte g = src[col3 + 1];
+ GLubyte b = src[col3 + 2];
+ GLubyte a = 255;
+ dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ src += srcStride;
+ dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
+ }
+ }
+ else {
+ /* must rescale image */
+ GLuint *dst = dstImage;
+ GLint row;
+ for (row = 0; row < dstHeight; row++) {
+ GLint srcRow = row / hScale;
+ const GLubyte *src = _mesa_image_address(packing, srcImage,
+ srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ GLint col;
+ for (col = 0; col < dstWidth; col++) {
+ GLint col3 = (col / wScale) * 3;
+ GLubyte r = src[col3 + 0];
+ GLubyte g = src[col3 + 1];
+ GLubyte b = src[col3 + 2];
+ GLubyte a = 255;
+ dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
+ }
+ }
+ }
else {
/* can't handle this source format/type combination */
return GL_FALSE;
}
+ if (dstFormat == MESA_FF_R8_G8_B8) {
+ /* set alpha bytes to 0xff */
+ GLuint i;
+ GLubyte *dst = (GLubyte *) dstImage;
+ for (i = 0; i < dstWidth * dstHeight; i++) {
+ dst[i * 4 + 3] = 0xff;
+ }
+ }
break;
-
default:
/* unexpected internal format! */
return GL_FALSE;
@@ -1140,6 +1191,7 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat,
break;
case MESA_A8_R8_G8_B8:
+ case MESA_FF_R8_G8_B8:
/* 32-bit texels */
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV){
/* special, optimized case */
@@ -1223,6 +1275,18 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat,
/* can't handle this source format/type combination */
return GL_FALSE;
}
+ if (dstFormat == MESA_FF_R8_G8_B8) {
+ /* set alpha bytes to 0xff */
+ GLint row, col;
+ GLubyte *dst = (GLubyte *) dstImage
+ + dstYoffset * dstRowStride + dstXoffset;
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width; col++) {
+ dst[col * 4 + 3] = 0xff;
+ }
+ dst = dst + dstRowStride;
+ }
+ }
break;
@@ -1491,6 +1555,7 @@ _mesa_unconvert_teximage(MesaIntTexFormat srcFormat,
}
break;
case MESA_A8_R8_G8_B8:
+ case MESA_FF_R8_G8_B8:
ASSERT(dstFormat == GL_RGBA);
if (wScale == 1 && hScale == 1) {
GLint i, n = dstWidth * dstHeight;
@@ -1546,6 +1611,7 @@ _mesa_set_teximage_component_sizes(MesaIntTexFormat mesaFormat,
{ MESA_A4_R4_G4_B4, 4, 4, 4, 4, 0, 0, 0 },
{ MESA_A1_R5_G5_B5, 5, 5, 5, 1, 0, 0, 0 },
{ MESA_A8_R8_G8_B8, 8, 8, 8, 8, 0, 0, 0 },
+ { MESA_FF_R8_G8_B8, 8, 8, 8, 8, 0, 0, 0 },
{ -1, 0, 0, 0, 0, 0, 0, 0 }
};
GLint i;
diff --git a/xc/extras/Mesa/src/texutil.h b/xc/extras/Mesa/src/texutil.h
index 5f000be60..22e916d50 100644
--- a/xc/extras/Mesa/src/texutil.h
+++ b/xc/extras/Mesa/src/texutil.h
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -32,6 +32,9 @@
+/*
+ * NOTE: "FF" means fill with byte value 0xff
+ */
/* msb <------ TEXEL BITS -----------> lsb */
typedef enum { /* ---- ---- ---- ---- ---- ---- ---- ---- */
MESA_I8, /* IIII IIII */
@@ -42,7 +45,8 @@ typedef enum { /* ---- ---- ---- ---- ---- ---- ---- ---- */
MESA_R5_G6_B5, /* RRRR RGGG GGGB BBBB */
MESA_A4_R4_G4_B4, /* AAAA RRRR GGGG BBBB */
MESA_A1_R5_G5_B5, /* ARRR RRGG GGGB BBBB */
- MESA_A8_R8_G8_B8 /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_A8_R8_G8_B8, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FF_R8_G8_B8 /* FFFF FFFF RRRR RRRR GGGG GGGG BBBB BBBB */
} MesaIntTexFormat;
diff --git a/xc/extras/Mesa/src/triangle.c b/xc/extras/Mesa/src/triangle.c
index 29f85a4ef..04c91bdc0 100644
--- a/xc/extras/Mesa/src/triangle.c
+++ b/xc/extras/Mesa/src/triangle.c
@@ -1534,7 +1534,8 @@ void gl_set_triangle_function( GLcontext *ctx )
&& image->Border==0
&& ((format = image->Format)==GL_RGB || format==GL_RGBA)
&& (filter = current2Dtex->MinFilter)==current2Dtex->MagFilter
- && ctx->Light.Model.ColorControl==GL_SINGLE_COLOR) {
+ && ctx->Light.Model.ColorControl==GL_SINGLE_COLOR
+ && ctx->Texture.Unit[0].EnvMode!=GL_COMBINE_EXT) {
if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) {
diff --git a/xc/extras/Mesa/src/tritemp.h b/xc/extras/Mesa/src/tritemp.h
index 61e040365..25f0f2b57 100644
--- a/xc/extras/Mesa/src/tritemp.h
+++ b/xc/extras/Mesa/src/tritemp.h
@@ -146,10 +146,17 @@
const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
/* Do backface culling */
- if (area * bf < 0 || area * area < .0025)
+ if (area * bf < 0.0)
return;
- oneOverArea = 1.0F / area;
+ if (area == 0.0F)
+ return;
+
+ /* check for very tiny triangle */
+ if (area * area < 0.0025F) /* square it to ensure positive value */
+ oneOverArea = 1.0F / 0.0025F; /* a close-enough value */
+ else
+ oneOverArea = 1.0F / area;
}
#ifndef DO_OCCLUSION_TEST
diff --git a/xc/extras/Mesa/src/types.h b/xc/extras/Mesa/src/types.h
index c44d602b9..ada9fd745 100644
--- a/xc/extras/Mesa/src/types.h
+++ b/xc/extras/Mesa/src/types.h
@@ -2,7 +2,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -831,9 +831,18 @@ struct gl_texture_unit {
GLuint Enabled;
GLuint ReallyEnabled;
- GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND */
+ GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND, GL_COMBINE_EXT */
GLenum LastEnvMode;
+ GLenum CombineSourceRGB[3]; /* arg[i] for rgb EXT_texture_combine */
+ GLenum CombineSourceA[3]; /* dito for alpha combiner */
+ GLenum CombineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD ... */
+ GLenum CombineModeA;
+ GLenum CombineOperandRGB[3]; /* SRC_COLOR or ONE_MINUS_SRC_COLOR */
+ GLenum CombineOperandA[3]; /* SRC_ALPHA or ONE_MINUS_SRC_ALPHA */
+ GLuint CombineScaleShiftRGB; /* 0, 1 or 2 */
+ GLuint CombineScaleShiftA;
+
GLfloat EnvColor[4];
GLuint TexGenEnabled; /* Bitwise-OR of [STRQ]_BIT values */
GLenum GenModeS; /* Tex coord generation mode, either */
@@ -868,6 +877,7 @@ struct gl_texture_unit {
struct gl_texture_object Saved1D; /* only used by glPush/PopAttrib */
struct gl_texture_object Saved2D;
struct gl_texture_object Saved3D;
+ struct gl_texture_object SavedCubeMap;
};
@@ -1259,6 +1269,8 @@ struct gl_shared_state {
/* Default texture objects (shared by all multi-texture units) */
struct gl_texture_object *DefaultD[4];
struct gl_texture_object *DefaultCubeMap;
+
+ void *DriverData; /* Device driver shared state */
};
@@ -1365,6 +1377,7 @@ struct gl_extensions {
struct extension *ext_list;
/* flags to quickly test if certain extensions are available */
GLboolean HaveTextureEnvAdd;
+ GLboolean HaveTextureEnvCombine;
GLboolean HaveTextureLodBias;
GLboolean HaveHpOcclusionTest;
GLboolean HaveTextureCubeMap;
@@ -1520,10 +1533,7 @@ struct gl_extensions {
* shared with the cull mode (ie. cull_mask_active and
* compacted_normals.)
*/
-#define SHADE_RGBA_VERTICES 0x4
-#define SHADE_RGBA_NORMALS 0x8
-#define SHADE_RGBA_SPEC 0xc /* note - not a seperate bit */
-#define SHADE_TWOSIDE 0x10
+#define SHADE_TWOSIDE 0x4
/* Flags for selecting a normal transformation function.
*/
@@ -1778,7 +1788,7 @@ struct gl_context {
GLmatrix ProjectionMatrix; /* current matrix, not stored on stack */
GLuint ProjectionStackDepth;
GLmatrix ProjectionStack[MAX_PROJECTION_STACK_DEPTH - 1];
- GLfloat NearFarStack[MAX_PROJECTION_STACK_DEPTH - 1][2];
+ GLfloat NearFarStack[MAX_PROJECTION_STACK_DEPTH][2];
/* Combined modelview and projection matrix */
GLmatrix ModelProjectMatrix;
@@ -1825,18 +1835,18 @@ struct gl_context {
struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
/* Renderer attribute groups */
- struct gl_accum_attrib Accum;
+ struct gl_accum_attrib Accum;
struct gl_colorbuffer_attrib Color;
struct gl_current_attrib Current;
struct gl_depthbuffer_attrib Depth;
- struct gl_eval_attrib Eval;
+ struct gl_eval_attrib Eval;
struct gl_fog_attrib Fog;
- struct gl_hint_attrib Hint;
- struct gl_light_attrib Light;
- struct gl_line_attrib Line;
- struct gl_list_attrib List;
- struct gl_pixel_attrib Pixel;
- struct gl_point_attrib Point;
+ struct gl_hint_attrib Hint;
+ struct gl_light_attrib Light;
+ struct gl_line_attrib Line;
+ struct gl_list_attrib List;
+ struct gl_pixel_attrib Pixel;
+ struct gl_point_attrib Point;
struct gl_polygon_attrib Polygon;
GLuint PolygonStipple[32];
struct gl_scissor_attrib Scissor;
@@ -1847,23 +1857,23 @@ struct gl_context {
/* Other attribute groups */
struct gl_histogram_attrib Histogram;
- struct gl_minmax_attrib MinMax;
- struct gl_convolution_attrib Convolution1D;
- struct gl_convolution_attrib Convolution2D;
- struct gl_convolution_attrib Separable2D;
+ struct gl_minmax_attrib MinMax;
+ struct gl_convolution_attrib Convolution1D;
+ struct gl_convolution_attrib Convolution2D;
+ struct gl_convolution_attrib Separable2D;
/* Client attribute stack */
GLuint ClientAttribStackDepth;
struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
/* Client attribute groups */
- struct gl_array_attrib Array; /* Vertex arrays */
+ struct gl_array_attrib Array; /* Vertex arrays */
struct gl_pixelstore_attrib Pack; /* Pixel packing */
struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */
- struct gl_evaluators EvalMap; /* All evaluators */
- struct gl_feedback Feedback; /* Feedback */
- struct gl_selection Select; /* Selection */
+ struct gl_evaluators EvalMap; /* All evaluators */
+ struct gl_feedback Feedback; /* Feedback */
+ struct gl_selection Select; /* Selection */
struct gl_color_table ColorTable; /* Pre-convolution */
struct gl_color_table ProxyColorTable; /* Pre-convolution */
@@ -1878,21 +1888,21 @@ struct gl_context {
struct gl_fallback_arrays Fallback;
- GLenum ErrorValue; /* Last error code */
+ GLenum ErrorValue; /* Last error code */
/* Miscellaneous */
- GLuint NewState; /* bitwise OR of NEW_* flags */
- GLuint Enabled; /* bitwise or of ENABLE_* flags */
- GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
- GLuint StippleCounter; /* Line stipple counter */
- GLuint RasterMask; /* OR of rasterization flags */
+ GLuint NewState; /* bitwise OR of NEW_* flags */
+ GLuint Enabled; /* bitwise or of ENABLE_* flags */
+ GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
+ GLuint StippleCounter; /* Line stipple counter */
+ GLuint RasterMask; /* OR of rasterization flags */
GLuint TriangleCaps; /* OR of DD_* flags */
GLuint IndirectTriangles; /* TriangleCaps not handled by the driver */
- GLfloat PolygonZoffset; /* Z offset for GL_FILL polygons */
- GLfloat LineZoffset; /* Z offset for GL_LINE polygons */
- GLfloat PointZoffset; /* Z offset for GL_POINT polygons */
- GLboolean NeedNormals; /* Are vertex normal vectors needed? */
- GLuint FogMode; /* FOG_OFF, FOG_VERTEX or FOG_FRAGMENT */
+ GLfloat PolygonZoffset; /* Z offset for GL_FILL polygons */
+ GLfloat LineZoffset; /* Z offset for GL_LINE polygons */
+ GLfloat PointZoffset; /* Z offset for GL_POINT polygons */
+ GLboolean NeedNormals; /* Are vertex normal vectors needed? */
+ GLuint FogMode; /* FOG_OFF, FOG_VERTEX or FOG_FRAGMENT */
GLboolean DoViewportMapping;
@@ -1906,8 +1916,8 @@ struct gl_context {
normal_func *NormalTransform;
- /* Current shading function */
- GLuint shade_func_flags;
+ /* Current shading function table */
+ gl_shade_func *shade_func_tab;
GLfloat EyeZDir[3];
GLfloat rescale_factor;
diff --git a/xc/extras/Mesa/src/varray.c b/xc/extras/Mesa/src/varray.c
index 7df2603b1..5915cdb97 100644
--- a/xc/extras/Mesa/src/varray.c
+++ b/xc/extras/Mesa/src/varray.c
@@ -375,7 +375,6 @@ _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
GLsizei count, const GLvoid *ptr)
{
(void) count;
- printf("glVertexPointerEXT %p\n", ptr);
_mesa_VertexPointer(size, type, stride, ptr);
}
diff --git a/xc/extras/Mesa/src/vb.c b/xc/extras/Mesa/src/vb.c
index 7dcb64b10..18ca16b14 100644
--- a/xc/extras/Mesa/src/vb.c
+++ b/xc/extras/Mesa/src/vb.c
@@ -43,9 +43,9 @@ struct vertex_buffer *gl_vb_create_for_immediate( GLcontext *ctx )
{
struct vertex_buffer *VB;
struct immediate *IM;
- GLuint alignment = 32;
+ const GLuint alignment = 32;
- VB = CALLOC_STRUCT(vertex_buffer);
+ VB = ALIGN_CALLOC_STRUCT( vertex_buffer, alignment );
if (!VB)
return 0;
@@ -63,14 +63,14 @@ struct vertex_buffer *gl_vb_create_for_immediate( GLcontext *ctx )
gl_vector4ub_alloc( &VB->BColor, VEC_WRITABLE, VB_SIZE, alignment );
gl_vector1ui_alloc( &VB->BIndex, VEC_WRITABLE, VB_SIZE, alignment );
- VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * VB_SIZE);
- VB->UserClipMask = (GLubyte *)CALLOC(sizeof(GLubyte) * VB_SIZE);
- VB->CullMask = (GLubyte *)MALLOC(sizeof(GLubyte) * VB_SIZE);
- VB->NormCullMask = (GLubyte *)MALLOC(sizeof(GLubyte) * VB_SIZE);
- VB->Spec[0] = (GLubyte (*)[4])MALLOC(sizeof(GLubyte) * 4 * VB_SIZE);
- VB->Spec[1] = (GLubyte (*)[4])MALLOC(sizeof(GLubyte) * 4 * VB_SIZE);
+ VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * VB_SIZE, alignment);
+ VB->UserClipMask = (GLubyte *) ALIGN_CALLOC(sizeof(GLubyte) * VB_SIZE, alignment);
+ VB->CullMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * VB_SIZE, alignment);
+ VB->NormCullMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * VB_SIZE, alignment);
+ VB->Spec[0] = (GLubyte (*)[4]) ALIGN_MALLOC(sizeof(GLubyte) * 4 * VB_SIZE, alignment);
+ VB->Spec[1] = (GLubyte (*)[4]) ALIGN_MALLOC(sizeof(GLubyte) * 4 * VB_SIZE, alignment);
- IM = VB->IM = gl_immediate_alloc( ctx );
+ IM = VB->IM = gl_immediate_alloc(ctx);
VB->store.Obj = &IM->v.Obj;
VB->store.Normal = &IM->v.Normal;
@@ -105,7 +105,7 @@ struct vertex_buffer *gl_vb_create_for_cva( GLcontext *ctx, GLuint size )
struct vertex_buffer *VB;
GLuint alignment = 32;
- VB = CALLOC_STRUCT(vertex_buffer);
+ VB = ALIGN_CALLOC_STRUCT( vertex_buffer, alignment );
if (!VB)
return 0;
@@ -121,11 +121,14 @@ struct vertex_buffer *gl_vb_create_for_cva( GLcontext *ctx, GLuint size )
VB->ClipAndMask = CLIP_ALL_BITS;
VB->pipeline = &ctx->CVA.pre;
- VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * size);
- VB->UserClipMask = (GLubyte *)CALLOC(sizeof(GLubyte) * size);
- VB->Spec[0] = (GLubyte (*)[4])MALLOC(sizeof(GLubyte) * 4 * size);
- VB->Spec[1] = (GLubyte (*)[4])MALLOC(sizeof(GLubyte) * 4 * size);
- VB->Flag = (GLuint *)MALLOC(sizeof(GLuint) * size);
+ VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * size, alignment );
+ VB->UserClipMask = (GLubyte *)ALIGN_CALLOC( sizeof(GLubyte) * size,
+ alignment );
+ VB->Spec[0] = (GLubyte (*)[4])ALIGN_MALLOC( sizeof(GLubyte) * 4 * size,
+ alignment );
+ VB->Spec[1] = (GLubyte (*)[4])ALIGN_MALLOC( sizeof(GLubyte) * 4 * size,
+ alignment );
+ VB->Flag = (GLuint *)ALIGN_MALLOC( sizeof(GLuint) * size, alignment );
gl_vector4f_alloc( &VB->Eye, 2, VEC_WRITABLE, size, alignment );
gl_vector4f_alloc( &VB->Clip, 2, VEC_WRITABLE, size, alignment );
@@ -201,8 +204,8 @@ void gl_vb_free( struct vertex_buffer *VB )
if ( ! --VB->IM->ref_count )
gl_immediate_free( VB->IM );
- FREE( VB->CullMask );
- FREE( VB->NormCullMask );
+ ALIGN_FREE( VB->CullMask );
+ ALIGN_FREE( VB->NormCullMask );
} else {
if (VB->store.Elt)
gl_vector4f_free( VB->store.Obj ); FREE( VB->store.Obj );
@@ -221,22 +224,22 @@ void gl_vb_free( struct vertex_buffer *VB )
gl_vector1ui_free( VB->FoggedIndex[0] ); FREE( VB->FoggedIndex[0] );
gl_vector1ui_free( VB->FoggedIndex[1] ); FREE( VB->FoggedIndex[1] );
- FREE( VB->Flag );
+ ALIGN_FREE( VB->Flag );
}
- if (VB->tmp_f) FREE(VB->tmp_f);
- if (VB->tmp_m) FREE(VB->tmp_m);
- if (VB->EvaluatedFlags) FREE(VB->EvaluatedFlags);
+ if (VB->tmp_f) FREE( VB->tmp_f );
+ if (VB->tmp_m) FREE( VB->tmp_m );
+ if (VB->EvaluatedFlags) FREE( VB->EvaluatedFlags );
- FREE( VB->Spec[0] );
- FREE( VB->Spec[1] );
- FREE( VB->ClipMask );
- FREE( VB->UserClipMask );
+ ALIGN_FREE( VB->Spec[0] );
+ ALIGN_FREE( VB->Spec[1] );
+ ALIGN_FREE( VB->ClipMask );
+ ALIGN_FREE( VB->UserClipMask );
if (VB->ctx->Driver.UnregisterVB)
VB->ctx->Driver.UnregisterVB( VB );
- FREE( VB );
+ ALIGN_FREE( VB );
}
@@ -254,7 +257,7 @@ struct immediate *gl_immediate_alloc( GLcontext *ctx )
return IM;
}
- IM = MALLOC_STRUCT(immediate);
+ IM = ALIGN_MALLOC_STRUCT( immediate, 32 );
if (!IM)
return 0;
@@ -272,7 +275,7 @@ struct immediate *gl_immediate_alloc( GLcontext *ctx )
IM->Material = 0;
IM->MaterialMask = 0;
#ifdef VMS
- for (j=0; j<VB_SIZE ; j++ )
+ for (j = 0; j < VB_SIZE; j++)
IM->Normal[j][0] = IM->Normal[j][1] = IM->Normal[j][2] = 0.0;
#endif
@@ -323,7 +326,7 @@ void gl_immediate_free( struct immediate *IM )
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
fprintf(stderr, "really free immediate %d\n", IM->id);
- FREE( IM );
+ ALIGN_FREE( IM );
}
else {
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
diff --git a/xc/extras/Mesa/src/vbcull.c b/xc/extras/Mesa/src/vbcull.c
index 927e485c6..61c8ea9eb 100644
--- a/xc/extras/Mesa/src/vbcull.c
+++ b/xc/extras/Mesa/src/vbcull.c
@@ -92,7 +92,7 @@ static GLuint gl_cull_points( struct vertex_buffer *VB,
/* This is pretty pointless. (arf arf)
*/
- for (i=start+1;i<count;i++) {
+ for (i = start; i < count; i++) {
if (clipmask[i] == 0)
cullmask[i] = VERT_FACE_FRONT | PRIM_FACE_FRONT;
else {
@@ -783,6 +783,7 @@ void gl_purge_vertices( struct vertex_buffer *VB )
#define VERT_NOT_CLIPPED 0x80
+
static void build_clip_vert_bits( GLubyte *clipmask, const GLubyte *cullmask,
GLuint count )
{
@@ -842,7 +843,6 @@ GLuint gl_cull_vb( struct vertex_buffer *VB )
cullcount += n;
}
-
if (VB->LastPrimitive < VB->Count) {
if (copy_tab_cull[lastprim])
cullcount -= copy_tab_cull[prim]( VB,
@@ -862,8 +862,8 @@ GLuint gl_cull_vb( struct vertex_buffer *VB )
if (cullcount < VB->Count)
build_clip_vert_bits( VB->ClipMask, VB->CullMask, VB->Count );
-
}
+
if (VB->ClipOrMask) {
VB->CullMode |= CLIP_MASK_ACTIVE;
VB->CullFlag[1] |= (CLIP_ALL_BITS|CLIP_USER_BIT) & ctx->AllowVertexCull;
diff --git a/xc/extras/Mesa/src/vbfill.c b/xc/extras/Mesa/src/vbfill.c
index 4ee9d52a3..50d5806d5 100644
--- a/xc/extras/Mesa/src/vbfill.c
+++ b/xc/extras/Mesa/src/vbfill.c
@@ -693,6 +693,20 @@ _mesa_Indexubv( const GLubyte *c )
ASSIGN_3V(normal, x,y,z); \
}
+#if defined(USE_IEEE)
+#define NORMALF( x, y, z ) \
+{ \
+ GLuint count; \
+ GLint *normal; \
+ GET_IMMEDIATE; \
+ count = IM->Count; \
+ IM->Flag[count] |= VERT_NORM; \
+ normal = (GLint *)IM->Normal[count]; \
+ ASSIGN_3V(normal, *(int*)&(x), *(int*)&(y), *(int*)&(z)); \
+}
+#else
+#define NORMALF NORMAL
+#endif
void
_mesa_Normal3b( GLbyte nx, GLbyte ny, GLbyte nz )
@@ -711,7 +725,7 @@ _mesa_Normal3d( GLdouble nx, GLdouble ny, GLdouble nz )
void
_mesa_Normal3f( GLfloat nx, GLfloat ny, GLfloat nz )
{
- NORMAL(nx, ny, nz);
+ NORMALF(nx, ny, nz);
}
@@ -746,7 +760,7 @@ _mesa_Normal3dv( const GLdouble *v )
void
_mesa_Normal3fv( const GLfloat *v )
{
- NORMAL( v[0], v[1], v[2] );
+ NORMALF( v[0], v[1], v[2] );
}
@@ -811,6 +825,23 @@ _mesa_Normal3sv( const GLshort *v )
ASSIGN_4V(tc, s,t,u,v); \
}
+#if defined(USE_IEEE)
+#define TEXCOORD2F(s,t) \
+{ \
+ GLuint count; \
+ GLint *tc; \
+ GET_IMMEDIATE; \
+ count = IM->Count; \
+ IM->Flag[count] |= VERT_TEX0_12; \
+ tc = (GLint *)IM->TexCoord[0][count]; \
+ *tc = *(int *)&(s); \
+ *(tc+1) = *(int *)&(t); \
+ *(tc+2) = 0; \
+ *(tc+3) = IEEE_ONE; \
+}
+#else
+#define TEXCOORD2F TEXCOORD2
+#endif
void
_mesa_TexCoord1d( GLdouble s )
@@ -850,7 +881,7 @@ _mesa_TexCoord2d( GLdouble s, GLdouble t )
void
_mesa_TexCoord2f( GLfloat s, GLfloat t )
{
- TEXCOORD2(*(&s),*&t);
+ TEXCOORD2F(s,t);
}
@@ -962,7 +993,7 @@ _mesa_TexCoord2dv( const GLdouble *v )
void
_mesa_TexCoord2fv( const GLfloat *v )
{
- TEXCOORD2(v[0],v[1]);
+ TEXCOORD2F(v[0],v[1]);
}
@@ -1072,6 +1103,22 @@ _mesa_TexCoord4sv( const GLshort *v )
IM->maybe_transform_vb( IM ); \
}
+#if defined(USE_IEEE)
+#define VERTEX3F(IM,x,y,z) \
+{ \
+ GLuint count = IM->Count++; \
+ GLint *dest = (GLint *)IM->Obj[count]; \
+ IM->Flag[count] |= VERT_OBJ_23; \
+ dest[0] = *(int *)&(x); \
+ dest[1] = *(int *)&(y); \
+ dest[2] = *(int *)&(z); \
+ dest[3] = IEEE_ONE; \
+ if (dest == (GLint *)IM->Obj[VB_MAX-1]) \
+ IM->maybe_transform_vb( IM ); \
+}
+#else
+#define VERTEX3F VERTEX3
+#endif
void
_mesa_Vertex2d( GLdouble x, GLdouble y )
@@ -1127,7 +1174,7 @@ void
_mesa_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
{
GET_IMMEDIATE;
- VERTEX3( IM, *(&x), *(&y), *(&z) );
+ VERTEX3F( IM, x, y, z );
}
@@ -1159,7 +1206,7 @@ void
_mesa_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
GET_IMMEDIATE;
- VERTEX4( IM, *(&x), *(&y), *(&z), *(&w) );
+ VERTEX4( IM, x, y, z, w );
}
@@ -1223,7 +1270,7 @@ void
_mesa_Vertex3fv( const GLfloat *v )
{
GET_IMMEDIATE;
- VERTEX3( IM, v[0], v[1], v[2] );
+ VERTEX3F( IM, v[0], v[1], v[2] );
}
@@ -1347,6 +1394,22 @@ _mesa_Vertex4sv( const GLshort *v )
ASSIGN_4V(tc, s,t,u,v); \
}
+#if defined(USE_IEEE)
+#define MULTI_TEXCOORD2F(s,t) \
+{ \
+ GLuint count; \
+ GLint *tc; \
+ count = IM->Count; \
+ IM->Flag[count] |= IM->TF2[texSet]; \
+ tc = (GLint *)IM->TexCoord[texSet][count]; \
+ tc[0] = *(int *)&(s); \
+ tc[1] = *(int *)&(t); \
+ tc[2] = 0; \
+ tc[3] = IEEE_ONE; \
+}
+#else
+#define MULTI_TEXCOORD2F MULTI_TEXCOORD2
+#endif
void
_mesa_MultiTexCoord1dARB(GLenum target, GLdouble s)
@@ -1444,7 +1507,7 @@ _mesa_MultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
GLint texSet;
GET_IMMEDIATE;
CHECK_ARB
- MULTI_TEXCOORD2( s, t );
+ MULTI_TEXCOORD2F( s, t );
}
void
@@ -1453,7 +1516,7 @@ _mesa_MultiTexCoord2fvARB(GLenum target, const GLfloat *v)
GLint texSet;
GET_IMMEDIATE;
CHECK_ARB
- MULTI_TEXCOORD2( v[0], v[1] );
+ MULTI_TEXCOORD2F( v[0], v[1] );
}
void
diff --git a/xc/extras/Mesa/src/vbrender.c b/xc/extras/Mesa/src/vbrender.c
index 9ee4fbb8c..5391ff186 100644
--- a/xc/extras/Mesa/src/vbrender.c
+++ b/xc/extras/Mesa/src/vbrender.c
@@ -100,20 +100,14 @@ static INLINE void gl_render_clipped_line2( GLcontext *ctx,
static void offset_polygon( GLcontext *ctx, GLfloat a, GLfloat b, GLfloat c )
{
GLfloat ac, bc, m;
- GLfloat offset;
+ GLfloat offset = 0.0F;
- if (c<0.001F && c>-0.001F) {
- /* to prevent underflow problems */
- offset = 0.0F;
- }
- else {
+ if (c*c > 1e-16) {
ac = a / c;
bc = b / c;
if (ac<0.0F) ac = -ac;
if (bc<0.0F) bc = -bc;
m = MAX2( ac, bc );
- /* m = sqrt( ac*ac + bc*bc ); */
-
offset = m * ctx->Polygon.OffsetFactor + ctx->Polygon.OffsetUnits;
}
@@ -125,10 +119,17 @@ static void offset_polygon( GLcontext *ctx, GLfloat a, GLfloat b, GLfloat c )
#define FLUSH_PRIM(prim) \
do { \
if (ctx->PB->primitive != prim) { \
- gl_reduced_prim_change( ctx, prim ); \
+ gl_reduced_prim_change( ctx, prim ); \
} \
} while(0)
+#define FLUSH_POLY(prim) \
+do { \
+ if ((ctx->IndirectTriangles & DD_TRI_UNFILLED) == 0) { \
+ FLUSH_PRIM(prim); \
+ } \
+} while(0)
+
/*
* When glPolygonMode() is used to specify that the front/back rendering
@@ -156,7 +157,6 @@ static void unfilled_polygon( GLcontext *ctx,
}
else if (mode==GL_LINE) {
GLuint i, j0, j1;
- ctx->StippleCounter = 0;
/* draw the edges */
for (i=0;i<n-1;i++) {
@@ -292,7 +292,7 @@ static void render_triangle( GLcontext *ctx,
return;
facing = (c<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW);
- tricaps = ctx->IndirectTriangles;
+ tricaps = ctx->TriangleCaps;
if (tricaps & DD_TRI_OFFSET) {
/* finish computing plane equation of polygon, compute offset */
@@ -319,6 +319,13 @@ static void render_triangle( GLcontext *ctx,
else {
(*ctx->Driver.TriangleFunc)( ctx, v0, v1, v2, pv );
}
+
+ if (tricaps & DD_TRI_OFFSET) {
+ /* reset Z offsets now */
+ ctx->PointZoffset = 0.0;
+ ctx->LineZoffset = 0.0;
+ ctx->PolygonZoffset = 0.0;
+ }
}
@@ -342,7 +349,7 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1,
GLfloat fy = win[v3][1] - win[v1][1];
GLfloat c = ex*fy-ey*fx;
GLuint facing;
- GLuint tricaps = ctx->IndirectTriangles;
+ GLuint tricaps = ctx->TriangleCaps;
if (c * ctx->backface_sign > 0)
return;
@@ -377,6 +384,13 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1,
else {
(*ctx->Driver.QuadFunc)( ctx, v0, v1, v2, v3, pv );
}
+
+ if (tricaps & DD_TRI_OFFSET) {
+ /* reset Z offsets now */
+ ctx->PointZoffset = 0.0;
+ ctx->LineZoffset = 0.0;
+ ctx->PolygonZoffset = 0.0;
+ }
}
@@ -415,15 +429,16 @@ do { \
#define EDGEFLAG_POLY_TRI_PRE( i2, i1, i, pv) \
do { \
+ eflag[i2] |= (eflag[i2] >> 2) & 1; \
eflag[i1] |= (eflag[i1] >> 2) & 1; \
eflag[i] |= (eflag[i] >> 2) & 2; \
} while (0)
#define EDGEFLAG_POLY_TRI_POST( i2, i1, i, pv) \
do { \
- eflag[i2] = 0; \
+ eflag[i2] &= ~(4|1); \
eflag[i1] &= ~(4|1); \
- eflag[i] &= ~(8|2); \
+ eflag[i] &= ~(8|2); \
} while (0)
@@ -503,7 +518,7 @@ do { \
(void) vlist; (void) eflag; (void) stipplecounter;
#define TAG(x) x##_cull
-#define INIT(x) FLUSH_PRIM(x)
+#define INIT(x) if (x == GL_POLYGON) FLUSH_POLY(x); else FLUSH_PRIM(x)
#define RESET_STIPPLE *stipplecounter = 0
#include "render_tmp.h"
@@ -541,7 +556,7 @@ do { \
GLuint *stipplecounter = &VB->ctx->StippleCounter; \
(void) eflag; (void) stipplecounter;
-#define INIT(x) FLUSH_PRIM(x);
+#define INIT(x) if (x == GL_POLYGON) FLUSH_POLY(x); else FLUSH_PRIM(x)
#define RESET_STIPPLE *stipplecounter = 0
#include "render_tmp.h"
@@ -575,7 +590,7 @@ do { \
GLuint *stipplecounter = &VB->ctx->StippleCounter; \
(void) eflag; (void) stipplecounter;
-#define INIT(x) FLUSH_PRIM(x);
+#define INIT(x) if (x == GL_POLYGON) FLUSH_POLY(x); else FLUSH_PRIM(x)
#define TAG(x) x##_clipped
#define RESET_STIPPLE *stipplecounter = 0
@@ -633,9 +648,9 @@ setup_edgeflag( struct vertex_buffer *VB,
case GL_POLYGON:
if (flag[0]) flag[0] = 0x1;
for (i = 1 ; i < n-1 ; i++) {
- if (flag[i]) flag[i] = 0x1<<2;
+ if (flag[i]) flag[i] = 0x4;
}
- if (flag[i]) flag[i] = 0x3<<2;
+ if (flag[i]) flag[i] = 0x8;
break;
default:
break;
diff --git a/xc/extras/Mesa/src/vector.c b/xc/extras/Mesa/src/vector.c
index b63b8df69..954a4235a 100644
--- a/xc/extras/Mesa/src/vector.c
+++ b/xc/extras/Mesa/src/vector.c
@@ -68,6 +68,8 @@ static const GLubyte size_bits[5] = {
VEC_SIZE_4,
};
+
+
void gl_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
{
v->stride = 4*sizeof(GLfloat);
@@ -78,7 +80,6 @@ void gl_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
v->flags = size_bits[4] | flags | VEC_GOOD_STRIDE;
}
-
void gl_vector3f_init( GLvector3f *v, GLuint flags, GLfloat (*storage)[3] )
{
v->stride = 3*sizeof(GLfloat);
@@ -116,13 +117,6 @@ void gl_vector1ui_init( GLvector1ui *v, GLuint flags, GLuint *storage )
}
-#define ALIGN_MALLOC(vec, type, bytes, alignment) \
-do { \
- vec->storage = MALLOC( bytes + alignment - 1 ); \
- vec->start = type (((unsigned long)vec->storage + alignment - 1) \
- & ~(unsigned long)(alignment - 1)); \
-} while (0)
-
void gl_vector4f_alloc( GLvector4f *v, GLuint sz, GLuint flags, GLuint count,
GLuint alignment )
@@ -130,18 +124,19 @@ void gl_vector4f_alloc( GLvector4f *v, GLuint sz, GLuint flags, GLuint count,
(void) sz;
v->stride = 4*sizeof(GLfloat);
v->size = 2;
- ALIGN_MALLOC(v, (GLfloat *), count * 4 * sizeof(GLfloat), alignment);
+ v->storage = v->start = (GLfloat *)
+ ALIGN_MALLOC( count * 4 * sizeof(GLfloat), alignment );
v->data = (GLfloat (*)[4])v->start;
v->count = 0;
v->flags = size_bits[4] | flags | VEC_MALLOC | VEC_GOOD_STRIDE;
}
-
void gl_vector3f_alloc( GLvector3f *v, GLuint flags, GLuint count,
GLuint alignment )
{
v->stride = 3*sizeof(GLfloat);
- ALIGN_MALLOC(v, (GLfloat *), count * 3 * sizeof(GLfloat), alignment);
+ v->storage = v->start = (GLfloat *)
+ ALIGN_MALLOC( count * 3 * sizeof(GLfloat), alignment );
v->data = (GLfloat (*)[3])v->start;
v->count = 0;
v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
@@ -151,7 +146,8 @@ void gl_vector4ub_alloc( GLvector4ub *v, GLuint flags, GLuint count,
GLuint alignment )
{
v->stride = 4*sizeof(GLubyte);
- ALIGN_MALLOC(v, (GLubyte *), count * 4 * sizeof(GLubyte), alignment);
+ v->storage = v->start = (GLubyte *)
+ ALIGN_MALLOC( count * 4 * sizeof(GLubyte), alignment );
v->data = (GLubyte (*)[4])v->start;
v->count = 0;
v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
@@ -161,7 +157,8 @@ void gl_vector1ub_alloc( GLvector1ub *v, GLuint flags, GLuint count,
GLuint alignment )
{
v->stride = 1*sizeof(GLubyte);
- ALIGN_MALLOC(v, (GLubyte *), count * sizeof(GLubyte), alignment);
+ v->storage = v->start = (GLubyte *)
+ ALIGN_MALLOC( count * sizeof(GLubyte), alignment );
v->data = v->start;
v->count = 0;
v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
@@ -171,7 +168,8 @@ void gl_vector1ui_alloc( GLvector1ui *v, GLuint flags, GLuint count,
GLuint alignment )
{
v->stride = 1*sizeof(GLuint);
- ALIGN_MALLOC(v, (GLuint *), count * sizeof(GLuint), alignment);
+ v->storage = v->start = (GLuint *)
+ ALIGN_MALLOC( count * sizeof(GLuint), alignment );
v->data = v->start;
v->count = 0;
v->flags = flags | VEC_MALLOC | VEC_GOOD_STRIDE;
@@ -182,7 +180,7 @@ void gl_vector1ui_alloc( GLvector1ui *v, GLuint flags, GLuint count,
void gl_vector4f_free( GLvector4f *v )
{
if (v->flags & VEC_MALLOC) {
- FREE( v->storage );
+ ALIGN_FREE( v->storage );
v->data = 0;
v->start = 0;
v->storage = 0;
@@ -193,7 +191,7 @@ void gl_vector4f_free( GLvector4f *v )
void gl_vector3f_free( GLvector3f *v )
{
if (v->flags & VEC_MALLOC) {
- FREE( v->storage );
+ ALIGN_FREE( v->storage );
v->data = 0;
v->start = 0;
v->storage = 0;
@@ -204,7 +202,7 @@ void gl_vector3f_free( GLvector3f *v )
void gl_vector4ub_free( GLvector4ub *v )
{
if (v->flags & VEC_MALLOC) {
- FREE( v->storage );
+ ALIGN_FREE( v->storage );
v->data = 0;
v->start = 0;
v->storage = 0;
@@ -215,7 +213,7 @@ void gl_vector4ub_free( GLvector4ub *v )
void gl_vector1ub_free( GLvector1ub *v )
{
if (v->flags & VEC_MALLOC) {
- FREE( v->storage );
+ ALIGN_FREE( v->storage );
v->data = 0;
v->start = 0;
v->storage = 0;
@@ -226,7 +224,7 @@ void gl_vector1ub_free( GLvector1ub *v )
void gl_vector1ui_free( GLvector1ui *v )
{
if (v->flags & VEC_MALLOC) {
- FREE( v->storage );
+ ALIGN_FREE( v->storage );
v->data = 0;
v->start = 0;
v->storage = 0;
@@ -234,6 +232,8 @@ void gl_vector1ui_free( GLvector1ui *v )
}
}
+
+
void gl_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
{
GLfloat c[4] = { 0, 0, 0, 1 };
@@ -282,7 +282,6 @@ void gl_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
}
}
-
void gl_vector3f_print( GLvector3f *v, GLubyte *cullmask, GLboolean culling )
{
GLfloat *d = (GLfloat *)v->data;
diff --git a/xc/extras/Mesa/src/xform.h b/xc/extras/Mesa/src/xform.h
index d8757b803..2f8843815 100644
--- a/xc/extras/Mesa/src/xform.h
+++ b/xc/extras/Mesa/src/xform.h
@@ -134,7 +134,7 @@ typedef void (*vec_copy_func)( GLvector4f *to,
* parameter, to allow a unified interface.
*/
typedef void (_XFORMAPIP transform_func)( GLvector4f *to_vec,
- const GLmatrix *mat,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *clipmask,
const GLubyte flag );
@@ -144,11 +144,11 @@ extern GLvector4f *gl_project_points( GLvector4f *to,
const GLvector4f *from );
extern void gl_transform_bounds3( GLubyte *orMask, GLubyte *andMask,
- const GLmatrix *mat,
+ const GLfloat m[16],
CONST GLfloat src[][3] );
extern void gl_transform_bounds2( GLubyte *orMask, GLubyte *andMask,
- const GLmatrix *mat,
+ const GLfloat m[16],
CONST GLfloat src[][3] );
@@ -168,11 +168,11 @@ extern void gl_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
#define TransformRaw( to, mat, from ) \
- ( (*gl_transform_tab[0][(from)->size][(mat)->type])( to, mat, from, 0, 0 ), \
+ ( (*gl_transform_tab[0][(from)->size][(mat)->type])( to, (mat)->m, from, 0, 0 ), \
(to) )
#define Transform( to, mat, from, mask, cull ) \
- ( (*gl_transform_tab[cull!=0][(from)->size][(mat)->type])( to, mat, from, mask, cull ), \
+ ( (*gl_transform_tab[cull!=0][(from)->size][(mat)->type])( to, (mat)->m, from, mask, cull ), \
(to) )
diff --git a/xc/extras/Mesa/src/xform_tmp.h b/xc/extras/Mesa/src/xform_tmp.h
index 2e796aac1..aacbee841 100644
--- a/xc/extras/Mesa/src/xform_tmp.h
+++ b/xc/extras/Mesa/src/xform_tmp.h
@@ -64,8 +64,9 @@
* cliped and/or culled vertices.
*/
-static void _XFORMAPI TAG(transform_points1_general)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -74,7 +75,6 @@ static void _XFORMAPI TAG(transform_points1_general)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m12 = m[12];
const GLfloat m1 = m[1], m13 = m[13];
const GLfloat m2 = m[2], m14 = m[14];
@@ -97,8 +97,9 @@ static void _XFORMAPI TAG(transform_points1_general)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points1_identity)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -108,10 +109,8 @@ static void _XFORMAPI TAG(transform_points1_identity)( GLvector4f *to_vec,
GLuint count = from_vec->count;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint i;
- (void) mat;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_IDENTITY);
if (to_vec == from_vec) return;
STRIDE_LOOP {
CLIP_CHECK {
@@ -124,8 +123,9 @@ static void _XFORMAPI TAG(transform_points1_identity)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points1_2d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -134,13 +134,11 @@ static void _XFORMAPI TAG(transform_points1_2d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1];
const GLfloat m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0];
@@ -153,8 +151,9 @@ static void _XFORMAPI TAG(transform_points1_2d)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -163,12 +162,10 @@ static void _XFORMAPI TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0];
@@ -182,8 +179,9 @@ static void _XFORMAPI TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points1_3d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -192,13 +190,11 @@ static void _XFORMAPI TAG(transform_points1_3d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2];
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0];
@@ -213,8 +209,9 @@ static void _XFORMAPI TAG(transform_points1_3d)( GLvector4f *to_vec,
}
-static void _XFORMAPI TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -223,13 +220,11 @@ static void _XFORMAPI TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0];
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0];
@@ -243,8 +238,9 @@ static void _XFORMAPI TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points1_perspective)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points1_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -253,12 +249,10 @@ static void _XFORMAPI TAG(transform_points1_perspective)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_PERSPECTIVE);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0];
@@ -280,8 +274,9 @@ static void _XFORMAPI TAG(transform_points1_perspective)( GLvector4f *to_vec,
* present early in the geometry pipeline and throughout the
* texture pipeline.
*/
-static void _XFORMAPI TAG(transform_points2_general)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -290,7 +285,6 @@ static void _XFORMAPI TAG(transform_points2_general)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m4 = m[4], m12 = m[12];
const GLfloat m1 = m[1], m5 = m[5], m13 = m[13];
const GLfloat m2 = m[2], m6 = m[6], m14 = m[14];
@@ -312,8 +306,9 @@ static void _XFORMAPI TAG(transform_points2_general)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points2_identity)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -323,10 +318,8 @@ static void _XFORMAPI TAG(transform_points2_identity)( GLvector4f *to_vec,
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
GLuint i;
- (void) mat;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_IDENTITY);
if (to_vec == from_vec) return;
STRIDE_LOOP {
CLIP_CHECK {
@@ -339,8 +332,9 @@ static void _XFORMAPI TAG(transform_points2_identity)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points2_2d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -349,13 +343,11 @@ static void _XFORMAPI TAG(transform_points2_2d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
const GLfloat m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1];
@@ -369,8 +361,9 @@ static void _XFORMAPI TAG(transform_points2_2d)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -379,12 +372,10 @@ static void _XFORMAPI TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1];
@@ -398,8 +389,9 @@ static void _XFORMAPI TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points2_3d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -408,13 +400,11 @@ static void _XFORMAPI TAG(transform_points2_3d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1];
@@ -432,8 +422,9 @@ static void _XFORMAPI TAG(transform_points2_3d)( GLvector4f *to_vec,
/* I would actually say this was a fairly important function, from
* a texture transformation point of view.
*/
-static void _XFORMAPI TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -442,13 +433,11 @@ static void _XFORMAPI TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5];
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1];
@@ -471,8 +460,9 @@ static void _XFORMAPI TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
* code. It's also hard to remove any of these functions if you are
* attached to the assertions that have appeared in them.
*/
-static void _XFORMAPI TAG(transform_points2_perspective)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points2_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -481,12 +471,10 @@ static void _XFORMAPI TAG(transform_points2_perspective)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_PERSPECTIVE);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1];
@@ -503,8 +491,9 @@ static void _XFORMAPI TAG(transform_points2_perspective)( GLvector4f *to_vec,
-static void _XFORMAPI TAG(transform_points3_general)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -513,7 +502,6 @@ static void _XFORMAPI TAG(transform_points3_general)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
@@ -521,7 +509,6 @@ static void _XFORMAPI TAG(transform_points3_general)( GLvector4f *to_vec,
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_GENERAL);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2];
@@ -536,8 +523,9 @@ static void _XFORMAPI TAG(transform_points3_general)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points3_identity)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -547,10 +535,8 @@ static void _XFORMAPI TAG(transform_points3_identity)( GLvector4f *to_vec,
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
GLuint i;
- (void) mat;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_IDENTITY);
if (to_vec == from_vec) return;
STRIDE_LOOP {
CLIP_CHECK {
@@ -564,8 +550,9 @@ static void _XFORMAPI TAG(transform_points3_identity)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points3_2d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -574,13 +561,11 @@ static void _XFORMAPI TAG(transform_points3_2d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
const GLfloat m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2];
@@ -594,8 +579,9 @@ static void _XFORMAPI TAG(transform_points3_2d)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -604,12 +590,10 @@ static void _XFORMAPI TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2];
@@ -623,8 +607,9 @@ static void _XFORMAPI TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points3_3d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -633,14 +618,12 @@ static void _XFORMAPI TAG(transform_points3_3d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2];
@@ -656,8 +639,9 @@ static void _XFORMAPI TAG(transform_points3_3d)( GLvector4f *to_vec,
/* previously known as ortho...
*/
-static void _XFORMAPI TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -666,13 +650,11 @@ static void _XFORMAPI TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5];
const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2];
@@ -686,8 +668,9 @@ static void _XFORMAPI TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points3_perspective)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points3_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -696,13 +679,11 @@ static void _XFORMAPI TAG(transform_points3_perspective)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
const GLfloat m10 = m[10], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_PERSPECTIVE);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2];
@@ -719,8 +700,9 @@ static void _XFORMAPI TAG(transform_points3_perspective)( GLvector4f *to_vec,
-static void _XFORMAPI TAG(transform_points4_general)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -729,7 +711,6 @@ static void _XFORMAPI TAG(transform_points4_general)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
@@ -737,7 +718,6 @@ static void _XFORMAPI TAG(transform_points4_general)( GLvector4f *to_vec,
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_GENERAL);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
@@ -752,8 +732,9 @@ static void _XFORMAPI TAG(transform_points4_general)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points4_identity)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -763,10 +744,8 @@ static void _XFORMAPI TAG(transform_points4_identity)( GLvector4f *to_vec,
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
GLuint i;
- (void) mat;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_IDENTITY);
if (to_vec == from_vec) return;
STRIDE_LOOP {
CLIP_CHECK {
@@ -781,8 +760,9 @@ static void _XFORMAPI TAG(transform_points4_identity)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points4_2d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -791,13 +771,11 @@ static void _XFORMAPI TAG(transform_points4_2d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
const GLfloat m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
@@ -812,8 +790,9 @@ static void _XFORMAPI TAG(transform_points4_2d)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -822,12 +801,10 @@ static void _XFORMAPI TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_2D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
@@ -842,8 +819,9 @@ static void _XFORMAPI TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points4_3d)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -852,14 +830,12 @@ static void _XFORMAPI TAG(transform_points4_3d)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
@@ -874,8 +850,9 @@ static void _XFORMAPI TAG(transform_points4_3d)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -884,13 +861,11 @@ static void _XFORMAPI TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5];
const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_3D_NO_ROT);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
@@ -905,8 +880,9 @@ static void _XFORMAPI TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
to_vec->count = from_vec->count;
}
-static void _XFORMAPI TAG(transform_points4_perspective)( GLvector4f *to_vec,
- const GLmatrix *mat,
+static void _XFORMAPI
+TAG(transform_points4_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
const GLvector4f *from_vec,
const GLubyte *mask,
const GLubyte flag )
@@ -915,13 +891,11 @@ static void _XFORMAPI TAG(transform_points4_perspective)( GLvector4f *to_vec,
GLfloat *from = from_vec->start;
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
GLuint count = from_vec->count;
- const GLfloat *m = mat->m;
const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
const GLfloat m10 = m[10], m14 = m[14];
GLuint i;
(void) mask;
(void) flag;
- ASSERT(mat->type == MATRIX_PERSPECTIVE);
STRIDE_LOOP {
CLIP_CHECK {
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];