From b16b9e4656e7199c2aec74a4c8ebc7a875d3ba73 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 2 Feb 2015 15:02:49 +0100 Subject: massive reduction of unneeded files --- nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS | 64 - .../extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile | 37 - .../mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S | 84 - .../mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h | 314 --- .../Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h | 60 - .../src/mesa/drivers/dri/tdfx/server/tdfx_dri.c | 471 ----- .../src/mesa/drivers/dri/tdfx/server/tdfx_dri.h | 28 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c | 1028 --------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h | 1007 --------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c | 322 --- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h | 45 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h | 606 ------ .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c | 90 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h | 144 -- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c | 689 ------ .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h | 77 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c | 808 ------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h | 50 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c | 492 ----- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h | 73 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c | 1427 ------------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h | 49 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c | 1449 ------------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h | 61 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c | 1914 ----------------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h | 102 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c | 994 --------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h | 84 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c | 2209 -------------------- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h | 44 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c | 1293 ------------ .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h | 42 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c | 353 ---- .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h | 69 - .../Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h | 266 --- 35 files changed, 16845 deletions(-) delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h delete mode 100644 nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h (limited to 'nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx') diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS deleted file mode 100644 index b15f6a91e..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS +++ /dev/null @@ -1,64 +0,0 @@ -REMOVE THIS FILE BEFORE MERGING WITH TRUNK ------------------------------------------- - -OUTSTANDING BUGS - -demos/reflect - reading back Z on Voodoo3, image offset to right - Fixed in latest Glide. - -Q3 - some polygons drawn as vertical strips, similar to bug that was - seen in demos/fire. Voodoo3 only. May be related to glDepthMask - or glColorMask. - -book/fog - not fogging - Fog in orthograph mode still not implemented. Checking with - 3dfx engineers for ideas. - -Q3 demo crashes after changing display settings - but the full Q3 game version seems OK. - - - -MORE OUTSTANDING BUGS - -private context was NULL! causing immediate failure of any glx prog. cant -reproduce after restarting the X server. putting it down as halluc. - -texture object image was NULL, causing segmentation failure. happens with -prboom. ive put a check in tdfx_texstate.c but this isn't a fix. - -prboom, wall textures near first chainsaw aren't bound properly. sideways -movements causes the wall textures to move with you. prboom busted? - -16bpp mode, quake3, windowed, q3dm1, floor under rocketlauncher bands. it -looks like multitexturing gone wrong. i'll disable a tmu and test. - -sof, polygons appear at wrong x,y,z positions, intermittent, have not yet -found reliable way of reproducing. culling? sometimes polys disappear. - -descent3 is all black in 16bpp mode - FIXED (palette problems) - -smeared pixels in quake3 - FIXED (texture memory overlapped FB) - - - -PERFORMANCE COMPARISON (Brian / Alan) - - V3/16 is Voodoo3 in 16bpp on a P3/500 - V5/16 is Voodoo5 in 16bpp on a P3/600 - V5/32 is Voodoo5 in 32bpp on a P3/600 - V5A/16 is Voodoo5 in 16bpp on an Alpha AXP/600 - V5A/32 is Voodoo5 in 32bpp on an Alpha AXP/600 - - tdfx-2-1-branch tdfx-3-0-0-branch -demo V3/16 V5/16 V5/32 V3/16 V5/16 V5/32 V5A/16 V5A/32 ------------------------------------------------------------------------- -gloss 257 183 174 320 308 177 313 167 -fire 42 39 52 41 -fire (no help) 98 80 50 106 113 73 124 80 -tunnel 61 50 70 58 -tunnel (no help) 167 142 57 138 152 113 171 122 -gears 663 554 540 881 1232 776 1484 830 -teapot 20 21 37 36 -teapot (no help) 22 14 14 24 30 30 43 42 - diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile deleted file mode 100644 index 092c580fe..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# src/mesa/drivers/dri/tdfx/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = tdfx_dri.so - -# not yet -# MINIGLX_SOURCES = server/tdfx_dri.c - -DRIVER_SOURCES = \ - tdfx_context.c \ - tdfx_dd.c \ - tdfx_lock.c \ - tdfx_pixels.c \ - tdfx_render.c \ - tdfx_screen.c \ - tdfx_span.c \ - tdfx_state.c \ - tdfx_tex.c \ - tdfx_texman.c \ - tdfx_texstate.c \ - tdfx_tris.c \ - tdfx_vb.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - - -ASM_SOURCES = - -include ../Makefile.template - -symlinks: - - diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S deleted file mode 100644 index 0f4cc4508..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S +++ /dev/null @@ -1,84 +0,0 @@ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fastpath.S,v 1.2 2000/09/26 15:56:51 tsi Exp $ */ - -#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/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h deleted file mode 100644 index 9ec4935d7..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h +++ /dev/null @@ -1,314 +0,0 @@ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h,v 1.2 2000/09/26 15:56:51 tsi Exp $ */ - -#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/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h deleted file mode 100644 index 52a53f7dd..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/dri_glide.h,v 1.1 2001/03/21 16:14:26 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#ifndef __DRI_GLIDE_H__ -#define __DRI_GLIDE_H__ - -#include -#include "dri_mesaint.h" - -/* - * This is the private interface between Glide and the DRI. - */ -extern void grDRIOpen( char *pFB, char *pRegs, int deviceID, - int width, int height, - int mem, int cpp, int stride, - int fifoOffset, int fifoSize, - int fbOffset, int backOffset, int depthOffset, - int textureOffset, int textureSize, - volatile int *fifoPtr, volatile int *fifoRead ); -extern void grDRIPosition( int x, int y, int w, int h, - int numClip, drm_clip_rect_t *pClip ); -extern void grDRILostContext( void ); -extern void grDRIImportFifo( int fifoPtr, int fifoRead ); -extern void grDRIInvalidateAll( void ); -extern void grDRIResetSAREA( void ); -extern void grDRIBufferSwap( FxU32 swapInterval ); -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c deleted file mode 100644 index 63fe875f5..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Authors: - * Keith Whitwell - * Daniel Borca - */ - - -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" -#include "imports.h" - -#include "dri_util.h" - -#include "tdfx_context.h" -#include "tdfx_dri.h" -#include "xf86drm.h" - - -#define TILE_WIDTH 128 -#define TILE_HEIGHT 32 - -#define CMDFIFO_PAGES 64 - - -static int -calcBufferStride (int xres, int tiled, int cpp) -{ - int strideInTiles; - - if (tiled) { - /* Calculate tile width stuff */ - strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH; - - return strideInTiles*cpp*TILE_WIDTH; - } else { - return xres*cpp; - } -} /* calcBufferStride */ - - -static int -calcBufferHeightInTiles (int yres) -{ - int heightInTiles; /* Height of buffer in tiles */ - - /* Calculate tile height stuff */ - heightInTiles = yres >> 5; - - if (yres & (TILE_HEIGHT - 1)) - heightInTiles++; - - return heightInTiles; - -} /* calcBufferHeightInTiles */ - - -static int -calcBufferSize (int xres, int yres, int tiled, int cpp) -{ - int stride, height, bufSize; - - if (tiled) { - stride = calcBufferStride(xres, tiled, cpp); - height = TILE_HEIGHT * calcBufferHeightInTiles(yres); - } else { - stride = xres*cpp; - height = yres; - } - - bufSize = stride * height; - - return bufSize; -} /* calcBufferSize */ - - -static void allocateMemory (const DRIDriverContext *ctx, TDFXDRIPtr pTDFX) -{ - int memRemaining, fifoSize, screenSizeInTiles; - int fbSize; - char *str; - int pixmapCacheLinesMin; - int cursorOffset, cursorSize; - - pTDFX->stride = calcBufferStride(pTDFX->width, !0, pTDFX->cpp); - - /* enough to do DVD */ - pixmapCacheLinesMin = ((720*480*pTDFX->cpp) + - pTDFX->stride - 1)/pTDFX->stride; - - if (pTDFX->deviceID > PCI_CHIP_VOODOO3) { - if ((pixmapCacheLinesMin + pTDFX->height) > 4095) - pixmapCacheLinesMin = 4095 - pTDFX->height; - } else { - if ((pixmapCacheLinesMin + pTDFX->height) > 2047) - pixmapCacheLinesMin = 2047 - pTDFX->height; - } - - if (pTDFX->cpp!=3) { - screenSizeInTiles=calcBufferSize(pTDFX->width, pTDFX->height, - !0, pTDFX->cpp); - } - else { - /* cpp==3 needs to bump up to 4 */ - screenSizeInTiles=calcBufferSize(pTDFX->width, pTDFX->height, - !0, 4); - } - - /* - * Layout is: - * cursor, fifo, fb, tex, bb, db - */ - - fbSize = (pTDFX->height + pixmapCacheLinesMin) * pTDFX->stride; - - memRemaining=(pTDFX->mem - 1) &~ 0xFFF; - /* Note that a page is 4096 bytes, and a */ - /* tile is 32 x 128 = 4096 bytes. So, */ - /* page and tile boundaries are the same */ - /* Place the depth offset first, forcing */ - /* it to be on an *odd* page boundary. */ - pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF; - if ((pTDFX->depthOffset & (0x1 << 12)) == 0) { - pTDFX->depthOffset -= (0x1 << 12); - } - /* Now, place the back buffer, forcing it */ - /* to be on an *even* page boundary. */ - pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF; - if (pTDFX->backOffset & (0x1 << 12)) { - pTDFX->backOffset -= (0x1 << 12); - } - /* Give the cmd fifo at least */ - /* CMDFIFO_PAGES pages, but no more than */ - /* 64. NOTE: Don't go higher than 64, as */ - /* there is suspect code in Glide3 ! */ - fifoSize = ((64 <= CMDFIFO_PAGES) ? 64 : CMDFIFO_PAGES) << 12; - - /* We give 4096 bytes to the cursor */ - cursorSize = 0/*4096*/; - cursorOffset = 0; - - pTDFX->fifoOffset = cursorOffset + cursorSize; - pTDFX->fifoSize = fifoSize; - /* Now, place the front buffer, forcing */ - /* it to be on a page boundary too, just */ - /* for giggles. */ - pTDFX->fbOffset = pTDFX->fifoOffset + pTDFX->fifoSize; - pTDFX->textureOffset = pTDFX->fbOffset + fbSize; - if (pTDFX->depthOffset <= pTDFX->textureOffset || - pTDFX->backOffset <= pTDFX->textureOffset) { - /* - * pTDFX->textureSize < 0 means that the DRI is disabled. pTDFX->backOffset - * is used to calculate the maximum amount of memory available for - * 2D offscreen use. With DRI disabled, set this to the top of memory. - */ - - pTDFX->textureSize = -1; - pTDFX->backOffset = pTDFX->mem; - pTDFX->depthOffset = -1; - fprintf(stderr, - "Not enough video memory available for textures and depth buffer\n" - "\tand/or back buffer. Disabling DRI. To use DRI try lower\n" - "\tresolution modes and/or a smaller virtual screen size\n"); - } else { - pTDFX->textureSize = pTDFX->backOffset - pTDFX->textureOffset; - } -} - - -static int createScreen (DRIDriverContext *ctx, TDFXDRIPtr pTDFX) -{ - int err; - - { - int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); - int maxy = ctx->shared.fbSize / width_bytes; - - - if (maxy <= ctx->shared.virtualHeight * 3) { - fprintf(stderr, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (ctx->shared.virtualWidth * ctx->shared.virtualHeight * - ctx->cpp * 3 + 1023) / 1024, - ctx->shared.fbSize / 1024); - return 0; - } - } - - ctx->shared.SAREASize = SAREA_MAX; - pTDFX->regsSize = ctx->MMIOSize; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("tdfx", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, -#ifndef _EMBEDDED - 0, -#else - DRM_READ_ONLY, -#endif - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - - if (drmAddMap(ctx->drmFD, - ctx->MMIOStart, - ctx->MMIOSize, - DRM_REGISTERS, - DRM_READ_ONLY, - &pTDFX->regs) < 0) { - fprintf(stderr, "[drm] drmAddMap mmio failed\n"); - return 0; - } - fprintf(stderr, - "[drm] register handle = 0x%08lx\n", pTDFX->regs); - - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the kernel data structures */ - - /* Initialize kernel gart memory manager */ - allocateMemory(ctx, pTDFX); - - /* Initialize the SAREA private data structure */ - - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - - - /* This is the struct passed to tdfx_dri.so for its initialization */ - ctx->driverClientMsg = malloc(sizeof(TDFXDRIRec)); - ctx->driverClientMsgSize = sizeof(TDFXDRIRec); - memcpy(ctx->driverClientMsg, pTDFX, ctx->driverClientMsgSize); - pTDFX = (TDFXDRIPtr)ctx->driverClientMsg; - - /* Don't release the lock now - let the VT switch handler do it. */ - - return 1; -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa tdfxValidateMode(). - */ -static int tdfxValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa tdfxValidateMode(). - */ -static int tdfxPostValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int tdfxInitFBDev( DRIDriverContext *ctx ) -{ - TDFXDRIPtr pTDFX = calloc(1, sizeof(TDFXDRIRec)); - - { - int dummy = ctx->shared.virtualWidth; - - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - - ctx->shared.virtualWidth = dummy; - } - - ctx->driverPrivate = (void *)pTDFX; - - pTDFX->deviceID = ctx->chipset; - pTDFX->width = ctx->shared.virtualWidth; - pTDFX->height = ctx->shared.virtualHeight; - pTDFX->cpp = ctx->cpp; - pTDFX->mem = ctx->FBSize; /* ->shared.fbSize? mem probe? */ - pTDFX->sarea_priv_offset = sizeof(drm_sarea_t); - - if (!createScreen(ctx, pTDFX)) - return 0; - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void tdfxHaltFBDev( DRIDriverContext *ctx ) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - - -/** - * \brief Shutdown the drawing engine. - * - * \param ctx display handle - * - * Turns off the 3D engine & restores the graphics card - * to a state that fbdev understands. - */ -static int tdfxEngineShutdown( const DRIDriverContext *ctx ) -{ - fprintf(stderr, "%s: not implemented\n", __FUNCTION__); - return 1; -} - - -/** - * \brief Restore the drawing engine. - * - * \param ctx display handle - * - * Resets the graphics card and sets initial values for several registers of - * the card's drawing engine. - * - * Turns on 3dfx - */ -static int tdfxEngineRestore( const DRIDriverContext *ctx ) -{ - fprintf(stderr, "%s: not implemented\n", __FUNCTION__); - return 1; -} - - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -struct DRIDriverRec __driDriver = { - tdfxValidateMode, - tdfxPostValidateMode, - tdfxInitFBDev, - tdfxHaltFBDev, - tdfxEngineShutdown, - tdfxEngineRestore, - 0 -}; diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h deleted file mode 100644 index acd0b9ae5..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h +++ /dev/null @@ -1,28 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.h,v 1.5 2001/03/21 17:02:26 dawes Exp $ */ - -#ifndef _TDFX_DRI_ -#define _TDFX_DRI_ - -#include "xf86drm.h" -#include "drm.h" - -typedef struct { - drm_handle_t regs; - drmSize regsSize; - int deviceID; - int width; - int height; - int mem; - int cpp; - int stride; - int fifoOffset; - int fifoSize; - int fbOffset; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; - unsigned int sarea_priv_offset; -} TDFXDRIRec, *TDFXDRIPtr; - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c deleted file mode 100644 index 412a2791d..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c +++ /dev/null @@ -1,1028 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c,v 1.12 2003/05/08 09:25:35 herrb Exp $ */ - -/* - * New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#include -#include "tdfx_context.h" -#include "tdfx_dd.h" -#include "tdfx_state.h" -#include "tdfx_vb.h" -#include "tdfx_tex.h" -#include "tdfx_tris.h" -#include "tdfx_render.h" -#include "tdfx_span.h" -#include "tdfx_texman.h" -#include "extensions.h" -#include "hash.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "array_cache/acache.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "drivers/common/driverfuncs.h" - -#include "utils.h" - -#define need_GL_ARB_multisample -/* #define need_GL_ARB_point_parameters */ -#define need_GL_ARB_texture_compression -#define need_GL_ARB_vertex_buffer_object -/* #define need_GL_ARB_vertex_program */ -#define need_GL_EXT_blend_equation_separate -#define need_GL_EXT_blend_func_separate -#define need_GL_EXT_blend_minmax -#define need_GL_EXT_fog_coord -#define need_GL_EXT_multi_draw_arrays -#define need_GL_EXT_paletted_texture -/* #define need_GL_EXT_secondary_color */ -#define need_GL_IBM_multimode_draw_arrays -/* #define need_GL_MESA_program_debug */ -/* #define need_GL_NV_vertex_program */ -#include "extension_helper.h" - - -/** - * Common extension strings exported by all cards - */ -const struct dri_extension card_extensions[] = -{ - { "GL_ARB_multisample", GL_ARB_multisample_functions }, - { "GL_ARB_texture_mirrored_repeat", NULL }, - { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, - - { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions }, - { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions }, - { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions }, - { "GL_EXT_shared_texture_palette", NULL }, - { "GL_EXT_stencil_wrap", NULL }, - { "GL_EXT_texture_env_add", NULL }, - { "GL_EXT_texture_lod_bias", NULL }, - { "GL_HP_occlusion_test", NULL }, - { "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions }, - -#ifdef need_GL_ARB_point_parameters - { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, - { "GL_ARB_point_sprite", NULL }, -#endif -#ifdef need_GL_EXT_secondary_color - { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, -#endif -#ifdef need_GL_ARB_vertex_program - { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions } -#endif -#ifdef need_GL_NV_vertex_program - { "GL_NV_vertex_program", GL_NV_vertex_program_functions } - { "GL_NV_vertex_program1_1", NULL }, -#endif -#ifdef need_GL_MESA_program_debug - { "GL_MESA_program_debug", GL_MESA_program_debug_functions }, -#endif - { NULL, NULL } -}; - -/** - * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards. - */ -const struct dri_extension napalm_extensions[] = -{ - { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, - { "GL_ARB_texture_env_combine", NULL }, - { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions }, - { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions }, - { "GL_EXT_texture_compression_s3tc", NULL }, - { "GL_EXT_texture_env_combine", NULL }, - - { "GL_3DFX_texture_compression_FXT1", NULL }, - { "GL_NV_blend_square", NULL }, - { "GL_S3_s3tc", NULL }, - { NULL, NULL } -}; - -/* - * Enable/Disable the extensions for this context. - */ -static void tdfxDDInitExtensions( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - driInitExtensions( ctx, card_extensions, GL_FALSE ); - - if ( fxMesa->haveTwoTMUs ) { - _mesa_enable_extension( ctx, "GL_ARB_multitexture" ); - } - - if ( TDFX_IS_NAPALM( fxMesa ) ) { - driInitExtensions( ctx, napalm_extensions, GL_FALSE ); - } else { - _mesa_enable_extension( ctx, "GL_SGIS_generate_mipmap" ); - } -} - - - -static const struct tnl_pipeline_stage *tdfx_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_point_attenuation_stage, -#if 0 -#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program) - &_tnl_arb_vertex_program_stage, - &_tnl_vertex_program_stage, -#endif -#endif - &_tnl_render_stage, - 0, -}; - -static const struct dri_debug_control debug_control[] = -{ - { "dri", DEBUG_VERBOSE_DRI }, - { "sync", DEBUG_ALWAYS_SYNC }, - { "api", DEBUG_VERBOSE_API }, - { "fall", DEBUG_VERBOSE_FALL }, - { NULL, 0 } -}; - -GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate ) -{ - tdfxContextPtr fxMesa; - GLcontext *ctx, *shareCtx; - __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; - tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private; - TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA + - sizeof(drm_sarea_t)); - struct dd_function_table functions; - - /* Allocate tdfx context */ - fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) ); - if (!fxMesa) - return GL_FALSE; - - /* Init default driver functions then plug in our tdfx-specific functions - * (the texture functions are especially important) - */ - _mesa_init_driver_functions(&functions); - tdfxDDInitDriverFuncs(mesaVis, &functions); - tdfxInitTextureFuncs(&functions); - tdfxInitRenderFuncs(&functions); - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx, - &functions, (void *) fxMesa); - if (!fxMesa->glCtx) { - FREE(fxMesa); - return GL_FALSE; - } - driContextPriv->driverPrivate = fxMesa; - - /* Mirror some important DRI state - */ - fxMesa->hHWContext = driContextPriv->hHWContext; - fxMesa->driHwLock = &sPriv->pSAREA->lock; - fxMesa->driFd = sPriv->fd; - - fxMesa->driScreen = sPriv; - fxMesa->driContext = driContextPriv; - fxMesa->fxScreen = fxScreen; - fxMesa->sarea = saPriv; - - /*JJJ - really?*/ - fxMesa->haveHwAlpha = ( mesaVis->alphaBits && - ((mesaVis->greenBits == 8) || - (mesaVis->depthBits == 0)) ); - fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) && - mesaVis->stencilBits && - mesaVis->depthBits == 24 ); - - fxMesa->screen_width = fxScreen->width; - fxMesa->screen_height = fxScreen->height; - - fxMesa->new_gl_state = ~0; - fxMesa->new_state = ~0; - fxMesa->dirty = ~0; - - /* Parse configuration files */ - driParseConfigFiles (&fxMesa->optionCache, &fxScreen->optionCache, - fxMesa->driScreen->myNum, "tdfx"); - - /* NOTE: This must be here before any Glide calls! */ - if (!tdfxInitGlide( fxMesa )) { - FREE(fxMesa); - return GL_FALSE; - } - - fxMesa->Glide.grDRIOpen( (char*) sPriv->pFB, fxScreen->regs.map, fxScreen->deviceID, - fxScreen->width, fxScreen->height, fxScreen->mem, fxScreen->cpp, - fxScreen->stride, fxScreen->fifoOffset, fxScreen->fifoSize, - fxScreen->fbOffset, fxScreen->backOffset, fxScreen->depthOffset, - fxScreen->textureOffset, fxScreen->textureSize, &saPriv->fifoPtr, - &saPriv->fifoRead ); - - if ( getenv( "FX_GLIDE_SWAPINTERVAL" ) ) { - fxMesa->Glide.SwapInterval = atoi( getenv( "FX_GLIDE_SWAPINTERVAL" ) ); - } else { - fxMesa->Glide.SwapInterval = 0; - } - if ( getenv( "FX_MAX_PENDING_SWAPS" ) ) { - fxMesa->Glide.MaxPendingSwaps = atoi( getenv( "FX_MAX_PENDING_SWAPS" ) ); - } else { - fxMesa->Glide.MaxPendingSwaps = 2; - } - - fxMesa->Glide.Initialized = GL_FALSE; - fxMesa->Glide.Board = 0; - - - if (getenv("FX_EMULATE_SINGLE_TMU")) { - fxMesa->haveTwoTMUs = GL_FALSE; - } - else { - if ( TDFX_IS_BANSHEE( fxMesa ) ) { - fxMesa->haveTwoTMUs = GL_FALSE; - } else { - fxMesa->haveTwoTMUs = GL_TRUE; - } - } - - fxMesa->stats.swapBuffer = 0; - fxMesa->stats.reqTexUpload = 0; - fxMesa->stats.texUpload = 0; - fxMesa->stats.memTexUpload = 0; - - fxMesa->tmuSrc = TDFX_TMU_NONE; - - ctx = fxMesa->glCtx; - if ( TDFX_IS_NAPALM( fxMesa ) ) { - ctx->Const.MaxTextureLevels = 12; - } else { - ctx->Const.MaxTextureLevels = 9; - } - ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2; - ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; - ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; - - /* No wide points. - */ - ctx->Const.MinPointSize = 1.0; - ctx->Const.MinPointSizeAA = 1.0; - ctx->Const.MaxPointSize = 1.0; - ctx->Const.MaxPointSizeAA = 1.0; - - /* Disable wide lines as we can't antialias them correctly in - * hardware. - */ - ctx->Const.MinLineWidth = 1.0; - ctx->Const.MinLineWidthAA = 1.0; - ctx->Const.MaxLineWidth = 1.0; - ctx->Const.MaxLineWidthAA = 1.0; - ctx->Const.LineWidthGranularity = 1.0; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _ac_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, tdfx_pipeline ); - - /* Configure swrast and T&L to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_TRUE ); - _swrast_allow_vertex_fog( ctx, GL_FALSE ); - _tnl_allow_pixel_fog( ctx, GL_TRUE ); - _tnl_allow_vertex_fog( ctx, GL_FALSE ); - - tdfxDDInitExtensions( ctx ); - /* XXX these should really go right after _mesa_init_driver_functions() */ - tdfxDDInitSpanFuncs( ctx ); - tdfxDDInitStateFuncs( ctx ); - tdfxDDInitTriFuncs( ctx ); - tdfxInitVB( ctx ); - tdfxInitState( fxMesa ); - -#if DO_DEBUG - TDFX_DEBUG = driParseDebugString( getenv( "TDFX_DEBUG" ), debug_control ); -#endif - - if (driQueryOptionb(&fxMesa->optionCache, "no_rast")) { - fprintf(stderr, "disabling 3D acceleration\n"); - FALLBACK(fxMesa, TDFX_FALLBACK_DISABLE, 1); - } - - return GL_TRUE; -} - - -static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa ) -{ - FxI32 result; - int i; - - LOCK_HARDWARE( fxMesa ); - - fxMesa->Glide.grGet( GR_GLIDE_VERTEXLAYOUT_SIZE, sizeof(FxI32), &result ); - for ( i = 0 ; i < TDFX_NUM_LAYOUTS ; i++ ) { - fxMesa->layout[i] = MALLOC( result ); - if ( !fxMesa->layout[i] ) { - UNLOCK_HARDWARE( fxMesa ); - return GL_FALSE; - } - } - - /* Tiny vertex format - 16 bytes. - */ - fxMesa->Glide.grReset( GR_VERTEX_PARAMETER ); - fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS ); - fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_TINY] ); - - /* Non textured vertex format - 24 bytes (Need w for table fog) - */ - fxMesa->Glide.grReset( GR_VERTEX_PARAMETER ); - fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS ); - fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_NOTEX] ); - - /* Single textured vertex format - 32 bytes. - */ - fxMesa->Glide.grReset( GR_VERTEX_PARAMETER ); - fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS ); - fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_SINGLE] ); - - /* Multitextured vertex format - 40 bytes. - */ - fxMesa->Glide.grReset( GR_VERTEX_PARAMETER ); - fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS ); - fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] ); - - /* Projected texture vertex format - 36 bytes. - */ - fxMesa->Glide.grReset( GR_VERTEX_PARAMETER ); - fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS ); - fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ1] ); - - /* Projected multitexture vertex format - 48 bytes. - */ - fxMesa->Glide.grReset( GR_VERTEX_PARAMETER ); - fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS ); - fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grVertexLayout( GR_PARAM_Q1, TDFX_Q1_OFFSET, GR_PARAM_ENABLE ); - fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ2] ); - - UNLOCK_HARDWARE( fxMesa ); - - return GL_TRUE; -} - - -/* - * Initialize the state in an tdfxContextPtr struct. - */ -static GLboolean -tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa ) -{ - /* KW: Would be nice to make one of these a member of the other. - */ - FxI32 result[2]; - const char *gext; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa ); - } - -#if DEBUG_LOCKING - fprintf(stderr, "Debug locking enabled\n"); -#endif - - if ( fxMesa->Glide.Initialized ) - return GL_TRUE; - - fxMesa->width = driDrawPriv->w; - fxMesa->height = driDrawPriv->h; - - /* We have to use a light lock here, because we can't do any glide - * operations yet. No use of FX_* functions in this function. - */ - DRM_LIGHT_LOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); - - fxMesa->Glide.grGlideInit(); - fxMesa->Glide.grSstSelect( fxMesa->Glide.Board ); - - fxMesa->Glide.Context = fxMesa->Glide.grSstWinOpen( (FxU32) -1, - GR_RESOLUTION_NONE, - GR_REFRESH_NONE, - fxMesa->Glide.ColorFormat, - fxMesa->Glide.Origin, - 2, 1 ); - - fxMesa->Glide.grDRIResetSAREA(); - - DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); - - if ( !fxMesa->Glide.Context ) - return GL_FALSE; - - - /* Perform the Glide-dependant part of the context initialization. - */ - FX_grColorMaskv( fxMesa->glCtx, true4 ); - - tdfxTMInit( fxMesa ); - - LOCK_HARDWARE( fxMesa ); - - /* JJJ - COMMAND_TRANSPORT, PALETTE6666 */ - gext = fxMesa->Glide.grGetString( GR_EXTENSION ); - fxMesa->Glide.HaveCombineExt = strstr(gext, "COMBINE") && !getenv("MESA_FX_IGNORE_CMBEXT"); - fxMesa->Glide.HaveCommandTransportExt = GL_FALSE; - fxMesa->Glide.HaveFogCoordExt = GL_TRUE; - fxMesa->Glide.HavePixelExt = strstr(gext, "PIXEXT") && !getenv("MESA_FX_IGNORE_PIXEXT"); - fxMesa->Glide.HaveTextureBufferExt = GL_TRUE; - fxMesa->Glide.HaveTexFmtExt = strstr(gext, "TEXFMT") && !getenv("MESA_FX_IGNORE_TEXFMT"); - fxMesa->Glide.HaveTexUMAExt = strstr(gext, "TEXUMA") && !getenv("MESA_FX_IGNORE_TEXUMA"); - fxMesa->Glide.HaveMirrorExt = strstr(gext, "TEXMIRROR") && !getenv("MESA_FX_IGNORE_MIREXT"); - fxMesa->Glide.HaveTexus2 = GL_FALSE; - - if ( fxMesa->glCtx->Visual.depthBits > 0 ) { - fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); - } else { - fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_DISABLE); - } - - fxMesa->Glide.grLfbWriteColorFormat( GR_COLORFORMAT_ABGR ); - - fxMesa->Glide.grGet( GR_TEXTURE_ALIGN, sizeof(FxI32), result ); - fxMesa->Glide.TextureAlign = result[0]; - - fxMesa->Glide.State = NULL; - fxMesa->Glide.grGet( GR_GLIDE_STATE_SIZE, sizeof(FxI32), result ); - fxMesa->Glide.State = MALLOC( result[0] ); - - fxMesa->Fog.Table = NULL; - fxMesa->Glide.grGet( GR_FOG_TABLE_ENTRIES, sizeof(FxI32), result ); - fxMesa->Fog.Table = MALLOC( result[0] * sizeof(GrFog_t) ); - - UNLOCK_HARDWARE( fxMesa ); - - if ( !fxMesa->Glide.State || !fxMesa->Fog.Table ) { - if ( fxMesa->Glide.State ) - FREE( fxMesa->Glide.State ); - if ( fxMesa->Fog.Table ) - FREE( fxMesa->Fog.Table ); - return GL_FALSE; - } - - if ( !tdfxInitVertexFormats( fxMesa ) ) { - return GL_FALSE; - } - - LOCK_HARDWARE( fxMesa ); - - fxMesa->Glide.grGlideGetState( fxMesa->Glide.State ); - - if ( getenv( "FX_GLIDE_INFO" ) ) { - printf( "GR_RENDERER = %s\n", (char *) fxMesa->Glide.grGetString( GR_RENDERER ) ); - printf( "GR_VERSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_VERSION ) ); - printf( "GR_VENDOR = %s\n", (char *) fxMesa->Glide.grGetString( GR_VENDOR ) ); - printf( "GR_HARDWARE = %s\n", (char *) fxMesa->Glide.grGetString( GR_HARDWARE ) ); - printf( "GR_EXTENSION = %s\n", (char *) gext ); - } - - UNLOCK_HARDWARE( fxMesa ); - - fxMesa->numClipRects = 0; - fxMesa->pClipRects = NULL; - fxMesa->scissoredClipRects = GL_FALSE; - - fxMesa->Glide.Initialized = GL_TRUE; - - return GL_TRUE; -} - - -void -tdfxDestroyContext( __DRIcontextPrivate *driContextPriv ) -{ - tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa ); - } - - if ( fxMesa ) { - if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) { - /* This share group is about to go away, free our private - * texture object data. - */ - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tdfxTMFreeTexture(fxMesa, tObj); - } - } - - tdfxTMClose(fxMesa); /* free texture memory */ - - _swsetup_DestroyContext( fxMesa->glCtx ); - _tnl_DestroyContext( fxMesa->glCtx ); - _ac_DestroyContext( fxMesa->glCtx ); - _swrast_DestroyContext( fxMesa->glCtx ); - - tdfxFreeVB( fxMesa->glCtx ); - - /* Free Mesa context */ - fxMesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(fxMesa->glCtx); - - /* free the tdfx context */ - FREE( fxMesa ); - } -} - - -GLboolean -tdfxUnbindContext( __DRIcontextPrivate *driContextPriv ) -{ - GET_CURRENT_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv ); - } - - if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) { - LOCK_HARDWARE(fxMesa); - fxMesa->Glide.grGlideGetState(fxMesa->Glide.State); - UNLOCK_HARDWARE(fxMesa); - } - return GL_TRUE; -} - - -GLboolean -tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv ) -{ - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv ); - } - - if ( driContextPriv ) { - tdfxContextPtr newFx = (tdfxContextPtr) driContextPriv->driverPrivate; - GLcontext *newCtx = newFx->glCtx; - GET_CURRENT_CONTEXT(curCtx); - - if ( newFx->driDrawable != driDrawPriv ) { - newFx->driDrawable = driDrawPriv; - newFx->dirty = ~0; - } - else { - if (curCtx == newCtx) { - /* same drawable, same context -> no-op */ - /* Need to call _mesa_make_current2() in order to make sure API - * dispatch is set correctly. - */ - _mesa_make_current( newCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); - return GL_TRUE; - } - /* [dBorca] tunnel2 requires this */ - newFx->dirty = ~0; - } - - if ( !newFx->Glide.Initialized ) { - if ( !tdfxInitContext( driDrawPriv, newFx ) ) - return GL_FALSE; - - LOCK_HARDWARE( newFx ); - - /* FIXME: Force loading of window information */ - newFx->width = 0; - tdfxUpdateClipping(newCtx); - tdfxUploadClipping(newFx); - - UNLOCK_HARDWARE( newFx ); - } else { - LOCK_HARDWARE( newFx ); - - newFx->Glide.grSstSelect( newFx->Glide.Board ); - newFx->Glide.grGlideSetState( newFx->Glide.State ); - - tdfxUpdateClipping(newCtx); - tdfxUploadClipping(newFx); - - UNLOCK_HARDWARE( newFx ); - } - - _mesa_make_current( newCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - return GL_TRUE; -} - - -/* - * Enable this to trace calls to various Glide functions. - */ -/*#define DEBUG_TRAP*/ -#ifdef DEBUG_TRAP -static void (*real_grDrawTriangle)( const void *a, const void *b, const void *c ); -static void (*real_grDrawPoint)( const void *a ); -static void (*real_grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers); -static void (*real_grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count, - void *pointers, FxU32 stride); -static void (*real_grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy ); - -static void (*real_grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode); -static void (*real_grGlideGetVertexLayout)( void *layout ); -static void (*real_grGlideSetVertexLayout)( const void *layout ); - -static void (*real_grTexDownloadMipMapLevel)( GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data ); - - -static void debug_grDrawTriangle( const void *a, const void *b, const void *c ) -{ - printf("%s\n", __FUNCTION__); - (*real_grDrawTriangle)(a, b, c); -} - -static void debug_grDrawPoint( const void *a ) -{ - const float *f = (const float *) a; - printf("%s %g %g\n", __FUNCTION__, f[0], f[1]); - (*real_grDrawPoint)(a); -} - -static void debug_grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers) -{ - printf("%s count=%d\n", __FUNCTION__, (int) Count); - (*real_grDrawVertexArray)(mode, Count, pointers); -} - -static void debug_grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, - void *pointers, FxU32 stride) -{ - printf("%s mode=0x%x count=%d\n", __FUNCTION__, (int) mode, (int) Count); - (*real_grDrawVertexArrayContiguous)(mode, Count, pointers, stride); -} - -static void debug_grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy ) -{ - printf("%s %d,%d .. %d,%d\n", __FUNCTION__, - (int) minx, (int) miny, (int) maxx, (int) maxy); - (*real_grClipWindow)(minx, miny, maxx, maxy); -} - -static void debug_grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode) -{ - (*real_grVertexLayout)(param, offset, mode); -} - -static void debug_grGlideGetVertexLayout( void *layout ) -{ - (*real_grGlideGetVertexLayout)(layout); -} - -static void debug_grGlideSetVertexLayout( const void *layout ) -{ - (*real_grGlideSetVertexLayout)(layout); -} - -static void debug_grTexDownloadMipMapLevel( GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data ) -{ - (*real_grTexDownloadMipMapLevel)(tmu, startAddress, thisLod, largeLod, - aspectRatio, format, evenOdd, data); -} - -#endif - - -/* - * Examine the context's deviceID to determine what kind of 3dfx hardware - * is installed. dlopen() the appropriate Glide library and initialize - * this context's Glide function pointers. - * Return: true/false = success/failure - */ -GLboolean tdfxInitGlide(tdfxContextPtr tmesa) -{ - static const char *defaultGlide = "libglide3.so"; - const char *libName; - void *libHandle; - - /* - * XXX this code which selects a Glide library filename given the - * deviceID may need to be cleaned up a bit. - * Non-Linux systems may have different filenames, for example. - */ - switch (tmesa->fxScreen->deviceID) { - case PCI_CHIP_BANSHEE: - case PCI_CHIP_VOODOO3: - libName = "libglide3-v3.so"; - break; - case PCI_CHIP_VOODOO5: /* same as PCI_CHIP_VOODOO4 */ - libName = "libglide3-v5.so"; - break; - default: - { - __driUtilMessage("unrecognized 3dfx deviceID: 0x%x", - tmesa->fxScreen->deviceID); - } - return GL_FALSE; - } - - libHandle = dlopen(libName, RTLD_NOW); - if (!libHandle) { - /* The device-specific Glide library filename didn't work, try the - * old, generic libglide3.so library. - */ - libHandle = dlopen(defaultGlide, RTLD_NOW); - if (!libHandle) { - __driUtilMessage( - "can't find Glide library, dlopen(%s) and dlopen(%s) both failed.", - libName, defaultGlide); - __driUtilMessage("dlerror() message: %s", dlerror()); - return GL_FALSE; - } - libName = defaultGlide; - } - - { - const char *env = getenv("LIBGL_DEBUG"); - if (env && strstr(env, "verbose")) { - fprintf(stderr, "libGL: using Glide library %s\n", libName); - } - } - -#define GET_FUNCTION(PTR, NAME) \ - tmesa->Glide.PTR = dlsym(libHandle, NAME); \ - if (!tmesa->Glide.PTR) { \ - __driUtilMessage("couldn't find Glide function %s in %s.", \ - NAME, libName); \ - } - - GET_FUNCTION(grDrawPoint, "grDrawPoint"); - GET_FUNCTION(grDrawLine, "grDrawLine"); - GET_FUNCTION(grDrawTriangle, "grDrawTriangle"); - GET_FUNCTION(grVertexLayout, "grVertexLayout"); - GET_FUNCTION(grDrawVertexArray, "grDrawVertexArray"); - GET_FUNCTION(grDrawVertexArrayContiguous, "grDrawVertexArrayContiguous"); - GET_FUNCTION(grBufferClear, "grBufferClear"); - /*GET_FUNCTION(grBufferSwap, "grBufferSwap");*/ - GET_FUNCTION(grRenderBuffer, "grRenderBuffer"); - GET_FUNCTION(grErrorSetCallback, "grErrorSetCallback"); - GET_FUNCTION(grFinish, "grFinish"); - GET_FUNCTION(grFlush, "grFlush"); - GET_FUNCTION(grSstWinOpen, "grSstWinOpen"); - GET_FUNCTION(grSstWinClose, "grSstWinClose"); -#if 0 - /* Not in V3 lib, and not used anyway. */ - GET_FUNCTION(grSetNumPendingBuffers, "grSetNumPendingBuffers"); -#endif - GET_FUNCTION(grSelectContext, "grSelectContext"); - GET_FUNCTION(grSstOrigin, "grSstOrigin"); - GET_FUNCTION(grSstSelect, "grSstSelect"); - GET_FUNCTION(grAlphaBlendFunction, "grAlphaBlendFunction"); - GET_FUNCTION(grAlphaCombine, "grAlphaCombine"); - GET_FUNCTION(grAlphaControlsITRGBLighting, "grAlphaControlsITRGBLighting"); - GET_FUNCTION(grAlphaTestFunction, "grAlphaTestFunction"); - GET_FUNCTION(grAlphaTestReferenceValue, "grAlphaTestReferenceValue"); - GET_FUNCTION(grChromakeyMode, "grChromakeyMode"); - GET_FUNCTION(grChromakeyValue, "grChromakeyValue"); - GET_FUNCTION(grClipWindow, "grClipWindow"); - GET_FUNCTION(grColorCombine, "grColorCombine"); - GET_FUNCTION(grColorMask, "grColorMask"); - GET_FUNCTION(grCullMode, "grCullMode"); - GET_FUNCTION(grConstantColorValue, "grConstantColorValue"); - GET_FUNCTION(grDepthBiasLevel, "grDepthBiasLevel"); - GET_FUNCTION(grDepthBufferFunction, "grDepthBufferFunction"); - GET_FUNCTION(grDepthBufferMode, "grDepthBufferMode"); - GET_FUNCTION(grDepthMask, "grDepthMask"); - GET_FUNCTION(grDisableAllEffects, "grDisableAllEffects"); - GET_FUNCTION(grDitherMode, "grDitherMode"); - GET_FUNCTION(grFogColorValue, "grFogColorValue"); - GET_FUNCTION(grFogMode, "grFogMode"); - GET_FUNCTION(grFogTable, "grFogTable"); - GET_FUNCTION(grLoadGammaTable, "grLoadGammaTable"); - GET_FUNCTION(grSplash, "grSplash"); - GET_FUNCTION(grGet, "grGet"); - GET_FUNCTION(grGetString, "grGetString"); - GET_FUNCTION(grQueryResolutions, "grQueryResolutions"); - GET_FUNCTION(grReset, "grReset"); - GET_FUNCTION(grGetProcAddress, "grGetProcAddress"); - GET_FUNCTION(grEnable, "grEnable"); - GET_FUNCTION(grDisable, "grDisable"); - GET_FUNCTION(grCoordinateSpace, "grCoordinateSpace"); - GET_FUNCTION(grDepthRange, "grDepthRange"); - GET_FUNCTION(grStippleMode, "grStippleMode"); - GET_FUNCTION(grStipplePattern, "grStipplePattern"); - GET_FUNCTION(grViewport, "grViewport"); - GET_FUNCTION(grTexCalcMemRequired, "grTexCalcMemRequired"); - GET_FUNCTION(grTexTextureMemRequired, "grTexTextureMemRequired"); - GET_FUNCTION(grTexMinAddress, "grTexMinAddress"); - GET_FUNCTION(grTexMaxAddress, "grTexMaxAddress"); - GET_FUNCTION(grTexNCCTable, "grTexNCCTable"); - GET_FUNCTION(grTexSource, "grTexSource"); - GET_FUNCTION(grTexClampMode, "grTexClampMode"); - GET_FUNCTION(grTexCombine, "grTexCombine"); - GET_FUNCTION(grTexDetailControl, "grTexDetailControl"); - GET_FUNCTION(grTexFilterMode, "grTexFilterMode"); - GET_FUNCTION(grTexLodBiasValue, "grTexLodBiasValue"); - GET_FUNCTION(grTexDownloadMipMap, "grTexDownloadMipMap"); - GET_FUNCTION(grTexDownloadMipMapLevel, "grTexDownloadMipMapLevel"); - GET_FUNCTION(grTexDownloadMipMapLevelPartial, "grTexDownloadMipMapLevelPartial"); - GET_FUNCTION(grTexDownloadTable, "grTexDownloadTable"); - GET_FUNCTION(grTexDownloadTablePartial, "grTexDownloadTablePartial"); - GET_FUNCTION(grTexMipMapMode, "grTexMipMapMode"); - GET_FUNCTION(grTexMultibase, "grTexMultibase"); - GET_FUNCTION(grTexMultibaseAddress, "grTexMultibaseAddress"); - GET_FUNCTION(grLfbLock, "grLfbLock"); - GET_FUNCTION(grLfbUnlock, "grLfbUnlock"); - GET_FUNCTION(grLfbConstantAlpha, "grLfbConstantAlpha"); - GET_FUNCTION(grLfbConstantDepth, "grLfbConstantDepth"); - GET_FUNCTION(grLfbWriteColorSwizzle, "grLfbWriteColorSwizzle"); - GET_FUNCTION(grLfbWriteColorFormat, "grLfbWriteColorFormat"); - GET_FUNCTION(grLfbWriteRegion, "grLfbWriteRegion"); - GET_FUNCTION(grLfbReadRegion, "grLfbReadRegion"); - GET_FUNCTION(grGlideInit, "grGlideInit"); - GET_FUNCTION(grGlideShutdown, "grGlideShutdown"); - GET_FUNCTION(grGlideGetState, "grGlideGetState"); - GET_FUNCTION(grGlideSetState, "grGlideSetState"); - GET_FUNCTION(grGlideGetVertexLayout, "grGlideGetVertexLayout"); - GET_FUNCTION(grGlideSetVertexLayout, "grGlideSetVertexLayout"); - - /* Glide utility functions */ - GET_FUNCTION(guFogGenerateExp, "guFogGenerateExp"); - GET_FUNCTION(guFogGenerateExp2, "guFogGenerateExp2"); - GET_FUNCTION(guFogGenerateLinear, "guFogGenerateLinear"); - - /* DRI functions */ - GET_FUNCTION(grDRIOpen, "grDRIOpen"); - GET_FUNCTION(grDRIPosition, "grDRIPosition"); - /*GET_FUNCTION(grDRILostContext, "grDRILostContext");*/ - GET_FUNCTION(grDRIImportFifo, "grDRIImportFifo"); - GET_FUNCTION(grDRIInvalidateAll, "grDRIInvalidateAll"); - GET_FUNCTION(grDRIResetSAREA, "grDRIResetSAREA"); - GET_FUNCTION(grDRIBufferSwap, "grDRIBufferSwap"); - - /* - * Extension functions: - * Just use dlysm() because we want a NULL pointer if the function is - * not found. - */ - /* PIXEXT extension */ - tmesa->Glide.grStencilFunc = dlsym(libHandle, "grStencilFunc"); - tmesa->Glide.grStencilMask = dlsym(libHandle, "grStencilMask"); - tmesa->Glide.grStencilOp = dlsym(libHandle, "grStencilOp"); - tmesa->Glide.grBufferClearExt = dlsym(libHandle, "grBufferClearExt"); - tmesa->Glide.grColorMaskExt = dlsym(libHandle, "grColorMaskExt"); - /* COMBINE extension */ - tmesa->Glide.grColorCombineExt = dlsym(libHandle, "grColorCombineExt"); - tmesa->Glide.grTexColorCombineExt = dlsym(libHandle, "grTexColorCombineExt"); - tmesa->Glide.grAlphaCombineExt = dlsym(libHandle, "grAlphaCombineExt"); - tmesa->Glide.grTexAlphaCombineExt = dlsym(libHandle, "grTexAlphaCombineExt"); - tmesa->Glide.grAlphaBlendFunctionExt = dlsym(libHandle, "grAlphaBlendFunctionExt"); - tmesa->Glide.grConstantColorValueExt = dlsym(libHandle, "grConstantColorValueExt"); - /* Texus 2 */ - tmesa->Glide.txImgQuantize = dlsym(libHandle, "txImgQuantize"); - tmesa->Glide.txImgDequantizeFXT1 = dlsym(libHandle, "_txImgDequantizeFXT1"); - tmesa->Glide.txErrorSetCallback = dlsym(libHandle, "txErrorSetCallback"); - -#ifdef DEBUG_TRAP - /* wrap the drawing functions so we can trap them */ - real_grDrawTriangle = tmesa->Glide.grDrawTriangle; - tmesa->Glide.grDrawTriangle = debug_grDrawTriangle; - - real_grDrawPoint = tmesa->Glide.grDrawPoint; - tmesa->Glide.grDrawPoint = debug_grDrawPoint; - - real_grDrawVertexArray = tmesa->Glide.grDrawVertexArray; - tmesa->Glide.grDrawVertexArray = debug_grDrawVertexArray; - - real_grDrawVertexArrayContiguous = tmesa->Glide.grDrawVertexArrayContiguous; - tmesa->Glide.grDrawVertexArrayContiguous = debug_grDrawVertexArrayContiguous; - - real_grClipWindow = tmesa->Glide.grClipWindow; - tmesa->Glide.grClipWindow = debug_grClipWindow; - - real_grVertexLayout = tmesa->Glide.grVertexLayout; - tmesa->Glide.grVertexLayout = debug_grVertexLayout; - - real_grGlideGetVertexLayout = tmesa->Glide.grGlideGetVertexLayout; - tmesa->Glide.grGlideGetVertexLayout = debug_grGlideGetVertexLayout; - - real_grGlideSetVertexLayout = tmesa->Glide.grGlideSetVertexLayout; - tmesa->Glide.grGlideSetVertexLayout = debug_grGlideSetVertexLayout; - - real_grTexDownloadMipMapLevel = tmesa->Glide.grTexDownloadMipMapLevel; - tmesa->Glide.grTexDownloadMipMapLevel = debug_grTexDownloadMipMapLevel; - -#endif - return GL_TRUE; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h deleted file mode 100644 index b8349fec7..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h +++ /dev/null @@ -1,1007 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h,v 1.5 2002/02/24 21:51:10 dawes Exp $ */ - -/* - * New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#ifndef __TDFX_CONTEXT_H__ -#define __TDFX_CONTEXT_H__ - -#include -#include "dri_util.h" -#ifdef XFree86Server -#include "GL/xf86glx.h" -#else -#include "glheader.h" -#endif -#if defined(__linux__) -#include -#endif - -#include "drm.h" -#include "drm_sarea.h" -#include "tdfx_glide.h" -#include "xmlconfig.h" - -#include "clip.h" -#include "context.h" -#include "macros.h" -#include "matrix.h" -#include "imports.h" -#include "mtypes.h" - -#include "tdfx_screen.h" - - - - -#define TDFX_TMU0 GR_TMU0 -#define TDFX_TMU1 GR_TMU1 -#define TDFX_TMU_SPLIT 98 -#define TDFX_TMU_BOTH 99 -#define TDFX_TMU_NONE 100 - - - -/* Flags for fxMesa->new_state - */ -#define TDFX_NEW_COLOR 0x0001 -#define TDFX_NEW_ALPHA 0x0002 -#define TDFX_NEW_DEPTH 0x0004 -#define TDFX_NEW_FOG 0x0008 -#define TDFX_NEW_STENCIL 0x0010 -#define TDFX_NEW_CLIP 0x0020 -#define TDFX_NEW_VIEWPORT 0x0040 -#define TDFX_NEW_CULL 0x0080 -#define TDFX_NEW_GLIDE 0x0100 -#define TDFX_NEW_TEXTURE 0x0200 -#define TDFX_NEW_CONTEXT 0x0400 -#define TDFX_NEW_LINE 0x0800 -#define TDFX_NEW_RENDER 0x1000 -#define TDFX_NEW_STIPPLE 0x2000 -#define TDFX_NEW_TEXTURE_BIND 0x4000 /* experimental */ - - -/* Flags for fxMesa->dirty - */ -#define TDFX_UPLOAD_COLOR_COMBINE 0x00000001 -#define TDFX_UPLOAD_ALPHA_COMBINE 0x00000002 -#define TDFX_UPLOAD_RENDER_BUFFER 0x00000004 -#define TDFX_UPLOAD_ALPHA_TEST 0x00000008 -#define TDFX_UPLOAD_ALPHA_REF 0x00000010 -#define TDFX_UPLOAD_BLEND_FUNC 0x00000020 -#define TDFX_UPLOAD_DEPTH_MODE 0x00000040 -#define TDFX_UPLOAD_DEPTH_BIAS 0x00000080 -#define TDFX_UPLOAD_DEPTH_FUNC 0x00000100 -#define TDFX_UPLOAD_DEPTH_MASK 0x00000200 -#define TDFX_UPLOAD_FOG_MODE 0x00000400 -#define TDFX_UPLOAD_FOG_COLOR 0x00000800 -#define TDFX_UPLOAD_FOG_TABLE 0x00001000 -#define TDFX_UPLOAD_CONSTANT_COLOR 0x00002000 - -#define TDFX_UPLOAD_CLIP 0x00002000 -#define TDFX_UPLOAD_CULL 0x00004000 -#define TDFX_UPLOAD_VERTEX_LAYOUT 0x00008000 -#define TDFX_UPLOAD_COLOR_MASK 0x00010000 -#define TDFX_UPLOAD_DITHER 0x00040000 -#define TDFX_UPLOAD_STENCIL 0x00080000 - -#define TDFX_UPLOAD_TEXTURE_SOURCE 0x00100000 -#define TDFX_UPLOAD_TEXTURE_PARAMS 0x00200000 -#define TDFX_UPLOAD_TEXTURE_PALETTE 0x00400000 -#define TDFX_UPLOAD_TEXTURE_ENV 0x00800000 -#define TDFX_UPLOAD_TEXTURE_IMAGES 0x01000000 - -#define TDFX_UPLOAD_LINE 0x02000000 - -#define TDFX_UPLOAD_STIPPLE 0x04000000 - -/* Flags for software fallback cases */ -/* See correponding strings in tdfx_tris.c */ -#define TDFX_FALLBACK_TEXTURE_MAP 0x0001 -#define TDFX_FALLBACK_DRAW_BUFFER 0x0002 -#define TDFX_FALLBACK_SPECULAR 0x0004 -#define TDFX_FALLBACK_STENCIL 0x0008 -#define TDFX_FALLBACK_RENDER_MODE 0x0010 -#define TDFX_FALLBACK_LOGICOP 0x0020 -#define TDFX_FALLBACK_TEXTURE_ENV 0x0040 -#define TDFX_FALLBACK_TEXTURE_BORDER 0x0080 -#define TDFX_FALLBACK_COLORMASK 0x0100 -#define TDFX_FALLBACK_BLEND 0x0200 -#define TDFX_FALLBACK_LINE_STIPPLE 0x0400 -#define TDFX_FALLBACK_DISABLE 0x0800 - -/* Different Glide vertex layouts - */ -#define TDFX_LAYOUT_TINY 0 -#define TDFX_LAYOUT_NOTEX 1 -#define TDFX_LAYOUT_SINGLE 2 -#define TDFX_LAYOUT_MULTI 3 -#define TDFX_LAYOUT_PROJ1 4 -#define TDFX_LAYOUT_PROJ2 5 -#define TDFX_NUM_LAYOUTS 6 - -#define TDFX_XY_OFFSET 0 -#define TDFX_Z_OFFSET 8 -#define TDFX_Q_OFFSET 12 -#define TDFX_ARGB_OFFSET 16 -#define TDFX_FOG_OFFSET 20 -#define TDFX_ST0_OFFSET 24 -#define TDFX_ST1_OFFSET 32 -#define TDFX_Q0_OFFSET 40 -#define TDFX_Q1_OFFSET 44 - - -/* Flags for buffer clears - */ -#define TDFX_FRONT 0x1 -#define TDFX_BACK 0x2 -#define TDFX_DEPTH 0x4 -#define TDFX_STENCIL 0x8 - -/* - * Subpixel offsets to adjust Mesa's (true) window coordinates to - * Glide coordinates. We need these to ensure precise rasterization. - * Otherwise, we'll fail a bunch of conformance tests. - */ -#define TRI_X_OFFSET ( 0.0F) -#define TRI_Y_OFFSET ( 0.0F) -#define LINE_X_OFFSET ( 0.0F) -#define LINE_Y_OFFSET ( 0.125F) -#define PNT_X_OFFSET ( 0.375F) -#define PNT_Y_OFFSET ( 0.375F) - - -#define TDFX_DEPTH_BIAS_SCALE 128 - -/* Including xf86PciInfo.h causes a bunch of errors - */ -#ifndef PCI_CHIP_BANSHEE -#define PCI_CHIP_BANSHEE 0x0003 -#define PCI_CHIP_VOODOO3 0x0005 -#define PCI_CHIP_VOODOO4 0x0009 -#define PCI_CHIP_VOODOO5 0x0009 -#endif - -#define TDFX_IS_BANSHEE( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_BANSHEE ) -#define TDFX_IS_VOODOO3( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO3 ) -#define TDFX_IS_VOODOO4( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4 ) -#define TDFX_IS_VOODOO5( fxMesa ) \ - ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5 ) -#define TDFX_IS_NAPALM( fxMesa ) \ - ( (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4) || \ - (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5) ) - - -#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) ) - -/* - * The first two macros are to pack 8 bit color - * channel values into a 565 format. - */ -#define PACK_RGB16(R, G, B) \ - ((((GLuint) (R) & 0xF8) << 8) | \ - (((GLuint) (G) & 0xFC) << 3) | \ - (((GLuint) (B) & 0xFF) >> 3)) -#define PACK_BGR16(R, G, B) \ - ((((GLuint) (B) & 0xF8) << 8) | \ - (((GLuint) (G) & 0xFC) << 3) | \ - (((GLuint) (R) & 0xFF) >> 3)) -/* - * The second two macros pack 8 bit color channel values - * into 1555 values. - */ -#define PACK_RGBA16(R, G, B, A) \ - (((((GLuint) (A) & 0xFF) > 0) << 15)| \ - (((GLuint) (R) & 0xF8) << 7) | \ - (((GLuint) (G) & 0xF8) << 2) | \ - (((GLuint) (B) & 0xF8) >> 3)) -#define PACK_BGRA16(R, G, B, A) \ - (((((GLuint) (A) & 0xFF) > 0) << 15)| \ - (((GLuint) (B) & 0xF8) << 7) | \ - (((GLuint) (G) & 0xF8) << 2) | \ - (((GLuint) (R) & 0xF8) >> 3)) - -/* Used in calls to grColorMaskv()... - */ -extern const GLboolean false4[4]; -extern const GLboolean true4[4]; - - -typedef struct tdfx_context tdfxContextRec; -typedef struct tdfx_context *tdfxContextPtr; - - -typedef struct { - volatile int fifoPtr; - volatile int fifoRead; - volatile int fifoOwner; - volatile int ctxOwner; - volatile int texOwner; -} -TDFXSAREAPriv; - - -typedef struct { - GLuint swapBuffer; - GLuint reqTexUpload; - GLuint texUpload; - GLuint memTexUpload; - GLuint texSwaps; -} tdfxStats; - - - -/* - * Memory range from startAddr to endAddr-1 - */ -typedef struct mem_range { - struct mem_range *next; - FxU32 startAddr, endAddr; -} -tdfxMemRange; - - -typedef struct { - GLsizei width, height; /* image size */ - GLint wScale, hScale; /* scale factors */ - GrTextureFormat_t glideFormat; /* Glide image format */ -} -tdfxMipMapLevel; - - -#define TDFX_NUM_TMU 2 - - -typedef struct tdfxTexInfo_t -{ - GLboolean isInTM; - GLboolean reloadImages; /* if true, resend images to Glide */ - GLuint lastTimeUsed; - FxU32 whichTMU; - - GrTexInfo info; - GrAspectRatio_t aspectRatio; - tdfxMemRange *tm[TDFX_NUM_TMU]; - - GLint minLevel, maxLevel; - GrTextureFilterMode_t minFilt; - GrTextureFilterMode_t magFilt; - GrTextureClampMode_t sClamp; - GrTextureClampMode_t tClamp; - FxBool LODblend; - GrMipMapMode_t mmMode; - - GLfloat sScale, tScale; /* texcoord scale factor */ - - GrTexTable_t paltype; - GuTexPalette palette; - - GLboolean padded; -} -tdfxTexInfo; - - -#define TDFX_TEXTURE_DATA(mesaObj) ((tdfxTexInfo *)((mesaObj)->DriverData)) - -#define TDFX_TEXIMAGE_DATA(mesaImg) ((tdfxMipMapLevel *)((mesaImg)->DriverData)) - - - -/* - * This is state which may be shared by several tdfx contexts. - * It hangs off of Mesa's gl_shared_state object (ctx->Shared->DriverData). - */ -struct tdfxSharedState { - GLboolean umaTexMemory; - GLuint totalTexMem[TDFX_NUM_TMU]; /* constant */ - GLuint freeTexMem[TDFX_NUM_TMU]; /* changes as we go */ - tdfxMemRange *tmPool; - tdfxMemRange *tmFree[TDFX_NUM_TMU]; -}; - - - -/* ================================================================ - * The vertex structures. - */ -/* The size of this union is not of relevence: - */ -typedef struct tdfx_vertex_t { - GLfloat x, y, z; /* Coordinates in screen space */ - GLfloat rhw; /* Reciprocal homogeneous w */ - GLubyte color[4]; /* Diffuse color */ - GLfloat fog; - GLfloat tu0, tv0; /* Texture 0 coordinates */ - GLfloat tu1, tv1; /* Texture 1 coordinates */ - GLfloat tq0, tq1; /* Texture 0/1 q coords */ - unsigned char pspec[4]; /* B, G, R, A [0..255] */ - float psize; /* point size */ - long pad[16 - 14]; /* ensure 64b structure */ -} tdfxVertex, *tdfxVertexPtr; - - -/* ================================================================ - * - * We want to keep a mirror of the Glide function call parameters so we - * can avoid updating our state too often. - * - * Each of these broad groups will typically have a new state flag - * associated with it, and will be updated together. The individual - * Glide function calls each have a dirty flag and will only be called - * when absolutely necessary. - */ - -/* for grTexSource() */ -struct tdfx_texsource { - FxU32 StartAddress; - FxU32 EvenOdd; - GrTexInfo *Info; -}; - -/* Texture object params */ -struct tdfx_texparams { - GrTextureClampMode_t sClamp; - GrTextureClampMode_t tClamp; - GrTextureFilterMode_t minFilt; - GrTextureFilterMode_t magFilt; - GrMipMapMode_t mmMode; - FxBool LODblend; - GLfloat LodBias; -}; - -/* for grTexDownloadTable() texture palettes */ -struct tdfx_texpalette { - GrTexTable_t Type; - void *Data; -}; - -/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */ -struct tdfx_combine { - GrCombineFunction_t Function; /* Combine function */ - GrCombineFactor_t Factor; /* Combine scale factor */ - GrCombineLocal_t Local; /* Local combine source */ - GrCombineOther_t Other; /* Other combine source */ - FxBool Invert; /* Combine result inversion flag */ -}; - -/* for Voodoo3's grTexCombine() */ -struct tdfx_texcombine { - GrCombineFunction_t FunctionRGB; - GrCombineFactor_t FactorRGB; - GrCombineFunction_t FunctionAlpha; - GrCombineFactor_t FactorAlpha; - FxBool InvertRGB; - FxBool InvertAlpha; -}; - - -/* for Voodoo5's grColorCombineExt() */ -struct tdfx_combine_color_ext { - GrCCUColor_t SourceA; - GrCombineMode_t ModeA; - GrCCUColor_t SourceB; - GrCombineMode_t ModeB; - GrCCUColor_t SourceC; - FxBool InvertC; - GrCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grAlphaCombineExt() */ -struct tdfx_combine_alpha_ext { - GrACUColor_t SourceA; - GrCombineMode_t ModeA; - GrACUColor_t SourceB; - GrCombineMode_t ModeB; - GrACUColor_t SourceC; - FxBool InvertC; - GrACUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grTexColorCombineExt() */ -struct tdfx_color_texenv { - GrTCCUColor_t SourceA; - GrCombineMode_t ModeA; - GrTCCUColor_t SourceB; - GrCombineMode_t ModeB; - GrTCCUColor_t SourceC; - FxBool InvertC; - GrTCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* for Voodoo5's grTexAlphaCombineExt() */ -struct tdfx_alpha_texenv { - GrTACUColor_t SourceA; - GrCombineMode_t ModeA; - GrTACUColor_t SourceB; - GrCombineMode_t ModeB; - GrTACUColor_t SourceC; - FxBool InvertC; - GrTCCUColor_t SourceD; - FxBool InvertD; - FxU32 Shift; - FxBool Invert; -}; - -/* Voodoo5's texture combine environment */ -struct tdfx_texcombine_ext { - struct tdfx_alpha_texenv Alpha; - struct tdfx_color_texenv Color; - GrColor_t EnvColor; -}; - -/* Used to track changes between Glide's state and Mesa's */ -struct tdfx_texstate { - GLuint Enabled[2]; /* values ala ctx->Texture.Unit[i]._ReallyEnabled */ - GLenum EnvMode[TDFX_NUM_TMU]; /* index is Glide index, not OpenGL */ - GLenum TexFormat[TDFX_NUM_TMU]; /* index is Glide index, not OpenGL */ -}; - -struct tdfx_color { - GrColor_t ClearColor; /* Buffer clear color value */ - GrAlpha_t ClearAlpha; /* Buffer clear alpha value */ - FxBool ColorMask[4]; /* Per-channel write enable flags */ - - GrColor_t MonoColor; /* Constant color value */ - - /* Alpha testing */ - GrCmpFnc_t AlphaFunc; /* Alpha test function */ - GrAlpha_t AlphaRef; /* Alpha ref value in range [0,255] */ - - /* Blending */ - GrAlphaBlendFnc_t BlendSrcRGB; /* Blend source RGB factor */ - GrAlphaBlendFnc_t BlendDstRGB; /* Blend destination RGB factor */ - GrAlphaBlendOp_t BlendEqRGB; /* Blend source RGB op */ - GrAlphaBlendFnc_t BlendSrcA; /* Blend source alpha factor */ - GrAlphaBlendFnc_t BlendDstA; /* Blend destination alpha factor */ - GrAlphaBlendOp_t BlendEqA; /* Blend source alpha op */ - - GrDitherMode_t Dither; /* Dither enable */ -}; - -struct tdfx_depth { - GrDepthBufferMode_t Mode; /* Fixed-point Z or floating-point W */ - FxI32 Bias; /* Polygon offset factor */ - GrCmpFnc_t Func; /* Depth test function */ - FxU32 Clear; /* Buffer clear value */ - FxBool Mask; /* Write enable flag */ -}; - -struct tdfx_stipple { - GrStippleMode_t Mode; /* Stipple enable/disable */ - FxU32 Pattern; /* 8x4 Stipple Pattern */ -}; - -struct tdfx_fog { - GrFogMode_t Mode; /* Glide fog mode */ - GrColor_t Color; /* Fog color value */ - GLenum TableMode; /* GL fog mode currently in table */ - GrFog_t *Table; /* Fog value table */ - FxFloat Density; /* Density >= 0 */ - FxFloat Near; /* Start distance in eye coords */ - FxFloat Far; /* End distance in eye coords */ -}; - -struct tdfx_stencil { - GrCmpFnc_t Function; /* Stencil function */ - GrStencil_t RefValue; /* Stencil reference value */ - GrStencil_t ValueMask; /* Value mask */ - GrStencil_t WriteMask; /* Write mask */ - GrStencil_t FailFunc; /* Stencil fail function */ - GrStencil_t ZFailFunc; /* Stencil pass, depth fail function */ - GrStencil_t ZPassFunc; /* Stencil pass, depth pass function */ - GrStencil_t Clear; /* Buffer clear value */ -}; - -struct tdfx_scissor { - FxU32 minX, minY; /* Lower left corner */ - FxU32 maxX, maxY; /* Upper right corner */ -}; - -struct tdfx_viewport { - GrCoordinateSpaceMode_t Mode; /* Coordinate space */ - FxI32 X, Y; /* Position */ - FxI32 Width, Height; /* Size */ - FxFloat Near, Far; /* Depth buffer range */ -}; - -struct tdfx_glide { - void *State; /* Mirror of internal Glide state */ - GrContext_t Context; /* Glide context identifier */ - FxI32 Board; /* Current graphics subsystem */ - GrColorFormat_t ColorFormat; /* Framebuffer format */ - GrOriginLocation_t Origin; /* Location of screen space origin */ - - FxBool Initialized; /* Glide initialization done? */ - - FxI32 SwapInterval; /* SwapBuffers interval */ - FxI32 MaxPendingSwaps; /* Maximum outstanding SwapBuffers */ - FxI32 TextureAlign; - - /* Extensions */ - FxBool HaveCombineExt; /* COMBINE */ - FxBool HaveCommandTransportExt; /* COMMAND_TRANSPORT */ - FxBool HaveFogCoordExt; /* FOGCOORD */ - FxBool HavePixelExt; /* PIXEXT */ - FxBool HaveTextureBufferExt; /* TEXTUREBUFFER */ - FxBool HaveTexFmtExt; /* TEXFMT */ - FxBool HaveTexUMAExt; /* TEXUMA */ - FxBool HaveMirrorExt; /* MIRROR */ - FxBool HaveTexus2; /* Texus 2 - FXT1 */ - - /* Glide library function pointers */ - void (*grDrawPoint)( const void *pt ); - void (*grDrawLine)( const void *v1, const void *v2 ); - void (*grDrawTriangle)( const void *a, const void *b, const void *c ); - void (*grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode); - void (*grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers); - void (*grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count, - void *pointers, FxU32 stride); - void (*grBufferClear)( GrColor_t color, GrAlpha_t alpha, FxU32 depth ); - void (*grBufferSwap)( FxU32 swap_interval ); - void (*grRenderBuffer)( GrBuffer_t buffer ); - void (*grErrorSetCallback)( GrErrorCallbackFnc_t fnc ); - void (*grFinish)(void); - void (*grFlush)(void); - GrContext_t (*grSstWinOpen)(FxU32 hWnd, - GrScreenResolution_t screen_resolution, - GrScreenRefresh_t refresh_rate, - GrColorFormat_t color_format, - GrOriginLocation_t origin_location, - int nColBuffers, - int nAuxBuffers); - void (*grSstWinClose)( GrContext_t context ); -/* Not used */ -#if 0 - void (*grSetNumPendingBuffers)(FxI32 NumPendingBuffers); -#endif - void (*grSelectContext)( GrContext_t context ); - void (*grSstOrigin)(GrOriginLocation_t origin); - void (*grSstSelect)( int which_sst ); - void (*grAlphaBlendFunction)(GrAlphaBlendFnc_t rgb_sf, - GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendFnc_t alpha_sf, - GrAlphaBlendFnc_t alpha_df); - void (*grAlphaCombine)(GrCombineFunction_t function, - GrCombineFactor_t factor, - GrCombineLocal_t local, GrCombineOther_t other, - FxBool invert); - void (*grAlphaControlsITRGBLighting)( FxBool enable ); - void (*grAlphaTestFunction)( GrCmpFnc_t function ); - void (*grAlphaTestReferenceValue)( GrAlpha_t value ); - void (*grChromakeyMode)( GrChromakeyMode_t mode ); - void (*grChromakeyValue)( GrColor_t value ); - void (*grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy ); - void (*grColorCombine)( GrCombineFunction_t function, - GrCombineFactor_t factor, - GrCombineLocal_t local, - GrCombineOther_t other, - FxBool invert ); - void (*grColorMask)( FxBool rgb, FxBool a ); - void (*grCullMode)( GrCullMode_t mode ); - void (*grConstantColorValue)( GrColor_t value ); - void (*grDepthBiasLevel)( FxI32 level ); - void (*grDepthBufferFunction)( GrCmpFnc_t function ); - void (*grDepthBufferMode)( GrDepthBufferMode_t mode ); - void (*grDepthMask)( FxBool mask ); - void (*grDisableAllEffects)( void ); - void (*grDitherMode)( GrDitherMode_t mode ); - void (*grFogColorValue)( GrColor_t fogcolor ); - void (*grFogMode)( GrFogMode_t mode ); - void (*grFogTable)( const GrFog_t ft[] ); - void (*grLoadGammaTable)( FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue); - void (*grSplash)(float x, float y, float width, float height, FxU32 frame); - FxU32 (*grGet)( FxU32 pname, FxU32 plength, FxI32 *params ); - const char * (*grGetString)( FxU32 pname ); - FxI32 (*grQueryResolutions)( const GrResolution *resTemplate, - GrResolution *output ); - FxBool (*grReset)( FxU32 what ); - GrProc (*grGetProcAddress)( char *procName ); - void (*grEnable)( GrEnableMode_t mode ); - void (*grDisable)( GrEnableMode_t mode ); - void (*grCoordinateSpace)( GrCoordinateSpaceMode_t mode ); - void (*grDepthRange)( FxFloat n, FxFloat f ); - void (*grStippleMode)( GrStippleMode_t mode ); - void (*grStipplePattern)( GrStipplePattern_t mode ); - void (*grViewport)( FxI32 x, FxI32 y, FxI32 width, FxI32 height ); - FxU32 (*grTexCalcMemRequired)(GrLOD_t lodmin, GrLOD_t lodmax, - GrAspectRatio_t aspect, GrTextureFormat_t fmt); - FxU32 (*grTexTextureMemRequired)( FxU32 evenOdd, GrTexInfo *info ); - FxU32 (*grTexMinAddress)( GrChipID_t tmu ); - FxU32 (*grTexMaxAddress)( GrChipID_t tmu ); - void (*grTexNCCTable)( GrNCCTable_t table ); - void (*grTexSource)( GrChipID_t tmu, FxU32 startAddress, - FxU32 evenOdd, GrTexInfo *info ); - void (*grTexClampMode)( GrChipID_t tmu, - GrTextureClampMode_t s_clampmode, - GrTextureClampMode_t t_clampmode ); - void (*grTexCombine)( GrChipID_t tmu, - GrCombineFunction_t rgb_function, - GrCombineFactor_t rgb_factor, - GrCombineFunction_t alpha_function, - GrCombineFactor_t alpha_factor, - FxBool rgb_invert, - FxBool alpha_invert); - void (*grTexDetailControl)( GrChipID_t tmu, int lod_bias, - FxU8 detail_scale, float detail_max ); - void (*grTexFilterMode)( GrChipID_t tmu, - GrTextureFilterMode_t minfilter_mode, - GrTextureFilterMode_t magfilter_mode ); - void (*grTexLodBiasValue)(GrChipID_t tmu, float bias ); - void (*grTexDownloadMipMap)( GrChipID_t tmu, FxU32 startAddress, - FxU32 evenOdd, GrTexInfo *info ); - void (*grTexDownloadMipMapLevel)( GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data ); - FxBool (*grTexDownloadMipMapLevelPartial)( GrChipID_t tmu, - FxU32 startAddress, - GrLOD_t thisLod, - GrLOD_t largeLod, - GrAspectRatio_t aspectRatio, - GrTextureFormat_t format, - FxU32 evenOdd, - void *data, - int start, - int end ); - void (*grTexDownloadTable)( GrTexTable_t type, void *data ); - void (*grTexDownloadTablePartial)( GrTexTable_t type, - void *data, int start, int end ); - void (*grTexMipMapMode)( GrChipID_t tmu, GrMipMapMode_t mode, - FxBool lodBlend ); - void (*grTexMultibase)( GrChipID_t tmu, FxBool enable ); - void (*grTexMultibaseAddress)( GrChipID_t tmu, - GrTexBaseRange_t range, - FxU32 startAddress, - FxU32 evenOdd, - GrTexInfo *info ); - FxBool (*grLfbLock)( GrLock_t type, GrBuffer_t buffer, - GrLfbWriteMode_t writeMode, - GrOriginLocation_t origin, FxBool pixelPipeline, - GrLfbInfo_t *info ); - FxBool (*grLfbUnlock)( GrLock_t type, GrBuffer_t buffer ); - void (*grLfbConstantAlpha)( GrAlpha_t alpha ); - void (*grLfbConstantDepth)( FxU32 depth ); - void (*grLfbWriteColorSwizzle)(FxBool swizzleBytes, FxBool swapWords); - void (*grLfbWriteColorFormat)(GrColorFormat_t colorFormat); - FxBool (*grLfbWriteRegion)( GrBuffer_t dst_buffer, - FxU32 dst_x, FxU32 dst_y, - GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, - FxBool pixelPipeline, - FxI32 src_stride, void *src_data ); - FxBool (*grLfbReadRegion)( GrBuffer_t src_buffer, - FxU32 src_x, FxU32 src_y, - FxU32 src_width, FxU32 src_height, - FxU32 dst_stride, void *dst_data ); - void (*grGlideInit)( void ); - void (*grGlideShutdown)( void ); - void (*grGlideGetState)( void *state ); - void (*grGlideSetState)( const void *state ); - void (*grGlideGetVertexLayout)( void *layout ); - void (*grGlideSetVertexLayout)( const void *layout ); - /* Glide utility functions */ - void (*guFogGenerateExp)( GrFog_t *fogtable, float density ); - void (*guFogGenerateExp2)( GrFog_t *fogtable, float density ); - void (*guFogGenerateLinear)(GrFog_t *fogtable, float nearZ, float farZ ); - /* DRI functions */ - void (*grDRIOpen)( char *pFB, char *pRegs, int deviceID, - int width, int height, - int mem, int cpp, int stride, - int fifoOffset, int fifoSize, - int fbOffset, int backOffset, int depthOffset, - int textureOffset, int textureSize, - volatile int *fifoPtr, volatile int *fifoRead ); - void (*grDRIPosition)( int x, int y, int w, int h, - int numClip, drm_clip_rect_t *pClip ); - void (*grDRILostContext)( void ); - void (*grDRIImportFifo)( int fifoPtr, int fifoRead ); - void (*grDRIInvalidateAll)( void ); - void (*grDRIResetSAREA)( void ); - void (*grDRIBufferSwap)( FxU32 swapInterval ); - /* Glide extensions */ - /* PIXEXT extension */ - void (*grStencilFunc)( GrCmpFnc_t func, GrStencil_t ref, GrStencil_t mask ); - void (*grStencilMask)( GrStencil_t mask ); - void (*grStencilOp)( GrStencilOp_t fail, GrStencilOp_t zfail, - GrStencilOp_t zpass ); - void (*grBufferClearExt)( GrColor_t color, GrAlpha_t alpha, - FxU32 depth, GrStencil_t stencil ); - void (*grColorMaskExt)( FxBool r, FxBool g, FxBool b, FxBool a ); - /* COMBINE extension */ - void (*grColorCombineExt)( GrCCUColor_t a, GrCombineMode_t a_mode, - GrCCUColor_t b, GrCombineMode_t b_mode, - GrCCUColor_t c, FxBool c_invert, - GrCCUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grTexColorCombineExt)( FxU32 tmu, - GrTCCUColor_t a, GrCombineMode_t a_mode, - GrTCCUColor_t b, GrCombineMode_t b_mode, - GrTCCUColor_t c, FxBool c_invert, - GrTCCUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grAlphaCombineExt)( GrACUColor_t a, GrCombineMode_t a_mode, - GrACUColor_t b, GrCombineMode_t b_mode, - GrACUColor_t c, FxBool c_invert, - GrACUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grTexAlphaCombineExt)( FxU32 tmu, - GrTACUColor_t a, GrCombineMode_t a_mode, - GrTACUColor_t b, GrCombineMode_t b_mode, - GrTACUColor_t c, FxBool c_invert, - GrTACUColor_t d, FxBool d_invert, - FxU32 shift, FxBool invert ); - void (*grAlphaBlendFunctionExt)( GrAlphaBlendFnc_t rgb_sf, - GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendOp_t rgb_op, - GrAlphaBlendFnc_t alpha_sf, - GrAlphaBlendFnc_t alpha_df, - GrAlphaBlendOp_t alpha_op ); - void (*grConstantColorValueExt)( FxU32 tmu, GrColor_t value ); - /* Texus 2 */ - void (*txImgQuantize)( void *xxx_unknown_arguments ); - void (*txImgDequantizeFXT1)( void *txMip, void *pxMip ); - void (*txErrorSetCallback)( void *fnc ); -}; - -typedef void (*tdfx_tri_func)( tdfxContextPtr, tdfxVertex *, tdfxVertex *, - tdfxVertex * ); -typedef void (*tdfx_line_func)( tdfxContextPtr, tdfxVertex *, tdfxVertex * ); -typedef void (*tdfx_point_func)( tdfxContextPtr, tdfxVertex * ); - -struct tdfx_context { - /* Set once and never changed: - */ - GLcontext *glCtx; /* The core Mesa context */ - - GLuint new_gl_state; - GLuint new_state; - GLuint dirty; - - /* Mirror of hardware state, Glide parameters - */ - GLuint tmu_source[TDFX_NUM_TMU]; - struct tdfx_texsource TexSource[TDFX_NUM_TMU]; - struct tdfx_texparams TexParams[TDFX_NUM_TMU]; - struct tdfx_texpalette TexPalette; - - /* Voodoo3 texture/color combine state */ - struct tdfx_combine ColorCombine; - struct tdfx_combine AlphaCombine; - struct tdfx_texcombine TexCombine[TDFX_NUM_TMU]; - - /* Voodoo5 texture/color combine state */ - struct tdfx_combine_color_ext ColorCombineExt; - struct tdfx_combine_alpha_ext AlphaCombineExt; - struct tdfx_texcombine_ext TexCombineExt[TDFX_NUM_TMU]; - - /* Tracks tex state difference between Glide and Mesa */ - struct tdfx_texstate TexState; - - GrBuffer_t DrawBuffer; /* Current draw buffer */ - GrBuffer_t ReadBuffer; /* Current read buffer */ - - struct tdfx_color Color; - struct tdfx_depth Depth; - struct tdfx_fog Fog; - struct tdfx_stencil Stencil; - struct tdfx_scissor Scissor; - struct tdfx_viewport Viewport; - struct tdfx_stipple Stipple; - - GrCullMode_t CullMode; - - struct tdfx_glide Glide; - - /* Fallback rasterization functions - */ - tdfx_point_func draw_point; - tdfx_line_func draw_line; - tdfx_tri_func draw_triangle; - - - /* Variable-size Glide vertex formats - */ - GLuint vertexFormat; /* the current format */ - void *layout[TDFX_NUM_LAYOUTS]; - tdfxVertex *verts; - - GLfloat hw_viewport[16]; - - GLuint SetupIndex; - GLuint SetupNewInputs; - GLuint RenderIndex; - GLuint Fallback; - GLenum render_primitive; /* what GL thinks */ - GLenum raster_primitive; /* what the hardware thinks */ - - GLfloat sScale0, tScale0; - GLfloat sScale1, tScale1; - - GLuint texBindNumber; - GLint tmuSrc; - - int screen_width; - int screen_height; - - GLboolean haveTwoTMUs; /* True if we have 2 tmu's */ - GLboolean haveHwAlpha; - GLboolean haveHwStencil; - GLboolean haveHwStipple; - - GLint maxPendingSwapBuffers; - - char rendererString[100]; - - /* stuff added for DRI */ - __DRIscreenPrivate *driScreen; - __DRIcontextPrivate *driContext; - __DRIdrawablePrivate *driDrawable; - drm_context_t hHWContext; - drm_hw_lock_t *driHwLock; - int driFd; - tdfxScreenPrivate *fxScreen; - TDFXSAREAPriv *sarea; - - - /* - * Changes during execution: - */ - int width, height; /* size of window */ - int x_offset; /* distance from window left to screen left */ - int y_offset; /* distance from window top to screen top */ - int y_delta; /* distance from window bottom to screen bottom */ - - int numClipRects; - drm_clip_rect_t *pClipRects; - GLboolean scissoredClipRects; /* if true, pClipRects is private storage */ - - GuTexPalette glbPalette; /* global texture palette */ - - tdfxStats stats; - - /* Configuration cache - */ - driOptionCache optionCache; -}; - -#define TDFX_CONTEXT(ctx) ((tdfxContextPtr)((ctx)->DriverCtx)) - - -extern GLboolean -tdfxCreateContext( const __GLcontextModes *mesaVis, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate ); - -extern void -tdfxDestroyContext( __DRIcontextPrivate *driContextPriv ); - -extern GLboolean -tdfxUnbindContext( __DRIcontextPrivate *driContextPriv ); - -extern GLboolean -tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv ); - -extern GLboolean -tdfxInitGlide( tdfxContextPtr tmesa ); - -extern void -FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4]); - -extern void -FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]); - - -/* Color packing utilities - */ -#define TDFXPACKCOLOR332( r, g, b ) \ - (((b) & 0xe0) | (((g) & 0xe0) >> 3) | (((r) & 0xc0) >> 6)) - -#define TDFXPACKCOLOR1555( r, g, b, a ) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define TDFXPACKCOLOR565( r, g, b ) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define TDFXPACKCOLOR888( r, g, b ) \ - (((b) << 16) | ((g) << 8) | (r)) - -#define TDFXPACKCOLOR8888( r, g, b, a ) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define TDFXPACKCOLOR4444( r, g, b, a ) \ - ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((g) & 0xf0) | ((r) >> 4)) - -static __inline__ GrColor_t tdfxPackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return TDFXPACKCOLOR565( r, g, b ); - case 4: - return TDFXPACKCOLOR8888( r, g, b, a ); - default: - return 0; - } -} - -#define DO_DEBUG 1 -#if DO_DEBUG -extern int TDFX_DEBUG; -#else -#define TDFX_DEBUG 0 -#endif - -#define DEBUG_ALWAYS_SYNC 0x01 -#define DEBUG_VERBOSE_API 0x02 -#define DEBUG_VERBOSE_DRI 0x04 -#define DEBUG_VERBOSE_FALL 0x08 - -/* conf */ -#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1 -#define FX_TC_NAPALM 0 - -#endif /* __TDFX_CONTEXT_H__ */ diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c deleted file mode 100644 index 02fbace5b..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c +++ /dev/null @@ -1,322 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c,v 1.10 2002/10/30 12:52:00 alanh Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#include "tdfx_context.h" -#include "tdfx_dd.h" -#include "tdfx_lock.h" -#include "tdfx_vb.h" -#include "tdfx_pixels.h" - -#include "context.h" -#include "enums.h" -#include "framebuffer.h" -#include "swrast/swrast.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif - - -#define TDFX_DATE "20040719" - - -/* These are used in calls to FX_grColorMaskv() */ -const GLboolean false4[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; -const GLboolean true4[4] = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; - - - -/* 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 *tdfxDDGetString( GLcontext *ctx, GLenum name ) -{ - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - - switch ( name ) { - case GL_RENDERER: - { - /* The renderer string must be per-context state to handle - * multihead correctly. - */ - char *buffer = fxMesa->rendererString; - char hardware[100]; - - LOCK_HARDWARE(fxMesa); - strcpy( hardware, fxMesa->Glide.grGetString(GR_HARDWARE) ); - UNLOCK_HARDWARE(fxMesa); - - strcpy( buffer, "Mesa DRI " ); - strcat( buffer, TDFX_DATE ); - strcat( buffer, " " ); - - if ( strcmp( hardware, "Voodoo3 (tm)" ) == 0 ) { - strcat( buffer, "Voodoo3" ); - } - else if ( strcmp( hardware, "Voodoo Banshee (tm)" ) == 0 ) { - strcat( buffer, "VoodooBanshee" ); - } - else if ( strcmp( hardware, "Voodoo4 (tm)" ) == 0 ) { - strcat( buffer, "Voodoo4" ); - } - else if ( strcmp( hardware, "Voodoo5 (tm)" ) == 0 ) { - strcat( buffer, "Voodoo5" ); - } - else { - /* unexpected result: replace spaces with hyphens */ - int i; - for ( i = 0 ; hardware[i] && i < 60 ; i++ ) { - if ( hardware[i] == ' ' || hardware[i] == '\t' ) - hardware[i] = '-'; - } - strcat( buffer, hardware ); - } - - /* Append any CPU-specific information. - */ -#ifdef USE_X86_ASM - if ( _mesa_x86_cpu_features ) { - strncat( buffer, " x86", 4 ); - } -#endif -#ifdef USE_MMX_ASM - if ( cpu_has_mmx ) { - strncat( buffer, "/MMX", 4 ); - } -#endif -#ifdef USE_3DNOW_ASM - if ( cpu_has_3dnow ) { - strncat( buffer, "/3DNow!", 7 ); - } -#endif -#ifdef USE_SSE_ASM - if ( cpu_has_xmm ) { - strncat( buffer, "/SSE", 4 ); - } -#endif - return (const GLubyte *) buffer; - } - case GL_VENDOR: - return (const GLubyte *)"VA Linux Systems, Inc."; - default: - return NULL; - } -} - - -/* Return uptodate buffer size information. - */ -static void tdfxDDGetBufferSize( GLframebuffer *buffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - LOCK_HARDWARE( fxMesa ); - *width = fxMesa->width; - *height = fxMesa->height; - UNLOCK_HARDWARE( fxMesa ); -} - - - -/* - * Return the current value of the occlusion test flag and - * reset the flag (hardware counters) to false. - */ -static GLboolean get_occlusion_result( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLboolean result; - - LOCK_HARDWARE( fxMesa ); - fxMesa->Glide.grFinish(); /* required to flush the FIFO - FB 21-01-2002 */ - - if (ctx->Depth.OcclusionTest) { - if (ctx->OcclusionResult) { - result = GL_TRUE; /* result of software rendering */ - } - else { - FxI32 zfail, in; - fxMesa->Glide.grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &zfail); - fxMesa->Glide.grGet(GR_STATS_PIXELS_IN, 4, &in); - /* Geometry is occluded if there is no input (in == 0) */ - /* or if all pixels failed the depth test (zfail == in) */ - /* The < 1 is there because I have empirically seen cases where */ - /* zfail > in.... go figure. FB - 21-01-2002. */ - result = ((in - zfail) < 1 || in == 0) ? GL_FALSE : GL_TRUE; - } - } - else { - result = ctx->OcclusionResultSaved; - } - - /* reset results now */ - fxMesa->Glide.grReset(GR_STATS_PIXELS); - ctx->OcclusionResult = GL_FALSE; - ctx->OcclusionResultSaved = GL_FALSE; - - UNLOCK_HARDWARE( fxMesa ); - - return result; -} - - -/* - * We're only implementing this function to handle the - * GL_OCCLUSTION_TEST_RESULT_HP case. It's special because it - * has a side-effect: resetting the occlustion result flag. - */ -static GLboolean tdfxDDGetBooleanv( GLcontext *ctx, GLenum pname, - GLboolean *result ) -{ - if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) { - *result = get_occlusion_result( ctx ); - return GL_TRUE; - } - return GL_FALSE; -} - -static GLboolean tdfxDDGetDoublev( GLcontext *ctx, GLenum pname, - GLdouble *result ) -{ - if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) { - *result = (GLdouble) get_occlusion_result( ctx ); - return GL_TRUE; - } - return GL_FALSE; -} - -static GLboolean tdfxDDGetFloatv( GLcontext *ctx, GLenum pname, - GLfloat *result ) -{ - if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) { - *result = (GLfloat) get_occlusion_result( ctx ); - return GL_TRUE; - } - return GL_FALSE; -} - -static GLboolean tdfxDDGetIntegerv( GLcontext *ctx, GLenum pname, - GLint *result ) -{ - if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) { - *result = (GLint) get_occlusion_result( ctx ); - return GL_TRUE; - } - return GL_FALSE; -} - - - -#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \ - ((vis->redBits == r) && \ - (vis->greenBits == g) && \ - (vis->blueBits == b) && \ - (vis->alphaBits == a)) - -void tdfxDDInitDriverFuncs( const __GLcontextModes *visual, - struct dd_function_table *functions ) -{ - if ( MESA_VERBOSE & VERBOSE_DRIVER ) { - fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ ); - } - - functions->GetString = tdfxDDGetString; - functions->GetBufferSize = tdfxDDGetBufferSize; - functions->ResizeBuffers = _mesa_resize_framebuffer; - - /* Accelerated paths - */ - if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) ) - { - functions->DrawPixels = tdfx_drawpixels_R8G8B8A8; - functions->ReadPixels = tdfx_readpixels_R8G8B8A8; - } - else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) ) - { - functions->ReadPixels = tdfx_readpixels_R5G6B5; - } - - functions->GetBooleanv = tdfxDDGetBooleanv; - functions->GetDoublev = tdfxDDGetDoublev; - functions->GetFloatv = tdfxDDGetFloatv; - functions->GetIntegerv = tdfxDDGetIntegerv; -} - - -/* - * These are here for lack of a better place. - */ - -void -FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4]) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - LOCK_HARDWARE(fxMesa); - if (ctx->Visual.redBits == 8) { - /* 32bpp mode */ - ASSERT( fxMesa->Glide.grColorMaskExt ); - fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP], - rgba[BCOMP], rgba[ACOMP]); - } - else { - /* 16 bpp mode */ - /* we never have an alpha buffer */ - fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP], - GL_FALSE); - } - UNLOCK_HARDWARE(fxMesa); -} - -void -FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - if (ctx->Visual.redBits == 8) { - /* 32bpp mode */ - ASSERT( fxMesa->Glide.grColorMaskExt ); - fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP], - rgba[BCOMP], rgba[ACOMP]); - } - else { - /* 16 bpp mode */ - /* we never have an alpha buffer */ - fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP], - GL_FALSE); - } -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h deleted file mode 100644 index 5ceba9d5f..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.h,v 1.1 2001/03/21 16:14:27 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#ifndef __TDFX_DD_H__ -#define __TDFX_DD_H__ - -#include "context.h" - -extern void tdfxDDInitDriverFuncs( const __GLcontextModes *visual, - struct dd_function_table *functions ); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h deleted file mode 100644 index f077aa678..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h +++ /dev/null @@ -1,606 +0,0 @@ -/* - * This file defines macros and types necessary for accessing glide3. - */ - -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_glide.h,v 1.1 2002/02/22 21:45:03 dawes Exp $ */ - -#ifndef NEWGLIDE_H -#define NEWGLIDE_H - -#define FX_CALL - -typedef unsigned char FxU8; -typedef signed char FxI8; -typedef unsigned short FxU16; -typedef signed short FxI16; -#if defined(__alpha__) || defined (__LP64__) -typedef signed int FxI32; -typedef unsigned int FxU32; -#else -typedef signed long FxI32; -typedef unsigned long FxU32; -#endif -typedef unsigned long AnyPtr; -typedef int FxBool; -typedef float FxFloat; -typedef double FxDouble; - -typedef unsigned long FxColor_t; -typedef struct -{ - float r, g, b, a; -} -FxColor4; - -typedef FxU32 GrColor_t; -typedef FxU8 GrAlpha_t; -typedef FxU32 GrMipMapId_t; -typedef FxU32 GrStipplePattern_t; -typedef FxU8 GrFog_t; -typedef FxU32 GrContext_t; -typedef int (FX_CALL * GrProc) (void); - -#define FXTRUE 1 -#define FXFALSE 0 - -#define FXBIT(i) (1L << (i)) - -#define GR_NULL_MIPMAP_HANDLE ((GrMipMapId_t) -1) - -#define GR_MIPMAPLEVELMASK_EVEN FXBIT(0) -#define GR_MIPMAPLEVELMASK_ODD FXBIT(1) -#define GR_MIPMAPLEVELMASK_BOTH (GR_MIPMAPLEVELMASK_EVEN | GR_MIPMAPLEVELMASK_ODD ) - -typedef FxI32 GrChipID_t; -#define GR_TMU0 0x0 -#define GR_TMU1 0x1 -#define GR_TMU2 0x2 - -#define GR_FBI 0x0 - -typedef FxI32 GrCombineFunction_t; -#define GR_COMBINE_FUNCTION_ZERO 0x0 -#define GR_COMBINE_FUNCTION_NONE GR_COMBINE_FUNCTION_ZERO -#define GR_COMBINE_FUNCTION_LOCAL 0x1 -#define GR_COMBINE_FUNCTION_LOCAL_ALPHA 0x2 -#define GR_COMBINE_FUNCTION_SCALE_OTHER 0x3 -#define GR_COMBINE_FUNCTION_BLEND_OTHER GR_COMBINE_FUNCTION_SCALE_OTHER -#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL 0x4 -#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA 0x5 -#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL 0x6 -#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL 0x7 -#define GR_COMBINE_FUNCTION_BLEND GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL -#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x8 -#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL 0x9 -#define GR_COMBINE_FUNCTION_BLEND_LOCAL GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL -#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x10 - -typedef FxI32 GrCombineFactor_t; -#define GR_COMBINE_FACTOR_ZERO 0x0 -#define GR_COMBINE_FACTOR_NONE GR_COMBINE_FACTOR_ZERO -#define GR_COMBINE_FACTOR_LOCAL 0x1 -#define GR_COMBINE_FACTOR_OTHER_ALPHA 0x2 -#define GR_COMBINE_FACTOR_LOCAL_ALPHA 0x3 -#define GR_COMBINE_FACTOR_TEXTURE_ALPHA 0x4 -#define GR_COMBINE_FACTOR_TEXTURE_RGB 0x5 -#define GR_COMBINE_FACTOR_DETAIL_FACTOR GR_COMBINE_FACTOR_TEXTURE_ALPHA -#define GR_COMBINE_FACTOR_LOD_FRACTION 0x5 -#define GR_COMBINE_FACTOR_ONE 0x8 -#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL 0x9 -#define GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA 0xa -#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA 0xb -#define GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA 0xc -#define GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA -#define GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION 0xd - -typedef FxI32 GrCombineLocal_t; -#define GR_COMBINE_LOCAL_ITERATED 0x0 -#define GR_COMBINE_LOCAL_CONSTANT 0x1 -#define GR_COMBINE_LOCAL_NONE GR_COMBINE_LOCAL_CONSTANT -#define GR_COMBINE_LOCAL_DEPTH 0x2 - -typedef FxI32 GrCombineOther_t; -#define GR_COMBINE_OTHER_ITERATED 0x0 -#define GR_COMBINE_OTHER_TEXTURE 0x1 -#define GR_COMBINE_OTHER_CONSTANT 0x2 -#define GR_COMBINE_OTHER_NONE GR_COMBINE_OTHER_CONSTANT - -typedef FxI32 GrAlphaSource_t; -#define GR_ALPHASOURCE_CC_ALPHA 0x0 -#define GR_ALPHASOURCE_ITERATED_ALPHA 0x1 -#define GR_ALPHASOURCE_TEXTURE_ALPHA 0x2 -#define GR_ALPHASOURCE_TEXTURE_ALPHA_TIMES_ITERATED_ALPHA 0x3 - -typedef FxI32 GrColorCombineFnc_t; -#define GR_COLORCOMBINE_ZERO 0x0 -#define GR_COLORCOMBINE_CCRGB 0x1 -#define GR_COLORCOMBINE_ITRGB 0x2 -#define GR_COLORCOMBINE_ITRGB_DELTA0 0x3 -#define GR_COLORCOMBINE_DECAL_TEXTURE 0x4 -#define GR_COLORCOMBINE_TEXTURE_TIMES_CCRGB 0x5 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB 0x6 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_DELTA0 0x7 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_ADD_ALPHA 0x8 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA 0x9 -#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA_ADD_ITRGB 0xa -#define GR_COLORCOMBINE_TEXTURE_ADD_ITRGB 0xb -#define GR_COLORCOMBINE_TEXTURE_SUB_ITRGB 0xc -#define GR_COLORCOMBINE_CCRGB_BLEND_ITRGB_ON_TEXALPHA 0xd -#define GR_COLORCOMBINE_DIFF_SPEC_A 0xe -#define GR_COLORCOMBINE_DIFF_SPEC_B 0xf -#define GR_COLORCOMBINE_ONE 0x10 - -typedef FxI32 GrAlphaBlendFnc_t; -#define GR_BLEND_ZERO 0x0 -#define GR_BLEND_SRC_ALPHA 0x1 -#define GR_BLEND_SRC_COLOR 0x2 -#define GR_BLEND_DST_COLOR GR_BLEND_SRC_COLOR -#define GR_BLEND_DST_ALPHA 0x3 -#define GR_BLEND_ONE 0x4 -#define GR_BLEND_ONE_MINUS_SRC_ALPHA 0x5 -#define GR_BLEND_ONE_MINUS_SRC_COLOR 0x6 -#define GR_BLEND_ONE_MINUS_DST_COLOR GR_BLEND_ONE_MINUS_SRC_COLOR -#define GR_BLEND_ONE_MINUS_DST_ALPHA 0x7 -#define GR_BLEND_RESERVED_8 0x8 -#define GR_BLEND_RESERVED_9 0x9 -#define GR_BLEND_RESERVED_A 0xa -#define GR_BLEND_RESERVED_B 0xb -#define GR_BLEND_RESERVED_C 0xc -#define GR_BLEND_RESERVED_D 0xd -#define GR_BLEND_RESERVED_E 0xe -#define GR_BLEND_ALPHA_SATURATE 0xf -#define GR_BLEND_PREFOG_COLOR GR_BLEND_ALPHA_SATURATE -#define GR_BLEND_SAME_COLOR_EXT 0x08 -#define GR_BLEND_ONE_MINUS_SAME_COLOR_EXT 0x09 - -typedef FxI32 GrAspectRatio_t; -#define GR_ASPECT_LOG2_8x1 3 -#define GR_ASPECT_LOG2_4x1 2 -#define GR_ASPECT_LOG2_2x1 1 -#define GR_ASPECT_LOG2_1x1 0 -#define GR_ASPECT_LOG2_1x2 -1 -#define GR_ASPECT_LOG2_1x4 -2 -#define GR_ASPECT_LOG2_1x8 -3 - -typedef FxI32 GrBuffer_t; -#define GR_BUFFER_FRONTBUFFER 0x0 -#define GR_BUFFER_BACKBUFFER 0x1 -#define GR_BUFFER_AUXBUFFER 0x2 -#define GR_BUFFER_DEPTHBUFFER 0x3 -#define GR_BUFFER_ALPHABUFFER 0x4 -#define GR_BUFFER_TRIPLEBUFFER 0x5 - -typedef FxI32 GrChromakeyMode_t; -#define GR_CHROMAKEY_DISABLE 0x0 -#define GR_CHROMAKEY_ENABLE 0x1 - -typedef FxI32 GrChromaRangeMode_t; -#define GR_CHROMARANGE_RGB_ALL_EXT 0x0 - -#define GR_CHROMARANGE_DISABLE_EXT 0x00 -#define GR_CHROMARANGE_ENABLE_EXT 0x01 - -typedef FxI32 GrTexChromakeyMode_t; -#define GR_TEXCHROMA_DISABLE_EXT 0x0 -#define GR_TEXCHROMA_ENABLE_EXT 0x1 - -#define GR_TEXCHROMARANGE_RGB_ALL_EXT 0x0 - -typedef FxI32 GrCmpFnc_t; -#define GR_CMP_NEVER 0x0 -#define GR_CMP_LESS 0x1 -#define GR_CMP_EQUAL 0x2 -#define GR_CMP_LEQUAL 0x3 -#define GR_CMP_GREATER 0x4 -#define GR_CMP_NOTEQUAL 0x5 -#define GR_CMP_GEQUAL 0x6 -#define GR_CMP_ALWAYS 0x7 - -typedef FxI32 GrColorFormat_t; -#define GR_COLORFORMAT_ARGB 0x0 -#define GR_COLORFORMAT_ABGR 0x1 - -#define GR_COLORFORMAT_RGBA 0x2 -#define GR_COLORFORMAT_BGRA 0x3 - -typedef FxI32 GrCullMode_t; -#define GR_CULL_DISABLE 0x0 -#define GR_CULL_NEGATIVE 0x1 -#define GR_CULL_POSITIVE 0x2 - -typedef FxI32 GrDepthBufferMode_t; -#define GR_DEPTHBUFFER_DISABLE 0x0 -#define GR_DEPTHBUFFER_ZBUFFER 0x1 -#define GR_DEPTHBUFFER_WBUFFER 0x2 -#define GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS 0x3 -#define GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS 0x4 - -typedef FxI32 GrDitherMode_t; -#define GR_DITHER_DISABLE 0x0 -#define GR_DITHER_2x2 0x1 -#define GR_DITHER_4x4 0x2 - -typedef FxI32 GrStippleMode_t; -#define GR_STIPPLE_DISABLE 0x0 -#define GR_STIPPLE_PATTERN 0x1 -#define GR_STIPPLE_ROTATE 0x2 - -typedef FxI32 GrFogMode_t; -#define GR_FOG_DISABLE 0x0 -#define GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT 0x1 -#define GR_FOG_WITH_TABLE_ON_Q 0x2 -#define GR_FOG_WITH_TABLE_ON_W GR_FOG_WITH_TABLE_ON_Q -#define GR_FOG_WITH_ITERATED_Z 0x3 -#define GR_FOG_WITH_ITERATED_ALPHA_EXT 0x4 -#define GR_FOG_MULT2 0x100 -#define GR_FOG_ADD2 0x200 - -typedef FxU32 GrLock_t; -#define GR_LFB_READ_ONLY 0x00 -#define GR_LFB_WRITE_ONLY 0x01 -#define GR_LFB_IDLE 0x00 -#define GR_LFB_NOIDLE 0x10 - -typedef FxI32 GrLfbBypassMode_t; -#define GR_LFBBYPASS_DISABLE 0x0 -#define GR_LFBBYPASS_ENABLE 0x1 - -typedef FxI32 GrLfbWriteMode_t; -#define GR_LFBWRITEMODE_565 0x0 -#define GR_LFBWRITEMODE_555 0x1 -#define GR_LFBWRITEMODE_1555 0x2 -#define GR_LFBWRITEMODE_RESERVED1 0x3 -#define GR_LFBWRITEMODE_888 0x4 -#define GR_LFBWRITEMODE_8888 0x5 -#define GR_LFBWRITEMODE_RESERVED2 0x6 -#define GR_LFBWRITEMODE_RESERVED3 0x7 -#define GR_LFBWRITEMODE_RESERVED4 0x8 -#define GR_LFBWRITEMODE_RESERVED5 0x9 -#define GR_LFBWRITEMODE_RESERVED6 0xa -#define GR_LFBWRITEMODE_RESERVED7 0xb -#define GR_LFBWRITEMODE_565_DEPTH 0xc -#define GR_LFBWRITEMODE_555_DEPTH 0xd -#define GR_LFBWRITEMODE_1555_DEPTH 0xe -#define GR_LFBWRITEMODE_ZA16 0xf -#define GR_LFBWRITEMODE_ANY 0xFF - -typedef FxI32 GrOriginLocation_t; -#define GR_ORIGIN_UPPER_LEFT 0x0 -#define GR_ORIGIN_LOWER_LEFT 0x1 -#define GR_ORIGIN_ANY 0xFF - -typedef struct -{ - int size; - void *lfbPtr; - FxU32 strideInBytes; - GrLfbWriteMode_t writeMode; - GrOriginLocation_t origin; -} -GrLfbInfo_t; - -typedef FxI32 GrLOD_t; -#define GR_LOD_LOG2_2048 0xb -#define GR_LOD_LOG2_1024 0xa -#define GR_LOD_LOG2_512 0x9 -#define GR_LOD_LOG2_256 0x8 -#define GR_LOD_LOG2_128 0x7 -#define GR_LOD_LOG2_64 0x6 -#define GR_LOD_LOG2_32 0x5 -#define GR_LOD_LOG2_16 0x4 -#define GR_LOD_LOG2_8 0x3 -#define GR_LOD_LOG2_4 0x2 -#define GR_LOD_LOG2_2 0x1 -#define GR_LOD_LOG2_1 0x0 - -typedef FxI32 GrMipMapMode_t; -#define GR_MIPMAP_DISABLE 0x0 -#define GR_MIPMAP_NEAREST 0x1 -#define GR_MIPMAP_NEAREST_DITHER 0x2 - -typedef FxI32 GrSmoothingMode_t; -#define GR_SMOOTHING_DISABLE 0x0 -#define GR_SMOOTHING_ENABLE 0x1 - -typedef FxI32 GrTextureClampMode_t; -#define GR_TEXTURECLAMP_WRAP 0x0 -#define GR_TEXTURECLAMP_CLAMP 0x1 -#define GR_TEXTURECLAMP_MIRROR_EXT 0x2 - -typedef FxI32 GrTextureCombineFnc_t; -#define GR_TEXTURECOMBINE_ZERO 0x0 -#define GR_TEXTURECOMBINE_DECAL 0x1 -#define GR_TEXTURECOMBINE_OTHER 0x2 -#define GR_TEXTURECOMBINE_ADD 0x3 -#define GR_TEXTURECOMBINE_MULTIPLY 0x4 -#define GR_TEXTURECOMBINE_SUBTRACT 0x5 -#define GR_TEXTURECOMBINE_DETAIL 0x6 -#define GR_TEXTURECOMBINE_DETAIL_OTHER 0x7 -#define GR_TEXTURECOMBINE_TRILINEAR_ODD 0x8 -#define GR_TEXTURECOMBINE_TRILINEAR_EVEN 0x9 -#define GR_TEXTURECOMBINE_ONE 0xa - -typedef FxI32 GrTextureFilterMode_t; -#define GR_TEXTUREFILTER_POINT_SAMPLED 0x0 -#define GR_TEXTUREFILTER_BILINEAR 0x1 - -typedef FxI32 GrTextureFormat_t; -#define GR_TEXFMT_8BIT 0x0 -#define GR_TEXFMT_RGB_332 GR_TEXFMT_8BIT -#define GR_TEXFMT_YIQ_422 0x1 -#define GR_TEXFMT_ALPHA_8 0x2 -#define GR_TEXFMT_INTENSITY_8 0x3 -#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4 -#define GR_TEXFMT_P_8 0x5 -#define GR_TEXFMT_RSVD0 0x6 -#define GR_TEXFMT_RSVD1 0x7 -#define GR_TEXFMT_16BIT 0x8 -#define GR_TEXFMT_ARGB_8332 GR_TEXFMT_16BIT -#define GR_TEXFMT_AYIQ_8422 0x9 -#define GR_TEXFMT_RGB_565 0xa -#define GR_TEXFMT_ARGB_1555 0xb -#define GR_TEXFMT_ARGB_4444 0xc -#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd -#define GR_TEXFMT_AP_88 0xe -#define GR_TEXFMT_RSVD2 0xf -#define GR_TEXFMT_ARGB_CMP_FXT1 0x11 -#define GR_TEXFMT_ARGB_8888 0x12 -#define GR_TEXFMT_YUYV_422 0x13 -#define GR_TEXFMT_UYVY_422 0x14 -#define GR_TEXFMT_AYUV_444 0x15 -#define GR_TEXFMT_ARGB_CMP_DXT1 0x16 -#define GR_TEXFMT_ARGB_CMP_DXT2 0x17 -#define GR_TEXFMT_ARGB_CMP_DXT3 0x18 -#define GR_TEXFMT_ARGB_CMP_DXT4 0x19 -#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A - -typedef FxU32 GrTexTable_t; -#define GR_TEXTABLE_NCC0 0x0 -#define GR_TEXTABLE_NCC1 0x1 -#define GR_TEXTABLE_PALETTE 0x2 -#define GR_TEXTABLE_PALETTE_6666_EXT 0x3 - -typedef FxU32 GrNCCTable_t; -#define GR_NCCTABLE_NCC0 0x0 -#define GR_NCCTABLE_NCC1 0x1 - -typedef FxU32 GrTexBaseRange_t; -#define GR_TEXBASE_256 0x3 -#define GR_TEXBASE_128 0x2 -#define GR_TEXBASE_64 0x1 -#define GR_TEXBASE_32_TO_1 0x0 -#define GR_TEXBASE_2048 0x7 -#define GR_TEXBASE_1024 0x6 -#define GR_TEXBASE_512 0x5 -#define GR_TEXBASE_256_TO_1 0x4 - -typedef FxU32 GrEnableMode_t; -#define GR_MODE_DISABLE 0x0 -#define GR_MODE_ENABLE 0x1 - -#define GR_AA_ORDERED 0x01 -#define GR_ALLOW_MIPMAP_DITHER 0x02 -#define GR_PASSTHRU 0x03 -#define GR_SHAMELESS_PLUG 0x04 -#define GR_VIDEO_SMOOTHING 0x05 - -typedef FxU32 GrCoordinateSpaceMode_t; -#define GR_WINDOW_COORDS 0x00 -#define GR_CLIP_COORDS 0x01 - -/* Parameters for strips */ -#define GR_PARAM_XY 0x01 -#define GR_PARAM_Z 0x02 -#define GR_PARAM_W 0x03 -#define GR_PARAM_Q 0x04 -#define GR_PARAM_FOG_EXT 0x05 - -#define GR_PARAM_A 0x10 - -#define GR_PARAM_RGB 0x20 - -#define GR_PARAM_PARGB 0x30 - -#define GR_PARAM_ST0 0x40 -#define GR_PARAM_ST1 GR_PARAM_ST0+1 -#define GR_PARAM_ST2 GR_PARAM_ST0+2 - -#define GR_PARAM_Q0 0x50 -#define GR_PARAM_Q1 GR_PARAM_Q0+1 -#define GR_PARAM_Q2 GR_PARAM_Q0+2 - -#define GR_PARAM_DISABLE 0x00 -#define GR_PARAM_ENABLE 0x01 - -/* grDrawVertexArray/grDrawVertexArrayContiguous */ -#define GR_POINTS 0 -#define GR_LINE_STRIP 1 -#define GR_LINES 2 -#define GR_POLYGON 3 -#define GR_TRIANGLE_STRIP 4 -#define GR_TRIANGLE_FAN 5 -#define GR_TRIANGLES 6 -#define GR_TRIANGLE_STRIP_CONTINUE 7 -#define GR_TRIANGLE_FAN_CONTINUE 8 - -/* grGet/grReset */ -#define GR_BITS_DEPTH 0x01 -#define GR_BITS_RGBA 0x02 -#define GR_FIFO_FULLNESS 0x03 -#define GR_FOG_TABLE_ENTRIES 0x04 -#define GR_GAMMA_TABLE_ENTRIES 0x05 -#define GR_GLIDE_STATE_SIZE 0x06 -#define GR_GLIDE_VERTEXLAYOUT_SIZE 0x07 -#define GR_IS_BUSY 0x08 -#define GR_LFB_PIXEL_PIPE 0x09 -#define GR_MAX_TEXTURE_SIZE 0x0a -#define GR_MAX_TEXTURE_ASPECT_RATIO 0x0b -#define GR_MEMORY_FB 0x0c -#define GR_MEMORY_TMU 0x0d -#define GR_MEMORY_UMA 0x0e -#define GR_NUM_BOARDS 0x0f -#define GR_NON_POWER_OF_TWO_TEXTURES 0x10 -#define GR_NUM_FB 0x11 -#define GR_NUM_SWAP_HISTORY_BUFFER 0x12 -#define GR_NUM_TMU 0x13 -#define GR_PENDING_BUFFERSWAPS 0x14 -#define GR_REVISION_FB 0x15 -#define GR_REVISION_TMU 0x16 -#define GR_STATS_LINES 0x17 -#define GR_STATS_PIXELS_AFUNC_FAIL 0x18 -#define GR_STATS_PIXELS_CHROMA_FAIL 0x19 -#define GR_STATS_PIXELS_DEPTHFUNC_FAIL 0x1a -#define GR_STATS_PIXELS_IN 0x1b -#define GR_STATS_PIXELS_OUT 0x1c -#define GR_STATS_PIXELS 0x1d -#define GR_STATS_POINTS 0x1e -#define GR_STATS_TRIANGLES_IN 0x1f -#define GR_STATS_TRIANGLES_OUT 0x20 -#define GR_STATS_TRIANGLES 0x21 -#define GR_SWAP_HISTORY 0x22 -#define GR_SUPPORTS_PASSTHRU 0x23 -#define GR_TEXTURE_ALIGN 0x24 -#define GR_VIDEO_POSITION 0x25 -#define GR_VIEWPORT 0x26 -#define GR_WDEPTH_MIN_MAX 0x27 -#define GR_ZDEPTH_MIN_MAX 0x28 -#define GR_VERTEX_PARAMETER 0x29 -#define GR_BITS_GAMMA 0x2a -#define GR_GET_RESERVED_1 0x1000 - -/* grGetString types */ -#define GR_EXTENSION 0xa0 -#define GR_HARDWARE 0xa1 -#define GR_RENDERER 0xa2 -#define GR_VENDOR 0xa3 -#define GR_VERSION 0xa4 - -typedef FxI32 GrScreenRefresh_t; -#define GR_REFRESH_NONE 0xff - -typedef FxI32 GrScreenResolution_t; -#define GR_RESOLUTION_NONE 0xff - -typedef struct -{ - GrLOD_t smallLodLog2; - GrLOD_t largeLodLog2; - GrAspectRatio_t aspectRatioLog2; - GrTextureFormat_t format; - void *data; -} -GrTexInfo; - -typedef struct GrSstPerfStats_s -{ - FxU32 pixelsIn; - FxU32 chromaFail; - FxU32 zFuncFail; - FxU32 aFuncFail; - FxU32 pixelsOut; -} -GrSstPerfStats_t; - -typedef struct -{ - GrScreenResolution_t resolution; - GrScreenRefresh_t refresh; - int numColorBuffers; - int numAuxBuffers; -} -GrResolution; - -typedef GrResolution GlideResolution; -#define GR_QUERY_ANY ((FxU32)(~0)) - -typedef FxU32 GrLfbSrcFmt_t; -#define GR_LFB_SRC_FMT_565 0x00 -#define GR_LFB_SRC_FMT_555 0x01 -#define GR_LFB_SRC_FMT_1555 0x02 -#define GR_LFB_SRC_FMT_888 0x04 -#define GR_LFB_SRC_FMT_8888 0x05 -#define GR_LFB_SRC_FMT_565_DEPTH 0x0c -#define GR_LFB_SRC_FMT_555_DEPTH 0x0d -#define GR_LFB_SRC_FMT_1555_DEPTH 0x0e -#define GR_LFB_SRC_FMT_ZA16 0x0f -#define GR_LFB_SRC_FMT_RLE16 0x80 - -typedef FxU32 GrPixelFormat_t; -#define GR_PIXFMT_I_8 0x0001 -#define GR_PIXFMT_AI_88 0x0002 -#define GR_PIXFMT_RGB_565 0x0003 -#define GR_PIXFMT_ARGB_1555 0x0004 -#define GR_PIXFMT_ARGB_8888 0x0005 -#define GR_PIXFMT_AA_2_RGB_565 0x0006 -#define GR_PIXFMT_AA_2_ARGB_1555 0x0007 -#define GR_PIXFMT_AA_2_ARGB_8888 0x0008 -#define GR_PIXFMT_AA_4_RGB_565 0x0009 -#define GR_PIXFMT_AA_4_ARGB_1555 0x000a -#define GR_PIXFMT_AA_4_ARGB_8888 0x000b - -#define GR_LFBWRITEMODE_Z32 0x0008 - -typedef FxU32 GrAAMode_t; -#define GR_AA_NONE 0x0000 -#define GR_AA_4SAMPLES 0x0001 - -typedef FxU8 GrStencil_t; - -typedef FxU32 GrStencilOp_t; -#define GR_STENCILOP_KEEP 0x00 -#define GR_STENCILOP_ZERO 0x01 -#define GR_STENCILOP_REPLACE 0x02 -#define GR_STENCILOP_INCR_CLAMP 0x03 -#define GR_STENCILOP_DECR_CLAMP 0x04 -#define GR_STENCILOP_INVERT 0x05 -#define GR_STENCILOP_INCR_WRAP 0x06 -#define GR_STENCILOP_DECR_WRAP 0x07 - -#define GR_TEXTURE_UMA_EXT 0x06 -#define GR_STENCIL_MODE_EXT 0x07 -#define GR_OPENGL_MODE_EXT 0x08 - -typedef FxU32 GrCCUColor_t; -typedef FxU32 GrACUColor_t; -typedef FxU32 GrTCCUColor_t; -typedef FxU32 GrTACUColor_t; -#define GR_CMBX_ZERO 0x00 -#define GR_CMBX_TEXTURE_ALPHA 0x01 -#define GR_CMBX_ALOCAL 0x02 -#define GR_CMBX_AOTHER 0x03 -#define GR_CMBX_B 0x04 -#define GR_CMBX_CONSTANT_ALPHA 0x05 -#define GR_CMBX_CONSTANT_COLOR 0x06 -#define GR_CMBX_DETAIL_FACTOR 0x07 -#define GR_CMBX_ITALPHA 0x08 -#define GR_CMBX_ITRGB 0x09 -#define GR_CMBX_LOCAL_TEXTURE_ALPHA 0x0a -#define GR_CMBX_LOCAL_TEXTURE_RGB 0x0b -#define GR_CMBX_LOD_FRAC 0x0c -#define GR_CMBX_OTHER_TEXTURE_ALPHA 0x0d -#define GR_CMBX_OTHER_TEXTURE_RGB 0x0e -#define GR_CMBX_TEXTURE_RGB 0x0f -#define GR_CMBX_TMU_CALPHA 0x10 -#define GR_CMBX_TMU_CCOLOR 0x11 - -typedef FxU32 GrCombineMode_t; -#define GR_FUNC_MODE_ZERO 0x00 -#define GR_FUNC_MODE_X 0x01 -#define GR_FUNC_MODE_ONE_MINUS_X 0x02 -#define GR_FUNC_MODE_NEGATIVE_X 0x03 -#define GR_FUNC_MODE_X_MINUS_HALF 0x04 - -typedef FxU32 GrAlphaBlendOp_t; -#define GR_BLEND_OP_ADD 0x00 -#define GR_BLEND_OP_SUB 0x01 -#define GR_BLEND_OP_REVSUB 0x02 - -typedef struct -{ - FxU32 data[256]; -} -GuTexPalette; - -typedef void (*GrErrorCallbackFnc_t) (const char *string, FxBool fatal); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c deleted file mode 100644 index 6bbfb8d3a..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c,v 1.5 2002/12/16 16:19:00 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#include "tdfx_context.h" -#include "tdfx_lock.h" -#include "tdfx_state.h" -#include "tdfx_render.h" -#include "tdfx_texman.h" -#include "tdfx_tris.h" - - -void tdfxGetLock( tdfxContextPtr fxMesa ) -{ - __DRIcontextPrivate *cPriv = fxMesa->driContext; - __DRIdrawablePrivate *dPriv = cPriv->driDrawablePriv; - __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; - TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) + - fxMesa->fxScreen->sarea_priv_offset); - unsigned int stamp = dPriv->lastStamp; - - drmGetLock( fxMesa->driFd, fxMesa->hHWContext, 0 ); - - /* This macro will update dPriv's cliprects if needed */ - DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv ); - - if ( saPriv->fifoOwner != fxMesa->hHWContext ) { - fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead ); - } - - if ( saPriv->ctxOwner != fxMesa->hHWContext ) { - /* This sequence looks a little odd. Glide mirrors the state, and - * when you get the state you are forcing the mirror to be up to - * date, and then getting a copy from the mirror. You can then force - * that state onto the hardware when you set the state. - */ - void *state; - FxI32 stateSize; - fxMesa->Glide.grGet(GR_GLIDE_STATE_SIZE, 4, &stateSize); - state = malloc(stateSize); - fxMesa->Glide.grGlideGetState( state ); - fxMesa->Glide.grGlideSetState( state ); - free( state ); - } - -#if 0 - if ( saPriv->texOwner != fxMesa->hHWContext ) { - tdfxTMRestoreTextures_NoLock( fxMesa ); - } -#endif - - if ( *dPriv->pStamp != stamp || saPriv->ctxOwner != fxMesa->hHWContext ) { - tdfxUpdateClipping(fxMesa->glCtx); - tdfxUploadClipping(fxMesa); - } - - DEBUG_LOCK(); -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h deleted file mode 100644 index 616e65b2a..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h,v 1.3 2002/02/22 21:45:03 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#ifndef __TDFX_LOCK_H__ -#define __TDFX_LOCK_H__ - -/* You can turn this on to find locking conflicts. - */ -#define DEBUG_LOCKING 0 - -#if DEBUG_LOCKING -extern char *prevLockFile; -extern int prevLockLine; - -#define DEBUG_LOCK() \ - do { \ - prevLockFile = (__FILE__); \ - prevLockLine = (__LINE__); \ - } while (0) - -#define DEBUG_RESET() \ - do { \ - prevLockFile = 0; \ - prevLockLine = 0; \ - } while (0) - -#define DEBUG_CHECK_LOCK() \ - do { \ - if ( prevLockFile ) { \ - fprintf( stderr, \ - "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \ - prevLockFile, prevLockLine, __FILE__, __LINE__ ); \ - exit( 1 ); \ - } \ - } while (0) - -#else - -#define DEBUG_LOCK() -#define DEBUG_RESET() -#define DEBUG_CHECK_LOCK() - -#endif /* DEBUG_LOCKING */ - - -extern void tdfxGetLock( tdfxContextPtr fxMesa ); - - -/* !!! We may want to separate locks from locks with validation. - This could be used to improve performance for those things - commands that do not do any drawing !!! */ - -#define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \ - do { \ - DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ - if (__ret) drmGetLock(fd,context,0); \ - } while(0) - -#define LOCK_HARDWARE( fxMesa ) \ - do { \ - char __ret = 0; \ - \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( fxMesa->driHwLock, fxMesa->hHWContext, \ - DRM_LOCK_HELD | fxMesa->hHWContext, __ret ); \ - if ( __ret ) { \ - tdfxGetLock( fxMesa ); \ - } \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware using the global current context */ -#define UNLOCK_HARDWARE( fxMesa ) \ - do { \ - DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); \ - DEBUG_RESET(); \ - } while (0) - -/* - * This pair of macros makes a loop over the drawing operations - * so it is not self contained and doesn't have the nice single - * statement semantics of most macros. - */ -#define BEGIN_CLIP_LOOP(fxMesa) \ - do { \ - LOCK_HARDWARE( fxMesa ); \ - BEGIN_CLIP_LOOP_LOCKED( fxMesa ) - -#define BEGIN_CLIP_LOOP_LOCKED(fxMesa) \ - do { \ - int _nc = fxMesa->numClipRects; \ - while (_nc--) { \ - if (fxMesa->numClipRects > 1) { \ - int _height = fxMesa->screen_height; \ - fxMesa->Glide.grClipWindow(fxMesa->pClipRects[_nc].x1, \ - _height - fxMesa->pClipRects[_nc].y2, \ - fxMesa->pClipRects[_nc].x2, \ - _height - fxMesa->pClipRects[_nc].y1); \ - } - - -#define END_CLIP_LOOP_LOCKED( fxMesa ) \ - } \ - } while (0) - -#define END_CLIP_LOOP( fxMesa ) \ - END_CLIP_LOOP_LOCKED( fxMesa ); \ - UNLOCK_HARDWARE( fxMesa ); \ - } while (0) - -#endif /* __TDFX_LOCK_H__ */ diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c deleted file mode 100644 index 6592ecccf..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c +++ /dev/null @@ -1,689 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c,v 1.4 2002/02/22 21:45:03 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * Nathan Hand - * - */ - -#include "tdfx_context.h" -#include "tdfx_dd.h" -#include "tdfx_lock.h" -#include "tdfx_vb.h" -#include "tdfx_pixels.h" -#include "tdfx_render.h" - -#include "swrast/swrast.h" - -#include "image.h" - - -#define FX_grLfbWriteRegion(fxMesa,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - do { \ - LOCK_HARDWARE(fxMesa); \ - fxMesa->Glide.grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \ - UNLOCK_HARDWARE(fxMesa); \ - } while(0) - - -#define FX_grLfbReadRegion(fxMesa,src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \ - do { \ - LOCK_HARDWARE(fxMesa); \ - fxMesa->Glide.grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \ - UNLOCK_HARDWARE(fxMesa); \ - } while (0); - - -#if 0 -static FxBool -FX_grLfbLock(tdfxContextPtr fxMesa, GrLock_t type, GrBuffer_t buffer, - GrLfbWriteMode_t writeMode, GrOriginLocation_t origin, - FxBool pixelPipeline, GrLfbInfo_t * info) -{ - FxBool result; - - LOCK_HARDWARE(fxMesa); - result = fxMesa->Glide.grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info); - UNLOCK_HARDWARE(fxMesa); - return result; -} -#endif - - -#define FX_grLfbUnlock(fxMesa, t, b) \ - do { \ - LOCK_HARDWARE(fxMesa); \ - fxMesa->Glide.grLfbUnlock(t, b); \ - UNLOCK_HARDWARE(fxMesa); \ - } while (0) - - - -#if 0 -/* test if window coord (px,py) is visible */ -static GLboolean -inClipRects(tdfxContextPtr 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 - -/* test if rectangle of pixels (px,py) (px+width,py+height) is visible */ -static GLboolean -inClipRects_Region(tdfxContextPtr fxMesa, int x, int y, int width, int height) -{ - int i; - int x1, y1, x2, y2; - int xmin, xmax, ymin, ymax, pixelsleft; - - y1 = y - height + 1; y2 = y; - x1 = x; x2 = x + width - 1; - pixelsleft = width * height; - - for (i = 0; i < fxMesa->numClipRects; i++) - { - /* algorithm requires x1 < x2 and y1 < y2 */ - if ((fxMesa->pClipRects[i].x1 < fxMesa->pClipRects[i].x2)) { - xmin = fxMesa->pClipRects[i].x1; - xmax = fxMesa->pClipRects[i].x2-1; - } else { - xmin = fxMesa->pClipRects[i].x2; - xmax = fxMesa->pClipRects[i].x1-1; - } - if ((fxMesa->pClipRects[i].y1 < fxMesa->pClipRects[i].y2)) { - ymin = fxMesa->pClipRects[i].y1; - ymax = fxMesa->pClipRects[i].y2-1; - } else { - ymin = fxMesa->pClipRects[i].y2; - ymax = fxMesa->pClipRects[i].y1-1; - } - - /* reject trivial cases */ - if (xmax < x1) continue; - if (ymax < y1) continue; - if (xmin > x2) continue; - if (ymin > y2) continue; - - /* find the intersection */ - if (xmin < x1) xmin = x1; - if (ymin < y1) ymin = y1; - if (xmax > x2) xmax = x2; - if (ymax > y2) ymax = y2; - - pixelsleft -= (xmax-xmin+1) * (ymax-ymin+1); - } - - return pixelsleft == 0; -} - -#if 0 -GLboolean -tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte * bitmap) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - TdfxU16 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 | - 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 = (TdfxU16) - (((TdfxU16) 0xf8 & b) << (11 - 3)) | - (((TdfxU16) 0xfc & g) << (5 - 3 + 1)) | - (((TdfxU16) 0xf8 & r) >> 3); - } - else - color = (TdfxU16) - (((TdfxU16) 0xf8 & r) << (11 - 3)) | - (((TdfxU16) 0xfc & g) << (5 - 3 + 1)) | - (((TdfxU16) 0xf8 & b) >> 3); - } - - info.size = sizeof(info); - if (!TDFX_grLfbLock(fxMesa, - GR_LFB_WRITE_ONLY, - fxMesa->currentFB, - GR_LFBWRITEMODE_565, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { -#ifndef TDFX_SILENT - fprintf(stderr, "tdfx Driver: error locking the linear frame buffer\n"); -#endif - return GL_TRUE; - } - - { - 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. - */ - const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) - ? (fxMesa->screen_width) : (info.strideInBytes / 2); - 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_address2d(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, - GL_BITMAP, 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 (inClipRects(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 (inClipRects(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; - } - } - - TDFX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB); - return GL_TRUE; -} -#endif - -#if 0 -GLboolean -tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte * bitmap) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - 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 | - 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); - color = PACK_BGRA32(r, g, b, a); - } - - info.size = sizeof(info); - if (!TDFX_grLfbLock(fxMesa, GR_LFB_WRITE_ONLY, - fxMesa->currentFB, GR_LFBWRITEMODE_8888, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { -#ifndef TDFX_SILENT - fprintf(stderr, "tdfx Driver: error locking the linear frame buffer\n"); -#endif - return GL_TRUE; - } - - { - 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[0] == 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_address2d(finalUnpack, - bitmap, width, height, - GL_COLOR_INDEX, - GL_BITMAP, 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 (inClipRects(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 (inClipRects(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; - } - } - - TDFX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB); - return GL_TRUE; -} -#endif - -void -tdfx_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 (format != GL_RGB || - type != GL_UNSIGNED_SHORT_5_6_5 || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT))) - { - _swrast_ReadPixels( ctx, x, y, width, height, format, type, packing, - dstImage ); - return; - } - - { - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - - const GLint winX = fxMesa->x_offset; - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint scrX = winX + x; - const GLint scrY = winY - y; - - LOCK_HARDWARE( fxMesa ); - info.size = sizeof(info); - if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY, - fxMesa->ReadBuffer, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { - const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer[0] == - GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2); - const GLushort *src = (const GLushort *) info.lfbPtr - + scrY * srcStride + scrX; - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, - dstImage, width, height, format, type, 0, 0); - const GLint dstStride = _mesa_image_row_stride(packing, - width, format, type); - - /* 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; - } - - fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->ReadBuffer); - } - UNLOCK_HARDWARE( fxMesa ); - return; - } -} - -void -tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid * dstImage) -{ - if ((!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) && - !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT))) - { - _swrast_ReadPixels( ctx, x, y, width, height, format, type, packing, - dstImage ); - return; - } - - - { - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - - const GLint winX = fxMesa->x_offset; - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint scrX = winX + x; - const GLint scrY = winY - y; - - LOCK_HARDWARE(fxMesa); - info.size = sizeof(info); - if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY, - fxMesa->ReadBuffer, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) - { - const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) - ? (fxMesa->screen_width) : (info.strideInBytes / 4); - const GLuint *src = (const GLuint *) info.lfbPtr - + scrY * srcStride + scrX; - const GLint dstStride = - _mesa_image_row_stride(packing, width, format, type); - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, - dstImage, width, height, format, type, 0, 0); - const GLint widthInBytes = width * 4; - - { - GLint row; - for (row = 0; row < height; row++) { - MEMCPY(dst, src, widthInBytes); - dst += dstStride; - src -= srcStride; - } - } - - fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->ReadBuffer); - } - UNLOCK_HARDWARE(fxMesa); - } -} - -void -tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid * pixels) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ((!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) && - !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) || - ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| - IMAGE_MAP_COLOR_BIT)) || - ctx->Color.AlphaEnabled || - ctx->Depth.Test || - ctx->Fog.Enabled || - ctx->Scissor.Enabled || - ctx->Stencil.Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || - ctx->Color.ColorLogicOpEnabled || - ctx->Texture._EnabledUnits || - ctx->Depth.OcclusionTest || - fxMesa->Fallback) - { - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - return; - } - - { - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GLboolean result = GL_FALSE; - - const GLint winX = fxMesa->x_offset; - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint scrX = winX + x; - const GLint scrY = winY - y; - - /* lock early to make sure cliprects are right */ - LOCK_HARDWARE(fxMesa); - - /* make sure hardware has latest blend funcs */ - if (ctx->Color.BlendEnabled) { - fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC; - tdfxEmitHwStateLocked( fxMesa ); - } - - /* look for clipmasks, giveup if region obscured */ - if (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) { - if (!inClipRects_Region(fxMesa, scrX, scrY, width, height)) { - UNLOCK_HARDWARE(fxMesa); - _swrast_DrawPixels( ctx, x, y, width, height, format, type, - unpack, pixels ); - return; - } - } - - info.size = sizeof(info); - if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY, - fxMesa->DrawBuffer, - GR_LFBWRITEMODE_8888, - GR_ORIGIN_UPPER_LEFT, FXTRUE, &info)) - { - const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) - ? (fxMesa->screen_width * 4) : (info.strideInBytes); - GLubyte *dst = (GLubyte *) info.lfbPtr - + scrY * dstStride + scrX * 4; - const GLint srcStride = - _mesa_image_row_stride(unpack, width, format, type); - const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack, - pixels, width, height, format, type, 0, 0); - const GLint widthInBytes = width * 4; - - if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) || - (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) { - GLint row; - for (row = 0; row < height; row++) { - MEMCPY(dst, src, widthInBytes); - dst -= dstStride; - src += srcStride; - } - result = GL_TRUE; - } - - fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer); - } - UNLOCK_HARDWARE(fxMesa); - } -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h deleted file mode 100644 index c38ce070c..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h,v 1.2 2002/02/22 21:45:03 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * Nathan Hand - * - */ - -#ifndef __TDFX_PIXELS_H__ -#define __TDFX_PIXELS_H__ - -#include "context.h" - -extern void -tdfx_bitmap_R5G6B5( GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - -extern void -tdfx_bitmap_R8G8B8A8( GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - -extern void -tdfx_readpixels_R5G6B5( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage ); - -extern void -tdfx_readpixels_R8G8B8A8( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *dstImage ); - -extern void -tdfx_drawpixels_R8G8B8A8( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c deleted file mode 100644 index 56f5f147e..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c +++ /dev/null @@ -1,808 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c,v 1.4 2002/02/22 21:45:03 dawes Exp $ */ - -/* - * New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#include "tdfx_context.h" -#include "tdfx_render.h" -#include "tdfx_state.h" -#include "tdfx_texman.h" -#include "swrast/swrast.h" - -/* Clear the color and/or depth buffers. - */ -static void tdfxClear( GLcontext *ctx, - GLbitfield mask, GLboolean all, - GLint x, GLint y, GLint width, GLint height ) -{ - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLbitfield softwareMask = mask & (BUFFER_BIT_ACCUM); - const GLuint stencil_size = - fxMesa->haveHwStencil ? fxMesa->glCtx->Visual.stencilBits : 0; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s( %d, %d, %d, %d )\n", - __FUNCTION__, (int) x, (int) y, (int) width, (int) height ); - } - - /* Need this check to respond to glScissor and clipping updates */ - if ((fxMesa->new_state & (TDFX_NEW_CLIP | TDFX_NEW_DEPTH)) || - (fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK)) { - tdfxDDUpdateHwState(ctx); - } - - /* we can't clear accum buffers */ - mask &= ~(BUFFER_BIT_ACCUM); - - if (mask & BUFFER_BIT_STENCIL) { - if (!fxMesa->haveHwStencil || ctx->Stencil.WriteMask[0] != 0xff) { - /* Napalm seems to have trouble with stencil write masks != 0xff */ - /* do stencil clear in software */ - mask &= ~(BUFFER_BIT_STENCIL); - softwareMask |= BUFFER_BIT_STENCIL; - } - } - - if (fxMesa->glCtx->Visual.redBits != 8) { - /* can only do color masking if running in 24/32bpp on Napalm */ - if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] || - ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) { - softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)); - mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); - } - } - - if (fxMesa->haveHwStencil) { - /* - * If we want to clear stencil, it must be enabled - * in the HW, even if the stencil test is not enabled - * in the OGL state. - */ - LOCK_HARDWARE(fxMesa); - if (mask & BUFFER_BIT_STENCIL) { - fxMesa->Glide.grStencilMask(/*ctx->Stencil.WriteMask*/ 0xff); - /* set stencil ref value = desired clear value */ - fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS, - fxMesa->Stencil.Clear, 0xff); - fxMesa->Glide.grStencilOp(GR_STENCILOP_REPLACE, - GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE); - fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT); - } - else { - fxMesa->Glide.grDisable(GR_STENCIL_MODE_EXT); - } - UNLOCK_HARDWARE(fxMesa); - } - - /* - * This may be ugly, but it's needed in order to work around a number - * of Glide bugs. - */ - BEGIN_CLIP_LOOP(fxMesa); - { - /* - * This could probably be done fancier but doing each possible case - * explicitly is less error prone. - */ - switch (mask & ~BUFFER_BIT_STENCIL) { - case BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH: - /* back buffer & depth */ - FX_grColorMaskv_NoLock(ctx, true4); /* work around Voodoo3 bug */ - fxMesa->Glide.grDepthMask(FXTRUE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) { - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - } - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (!ctx->Depth.Mask || !ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXFALSE); - } - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_DEPTH: - /* XXX it appears that the depth buffer isn't cleared when - * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set. - * This is a work-around/ - */ - /* clear depth */ - fxMesa->Glide.grDepthMask(FXTRUE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grColorMaskv_NoLock(ctx, false4); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - /* clear front */ - FX_grColorMaskv_NoLock(ctx, true4); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (!ctx->Depth.Mask || !ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXFALSE); - } - break; - case BUFFER_BIT_BACK_LEFT: - /* back buffer only */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - break; - case BUFFER_BIT_FRONT_LEFT: - /* front buffer only */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT: - /* front and back */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - break; - case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH: - /* clear front */ - fxMesa->Glide.grDepthMask(FXFALSE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - /* clear back and depth */ - fxMesa->Glide.grDepthMask(FXTRUE); - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - if (!ctx->Depth.Mask || !ctx->Depth.Mask) { - fxMesa->Glide.grDepthMask(FXFALSE); - } - break; - case BUFFER_BIT_DEPTH: - /* just the depth buffer */ - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grColorMaskv_NoLock(ctx, false4); - fxMesa->Glide.grDepthMask(FXTRUE); - if (stencil_size > 0) - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - else - fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear); - FX_grColorMaskv_NoLock(ctx, true4); - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - if (!ctx->Depth.Test || !ctx->Depth.Mask) - fxMesa->Glide.grDepthMask(FXFALSE); - break; - default: - /* clear no color buffers or depth buffer but might clear stencil */ - if (stencil_size > 0 && (mask & BUFFER_BIT_STENCIL)) { - /* XXX need this RenderBuffer call to work around Glide bug */ - fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER); - fxMesa->Glide.grDepthMask(FXFALSE); - FX_grColorMaskv_NoLock(ctx, false4); - fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor, - fxMesa->Color.ClearAlpha, - fxMesa->Depth.Clear, - (FxU32) ctx->Stencil.Clear); - if (ctx->Depth.Mask && ctx->Depth.Test) { - fxMesa->Glide.grDepthMask(FXTRUE); - } - FX_grColorMaskv_NoLock(ctx, true4); - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) - fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); - } - } - } - END_CLIP_LOOP(fxMesa); - - if (fxMesa->haveHwStencil && (mask & BUFFER_BIT_STENCIL)) { - /* We changed the stencil state above. Signal that we need to - * upload it again. - */ - fxMesa->dirty |= TDFX_UPLOAD_STENCIL; - } - - if (softwareMask) - _swrast_Clear( ctx, softwareMask, all, x, y, width, height ); -} - - - -static void tdfxFinish( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - - LOCK_HARDWARE( fxMesa ); - fxMesa->Glide.grFinish(); - UNLOCK_HARDWARE( fxMesa ); -} - -static void tdfxFlush( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - - LOCK_HARDWARE( fxMesa ); - fxMesa->Glide.grFlush(); - UNLOCK_HARDWARE( fxMesa ); -} - - -#if 0 -static const char *texSource(int k) -{ - switch (k) { - case GR_CMBX_ZERO: - return "GR_CMBX_ZERO"; - case GR_CMBX_TEXTURE_ALPHA: - return "GR_CMBX_TEXTURE_ALPHA"; - case GR_CMBX_ALOCAL: - return "GR_CMBX_ALOCAL"; - case GR_CMBX_AOTHER: - return "GR_CMBX_AOTHER"; - case GR_CMBX_B: - return "GR_CMBX_B"; - case GR_CMBX_CONSTANT_ALPHA: - return "GR_CMBX_CONSTANT_ALPHA"; - case GR_CMBX_CONSTANT_COLOR: - return "GR_CMBX_CONSTANT_COLOR"; - case GR_CMBX_DETAIL_FACTOR: - return "GR_CMBX_DETAIL_FACTOR"; - case GR_CMBX_ITALPHA: - return "GR_CMBX_ITALPHA"; - case GR_CMBX_ITRGB: - return "GR_CMBX_ITRGB"; - case GR_CMBX_LOCAL_TEXTURE_ALPHA: - return "GR_CMBX_LOCAL_TEXTURE_ALPHA"; - case GR_CMBX_LOCAL_TEXTURE_RGB: - return "GR_CMBX_LOCAL_TEXTURE_RGB"; - case GR_CMBX_LOD_FRAC: - return "GR_CMBX_LOD_FRAC"; - case GR_CMBX_OTHER_TEXTURE_ALPHA: - return "GR_CMBX_OTHER_TEXTURE_ALPHA"; - case GR_CMBX_OTHER_TEXTURE_RGB: - return "GR_CMBX_OTHER_TEXTURE_RGB"; - case GR_CMBX_TEXTURE_RGB: - return "GR_CMBX_TEXTURE_RGB"; - case GR_CMBX_TMU_CALPHA: - return "GR_CMBX_TMU_CALPHA"; - case GR_CMBX_TMU_CCOLOR: - return "GR_CMBX_TMU_CCOLOR"; - default: - return ""; - } -} -#endif - -#if 0 -static const char *texMode(int k) -{ - switch (k) { - case GR_FUNC_MODE_ZERO: - return "GR_FUNC_MODE_ZERO"; - case GR_FUNC_MODE_X: - return "GR_FUNC_MODE_X"; - case GR_FUNC_MODE_ONE_MINUS_X: - return "GR_FUNC_MODE_ONE_MINUS_X"; - case GR_FUNC_MODE_NEGATIVE_X: - return "GR_FUNC_MODE_NEGATIVE_X"; - case GR_FUNC_MODE_X_MINUS_HALF: - return "GR_FUNC_MODE_X_MINUS_HALF"; - default: - return ""; - } -} -#endif - -#if 0 -static const char *texInvert(int k) -{ - return k ? "FXTRUE" : "FXFALSE"; -} -#endif - -static void uploadTextureEnv( tdfxContextPtr fxMesa ) -{ - if (TDFX_IS_NAPALM(fxMesa)) { - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { -#if 0 - printf("upload env %d\n", unit); - printf(" cSourceA = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceA)); - printf(" cModeA = %s\n", texMode(fxMesa->TexCombineExt[unit].Color.ModeA)); - printf(" cSourceB = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceB)); - printf(" cModeB = %s\n", texMode(fxMesa->TexCombineExt[unit].Color.ModeB)); - printf(" cSourceC = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceC)); - printf(" cInvertC = %s\n", texInvert(fxMesa->TexCombineExt[unit].Color.InvertC)); - printf(" cSourceD = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceD)); - printf(" cInvertD = %s\n", texInvert(fxMesa->TexCombineExt[unit].Color.InvertD)); - printf(" cShift = %d\t", fxMesa->TexCombineExt[unit].Color.Shift); - printf(" cInvert = %d\n", fxMesa->TexCombineExt[unit].Color.Invert); - printf(" aSourceA = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceA)); - printf(" aModeA = %s\n", texMode(fxMesa->TexCombineExt[unit].Alpha.ModeA)); - printf(" aSourceB = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceB)); - printf(" aModeB = %s\n", texMode(fxMesa->TexCombineExt[unit].Alpha.ModeB)); - printf(" aSourceC = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceC)); - printf(" aInvertC = %s\n", texInvert(fxMesa->TexCombineExt[unit].Alpha.InvertC)); - printf(" aSourceD = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceD)); - printf(" aInvertD = %s\n", texInvert(fxMesa->TexCombineExt[unit].Alpha.InvertD)); - printf(" aShift = %d\t", fxMesa->TexCombineExt[unit].Alpha.Shift); - printf(" aInvert = %d\n", fxMesa->TexCombineExt[unit].Alpha.Invert); - printf(" Color = 0x%08x\n", fxMesa->TexCombineExt[unit].EnvColor); -#endif - fxMesa->Glide.grTexColorCombineExt(TDFX_TMU0 + unit, - fxMesa->TexCombineExt[unit].Color.SourceA, - fxMesa->TexCombineExt[unit].Color.ModeA, - fxMesa->TexCombineExt[unit].Color.SourceB, - fxMesa->TexCombineExt[unit].Color.ModeB, - fxMesa->TexCombineExt[unit].Color.SourceC, - fxMesa->TexCombineExt[unit].Color.InvertC, - fxMesa->TexCombineExt[unit].Color.SourceD, - fxMesa->TexCombineExt[unit].Color.InvertD, - fxMesa->TexCombineExt[unit].Color.Shift, - fxMesa->TexCombineExt[unit].Color.Invert); - fxMesa->Glide.grTexAlphaCombineExt(TDFX_TMU0 + unit, - fxMesa->TexCombineExt[unit].Alpha.SourceA, - fxMesa->TexCombineExt[unit].Alpha.ModeA, - fxMesa->TexCombineExt[unit].Alpha.SourceB, - fxMesa->TexCombineExt[unit].Alpha.ModeB, - fxMesa->TexCombineExt[unit].Alpha.SourceC, - fxMesa->TexCombineExt[unit].Alpha.InvertC, - fxMesa->TexCombineExt[unit].Alpha.SourceD, - fxMesa->TexCombineExt[unit].Alpha.InvertD, - fxMesa->TexCombineExt[unit].Alpha.Shift, - fxMesa->TexCombineExt[unit].Alpha.Invert); - fxMesa->Glide.grConstantColorValueExt(TDFX_TMU0 + unit, - fxMesa->TexCombineExt[unit].EnvColor); - } - } - else { - /* Voodoo3 */ - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - struct tdfx_texcombine *comb = &fxMesa->TexCombine[unit]; - fxMesa->Glide.grTexCombine(TDFX_TMU0 + unit, - comb->FunctionRGB, - comb->FactorRGB, - comb->FunctionAlpha, - comb->FactorAlpha, - comb->InvertRGB, - comb->InvertAlpha); - } - } -} - - -static void uploadTextureParams( tdfxContextPtr fxMesa ) -{ - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - const struct tdfx_texparams *p = &fxMesa->TexParams[unit]; - /* - printf("upload params %d\n", unit); - printf(" clamp %x %x\n", env->sClamp, env->tClamp); - printf(" filter %x %x\n", env->minFilt, env->magFilt); - printf(" mipmap %x %x\n", env->mmMode, env->LODblend); - printf(" lod bias %f\n", env->LodBias); - */ - fxMesa->Glide.grTexClampMode(GR_TMU0 + unit, p->sClamp, p->tClamp); - fxMesa->Glide.grTexFilterMode(GR_TMU0 + unit, p->minFilt, p->magFilt); - fxMesa->Glide.grTexMipMapMode(GR_TMU0 + unit, p->mmMode, p->LODblend); - fxMesa->Glide.grTexLodBiasValue(GR_TMU0 + unit, CLAMP(p->LodBias, -8, 7.75)); - } -} - - -static void uploadTextureSource( tdfxContextPtr fxMesa ) -{ - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - const struct tdfx_texsource *src = &fxMesa->TexSource[unit]; - /* - printf("upload source %d @ %d %p\n", unit, src->StartAddress, src->Info); - */ - if (src->Info) { - /* - printf(" smallLodLog2=%d largeLodLog2=%d ar=%d format=%d data=%p\n", - src->Info->smallLodLog2, src->Info->largeLodLog2, - src->Info->aspectRatioLog2, src->Info->format, - src->Info->data); - */ - fxMesa->Glide.grTexSource(GR_TMU0 + unit, - src->StartAddress, - src->EvenOdd, - src->Info); - } - } -} - - -static void uploadTextureImages( tdfxContextPtr fxMesa ) -{ - GLcontext *ctx = fxMesa->glCtx; - int unit; - for (unit = 0; unit < TDFX_NUM_TMU; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current; - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - if (ti && ti->reloadImages && ti->whichTMU != TDFX_TMU_NONE) { - /* - printf("download texture image on unit %d\n", unit); - */ - tdfxTMDownloadTexture(fxMesa, tObj); - ti->reloadImages = GL_FALSE; - } - } - } -} - - - -/* - * If scissoring is enabled, compute intersection of scissor region - * with all X clip rects, resulting in new cliprect list. - * If number of cliprects is zero or one, call grClipWindow to setup - * the clip region. Otherwise we'll call grClipWindow inside the - * BEGIN_CLIP_LOOP macro. - */ -void tdfxUploadClipping( tdfxContextPtr fxMesa ) -{ - __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; - - assert(dPriv); - - if (fxMesa->numClipRects == 0) { - /* all drawing clipped away */ - fxMesa->Glide.grClipWindow(0, 0, 0, 0); - } - else if (fxMesa->numClipRects == 1) { - fxMesa->Glide.grClipWindow(fxMesa->pClipRects[0].x1, - fxMesa->screen_height - fxMesa->pClipRects[0].y2, - fxMesa->pClipRects[0].x2, - fxMesa->screen_height - fxMesa->pClipRects[0].y1); - } - /* else, we'll do a cliprect loop around all drawing */ - - fxMesa->Glide.grDRIPosition( dPriv->x, dPriv->y, dPriv->w, dPriv->h, - fxMesa->numClipRects, fxMesa->pClipRects ); -} - - -void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa ) -{ - if ( !fxMesa->dirty ) - return; - - if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_COMBINE ) { - if (TDFX_IS_NAPALM(fxMesa)) { - fxMesa->Glide.grColorCombineExt(fxMesa->ColorCombineExt.SourceA, - fxMesa->ColorCombineExt.ModeA, - fxMesa->ColorCombineExt.SourceB, - fxMesa->ColorCombineExt.ModeB, - fxMesa->ColorCombineExt.SourceC, - fxMesa->ColorCombineExt.InvertC, - fxMesa->ColorCombineExt.SourceD, - fxMesa->ColorCombineExt.InvertD, - fxMesa->ColorCombineExt.Shift, - fxMesa->ColorCombineExt.Invert); - } - else { - /* Voodoo 3 */ - fxMesa->Glide.grColorCombine( fxMesa->ColorCombine.Function, - fxMesa->ColorCombine.Factor, - fxMesa->ColorCombine.Local, - fxMesa->ColorCombine.Other, - fxMesa->ColorCombine.Invert ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_COMBINE; - } - if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_COMBINE ) { - if (TDFX_IS_NAPALM(fxMesa)) { - fxMesa->Glide.grAlphaCombineExt(fxMesa->AlphaCombineExt.SourceA, - fxMesa->AlphaCombineExt.ModeA, - fxMesa->AlphaCombineExt.SourceB, - fxMesa->AlphaCombineExt.ModeB, - fxMesa->AlphaCombineExt.SourceC, - fxMesa->AlphaCombineExt.InvertC, - fxMesa->AlphaCombineExt.SourceD, - fxMesa->AlphaCombineExt.InvertD, - fxMesa->AlphaCombineExt.Shift, - fxMesa->AlphaCombineExt.Invert); - } - else { - /* Voodoo 3 */ - fxMesa->Glide.grAlphaCombine( fxMesa->AlphaCombine.Function, - fxMesa->AlphaCombine.Factor, - fxMesa->AlphaCombine.Local, - fxMesa->AlphaCombine.Other, - fxMesa->AlphaCombine.Invert ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_COMBINE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_RENDER_BUFFER ) { - fxMesa->Glide.grRenderBuffer( fxMesa->DrawBuffer ); - fxMesa->dirty &= ~TDFX_UPLOAD_RENDER_BUFFER; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE) { - fxMesa->Glide.grStipplePattern( fxMesa->Stipple.Pattern ); - fxMesa->Glide.grStippleMode( fxMesa->Stipple.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_TEST ) { - fxMesa->Glide.grAlphaTestFunction( fxMesa->Color.AlphaFunc ); - fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_TEST; - } - if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_REF ) { - fxMesa->Glide.grAlphaTestReferenceValue( fxMesa->Color.AlphaRef ); - fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_REF; - } - if ( fxMesa->dirty & TDFX_UPLOAD_BLEND_FUNC ) { - if (fxMesa->Glide.grAlphaBlendFunctionExt) { - fxMesa->Glide.grAlphaBlendFunctionExt( fxMesa->Color.BlendSrcRGB, - fxMesa->Color.BlendDstRGB, - fxMesa->Color.BlendEqRGB, - fxMesa->Color.BlendSrcA, - fxMesa->Color.BlendDstA, - fxMesa->Color.BlendEqA ); - } - else { - fxMesa->Glide.grAlphaBlendFunction( fxMesa->Color.BlendSrcRGB, - fxMesa->Color.BlendDstRGB, - fxMesa->Color.BlendSrcA, - fxMesa->Color.BlendDstA ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_BLEND_FUNC; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_MODE ) { - fxMesa->Glide.grDepthBufferMode( fxMesa->Depth.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_MODE; - } - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_BIAS ) { - fxMesa->Glide.grDepthBiasLevel( fxMesa->Depth.Bias ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_BIAS; - } - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_FUNC ) { - fxMesa->Glide.grDepthBufferFunction( fxMesa->Depth.Func ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_FUNC; - } - if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_MASK ) { - fxMesa->Glide.grDepthMask( fxMesa->Depth.Mask ); - fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_MASK; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_DITHER) { - fxMesa->Glide.grDitherMode( fxMesa->Color.Dither ); - } - - if ( fxMesa->dirty & TDFX_UPLOAD_FOG_MODE ) { - fxMesa->Glide.grFogMode( fxMesa->Fog.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_FOG_MODE; - } - if ( fxMesa->dirty & TDFX_UPLOAD_FOG_COLOR ) { - fxMesa->Glide.grFogColorValue( fxMesa->Fog.Color ); - fxMesa->dirty &= ~TDFX_UPLOAD_FOG_COLOR; - } - if ( fxMesa->dirty & TDFX_UPLOAD_FOG_TABLE ) { - fxMesa->Glide.grFogTable( fxMesa->Fog.Table ); - fxMesa->dirty &= ~TDFX_UPLOAD_FOG_TABLE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) { - fxMesa->Glide.grCullMode( fxMesa->CullMode ); - fxMesa->dirty &= ~TDFX_UPLOAD_CULL; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_CLIP ) { - tdfxUploadClipping( fxMesa ); - fxMesa->dirty &= ~TDFX_UPLOAD_CLIP; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK ) { - if ( fxMesa->Glide.grColorMaskExt - && fxMesa->glCtx->Visual.redBits == 8) { - fxMesa->Glide.grColorMaskExt( fxMesa->Color.ColorMask[RCOMP], - fxMesa->Color.ColorMask[GCOMP], - fxMesa->Color.ColorMask[BCOMP], - fxMesa->Color.ColorMask[ACOMP] ); - } else { - fxMesa->Glide.grColorMask( fxMesa->Color.ColorMask[RCOMP] || - fxMesa->Color.ColorMask[GCOMP] || - fxMesa->Color.ColorMask[BCOMP], - /*fxMesa->Color.ColorMask[ACOMP]*/GL_FALSE/*[dBorca] no-no*/ ); - } - fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_CONSTANT_COLOR ) { - fxMesa->Glide.grConstantColorValue( fxMesa->Color.MonoColor ); - fxMesa->dirty &= ~TDFX_UPLOAD_CONSTANT_COLOR; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_LINE ) { - if (fxMesa->glCtx->Line.SmoothFlag && fxMesa->glCtx->Line.Width == 1.0) - fxMesa->Glide.grEnable(GR_AA_ORDERED); - else - fxMesa->Glide.grDisable(GR_AA_ORDERED); - fxMesa->dirty &= ~TDFX_UPLOAD_LINE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_STENCIL ) { - if (fxMesa->glCtx->Stencil.Enabled) { - fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT); - fxMesa->Glide.grStencilOp(fxMesa->Stencil.FailFunc, - fxMesa->Stencil.ZFailFunc, - fxMesa->Stencil.ZPassFunc); - fxMesa->Glide.grStencilFunc(fxMesa->Stencil.Function, - fxMesa->Stencil.RefValue, - fxMesa->Stencil.ValueMask); - fxMesa->Glide.grStencilMask(fxMesa->Stencil.WriteMask); - } - else { - fxMesa->Glide.grDisable(GR_STENCIL_MODE_EXT); - } - fxMesa->dirty &= ~TDFX_UPLOAD_STENCIL; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_VERTEX_LAYOUT ) { - fxMesa->Glide.grGlideSetVertexLayout( fxMesa->layout[fxMesa->vertexFormat] ); - /* [dborca] enable fogcoord */ - fxMesa->Glide.grVertexLayout(GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, - fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); - fxMesa->dirty &= ~TDFX_UPLOAD_VERTEX_LAYOUT; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_ENV ) { - uploadTextureEnv(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_ENV; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_PARAMS ) { - uploadTextureParams(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_PARAMS; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_PALETTE ) { - if (fxMesa->TexPalette.Data) { - fxMesa->Glide.grTexDownloadTable(fxMesa->TexPalette.Type, fxMesa->TexPalette.Data); - } - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_PALETTE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_SOURCE ) { - uploadTextureSource(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_SOURCE; - } - - if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_IMAGES ) { - uploadTextureImages(fxMesa); - fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_IMAGES; - } - - fxMesa->dirty = 0; -} - - - -void tdfxInitRenderFuncs( struct dd_function_table *functions ) -{ - functions->Clear = tdfxClear; - functions->Finish = tdfxFinish; - functions->Flush = tdfxFlush; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h deleted file mode 100644 index 09d0d9019..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#ifndef __TDFX_RENDER_H__ -#define __TDFX_RENDER_H__ - -#include "tdfx_context.h" - -extern void tdfxInitRenderFuncs( struct dd_function_table *functions ); - -extern void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa ); - -extern void tdfxUploadClipping( tdfxContextPtr fxMesa ); - -#define FLUSH_BATCH( fxMesa ) - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c deleted file mode 100644 index ab64f7986..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ /dev/null @@ -1,492 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c,v 1.3 2002/02/22 21:45:03 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#include "tdfx_dri.h" -#include "tdfx_context.h" -#include "tdfx_lock.h" -#include "tdfx_vb.h" -#include "tdfx_span.h" -#include "tdfx_tris.h" - -#include "framebuffer.h" -#include "renderbuffer.h" -#include "xmlpool.h" - -#include "utils.h" - -#ifdef DEBUG_LOCKING -char *prevLockFile = 0; -int prevLockLine = 0; -#endif - -#ifndef TDFX_DEBUG -int TDFX_DEBUG = 0; -#endif - -PUBLIC const char __driConfigOptions[] = -DRI_CONF_BEGIN - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST(false) - DRI_CONF_SECTION_END -DRI_CONF_END; - -static const GLuint __driNConfigOptions = 1; - -extern const struct dri_extension card_extensions[]; -extern const struct dri_extension napalm_extensions[]; - -static GLboolean -tdfxCreateScreen( __DRIscreenPrivate *sPriv ) -{ - tdfxScreenPrivate *fxScreen; - TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv; - - if (sPriv->devPrivSize != sizeof(TDFXDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(TDFXDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - fxScreen = (tdfxScreenPrivate *) CALLOC( sizeof(tdfxScreenPrivate) ); - if ( !fxScreen ) - return GL_FALSE; - - /* parse information in __driConfigOptions */ - driParseOptionInfo (&fxScreen->optionCache, - __driConfigOptions, __driNConfigOptions); - - fxScreen->driScrnPriv = sPriv; - sPriv->private = (void *) fxScreen; - - fxScreen->regs.handle = fxDRIPriv->regs; - fxScreen->regs.size = fxDRIPriv->regsSize; - fxScreen->deviceID = fxDRIPriv->deviceID; - fxScreen->width = fxDRIPriv->width; - fxScreen->height = fxDRIPriv->height; - fxScreen->mem = fxDRIPriv->mem; - fxScreen->cpp = fxDRIPriv->cpp; - fxScreen->stride = fxDRIPriv->stride; - fxScreen->fifoOffset = fxDRIPriv->fifoOffset; - fxScreen->fifoSize = fxDRIPriv->fifoSize; - fxScreen->fbOffset = fxDRIPriv->fbOffset; - fxScreen->backOffset = fxDRIPriv->backOffset; - fxScreen->depthOffset = fxDRIPriv->depthOffset; - fxScreen->textureOffset = fxDRIPriv->textureOffset; - fxScreen->textureSize = fxDRIPriv->textureSize; - fxScreen->sarea_priv_offset = fxDRIPriv->sarea_priv_offset; - - if ( drmMap( sPriv->fd, fxScreen->regs.handle, - fxScreen->regs.size, &fxScreen->regs.map ) ) { - return GL_FALSE; - } - - return GL_TRUE; -} - - -static void -tdfxDestroyScreen( __DRIscreenPrivate *sPriv ) -{ - tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private; - - if (!fxScreen) - return; - - drmUnmap( fxScreen->regs.map, fxScreen->regs.size ); - - /* free all option information */ - driDestroyOptionInfo (&fxScreen->optionCache); - - FREE( fxScreen ); - sPriv->private = NULL; -} - - -static GLboolean -tdfxInitDriver( __DRIscreenPrivate *sPriv ) -{ - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)sPriv ); - } - - if ( !tdfxCreateScreen( sPriv ) ) { - tdfxDestroyScreen( sPriv ); - return GL_FALSE; - } - - return GL_TRUE; -} - - -static GLboolean -tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) -{ - tdfxScreenPrivate *screen = (tdfxScreenPrivate *) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { -#if 0 - driDrawPriv->driverPrivate = (void *) - _mesa_create_framebuffer( mesaVis, - GL_FALSE, /* software depth buffer? */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - GL_FALSE /* software alpha channel? */ ); -#else - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(GL_RGBA, screen->cpp, - screen->fbOffset, screen->width); - tdfxSetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(GL_RGBA, screen->cpp, - screen->backOffset, screen->width); - tdfxSetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp, - screen->depthOffset, screen->width); - tdfxSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp, - screen->depthOffset, screen->width); - tdfxSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - if (mesaVis->stencilBits > 0) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp, - screen->depthOffset, screen->width); - tdfxSetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - GL_FALSE, /*swStencil,*/ - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; -#endif - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -tdfxDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) -{ - _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate)); -} - - -static void -tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv ) - -{ - GET_CURRENT_CONTEXT(ctx); - tdfxContextPtr fxMesa = 0; - GLframebuffer *mesaBuffer; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driDrawPriv ); - } - - mesaBuffer = (GLframebuffer *) driDrawPriv->driverPrivate; - if ( !mesaBuffer->Visual.doubleBufferMode ) - return; /* can't swap a single-buffered window */ - - /* If the current context's drawable matches the given drawable - * we have to do a glFinish (per the GLX spec). - */ - if ( ctx ) { - __DRIdrawablePrivate *curDrawPriv; - fxMesa = TDFX_CONTEXT(ctx); - curDrawPriv = fxMesa->driContext->driDrawablePriv; - - if ( curDrawPriv == driDrawPriv ) { - /* swapping window bound to current context, flush first */ - _mesa_notifySwapBuffers( ctx ); - LOCK_HARDWARE( fxMesa ); - } - else { - /* find the fxMesa context previously bound to the window */ - fxMesa = (tdfxContextPtr) driDrawPriv->driContextPriv->driverPrivate; - if (!fxMesa) - return; - LOCK_HARDWARE( fxMesa ); - fxMesa->Glide.grSstSelect( fxMesa->Glide.Board ); - printf("SwapBuf SetState 1\n"); - fxMesa->Glide.grGlideSetState(fxMesa->Glide.State ); - } - } - -#ifdef STATS - { - int stalls; - static int prevStalls = 0; - - stalls = fxMesa->Glide.grFifoGetStalls(); - - fprintf( stderr, "%s:\n", __FUNCTION__ ); - if ( stalls != prevStalls ) { - fprintf( stderr, " %d stalls occurred\n", - stalls - prevStalls ); - prevStalls = stalls; - } - if ( fxMesa && fxMesa->texSwaps ) { - fprintf( stderr, " %d texture swaps occurred\n", - fxMesa->texSwaps ); - fxMesa->texSwaps = 0; - } - } -#endif - - if (fxMesa->scissoredClipRects) { - /* restore clip rects without scissor box */ - fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y, - driDrawPriv->w, driDrawPriv->h, - driDrawPriv->numClipRects, - driDrawPriv->pClipRects ); - } - - fxMesa->Glide.grDRIBufferSwap( fxMesa->Glide.SwapInterval ); - - if (fxMesa->scissoredClipRects) { - /* restore clip rects WITH scissor box */ - fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y, - driDrawPriv->w, driDrawPriv->h, - fxMesa->numClipRects, fxMesa->pClipRects ); - } - - -#if 0 - { - FxI32 result; - do { - FxI32 result; - fxMesa->Glide.grGet(GR_PENDING_BUFFERSWAPS, 4, &result); - } while ( result > fxMesa->maxPendingSwapBuffers ); - } -#endif - - fxMesa->stats.swapBuffer++; - - if (ctx) { - if (ctx->DriverCtx != fxMesa) { - fxMesa = TDFX_CONTEXT(ctx); - fxMesa->Glide.grSstSelect( fxMesa->Glide.Board ); - printf("SwapBuf SetState 2\n"); - fxMesa->Glide.grGlideSetState(fxMesa->Glide.State ); - } - UNLOCK_HARDWARE( fxMesa ); - } -} - - -static const struct __DriverAPIRec tdfxAPI = { - .InitDriver = tdfxInitDriver, - .DestroyScreen = tdfxDestroyScreen, - .CreateContext = tdfxCreateContext, - .DestroyContext = tdfxDestroyContext, - .CreateBuffer = tdfxCreateBuffer, - .DestroyBuffer = tdfxDestroyBuffer, - .SwapBuffers = tdfxSwapBuffers, - .MakeCurrent = tdfxMakeCurrent, - .UnbindContext = tdfxUnbindContext, - .GetSwapInfo = NULL, - .GetMSC = NULL, - .WaitForMSC = NULL, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - - -static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits, - unsigned depth_bits, - unsigned stencil_bits, - GLboolean have_back_buffer) -{ - __GLcontextModes *modes; - __GLcontextModes *m; - unsigned num_modes; - unsigned vis[2] = { GLX_TRUE_COLOR, GLX_DIRECT_COLOR }; - unsigned deep = (depth_bits > 17); - unsigned i, db, depth, accum, stencil; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - - num_modes = (depth_bits == 16) ? 32 : 16; - - modes = (*dri_interface->createContextModes)(num_modes, sizeof(__GLcontextModes)); - m = modes; - - for (i = 0; i <= 1; i++) { - for (db = 0; db <= 1; db++) { - for (depth = 0; depth <= 1; depth++) { - for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= !deep; stencil++) { - if (deep) stencil = depth; - m->redBits = deep ? 8 : 5; - m->greenBits = deep ? 8 : 6; - m->blueBits = deep ? 8 : 5; - m->alphaBits = deep ? 8 : 0; - m->redMask = deep ?0xFF000000 :0x0000F800; - m->greenMask = deep ?0x00FF0000 :0x000007E0; - m->blueMask = deep ?0x0000FF00 :0x0000001F; - m->alphaMask = deep ? 0x000000FF : 0; - m->rgbBits = m->redBits + m->greenBits + - m->blueBits + m->alphaBits; - m->accumRedBits = accum ? 16 : 0; - m->accumGreenBits = accum ? 16 : 0; - m->accumBlueBits = accum ? 16 : 0; - m->accumAlphaBits = accum ? 16 : 0; - m->stencilBits = stencil ? 8 : 0; - m->depthBits = deep - ? (depth ? 24 : 0) - : (depth ? 0 : depth_bits); - m->visualType = vis[i]; - m->renderType = GLX_RGBA_BIT; - m->drawableType = GLX_WINDOW_BIT; - m->rgbMode = GL_TRUE; - m->doubleBufferMode = db ? GL_TRUE : GL_FALSE; - if (db) - m->swapMethod = GLX_SWAP_UNDEFINED_OML; - m->visualRating = ((stencil && !deep) || accum) - ? GLX_SLOW_CONFIG - : GLX_NONE; - m = m->next; - if (deep) stencil = 0; - } - } - } - } - } - - return modes; -} - -/** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. - * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. - */ -PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) -{ - __DRIscreenPrivate *psp; - static const __DRIversion ddx_expected = { 1, 1, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 0, 0 }; - - dri_interface = interface; - - if ( ! driCheckDriDdxDrmVersions2( "tdfx", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { - return NULL; - } - - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &tdfxAPI); - - if (psp != NULL) { - /* divined from tdfx_dri.c, sketchy */ - TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv; - int bpp = (dri_priv->cpp > 2) ? 24 : 16; - - /* XXX i wish it was like this */ - /* bpp = dri_priv->bpp */ - - *driver_modes = tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24, - (bpp == 16) ? 0 : 8, - (dri_priv->backOffset!=dri_priv->depthOffset)); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - driInitExtensions( NULL, napalm_extensions, GL_FALSE ); - } - - return (void *)psp; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h deleted file mode 100644 index 90be89a35..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h,v 1.2 2002/02/22 21:45:03 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * - */ - -#ifndef __TDFX_SCREEN_H__ -#define __TDFX_SCREEN_H__ - -typedef struct { - drm_handle_t handle; - drmSize size; - drmAddress map; -} tdfxRegion, *tdfxRegionPtr; - -typedef struct { - tdfxRegion regs; - - int deviceID; - int width; - int height; - int mem; - int cpp; - int stride; - - int fifoOffset; - int fifoSize; - - int fbOffset; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; - - __DRIscreenPrivate *driScrnPriv; - unsigned int sarea_priv_offset; - - /* Configuration cache with default values for all contexts */ - driOptionCache optionCache; -} tdfxScreenPrivate; - - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c deleted file mode 100644 index b00b7ad8d..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c +++ /dev/null @@ -1,1427 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * Keith Whitwell - * - */ - -#include "tdfx_context.h" -#include "tdfx_lock.h" -#include "tdfx_span.h" -#include "tdfx_render.h" -#include "swrast/swrast.h" - - -#define DBG 0 - - -#define LOCAL_VARS \ - __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; \ - tdfxScreenPrivate *fxPriv = fxMesa->fxScreen; \ - GLuint pitch = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) \ - ? (fxMesa->screen_width * BYTESPERPIXEL) : \ - (info.strideInBytes); \ - GLuint height = fxMesa->height; \ - char *buf = (char *)((char *)info.lfbPtr + \ - dPriv->x * fxPriv->cpp + \ - dPriv->y * pitch); \ - GLuint p; \ - (void) buf; (void) p; - - -#define Y_FLIP(_y) (height - _y - 1) - - -#define HW_WRITE_LOCK() \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - FLUSH_BATCH( fxMesa ); \ - UNLOCK_HARDWARE( fxMesa ); \ - LOCK_HARDWARE( fxMesa ); \ - info.size = sizeof(GrLfbInfo_t); \ - if ( fxMesa->Glide.grLfbLock( GR_LFB_WRITE_ONLY, \ - fxMesa->DrawBuffer, LFB_MODE, \ - GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \ - { - -#define HW_WRITE_UNLOCK() \ - fxMesa->Glide.grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer );\ - } - - -#define HW_READ_LOCK() \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - GrLfbInfo_t info; \ - FLUSH_BATCH( fxMesa ); \ - UNLOCK_HARDWARE( fxMesa ); \ - LOCK_HARDWARE( fxMesa ); \ - info.size = sizeof(GrLfbInfo_t); \ - if ( fxMesa->Glide.grLfbLock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer, \ - LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \ - { - -#define HW_READ_UNLOCK() \ - fxMesa->Glide.grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer );\ - } - - -#define HW_WRITE_CLIPLOOP() \ - do { \ - int _nc = fxMesa->numClipRects; \ - while (_nc--) { \ - int minx = fxMesa->pClipRects[_nc].x1 - fxMesa->x_offset; \ - int miny = fxMesa->pClipRects[_nc].y1 - fxMesa->y_offset; \ - int maxx = fxMesa->pClipRects[_nc].x2 - fxMesa->x_offset; \ - int maxy = fxMesa->pClipRects[_nc].y2 - fxMesa->y_offset; - -#define HW_READ_CLIPLOOP() \ - do { \ - const __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; \ - drm_clip_rect_t *rect = dPriv->pClipRects; \ - int _nc = dPriv->numClipRects; \ - while (_nc--) { \ - const int minx = rect->x1 - fxMesa->x_offset; \ - const int miny = rect->y1 - fxMesa->y_offset; \ - const int maxx = rect->x2 - fxMesa->x_offset; \ - const int maxy = rect->y2 - fxMesa->y_offset; \ - rect++; - -#define HW_ENDCLIPLOOP() \ - } \ - } while (0) - - - -#define LFB_MODE GR_LFBWRITEMODE_565 - - -/* 16 bit, RGB565 color spanline and pixel functions */ \ - -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = TDFXPACKCOLOR565( color[0], color[1], color[2] ) - - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \ - (((int)g & 0xfc) << 3) | \ - (((int)b & 0xf8) >> 3)) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (((p >> 11) & 0x1f) * 255) / 31; \ - rgba[1] = (((p >> 5) & 0x3f) * 255) / 63; \ - rgba[2] = (((p >> 0) & 0x1f) * 255) / 31; \ - rgba[3] = 0xff; \ - } while (0) - -#define TAG(x) tdfx##x##_RGB565 -#define BYTESPERPIXEL 2 -#include "spantmp.h" -#undef BYTESPERPIXEL - - -/* 16 bit, BGR565 color spanline and pixel functions */ \ -#if 0 - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)b & 0xf8) << 8) | \ - (((int)g & 0xfc) << 3) | \ - (((int)r & 0xf8) >> 3)) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (p << 3) & 0xf8; \ - rgba[1] = (p >> 3) & 0xfc; \ - rgba[2] = (p >> 8) & 0xf8; \ - rgba[3] = 0xff; \ - } while (0) - -#define TAG(x) tdfx##x##_BGR565 -#define BYTESPERPIXEL 2 -#include "spantmp.h" -#undef BYTESPERPIXEL -#endif - - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_888 - - -/* 24 bit, RGB888 color spanline and pixel functions */ -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = TDFXPACKCOLOR888( color[0], color[1], color[2] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*3 + _y*pitch) = ((b << 0) | \ - (g << 8) | \ - (r << 16)) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*3 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLuint p = *(GLuint *)(buf + _x*3 + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = 0xff; \ -} while (0) - -#define TAG(x) tdfx##x##_RGB888 -#define BYTESPERPIXEL 4 -#include "spantmp.h" -#undef BYTESPERPIXEL - - -#undef LFB_MODE -#define LFB_MODE GR_LFBWRITEMODE_8888 - - -/* 32 bit, ARGB8888 color spanline and pixel functions */ -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = TDFXPACKCOLOR8888( color[0], color[1], color[2], color[3] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \ - (g << 8) | \ - (r << 16) | \ - (a << 24) ) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = (p >> 24) & 0xff; \ -} while (0) - -#define TAG(x) tdfx##x##_ARGB8888 -#define BYTESPERPIXEL 4 -#include "spantmp.h" -#undef BYTESPERPIXEL - - - -/* ================================================================ - * Old span functions below... - */ - - -/* - * 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 tdfxContextPtr fxMesa, GLint x, GLint y, GLint n, - GLubyte vismask[]) -{ - GLboolean initialized = GL_FALSE; - GLint i, j; - - /* Ensure we clear the visual mask */ - MEMSET(vismask, 0, n); - - /* turn on flags for all visible pixels */ - for (i = 0; i < fxMesa->numClipRects; i++) { - const drm_clip_rect_t *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 tdfxContextPtr fxMesa, int scrX, int scrY) -{ - int i; - for (i = 0; i < fxMesa->numClipRects; i++) { - const drm_clip_rect_t *rect = &fxMesa->pClipRects[i]; - if (scrX >= rect->x1 && - scrX < rect->x2 && - scrY >= rect->y1 && scrY < rect->y2) return GL_TRUE; - } - return GL_FALSE; -} - - - -/* - * Depth buffer read/write functions. - */ -/* - * To read the frame buffer, we need to lock and unlock it. The - * four macros {READ,WRITE}_FB_SPAN_{LOCK,UNLOCK} - * do this for us. - * - * Note that the lock must be matched with an unlock. These - * macros include a spare curly brace, so they must - * be syntactically matched. - * - * Note, also, that you can't lock a buffer twice with different - * modes. That is to say, you can't lock a buffer in both read - * and write modes. The strideInBytes and LFB pointer will be - * the same with read and write locks, so you can use either. - * o The HW has different state for reads and writes, so - * locking it twice may give screwy results. - * o The DRM won't let you lock twice. It hangs. This is probably - * because of the LOCK_HARDWARE IN THE *_FB_SPAN_LOCK macros, - * and could be eliminated with nonlocking lock routines. But - * what's the point after all. - */ -#define READ_FB_SPAN_LOCK(fxMesa, info, target_buffer) \ - UNLOCK_HARDWARE(fxMesa); \ - LOCK_HARDWARE(fxMesa); \ - (info).size=sizeof(info); \ - if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY, \ - target_buffer, \ - GR_LFBWRITEMODE_ANY, \ - GR_ORIGIN_UPPER_LEFT, \ - FXFALSE, \ - &(info))) { - -#define READ_FB_SPAN_UNLOCK(fxMesa, target_buffer) \ - fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, target_buffer); \ - } else { \ - fprintf(stderr, "tdfxDriver: Can't get %s (%d) read lock\n", \ - (target_buffer == GR_BUFFER_BACKBUFFER) \ - ? "back buffer" \ - : ((target_buffer == GR_BUFFER_AUXBUFFER) \ - ? "depth buffer" \ - : "unknown buffer"), \ - target_buffer); \ - } - -#define WRITE_FB_SPAN_LOCK(fxMesa, info, target_buffer, write_mode) \ - UNLOCK_HARDWARE(fxMesa); \ - LOCK_HARDWARE(fxMesa); \ - info.size=sizeof(info); \ - if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY, \ - target_buffer, \ - write_mode, \ - GR_ORIGIN_UPPER_LEFT, \ - FXFALSE, \ - &info)) { - -#define WRITE_FB_SPAN_UNLOCK(fxMesa, target_buffer) \ - fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, target_buffer); \ - } else { \ - fprintf(stderr, "tdfxDriver: Can't get %s (%d) write lock\n", \ - (target_buffer == GR_BUFFER_BACKBUFFER) \ - ? "back buffer" \ - : ((target_buffer == GR_BUFFER_AUXBUFFER) \ - ? "depth buffer" \ - : "unknown buffer"), \ - target_buffer); \ - } - -/* - * Because the Linear Frame Buffer is not necessarily aligned - * with the depth buffer, we have to do some fiddling - * around to get the right addresses. - * - * Perhaps a picture is in order. The Linear Frame Buffer - * looks like this: - * - * |<----------------------info.strideInBytes------------->| - * |<-----physicalStrideInBytes------->| - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * | | | - * | Legal Memory | Forbidden Zone | - * | | | - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * - * You can only reliably read and write legal locations. Reads - * and writes from the Forbidden Zone will return undefined values, - * and may cause segmentation faults. - * - * Now, the depth buffer may not end up in a location such each - * scan line is an LFB line. For example, the depth buffer may - * look like this: - * - * wrapped ordinary. - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * |0000000000000000000000 | | back - * |1111111111111111111111 | | buffer - * |2222222222222222222222 | | - * |4096b align. padxx00000000000000000| Forbidden Zone | depth - * |0000 11111111111111111| | buffer - * |1111 22222222222222222| | - * |2222 | | - * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+ - * where each number is the scan line number. We know it will - * be aligned on 128 byte boundaries, at least. Aligning this - * on a scanline boundary causes the back and depth buffers to - * thrash in the SST1 cache. (Note that the back buffer is always - * allocated at the beginning of LFB memory, and so it is always - * properly aligned with the LFB stride.) - * - * We call the beginning of the line (which is the rightmost - * part of the depth line in the picture above) the *ordinary* part - * of the scanline, and the end of the line (which is the - * leftmost part, one line below) the *wrapped* part of the scanline. - * a.) We need to know what x value to subtract from the screen - * x coordinate to index into the wrapped part. - * b.) We also need to figure out if we need to read from the ordinary - * part scan line, or from the wrapped part of the scan line. - * - * [ad a] - * The first wrapped x coordinate is that coordinate such that - * depthBufferOffset&(info.strideInBytes) + x*elmentSize {*} - * > physicalStrideInBytes - * where depthBufferOffset is the LFB distance in bytes - * from the back buffer to the depth buffer. The expression - * depthBufferOffset&(info.strideInBytes) - * is then the offset (in bytes) from the beginining of (any) - * depth buffer line to first element in the line. - * Simplifying inequation {*} above we see that x is the smallest - * value such that - * x*elementSize > physicalStrideInBytes {**} - * - depthBufferOffset&(info.strideInBytes) - * Now, we know that both the summands on the right are multiples of - * 128, and elementSize <= 4, so if equality holds in {**}, x would - * be a multiple of 32. Thus we can set x to - * xwrapped = (physicalStrideInBytes - * - depthBufferOffset&(info.strideInBytes))/elementSize - * + 1 - * - * [ad b] - * Question b is now simple. We read from the wrapped scan line if - * x is greater than xwrapped. - */ -#define TILE_WIDTH_IN_BYTES 128 -#define TILE_WIDTH_IN_ZOXELS(bpz) (TILE_WIDTH_IN_BYTES/(bpz)) -#define TILE_HEIGHT_IN_LINES 32 -typedef struct -{ - void *lfbPtr; - void *lfbWrapPtr; - FxU32 LFBStrideInElts; - GLint firstWrappedX; -} -LFBParameters; - -/* - * We need information about the back buffer. Note that - * this function *cannot be called* while the aux buffer - * is locked, or the caller will hang. - * - * Only Glide knows the LFB address of the back and depth - * offsets. The upper levels of Mesa know the depth offset, - * but that is not in LFB space, it is tiled memory space, - * and is not useable for us. - */ -static void -GetBackBufferInfo(tdfxContextPtr fxMesa, GrLfbInfo_t * backBufferInfo) -{ - READ_FB_SPAN_LOCK(fxMesa, *backBufferInfo, GR_BUFFER_BACKBUFFER); - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_BACKBUFFER); -} - -static void -GetFbParams(tdfxContextPtr fxMesa, - GrLfbInfo_t * info, - GrLfbInfo_t * backBufferInfo, - LFBParameters * ReadParamsp, FxU32 elementSize) -{ - FxU32 physicalStrideInBytes, bufferOffset; - FxU32 strideInBytes = info->strideInBytes; - char *lfbPtr = (char *) (info->lfbPtr); /* For arithmetic, use char * */ - - /* - * These two come directly from the info structure. - */ - ReadParamsp->lfbPtr = (void *) lfbPtr; - ReadParamsp->LFBStrideInElts = strideInBytes / elementSize; - /* - * Now, calculate the value of firstWrappedX. - * - * The physical stride is the screen width in bytes rounded up to - * the next highest multiple of 128 bytes. Note that this fails - * when TILE_WIDTH_IN_BYTES is not a power of two. - * - * The buffer Offset is the distance between the beginning of - * the LFB space, which is the beginning of the back buffer, - * and the buffer we are gathering information about. - * We want to make this routine usable for operations on the - * back buffer, though we don't actually use it on the back - * buffer. Note, then, that if bufferOffset == 0, the firstWrappedX - * is in the forbidden zone, and is therefore never reached. - * - * Note that if - * physicalStrideInBytes - * < bufferOffset&(info->strideInBytes-1) - * the buffer begins in the forbidden zone. We assert for this. - */ - bufferOffset = (FxU32)(lfbPtr - (char *) backBufferInfo->lfbPtr); - physicalStrideInBytes - = (fxMesa->screen_width * elementSize + TILE_WIDTH_IN_BYTES - 1) - & ~(TILE_WIDTH_IN_BYTES - 1); - assert(physicalStrideInBytes > (bufferOffset & (strideInBytes - 1))); - ReadParamsp->firstWrappedX - = (physicalStrideInBytes - - (bufferOffset & (strideInBytes - 1))) / elementSize; - /* - * This is the address of the next physical line. - */ - ReadParamsp->lfbWrapPtr - = (void *) ((char *) backBufferInfo->lfbPtr - + (bufferOffset & ~(strideInBytes - 1)) - + (TILE_HEIGHT_IN_LINES) * strideInBytes); -} - -/* - * These macros fetch data from the frame buffer. The type is - * the type of data we want to fetch. It should match the type - * whose size was used with GetFbParams to fill in the structure - * in *ReadParamsp. We have a macro to read the ordinary - * part, a second macro to read the wrapped part, and one which - * will do either. When we are reading a span, we will know - * when the ordinary part ends, so there's no need to test for - * it. However, when reading and writing pixels, we don't - * necessarily know. I suppose it's a matter of taste whether - * it's better in the macro or in the call. - * - * Recall that x and y are screen coordinates. - */ -#define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \ - (((type *)((ReadParamsp)->lfbPtr)) \ - [(y) * ((ReadParamsp)->LFBStrideInElts) \ - + (x)]) -#define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \ - (((type *)((ReadParamsp)->lfbWrapPtr)) \ - [((y)) * ((ReadParamsp)->LFBStrideInElts) \ - + ((x) - (ReadParamsp)->firstWrappedX)]) -#define GET_FB_DATA(ReadParamsp, type, x, y) \ - (((x) < (ReadParamsp)->firstWrappedX) \ - ? GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \ - : GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y)) -#define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \ - (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) -#define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \ - (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) -#define PUT_FB_DATA(ReadParamsp, type, x, y, value) \ - do { \ - if ((x) < (ReadParamsp)->firstWrappedX) \ - PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value); \ - else \ - PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value); \ - } while (0) - - -static void -tdfxDDWriteDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, const void *values, - const GLubyte mask[]) -{ - const GLuint *depth = (const GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->y_offset + fxMesa->height - 1; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits; - GrLfbInfo_t info; - GLubyte visMask[MAX_WIDTH]; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDWriteDepthSpan(...)\n"); - } - - assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32)); - /* - * Convert x and y to screen coordinates. - */ - x += fxMesa->x_offset; - y = bottom - y; - if (mask) { - GLint i; - GLushort d16; - GrLfbInfo_t backBufferInfo; - - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, - GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - int wrappedPartStart; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - if (mask[i] && visMask[i]) { - d16 = depth[i]; - PUT_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y, d16); - } - } - for (; i < n; i++) { - if (mask[i] && visMask[i]) { - d16 = depth[i]; - PUT_WRAPPED_FB_DATA(&ReadParams, GLushort, x + i, y, d16); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, - GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - int wrappedPartStart; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - GLuint d32; - if (mask[i] && visMask[i]) { - if (stencil_size > 0) { - d32 = - GET_ORDINARY_FB_DATA(&ReadParams, GLuint, - x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - for (; i < n; i++) { - GLuint d32; - if (mask[i] && visMask[i]) { - if (stencil_size > 0) { - d32 = - GET_WRAPPED_FB_DATA(&ReadParams, GLuint, - x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - } - else { - GLint i; - GLuint d32; - GLushort d16; - GrLfbInfo_t backBufferInfo; - - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - GLuint wrappedPartStart; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - if (visMask[i]) { - d16 = depth[i]; - PUT_ORDINARY_FB_DATA(&ReadParams, - GLushort, - x + i, y, - d16); - } - } - for (; i < n; i++) { - if (visMask[i]) { - d16 = depth[i]; - PUT_WRAPPED_FB_DATA(&ReadParams, - GLushort, - x + i, y, - d16); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - generate_vismask(fxMesa, x, y, n, visMask); - { - LFBParameters ReadParams; - GLuint wrappedPartStart; - - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - if (visMask[i]) { - if (stencil_size > 0) { - d32 = GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - for (; i < n; i++) { - if (visMask[i]) { - if (stencil_size > 0) { - d32 = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y); - d32 = - (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF); - } - else { - d32 = depth[i]; - } - PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - } -} - -static void -tdfxDDWriteMonoDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, const void *value, - const GLubyte mask[]) -{ - GLuint depthVal = *((GLuint *) value); - GLuint depths[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) - depths[i] = depthVal; - tdfxDDWriteDepthSpan(ctx, rb, n, x, y, depths, mask); -} - - -static void -tdfxDDReadDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, void *values) -{ - GLuint *depth = (GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->height + fxMesa->y_offset - 1; - GLuint i; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GrLfbInfo_t info; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDReadDepthSpan(...)\n"); - } - - /* - * Convert to screen coordinates. - */ - x += fxMesa->x_offset; - y = bottom - y; - switch (depth_size) { - case 16: - { - LFBParameters ReadParams; - GrLfbInfo_t backBufferInfo; - int wrappedPartStart; - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - /* - * Read the line. - */ - for (i = 0; i < wrappedPartStart; i++) { - depth[i] = - GET_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y); - } - for (; i < n; i++) { - depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLushort, - x + i, y); - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - case 24: - case 32: - { - LFBParameters ReadParams; - GrLfbInfo_t backBufferInfo; - int wrappedPartStart; - GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits; - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - /* - * Read the line. - */ - for (i = 0; i < wrappedPartStart; i++) { - const GLuint mask = - (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF; - depth[i] = - GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y); - depth[i] &= mask; - } - for (; i < n; i++) { - const GLuint mask = - (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF; - depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y); - depth[i] &= mask; - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } - } -} - - -static void -tdfxDDWriteDepthPixels(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[]) -{ - const GLuint *depth = (const GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->height + fxMesa->y_offset - 1; - GLuint i; - GLushort d16; - GLuint d32; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits; - GrLfbInfo_t info; - int xpos; - int ypos; - GrLfbInfo_t backBufferInfo; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDWriteDepthPixels(...)\n"); - } - - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - for (i = 0; i < n; i++) { - if (mask[i] && visible_pixel(fxMesa, x[i], y[i])) { - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - d16 = depth[i]; - PUT_FB_DATA(&ReadParams, GLushort, xpos, ypos, d16); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, - GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - for (i = 0; i < n; i++) { - if (mask[i]) { - if (visible_pixel(fxMesa, x[i], y[i])) { - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - if (stencil_size > 0) { - d32 = - GET_FB_DATA(&ReadParams, GLuint, xpos, ypos); - d32 = (d32 & 0xFF000000) | (depth[i] & 0xFFFFFF); - } - else { - d32 = depth[i]; - } - PUT_FB_DATA(&ReadParams, GLuint, xpos, ypos, d32); - } - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - } -} - - -static void -tdfxDDReadDepthPixels(GLcontext * ctx, struct gl_renderbuffer *rb, GLuint n, - const GLint x[], const GLint y[], void *values) -{ - GLuint *depth = (GLuint *) values; - tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx; - GLint bottom = fxMesa->height + fxMesa->y_offset - 1; - GLuint i; - GLuint depth_size = fxMesa->glCtx->Visual.depthBits; - GLushort d16; - int xpos; - int ypos; - GrLfbInfo_t info; - GLuint stencil_size; - GrLfbInfo_t backBufferInfo; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "tdfxmesa: tdfxDDReadDepthPixels(...)\n"); - } - - assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32)); - switch (depth_size) { - case 16: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLushort)); - for (i = 0; i < n; i++) { - /* - * Convert to screen coordinates. - */ - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - d16 = GET_FB_DATA(&ReadParams, GLushort, xpos, ypos); - depth[i] = d16; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - case 24: - case 32: - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - stencil_size = fxMesa->glCtx->Visual.stencilBits; - { - LFBParameters ReadParams; - GetFbParams(fxMesa, &info, &backBufferInfo, - &ReadParams, sizeof(GLuint)); - for (i = 0; i < n; i++) { - GLuint d32; - - /* - * Convert to screen coordinates. - */ - xpos = x[i] + fxMesa->x_offset; - ypos = bottom - y[i]; - d32 = GET_FB_DATA(&ReadParams, GLuint, xpos, ypos); - if (stencil_size > 0) { - d32 &= 0x00FFFFFF; - } - depth[i] = d32; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); - break; - default: - assert(0); - } -} - -/* - * Stencil buffer read/write functions. - */ -#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, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *values, const GLubyte mask[]) -{ - const GLubyte *stencil = (const GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - 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; - LFBParameters ReadParams; - GLubyte visMask[MAX_WIDTH]; - GLuint i; - int wrappedPartStart; - - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - generate_vismask(fxMesa, scrX, scrY, n, visMask); - for (i = 0; i < wrappedPartStart; i++) { - if (visMask[i] && (!mask || mask[i])) { - GLuint z = GET_ORDINARY_FB_DATA(&ReadParams, GLuint, - scrX + i, scrY) & 0x00FFFFFF; - z |= (stencil[i] & 0xFF) << 24; - PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z); - } - } - for (; i < n; i++) { - if (visMask[i] && (!mask || mask[i])) { - GLuint z = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, - scrX + i, scrY) & 0x00FFFFFF; - z |= (stencil[i] & 0xFF) << 24; - PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - - -static void -write_mono_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - const void *value, const GLubyte mask[]) -{ - GLbyte stencilVal = *((GLbyte *) value); - GLbyte stencils[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) - stencils[i] = stencilVal; - write_stencil_span(ctx, rb, n, x, y, stencils, mask); -} - - -static void -read_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - void *values) -{ - GLubyte *stencil = (GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - GLuint i; - LFBParameters ReadParams; - int wrappedPartStart; - - /* - * Convert to screen coordinates. - */ - x += winX; - y = winY - y; - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - if (ReadParams.firstWrappedX <= x) { - wrappedPartStart = 0; - } - else if (n <= (ReadParams.firstWrappedX - x)) { - wrappedPartStart = n; - } - else { - wrappedPartStart = (ReadParams.firstWrappedX - x); - } - for (i = 0; i < wrappedPartStart; i++) { - stencil[i] = (GET_ORDINARY_FB_DATA(&ReadParams, GLuint, - x + i, y) >> 24) & 0xFF; - } - for (; i < n; i++) { - stencil[i] = (GET_WRAPPED_FB_DATA(&ReadParams, GLuint, - x + i, y) >> 24) & 0xFF; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - - -static void -write_stencil_pixels(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - const void *values, const GLubyte mask[]) -{ - const GLubyte *stencil = (const GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - LFBParameters ReadParams; - GLuint i; - - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - for (i = 0; i < n; i++) { - const GLint scrX = winX + x[i]; - const GLint scrY = winY - y[i]; - if ((!mask || mask[i]) && visible_pixel(fxMesa, scrX, scrY)) { - GLuint z = - GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) & 0x00FFFFFF; - z |= (stencil[i] & 0xFF) << 24; - PUT_FB_DATA(&ReadParams, GLuint, scrX, scrY, z); - } - } - } - WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - - -static void -read_stencil_pixels(GLcontext * ctx, struct gl_renderbuffer *rb, - GLuint n, const GLint x[], const GLint y[], - void *values) -{ - GLubyte *stencil = (GLubyte *) values; - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrLfbInfo_t info; - GrLfbInfo_t backBufferInfo; - - GetBackBufferInfo(fxMesa, &backBufferInfo); - /* - * Note that the _LOCK macro adds a curly brace, - * and the UNLOCK macro removes it. - */ - READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER); - { - const GLint winY = fxMesa->y_offset + fxMesa->height - 1; - const GLint winX = fxMesa->x_offset; - GLuint i; - LFBParameters ReadParams; - - GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams, - sizeof(GLuint)); - for (i = 0; i < n; i++) { - const GLint scrX = winX + x[i]; - const GLint scrY = winY - y[i]; - stencil[i] = - (GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) >> 24) & 0xFF; - } - } - READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); -} - -#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \ - ((vis.redBits == r) && \ - (vis.greenBits == g) && \ - (vis.blueBits == b) && \ - (vis.alphaBits == a)) - - - - -/**********************************************************************/ -/* Locking for swrast */ -/**********************************************************************/ - - -static void tdfxSpanRenderStart( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - LOCK_HARDWARE(fxMesa); -} - -static void tdfxSpanRenderFinish( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - _swrast_flush( ctx ); - UNLOCK_HARDWARE(fxMesa); -} - -/* Set the buffer used for reading */ -static void tdfxDDSetBuffer( GLcontext *ctx, - GLframebuffer *buffer, GLuint bufferBit ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - (void) buffer; - - switch ( bufferBit ) { - case BUFFER_BIT_FRONT_LEFT: - fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; - break; - case BUFFER_BIT_BACK_LEFT: - fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; - break; - default: - break; - } -} - -/**********************************************************************/ -/* Initialize swrast device driver */ -/**********************************************************************/ - -void tdfxDDInitSpanFuncs( GLcontext *ctx ) -{ - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx ); - swdd->SetBuffer = tdfxDDSetBuffer; - swdd->SpanRenderStart = tdfxSpanRenderStart; - swdd->SpanRenderFinish = tdfxSpanRenderFinish; -} - - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -tdfxSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) -{ - if (drb->Base.InternalFormat == GL_RGBA) { - if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { - drb->Base.GetRow = tdfxReadRGBASpan_RGB565; - drb->Base.GetValues = tdfxReadRGBAPixels_RGB565; - drb->Base.PutRow = tdfxWriteRGBASpan_RGB565; - drb->Base.PutRowRGB = tdfxWriteRGBSpan_RGB565; - drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_RGB565; - drb->Base.PutValues = tdfxWriteRGBAPixels_RGB565; - drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_RGB565; - } - else if (vis->redBits == 8 && vis->greenBits == 8 - && vis->blueBits == 8 && vis->alphaBits == 0) { - drb->Base.GetRow = tdfxReadRGBASpan_RGB888; - drb->Base.GetValues = tdfxReadRGBAPixels_RGB888; - drb->Base.PutRow = tdfxWriteRGBASpan_RGB888; - drb->Base.PutRowRGB = tdfxWriteRGBSpan_RGB888; - drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_RGB888; - drb->Base.PutValues = tdfxWriteRGBAPixels_RGB888; - drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_RGB888; - } - else if (vis->redBits == 8 && vis->greenBits == 8 - && vis->blueBits == 8 && vis->alphaBits == 8) { - drb->Base.GetRow = tdfxReadRGBASpan_ARGB8888; - drb->Base.GetValues = tdfxReadRGBAPixels_ARGB8888; - drb->Base.PutRow = tdfxWriteRGBASpan_ARGB8888; - drb->Base.PutRowRGB = tdfxWriteRGBSpan_ARGB8888; - drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_ARGB8888; - drb->Base.PutValues = tdfxWriteRGBAPixels_ARGB8888; - drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_ARGB8888; - } - else { - _mesa_problem(NULL, "problem in tdfxSetSpanFunctions"); - } - } - else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16 || - drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { - drb->Base.GetRow = tdfxDDReadDepthSpan; - drb->Base.GetValues = tdfxDDReadDepthPixels; - drb->Base.PutRow = tdfxDDWriteDepthSpan; - drb->Base.PutMonoRow = tdfxDDWriteMonoDepthSpan; - drb->Base.PutValues = tdfxDDWriteDepthPixels; - drb->Base.PutMonoValues = NULL; - } - else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { - drb->Base.GetRow = read_stencil_span; - drb->Base.GetValues = read_stencil_pixels; - drb->Base.PutRow = write_stencil_span; - drb->Base.PutMonoRow = write_mono_stencil_span; - drb->Base.PutValues = write_stencil_pixels; - drb->Base.PutMonoValues = NULL; - } -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h deleted file mode 100644 index 62044144f..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#ifndef __TDFX_SPAN_H__ -#define __TDFX_SPAN_H__ - -#include "context.h" -#include "drirenderbuffer.h" - -extern void tdfxDDInitSpanFuncs( GLcontext *ctx ); - -extern void -tdfxSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c deleted file mode 100644 index 85d99bb05..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c +++ /dev/null @@ -1,1449 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */ - -/* - * New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * Keith Whitwell (port to 3.5) - * - */ - -#include "mtypes.h" -#include "buffers.h" -#include "colormac.h" -#include "texformat.h" -#include "texstore.h" -#include "teximage.h" - -#include "swrast/swrast.h" -#include "array_cache/acache.h" -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" -#include "swrast_setup/swrast_setup.h" - -#include "tdfx_context.h" -#include "tdfx_state.h" -#include "tdfx_vb.h" -#include "tdfx_tex.h" -#include "tdfx_texman.h" -#include "tdfx_texstate.h" -#include "tdfx_tris.h" -#include "tdfx_render.h" - - - -/* ============================================================= - * Alpha blending - */ - -static void tdfxUpdateAlphaMode( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrCmpFnc_t func; - GrAlphaBlendFnc_t srcRGB, dstRGB, srcA, dstA; - GrAlphaBlendOp_t eqRGB, eqA; - GrAlpha_t ref = (GLint) (ctx->Color.AlphaRef * 255.0); - - GLboolean isNapalm = TDFX_IS_NAPALM(fxMesa); - GLboolean have32bpp = (ctx->Visual.greenBits == 8); - GLboolean haveAlpha = fxMesa->haveHwAlpha; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if ( ctx->Color.AlphaEnabled ) { - func = ctx->Color.AlphaFunc - GL_NEVER + GR_CMP_NEVER; - } else { - func = GR_CMP_ALWAYS; - } - - if ( ctx->Color.BlendEnabled - && (fxMesa->Fallback & TDFX_FALLBACK_BLEND) == 0 ) { - switch ( ctx->Color.BlendSrcRGB ) { - case GL_ZERO: - srcRGB = GR_BLEND_ZERO; - break; - case GL_ONE: - srcRGB = GR_BLEND_ONE; - break; - case GL_DST_COLOR: - srcRGB = GR_BLEND_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - srcRGB = GR_BLEND_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - srcRGB = GR_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - srcRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - srcRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - srcRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_SRC_ALPHA_SATURATE: - srcRGB = GR_BLEND_ALPHA_SATURATE; - break; - case GL_SRC_COLOR: - if (isNapalm) { - srcRGB = GR_BLEND_SAME_COLOR_EXT; - break; - } - case GL_ONE_MINUS_SRC_COLOR: - if (isNapalm) { - srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; - break; - } - default: - srcRGB = GR_BLEND_ONE; - } - - switch ( ctx->Color.BlendSrcA ) { - case GL_ZERO: - srcA = GR_BLEND_ZERO; - break; - case GL_ONE: - srcA = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - srcA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - srcA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_DST_COLOR: - case GL_DST_ALPHA: - srcA = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_COLOR: - case GL_ONE_MINUS_DST_ALPHA: - srcA = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_SRC_ALPHA_SATURATE: - srcA = GR_BLEND_ONE; - break; - default: - srcA = GR_BLEND_ONE; - } - - switch ( ctx->Color.BlendDstRGB ) { - case GL_ZERO: - dstRGB = GR_BLEND_ZERO; - break; - case GL_ONE: - dstRGB = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - dstRGB = GR_BLEND_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - dstRGB = GR_BLEND_ONE_MINUS_SRC_COLOR; - break; - case GL_SRC_ALPHA: - dstRGB = GR_BLEND_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dstRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - dstRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_ALPHA: - dstRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_DST_COLOR: - if (isNapalm) { - dstRGB = GR_BLEND_SAME_COLOR_EXT; - break; - } - case GL_ONE_MINUS_DST_COLOR: - if (isNapalm) { - dstRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT; - break; - } - default: - dstRGB = GR_BLEND_ZERO; - } - - switch ( ctx->Color.BlendDstA ) { - case GL_ZERO: - dstA = GR_BLEND_ZERO; - break; - case GL_ONE: - dstA = GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_SRC_ALPHA: - dstA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_ONE_MINUS_SRC_COLOR: - case GL_ONE_MINUS_SRC_ALPHA: - dstA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - case GL_DST_COLOR: - case GL_DST_ALPHA: - dstA = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/; - break; - case GL_ONE_MINUS_DST_COLOR: - case GL_ONE_MINUS_DST_ALPHA: - dstA = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/; - break; - default: - dstA = GR_BLEND_ZERO; - } - - switch ( ctx->Color.BlendEquationRGB ) { - case GL_FUNC_SUBTRACT: - eqRGB = GR_BLEND_OP_SUB; - break; - case GL_FUNC_REVERSE_SUBTRACT: - eqRGB = GR_BLEND_OP_REVSUB; - break; - case GL_FUNC_ADD: - default: - eqRGB = GR_BLEND_OP_ADD; - break; - } - - switch ( ctx->Color.BlendEquationA ) { - case GL_FUNC_SUBTRACT: - eqA = GR_BLEND_OP_SUB; - break; - case GL_FUNC_REVERSE_SUBTRACT: - eqA = GR_BLEND_OP_REVSUB; - break; - case GL_FUNC_ADD: - default: - eqA = GR_BLEND_OP_ADD; - break; - } - } else { - /* blend disabled */ - srcRGB = GR_BLEND_ONE; - dstRGB = GR_BLEND_ZERO; - eqRGB = GR_BLEND_OP_ADD; - srcA = GR_BLEND_ONE; - dstA = GR_BLEND_ZERO; - eqA = GR_BLEND_OP_ADD; - } - - if ( fxMesa->Color.AlphaFunc != func ) { - fxMesa->Color.AlphaFunc = func; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_TEST; - } - if ( fxMesa->Color.AlphaRef != ref ) { - fxMesa->Color.AlphaRef = ref; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_REF; - } - - if ( fxMesa->Color.BlendSrcRGB != srcRGB || - fxMesa->Color.BlendDstRGB != dstRGB || - fxMesa->Color.BlendEqRGB != eqRGB || - fxMesa->Color.BlendSrcA != srcA || - fxMesa->Color.BlendDstA != dstA || - fxMesa->Color.BlendEqA != eqA ) - { - fxMesa->Color.BlendSrcRGB = srcRGB; - fxMesa->Color.BlendDstRGB = dstRGB; - fxMesa->Color.BlendEqRGB = eqRGB; - fxMesa->Color.BlendSrcA = srcA; - fxMesa->Color.BlendDstA = dstA; - fxMesa->Color.BlendEqA = eqA; - fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC; - } -} - -static void tdfxDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; -} - -static void tdfxDDBlendEquationSeparate( GLcontext *ctx, - GLenum modeRGB, GLenum modeA ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - assert( modeRGB == modeA ); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; -} - -static void tdfxDDBlendFuncSeparate( GLcontext *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; - - /* - * XXX - Voodoo5 seems to suffer from precision problems in some - * blend modes. To pass all the conformance tests we'd have to - * fall back to software for many modes. Revisit someday. - */ -} - -/* ============================================================= - * Stipple - */ - -void tdfxUpdateStipple( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - GrStippleMode_t mode = GR_STIPPLE_DISABLE; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - FLUSH_BATCH( fxMesa ); - - if (ctx->Polygon.StippleFlag) { - mode = GR_STIPPLE_PATTERN; - } - - if ( fxMesa->Stipple.Mode != mode ) { - fxMesa->Stipple.Mode = mode; - fxMesa->dirty |= TDFX_UPLOAD_STIPPLE; - } -} - - -/* ============================================================= - * Depth testing - */ - -static void tdfxUpdateZMode( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - GrCmpFnc_t func; - FxI32 bias; - FxBool mask; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) - fprintf( stderr, "%s()\n", __FUNCTION__ ); - - - bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE); - - if ( ctx->Depth.Test ) { - func = ctx->Depth.Func - GL_NEVER + GR_CMP_NEVER; - mask = ctx->Depth.Mask; - } - else { - /* depth testing disabled */ - func = GR_CMP_ALWAYS; /* fragments always pass */ - mask = FXFALSE; /* zbuffer is not touched */ - } - - fxMesa->Depth.Clear = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear); - - if ( fxMesa->Depth.Bias != bias ) { - fxMesa->Depth.Bias = bias; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS; - } - if ( fxMesa->Depth.Func != func ) { - fxMesa->Depth.Func = func; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_FUNC | TDFX_UPLOAD_DEPTH_MASK; - } - if ( fxMesa->Depth.Mask != mask ) { - fxMesa->Depth.Mask = mask; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_MASK; - } -} - -static void tdfxDDDepthFunc( GLcontext *ctx, GLenum func ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; -} - -static void tdfxDDDepthMask( GLcontext *ctx, GLboolean flag ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; -} - -static void tdfxDDClearDepth( GLcontext *ctx, GLclampd d ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; -} - - - -/* ============================================================= - * Stencil - */ - - -/* Evaluate all stencil state and make the Glide calls. - */ -static GrStencil_t convertGLStencilOp( GLenum op ) -{ - switch ( op ) { - case GL_KEEP: - return GR_STENCILOP_KEEP; - case GL_ZERO: - return GR_STENCILOP_ZERO; - case GL_REPLACE: - return GR_STENCILOP_REPLACE; - case GL_INCR: - return GR_STENCILOP_INCR_CLAMP; - case GL_DECR: - return GR_STENCILOP_DECR_CLAMP; - case GL_INVERT: - return GR_STENCILOP_INVERT; - case GL_INCR_WRAP_EXT: - return GR_STENCILOP_INCR_WRAP; - case GL_DECR_WRAP_EXT: - return GR_STENCILOP_DECR_WRAP; - default: - _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" ); - } - return GR_STENCILOP_KEEP; /* never get, silence compiler warning */ -} - - -static void tdfxUpdateStencil( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if (fxMesa->haveHwStencil) { - if (ctx->Stencil.Enabled) { - fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER + GR_CMP_NEVER; - fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0]; - fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0]; - fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0]; - fxMesa->Stencil.FailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[0]); - fxMesa->Stencil.ZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[0]); - fxMesa->Stencil.ZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[0]); - fxMesa->Stencil.Clear = ctx->Stencil.Clear & 0xff; - } - fxMesa->dirty |= TDFX_UPLOAD_STENCIL; - } -} - - -static void tdfxDDStencilFunc( GLcontext *ctx, GLenum func, - GLint ref, GLuint mask ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_STENCIL; -} - -static void tdfxDDStencilMask( GLcontext *ctx, GLuint mask ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_STENCIL; -} - -static void tdfxDDStencilOp( GLcontext *ctx, GLenum sfail, - GLenum zfail, GLenum zpass ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_STENCIL; -} - - -/* ============================================================= - * Fog - orthographic fog still not working - */ - -static void tdfxUpdateFogAttrib( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrFogMode_t mode; - GrColor_t color; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if ( ctx->Fog.Enabled ) { - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) { - mode = GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT; - } else { - mode = GR_FOG_WITH_TABLE_ON_Q; - } - } else { - mode = GR_FOG_DISABLE; - } - - color = TDFXPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F), - (GLubyte)(ctx->Fog.Color[1]*255.0F), - (GLubyte)(ctx->Fog.Color[2]*255.0F)); - - if ( fxMesa->Fog.Mode != mode ) { - fxMesa->Fog.Mode = mode; - fxMesa->dirty |= TDFX_UPLOAD_FOG_MODE; - fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;/*JJJ*/ - } - if ( fxMesa->Fog.Color != color ) { - fxMesa->Fog.Color = color; - fxMesa->dirty |= TDFX_UPLOAD_FOG_COLOR; - } - if ( fxMesa->Fog.TableMode != ctx->Fog.Mode || - fxMesa->Fog.Density != ctx->Fog.Density || - fxMesa->Fog.Near != ctx->Fog.Start || - fxMesa->Fog.Far != ctx->Fog.End ) - { - switch( ctx->Fog.Mode ) { - case GL_EXP: - fxMesa->Glide.guFogGenerateExp( fxMesa->Fog.Table, ctx->Fog.Density ); - break; - case GL_EXP2: - fxMesa->Glide.guFogGenerateExp2( fxMesa->Fog.Table, ctx->Fog.Density); - break; - case GL_LINEAR: - fxMesa->Glide.guFogGenerateLinear( fxMesa->Fog.Table, - ctx->Fog.Start, ctx->Fog.End ); - break; - } - - fxMesa->Fog.TableMode = ctx->Fog.Mode; - fxMesa->Fog.Density = ctx->Fog.Density; - fxMesa->Fog.Near = ctx->Fog.Start; - fxMesa->Fog.Far = ctx->Fog.End; - fxMesa->dirty |= TDFX_UPLOAD_FOG_TABLE; - } -} - -static void tdfxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_FOG; - - switch (pname) { - case GL_FOG_COORDINATE_SOURCE_EXT: { - GLenum p = (GLenum)*param; - if (p == GL_FOG_COORDINATE_EXT) { - _swrast_allow_vertex_fog(ctx, GL_TRUE); - _swrast_allow_pixel_fog(ctx, GL_FALSE); - _tnl_allow_vertex_fog( ctx, GL_TRUE); - _tnl_allow_pixel_fog( ctx, GL_FALSE); - } else { - _swrast_allow_vertex_fog(ctx, GL_FALSE); - _swrast_allow_pixel_fog(ctx, GL_TRUE); - _tnl_allow_vertex_fog( ctx, GL_FALSE); - _tnl_allow_pixel_fog( ctx, GL_TRUE); - } - break; - } - default: - ; - } -} - - -/* ============================================================= - * Clipping - */ - -static int intersect_rect( drm_clip_rect_t *out, - const drm_clip_rect_t *a, - const drm_clip_rect_t *b) -{ - *out = *a; - if (b->x1 > out->x1) out->x1 = b->x1; - if (b->y1 > out->y1) out->y1 = b->y1; - if (b->x2 < out->x2) out->x2 = b->x2; - if (b->y2 < out->y2) out->y2 = b->y2; - if (out->x1 >= out->x2) return 0; - if (out->y1 >= out->y2) return 0; - return 1; -} - - -/* - * Examine XF86 cliprect list and scissor state to recompute our - * cliprect list. - */ -void tdfxUpdateClipping( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - assert(ctx); - assert(fxMesa); - assert(dPriv); - - if ( dPriv->x != fxMesa->x_offset || dPriv->y != fxMesa->y_offset || - dPriv->w != fxMesa->width || dPriv->h != fxMesa->height ) { - fxMesa->x_offset = dPriv->x; - fxMesa->y_offset = dPriv->y; - fxMesa->width = dPriv->w; - fxMesa->height = dPriv->h; - fxMesa->y_delta = - fxMesa->screen_height - fxMesa->y_offset - fxMesa->height; - tdfxUpdateViewport( ctx ); - } - - if (fxMesa->scissoredClipRects && fxMesa->pClipRects) { - free(fxMesa->pClipRects); - } - - if (ctx->Scissor.Enabled) { - /* intersect OpenGL scissor box with all cliprects to make a new - * list of cliprects. - */ - drm_clip_rect_t scissor; - int x1 = ctx->Scissor.X + fxMesa->x_offset; - int y1 = fxMesa->screen_height - fxMesa->y_delta - - ctx->Scissor.Y - ctx->Scissor.Height; - int x2 = x1 + ctx->Scissor.Width; - int y2 = y1 + ctx->Scissor.Height; - scissor.x1 = MAX2(x1, 0); - scissor.y1 = MAX2(y1, 0); - scissor.x2 = MAX2(x2, 0); - scissor.y2 = MAX2(y2, 0); - - assert(scissor.x2 >= scissor.x1); - assert(scissor.y2 >= scissor.y1); - - fxMesa->pClipRects = malloc(dPriv->numClipRects - * sizeof(drm_clip_rect_t)); - if (fxMesa->pClipRects) { - int i; - fxMesa->numClipRects = 0; - for (i = 0; i < dPriv->numClipRects; i++) { - if (intersect_rect(&fxMesa->pClipRects[fxMesa->numClipRects], - &scissor, &dPriv->pClipRects[i])) { - fxMesa->numClipRects++; - } - } - fxMesa->scissoredClipRects = GL_TRUE; - } - else { - /* out of memory, forgo scissor */ - fxMesa->numClipRects = dPriv->numClipRects; - fxMesa->pClipRects = dPriv->pClipRects; - fxMesa->scissoredClipRects = GL_FALSE; - } - } - else { - fxMesa->numClipRects = dPriv->numClipRects; - fxMesa->pClipRects = dPriv->pClipRects; - fxMesa->scissoredClipRects = GL_FALSE; - } - - fxMesa->dirty |= TDFX_UPLOAD_CLIP; -} - - - -/* ============================================================= - * Culling - */ - -void tdfxUpdateCull( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrCullMode_t mode = GR_CULL_DISABLE; - - /* KW: don't need to check raster_primitive here as we don't - * attempt to draw lines or points with triangles. - */ - if ( ctx->Polygon.CullFlag ) { - switch ( ctx->Polygon.CullFaceMode ) { - case GL_FRONT: - if ( ctx->Polygon.FrontFace == GL_CCW ) { - mode = GR_CULL_POSITIVE; - } else { - mode = GR_CULL_NEGATIVE; - } - break; - - case GL_BACK: - if ( ctx->Polygon.FrontFace == GL_CCW ) { - mode = GR_CULL_NEGATIVE; - } else { - mode = GR_CULL_POSITIVE; - } - break; - - case GL_FRONT_AND_BACK: - /* Handled as a fallback on triangles in tdfx_tris.c */ - return; - - default: - ASSERT(0); - break; - } - } - - if ( fxMesa->CullMode != mode ) { - fxMesa->CullMode = mode; - fxMesa->dirty |= TDFX_UPLOAD_CULL; - } -} - -static void tdfxDDCullFace( GLcontext *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CULL; -} - -static void tdfxDDFrontFace( GLcontext *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CULL; -} - - -/* ============================================================= - * Line drawing. - */ - -static void tdfxUpdateLine( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - FLUSH_BATCH( fxMesa ); - fxMesa->dirty |= TDFX_UPLOAD_LINE; -} - - -static void tdfxDDLineWidth( GLcontext *ctx, GLfloat width ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_LINE; -} - - -/* ============================================================= - * Color Attributes - */ - -static void tdfxDDColorMask( GLcontext *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FLUSH_BATCH( fxMesa ); - - if ( fxMesa->Color.ColorMask[RCOMP] != r || - fxMesa->Color.ColorMask[GCOMP] != g || - fxMesa->Color.ColorMask[BCOMP] != b || - fxMesa->Color.ColorMask[ACOMP] != a ) { - fxMesa->Color.ColorMask[RCOMP] = r; - fxMesa->Color.ColorMask[GCOMP] = g; - fxMesa->Color.ColorMask[BCOMP] = b; - fxMesa->Color.ColorMask[ACOMP] = a; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_MASK; - - if (ctx->Visual.redBits < 8) { - /* Can't do RGB colormasking in 16bpp mode. */ - /* We can completely ignore the alpha mask. */ - FALLBACK( fxMesa, TDFX_FALLBACK_COLORMASK, (r != g || g != b) ); - } - } -} - - -static void tdfxDDClearColor( GLcontext *ctx, - const GLfloat color[4] ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLubyte c[4]; - FLUSH_BATCH( fxMesa ); - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - fxMesa->Color.ClearColor = TDFXPACKCOLOR888( c[0], c[1], c[2] ); - fxMesa->Color.ClearAlpha = c[3]; -} - - -/* ============================================================= - * Light Model - */ - -static void tdfxDDLightModelfv( GLcontext *ctx, GLenum pname, - const GLfloat *param ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) { - FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR, - (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR )); - } -} - -static void tdfxDDShadeModel( GLcontext *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - /* FIXME: Can we implement native flat shading? */ - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -/* ============================================================= - * Scissor - */ - -static void -tdfxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CLIP; -} - -/* ============================================================= - * Render - */ - -static void tdfxUpdateRenderAttrib( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->dirty |= TDFX_UPLOAD_RENDER_BUFFER; -} - -/* ============================================================= - * Viewport - */ - -void tdfxUpdateViewport( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = fxMesa->hw_viewport; - - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX] + fxMesa->x_offset + TRI_X_OFFSET; - m[MAT_SY] = v[MAT_SY]; - m[MAT_TY] = v[MAT_TY] + fxMesa->y_delta + TRI_Y_OFFSET; - m[MAT_SZ] = v[MAT_SZ]; - m[MAT_TZ] = v[MAT_TZ]; - - fxMesa->SetupNewInputs |= VERT_BIT_POS; -} - - -static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y, - GLsizei w, GLsizei h ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - /* update size of Mesa/software ancillary buffers */ - _mesa_ResizeBuffersMESA(); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_VIEWPORT; -} - - -static void tdfxDDDepthRange( GLcontext *ctx, GLclampd nearVal, GLclampd farVal ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_VIEWPORT; -} - - -/* ============================================================= - * State enable/disable - */ - -static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - switch ( cap ) { - case GL_ALPHA_TEST: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; - break; - - case GL_BLEND: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_ALPHA; - FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)/*JJJ - more blending*/); - break; - - case GL_CULL_FACE: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CULL; - break; - - case GL_DEPTH_TEST: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_DEPTH; - break; - - case GL_DITHER: - FLUSH_BATCH( fxMesa ); - if ( state ) { - fxMesa->Color.Dither = GR_DITHER_2x2; - } else { - fxMesa->Color.Dither = GR_DITHER_DISABLE; - } - fxMesa->dirty |= TDFX_UPLOAD_DITHER; - break; - - case GL_FOG: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_FOG; - break; - - case GL_COLOR_LOGIC_OP: - FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP, - (ctx->Color.ColorLogicOpEnabled && - ctx->Color.LogicOp != GL_COPY)); - break; - - case GL_LIGHTING: - FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR, - (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR )); - break; - - case GL_LINE_SMOOTH: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_LINE; - break; - - case GL_LINE_STIPPLE: - FALLBACK(fxMesa, TDFX_FALLBACK_LINE_STIPPLE, state); - break; - - case GL_POLYGON_STIPPLE: - FLUSH_BATCH(fxMesa); - fxMesa->new_state |= TDFX_NEW_STIPPLE; - break; - - case GL_SCISSOR_TEST: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_CLIP; - break; - - case GL_STENCIL_TEST: - FLUSH_BATCH( fxMesa ); - FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil); - fxMesa->new_state |= TDFX_NEW_STENCIL; - break; - - case GL_TEXTURE_3D: - FLUSH_BATCH( fxMesa ); - FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_MAP, state); /* wrong */ - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - FLUSH_BATCH( fxMesa ); - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - default: - return; - } -} - - - -/* Set the buffer used for drawing */ -/* XXX support for separate read/draw buffers hasn't been tested */ -static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - FLUSH_BATCH( fxMesa ); - - /* - * _ColorDrawBufferMask is easier to cope with than . - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: - fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; - fxMesa->new_state |= TDFX_NEW_RENDER; - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - case BUFFER_BIT_BACK_LEFT: - fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; - fxMesa->new_state |= TDFX_NEW_RENDER; - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - case 0: - FX_grColorMaskv( ctx, false4 ); - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - default: - FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE ); - break; - } - - /* We want to update the s/w rast state too so that tdfxDDSetBuffer() - * gets called. - */ - _swrast_DrawBuffer(ctx, mode); -} - - -static void tdfxDDReadBuffer( GLcontext *ctx, GLenum mode ) -{ - /* XXX ??? */ -} - - -/* ============================================================= - * Polygon stipple - */ - -static void tdfxDDPolygonStipple( GLcontext *ctx, const GLubyte *mask ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - const GLubyte *m = mask; - GLubyte q[4]; - int i,j,k; - GLboolean allBitsSet; - -/* int active = (ctx->Polygon.StippleFlag && */ -/* fxMesa->reduced_prim == GL_TRIANGLES); */ - - FLUSH_BATCH(fxMesa); - fxMesa->Stipple.Pattern = 0xffffffff; - fxMesa->dirty |= TDFX_UPLOAD_STIPPLE; - fxMesa->new_state |= TDFX_NEW_STIPPLE; - - /* Check if the stipple pattern is fully opaque. If so, use software - * rendering. This basically a trick to make sure the OpenGL conformance - * test passes. - */ - allBitsSet = GL_TRUE; - for (i = 0; i < 32; i++) { - if (((GLuint *) mask)[i] != 0xffffffff) { - allBitsSet = GL_FALSE; - break; - } - } - if (allBitsSet) { - fxMesa->haveHwStipple = GL_FALSE; - return; - } - - q[0] = mask[0]; - q[1] = mask[4]; - q[2] = mask[8]; - q[3] = mask[12]; - - for (k = 0 ; k < 8 ; k++) - for (j = 0 ; j < 4; j++) - for (i = 0 ; i < 4 ; i++,m++) { - if (*m != q[j]) { - fxMesa->haveHwStipple = GL_FALSE; - return; - } - } - - fxMesa->haveHwStipple = GL_TRUE; - fxMesa->Stipple.Pattern = ( (q[0] << 0) | - (q[1] << 8) | - (q[2] << 16) | - (q[3] << 24) ); -} - - - -static void tdfxDDRenderMode( GLcontext *ctx, GLenum mode ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - FALLBACK( fxMesa, TDFX_FALLBACK_RENDER_MODE, (mode != GL_RENDER) ); -} - - - -static void tdfxDDPrintState( const char *msg, GLuint flags ) -{ - fprintf( stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n", - msg, - flags, - (flags & TDFX_NEW_COLOR) ? "color, " : "", - (flags & TDFX_NEW_ALPHA) ? "alpha, " : "", - (flags & TDFX_NEW_DEPTH) ? "depth, " : "", - (flags & TDFX_NEW_RENDER) ? "render, " : "", - (flags & TDFX_NEW_FOG) ? "fog, " : "", - (flags & TDFX_NEW_STENCIL) ? "stencil, " : "", - (flags & TDFX_NEW_STIPPLE) ? "stipple, " : "", - (flags & TDFX_NEW_CLIP) ? "clip, " : "", - (flags & TDFX_NEW_VIEWPORT) ? "viewport, " : "", - (flags & TDFX_NEW_CULL) ? "cull, " : "", - (flags & TDFX_NEW_GLIDE) ? "glide, " : "", - (flags & TDFX_NEW_TEXTURE) ? "texture, " : "", - (flags & TDFX_NEW_CONTEXT) ? "context, " : ""); -} - - - -void tdfxDDUpdateHwState( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - int new_state = fxMesa->new_state; - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - fprintf( stderr, "%s()\n", __FUNCTION__ ); - } - - if ( new_state ) - { - FLUSH_BATCH( fxMesa ); - - fxMesa->new_state = 0; - - if ( 0 ) - tdfxDDPrintState( "tdfxUpdateHwState", new_state ); - - /* Update the various parts of the context's state. - */ - if ( new_state & TDFX_NEW_ALPHA ) { - tdfxUpdateAlphaMode( ctx ); - } - - if ( new_state & TDFX_NEW_DEPTH ) - tdfxUpdateZMode( ctx ); - - if ( new_state & TDFX_NEW_FOG ) - tdfxUpdateFogAttrib( ctx ); - - if ( new_state & TDFX_NEW_CLIP ) - tdfxUpdateClipping( ctx ); - - if ( new_state & TDFX_NEW_STIPPLE ) - tdfxUpdateStipple( ctx ); - - if ( new_state & TDFX_NEW_CULL ) - tdfxUpdateCull( ctx ); - - if ( new_state & TDFX_NEW_LINE ) - tdfxUpdateLine( ctx ); - - if ( new_state & TDFX_NEW_VIEWPORT ) - tdfxUpdateViewport( ctx ); - - if ( new_state & TDFX_NEW_RENDER ) - tdfxUpdateRenderAttrib( ctx ); - - if ( new_state & TDFX_NEW_STENCIL ) - tdfxUpdateStencil( ctx ); - - if ( new_state & TDFX_NEW_TEXTURE ) { - tdfxUpdateTextureState( ctx ); - } - else if ( new_state & TDFX_NEW_TEXTURE_BIND ) { - tdfxUpdateTextureBinding( ctx ); - } - } - - if ( 0 ) { - FxI32 bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE); - - if ( fxMesa->Depth.Bias != bias ) { - fxMesa->Depth.Bias = bias; - fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS; - } - } - - if ( fxMesa->dirty ) { - LOCK_HARDWARE( fxMesa ); - tdfxEmitHwStateLocked( fxMesa ); - UNLOCK_HARDWARE( fxMesa ); - } -} - - -static void tdfxDDInvalidateState( GLcontext *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _ac_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - TDFX_CONTEXT(ctx)->new_gl_state |= new_state; -} - - - -/* Initialize the context's Glide state mirror. These values will be - * used as Glide function call parameters when the time comes. - */ -void tdfxInitState( tdfxContextPtr fxMesa ) -{ - GLcontext *ctx = fxMesa->glCtx; - GLint i; - - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - - fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB; - fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertC = FXTRUE; - fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertD = FXFALSE; - fxMesa->ColorCombineExt.Shift = 0; - fxMesa->ColorCombineExt.Invert = FXFALSE; - fxMesa->AlphaCombineExt.SourceA = GR_CMBX_ITALPHA; - fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertC = FXTRUE; - fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertD = FXFALSE; - fxMesa->AlphaCombineExt.Shift = 0; - fxMesa->AlphaCombineExt.Invert = FXFALSE; - - fxMesa->sScale0 = fxMesa->tScale0 = 1.0; - fxMesa->sScale1 = fxMesa->tScale1 = 1.0; - - fxMesa->TexPalette.Type = 0; - fxMesa->TexPalette.Data = NULL; - - for ( i = 0 ; i < TDFX_NUM_TMU ; i++ ) { - fxMesa->TexSource[i].StartAddress = 0; - fxMesa->TexSource[i].EvenOdd = GR_MIPMAPLEVELMASK_EVEN; - fxMesa->TexSource[i].Info = NULL; - - fxMesa->TexCombine[i].FunctionRGB = 0; - fxMesa->TexCombine[i].FactorRGB = 0; - fxMesa->TexCombine[i].FunctionAlpha = 0; - fxMesa->TexCombine[i].FactorAlpha = 0; - fxMesa->TexCombine[i].InvertRGB = FXFALSE; - fxMesa->TexCombine[i].InvertAlpha = FXFALSE; - - fxMesa->TexCombineExt[i].Alpha.SourceA = 0; - /* XXX more state to init here */ - fxMesa->TexCombineExt[i].Color.SourceA = 0; - fxMesa->TexCombineExt[i].EnvColor = 0x0; - - fxMesa->TexParams[i].sClamp = GR_TEXTURECLAMP_WRAP; - fxMesa->TexParams[i].tClamp = GR_TEXTURECLAMP_WRAP; - fxMesa->TexParams[i].minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - fxMesa->TexParams[i].magFilt = GR_TEXTUREFILTER_BILINEAR; - fxMesa->TexParams[i].mmMode = GR_MIPMAP_DISABLE; - fxMesa->TexParams[i].LODblend = FXFALSE; - fxMesa->TexParams[i].LodBias = 0.0; - - fxMesa->TexState.EnvMode[i] = ~0; - fxMesa->TexState.TexFormat[i] = ~0; - fxMesa->TexState.Enabled[i] = 0; - } - - if ( ctx->Visual.doubleBufferMode) { - fxMesa->DrawBuffer = GR_BUFFER_BACKBUFFER; - fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; - } else { - fxMesa->DrawBuffer = GR_BUFFER_FRONTBUFFER; - fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; - } - - fxMesa->Color.ClearColor = 0x00000000; - fxMesa->Color.ClearAlpha = 0x00; - fxMesa->Color.ColorMask[RCOMP] = FXTRUE; - fxMesa->Color.ColorMask[BCOMP] = FXTRUE; - fxMesa->Color.ColorMask[GCOMP] = FXTRUE; - fxMesa->Color.ColorMask[ACOMP] = FXTRUE; - fxMesa->Color.MonoColor = 0xffffffff; - - fxMesa->Color.AlphaFunc = GR_CMP_ALWAYS; - fxMesa->Color.AlphaRef = 0x00; - fxMesa->Color.BlendSrcRGB = GR_BLEND_ONE; - fxMesa->Color.BlendDstRGB = GR_BLEND_ZERO; - fxMesa->Color.BlendSrcA = GR_BLEND_ONE; - fxMesa->Color.BlendSrcA = GR_BLEND_ZERO; - - fxMesa->Color.Dither = GR_DITHER_2x2; - - if ( fxMesa->glCtx->Visual.depthBits > 0 ) { - fxMesa->Depth.Mode = GR_DEPTHBUFFER_ZBUFFER; - } else { - fxMesa->Depth.Mode = GR_DEPTHBUFFER_DISABLE; - } - fxMesa->Depth.Bias = 0; - fxMesa->Depth.Func = GR_CMP_LESS; - fxMesa->Depth.Clear = 0; /* computed later */ - fxMesa->Depth.Mask = FXTRUE; - - - fxMesa->Fog.Mode = GR_FOG_DISABLE; - fxMesa->Fog.Color = 0x00000000; - fxMesa->Fog.Table = NULL; - fxMesa->Fog.Density = 1.0; - fxMesa->Fog.Near = 1.0; - fxMesa->Fog.Far = 1.0; - - fxMesa->Stencil.Function = GR_CMP_ALWAYS; - fxMesa->Stencil.RefValue = 0; - fxMesa->Stencil.ValueMask = 0xff; - fxMesa->Stencil.WriteMask = 0xff; - fxMesa->Stencil.FailFunc = 0; - fxMesa->Stencil.ZFailFunc = 0; - fxMesa->Stencil.ZPassFunc = 0; - fxMesa->Stencil.Clear = 0; - - fxMesa->Stipple.Mode = GR_STIPPLE_DISABLE; - fxMesa->Stipple.Pattern = 0xffffffff; - - fxMesa->Scissor.minX = 0; - fxMesa->Scissor.minY = 0; - fxMesa->Scissor.maxX = 0; - fxMesa->Scissor.maxY = 0; - - fxMesa->Viewport.Mode = GR_WINDOW_COORDS; - fxMesa->Viewport.X = 0; - fxMesa->Viewport.Y = 0; - fxMesa->Viewport.Width = 0; - fxMesa->Viewport.Height = 0; - fxMesa->Viewport.Near = 0.0; - fxMesa->Viewport.Far = 0.0; - - fxMesa->CullMode = GR_CULL_DISABLE; - - fxMesa->Glide.ColorFormat = GR_COLORFORMAT_ABGR; - fxMesa->Glide.Origin = GR_ORIGIN_LOWER_LEFT; - fxMesa->Glide.Initialized = FXFALSE; -} - - - -void tdfxDDInitStateFuncs( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - ctx->Driver.UpdateState = tdfxDDInvalidateState; - - - /* State notification callbacks: - */ - ctx->Driver.ClearColor = tdfxDDClearColor; - ctx->Driver.DrawBuffer = tdfxDDDrawBuffer; - ctx->Driver.ReadBuffer = tdfxDDReadBuffer; - - ctx->Driver.ColorMask = tdfxDDColorMask; - - ctx->Driver.AlphaFunc = tdfxDDAlphaFunc; - ctx->Driver.BlendEquationSeparate = tdfxDDBlendEquationSeparate; - ctx->Driver.BlendFuncSeparate = tdfxDDBlendFuncSeparate; - ctx->Driver.ClearDepth = tdfxDDClearDepth; - ctx->Driver.CullFace = tdfxDDCullFace; - ctx->Driver.FrontFace = tdfxDDFrontFace; - ctx->Driver.DepthFunc = tdfxDDDepthFunc; - ctx->Driver.DepthMask = tdfxDDDepthMask; - ctx->Driver.DepthRange = tdfxDDDepthRange; - ctx->Driver.Enable = tdfxDDEnable; - ctx->Driver.Fogfv = tdfxDDFogfv; - ctx->Driver.LightModelfv = tdfxDDLightModelfv; - ctx->Driver.LineWidth = tdfxDDLineWidth; - ctx->Driver.PolygonStipple = tdfxDDPolygonStipple; - ctx->Driver.RenderMode = tdfxDDRenderMode; - ctx->Driver.Scissor = tdfxDDScissor; - ctx->Driver.ShadeModel = tdfxDDShadeModel; - - if ( fxMesa->haveHwStencil ) { - ctx->Driver.StencilFunc = tdfxDDStencilFunc; - ctx->Driver.StencilMask = tdfxDDStencilMask; - ctx->Driver.StencilOp = tdfxDDStencilOp; - } - - ctx->Driver.Viewport = tdfxDDViewport; - - /* Swrast hooks for imaging extensions: - */ - ctx->Driver.CopyColorTable = _swrast_CopyColorTable; - ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; - ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; - ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h deleted file mode 100644 index b10c38f59..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#ifndef __TDFX_STATE_H__ -#define __TDFX_STATE_H__ - -#include "context.h" -#include "tdfx_context.h" - -extern void tdfxDDInitStateFuncs( GLcontext *ctx ); - -extern void tdfxDDUpdateHwState( GLcontext *ctx ); - -extern void tdfxInitState( tdfxContextPtr fxMesa ); - -extern void tdfxUpdateClipping( GLcontext *ctx ); - - -extern void tdfxFallback( GLcontext *ctx, GLuint bit, GLboolean mode ); -#define FALLBACK( rmesa, bit, mode ) tdfxFallback( rmesa->glCtx, bit, mode ) - -extern void tdfxUpdateCull( GLcontext *ctx ); -extern void tdfxUpdateStipple( GLcontext *ctx ); -extern void tdfxUpdateViewport( GLcontext *ctx ); - - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c deleted file mode 100644 index cf4de23b3..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c +++ /dev/null @@ -1,1914 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c,v 1.7 2002/11/05 17:46:10 tsi Exp $ */ - -/* - * New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - - -#include "enums.h" -#include "image.h" -#include "texcompress.h" -#include "texformat.h" -#include "teximage.h" -#include "texstore.h" -#include "texobj.h" -#include "tdfx_context.h" -#include "tdfx_tex.h" -#include "tdfx_texman.h" - - -/* no borders! can't halve 1x1! (stride > width * comp) not allowed */ -void -_mesa_halve2x2_teximage2d ( GLcontext *ctx, - struct gl_texture_image *texImage, - GLuint bytesPerPixel, - GLint srcWidth, GLint srcHeight, - const GLvoid *srcImage, GLvoid *dstImage ) -{ - GLint i, j, k; - GLint dstWidth = srcWidth / 2; - GLint dstHeight = srcHeight / 2; - GLint srcRowStride = srcWidth * bytesPerPixel; - GLubyte *src = (GLubyte *)srcImage; - GLubyte *dst = dstImage; - - GLuint bpt = 0; - GLubyte *_s = NULL; - GLubyte *_d = NULL; - GLenum _t = 0; - - if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) { - _t = GL_UNSIGNED_SHORT_5_6_5_REV; - bpt = bytesPerPixel; - } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) { - _t = GL_UNSIGNED_SHORT_4_4_4_4_REV; - bpt = bytesPerPixel; - } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) { - _t = GL_UNSIGNED_SHORT_1_5_5_5_REV; - bpt = bytesPerPixel; - } - if (bpt) { - bytesPerPixel = 4; - srcRowStride = srcWidth * bytesPerPixel; - if (dstWidth == 0) { - dstWidth = 1; - } - if (dstHeight == 0) { - dstHeight = 1; - } - _s = src = MALLOC(srcRowStride * srcHeight); - _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight); - _mesa_texstore_rgba8888(ctx, 2, GL_RGBA, - &_mesa_texformat_rgba8888_rev, src, - 0, 0, 0, /* dstX/Y/Zoffset */ - srcRowStride, /* dstRowStride */ - 0, /* dstImageStride */ - srcWidth, srcHeight, 1, - texImage->Format, _t, srcImage, &ctx->DefaultPacking); - } - - if (srcHeight == 1) { - for (i = 0; i < dstWidth; i++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + src[bytesPerPixel] + 1) / 2; - src++; - dst++; - } - src += bytesPerPixel; - } - } else if (srcWidth == 1) { - for (j = 0; j < dstHeight; j++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + src[srcRowStride] + 1) / 2; - src++; - dst++; - } - src += srcRowStride; - } - } else { - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - for (k = 0; k < bytesPerPixel; k++) { - dst[0] = (src[0] + - src[bytesPerPixel] + - src[srcRowStride] + - src[srcRowStride + bytesPerPixel] + 2) / 4; - src++; - dst++; - } - src += bytesPerPixel; - } - src += srcRowStride; - } - } - - if (bpt) { - src = _s; - dst = _d; - texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, - texImage->TexFormat, dstImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstWidth * bpt, - 0, /* dstImageStride */ - dstWidth, dstHeight, 1, - GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking); - FREE(dst); - FREE(src); - } -} - - -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; - } -} - - -/* - * Compute various texture image parameters. - * Input: w, h - source texture width and height - * Output: lodlevel - Glide lod level token for the larger texture dimension - * aspectratio - Glide aspect ratio token - * sscale - S scale factor used during triangle setup - * tscale - T scale factor used during triangle setup - * wscale - OpenGL -> Glide image width scale factor - * hscale - OpenGL -> Glide image height scale factor - * - * Sample results: - * w h lodlevel aspectRatio - * 128 128 GR_LOD_LOG2_128 (=7) GR_ASPECT_LOG2_1x1 (=0) - * 64 64 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_1x1 (=0) - * 64 32 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_2x1 (=1) - * 32 64 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_1x2 (=-1) - * 32 32 GR_LOD_LOG2_32 (=5) GR_ASPECT_LOG2_1x1 (=0) - */ -static void -tdfxTexGetInfo(const GLcontext *ctx, int w, int h, - GrLOD_t *lodlevel, GrAspectRatio_t *aspectratio, - float *sscale, float *tscale, - int *wscale, int *hscale) -{ - int logw, logh, ar, lod, ws, hs; - float s, t; - - ASSERT(w >= 1); - ASSERT(h >= 1); - - logw = logbase2(w); - logh = logbase2(h); - ar = logw - logh; /* aspect ratio = difference in log dimensions */ - s = t = 256.0; - ws = hs = 1; - - /* 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) { - ASSERT(w >= h); - lod = logw; - if (ar <= GR_ASPECT_LOG2_8x1) { - t = 256 >> ar; - } - else { - /* have to stretch image height */ - t = 32.0; - hs = 1 << (ar - 3); - ar = GR_ASPECT_LOG2_8x1; - } - } - else { - ASSERT(w < h); - lod = logh; - if (ar >= GR_ASPECT_LOG2_1x8) { - s = 256 >> -ar; - } - else { - /* have to stretch image width */ - s = 32.0; - ws = 1 << (-ar - 3); - ar = GR_ASPECT_LOG2_1x8; - } - } - - if (lodlevel) - *lodlevel = (GrLOD_t) lod; - if (aspectratio) - *aspectratio = (GrAspectRatio_t) ar; - if (sscale) - *sscale = s; - if (tscale) - *tscale = t; - if (wscale) - *wscale = ws; - if (hscale) - *hscale = hs; -} - - -/* - * We need to call this when a texture object's minification filter - * or texture image sizes change. - */ -static void RevalidateTexture(GLcontext *ctx, struct gl_texture_object *tObj) -{ - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - GLint minl, maxl; - - if (!ti) - return; - - minl = maxl = tObj->BaseLevel; - - if (tObj->Image[0][minl]) { - maxl = MIN2(tObj->MaxLevel, tObj->Image[0][minl]->MaxLog2); - - /* compute largeLodLog2, aspect ratio and texcoord scale factors */ - tdfxTexGetInfo(ctx, tObj->Image[0][minl]->Width, tObj->Image[0][minl]->Height, - &ti->info.largeLodLog2, - &ti->info.aspectRatioLog2, - &(ti->sScale), &(ti->tScale), NULL, NULL); - } - - if (tObj->Image[0][maxl] && (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) { - /* mipmapping: need to compute smallLodLog2 */ - tdfxTexGetInfo(ctx, tObj->Image[0][maxl]->Width, - tObj->Image[0][maxl]->Height, - &ti->info.smallLodLog2, NULL, - NULL, NULL, NULL, NULL); - } - else { - /* not mipmapping: smallLodLog2 = largeLodLog2 */ - ti->info.smallLodLog2 = ti->info.largeLodLog2; - maxl = minl; - } - - ti->minLevel = minl; - ti->maxLevel = maxl; - ti->info.data = NULL; - - /* this is necessary because of fxDDCompressedTexImage2D */ - if (ti->padded) { - struct gl_texture_image *texImage = tObj->Image[0][minl]; - tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - if (mml->wScale != 1 || mml->hScale != 1) { - ti->sScale /= mml->wScale; - ti->tScale /= mml->hScale; - } - } -} - - -static tdfxTexInfo * -fxAllocTexObjData(tdfxContextPtr fxMesa) -{ - tdfxTexInfo *ti; - - if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) { - _mesa_problem(NULL, "tdfx driver: out of memory"); - return NULL; - } - - ti->isInTM = GL_FALSE; - - ti->whichTMU = TDFX_TMU_NONE; - - ti->tm[TDFX_TMU0] = NULL; - ti->tm[TDFX_TMU1] = NULL; - - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - ti->magFilt = GR_TEXTUREFILTER_BILINEAR; - - ti->sClamp = GR_TEXTURECLAMP_WRAP; - ti->tClamp = GR_TEXTURECLAMP_WRAP; - - ti->mmMode = GR_MIPMAP_NEAREST; - ti->LODblend = FXFALSE; - - return ti; -} - - -/* - * Called via glBindTexture. - */ -static void -tdfxBindTexture(GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "fxmesa: fxDDTexBind(%d,%p)\n", tObj->Name, - tObj->DriverData); - } - - if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) - return; - - if (!tObj->DriverData) { - tObj->DriverData = fxAllocTexObjData(fxMesa); - } - - ti = TDFX_TEXTURE_DATA(tObj); - ti->lastTimeUsed = fxMesa->texBindNumber++; - - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -/* - * Called via glTexEnv. - */ -static void -tdfxTexEnv(GLcontext * ctx, GLenum target, GLenum pname, - const GLfloat * param) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { - if (param) - fprintf(stderr, "fxmesa: texenv(%x,%x)\n", pname, - (GLint) (*param)); - else - fprintf(stderr, "fxmesa: texenv(%x)\n", pname); - } - - /* XXX this is a bit of a hack to force the Glide texture - * state to be updated. - */ - fxMesa->TexState.EnvMode[ctx->Texture.CurrentUnit] = 0; - - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -/* - * Called via glTexParameter. - */ -static void -tdfxTexParameter(GLcontext * ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat * params) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLenum param = (GLenum) (GLint) params[0]; - tdfxTexInfo *ti; - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "fxmesa: fxDDTexParam(%d,%p,%x,%x)\n", tObj->Name, - tObj->DriverData, pname, param); - } - - if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D)) - return; - - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - - ti = TDFX_TEXTURE_DATA(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_LINEAR: - if (!fxMesa->Glide.HaveCombineExt) { - 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; - } - /* XXX Voodoo3/Banshee mipmap blending seems to produce - * incorrectly filtered colors for the smallest mipmap levels. - * To work-around we fall-through here and use a different filter. - */ - case GL_NEAREST_MIPMAP_NEAREST: - ti->mmMode = GR_MIPMAP_NEAREST; - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - ti->LODblend = FXFALSE; - break; - case GL_LINEAR_MIPMAP_LINEAR: - if (!fxMesa->Glide.HaveCombineExt) { - 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; - } - /* XXX Voodoo3/Banshee mipmap blending seems to produce - * incorrectly filtered colors for the smallest mipmap levels. - * To work-around we fall-through here and use a different filter. - */ - case GL_LINEAR_MIPMAP_NEAREST: - ti->mmMode = GR_MIPMAP_NEAREST; - ti->minFilt = GR_TEXTUREFILTER_BILINEAR; - ti->LODblend = FXFALSE; - break; - default: - break; - } - ti->reloadImages = GL_TRUE; - RevalidateTexture(ctx, tObj); - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - case GL_TEXTURE_MAG_FILTER: - switch (param) { - case GL_NEAREST: - ti->magFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - break; - case GL_LINEAR: - ti->magFilt = GR_TEXTUREFILTER_BILINEAR; - break; - default: - break; - } - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - case GL_TEXTURE_WRAP_S: - switch (param) { - case GL_CLAMP_TO_BORDER: - case GL_CLAMP_TO_EDGE: - case GL_CLAMP: - ti->sClamp = GR_TEXTURECLAMP_CLAMP; - break; - case GL_REPEAT: - ti->sClamp = GR_TEXTURECLAMP_WRAP; - break; - case GL_MIRRORED_REPEAT: - ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT; - break; - default: - break; - } - fxMesa->new_state |= TDFX_NEW_TEXTURE; - break; - - case GL_TEXTURE_WRAP_T: - switch (param) { - case GL_CLAMP_TO_BORDER: - case GL_CLAMP_TO_EDGE: - case GL_CLAMP: - ti->tClamp = GR_TEXTURECLAMP_CLAMP; - break; - case GL_REPEAT: - ti->tClamp = GR_TEXTURECLAMP_WRAP; - break; - case GL_MIRRORED_REPEAT: - ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT; - break; - default: - break; - } - fxMesa->new_state |= TDFX_NEW_TEXTURE; - 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: - RevalidateTexture(ctx, tObj); - break; - case GL_TEXTURE_MAX_LEVEL: - RevalidateTexture(ctx, tObj); - break; - - default: - break; - } -} - - -/* - * Called via glDeleteTextures to delete a texture object. - * Here, we delete the Glide data associated with the texture. - */ -static void -tdfxDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj) -{ - if (ctx && ctx->DriverCtx) { - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTMFreeTexture(fxMesa, tObj); - fxMesa->new_state |= TDFX_NEW_TEXTURE; - /* Free mipmap images and the texture object itself */ - _mesa_delete_texture_object(ctx, tObj); - } -} - - -/* - * Return true if texture is resident, false otherwise. - */ -static GLboolean -tdfxIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj) -{ - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - return (GLboolean) (ti && ti->isInTM); -} - - - -/* - * Convert a gl_color_table texture palette to Glide's format. - */ -static GrTexTable_t -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->Type == 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - 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; - } - return GR_TEXTABLE_PALETTE; - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - 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; - } - return GR_TEXTABLE_PALETTE; - 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; - } - return GR_TEXTABLE_PALETTE_6666_EXT; - default: - /* XXX fixme: how can this happen? */ - _mesa_error(NULL, GL_INVALID_ENUM, "convertPalette: table->Format == %s", - _mesa_lookup_enum_by_nr(table->Format)); - return GR_TEXTABLE_PALETTE; - } -} - - - -static void -tdfxUpdateTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (tObj) { - /* per-texture palette */ - tdfxTexInfo *ti; - - /* This might be a proxy texture. */ - if (!tObj->Palette.Table) - return; - - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = TDFX_TEXTURE_DATA(tObj); - assert(ti); - ti->paltype = convertPalette(ti->palette.data, &tObj->Palette); - /*tdfxTexInvalidate(ctx, tObj);*/ - } - else { - /* global texture palette */ - fxMesa->TexPalette.Type = convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette); - fxMesa->TexPalette.Data = &(fxMesa->glbPalette.data); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX too heavy-handed */ -} - - -/**********************************************************************/ -/**** NEW TEXTURE IMAGE FUNCTIONS ****/ -/**********************************************************************/ - -#if 000 -static FxBool TexusFatalError = FXFALSE; -static FxBool TexusError = FXFALSE; - -#define TX_DITHER_NONE 0x00000000 - -static void -fxTexusError(const char *string, FxBool fatal) -{ - _mesa_problem(NULL, string); - /* - * Just propagate the fatal value up. - */ - TexusError = FXTRUE; - TexusFatalError = fatal; -} -#endif - - -static const struct gl_texture_format * -tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - const GLboolean allow32bpt = TDFX_IS_NAPALM(fxMesa); - - switch (internalFormat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COMPRESSED_ALPHA: - return &_mesa_texformat_a8; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_COMPRESSED_LUMINANCE: - return &_mesa_texformat_l8; - 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: - case GL_COMPRESSED_LUMINANCE_ALPHA: - return &_mesa_texformat_al88; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_COMPRESSED_INTENSITY: - return &_mesa_texformat_i8; - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - return &_mesa_texformat_rgb565; - case GL_COMPRESSED_RGB: - /* intentional fall-through */ - case 3: - case GL_RGB: - if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) { - return &_mesa_texformat_rgb565; - } - /* intentional fall through */ - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return (allow32bpt) ? &_mesa_texformat_argb8888 - : &_mesa_texformat_rgb565; - case GL_RGBA2: - case GL_RGBA4: - return &_mesa_texformat_argb4444; - case GL_COMPRESSED_RGBA: - /* intentional fall-through */ - case 4: - case GL_RGBA: - if ( srcFormat == GL_BGRA ) { - if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) { - return &_mesa_texformat_argb8888; - } - else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) { - return &_mesa_texformat_argb4444; - } - else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) { - return &_mesa_texformat_argb1555; - } - } - /* intentional fall through */ - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return allow32bpt ? &_mesa_texformat_argb8888 - : &_mesa_texformat_argb4444; - case GL_RGB5_A1: - return &_mesa_texformat_argb1555; - 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: - return &_mesa_texformat_ci8; - /* GL_EXT_texture_compression_s3tc */ - /* GL_S3_s3tc */ - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - return &_mesa_texformat_rgb_dxt1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return &_mesa_texformat_rgba_dxt1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return &_mesa_texformat_rgba_dxt3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return &_mesa_texformat_rgba_dxt5; - /* GL_3DFX_texture_compression_FXT1 */ - case GL_COMPRESSED_RGB_FXT1_3DFX: - return &_mesa_texformat_rgb_fxt1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return &_mesa_texformat_rgba_fxt1; - default: - _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat"); - return NULL; - } -} - - -/* - * Return the Glide format for the given mesa texture format. - */ -static GrTextureFormat_t -fxGlideFormat(GLint mesaFormat) -{ - switch (mesaFormat) { - case MESA_FORMAT_I8: - return GR_TEXFMT_ALPHA_8; - case MESA_FORMAT_A8: - return GR_TEXFMT_ALPHA_8; - case MESA_FORMAT_L8: - return GR_TEXFMT_INTENSITY_8; - case MESA_FORMAT_CI8: - return GR_TEXFMT_P_8; - case MESA_FORMAT_AL88: - return GR_TEXFMT_ALPHA_INTENSITY_88; - case MESA_FORMAT_RGB565: - return GR_TEXFMT_RGB_565; - case MESA_FORMAT_ARGB4444: - return GR_TEXFMT_ARGB_4444; - case MESA_FORMAT_ARGB1555: - return GR_TEXFMT_ARGB_1555; - case MESA_FORMAT_ARGB8888: - return GR_TEXFMT_ARGB_8888; - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - return GR_TEXFMT_ARGB_CMP_FXT1; - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - return GR_TEXFMT_ARGB_CMP_DXT1; - case MESA_FORMAT_RGBA_DXT3: - return GR_TEXFMT_ARGB_CMP_DXT3; - case MESA_FORMAT_RGBA_DXT5: - return GR_TEXFMT_ARGB_CMP_DXT5; - default: - _mesa_problem(NULL, "Unexpected format in fxGlideFormat"); - return 0; - } -} - - -/* Texel-fetch functions for software texturing and glGetTexImage(). - * We should have been able to use some "standard" fetch functions (which - * may get defined in texutil.c) but we have to account for scaled texture - * images on tdfx hardware (the 8:1 aspect ratio limit). - * Hence, we need special functions here. - */ -extern void -fxt1_decode_1 (const void *texture, int width, - int i, int j, unsigned char *rgba); - -static void -fetch_intensity8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = *texel; - rgba[GCOMP] = *texel; - rgba[BCOMP] = *texel; - rgba[ACOMP] = *texel; -} - - -static void -fetch_luminance8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = *texel; - rgba[GCOMP] = *texel; - rgba[BCOMP] = *texel; - rgba[ACOMP] = 255; -} - - -static void -fetch_alpha8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = 255; - rgba[GCOMP] = 255; - rgba[BCOMP] = 255; - rgba[ACOMP] = *texel; -} - - -static void -fetch_index8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * indexOut) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + j * mml->width + i; - *indexOut = *texel; -} - - -static void -fetch_luminance8_alpha8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLubyte *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[0]; - rgba[BCOMP] = texel[0]; - rgba[ACOMP] = texel[1]; -} - - -static void -fetch_r5g6b5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLushort *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLushort *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31; - rgba[GCOMP] = (((*texel) >> 5) & 0x3f) * 255 / 63; - rgba[BCOMP] = (((*texel) >> 0) & 0x1f) * 255 / 31; - rgba[ACOMP] = 255; -} - - -static void -fetch_r4g4b4a4(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLushort *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLushort *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = (((*texel) >> 12) & 0xf) * 255 / 15; - rgba[GCOMP] = (((*texel) >> 8) & 0xf) * 255 / 15; - rgba[BCOMP] = (((*texel) >> 4) & 0xf) * 255 / 15; - rgba[ACOMP] = (((*texel) >> 0) & 0xf) * 255 / 15; -} - - -static void -fetch_r5g5b5a1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLushort *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLushort *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31; - rgba[GCOMP] = (((*texel) >> 6) & 0x1f) * 255 / 31; - rgba[BCOMP] = (((*texel) >> 1) & 0x1f) * 255 / 31; - rgba[ACOMP] = (((*texel) >> 0) & 0x01) * 255; -} - - -static void -fetch_a8r8g8b8(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan * rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - const GLuint *texel; - - i = i * mml->wScale; - j = j * mml->hScale; - - texel = ((GLuint *) texImage->Data) + j * mml->width + i; - rgba[RCOMP] = (((*texel) >> 16) & 0xff); - rgba[GCOMP] = (((*texel) >> 8) & 0xff); - rgba[BCOMP] = (((*texel) ) & 0xff); - rgba[ACOMP] = (((*texel) >> 24) & 0xff); -} - - -static void -fetch_rgb_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - fxt1_decode_1(texImage->Data, mml->width, i, j, rgba); - rgba[ACOMP] = 255; -} - - -static void -fetch_rgba_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - fxt1_decode_1(texImage->Data, mml->width, i, j, rgba); -} - - -static void -fetch_rgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static void -fetch_rgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static void -fetch_rgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static void -fetch_rgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *rgba) -{ - const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage); - - i = i * mml->wScale; - j = j * mml->hScale; - - _mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba); -} - - -static FetchTexelFuncC -fxFetchFunction(GLint mesaFormat) -{ - switch (mesaFormat) { - case MESA_FORMAT_I8: - return &fetch_intensity8; - case MESA_FORMAT_A8: - return &fetch_alpha8; - case MESA_FORMAT_L8: - return &fetch_luminance8; - case MESA_FORMAT_CI8: - return &fetch_index8; - case MESA_FORMAT_AL88: - return &fetch_luminance8_alpha8; - case MESA_FORMAT_RGB565: - return &fetch_r5g6b5; - case MESA_FORMAT_ARGB4444: - return &fetch_r4g4b4a4; - case MESA_FORMAT_ARGB1555: - return &fetch_r5g5b5a1; - case MESA_FORMAT_ARGB8888: - return &fetch_a8r8g8b8; - case MESA_FORMAT_RGB_FXT1: - return &fetch_rgb_fxt1; - case MESA_FORMAT_RGBA_FXT1: - return &fetch_rgba_fxt1; - case MESA_FORMAT_RGB_DXT1: - return &fetch_rgb_dxt1; - case MESA_FORMAT_RGBA_DXT1: - return &fetch_rgba_dxt1; - case MESA_FORMAT_RGBA_DXT3: - return &fetch_rgba_dxt3; - case MESA_FORMAT_RGBA_DXT5: - return &fetch_rgba_dxt5; - default: - _mesa_problem(NULL, "Unexpected format in fxFetchFunction"); - return NULL; - } -} - - -static GLboolean -adjust2DRatio (GLcontext *ctx, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - tdfxMipMapLevel *mml, - struct gl_texture_image *texImage, - GLint texelBytes, - GLint dstRowStride) -{ - const GLint newWidth = width * mml->wScale; - const GLint newHeight = height * mml->hScale; - GLvoid *tempImage; - - if (!texImage->IsCompressed) { - GLubyte *destAddr; - tempImage = MALLOC(width * height * texelBytes); - if (!tempImage) { - return GL_FALSE; - } - - texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, - texImage->TexFormat, tempImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - width * texelBytes, /* dstRowStride */ - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - - /* now rescale */ - /* compute address of dest subimage within the overal tex image */ - destAddr = (GLubyte *) texImage->Data - + (yoffset * mml->hScale * mml->width - + xoffset * mml->wScale) * texelBytes; - - _mesa_rescale_teximage2d(texelBytes, - width, - dstRowStride, /* dst stride */ - width, height, - newWidth, newHeight, - tempImage, destAddr); - } else { - const GLint rawBytes = 4; - GLvoid *rawImage = MALLOC(width * height * rawBytes); - if (!rawImage) { - return GL_FALSE; - } - tempImage = MALLOC(newWidth * newHeight * rawBytes); - if (!tempImage) { - return GL_FALSE; - } - /* unpack image, apply transfer ops and store in rawImage */ - _mesa_texstore_rgba8888(ctx, 2, GL_RGBA, - &_mesa_texformat_rgba8888_rev, rawImage, - 0, 0, 0, /* dstX/Y/Zoffset */ - width * rawBytes, /* dstRowStride */ - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - _mesa_rescale_teximage2d(rawBytes, - width, - newWidth * rawBytes, /* dst stride */ - width, height, /* src */ - newWidth, newHeight, /* dst */ - rawImage /*src*/, tempImage /*dst*/ ); - texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, - texImage->TexFormat, texImage->Data, - xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */ - dstRowStride, - 0, /* dstImageStride */ - newWidth, newHeight, 1, - GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking); - FREE(rawImage); - } - - FREE(tempImage); - - return GL_TRUE; -} - - -static void -tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - GLint texelBytes, dstRowStride; - - /* - printf("TexImage id=%d int 0x%x format 0x%x type 0x%x %dx%d\n", - texObj->Name, texImage->IntFormat, format, type, - texImage->Width, texImage->Height); - */ - - ti = TDFX_TEXTURE_DATA(texObj); - if (!ti) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - ti = TDFX_TEXTURE_DATA(texObj); - } - assert(ti); - - mml = TDFX_TEXIMAGE_DATA(texImage); - if (!mml) { - texImage->DriverData = CALLOC(sizeof(tdfxMipMapLevel)); - if (!texImage->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - mml = TDFX_TEXIMAGE_DATA(texImage); - } - - /* Determine width and height scale factors for texture. - * Remember, Glide is limited to 8:1 aspect ratios. - */ - tdfxTexGetInfo(ctx, - texImage->Width, texImage->Height, - NULL, /* lod level */ - NULL, /* aspect ratio */ - NULL, NULL, /* sscale, tscale */ - &mml->wScale, &mml->hScale); - - /* rescaled size: */ - mml->width = width * mml->wScale; - mml->height = height * mml->hScale; - -#if FX_COMPRESS_S3TC_AS_FXT1_HACK - /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */ - /* [dBorca] we should update texture's attribute, then, - * because if the application asks us to decompress, we - * have to know the REAL format! Also, DXT3/5 might not - * be correct, since it would mess with "compressedSize". - * Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3. - */ - if (texImage->IsCompressed) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - internalFormat = GL_COMPRESSED_RGB_FXT1_3DFX; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - internalFormat = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - texImage->IntFormat = internalFormat; - } -#endif -#if FX_TC_NAPALM - if (fxMesa->type >= GR_SSTTYPE_Voodoo4) { - GLenum texNapalm = 0; - if (internalFormat == GL_COMPRESSED_RGB) { - texNapalm = GL_COMPRESSED_RGB_FXT1_3DFX; - } else if (internalFormat == GL_COMPRESSED_RGBA) { - texNapalm = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - if (texNapalm) { - texImage->IntFormat = internalFormat = texNapalm; - texImage->IsCompressed = GL_TRUE; - } - } -#endif - - /* choose the texture format */ - assert(ctx->Driver.ChooseTextureFormat); - texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx, - internalFormat, format, type); - assert(texImage->TexFormat); - mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat); - ti->info.format = mml->glideFormat; - texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat); - texelBytes = texImage->TexFormat->TexelBytes; - - if (texImage->IsCompressed) { - texImage->CompressedSize = _mesa_compressed_texture_size(ctx, - mml->width, - mml->height, - 1, - internalFormat); - dstRowStride = _mesa_compressed_row_stride(internalFormat, mml->width); - texImage->Data = _mesa_malloc(texImage->CompressedSize); - } else { - dstRowStride = mml->width * texelBytes; - texImage->Data = _mesa_malloc(mml->width * mml->height * texelBytes); - } - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - - if (pixels != NULL) { - if (mml->wScale != 1 || mml->hScale != 1) { - /* rescale image to overcome 1:8 aspect limitation */ - if (!adjust2DRatio(ctx, - 0, 0, - width, height, - format, type, pixels, - packing, - mml, - texImage, - texelBytes, - dstRowStride) - ) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } - else { - /* no rescaling needed */ - /* unpack image, apply transfer ops and store in texImage->Data */ - texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, - texImage->TexFormat, texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - GLint mipWidth, mipHeight; - tdfxMipMapLevel *mip; - struct gl_texture_image *mipImage; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); - - assert(!texImage->IsCompressed); - - while (level < texObj->MaxLevel && level < maxLevels - 1) { - mipWidth = width / 2; - if (!mipWidth) { - mipWidth = 1; - } - mipHeight = height / 2; - if (!mipHeight) { - mipHeight = 1; - } - if ((mipWidth == width) && (mipHeight == height)) { - break; - } - _mesa_TexImage2D(target, ++level, internalFormat, - mipWidth, mipHeight, border, - format, type, - NULL); - mipImage = _mesa_select_tex_image(ctx, texUnit, target, level); - mip = TDFX_TEXIMAGE_DATA(mipImage); - _mesa_halve2x2_teximage2d(ctx, - texImage, - texelBytes, - mml->width, mml->height, - texImage->Data, mipImage->Data); - texImage = mipImage; - mml = mip; - width = mipWidth; - height = mipHeight; - } - } - } - - RevalidateTexture(ctx, texObj); - - ti->reloadImages = GL_TRUE; - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -static void -tdfxTexSubImage2D(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 ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - GLint texelBytes, dstRowStride; - - if (!texObj->DriverData) { - _mesa_problem(ctx, "problem in fxDDTexSubImage2D"); - return; - } - - ti = TDFX_TEXTURE_DATA(texObj); - assert(ti); - mml = TDFX_TEXIMAGE_DATA(texImage); - assert(mml); - - assert(texImage->Data); /* must have an existing texture image! */ - assert(texImage->Format); - - texelBytes = texImage->TexFormat->TexelBytes; - if (texImage->IsCompressed) { - dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, mml->width); - } else { - dstRowStride = mml->width * texelBytes; - } - - if (mml->wScale != 1 || mml->hScale != 1) { - /* need to rescale subimage to match mipmap level's rescale factors */ - if (!adjust2DRatio(ctx, - xoffset, yoffset, - width, height, - format, type, pixels, - packing, - mml, - texImage, - texelBytes, - dstRowStride) - ) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - return; - } - } - else { - /* no rescaling needed */ - texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, - texImage->TexFormat, texImage->Data, - xoffset, yoffset, 0, - dstRowStride, - 0, /* dstImageStride */ - width, height, 1, - format, type, pixels, packing); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - GLint mipWidth, mipHeight; - tdfxMipMapLevel *mip; - struct gl_texture_image *mipImage; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); - - assert(!texImage->IsCompressed); - - width = texImage->Width; - height = texImage->Height; - while (level < texObj->MaxLevel && level < maxLevels - 1) { - mipWidth = width / 2; - if (!mipWidth) { - mipWidth = 1; - } - mipHeight = height / 2; - if (!mipHeight) { - mipHeight = 1; - } - if ((mipWidth == width) && (mipHeight == height)) { - break; - } - ++level; - mipImage = _mesa_select_tex_image(ctx, texUnit, target, level); - mip = TDFX_TEXIMAGE_DATA(mipImage); - _mesa_halve2x2_teximage2d(ctx, - texImage, - texelBytes, - mml->width, mml->height, - texImage->Data, mipImage->Data); - texImage = mipImage; - mml = mip; - width = mipWidth; - height = mipHeight; - } - } - - ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */ - fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX this might be a bit much */ -} - - -static void -tdfxTexImage1D(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - tdfxTexImage2D(ctx, target, level, - internalFormat, width, 1, border, - format, type, pixels, - packing, - texObj, - texImage); -} - -static void -tdfxTexSubImage1D(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - tdfxTexSubImage2D(ctx, target, level, - xoffset, 0, - width, 1, - format, type, - pixels, - packing, - texObj, - texImage); -} - -/**********************************************************************/ -/**** COMPRESSED TEXTURE IMAGE FUNCTIONS ****/ -/**********************************************************************/ - -static void -tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - - if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) { - fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n", - texObj->Name, internalFormat, - width, height); - } - - if ((target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) || texImage->Border > 0) { - _mesa_problem(NULL, "tdfx: unsupported texture in tdfxCompressedTexImg()\n"); - return; - } - - assert(texImage->IsCompressed); - - ti = TDFX_TEXTURE_DATA(texObj); - if (!ti) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - ti = TDFX_TEXTURE_DATA(texObj); - } - assert(ti); - - mml = TDFX_TEXIMAGE_DATA(texImage); - if (!mml) { - texImage->DriverData = CALLOC(sizeof(tdfxMipMapLevel)); - if (!texImage->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - mml = TDFX_TEXIMAGE_DATA(texImage); - } - - tdfxTexGetInfo(ctx, width, height, NULL, NULL, NULL, NULL, - &mml->wScale, &mml->hScale); - - mml->width = width * mml->wScale; - mml->height = height * mml->hScale; - - - /* choose the texture format */ - assert(ctx->Driver.ChooseTextureFormat); - texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx, - internalFormat, -1/*format*/, -1/*type*/); - assert(texImage->TexFormat); - - /* Determine the appropriate Glide texel format, - * given the user's internal texture format hint. - */ - mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat); - ti->info.format = mml->glideFormat; - texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat); - - /* allocate new storage for texture image, if needed */ - if (!texImage->Data) { - texImage->CompressedSize = _mesa_compressed_texture_size(ctx, - mml->width, - mml->height, - 1, - internalFormat); - texImage->Data = _mesa_malloc(texImage->CompressedSize); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } - - /* save the texture data */ - if (mml->wScale != 1 || mml->hScale != 1) { - /* [dBorca] Hack alert: - * now we're screwed. We can't decompress, - * unless we do it in HW (via textureBuffer). - * We still have some chances: - * 1) we got FXT1 textures - we CAN decompress, rescale for - * aspectratio, then compress back. - * 2) there is a chance that MIN("s", "t") won't be overflowed. - * Thus, we don't care about textureclamp and we could lower - * MIN("uscale", "vscale") below 32. We still have to have - * our data aligned inside a 8:1 rectangle. - * 3) just in case if MIN("s", "t") gets overflowed with GL_REPEAT, - * we replicate the data over the padded area. - * For now, we take 2) + 3) but texelfetchers will be wrong! - */ - GLuint srcRowStride = _mesa_compressed_row_stride(internalFormat, width); - - GLuint destRowStride = _mesa_compressed_row_stride(internalFormat, - mml->width); - - _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4, - destRowStride, (mml->height+3) / 4, - 1, data, srcRowStride, - texImage->Data); - ti->padded = GL_TRUE; - } else { - MEMCPY(texImage->Data, data, texImage->CompressedSize); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - assert(!texImage->IsCompressed); - } - - RevalidateTexture(ctx, texObj); - - ti->reloadImages = GL_TRUE; - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -static void -tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target, - GLint level, GLint xoffset, - GLint yoffset, GLsizei width, - GLint height, GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - tdfxMipMapLevel *mml; - GLint destRowStride, srcRowStride; - GLint i, rows; - GLubyte *dest; - - if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) { - fprintf(stderr, "tdfxCompressedTexSubImage2D: id=%d\n", texObj->Name); - } - - ti = TDFX_TEXTURE_DATA(texObj); - assert(ti); - mml = TDFX_TEXIMAGE_DATA(texImage); - assert(mml); - - srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, width); - - destRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - mml->width); - dest = _mesa_compressed_image_address(xoffset, yoffset, 0, - texImage->IntFormat, - mml->width, - (GLubyte*) texImage->Data); - - rows = height / 4; /* [dBorca] hardcoded 4, but works for FXT1/DXTC */ - - for (i = 0; i < rows; i++) { - MEMCPY(dest, data, srcRowStride); - dest += destRowStride; - data = (GLvoid *)((GLuint)data + (GLuint)srcRowStride); - } - - /* [dBorca] Hack alert: - * see fxDDCompressedTexImage2D for caveats - */ - if (mml->wScale != 1 || mml->hScale != 1) { - srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, texImage->Width); - - destRowStride = _mesa_compressed_row_stride(texImage->IntFormat, - mml->width); - _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4, - destRowStride, mml->height / 4, - 1, texImage->Data, destRowStride, - texImage->Data); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - assert(!texImage->IsCompressed); - } - - RevalidateTexture(ctx, texObj); - - ti->reloadImages = GL_TRUE; - fxMesa->new_state |= TDFX_NEW_TEXTURE; -} - - -#if 0 -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"); - } -} -#endif - - -GLboolean -tdfxTestProxyTexImage(GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - /*JJJ wrong*/ - case GL_PROXY_TEXTURE_2D: - { - struct gl_texture_object *tObj; - tdfxTexInfo *ti; - int memNeeded; - - tObj = ctx->Texture.Proxy2D; - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = TDFX_TEXTURE_DATA(tObj); - assert(ti); - - /* assign the parameters to test against */ - tObj->Image[0][level]->Width = width; - tObj->Image[0][level]->Height = height; - tObj->Image[0][level]->Border = border; -#if 0 - tObj->Image[0][level]->IntFormat = internalFormat; -#endif - if (level == 0) { - /* don't use mipmap levels > 0 */ - tObj->MinFilter = tObj->MagFilter = GL_NEAREST; - } - else { - /* test with all mipmap levels */ - tObj->MinFilter = GL_LINEAR_MIPMAP_LINEAR; - tObj->MagFilter = GL_NEAREST; - } - RevalidateTexture(ctx, tObj); - - /* - printf("small lodlog2 0x%x\n", ti->info.smallLodLog2); - printf("large lodlog2 0x%x\n", ti->info.largeLodLog2); - printf("aspect ratio 0x%x\n", ti->info.aspectRatioLog2); - printf("glide format 0x%x\n", ti->info.format); - printf("data %p\n", ti->info.data); - printf("lodblend %d\n", (int) ti->LODblend); - */ - - /* determine where texture will reside */ - if (ti->LODblend && !shared->umaTexMemory) { - /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */ - memNeeded = fxMesa->Glide.grTexTextureMemRequired( - GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - } - else { - /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */ - memNeeded = fxMesa->Glide.grTexTextureMemRequired( - GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - } - /* - printf("Proxy test %d > %d\n", memNeeded, shared->totalTexMem[0]); - */ - if (memNeeded > shared->totalTexMem[0]) - return GL_FALSE; - else - return GL_TRUE; - } - case GL_PROXY_TEXTURE_3D: - return GL_TRUE; /* software rendering */ - default: - return GL_TRUE; /* never happens, silence compiler */ - } -} - - -/** - * Allocate a new texture object. - * Called via ctx->Driver.NewTextureObject. - * Note: this function will be called during context creation to - * allocate the default texture objects. - * Note: we could use containment here to 'derive' the driver-specific - * texture object from the core mesa gl_texture_object. Not done at this time. - */ -static struct gl_texture_object * -tdfxNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - obj = _mesa_new_texture_object(ctx, name, target); - return obj; -} - - -void tdfxInitTextureFuncs( struct dd_function_table *functions ) -{ - functions->BindTexture = tdfxBindTexture; - functions->NewTextureObject = tdfxNewTextureObject; - functions->DeleteTexture = tdfxDeleteTexture; - functions->TexEnv = tdfxTexEnv; - functions->TexParameter = tdfxTexParameter; - functions->ChooseTextureFormat = tdfxChooseTextureFormat; - functions->TexImage1D = tdfxTexImage1D; - functions->TexSubImage1D = tdfxTexSubImage1D; - functions->TexImage2D = tdfxTexImage2D; - functions->TexSubImage2D = tdfxTexSubImage2D; - functions->IsTextureResident = tdfxIsTextureResident; - functions->CompressedTexImage2D = tdfxCompressedTexImage2D; - functions->CompressedTexSubImage2D = tdfxCompressedTexSubImage2D; - functions->UpdateTexturePalette = tdfxUpdateTexturePalette; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h deleted file mode 100644 index f536c25a2..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#ifndef _TDFX_TEX_H_ -#define _TDFX_TEX_H_ - - -#define tdfxDDIsCompressedFormatMacro(internalFormat) \ - (((internalFormat) == GL_COMPRESSED_RGB_FXT1_3DFX) || \ - ((internalFormat) == GL_COMPRESSED_RGBA_FXT1_3DFX)) -#define tdfxDDIsCompressedGlideFormatMacro(internalFormat) \ - ((internalFormat) == GR_TEXFMT_ARGB_CMP_FXT1) - - - -extern void -tdfxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj); - - -#if 000 /* DEAD? */ -extern void -fxDDTexUseGlobalPalette(GLcontext * ctx, GLboolean state); -#endif - -extern GLboolean -tdfxTestProxyTexImage(GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border); - -extern GLvoid * -tdfxDDGetTexImage(GLcontext * ctx, GLenum target, GLint level, - const struct gl_texture_object *texObj, - GLenum * formatOut, GLenum * typeOut, - GLboolean * freeImageOut); - -extern void -tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target, - GLint lod, void *image, - const struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - -extern GLint -tdfxSpecificCompressedTexFormat(GLcontext *ctx, - GLint internalFormat, - GLint numDimensions); - -extern GLint -tdfxBaseCompressedTexFormat(GLcontext *ctx, - GLint internalFormat); - -extern GLboolean -tdfxDDIsCompressedFormat(GLcontext *ctx, GLint internalFormat); - -extern GLsizei -tdfxDDCompressedImageSize(GLcontext *ctx, - GLenum intFormat, - GLuint numDimensions, - GLuint width, - GLuint height, - GLuint depth); - - -extern void -tdfxInitTextureFuncs( struct dd_function_table *functions ); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c deleted file mode 100644 index 63cae17e4..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c +++ /dev/null @@ -1,994 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c,v 1.5 2002/02/22 21:45:04 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#include "tdfx_context.h" -#include "tdfx_tex.h" -#include "tdfx_texman.h" -#include "hash.h" - - -#define BAD_ADDRESS ((FxU32) -1) - - -#if 0 /* DEBUG use */ -/* - * Verify the consistancy of the texture memory manager. - * This involves: - * Traversing all texture objects and computing total memory used. - * Traverse the free block list and computing total memory free. - * Compare the total free and total used amounts to the total memory size. - * Make various assertions about the results. - */ -static void -VerifyFreeList(tdfxContextPtr fxMesa, FxU32 tmu) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxMemRange *block; - int prevStart = -1, prevEnd = -1; - int totalFree = 0; - int numObj = 0, numRes = 0; - int totalUsed = 0; - - for (block = shared->tmFree[tmu]; block; block = block->next) { - assert( block->endAddr > 0 ); - assert( block->startAddr <= shared->totalTexMem[tmu] ); - assert( block->endAddr <= shared->totalTexMem[tmu] ); - assert( (int) block->startAddr > prevStart ); - assert( (int) block->startAddr >= prevEnd ); - prevStart = (int) block->startAddr; - prevEnd = (int) block->endAddr; - totalFree += (block->endAddr - block->startAddr); - } - assert(totalFree == shared->freeTexMem[tmu]); - - { - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj; - tObj = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - if (ti) { - if (ti->isInTM) { - numRes++; - assert(ti->tm[0]); - if (ti->tm[tmu]) - totalUsed += (ti->tm[tmu]->endAddr - ti->tm[tmu]->startAddr); - } - else { - assert(!ti->tm[0]); - } - } - } - } - - printf("totalFree: %d totalUsed: %d totalMem: %d #objs=%d #res=%d\n", - shared->freeTexMem[tmu], totalUsed, shared->totalTexMem[tmu], - numObj, numRes); - - assert(totalUsed + totalFree == shared->totalTexMem[tmu]); -} - - -static void -dump_texmem(tdfxContextPtr fxMesa) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct _mesa_HashTable *textures = mesaShared->TexObjects; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxMemRange *r; - FxU32 prev; - GLuint id; - - printf("DUMP Objects:\n"); - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *obj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj); - - if (info && info->isInTM) { - printf("Obj %8p: %4d info = %p\n", obj, obj->Name, info); - - printf(" isInTM=%d whichTMU=%d lastTimeUsed=%d\n", - info->isInTM, info->whichTMU, info->lastTimeUsed); - printf(" tm[0] = %p", info->tm[0]); - assert(info->tm[0]); - if (info->tm[0]) { - printf(" tm startAddr = %d endAddr = %d", - info->tm[0]->startAddr, - info->tm[0]->endAddr); - } - printf("\n"); - printf(" tm[1] = %p", info->tm[1]); - if (info->tm[1]) { - printf(" tm startAddr = %d endAddr = %d", - info->tm[1]->startAddr, - info->tm[1]->endAddr); - } - printf("\n"); - } - } - - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - - printf("Free memory unit 0: %d bytes\n", shared->freeTexMem[0]); - prev = 0; - for (r = shared->tmFree[0]; r; r = r->next) { - printf("%8p: start %8d end %8d size %8d gap %8d\n", r, r->startAddr, r->endAddr, r->endAddr - r->startAddr, r->startAddr - prev); - prev = r->endAddr; - } - - printf("Free memory unit 1: %d bytes\n", shared->freeTexMem[1]); - prev = 0; - for (r = shared->tmFree[1]; r; r = r->next) { - printf("%8p: start %8d end %8d size %8d gap %8d\n", r, r->startAddr, r->endAddr, r->endAddr - r->startAddr, r->startAddr - prev); - prev = r->endAddr; - } - -} -#endif - - - -#ifdef TEXSANITY -static void -fubar(void) -{ -} - -/* - * Sanity Check - */ -static void -sanity(tdfxContextPtr fxMesa) -{ - tdfxMemRange *tmp, *prev, *pos; - - prev = 0; - tmp = fxMesa->tmFree[0]; - while (tmp) { - if (!tmp->startAddr && !tmp->endAddr) { - fprintf(stderr, "Textures fubar\n"); - fubar(); - } - if (tmp->startAddr >= tmp->endAddr) { - fprintf(stderr, "Node fubar\n"); - fubar(); - } - if (prev && (prev->startAddr >= tmp->startAddr || - prev->endAddr > tmp->startAddr)) { - fprintf(stderr, "Sorting fubar\n"); - fubar(); - } - prev = tmp; - tmp = tmp->next; - } - prev = 0; - tmp = fxMesa->tmFree[1]; - while (tmp) { - if (!tmp->startAddr && !tmp->endAddr) { - fprintf(stderr, "Textures fubar\n"); - fubar(); - } - if (tmp->startAddr >= tmp->endAddr) { - fprintf(stderr, "Node fubar\n"); - fubar(); - } - if (prev && (prev->startAddr >= tmp->startAddr || - prev->endAddr > tmp->startAddr)) { - fprintf(stderr, "Sorting fubar\n"); - fubar(); - } - prev = tmp; - tmp = tmp->next; - } -} -#endif - - - - - -/* - * Allocate and initialize a new MemRange struct. - * Try to allocate it from the pool of free MemRange nodes rather than malloc. - */ -static tdfxMemRange * -NewRangeNode(tdfxContextPtr fxMesa, FxU32 start, FxU32 end) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxMemRange *result; - - _glthread_LOCK_MUTEX(mesaShared->Mutex); - if (shared && shared->tmPool) { - result = shared->tmPool; - shared->tmPool = shared->tmPool->next; - } - else { - result = MALLOC(sizeof(tdfxMemRange)); - - } - _glthread_UNLOCK_MUTEX(mesaShared->Mutex); - - if (!result) { - /*fprintf(stderr, "fxDriver: out of memory!\n");*/ - return NULL; - } - - result->startAddr = start; - result->endAddr = end; - result->next = NULL; - - return result; -} - - -/* - * Initialize texture memory. - * We take care of one or both TMU's here. - */ -void -tdfxTMInit(tdfxContextPtr fxMesa) -{ - if (!fxMesa->glCtx->Shared->DriverData) { - const char *extensions; - struct tdfxSharedState *shared = CALLOC_STRUCT(tdfxSharedState); - if (!shared) - return; - - LOCK_HARDWARE(fxMesa); - extensions = fxMesa->Glide.grGetString(GR_EXTENSION); - UNLOCK_HARDWARE(fxMesa); - if (strstr(extensions, "TEXUMA")) { - FxU32 start, end; - shared->umaTexMemory = GL_TRUE; - LOCK_HARDWARE(fxMesa); - fxMesa->Glide.grEnable(GR_TEXTURE_UMA_EXT); - start = fxMesa->Glide.grTexMinAddress(0); - end = fxMesa->Glide.grTexMaxAddress(0); - UNLOCK_HARDWARE(fxMesa); - shared->totalTexMem[0] = end - start; - shared->totalTexMem[1] = 0; - shared->freeTexMem[0] = end - start; - shared->freeTexMem[1] = 0; - shared->tmFree[0] = NewRangeNode(fxMesa, start, end); - shared->tmFree[1] = NULL; - /*printf("UMA tex memory: %d\n", (int) (end - start));*/ - } - else { - const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1; - int tmu; - shared->umaTexMemory = GL_FALSE; - LOCK_HARDWARE(fxMesa); - for (tmu = 0; tmu < numTMUs; tmu++) { - FxU32 start = fxMesa->Glide.grTexMinAddress(tmu); - FxU32 end = fxMesa->Glide.grTexMaxAddress(tmu); - shared->totalTexMem[tmu] = end - start; - shared->freeTexMem[tmu] = end - start; - shared->tmFree[tmu] = NewRangeNode(fxMesa, start, end); - /*printf("Split tex memory: %d\n", (int) (end - start));*/ - } - UNLOCK_HARDWARE(fxMesa); - } - - shared->tmPool = NULL; - fxMesa->glCtx->Shared->DriverData = shared; - /*printf("Texture memory init UMA: %d\n", shared->umaTexMemory);*/ - } -} - - -/* - * Clean-up texture memory before destroying context. - */ -void -tdfxTMClose(tdfxContextPtr fxMesa) -{ - if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) { - /* refcount will soon go to zero, free our 3dfx stuff */ - struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData; - - const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1; - int tmu; - tdfxMemRange *tmp, *next; - - /* Deallocate the pool of free tdfxMemRange nodes */ - tmp = shared->tmPool; - while (tmp) { - next = tmp->next; - FREE(tmp); - tmp = next; - } - - /* Delete the texture memory block tdfxMemRange nodes */ - for (tmu = 0; tmu < numTMUs; tmu++) { - tmp = shared->tmFree[tmu]; - while (tmp) { - next = tmp->next; - FREE(tmp); - tmp = next; - } - } - - FREE(shared); - fxMesa->glCtx->Shared->DriverData = NULL; - } -} - - - -/* - * Delete a tdfxMemRange struct. - * We keep a linked list of free/available tdfxMemRange structs to - * avoid extra malloc/free calls. - */ -#if 0 -static void -DeleteRangeNode_NoLock(struct TdfxSharedState *shared, tdfxMemRange *range) -{ - /* insert at head of list */ - range->next = shared->tmPool; - shared->tmPool = range; -} -#endif - -#define DELETE_RANGE_NODE(shared, range) \ - (range)->next = (shared)->tmPool; \ - (shared)->tmPool = (range) - - - -/* - * When we've run out of texture memory we have to throw out an - * existing texture to make room for the new one. This function - * determins the texture to throw out. - */ -static struct gl_texture_object * -FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu) -{ - const GLuint bindnumber = fxMesa->texBindNumber; - struct gl_texture_object *oldestObj, *lowestPriorityObj; - GLfloat lowestPriority; - GLuint oldestAge; - GLuint id; - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - - oldestObj = NULL; - oldestAge = 0; - - lowestPriority = 1.0F; - lowestPriorityObj = NULL; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *obj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj); - - if (info && info->isInTM && - ((info->whichTMU == tmu) || (info->whichTMU == TDFX_TMU_BOTH) || - (info->whichTMU == TDFX_TMU_SPLIT))) { - GLuint age, lasttime; - - assert(info->tm[0]); - lasttime = info->lastTimeUsed; - - if (lasttime > bindnumber) - age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */ - else - age = bindnumber - lasttime; - - if (age >= oldestAge) { - oldestAge = age; - oldestObj = obj; - } - - /* examine priority */ - if (obj->Priority < lowestPriority) { - lowestPriority = obj->Priority; - lowestPriorityObj = obj; - } - } - } - - if (lowestPriority < 1.0) { - ASSERT(lowestPriorityObj); - /* - printf("discard %d pri=%f\n", lowestPriorityObj->Name, lowestPriority); - */ - return lowestPriorityObj; - } - else { - /* - printf("discard %d age=%d\n", oldestObj->Name, oldestAge); - */ - return oldestObj; - } -} - - -#if 0 -static void -FlushTexMemory(tdfxContextPtr fxMesa) -{ - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *obj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - if (obj->RefCount < 2) { - /* don't flush currently bound textures */ - tdfxTMMoveOutTM_NoLock(fxMesa, obj); - } - } -} -#endif - - -/* - * Find the address (offset?) at which we can store a new texture. - * is the texture unit. - * is the texture size in bytes. - */ -static FxU32 -FindStartAddr(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 size) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxMemRange *prev, *block; - FxU32 result; -#if 0 - int discardedCount = 0; -#define MAX_DISCARDS 10 -#endif - - if (shared->umaTexMemory) { - assert(tmu == TDFX_TMU0); - } - - _glthread_LOCK_MUTEX(mesaShared->Mutex); - while (1) { - prev = NULL; - block = shared->tmFree[tmu]; - while (block) { - if (block->endAddr - block->startAddr >= size) { - /* The texture will fit here */ - result = block->startAddr; - block->startAddr += size; - if (block->startAddr == block->endAddr) { - /* Remove this node since it's empty */ - if (prev) { - prev->next = block->next; - } - else { - shared->tmFree[tmu] = block->next; - } - DELETE_RANGE_NODE(shared, block); - } - shared->freeTexMem[tmu] -= size; - _glthread_UNLOCK_MUTEX(mesaShared->Mutex); - return result; - } - prev = block; - block = block->next; - } - /* We failed to find a block large enough to accomodate bytes. - * Find the oldest texObject and free it. - */ -#if 0 - discardedCount++; - if (discardedCount > MAX_DISCARDS + 1) { - _mesa_problem(NULL, "%s: extreme texmem fragmentation", __FUNCTION__); - _glthread_UNLOCK_MUTEX(mesaShared->Mutex); - return BAD_ADDRESS; - } - else if (discardedCount > MAX_DISCARDS) { - /* texture memory is probably really fragmented, flush it */ - FlushTexMemory(fxMesa); - } - else -#endif - { - struct gl_texture_object *obj = FindOldestObject(fxMesa, tmu); - if (obj) { - tdfxTMMoveOutTM_NoLock(fxMesa, obj); - fxMesa->stats.texSwaps++; - } - else { - _mesa_problem(NULL, "%s: extreme texmem fragmentation", __FUNCTION__); - _glthread_UNLOCK_MUTEX(mesaShared->Mutex); - return BAD_ADDRESS; - } - } - } - - /* never get here, but play it safe */ - _glthread_UNLOCK_MUTEX(mesaShared->Mutex); - return BAD_ADDRESS; -} - - -/* - * Remove the given tdfxMemRange node from hardware texture memory. - */ -static void -RemoveRange_NoLock(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxMemRange *block, *prev; - - if (shared->umaTexMemory) { - assert(tmu == TDFX_TMU0); - } - - if (!range) - return; - - if (range->startAddr == range->endAddr) { - DELETE_RANGE_NODE(shared, range); - return; - } - shared->freeTexMem[tmu] += range->endAddr - range->startAddr; - - /* find position in linked list to insert this tdfxMemRange node */ - prev = NULL; - block = shared->tmFree[tmu]; - while (block) { - assert(range->startAddr != block->startAddr); - if (range->startAddr > block->startAddr) { - prev = block; - block = block->next; - } - else { - break; - } - } - - /* Insert the free block, combine with adjacent blocks when possible */ - range->next = block; - if (block) { - if (range->endAddr == block->startAddr) { - /* Combine */ - block->startAddr = range->startAddr; - DELETE_RANGE_NODE(shared, range); - range = block; - } - } - if (prev) { - if (prev->endAddr == range->startAddr) { - /* Combine */ - prev->endAddr = range->endAddr; - prev->next = range->next; - DELETE_RANGE_NODE(shared, range); - } - else { - prev->next = range; - } - } - else { - shared->tmFree[tmu] = range; - } -} - - -#if 0 /* NOT USED */ -static void -RemoveRange(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - _glthread_LOCK_MUTEX(mesaShared->Mutex); - RemoveRange_NoLock(fxMesa, tmu, range); - _glthread_UNLOCK_MUTEX(mesaShared->Mutex); -} -#endif - - -/* - * Allocate space for a texture image. - * is the texture unit - * is the number of bytes to allocate - */ -static tdfxMemRange * -AllocTexMem(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 texmemsize) -{ - FxU32 startAddr; - startAddr = FindStartAddr(fxMesa, tmu, texmemsize); - if (startAddr == BAD_ADDRESS) { - _mesa_problem(fxMesa->glCtx, "%s returned NULL! tmu=%d texmemsize=%d", - __FUNCTION__, (int) tmu, (int) texmemsize); - return NULL; - } - else { - tdfxMemRange *range; - range = NewRangeNode(fxMesa, startAddr, startAddr + texmemsize); - return range; - } -} - - -/* - * Download (copy) the given texture data (all mipmap levels) into the - * Voodoo's texture memory. - * The texture memory must have already been allocated. - */ -void -tdfxTMDownloadTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj) -{ - tdfxTexInfo *ti; - GLint l; - FxU32 targetTMU; - - assert(tObj); - ti = TDFX_TEXTURE_DATA(tObj); - assert(ti); - targetTMU = ti->whichTMU; - - switch (targetTMU) { - case TDFX_TMU0: - case TDFX_TMU1: - if (ti->tm[targetTMU]) { - for (l = ti->minLevel; l <= ti->maxLevel - && tObj->Image[0][l]->Data; l++) { - GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel; - fxMesa->Glide.grTexDownloadMipMapLevel(targetTMU, - ti->tm[targetTMU]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - tObj->Image[0][l]->Data); - } - } - break; - case TDFX_TMU_SPLIT: - if (ti->tm[TDFX_TMU0] && ti->tm[TDFX_TMU1]) { - for (l = ti->minLevel; l <= ti->maxLevel - && tObj->Image[0][l]->Data; l++) { - GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel; - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[TDFX_TMU0]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_ODD, - tObj->Image[0][l]->Data); - - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[TDFX_TMU1]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_EVEN, - tObj->Image[0][l]->Data); - } - } - break; - case TDFX_TMU_BOTH: - if (ti->tm[TDFX_TMU0] && ti->tm[TDFX_TMU1]) { - for (l = ti->minLevel; l <= ti->maxLevel - && tObj->Image[0][l]->Data; l++) { - GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel; - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[TDFX_TMU0]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - tObj->Image[0][l]->Data); - - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[TDFX_TMU1]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - tObj->Image[0][l]->Data); - } - } - break; - default: - _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)targetTMU); - return; - } -} - - -void -tdfxTMReloadMipMapLevel(GLcontext *ctx, struct gl_texture_object *tObj, - GLint level) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - GrLOD_t glideLod; - FxU32 tmu; - - tmu = ti->whichTMU; - glideLod = ti->info.largeLodLog2 - level + tObj->BaseLevel; - ASSERT(ti->isInTM); - - LOCK_HARDWARE(fxMesa); - - switch (tmu) { - case TDFX_TMU0: - case TDFX_TMU1: - fxMesa->Glide.grTexDownloadMipMapLevel(tmu, - ti->tm[tmu]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - tObj->Image[0][level]->Data); - break; - case TDFX_TMU_SPLIT: - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[GR_TMU0]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_ODD, - tObj->Image[0][level]->Data); - - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[GR_TMU1]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_EVEN, - tObj->Image[0][level]->Data); - break; - case TDFX_TMU_BOTH: - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0, - ti->tm[GR_TMU0]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - tObj->Image[0][level]->Data); - - fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1, - ti->tm[GR_TMU1]->startAddr, - glideLod, - ti->info.largeLodLog2, - ti->info.aspectRatioLog2, - ti->info.format, - GR_MIPMAPLEVELMASK_BOTH, - tObj->Image[0][level]->Data); - break; - - default: - _mesa_problem(ctx, "%s: bad tmu (%d)", __FUNCTION__, (int)tmu); - break; - } - UNLOCK_HARDWARE(fxMesa); -} - - -/* - * Allocate space for the given texture in texture memory then - * download (copy) it into that space. - */ -void -tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj, - FxU32 targetTMU ) -{ - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - FxU32 texmemsize; - - fxMesa->stats.reqTexUpload++; - - if (ti->isInTM) { - if (ti->whichTMU == targetTMU) - return; - if (targetTMU == TDFX_TMU_SPLIT || ti->whichTMU == TDFX_TMU_SPLIT) { - tdfxTMMoveOutTM_NoLock(fxMesa, tObj); - } - else { - if (ti->whichTMU == TDFX_TMU_BOTH) - return; - targetTMU = TDFX_TMU_BOTH; - } - } - - ti->whichTMU = targetTMU; - - switch (targetTMU) { - case TDFX_TMU0: - case TDFX_TMU1: - texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, - &(ti->info)); - ti->tm[targetTMU] = AllocTexMem(fxMesa, targetTMU, texmemsize); - break; - case TDFX_TMU_SPLIT: - texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD, - &(ti->info)); - ti->tm[TDFX_TMU0] = AllocTexMem(fxMesa, TDFX_TMU0, texmemsize); - if (ti->tm[TDFX_TMU0]) - fxMesa->stats.memTexUpload += texmemsize; - - texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN, - &(ti->info)); - ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize); - break; - case TDFX_TMU_BOTH: - texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, - &(ti->info)); - ti->tm[TDFX_TMU0] = AllocTexMem(fxMesa, TDFX_TMU0, texmemsize); - if (ti->tm[TDFX_TMU0]) - fxMesa->stats.memTexUpload += texmemsize; - - /*texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, - &(ti->info));*/ - ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize); - break; - default: - _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)targetTMU); - return; - } - - ti->reloadImages = GL_TRUE; - ti->isInTM = GL_TRUE; - - fxMesa->stats.texUpload++; -} - - -/* - * Move the given texture out of hardware texture memory. - * This deallocates the texture's memory space. - */ -void -tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj ) -{ - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - - if (MESA_VERBOSE & VERBOSE_DRIVER) { - fprintf(stderr, "fxmesa: %s(%p (%d))\n", __FUNCTION__, (void *)tObj, tObj->Name); - } - - /* - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - */ - - if (!ti || !ti->isInTM) - return; - - switch (ti->whichTMU) { - case TDFX_TMU0: - case TDFX_TMU1: - RemoveRange_NoLock(fxMesa, ti->whichTMU, ti->tm[ti->whichTMU]); - break; - case TDFX_TMU_SPLIT: - case TDFX_TMU_BOTH: - assert(!shared->umaTexMemory); - RemoveRange_NoLock(fxMesa, TDFX_TMU0, ti->tm[TDFX_TMU0]); - RemoveRange_NoLock(fxMesa, TDFX_TMU1, ti->tm[TDFX_TMU1]); - break; - default: - _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)ti->whichTMU); - return; - } - - ti->isInTM = GL_FALSE; - ti->tm[0] = NULL; - ti->tm[1] = NULL; - ti->whichTMU = TDFX_TMU_NONE; - - /* - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - */ -} - - -/* - * Called via glDeleteTexture to delete a texture object. - */ -void -tdfxTMFreeTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj) -{ - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - if (ti) { - tdfxTMMoveOutTM(fxMesa, tObj); - FREE(ti); - tObj->DriverData = NULL; - } - /* - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - */ -} - - - -/* - * After a context switch this function will be called to restore - * texture memory for the new context. - */ -void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa ) -{ - GLcontext *ctx = fxMesa->glCtx; - struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; - GLuint id; - - for (id = _mesa_HashFirstEntry(textures); - id; - id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); - tdfxTexInfo *ti = TDFX_TEXTURE_DATA( tObj ); - if ( ti && ti->isInTM ) { - int i; - for ( i = 0 ; i < MAX_TEXTURE_UNITS ; i++ ) { - if ( ctx->Texture.Unit[i]._Current == tObj ) { - tdfxTMDownloadTexture( fxMesa, tObj ); - break; - } - } - if ( i == MAX_TEXTURE_UNITS ) { - tdfxTMMoveOutTM_NoLock( fxMesa, tObj ); - } - } - } - /* - VerifyFreeList(fxMesa, 0); - VerifyFreeList(fxMesa, 1); - */ -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h deleted file mode 100644 index 739d4e142..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#ifndef __TDFX_TEXMAN_H__ -#define __TDFX_TEXMAN_H__ - - -#include "tdfx_lock.h" - - -extern void tdfxTMInit( tdfxContextPtr fxMesa ); - -extern void tdfxTMClose( tdfxContextPtr fxMesa ); - -extern void tdfxTMDownloadTexture(tdfxContextPtr fxMesa, - struct gl_texture_object *tObj); - -extern void tdfxTMReloadMipMapLevel( GLcontext *ctx, - struct gl_texture_object *tObj, - GLint level ); - -extern void tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa, - struct gl_texture_object *tObj, - FxU32 targetTMU ); - -extern void tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa, - struct gl_texture_object *tObj ); - -extern void tdfxTMFreeTexture( tdfxContextPtr fxMesa, - struct gl_texture_object *tObj ); - -extern void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa ); - - -#define tdfxTMMoveInTM( fxMesa, tObj, targetTMU ) \ - do { \ - LOCK_HARDWARE( fxMesa ); \ - tdfxTMMoveInTM_NoLock( fxMesa, tObj, targetTMU ); \ - UNLOCK_HARDWARE( fxMesa ); \ - } while (0) - -#define tdfxTMMoveOutTM( fxMesa, tObj ) \ - do { \ - LOCK_HARDWARE( fxMesa ); \ - tdfxTMMoveOutTM_NoLock( fxMesa, tObj ); \ - UNLOCK_HARDWARE( fxMesa ); \ - } while (0) - - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c deleted file mode 100644 index 7059b56e3..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c +++ /dev/null @@ -1,2209 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c,v 1.2 2002/02/22 21:45:04 dawes Exp $ */ - -/* - * New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#include "tdfx_state.h" -#include "tdfx_tex.h" -#include "tdfx_texman.h" -#include "tdfx_texstate.h" - - -/* ============================================================= - * Texture - */ - -/* - * These macros are used below when handling COMBINE_EXT. - */ -#define TEXENV_OPERAND_INVERTED(operand) \ - (((operand) == GL_ONE_MINUS_SRC_ALPHA) \ - || ((operand) == GL_ONE_MINUS_SRC_COLOR)) -#define TEXENV_OPERAND_ALPHA(operand) \ - (((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA)) -#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha) \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CALPHA; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITALPHA; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedAlpha; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } - -#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \ - if (!TEXENV_OPERAND_ALPHA(operand)) { \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_RGB; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CCOLOR; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITRGB; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedColor; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } \ - } else { \ - switch (source) { \ - case GL_TEXTURE: \ - param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \ - break; \ - case GL_CONSTANT_EXT: \ - param = GR_CMBX_TMU_CALPHA; \ - break; \ - case GL_PRIMARY_COLOR_EXT: \ - param = GR_CMBX_ITALPHA; \ - break; \ - case GL_PREVIOUS_EXT: \ - param = iteratedAlpha; \ - break; \ - default: \ - /* \ - * This is here just to keep from getting \ - * compiler warnings. \ - */ \ - param = GR_CMBX_ZERO; \ - break; \ - } \ - } - -#define TEXENV_SETUP_MODE_RGB(param, operand) \ - switch (operand) { \ - case GL_SRC_COLOR: \ - case GL_SRC_ALPHA: \ - param = GR_FUNC_MODE_X; \ - break; \ - case GL_ONE_MINUS_SRC_ALPHA: \ - case GL_ONE_MINUS_SRC_COLOR: \ - param = GR_FUNC_MODE_ONE_MINUS_X; \ - break; \ - default: \ - param = GR_FUNC_MODE_ZERO; \ - break; \ - } - -#define TEXENV_SETUP_MODE_A(param, operand) \ - switch (operand) { \ - case GL_SRC_ALPHA: \ - param = GR_FUNC_MODE_X; \ - break; \ - case GL_ONE_MINUS_SRC_ALPHA: \ - param = GR_FUNC_MODE_ONE_MINUS_X; \ - break; \ - default: \ - param = GR_FUNC_MODE_ZERO; \ - break; \ - } - - - -/* - * Setup a texture environment on Voodoo5. - * Return GL_TRUE for success, GL_FALSE for failure. - * If we fail, we'll have to use software rendering. - */ -static GLboolean -SetupTexEnvNapalm(GLcontext *ctx, GLboolean useIteratedRGBA, - const struct gl_texture_unit *texUnit, GLenum baseFormat, - struct tdfx_texcombine_ext *env) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrTCCUColor_t incomingRGB, incomingAlpha; - const GLenum envMode = texUnit->EnvMode; - - if (useIteratedRGBA) { - incomingRGB = GR_CMBX_ITRGB; - incomingAlpha = GR_CMBX_ITALPHA; - } - else { - incomingRGB = GR_CMBX_OTHER_TEXTURE_RGB; - incomingAlpha = GR_CMBX_OTHER_TEXTURE_ALPHA; - } - - /* invariant: */ - env->Color.Shift = 0; - env->Color.Invert = FXFALSE; - env->Alpha.Shift = 0; - env->Alpha.Invert = FXFALSE; - - switch (envMode) { - case GL_REPLACE: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceA = incomingRGB; - } - else { - /* Rv = Rt */ - env->Color.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB; - } - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceD = incomingAlpha; - } - else { - /* Av = At */ - env->Alpha.SourceD = GR_CMBX_LOCAL_TEXTURE_ALPHA; - } - env->Alpha.SourceA = GR_CMBX_ITALPHA; - env->Alpha.ModeA = GR_FUNC_MODE_ZERO; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXFALSE; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_MODULATE: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - } - else { - /* Result = Frag * Tex */ - env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.InvertC = FXFALSE; - } - env->Color.SourceA = incomingRGB; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - } - else { - /* Av = Af * At */ - env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.SourceC = incomingAlpha; - env->Alpha.InvertC = FXFALSE; - } - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_DECAL: - /* -- Setup RGB combiner */ - if (baseFormat == GL_RGB) { - /* Rv = Rt */ - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_X; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - } - else { - /* Rv = Rf * (1 - At) + Rt * At */ - env->Color.SourceB = incomingRGB; - env->Color.ModeB = GR_FUNC_MODE_NEGATIVE_X; - env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Color.InvertC = FXFALSE; - env->Color.SourceD = GR_CMBX_B; - env->Color.InvertD = FXFALSE; - } - env->Color.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.ModeA = GR_FUNC_MODE_X; - /* -- Setup Alpha combiner */ - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_BLEND: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceA = incomingRGB; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - } - else { - /* Rv = Rf * (1 - Rt) + Rc * Rt */ - env->Color.SourceA = GR_CMBX_TMU_CCOLOR; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceB = incomingRGB; - env->Color.ModeB = GR_FUNC_MODE_NEGATIVE_X; - env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.InvertC = FXFALSE; - env->Color.SourceD = GR_CMBX_B; - env->Color.InvertD = FXFALSE; - } - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ZERO; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - } - else if (baseFormat == GL_INTENSITY) { - /* Av = Af * (1 - It) + Ac * It */ - env->Alpha.SourceA = GR_CMBX_TMU_CALPHA; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = incomingAlpha; - env->Alpha.ModeB = GR_FUNC_MODE_NEGATIVE_X; - env->Alpha.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.InvertC = FXFALSE; - env->Alpha.SourceD = GR_CMBX_B; - env->Alpha.InvertD = FXFALSE; - } - else { - /* Av = Af * At */ - env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = incomingAlpha; - env->Alpha.InvertC = FXFALSE; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - } - /* Also have to set up the tex env constant color */ - env->EnvColor = PACK_RGBA32(texUnit->EnvColor[0] * 255.0F, - texUnit->EnvColor[1] * 255.0F, - texUnit->EnvColor[2] * 255.0F, - texUnit->EnvColor[3] * 255.0F); - break; - case GL_ADD: - /* -- Setup RGB combiner */ - if (baseFormat == GL_ALPHA) { - /* Rv = Rf */ - env->Color.SourceB = GR_CMBX_ZERO; - env->Color.ModeB = GR_FUNC_MODE_ZERO; - } - else { - /* Rv = Rf + Tt */ - env->Color.SourceB = GR_CMBX_LOCAL_TEXTURE_RGB; - env->Color.ModeB = GR_FUNC_MODE_X; - } - env->Color.SourceA = incomingRGB; - env->Color.ModeA = GR_FUNC_MODE_X; - env->Color.SourceC = GR_CMBX_ZERO; - env->Color.InvertC = FXTRUE; - env->Color.SourceD = GR_CMBX_ZERO; - env->Color.InvertD = FXFALSE; - /* -- Setup Alpha combiner */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - - } - else if (baseFormat == GL_INTENSITY) { - /* Av = Af + It */ - env->Alpha.SourceA = incomingAlpha; - env->Alpha.SourceB = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_X; - env->Alpha.SourceC = GR_CMBX_ZERO; - env->Alpha.InvertC = FXTRUE; - } - else { - /* Av = Af * At */ - env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA; - env->Alpha.SourceB = GR_CMBX_ITALPHA; - env->Alpha.ModeB = GR_FUNC_MODE_ZERO; - env->Alpha.SourceC = incomingAlpha; - env->Alpha.InvertC = FXFALSE; - } - env->Alpha.ModeA = GR_FUNC_MODE_X; - env->Alpha.SourceD = GR_CMBX_ZERO; - env->Alpha.InvertD = FXFALSE; - break; - - case GL_COMBINE_EXT: - { - FxU32 A_RGB, B_RGB, C_RGB, D_RGB; - FxU32 Amode_RGB, Bmode_RGB; - FxBool Cinv_RGB, Dinv_RGB, Ginv_RGB; - FxU32 Shift_RGB; - FxU32 A_A, B_A, C_A, D_A; - FxU32 Amode_A, Bmode_A; - FxBool Cinv_A, Dinv_A, Ginv_A; - FxU32 Shift_A; - - /* - * - * In the formulas below, we write: - * o "1(x)" for the identity function applied to x, - * so 1(x) = x. - * o "0(x)" for the constant function 0, so - * 0(x) = 0 for all values of x. - * - * Calculate the color combination. - */ - Shift_RGB = texUnit->Combine.ScaleShiftRGB; - Shift_A = texUnit->Combine.ScaleShiftA; - switch (texUnit->Combine.ModeRGB) { - case GL_REPLACE: - /* - * The formula is: Arg0 - * We implement this by the formula: - * (Arg0 + 0(0))*(1-0) + 0 - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO; - Bmode_RGB = GR_FUNC_MODE_ZERO; - Cinv_RGB = FXTRUE; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_MODULATE: - /* - * The formula is: Arg0 * Arg1 - * - * We implement this by the formula - * (Arg0 + 0(0)) * Arg1 + 0(0) - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - B_RGB = GR_CMBX_ZERO; - Bmode_RGB = GR_CMBX_ZERO; - TEXENV_SETUP_ARG_RGB(C_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - Cinv_RGB = TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandRGB[1]); - D_RGB = GR_CMBX_ZERO; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_ADD: - /* - * The formula is Arg0 + Arg1 - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - TEXENV_SETUP_ARG_RGB(B_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Bmode_RGB, - texUnit->Combine.OperandRGB[1]); - C_RGB = D_RGB = GR_CMBX_ZERO; - Cinv_RGB = FXTRUE; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_ADD_SIGNED_EXT: - /* - * The formula is: Arg0 + Arg1 - 0.5. - * We compute this by calculating: - * (Arg0 - 1/2) + Arg1 if op0 is SRC_{COLOR,ALPHA} - * Arg0 + (Arg1 - 1/2) if op1 is SRC_{COLOR,ALPHA} - * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA} - * we cannot implement the formula properly. - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_ARG_RGB(B_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[0])) { - /* - * A is not inverted. So, choose it. - */ - Amode_RGB = GR_FUNC_MODE_X_MINUS_HALF; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandRGB[1])) { - Bmode_RGB = GR_FUNC_MODE_X; - } - else { - Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X; - } - } - else { - /* - * A is inverted, so try to subtract 1/2 - * from B. - */ - Amode_RGB = GR_FUNC_MODE_ONE_MINUS_X; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandRGB[1])) { - Bmode_RGB = GR_FUNC_MODE_X_MINUS_HALF; - } - else { - /* - * Both are inverted. This is the case - * we cannot handle properly. We just - * choose to not add the - 1/2. - */ - Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X; - return GL_FALSE; - } - } - C_RGB = D_RGB = GR_CMBX_ZERO; - Cinv_RGB = FXTRUE; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - case GL_INTERPOLATE_EXT: - /* - * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2). - * We compute this by the formula: - * (Arg0 - Arg1) * Arg2 + Arg1 - * == Arg0 * Arg2 - Arg1 * Arg2 + Arg1 - * == Arg0 * Arg2 + Arg1 * (1 - Arg2) - * However, if both Arg1 is ONE_MINUS_X, the HW does - * not support it properly. - */ - TEXENV_SETUP_ARG_RGB(A_RGB, - texUnit->Combine.SourceRGB[0], - texUnit->Combine.OperandRGB[0], - incomingRGB, incomingAlpha); - TEXENV_SETUP_MODE_RGB(Amode_RGB, - texUnit->Combine.OperandRGB[0]); - TEXENV_SETUP_ARG_RGB(B_RGB, - texUnit->Combine.SourceRGB[1], - texUnit->Combine.OperandRGB[1], - incomingRGB, incomingAlpha); - if (TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[1])) { - /* - * This case is wrong. - */ - Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X; - return GL_FALSE; - } - else { - Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X; - } - /* - * The Source/Operand for the C value must - * specify some kind of alpha value. - */ - TEXENV_SETUP_ARG_A(C_RGB, - texUnit->Combine.SourceRGB[2], - texUnit->Combine.OperandRGB[2], - incomingAlpha); - Cinv_RGB = FXFALSE; - D_RGB = GR_CMBX_B; - Dinv_RGB = Ginv_RGB = FXFALSE; - break; - default: - /* - * This is here mostly to keep from getting - * a compiler warning about these not being set. - * However, this should set all the texture values - * to zero. - */ - A_RGB = B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO; - Amode_RGB = Bmode_RGB = GR_FUNC_MODE_X; - Cinv_RGB = Dinv_RGB = Ginv_RGB = FXFALSE; - break; - } - /* - * Calculate the alpha combination. - */ - switch (texUnit->Combine.ModeA) { - case GL_REPLACE: - /* - * The formula is: Arg0 - * We implement this by the formula: - * (Arg0 + 0(0))*(1-0) + 0 - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - B_A = GR_CMBX_ITALPHA; - Bmode_A = GR_FUNC_MODE_ZERO; - C_A = D_A = GR_CMBX_ZERO; - Cinv_A = FXTRUE; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_MODULATE: - /* - * The formula is: Arg0 * Arg1 - * - * We implement this by the formula - * (Arg0 + 0(0)) * Arg1 + 0(0) - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - B_A = GR_CMBX_ZERO; - Bmode_A = GR_CMBX_ZERO; - TEXENV_SETUP_ARG_A(C_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - Cinv_A = TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandA[1]); - D_A = GR_CMBX_ZERO; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_ADD: - /* - * The formula is Arg0 + Arg1 - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - TEXENV_SETUP_ARG_A(B_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - TEXENV_SETUP_MODE_A(Bmode_A, - texUnit->Combine.OperandA[1]); - C_A = D_A = GR_CMBX_ZERO; - Cinv_A = FXTRUE; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_ADD_SIGNED_EXT: - /* - * The formula is: Arg0 + Arg1 - 0.5. - * We compute this by calculating: - * (Arg0 - 1/2) + Arg1 if op0 is SRC_{COLOR,ALPHA} - * Arg0 + (Arg1 - 1/2) if op1 is SRC_{COLOR,ALPHA} - * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA} - * we cannot implement the formula properly. - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_ARG_A(B_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandA[0])) { - /* - * A is not inverted. So, choose it. - */ - Amode_A = GR_FUNC_MODE_X_MINUS_HALF; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandA[1])) { - Bmode_A = GR_FUNC_MODE_X; - } else { - Bmode_A = GR_FUNC_MODE_ONE_MINUS_X; - } - } else { - /* - * A is inverted, so try to subtract 1/2 - * from B. - */ - Amode_A = GR_FUNC_MODE_ONE_MINUS_X; - if (!TEXENV_OPERAND_INVERTED - (texUnit->Combine.OperandA[1])) { - Bmode_A = GR_FUNC_MODE_X_MINUS_HALF; - } else { - /* - * Both are inverted. This is the case - * we cannot handle properly. We just - * choose to not add the - 1/2. - */ - Bmode_A = GR_FUNC_MODE_ONE_MINUS_X; - return GL_FALSE; - } - } - C_A = D_A = GR_CMBX_ZERO; - Cinv_A = FXTRUE; - Dinv_A = Ginv_A = FXFALSE; - break; - case GL_INTERPOLATE_EXT: - /* - * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2). - * We compute this by the formula: - * (Arg0 - Arg1) * Arg2 + Arg1 - * == Arg0 * Arg2 - Arg1 * Arg2 + Arg1 - * == Arg0 * Arg2 + Arg1 * (1 - Arg2) - * However, if both Arg1 is ONE_MINUS_X, the HW does - * not support it properly. - */ - TEXENV_SETUP_ARG_A(A_A, - texUnit->Combine.SourceA[0], - texUnit->Combine.OperandA[0], - incomingAlpha); - TEXENV_SETUP_MODE_A(Amode_A, - texUnit->Combine.OperandA[0]); - TEXENV_SETUP_ARG_A(B_A, - texUnit->Combine.SourceA[1], - texUnit->Combine.OperandA[1], - incomingAlpha); - if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandA[1])) { - Bmode_A = GR_FUNC_MODE_NEGATIVE_X; - } - else { - /* - * This case is wrong. - */ - Bmode_A = GR_FUNC_MODE_NEGATIVE_X; - return GL_FALSE; - } - /* - * The Source/Operand for the C value must - * specify some kind of alpha value. - */ - TEXENV_SETUP_ARG_A(C_A, - texUnit->Combine.SourceA[2], - texUnit->Combine.OperandA[2], - incomingAlpha); - Cinv_A = FXFALSE; - D_A = GR_CMBX_B; - Dinv_A = Ginv_A = FXFALSE; - break; - default: - /* - * This is here mostly to keep from getting - * a compiler warning about these not being set. - * However, this should set all the alpha values - * to one. - */ - A_A = B_A = C_A = D_A = GR_CMBX_ZERO; - Amode_A = Bmode_A = GR_FUNC_MODE_X; - Cinv_A = Dinv_A = FXFALSE; - Ginv_A = FXTRUE; - break; - } - /* - * Save the parameters. - */ - env->Color.SourceA = A_RGB; - env->Color.ModeA = Amode_RGB; - env->Color.SourceB = B_RGB; - env->Color.ModeB = Bmode_RGB; - env->Color.SourceC = C_RGB; - env->Color.InvertC = Cinv_RGB; - env->Color.SourceD = D_RGB; - env->Color.InvertD = Dinv_RGB; - env->Color.Shift = Shift_RGB; - env->Color.Invert = Ginv_RGB; - env->Alpha.SourceA = A_A; - env->Alpha.ModeA = Amode_A; - env->Alpha.SourceB = B_A; - env->Alpha.ModeB = Bmode_A; - env->Alpha.SourceC = C_A; - env->Alpha.InvertC = Cinv_A; - env->Alpha.SourceD = D_A; - env->Alpha.InvertD = Dinv_A; - env->Alpha.Shift = Shift_A; - env->Alpha.Invert = Ginv_A; - env->EnvColor = PACK_RGBA32(texUnit->EnvColor[0] * 255.0F, - texUnit->EnvColor[1] * 255.0F, - texUnit->EnvColor[2] * 255.0F, - texUnit->EnvColor[3] * 255.0F); - } - break; - - default: - _mesa_problem(ctx, "%s: Bad envMode", __FUNCTION__); - } - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; - - fxMesa->ColorCombineExt.SourceA = GR_CMBX_TEXTURE_RGB; - fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X, - fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_X; - fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertC = FXTRUE; - fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertD = FXFALSE; - fxMesa->ColorCombineExt.Shift = 0; - fxMesa->ColorCombineExt.Invert = FXFALSE; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - fxMesa->AlphaCombineExt.SourceA = GR_CMBX_TEXTURE_ALPHA; - fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertC = FXTRUE; - fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertD = FXFALSE; - fxMesa->AlphaCombineExt.Shift = 0; - fxMesa->AlphaCombineExt.Invert = FXFALSE; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - return GL_TRUE; /* success */ -} - - - -/* - * Setup the Voodoo3 texture environment for a single texture unit. - * Return GL_TRUE for success, GL_FALSE for failure. - * If failure, we'll use software rendering. - */ -static GLboolean -SetupSingleTexEnvVoodoo3(GLcontext *ctx, int unit, - GLenum envMode, GLenum baseFormat) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GrCombineLocal_t localc, locala; - struct tdfx_combine alphaComb, colorComb; - - if (1 /*iteratedRGBA*/) - localc = locala = GR_COMBINE_LOCAL_ITERATED; - else - localc = locala = GR_COMBINE_LOCAL_CONSTANT; - - switch (envMode) { - case GL_DECAL: - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - break; - case GL_MODULATE: - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - if (baseFormat == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_LOCAL; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - } - break; - - case GL_BLEND: - /* - * XXX we can't do real GL_BLEND mode. These settings assume that - * the TexEnv color is black and incoming fragment color is white. - */ - if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* Av = Af */ - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - } - else if (baseFormat == GL_INTENSITY) { - /* Av = Af * (1 - It) + Ac * It */ - alphaComb.Function = GR_COMBINE_FUNCTION_BLEND; - alphaComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_CONSTANT; - alphaComb.Invert = FXFALSE; - } - else { - /* Av = Af * At */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - if (baseFormat == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - colorComb.Function = GR_COMBINE_FUNCTION_BLEND; - colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_RGB; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_CONSTANT; - colorComb.Invert = FXTRUE; - } - fxMesa->Color.MonoColor = PACK_RGBA32( - ctx->Texture.Unit[unit].EnvColor[0] * 255.0f, - ctx->Texture.Unit[unit].EnvColor[1] * 255.0f, - ctx->Texture.Unit[unit].EnvColor[2] * 255.0f, - ctx->Texture.Unit[unit].EnvColor[3] * 255.0f); - fxMesa->dirty |= TDFX_UPLOAD_CONSTANT_COLOR; - break; - - case GL_REPLACE: - if ((baseFormat == GL_RGB) || (baseFormat == GL_LUMINANCE)) { - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - } - else { - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - if (baseFormat == GL_ALPHA) { - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - } - break; - - case GL_ADD: - if (baseFormat == GL_ALPHA || - baseFormat == GL_LUMINANCE_ALPHA || - baseFormat == GL_RGBA) { - /* product of texel and fragment alpha */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - else if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) { - /* fragment alpha is unchanged */ - alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL; - alphaComb.Factor = GR_COMBINE_FACTOR_NONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_NONE; - alphaComb.Invert = FXFALSE; - } - else { - ASSERT(baseFormat == GL_INTENSITY); - /* sum of texel and fragment alpha */ - alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, - alphaComb.Factor = GR_COMBINE_FACTOR_ONE; - alphaComb.Local = locala; - alphaComb.Other = GR_COMBINE_OTHER_TEXTURE; - alphaComb.Invert = FXFALSE; - } - if (baseFormat == GL_ALPHA) { - /* rgb unchanged */ - colorComb.Function = GR_COMBINE_FUNCTION_LOCAL; - colorComb.Factor = GR_COMBINE_FACTOR_NONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_NONE; - colorComb.Invert = FXFALSE; - } - else { - /* sum of texel and fragment rgb */ - colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, - colorComb.Factor = GR_COMBINE_FACTOR_ONE; - colorComb.Local = localc; - colorComb.Other = GR_COMBINE_OTHER_TEXTURE; - colorComb.Invert = FXFALSE; - } - break; - - default: - _mesa_problem(ctx, "bad texture env mode in %s", __FUNCTION__); - } - - if (colorComb.Function != fxMesa->ColorCombine.Function || - colorComb.Factor != fxMesa->ColorCombine.Factor || - colorComb.Local != fxMesa->ColorCombine.Local || - colorComb.Other != fxMesa->ColorCombine.Other || - colorComb.Invert != fxMesa->ColorCombine.Invert) { - fxMesa->ColorCombine = colorComb; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - } - - if (alphaComb.Function != fxMesa->AlphaCombine.Function || - alphaComb.Factor != fxMesa->AlphaCombine.Factor || - alphaComb.Local != fxMesa->AlphaCombine.Local || - alphaComb.Other != fxMesa->AlphaCombine.Other || - alphaComb.Invert != fxMesa->AlphaCombine.Invert) { - fxMesa->AlphaCombine = alphaComb; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - } - return GL_TRUE; -} - - -/* - * Setup the Voodoo3 texture environment for dual texture units. - * Return GL_TRUE for success, GL_FALSE for failure. - * If failure, we'll use software rendering. - */ -static GLboolean -SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0, - GLenum envMode0, GLenum baseFormat0, - GLenum envMode1, GLenum baseFormat1) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - const GrCombineLocal_t locala = GR_COMBINE_LOCAL_ITERATED; - const GrCombineLocal_t localc = GR_COMBINE_LOCAL_ITERATED; - const int tmu1 = 1 - tmu0; - - if (envMode0 == GL_MODULATE && envMode1 == GL_MODULATE) { - GLboolean isalpha[TDFX_NUM_TMU]; - - isalpha[tmu0] = (baseFormat0 == GL_ALPHA); - isalpha[tmu1] = (baseFormat1 == GL_ALPHA); - - if (isalpha[TDFX_TMU1]) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - if (isalpha[TDFX_TMU0]) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode0 == GL_REPLACE && envMode1 == GL_BLEND) { /* Quake */ - if (tmu0 == TDFX_TMU1) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode0 == GL_REPLACE && envMode1 == GL_MODULATE) { - /* Quake 2/3 */ - if (tmu1 == TDFX_TMU1) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXTRUE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - if (baseFormat0 == GL_RGB) { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - } - else if (envMode0 == GL_MODULATE && envMode1 == GL_ADD) { - /* Quake 3 sky */ - GLboolean isalpha[TDFX_NUM_TMU]; - - isalpha[tmu0] = (baseFormat0 == GL_ALPHA); - isalpha[tmu1] = (baseFormat1 == GL_ALPHA); - - if (isalpha[TDFX_TMU1]) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - if (isalpha[TDFX_TMU0]) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - else { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode0 == GL_REPLACE && envMode1 == GL_ADD) { - /* Vulpine sky */ - GLboolean isalpha[TDFX_NUM_TMU]; - - isalpha[tmu0] = (baseFormat0 == GL_ALPHA); - isalpha[tmu1] = (baseFormat1 == GL_ALPHA); - - if (isalpha[TDFX_TMU1]) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXTRUE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - - if (isalpha[TDFX_TMU0]) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } else { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - } - - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - else if (envMode1 == GL_REPLACE) { - /* Homeworld2 */ - - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - - if ((baseFormat0 == GL_RGB) && (baseFormat0 == GL_LUMINANCE)) { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } else { - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->AlphaCombine.Local = locala; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - if (baseFormat0 == GL_ALPHA) { - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->ColorCombine.Invert = FXFALSE; - } else { - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; - fxMesa->ColorCombine.Local = localc; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; - fxMesa->ColorCombine.Invert = FXFALSE; - } - } - else { - _mesa_problem(ctx, "%s: Unexpected dual texture mode encountered", __FUNCTION__); - return GL_FALSE; - } - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - return GL_TRUE; -} - - -/* - * This function makes sure that the correct mipmap levels are loaded - * in the right places in memory and then makes the Glide calls to - * setup the texture source pointers. - */ -static void -setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj) -{ - struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData; - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); - const GLcontext *ctx = fxMesa->glCtx; - - /* Make sure we're not loaded incorrectly */ - if (ti->isInTM && !shared->umaTexMemory) { - /* if doing filtering between mipmap levels, alternate mipmap levels - * must be in alternate TMUs. - */ - if (ti->LODblend) { - if (ti->whichTMU != TDFX_TMU_SPLIT) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj); - } - else { - if (ti->whichTMU == TDFX_TMU_SPLIT) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj); - } - } - - /* Make sure we're loaded correctly */ - if (!ti->isInTM) { - /* Have to download the texture */ - if (shared->umaTexMemory) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); - } - else { - /* Voodoo3 (split texture memory) */ - if (ti->LODblend) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU_SPLIT); - } - else { -#if 0 - /* XXX putting textures into the second memory bank when the - * first bank is full is not working at this time. - */ - if (fxMesa->haveTwoTMUs) { - GLint memReq = fxMesa->Glide.grTexTextureMemRequired( - GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - if (shared->freeTexMem[TDFX_TMU0] > memReq) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); - } - else { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU1); - } - } - else -#endif - { - tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); - } - } - } - } - - if (ti->LODblend && ti->whichTMU == TDFX_TMU_SPLIT) { - /* mipmap levels split between texture banks */ - GLint u; - - if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) { - fxMesa->TexPalette.Type = ti->paltype; - fxMesa->TexPalette.Data = &(ti->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - - for (u = 0; u < 2; u++) { - fxMesa->TexParams[u].sClamp = ti->sClamp; - fxMesa->TexParams[u].tClamp = ti->tClamp; - fxMesa->TexParams[u].minFilt = ti->minFilt; - fxMesa->TexParams[u].magFilt = ti->magFilt; - fxMesa->TexParams[u].mmMode = ti->mmMode; - fxMesa->TexParams[u].LODblend = ti->LODblend; - fxMesa->TexParams[u].LodBias = ctx->Texture.Unit[u].LodBias; - } - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS; - - fxMesa->TexSource[0].StartAddress = ti->tm[TDFX_TMU0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD; - fxMesa->TexSource[0].Info = &(ti->info); - fxMesa->TexSource[1].StartAddress = ti->tm[TDFX_TMU1]->startAddr; - fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN; - fxMesa->TexSource[1].Info = &(ti->info); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; - } - else { - FxU32 tmu; - - if (ti->whichTMU == TDFX_TMU_BOTH) - tmu = TDFX_TMU0; - else - tmu = ti->whichTMU; - - if (shared->umaTexMemory) { - assert(ti->whichTMU == TDFX_TMU0); - assert(tmu == TDFX_TMU0); - } - - if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) { - fxMesa->TexPalette.Type = ti->paltype; - fxMesa->TexPalette.Data = &(ti->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - - /* KW: The alternative is to do the download to the other tmu. If - * we get to this point, I think it means we are thrashing the - * texture memory, so perhaps it's not a good idea. - */ - - if (fxMesa->TexParams[tmu].sClamp != ti->sClamp || - fxMesa->TexParams[tmu].tClamp != ti->tClamp || - fxMesa->TexParams[tmu].minFilt != ti->minFilt || - fxMesa->TexParams[tmu].magFilt != ti->magFilt || - fxMesa->TexParams[tmu].mmMode != ti->mmMode || - fxMesa->TexParams[tmu].LODblend != FXFALSE || - fxMesa->TexParams[tmu].LodBias != ctx->Texture.Unit[tmu].LodBias) { - fxMesa->TexParams[tmu].sClamp = ti->sClamp; - fxMesa->TexParams[tmu].tClamp = ti->tClamp; - fxMesa->TexParams[tmu].minFilt = ti->minFilt; - fxMesa->TexParams[tmu].magFilt = ti->magFilt; - fxMesa->TexParams[tmu].mmMode = ti->mmMode; - fxMesa->TexParams[tmu].LODblend = FXFALSE; - fxMesa->TexParams[tmu].LodBias = ctx->Texture.Unit[tmu].LodBias; - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS; - } - - /* Glide texture source info */ - fxMesa->TexSource[0].Info = NULL; - fxMesa->TexSource[1].Info = NULL; - if (ti->tm[tmu]) { - fxMesa->TexSource[tmu].StartAddress = ti->tm[tmu]->startAddr; - fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu].Info = &(ti->info); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; - } - } - - fxMesa->sScale0 = ti->sScale; - fxMesa->tScale0 = ti->tScale; -} - -static void -selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend) -{ - if (LODblend) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - - if (fxMesa->haveTwoTMUs) { - const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - int tmu; - - if (shared->umaTexMemory) - tmu = GR_TMU0; - else - tmu = GR_TMU1; - - fxMesa->TexCombine[tmu].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[tmu].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[tmu].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[tmu].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[tmu].InvertRGB = FXFALSE; - fxMesa->TexCombine[tmu].InvertAlpha = FXFALSE; - } - fxMesa->tmuSrc = TDFX_TMU_SPLIT; - } - else { - if (tmu != TDFX_TMU1) { - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - if (fxMesa->haveTwoTMUs) { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - } - fxMesa->tmuSrc = TDFX_TMU0; - } - else { - fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; - fxMesa->TexCombine[1].InvertRGB = FXFALSE; - fxMesa->TexCombine[1].InvertAlpha = FXFALSE; - /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */ - fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; - fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; - fxMesa->TexCombine[0].InvertRGB = FXFALSE; - fxMesa->TexCombine[0].InvertAlpha = FXFALSE; - fxMesa->tmuSrc = TDFX_TMU1; - } - } - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; -} - -#if 0 -static void print_state(tdfxContextPtr fxMesa) -{ - GLcontext *ctx = fxMesa->glCtx; - struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current; - GLenum base0 = tObj0->Image[0][tObj0->BaseLevel] ? tObj0->Image[0][tObj0->BaseLevel]->Format : 99; - GLenum base1 = tObj1->Image[0][tObj1->BaseLevel] ? tObj1->Image[0][tObj1->BaseLevel]->Format : 99; - - printf("Unit 0: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[0]._ReallyEnabled, - fxMesa->TexState.Enabled[0]); - printf(" EnvMode: GL=0x%x Gr=0x%x\n", ctx->Texture.Unit[0].EnvMode, - fxMesa->TexState.EnvMode[0]); - printf(" BaseFmt: GL=0x%x Gr=0x%x\n", base0, fxMesa->TexState.TexFormat[0]); - - - printf("Unit 1: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[1]._ReallyEnabled, - fxMesa->TexState.Enabled[1]); - printf(" EnvMode: GL=0x%x Gr:0x%x\n", ctx->Texture.Unit[1].EnvMode, - fxMesa->TexState.EnvMode[1]); - printf(" BaseFmt: GL=0x%x Gr:0x%x\n", base1, fxMesa->TexState.TexFormat[1]); -} -#endif - -/* - * When we're only using a single texture unit, we always use the 0th - * Glide/hardware unit, regardless if it's GL_TEXTURE0_ARB or GL_TEXTURE1_ARB - * that's enalbed. - * Input: ctx - the context - * unit - the OpenGL texture unit to use. - */ -static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxTexInfo *ti; - struct gl_texture_object *tObj; - int tmu; - GLenum envMode, baseFormat; - - tObj = ctx->Texture.Unit[unit]._Current; - if (tObj->Image[0][tObj->BaseLevel]->Border > 0) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE); - return; - } - - setupSingleTMU(fxMesa, tObj); - - ti = TDFX_TEXTURE_DATA(tObj); - if (ti->whichTMU == TDFX_TMU_BOTH) - tmu = TDFX_TMU0; - else - tmu = ti->whichTMU; - - if (fxMesa->tmuSrc != tmu) { - selectSingleTMUSrc(fxMesa, tmu, ti->LODblend); - } - - if (ti->reloadImages) - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES; - - /* Check if we really need to update the texenv state */ - envMode = ctx->Texture.Unit[unit].EnvMode; - baseFormat = tObj->Image[0][tObj->BaseLevel]->Format; - - if (TDFX_IS_NAPALM(fxMesa)) { - /* see if we really need to update the unit */ - if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled || - envMode != fxMesa->TexState.EnvMode[0] || - envMode == GL_COMBINE_EXT || - baseFormat != fxMesa->TexState.TexFormat[0]*/) { - struct tdfx_texcombine_ext *otherEnv; - if (!SetupTexEnvNapalm(ctx, GL_TRUE, - &ctx->Texture.Unit[unit], baseFormat, - &fxMesa->TexCombineExt[0])) { - /* software fallback */ - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - /* disable other unit */ - otherEnv = &fxMesa->TexCombineExt[1]; - otherEnv->Color.SourceA = GR_CMBX_ZERO; - otherEnv->Color.ModeA = GR_FUNC_MODE_ZERO; - otherEnv->Color.SourceB = GR_CMBX_ZERO; - otherEnv->Color.ModeB = GR_FUNC_MODE_ZERO; - otherEnv->Color.SourceC = GR_CMBX_ZERO; - otherEnv->Color.InvertC = FXFALSE; - otherEnv->Color.SourceD = GR_CMBX_ZERO; - otherEnv->Color.InvertD = FXFALSE; - otherEnv->Color.Shift = 0; - otherEnv->Color.Invert = FXFALSE; - otherEnv->Alpha.SourceA = GR_CMBX_ITALPHA; - otherEnv->Alpha.ModeA = GR_FUNC_MODE_ZERO; - otherEnv->Alpha.SourceB = GR_CMBX_ITALPHA; - otherEnv->Alpha.ModeB = GR_FUNC_MODE_ZERO; - otherEnv->Alpha.SourceC = GR_CMBX_ZERO; - otherEnv->Alpha.InvertC = FXFALSE; - otherEnv->Alpha.SourceD = GR_CMBX_ZERO; - otherEnv->Alpha.InvertD = FXFALSE; - otherEnv->Alpha.Shift = 0; - otherEnv->Alpha.Invert = FXFALSE; - -#if 0/*JJJ*/ - fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled; - fxMesa->TexState.EnvMode[0] = envMode; - fxMesa->TexState.TexFormat[0] = baseFormat; - fxMesa->TexState.EnvMode[1] = 0; - fxMesa->TexState.TexFormat[1] = 0; -#endif - } - } - else { - /* Voodoo3 */ - - /* see if we really need to update the unit */ - if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled || - envMode != fxMesa->TexState.EnvMode[0] || - envMode == GL_COMBINE_EXT || - baseFormat != fxMesa->TexState.TexFormat[0]*/) { - if (!SetupSingleTexEnvVoodoo3(ctx, unit, envMode, baseFormat)) { - /* software fallback */ - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } -#if 0/*JJJ*/ - fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled; - fxMesa->TexState.EnvMode[0] = envMode; - fxMesa->TexState.TexFormat[0] = baseFormat; - fxMesa->TexState.EnvMode[1] = 0; - fxMesa->TexState.TexFormat[1] = 0; -#endif - } - } -} - - -static void -setupDoubleTMU(tdfxContextPtr fxMesa, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1) -{ -#define T0_NOT_IN_TMU 0x01 -#define T1_NOT_IN_TMU 0x02 -#define T0_IN_TMU0 0x04 -#define T1_IN_TMU0 0x08 -#define T0_IN_TMU1 0x10 -#define T1_IN_TMU1 0x20 - - const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - const GLcontext *ctx = fxMesa->glCtx; - tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0); - tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1); - GLuint tstate = 0; - int tmu0 = 0, tmu1 = 1; - - if (shared->umaTexMemory) { - if (!ti0->isInTM) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0); - assert(ti0->isInTM); - } - if (!ti1->isInTM) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0); - assert(ti1->isInTM); - } - } - else { - /* We shouldn't need to do this. There is something wrong with - multitexturing when the TMUs are swapped. So, we're forcing - them to always be loaded correctly. !!! */ - if (ti0->whichTMU == TDFX_TMU1) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj0); - if (ti1->whichTMU == TDFX_TMU0) - tdfxTMMoveOutTM_NoLock(fxMesa, tObj1); - - if (ti0->isInTM) { - switch (ti0->whichTMU) { - case TDFX_TMU0: - tstate |= T0_IN_TMU0; - break; - case TDFX_TMU1: - tstate |= T0_IN_TMU1; - break; - case TDFX_TMU_BOTH: - tstate |= T0_IN_TMU0 | T0_IN_TMU1; - break; - case TDFX_TMU_SPLIT: - tstate |= T0_NOT_IN_TMU; - break; - } - } - else - tstate |= T0_NOT_IN_TMU; - - if (ti1->isInTM) { - switch (ti1->whichTMU) { - case TDFX_TMU0: - tstate |= T1_IN_TMU0; - break; - case TDFX_TMU1: - tstate |= T1_IN_TMU1; - break; - case TDFX_TMU_BOTH: - tstate |= T1_IN_TMU0 | T1_IN_TMU1; - break; - case TDFX_TMU_SPLIT: - tstate |= T1_NOT_IN_TMU; - break; - } - } - else - tstate |= T1_NOT_IN_TMU; - - /* Move texture maps into TMUs */ - - if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) || - ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) { - if (tObj0 == tObj1) { - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU_BOTH); - } - else { - /* Find the minimal way to correct the situation */ - if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) { - /* We have one in the standard order, setup the other */ - if (tstate & T0_IN_TMU0) { - /* T0 is in TMU0, put T1 in TMU1 */ - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1); - } - else { - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0); - } - /* tmu0 and tmu1 are setup */ - } - else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) { - /* we have one in the reverse order, setup the other */ - if (tstate & T1_IN_TMU0) { - /* T1 is in TMU0, put T0 in TMU1 */ - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU1); - } - else { - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0); - } - tmu0 = 1; - tmu1 = 0; - } - else { /* Nothing is loaded */ - tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0); - tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1); - /* tmu0 and tmu1 are setup */ - } - } - } - } - - ti0->lastTimeUsed = fxMesa->texBindNumber; - ti1->lastTimeUsed = fxMesa->texBindNumber; - - - if (!ctx->Texture.SharedPalette) { - if (ti0->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti0->paltype; - fxMesa->TexPalette.Data = &(ti0->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - else if (ti1->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti1->paltype; - fxMesa->TexPalette.Data = &(ti1->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - else { - fxMesa->TexPalette.Data = NULL; - } - } - - /* - * Setup Unit 0 - */ - assert(ti0->isInTM); - assert(ti0->tm[tmu0]); - fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr; - fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu0].Info = &(ti0->info); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; - - if (fxMesa->TexParams[tmu0].sClamp != ti0->sClamp || - fxMesa->TexParams[tmu0].tClamp != ti0->tClamp || - fxMesa->TexParams[tmu0].minFilt != ti0->minFilt || - fxMesa->TexParams[tmu0].magFilt != ti0->magFilt || - fxMesa->TexParams[tmu0].mmMode != ti0->mmMode || - fxMesa->TexParams[tmu0].LODblend != FXFALSE || - fxMesa->TexParams[tmu0].LodBias != ctx->Texture.Unit[tmu0].LodBias) { - fxMesa->TexParams[tmu0].sClamp = ti0->sClamp; - fxMesa->TexParams[tmu0].tClamp = ti0->tClamp; - fxMesa->TexParams[tmu0].minFilt = ti0->minFilt; - fxMesa->TexParams[tmu0].magFilt = ti0->magFilt; - fxMesa->TexParams[tmu0].mmMode = ti0->mmMode; - fxMesa->TexParams[tmu0].LODblend = FXFALSE; - fxMesa->TexParams[tmu0].LodBias = ctx->Texture.Unit[tmu0].LodBias; - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS; - } - - /* - * Setup Unit 1 - */ - if (shared->umaTexMemory) { - ASSERT(ti1->isInTM); - ASSERT(ti1->tm[0]); - fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr; - fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu1].Info = &(ti1->info); - } - else { - ASSERT(ti1->isInTM); - ASSERT(ti1->tm[tmu1]); - fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr; - fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu1].Info = &(ti1->info); - } - - if (fxMesa->TexParams[tmu1].sClamp != ti1->sClamp || - fxMesa->TexParams[tmu1].tClamp != ti1->tClamp || - fxMesa->TexParams[tmu1].minFilt != ti1->minFilt || - fxMesa->TexParams[tmu1].magFilt != ti1->magFilt || - fxMesa->TexParams[tmu1].mmMode != ti1->mmMode || - fxMesa->TexParams[tmu1].LODblend != FXFALSE || - fxMesa->TexParams[tmu1].LodBias != ctx->Texture.Unit[tmu1].LodBias) { - fxMesa->TexParams[tmu1].sClamp = ti1->sClamp; - fxMesa->TexParams[tmu1].tClamp = ti1->tClamp; - fxMesa->TexParams[tmu1].minFilt = ti1->minFilt; - fxMesa->TexParams[tmu1].magFilt = ti1->magFilt; - fxMesa->TexParams[tmu1].mmMode = ti1->mmMode; - fxMesa->TexParams[tmu1].LODblend = FXFALSE; - fxMesa->TexParams[tmu1].LodBias = ctx->Texture.Unit[tmu1].LodBias; - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS; - } - - fxMesa->sScale0 = ti0->sScale; - fxMesa->tScale0 = ti0->tScale; - fxMesa->sScale1 = ti1->sScale; - fxMesa->tScale1 = ti1->tScale; - -#undef T0_NOT_IN_TMU -#undef T1_NOT_IN_TMU -#undef T0_IN_TMU0 -#undef T1_IN_TMU0 -#undef T0_IN_TMU1 -#undef T1_IN_TMU1 -} - -static void setupTextureDoubleTMU(GLcontext * ctx) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current; - tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0); - tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1); - struct gl_texture_image *baseImage0 = tObj0->Image[0][tObj0->BaseLevel]; - struct gl_texture_image *baseImage1 = tObj1->Image[0][tObj1->BaseLevel]; -#if 0/*JJJ*/ - const GLenum envMode0 = ctx->Texture.Unit[0].EnvMode; - const GLenum envMode1 = ctx->Texture.Unit[1].EnvMode; -#endif - - if (baseImage0->Border > 0 || baseImage1->Border > 0) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE); - return; - } - - setupDoubleTMU(fxMesa, tObj0, tObj1); - - if (ti0->reloadImages || ti1->reloadImages) - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES; - - fxMesa->tmuSrc = TDFX_TMU_BOTH; - - if (TDFX_IS_NAPALM(fxMesa)) { - /* Remember, Glide has its texture units numbered in backward - * order compared to OpenGL. - */ - GLboolean hw1 = GL_TRUE, hw2 = GL_TRUE; - - /* check if we really need to update glide unit 1 */ - if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled || - envMode0 != fxMesa->TexState.EnvMode[1] || - envMode0 == GL_COMBINE_EXT || - baseImage0->Format != fxMesa->TexState.TexFormat[1] || - (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) { - hw1 = SetupTexEnvNapalm(ctx, GL_TRUE, &ctx->Texture.Unit[0], - baseImage0->Format, &fxMesa->TexCombineExt[1]); -#if 0/*JJJ*/ - fxMesa->TexState.EnvMode[1] = envMode0; - fxMesa->TexState.TexFormat[1] = baseImage0->Format; - fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled; -#endif - } - - /* check if we really need to update glide unit 0 */ - if (1/*fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled || - envMode1 != fxMesa->TexState.EnvMode[0] || - envMode1 == GL_COMBINE_EXT || - baseImage1->Format != fxMesa->TexState.TexFormat[0] || - (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) { - hw2 = SetupTexEnvNapalm(ctx, GL_FALSE, &ctx->Texture.Unit[1], - baseImage1->Format, &fxMesa->TexCombineExt[0]); -#if 0/*JJJ*/ - fxMesa->TexState.EnvMode[0] = envMode1; - fxMesa->TexState.TexFormat[0] = baseImage1->Format; - fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled; -#endif - } - - - if (!hw1 || !hw2) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - } - else { - int unit0, unit1; - if ((ti0->whichTMU == TDFX_TMU1) || (ti1->whichTMU == TDFX_TMU0)) - unit0 = 1; - else - unit0 = 0; - unit1 = 1 - unit0; - - if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled || - fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled || - envMode0 != fxMesa->TexState.EnvMode[unit0] || - envMode0 == GL_COMBINE_EXT || - envMode1 != fxMesa->TexState.EnvMode[unit1] || - envMode1 == GL_COMBINE_EXT || - baseImage0->Format != fxMesa->TexState.TexFormat[unit0] || - baseImage1->Format != fxMesa->TexState.TexFormat[unit1] || - (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) { - - if (!SetupDoubleTexEnvVoodoo3(ctx, unit0, - ctx->Texture.Unit[0].EnvMode, baseImage0->Format, - ctx->Texture.Unit[1].EnvMode, baseImage1->Format)) { - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - -#if 0/*JJJ*/ - fxMesa->TexState.EnvMode[unit0] = envMode0; - fxMesa->TexState.TexFormat[unit0] = baseImage0->Format; - fxMesa->TexState.EnvMode[unit1] = envMode1; - fxMesa->TexState.TexFormat[unit1] = baseImage1->Format; - fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled; - fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled; -#endif - } - } -} - - -void -tdfxUpdateTextureState( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_FALSE); - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_FALSE); - - if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[1]._ReallyEnabled == 0) { - LOCK_HARDWARE( fxMesa ); /* XXX remove locking eventually */ - setupTextureSingleTMU(ctx, 0); - UNLOCK_HARDWARE( fxMesa ); - } - else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 && - ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - LOCK_HARDWARE( fxMesa ); - setupTextureSingleTMU(ctx, 1); - UNLOCK_HARDWARE( fxMesa ); - } - else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - LOCK_HARDWARE( fxMesa ); - setupTextureDoubleTMU(ctx); - UNLOCK_HARDWARE( fxMesa ); - } - else { - /* disable hardware texturing */ - if (TDFX_IS_NAPALM(fxMesa)) { - fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB; - fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertC = FXTRUE; - fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->ColorCombineExt.InvertD = FXFALSE; - fxMesa->ColorCombineExt.Shift = 0; - fxMesa->ColorCombineExt.Invert = FXFALSE; - fxMesa->AlphaCombineExt.SourceA = GR_CMBX_ITALPHA; - fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X; - fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_ZERO; - fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertC = FXTRUE; - fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO; - fxMesa->AlphaCombineExt.InvertD = FXFALSE; - fxMesa->AlphaCombineExt.Shift = 0; - fxMesa->AlphaCombineExt.Invert = FXFALSE; - } - else { - /* Voodoo 3*/ - fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->ColorCombine.Invert = FXFALSE; - fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; - fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; - fxMesa->AlphaCombine.Local = GR_COMBINE_LOCAL_ITERATED; - fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; - fxMesa->AlphaCombine.Invert = FXFALSE; - } - - fxMesa->TexState.Enabled[0] = 0; - fxMesa->TexState.Enabled[1] = 0; - fxMesa->TexState.EnvMode[0] = 0; - fxMesa->TexState.EnvMode[1] = 0; - - fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; - fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; - - if (ctx->Texture.Unit[0]._ReallyEnabled != 0 || - ctx->Texture.Unit[1]._ReallyEnabled != 0) { - /* software texture (cube map, rect tex, etc */ - FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE); - } - } -} - - - -/* - * This is a special case of texture state update. - * It's used when we've simply bound a new texture to a texture - * unit and the new texture has the exact same attributes as the - * previously bound texture. - * This is very common in Quake3. - */ -void -tdfxUpdateTextureBinding( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current; - struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current; - tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0); - tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1); - - const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - - if (ti0) { - fxMesa->sScale0 = ti0->sScale; - fxMesa->tScale0 = ti0->tScale; - if (ti0->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti0->paltype; - fxMesa->TexPalette.Data = &(ti0->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - else if (ti1 && ti1->info.format == GR_TEXFMT_P_8) { - fxMesa->TexPalette.Type = ti1->paltype; - fxMesa->TexPalette.Data = &(ti1->palette); - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; - } - } - if (ti1) { - fxMesa->sScale1 = ti1->sScale; - fxMesa->tScale1 = ti1->tScale; - } - - if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[0]._ReallyEnabled == 0) { - /* Only unit 0 2D enabled */ - if (shared->umaTexMemory) { - fxMesa->TexSource[0].StartAddress = ti0->tm[0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[0].Info = &(ti0->info); - } - else { - if (ti0->LODblend && ti0->whichTMU == TDFX_TMU_SPLIT) { - fxMesa->TexSource[0].StartAddress = ti0->tm[TDFX_TMU0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD; - fxMesa->TexSource[0].Info = &(ti0->info); - fxMesa->TexSource[1].StartAddress = ti0->tm[TDFX_TMU1]->startAddr; - fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN; - fxMesa->TexSource[1].Info = &(ti0->info); - } - else { - FxU32 tmu; - if (ti0->whichTMU == TDFX_TMU_BOTH) - tmu = TDFX_TMU0; - else - tmu = ti0->whichTMU; - fxMesa->TexSource[0].Info = NULL; - fxMesa->TexSource[1].Info = NULL; - if (ti0->tm[tmu]) { - fxMesa->TexSource[tmu].StartAddress = ti0->tm[tmu]->startAddr; - fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu].Info = &(ti0->info); - } - } - } - } - else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 && - ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - /* Only unit 1 2D enabled */ - if (shared->umaTexMemory) { - fxMesa->TexSource[0].StartAddress = ti1->tm[0]->startAddr; - fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[0].Info = &(ti1->info); - } - } - else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) && - ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) { - /* Both 2D enabled */ - if (shared->umaTexMemory) { - const FxU32 tmu0 = 0, tmu1 = 1; - fxMesa->TexSource[tmu0].StartAddress = ti0->tm[0]->startAddr; - fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu0].Info = &(ti0->info); - - fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr; - fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu1].Info = &(ti1->info); - } - else { - const FxU32 tmu0 = 0, tmu1 = 1; - fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr; - fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu0].Info = &(ti0->info); - - fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr; - fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; - fxMesa->TexSource[tmu1].Info = &(ti1->info); - } - } - - - fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h deleted file mode 100644 index 234ed4439..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.h,v 1.1 2002/02/22 21:45:04 dawes Exp $ */ - -/* - * Original rewrite: - * Gareth Hughes , 29 Sep - 1 Oct 2000 - * - * Authors: - * Gareth Hughes - * Brian Paul - * - */ - -#ifndef __TDFX_TEXSTATE_H__ -#define __TDFX_TEXSTATE_H__ - -extern void tdfxUpdateTextureState( GLcontext *ctx ); -extern void tdfxUpdateTextureBinding( GLcontext *ctx ); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c deleted file mode 100644 index ac8daf474..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c +++ /dev/null @@ -1,1293 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS 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. - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c,v 1.4 2002/10/30 12:52:01 alanh Exp $ */ - -/* New fixes: - * Daniel Borca , 19 Jul 2004 - * - * Authors: - * Keith Whitwell - */ - -#include "glheader.h" -#include "mtypes.h" -#include "macros.h" -#include "colormac.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "swrast_setup/ss_context.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - -#include "tdfx_tris.h" -#include "tdfx_state.h" -#include "tdfx_vb.h" -#include "tdfx_lock.h" -#include "tdfx_render.h" - - -static void tdfxRasterPrimitive( GLcontext *ctx, GLenum prim ); -static void tdfxRenderPrimitive( GLcontext *ctx, GLenum prim ); - -static GLenum reduced_prim[GL_POLYGON+1] = { - GL_POINTS, - GL_LINES, - GL_LINES, - GL_LINES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES -}; - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( a, b, c ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_triangle( fxMesa, a, b, c ); \ - else \ - fxMesa->Glide.grDrawTriangle( a, b, c ); \ -} while (0) \ - -#define QUAD( a, b, c, d ) \ -do { \ - if (DO_FALLBACK) { \ - fxMesa->draw_triangle( fxMesa, a, b, d ); \ - fxMesa->draw_triangle( fxMesa, b, c, d ); \ - } else { \ - tdfxVertex *_v_[4]; \ - _v_[0] = d; \ - _v_[1] = a; \ - _v_[2] = b; \ - _v_[3] = c; \ - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ - /*fxMesa->Glide.grDrawTriangle( a, b, d );*/\ - /*fxMesa->Glide.grDrawTriangle( b, c, d );*/\ - } \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_line( fxMesa, v0, v1 ); \ - else { \ - v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \ - v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \ - v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \ - v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \ - fxMesa->Glide.grDrawLine( v0, v1 ); \ - v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \ - v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \ - v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \ - v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \ - } \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - fxMesa->draw_point( fxMesa, v0 ); \ - else { \ - v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \ - v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \ - fxMesa->Glide.grDrawPoint( v0 ); \ - v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \ - v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \ - } \ -} while (0) - - -/*********************************************************************** - * Fallback to swrast for basic primitives * - ***********************************************************************/ - -/* Build an SWvertex from a hardware vertex. - * - * This code is hit only when a mix of accelerated and unaccelerated - * primitives are being drawn, and only for the unaccelerated - * primitives. - */ -static void -tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) { - dst->win[0] = src->x - fxMesa->x_offset; - dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset); - dst->win[2] = src->z; - dst->win[3] = 1.0; - - dst->color[0] = src->color[2]; - dst->color[1] = src->color[1]; - dst->color[2] = src->color[0]; - dst->color[3] = src->color[3]; - } - else { - GLfloat w = 1.0 / src->rhw; - - dst->win[0] = src->x - fxMesa->x_offset; - dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset); - dst->win[2] = src->z; - dst->win[3] = src->rhw; - - dst->color[0] = src->color[2]; - dst->color[1] = src->color[1]; - dst->color[2] = src->color[0]; - dst->color[3] = src->color[3]; - - dst->texcoord[0][0] = 1.0 / fxMesa->sScale0 * w * src->tu0; - dst->texcoord[0][1] = 1.0 / fxMesa->tScale0 * w * src->tv0; - if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ1 || fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) { - dst->texcoord[0][3] = w * src->tq0; - } else { - dst->texcoord[0][3] = 1.0; - } - - if (fxMesa->SetupIndex & TDFX_TEX1_BIT) { - dst->texcoord[1][0] = 1.0 / fxMesa->sScale1 * w * src->tu1; - dst->texcoord[1][1] = 1.0 / fxMesa->tScale1 * w * src->tv1; - if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) { - dst->texcoord[1][3] = w * src->tq1; - } else { - dst->texcoord[1][3] = 1.0; - } - } - } - - dst->pointSize = ctx->Point._Size; -} - - -static void -tdfx_fallback_tri( tdfxContextPtr fxMesa, - tdfxVertex *v0, - tdfxVertex *v1, - tdfxVertex *v2 ) -{ - GLcontext *ctx = fxMesa->glCtx; - SWvertex v[3]; - tdfx_translate_vertex( ctx, v0, &v[0] ); - tdfx_translate_vertex( ctx, v1, &v[1] ); - tdfx_translate_vertex( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - - -static void -tdfx_fallback_line( tdfxContextPtr fxMesa, - tdfxVertex *v0, - tdfxVertex *v1 ) -{ - GLcontext *ctx = fxMesa->glCtx; - SWvertex v[2]; - tdfx_translate_vertex( ctx, v0, &v[0] ); - tdfx_translate_vertex( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -static void -tdfx_fallback_point( tdfxContextPtr fxMesa, - tdfxVertex *v0 ) -{ - GLcontext *ctx = fxMesa->glCtx; - SWvertex v[1]; - tdfx_translate_vertex( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} - -/*********************************************************************** - * Functions to draw basic primitives * - ***********************************************************************/ - -static void tdfx_print_vertex( GLcontext *ctx, const tdfxVertex *v ) -{ - tdfxContextPtr tmesa = TDFX_CONTEXT( ctx ); - - fprintf(stderr, "vertex at %p\n", (void *)v); - - if (tmesa->vertexFormat == TDFX_LAYOUT_TINY) { - fprintf(stderr, "x %f y %f z %f\n", v->x, v->y, v->z); - } - else { - fprintf(stderr, "x %f y %f z %f oow %f\n", - v->x, v->y, v->z, v->rhw); - } - fprintf(stderr, "r %d g %d b %d a %d\n", - v->color[0], - v->color[1], - v->color[2], - v->color[3]); - - fprintf(stderr, "\n"); -} - -#define DO_FALLBACK 0 - -/* Need to do clip loop at each triangle when mixing swrast and hw - * rendering. These functions are only used when mixed-mode rendering - * is occurring. - */ -static void tdfx_draw_triangle( tdfxContextPtr fxMesa, - tdfxVertexPtr v0, - tdfxVertexPtr v1, - tdfxVertexPtr v2 ) -{ -/* fprintf(stderr, "%s\n", __FUNCTION__); */ -/* tdfx_print_vertex( fxMesa->glCtx, v0 ); */ -/* tdfx_print_vertex( fxMesa->glCtx, v1 ); */ -/* tdfx_print_vertex( fxMesa->glCtx, v2 ); */ - BEGIN_CLIP_LOOP_LOCKED(fxMesa) { - TRI( v0, v1, v2 ); - } END_CLIP_LOOP_LOCKED(fxMesa); -} - -static void tdfx_draw_line( tdfxContextPtr fxMesa, - tdfxVertexPtr v0, - tdfxVertexPtr v1 ) -{ - /* No support for wide lines (avoid wide/aa line fallback). - */ - BEGIN_CLIP_LOOP_LOCKED(fxMesa) { - LINE(v0, v1); - } END_CLIP_LOOP_LOCKED(fxMesa); -} - -static void tdfx_draw_point( tdfxContextPtr fxMesa, - tdfxVertexPtr v0 ) -{ - /* No support for wide points. - */ - BEGIN_CLIP_LOOP_LOCKED(fxMesa) { - POINT( v0 ); - } END_CLIP_LOOP_LOCKED(fxMesa); -} - -#undef DO_FALLBACK - - -#define TDFX_UNFILLED_BIT 0x1 -#define TDFX_OFFSET_BIT 0x2 -#define TDFX_TWOSIDE_BIT 0x4 -#define TDFX_FLAT_BIT 0x8 -#define TDFX_FALLBACK_BIT 0x10 -#define TDFX_MAX_TRIFUNC 0x20 - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[TDFX_MAX_TRIFUNC]; - -#define DO_FALLBACK (IND & TDFX_FALLBACK_BIT) -#define DO_OFFSET (IND & TDFX_OFFSET_BIT) -#define DO_UNFILLED (IND & TDFX_UNFILLED_BIT) -#define DO_TWOSIDE (IND & TDFX_TWOSIDE_BIT) -#define DO_FLAT (IND & TDFX_FLAT_BIT) -#define DO_TRI 1 -#define DO_QUAD 1 -#define DO_LINE 1 -#define DO_POINTS 1 -#define DO_FULL_QUAD 1 - -#define HAVE_RGBA 1 -#define HAVE_SPEC 0 -#define HAVE_HW_FLATSHADE 0 -#define HAVE_BACK_COLORS 0 -#define VERTEX tdfxVertex -#define TAB rast_tab - -#define DEPTH_SCALE 1.0 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) _v->x -#define VERT_Y(_v) _v->y -#define VERT_Z(_v) _v->z -#define AREA_IS_CCW( a ) (a < 0) -#define GET_VERTEX(e) (fxMesa->verts + (e)) - -#define VERT_SET_RGBA( dst, f ) \ -do { \ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[2], f[0]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[1], f[1]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[0], f[2]);\ - UNCLAMPED_FLOAT_TO_UBYTE(dst->color[3], f[3]);\ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) \ - *(GLuint *)&v0->color = *(GLuint *)&v1->color - -#define VERT_SAVE_RGBA( idx ) \ - *(GLuint *)&color[idx] = *(GLuint *)&v[idx]->color - -#define VERT_RESTORE_RGBA( idx ) \ - *(GLuint *)&v[idx]->color = *(GLuint *)&color[idx] - -#define LOCAL_VARS(n) \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - GLubyte color[n][4]; \ - (void) color; - - - -/*********************************************************************** - * Functions to draw basic unfilled primitives * - ***********************************************************************/ - -#define RASTERIZE(x) if (fxMesa->raster_primitive != reduced_prim[x]) \ - tdfxRasterPrimitive( ctx, reduced_prim[x] ) -#define RENDER_PRIMITIVE fxMesa->render_primitive -#define IND TDFX_FALLBACK_BIT -#define TAG(x) x -#include "tnl_dd/t_dd_unfilled.h" -#undef IND - -/*********************************************************************** - * Functions to draw GL primitives * - ***********************************************************************/ - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \ - TDFX_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - - -/* Tdfx doesn't support provoking-vertex flat-shading? - */ -#define IND (TDFX_FLAT_BIT) -#define TAG(x) x##_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_offset_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_UNFILLED_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_offset_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_unfilled_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_offset_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_offset_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \ - TDFX_FALLBACK_BIT|TDFX_FLAT_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback_flat -#include "tnl_dd/t_dd_tritmp.h" - - -static void init_rast_tab( void ) -{ - init(); - init_offset(); - init_twoside(); - init_twoside_offset(); - init_unfilled(); - init_offset_unfilled(); - init_twoside_unfilled(); - init_twoside_offset_unfilled(); - init_fallback(); - init_offset_fallback(); - init_twoside_fallback(); - init_twoside_offset_fallback(); - init_unfilled_fallback(); - init_offset_unfilled_fallback(); - init_twoside_unfilled_fallback(); - init_twoside_offset_unfilled_fallback(); - - init_flat(); - init_offset_flat(); - init_twoside_flat(); - init_twoside_offset_flat(); - init_unfilled_flat(); - init_offset_unfilled_flat(); - init_twoside_unfilled_flat(); - init_twoside_offset_unfilled_flat(); - init_fallback_flat(); - init_offset_fallback_flat(); - init_twoside_fallback_flat(); - init_twoside_offset_fallback_flat(); - init_unfilled_fallback_flat(); - init_offset_unfilled_fallback_flat(); - init_twoside_unfilled_fallback_flat(); - init_twoside_offset_unfilled_fallback_flat(); -} - - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - - -/* Accelerate vertex buffer rendering when renderindex == 0 and - * there is no clipping. - */ -#define INIT(x) tdfxRenderPrimitive( ctx, x ) - -static void tdfx_render_vb_points( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - INIT(GL_POINTS); - - /* Adjust point coords */ - for (i = start; i < count; i++) { - fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_POINTS, count-start, - fxVB + start, sizeof(tdfxVertex)); - /* restore point coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_line_strip( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - INIT(GL_LINE_STRIP); - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start, - fxVB + start, sizeof(tdfxVertex) ); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_line_loop( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - GLint j = start; - (void) flags; - - INIT(GL_LINE_LOOP); - - if (!(flags & PRIM_BEGIN)) { - j++; - } - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j, - fxVB + j, sizeof(tdfxVertex)); - - if (flags & PRIM_END) - fxMesa->Glide.grDrawLine( fxVB + (count - 1), - fxVB + start ); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_lines( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLint i; - (void) flags; - - INIT(GL_LINES); - - /* adjust line coords */ - for (i = start; i < count; i++) { - fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET; - } - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINES, count-start, - fxVB + start, sizeof(tdfxVertex)); - - /* restore line coords */ - for (i = start; i < count; i++) { - fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET; - fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET; - } -} - -static void tdfx_render_vb_triangles( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_TRIANGLES); - -#if 0 - /* [dBorca] - * apparently, this causes troubles with some programs (GLExcess); - * might be a bug in Glide... However, "grDrawVertexArrayContiguous" - * eventually calls "grDrawTriangle" for GR_TRIANGLES, so we're better - * off doing it by hand... - */ - fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLES, count-start, - fxVB + start, sizeof(tdfxVertex)); -#else - { - GLuint j; - for (j=start+2; jGlide.grDrawTriangle(fxVB + (j-2), fxVB + (j-1), fxVB + j); - } - } -#endif -} - - -static void tdfx_render_vb_tri_strip( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - int mode; - (void) flags; - - INIT(GL_TRIANGLE_STRIP); - -/* fprintf(stderr, "%s/%d\n", __FUNCTION__, 1<Glide.grDrawVertexArrayContiguous( mode, count-start, - fxVB + start, sizeof(tdfxVertex)); -} - - -static void tdfx_render_vb_tri_fan( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_TRIANGLE_FAN); - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start, - fxVB + start, sizeof(tdfxVertex) ); -} - -static void tdfx_render_vb_quads( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - GLuint i; - (void) flags; - - INIT(GL_QUADS); - - for (i = start + 3 ; i < count ; i += 4 ) { -#define VERT(x) (fxVB + (x)) - tdfxVertex *_v_[4]; - _v_[0] = VERT(i); - _v_[1] = VERT(i-3); - _v_[2] = VERT(i-2); - _v_[3] = VERT(i-1); - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_); - /*fxMesa->Glide.grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/ - /*fxMesa->Glide.grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/ -#undef VERT - } -} - -static void tdfx_render_vb_quad_strip( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_QUAD_STRIP); - - count -= (count-start)&1; - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, - count-start, fxVB + start, sizeof(tdfxVertex)); -} - -static void tdfx_render_vb_poly( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - tdfxVertex *fxVB = fxMesa->verts; - (void) flags; - - INIT(GL_POLYGON); - - fxMesa->Glide.grDrawVertexArrayContiguous( GR_POLYGON, count-start, - fxVB + start, sizeof(tdfxVertex)); -} - -static void tdfx_render_vb_noop( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - (void) (ctx && start && count && flags); -} - -static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *, - GLuint, - GLuint, - GLuint) = -{ - tdfx_render_vb_points, - tdfx_render_vb_lines, - tdfx_render_vb_line_loop, - tdfx_render_vb_line_strip, - tdfx_render_vb_triangles, - tdfx_render_vb_tri_strip, - tdfx_render_vb_tri_fan, - tdfx_render_vb_quads, - tdfx_render_vb_quad_strip, - tdfx_render_vb_poly, - tdfx_render_vb_noop, -}; -#undef INIT - - -/**********************************************************************/ -/* Render whole (indexed) begin/end objects */ -/**********************************************************************/ - - -#define VERT(x) (tdfxVertex *)(vertptr + (x)) - -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - fxMesa->Glide.grDrawPoint( VERT(ELT(start)) ); - -#define RENDER_LINE( v0, v1 ) \ - fxMesa->Glide.grDrawLine( VERT(v0), VERT(v1) ) - -#define RENDER_TRI( v0, v1, v2 ) \ - fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) ) - -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - do { \ - tdfxVertex *_v_[4]; \ - _v_[0] = VERT(v3); \ - _v_[1] = VERT(v0); \ - _v_[2] = VERT(v1); \ - _v_[3] = VERT(v2); \ - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\ - /*fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\ - /*fxMesa->Glide.grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\ - } while (0) - -#define INIT(x) tdfxRenderPrimitive( ctx, x ) - -#undef LOCAL_VARS -#define LOCAL_VARS \ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \ - tdfxVertex *vertptr = fxMesa->verts; \ - const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ - (void) elt; - -#define RESET_STIPPLE -#define RESET_OCCLUSION -#define PRESERVE_VB_DEFS - -/* Elts, no clipping. - */ -#undef ELT -#undef TAG -#define TAG(x) tdfx_##x##_elts -#define ELT(x) elt[x] -#include "tnl_dd/t_dd_rendertmp.h" - -/* Verts, no clipping. - */ -#undef ELT -#undef TAG -#define TAG(x) tdfx_##x##_verts -#define ELT(x) x -/*#include "tnl_dd/t_dd_rendertmp.h"*/ - - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - - - -static void tdfxRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint prim = fxMesa->render_primitive; - - /* Render the new vertices as an unclipped polygon. - */ - { - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); - VB->Elts = tmp; - } - - /* Restore the render primitive - */ - if (prim != GL_POLYGON) - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); -} - -static void tdfxRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -static void tdfxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - int i; - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - tdfxVertex *vertptr = fxMesa->verts; - if (n == 3) { - fxMesa->Glide.grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) ); - } else if (n <= 32) { - tdfxVertex *newvptr[32]; - for (i = 0 ; i < n ; i++) { - newvptr[i] = VERT(elts[i]); - } - fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr); - } else { - const tdfxVertex *start = VERT(elts[0]); - for (i = 2 ; i < n ; i++) { - fxMesa->Glide.grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) ); - } - } -} - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - -#define POINT_FALLBACK (DD_POINT_SMOOTH) -#define LINE_FALLBACK (DD_LINE_STIPPLE) -#define TRI_FALLBACK (DD_TRI_SMOOTH) -#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE) -#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \ - DD_TRI_UNFILLED) - - -/* All state referenced below: - */ -#define _TDFX_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \ - _DD_NEW_LINE_STIPPLE | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_FLATSHADE | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET | \ - _DD_NEW_TRI_STIPPLE | \ - _NEW_POLYGONSTIPPLE) - - -static void tdfxChooseRenderState(GLcontext *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (0) { - fxMesa->draw_point = tdfx_draw_point; - fxMesa->draw_line = tdfx_draw_line; - fxMesa->draw_triangle = tdfx_draw_triangle; - index |= TDFX_FALLBACK_BIT; - } - - if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) { - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TDFX_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= TDFX_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= TDFX_UNFILLED_BIT; - if (flags & DD_FLATSHADE) index |= TDFX_FLAT_BIT; - } - - fxMesa->draw_point = tdfx_draw_point; - fxMesa->draw_line = tdfx_draw_line; - fxMesa->draw_triangle = tdfx_draw_triangle; - - /* Hook in fallbacks for specific primitives. - * - * DD_TRI_UNFILLED is here because the unfilled_tri functions use - * fxMesa->draw_tri *always*, and thus can't use the multipass - * approach to cliprects. - * - */ - if (flags & (POINT_FALLBACK| - LINE_FALLBACK| - TRI_FALLBACK| - DD_TRI_STIPPLE| - DD_TRI_UNFILLED)) - { - if (flags & POINT_FALLBACK) - fxMesa->draw_point = tdfx_fallback_point; - - if (flags & LINE_FALLBACK) - fxMesa->draw_line = tdfx_fallback_line; - - if (flags & TRI_FALLBACK) - fxMesa->draw_triangle = tdfx_fallback_tri; - - if ((flags & DD_TRI_STIPPLE) && !fxMesa->haveHwStipple) - fxMesa->draw_triangle = tdfx_fallback_tri; - - index |= TDFX_FALLBACK_BIT; - } - } - - if (fxMesa->RenderIndex != index) { - fxMesa->RenderIndex = index; - - tnl->Driver.Render.Points = rast_tab[index].points; - tnl->Driver.Render.Line = rast_tab[index].line; - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (index == 0) { - tnl->Driver.Render.PrimTabVerts = tdfx_render_tab_verts; - tnl->Driver.Render.PrimTabElts = tdfx_render_tab_elts; - tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */ - tnl->Driver.Render.ClippedPolygon = tdfxFastRenderClippedPoly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = tdfxRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = tdfxRenderClippedPoly; - } - } -} - -/**********************************************************************/ -/* Use multipass rendering for cliprects */ -/**********************************************************************/ - - - -/* TODO: Benchmark this. - * TODO: Use single back-buffer cliprect where possible. - * NOTE: starts at 1, not zero! - */ -static GLboolean multipass_cliprect( GLcontext *ctx, GLuint pass ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - if (pass >= fxMesa->numClipRects) - return GL_FALSE; - else { - fxMesa->Glide.grClipWindow(fxMesa->pClipRects[pass].x1, - fxMesa->screen_height - fxMesa->pClipRects[pass].y2, - fxMesa->pClipRects[pass].x2, - fxMesa->screen_height - fxMesa->pClipRects[pass].y1); - - return GL_TRUE; - } -} - - -/**********************************************************************/ -/* Runtime render state and callbacks */ -/**********************************************************************/ - -static void tdfxRunPipeline( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (fxMesa->new_state) { - tdfxDDUpdateHwState( ctx ); - } - - if (!fxMesa->Fallback && fxMesa->new_gl_state) { - if (fxMesa->new_gl_state & _TDFX_NEW_RASTERSETUP) - tdfxChooseVertexState( ctx ); - - if (fxMesa->new_gl_state & _TDFX_NEW_RENDERSTATE) - tdfxChooseRenderState( ctx ); - - fxMesa->new_gl_state = 0; - } - - _tnl_run_pipeline( ctx ); -} - - -static void tdfxRenderStart( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - tdfxCheckTexSizes( ctx ); - - LOCK_HARDWARE(fxMesa); - - /* Make sure vertex format changes get uploaded before we start - * sending triangles. - */ - if (fxMesa->dirty) { - tdfxEmitHwStateLocked( fxMesa ); - } - - if (fxMesa->numClipRects && !(fxMesa->RenderIndex & TDFX_FALLBACK_BIT)) { - fxMesa->Glide.grClipWindow(fxMesa->pClipRects[0].x1, - fxMesa->screen_height - fxMesa->pClipRects[0].y2, - fxMesa->pClipRects[0].x2, - fxMesa->screen_height - fxMesa->pClipRects[0].y1); - if (fxMesa->numClipRects > 1) - tnl->Driver.Render.Multipass = multipass_cliprect; - else - tnl->Driver.Render.Multipass = NULL; - } - else - tnl->Driver.Render.Multipass = NULL; -} - - - -/* Always called between RenderStart and RenderFinish --> We already - * hold the lock. - */ -static void tdfxRasterPrimitive( GLcontext *ctx, GLenum prim ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - FLUSH_BATCH( fxMesa ); - - fxMesa->raster_primitive = prim; - - tdfxUpdateCull(ctx); - if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) { - fxMesa->Glide.grCullMode( fxMesa->CullMode ); - fxMesa->dirty &= ~TDFX_UPLOAD_CULL; - } - - tdfxUpdateStipple(ctx); - if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE ) { - fxMesa->Glide.grStipplePattern ( fxMesa->Stipple.Pattern ); - fxMesa->Glide.grStippleMode ( fxMesa->Stipple.Mode ); - fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE; - } -} - - - -/* Determine the rasterized primitive when not drawing unfilled - * polygons. - * - * Used only for the default render stage which always decomposes - * primitives to trianges/lines/points. For the accelerated stage, - * which renders strips as strips, the equivalent calculations are - * performed in tdfx_render.c. - */ -static void tdfxRenderPrimitive( GLcontext *ctx, GLenum prim ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLuint rprim = reduced_prim[prim]; - - fxMesa->render_primitive = prim; - - if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) - return; - - if (fxMesa->raster_primitive != rprim) { - tdfxRasterPrimitive( ctx, rprim ); - } -} - -static void tdfxRenderFinish( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - - if (fxMesa->RenderIndex & TDFX_FALLBACK_BIT) - _swrast_flush( ctx ); - - UNLOCK_HARDWARE(fxMesa); -} - - -/**********************************************************************/ -/* Manage total rasterization fallbacks */ -/**********************************************************************/ - -static char *fallbackStrings[] = { - "3D/Rect/Cube Texture map", - "glDrawBuffer(GL_FRONT_AND_BACK)", - "Separate specular color", - "glEnable/Disable(GL_STENCIL_TEST)", - "glRenderMode(selection or feedback)", - "glLogicOp()", - "Texture env mode", - "Texture border", - "glColorMask", - "blend mode", - "line stipple", - "Rasterization disable" -}; - - -static char *getFallbackString(GLuint bit) -{ - int i = 0; - while (bit > 1) { - i++; - bit >>= 1; - } - return fallbackStrings[i]; -} - - -void tdfxFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLuint oldfallback = fxMesa->Fallback; - - if (mode) { - fxMesa->Fallback |= bit; - if (oldfallback == 0) { - /*printf("Go to software rendering, bit = 0x%x\n", bit);*/ - FLUSH_BATCH(fxMesa); - _swsetup_Wakeup( ctx ); - fxMesa->RenderIndex = ~0; - if (TDFX_DEBUG & DEBUG_VERBOSE_FALL) { - fprintf(stderr, "Tdfx begin software fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } - else { - fxMesa->Fallback &= ~bit; - if (oldfallback == bit) { - /*printf("Go to hardware rendering, bit = 0x%x\n", bit);*/ - _swrast_flush( ctx ); - tnl->Driver.Render.Start = tdfxRenderStart; - tnl->Driver.Render.PrimitiveNotify = tdfxRenderPrimitive; - tnl->Driver.Render.Finish = tdfxRenderFinish; - tnl->Driver.Render.BuildVertices = tdfxBuildVertices; - fxMesa->new_gl_state |= (_TDFX_NEW_RENDERSTATE| - _TDFX_NEW_RASTERSETUP); - if (TDFX_DEBUG & DEBUG_VERBOSE_FALL) { - fprintf(stderr, "Tdfx end software fallback: 0x%x %s\n", - bit, getFallbackString(bit)); - } - } - } -} - - -void tdfxDDInitTriFuncs( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - } - - fxMesa->RenderIndex = ~0; - - tnl->Driver.RunPipeline = tdfxRunPipeline; - tnl->Driver.Render.Start = tdfxRenderStart; - tnl->Driver.Render.Finish = tdfxRenderFinish; - tnl->Driver.Render.PrimitiveNotify = tdfxRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = tdfxBuildVertices; - tnl->Driver.Render.Multipass = NULL; - - (void) tdfx_print_vertex; -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h deleted file mode 100644 index 57e5d9b0a..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- - * - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Authors: - * Keith Whitwell - * - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h,v 1.5 2002/10/30 12:52:01 alanh Exp $ */ - -#ifndef TDFX_TRIS_INC -#define TDFX_TRIS_INC - -#include "mtypes.h" - -extern void tdfxDDInitTriFuncs( GLcontext *ctx ); - - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c deleted file mode 100644 index 0580135d1..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * GLX Hardware Device Driver for Intel i810 - * Copyright (C) 1999 Keith Whitwell - * - * 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 - * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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. - * - * - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c,v 1.3 2002/10/30 12:52:01 alanh Exp $ */ - -#include "glheader.h" -#include "mtypes.h" -#include "imports.h" -#include "macros.h" -#include "colormac.h" - -#include "math/m_translate.h" -#include "swrast_setup/swrast_setup.h" - -#include "tdfx_context.h" -#include "tdfx_vb.h" -#include "tdfx_tris.h" -#include "tdfx_state.h" -#include "tdfx_render.h" - -static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - tdfxVertex *dst = fxMesa->verts + edst; - tdfxVertex *src = fxMesa->verts + esrc; - *(GLuint *)&dst->color = *(GLuint *)&src->color; -} - -static struct { - void (*emit)( GLcontext *, GLuint, GLuint, void * ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( GLcontext *ctx ); - GLuint vertex_format; -} setup_tab[TDFX_MAX_SETUP]; - - - - -#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) - - -static void interp_extras( GLcontext *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /*fprintf(stderr, "%s\n", __FUNCTION__);*/ - - if (VB->ColorPtr[1]) { - INTERP_4F( t, - GET_COLOR(VB->ColorPtr[1], dst), - GET_COLOR(VB->ColorPtr[1], out), - GET_COLOR(VB->ColorPtr[1], in) ); - } - - if (VB->EdgeFlag) { - VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; - } - - setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in, - force_boundary); -} - -static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->ColorPtr[1]) { - COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), - GET_COLOR(VB->ColorPtr[1], src) ); - } - - setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src); -} - - - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT) -#define TAG(x) x##_wg -#include "tdfx_vbtmp.h" - -/* Special for tdfx: fog requires w - */ -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT) -#define TAG(x) x##_wg_fog -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT) -#define TAG(x) x##_wgt0t1 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\ - TDFX_PTEX_BIT) -#define TAG(x) x##_wgpt0t1 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_RGBA_BIT) -#define TAG(x) x##_g -#include "tdfx_vbtmp.h" - -#define IND (TDFX_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_TEX0_BIT|TDFX_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tdfx_vbtmp.h" - -#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "tdfx_vbtmp.h" - - -/* fogc { */ -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgf -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgt0f -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgt0t1f -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgpt0f -#include "tdfx_vbtmp.h" - -#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\ - TDFX_PTEX_BIT|TDFX_FOGC_BIT) -#define TAG(x) x##_wgpt0t1f -#include "tdfx_vbtmp.h" -/* fogc } */ - - -static void init_setup_tab( void ) -{ - init_wg(); - init_wg_fog(); - init_wgt0(); - init_wgt0t1(); - init_wgpt0(); - init_wgpt0t1(); - - init_g(); - init_t0(); - init_t0t1(); - init_gt0(); - init_gt0t1(); - - /* fogcoord */ - init_wgf(); - init_wgt0f(); - init_wgt0t1f(); - init_wgpt0f(); - init_wgpt0t1f(); -} - - -void tdfxPrintSetupFlags(char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n", - msg, - (int)flags, - (flags & TDFX_XYZ_BIT) ? " xyz," : "", - (flags & TDFX_W_BIT) ? " w," : "", - (flags & TDFX_RGBA_BIT) ? " rgba," : "", - (flags & TDFX_TEX0_BIT) ? " tex-0," : "", - (flags & TDFX_TEX1_BIT) ? " tex-1," : "", - (flags & TDFX_FOGC_BIT) ? " fogc," : ""); -} - - - -void tdfxCheckTexSizes( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - - if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) { - GLuint ind = fxMesa->SetupIndex |= (TDFX_PTEX_BIT|TDFX_RGBA_BIT); - - /* Tdfx handles projective textures nicely; just have to change - * up to the new vertex format. - */ - if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) { - FLUSH_BATCH(fxMesa); - fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT; - fxMesa->vertexFormat = setup_tab[ind].vertex_format; - - /* This is required as we have just changed the vertex - * format, so the interp and copy routines must also change. - * In the unfilled and twosided cases we are using the - * swrast_setup ones anyway, so leave them in place. - */ - if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[fxMesa->SetupIndex].copy_pv; - } - } - } -} - - -void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint end, - GLuint newinputs ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - tdfxVertex *v = fxMesa->verts + start; - - newinputs |= fxMesa->SetupNewInputs; - fxMesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= TDFX_RGBA_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= TDFX_FOGC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= TDFX_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= TDFX_TEX0_BIT|TDFX_TEX1_BIT; - - if (fxMesa->SetupIndex & TDFX_PTEX_BIT) - ind = ~0; - - ind &= fxMesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, end, v ); - } - } -} - - -void tdfxChooseVertexState( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - GLuint ind = TDFX_XYZ_BIT|TDFX_RGBA_BIT; - - fxMesa->tmu_source[0] = 0; - fxMesa->tmu_source[1] = 1; - - if (ctx->Texture._EnabledUnits & 0x2) { - if (ctx->Texture._EnabledUnits & 0x1) { - ind |= TDFX_TEX1_BIT; - } - ind |= TDFX_W_BIT|TDFX_TEX0_BIT; - fxMesa->tmu_source[0] = 1; - fxMesa->tmu_source[1] = 0; - } else if (ctx->Texture._EnabledUnits & 0x1) { - /* unit 0 enabled */ - ind |= TDFX_W_BIT|TDFX_TEX0_BIT; - } else if (fxMesa->Fog.Mode != GR_FOG_DISABLE) { - ind |= TDFX_W_BIT; - } - - if (fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT) { - ind |= TDFX_FOGC_BIT; - } - - fxMesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = interp_extras; - tnl->Driver.Render.CopyPV = copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } - - if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) { - FLUSH_BATCH(fxMesa); - fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT; - fxMesa->vertexFormat = setup_tab[ind].vertex_format; - } -} - - - -void tdfxInitVB( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - - fxMesa->verts = ALIGN_MALLOC(size * sizeof(tdfxVertex), 32); - fxMesa->vertexFormat = TDFX_LAYOUT_TINY; - fxMesa->SetupIndex = TDFX_XYZ_BIT|TDFX_RGBA_BIT; -} - - -void tdfxFreeVB( GLcontext *ctx ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - if (fxMesa->verts) { - ALIGN_FREE(fxMesa->verts); - fxMesa->verts = 0; - } -} diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h deleted file mode 100644 index 7b7cd9065..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * GLX Hardware Device Driver for Intel tdfx - * Copyright (C) 1999 Keith Whitwell - * - * 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 - * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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. - * - * - */ -/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */ - -#ifndef TDFXVB_INC -#define TDFXVB_INC - -#include "mtypes.h" - -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "math/m_xform.h" - -#define TDFX_XYZ_BIT 0x1 -#define TDFX_W_BIT 0x2 -#define TDFX_RGBA_BIT 0x4 -#define TDFX_TEX1_BIT 0x8 -#define TDFX_TEX0_BIT 0x10 -#define TDFX_PTEX_BIT 0x20 -#define TDFX_FOGC_BIT 0x40 -#define TDFX_MAX_SETUP 0x80 - -#define _TDFX_NEW_RASTERSETUP (_NEW_TEXTURE | \ - _DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _NEW_FOG) - - -extern void tdfxValidateBuildProjVerts(GLcontext *ctx, - GLuint start, GLuint count, - GLuint newinputs ); - -extern void tdfxPrintSetupFlags(char *msg, GLuint flags ); - -extern void tdfxInitVB( GLcontext *ctx ); - -extern void tdfxFreeVB( GLcontext *ctx ); - -extern void tdfxCheckTexSizes( GLcontext *ctx ); - -extern void tdfxChooseVertexState( GLcontext *ctx ); - -extern void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint end, - GLuint newinputs ); - -#endif diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h deleted file mode 100644 index 9b780761f..000000000 --- a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Authors: - * Keith Whitwell - * Daniel Borca - */ - - -#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] -#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] -#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] - - -static void TAG(emit)( GLcontext *ctx, - GLuint start, GLuint end, - void *dest ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLuint tmu0_source = fxMesa->tmu_source[0]; - GLuint tmu1_source = fxMesa->tmu_source[1]; - GLfloat (*tc0)[4], (*tc1)[4]; - GLfloat (*col)[4]; - GLuint tc0_stride, tc1_stride, col_stride; - GLuint tc0_size, tc1_size, col_size; - GLfloat (*proj)[4] = VB->NdcPtr->data; - GLuint proj_stride = VB->NdcPtr->stride; - GLfloat (*fog)[4]; - GLuint fog_stride; - tdfxVertex *v = (tdfxVertex *)dest; - GLfloat u0scale,v0scale,u1scale,v1scale; - const GLubyte *mask = VB->ClipMask; - const GLfloat *s = fxMesa->hw_viewport; - int i; - -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - if (IND & TDFX_TEX0_BIT) { - tc0_stride = VB->TexCoordPtr[tmu0_source]->stride; - tc0 = VB->TexCoordPtr[tmu0_source]->data; - u0scale = fxMesa->sScale0; - v0scale = fxMesa->tScale0; - if (IND & TDFX_PTEX_BIT) - tc0_size = VB->TexCoordPtr[tmu0_source]->size; - } - - if (IND & TDFX_TEX1_BIT) { - tc1 = VB->TexCoordPtr[tmu1_source]->data; - tc1_stride = VB->TexCoordPtr[tmu1_source]->stride; - u1scale = fxMesa->sScale1; - v1scale = fxMesa->tScale1; - if (IND & TDFX_PTEX_BIT) - tc1_size = VB->TexCoordPtr[tmu1_source]->size; - } - - if (IND & TDFX_RGBA_BIT) { - col = VB->ColorPtr[0]->data; - col_stride = VB->ColorPtr[0]->stride; - col_size = VB->ColorPtr[0]->size; - } - - if (IND & TDFX_FOGC_BIT) { - fog = VB->FogCoordPtr->data; - fog_stride = VB->FogCoordPtr->stride; - } - - { - /* May have nonstandard strides: - */ - if (start) { - proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride); - if (IND & TDFX_TEX0_BIT) - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride); - if (IND & TDFX_TEX1_BIT) - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); - if (IND & TDFX_RGBA_BIT) - STRIDE_4F(col, start * col_stride); - if (IND & TDFX_FOGC_BIT) - STRIDE_4F(fog, start * fog_stride); - } - - for (i=start; i < end; i++, v++) { - if (IND & TDFX_XYZ_BIT) { - if (mask[i] == 0) { - /* unclipped */ - VIEWPORT_X(v->x, proj[0][0]); - VIEWPORT_Y(v->y, proj[0][1]); - VIEWPORT_Z(v->z, proj[0][2]); - v->rhw = proj[0][3]; - } else { - /* clipped */ - v->rhw = 1.0; - } - proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); - } - if (IND & TDFX_RGBA_BIT) { - UNCLAMPED_FLOAT_TO_UBYTE(v->color[0], col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(v->color[1], col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(v->color[2], col[0][0]); - if (col_size == 4) { - UNCLAMPED_FLOAT_TO_UBYTE(v->color[3], col[0][3]); - } else { - v->color[3] = 255; - } - STRIDE_4F(col, col_stride); - } - if (IND & TDFX_FOGC_BIT) { - v->fog = CLAMP(fog[0][0], 0.0f, 1.0f); - STRIDE_4F(fog, fog_stride); - } - if (IND & TDFX_TEX0_BIT) { - GLfloat w = v->rhw; - v->tu0 = tc0[0][0] * u0scale * w; - v->tv0 = tc0[0][1] * v0scale * w; - if (IND & TDFX_PTEX_BIT) { - v->tq0 = w; - if (tc0_size == 4) - v->tq0 = tc0[0][3] * w; - } - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); - } - if (IND & TDFX_TEX1_BIT) { - GLfloat w = v->rhw; - v->tu1 = tc1[0][0] * u1scale * w; - v->tv1 = tc1[0][1] * v1scale * w; - if (IND & TDFX_PTEX_BIT) { - v->tq1 = w; - if (tc1_size == 4) - v->tq1 = tc1[0][3] * w; - } - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); - } - } - } -} - - -static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) -{ -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - if (IND & TDFX_PTEX_BIT) - return GL_TRUE; - - if (IND & TDFX_TEX0_BIT) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (IND & TDFX_TEX1_BIT) { - if (VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[1]; - - if (VB->TexCoordPtr[1]->size == 4) - return GL_FALSE; - } - - if (VB->TexCoordPtr[0]->size == 4) - return GL_FALSE; - } - - return GL_TRUE; -} - - -static void TAG(interp)( GLcontext *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]); - const GLfloat *s = fxMesa->hw_viewport; - tdfxVertex *dst = fxMesa->verts + edst; - const tdfxVertex *out = fxMesa->verts + eout; - const tdfxVertex *in = fxMesa->verts + ein; - const GLfloat wout = oow / out->rhw; - const GLfloat win = oow / in->rhw; - - VIEWPORT_X(dst->x, dstclip[0] * oow); - VIEWPORT_Y(dst->y, dstclip[1] * oow); - VIEWPORT_Z(dst->z, dstclip[2] * oow); - dst->rhw = oow; - - INTERP_UB( t, dst->color[0], out->color[0], in->color[0] ); - INTERP_UB( t, dst->color[1], out->color[1], in->color[1] ); - INTERP_UB( t, dst->color[2], out->color[2], in->color[2] ); - INTERP_UB( t, dst->color[3], out->color[3], in->color[3] ); - - if (IND & TDFX_FOGC_BIT) { - INTERP_F( t, dst->fog, out->fog, in->fog ); - } - - if (IND & TDFX_TEX0_BIT) { - INTERP_F( t, dst->tu0, out->tu0 * wout, in->tu0 * win ); - INTERP_F( t, dst->tv0, out->tv0 * wout, in->tv0 * win ); - if (IND & TDFX_PTEX_BIT) { - INTERP_F( t, dst->tq0, out->tq0 * wout, in->tq0 * win ); - } - } - if (IND & TDFX_TEX1_BIT) { - INTERP_F( t, dst->tu1, out->tu1 * wout, in->tu1 * win ); - INTERP_F( t, dst->tv1, out->tv1 * wout, in->tv1 * win ); - if (IND & TDFX_PTEX_BIT) { - INTERP_F( t, dst->tq1, out->tq1 * wout, in->tq1 * win ); - } - } -} - - -static void TAG(init)( void ) -{ -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - setup_tab[IND].emit = TAG(emit); - setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); - setup_tab[IND].interp = TAG(interp); - setup_tab[IND].copy_pv = copy_pv; - - if (IND & TDFX_TEX1_BIT) { - if (IND & TDFX_PTEX_BIT) { - setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ2; - } - else { - setup_tab[IND].vertex_format = TDFX_LAYOUT_MULTI; - } - } - else if (IND & TDFX_TEX0_BIT) { - if (IND & TDFX_PTEX_BIT) { - setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ1; - } else { - setup_tab[IND].vertex_format = TDFX_LAYOUT_SINGLE; - } - } - else if (IND & TDFX_W_BIT) { - setup_tab[IND].vertex_format = TDFX_LAYOUT_NOTEX; - } else { - setup_tab[IND].vertex_format = TDFX_LAYOUT_TINY; - } -} - - -#undef IND -#undef TAG -- cgit v1.2.3