summaryrefslogtreecommitdiff
path: root/xc/lib/GL
diff options
context:
space:
mode:
authoralanh <alanh>2003-03-25 13:20:26 +0000
committeralanh <alanh>2003-03-25 13:20:26 +0000
commitb0f6bc7faa6cd2059f321874644d847ccaff76d9 (patch)
treeccfa193212f15b5ebc6650f9ba510505ab5b8d87 /xc/lib/GL
parent24332fb7e57f3dfaed2ac48d6d6d0ea6a82ec343 (diff)
i830 merge
Diffstat (limited to 'xc/lib/GL')
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/Imakefile4
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h320
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_context.c105
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_context.h24
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_debug.c17
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_debug.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c158
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_render.c67
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_screen.c63
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_screen.h62
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_span.c7
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_state.c123
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_state.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_tex.c80
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_texmem.c41
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_texstate.c223
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_tris.c29
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_vb.c5
19 files changed, 841 insertions, 495 deletions
diff --git a/xc/lib/GL/mesa/src/drv/i830/Imakefile b/xc/lib/GL/mesa/src/drv/i830/Imakefile
index 36154045e..656255de5 100644
--- a/xc/lib/GL/mesa/src/drv/i830/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/i830/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i830/Imakefile,v 1.4 2002/09/11 00:29:24 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i830/Imakefile,v 1.7 2002/11/25 14:04:51 eich Exp $
#include <Threads.tmpl>
@@ -25,7 +25,7 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i830/Imakefile,v 1.4 2002/09/11 00:29:24
#include "../../tnl/Imakefile.inc"
#include "../../tnl_dd/Imakefile.inc"
#include "../../Imakefile.inc"
-#ifdef i386Architecture
+#if defined(i386Architecture) && MesaUseX86Asm
#include "../../X86/Imakefile.inc"
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h b/xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h
index fd1c5be82..5cc73d6b3 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h,v 1.3 2002/09/09 19:18:47 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h,v 1.4 2002/12/10 01:26:53 dawes Exp $ */
#define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
#define CMD_3D (0x3<<29)
@@ -325,163 +325,8 @@
/* STATE3D_MAP_CUBE, p168 TODO */
-/* STATE3D_MAP_FILTER, p169 */
-#define STATE3D_MAP_FILTER_CMD (CMD_3D|(0x1c<<24)|(0x02<<19))
-#define ENABLE_CHROMA_KEY_PARAMS (1<<15)
-#define ENABLE_TEXCOLOR_KEY (1<<14)
-#define ENABLE_TEXCHROMA_KEY (1<<13)
-#define ENABLE_TEXKILLPIX_KEY (1<<12)
-#define KEYFILTER_KILL_ON_ANY_MATCH 0
-#define KEYFILTER_KILL_ON_ANY_MISMATCH (1<<11)
-#define KEYFILTER_REPLACE_BLACK 0
-#define KEYFILTER_REPLACE_NEAREST (1<<11)
-#define ENABLE_MIP_MODE_FILTER (1<<9)
-#define MIPFILTER_NONE 0
-#define MIPFILTER_NEAREST (1<<6)
-#define MIPFILTER_LINEAR (3<<6)
-#define ENABLE_MAG_MODE_FILTER (1<<5)
-#define ENABLE_MIN_MODE_FILTER (1<<2)
-#define MAG_FILTER(x) ((x)<<3)
-#define MIN_FILTER(x) (x)
-#define MIP_FILTER_MASK (0x3<<6)
-#define MAG_FILTER_MASK (0x3<<3)
-#define MIN_FILTER_MASK (0x3<<0)
-
-#define FILTER_NEAREST 0
-#define FILTER_LINEAR 1
-#define FILTER_ANISOTROPIC 2
-
-/* STATE3D_MAP_INFO, p172 */
-#define STATE3D_MAP_INFO_NOCOLR_CMD (CMD_3D|(0x1d<<24)|3)
-
-#define STATE3D_MAP_INFO_COLR_CMD (CMD_3D|(0x1d<<24)|4)
-/* Dword 1 */
-#define MAP_INFO_TEX(unit) ((unit)<<28)
-#define MAP_INFO_MASK (3<<28)
-
-#define MI_FORMAT_MASK ((1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21))
-
-#define MAPSURF_8BIT_INDEXED 0
-#define MAPSURF_8BIT (1<<24)
-#define MAPSURF_16BIT (2<<24)
-#define MAPSURF_32BIT (3<<24)
-#define MAPSURF_411 (4<<24)
-#define MAPSURF_422 (5<<24)
-#define MAPSURF_COMPRESSED (6<<24)
-#define MAPSURF_4BIT_INDEXED (7<<24)
-
-/* Texel formats */
-/* MAPSURF_4BIT_INDEXED */
-#define MT_4BIT_IDX_ARGB8888 (7<<21)
-
-/* MAPSURF_8BIT_INDEXED */
-#define MT_8BIT_IDX_RGB565 0
-#define MT_8BIT_IDX_ARGB1555 (1<<21)
-#define MT_8BIT_IDX_ARGB4444 (2<<21)
-#define MT_8BIT_IDX_AY88 (3<<21)
-#define MT_8BIT_IDX_ABGR8888 (4<<21)
-#define MT_8BIT_IDX_BUMP_88DVDU (5<<21)
-#define MT_8BIT_IDX_BUMP_655LDVDU (6<<21)
-#define MT_8BIT_IDX_ARGB8888 (7<<21)
-
-/* MAPSURF_8BIT */
-#define MT_8BIT_I8 0
-#define MT_8BIT_L8 (1<<21)
-
-/* MAPSURF_16BIT */
-#define MT_16BIT_RGB565 0
-#define MT_16BIT_ARGB1555 (1<<21)
-#define MT_16BIT_ARGB4444 (2<<21)
-#define MT_16BIT_AY88 (3<<21)
-#define MT_16BIT_DIB_ARGB1555_8888 (4<<21)
-#define MT_16BIT_BUMP_88DVDU (5<<21)
-#define MT_16BIT_BUMP_655LDVDU (6<<21)
-#define MT_16BIT_DIB_RGB565_8888 (7<<21)
-
-/* MAPSURF_32BIT */
-#define MT_32BIT_ARGB8888 0
-#define MT_32BIT_ABGR8888 (1<<21)
-#define MT_32BIT_BUMP_XLDVDU_8888 (6<<21)
-#define MT_32BIT_DIB_8888 (7<<21)
-
-/* MAPSURF_411 */
-#define MT_411_YUV411 0
-
-/* MAPSURF_422 */
-#define MT_422_YCRCB_SWAPY 0
-#define MT_422_YCRCB_NORMAL (1<<21)
-#define MT_422_YCRCB_SWAPUV (2<<21)
-#define MT_422_YCRCB_SWAPUVY (3<<21)
-
-/* MAPSURF_COMPRESSED */
-#define MT_COMPRESS_DXT1 0
-#define MT_COMPRESS_DXT2_3 (1<<21)
-#define MT_COMPRESS_DXT4_5 (2<<21)
-#define MT_COMPRESS_FXT1 (3<<21)
-
-#define MAP_INFO_OUTMUX_F0F1F2F3 0
-#define MAP_INFO_OUTMUX_XXF0XXF3 (1<<19)
-#define MAP_INFO_OUTMUX_XXF2XXF3 (2<<19)
-
-#define ENABLE_TEX_COLORSPACE_CONV (1<<18)
-#define MAP_INFO_VERTLINESTRIDE_0 0
-#define MAP_INFO_VERTLINESTRIDE_1 (1<<17)
-#define MAP_INFO_VERTLINESTRIDEOFS_0 0
-#define MAP_INFO_VERTLINESTRIDEOFS_1 (1<<16)
-#define MAP_INFO_FORMAT_2D 0
-#define MAP_INFO_FORMAT_3D (1<<11)
-#define MAP_INFO_USE_FENCE (1<<10)
-#define MAP_INFO_IS_TILED (1<<9)
-#define MAP_INFO_IS_LINEAR 0
-#define MAP_INFO_TILEWALK_XMAJOR 0
-#define MAP_INFO_TILEWALK_YMAJOR (1<<8)
-#define MAP_INFO_USE_PALETTE_0 0
-#define MAP_INFO_USE_PALETTE_1 (1<<4)
-#define MAP_INFO_USE_PALETTE_N(x) ((x<<4) & (1<<4))
-
-/* Dword 2 */
-#define MAP_INFO_HEIGHT(x) ((x)<<16)
-#define MAP_INFO_WIDTH(x) (x)
-
-/* Dword 3 */
-#define MAP_INFO_BASEADDR(x) ((x)&0x3)
-/* Dword 4 */
-#define MAP_INFO_DWORD_PITCH(x) ((x)<<2)
-
-/* Dword 5 */
-#define MAP_INFO_DFLT_COLR(x) (x)
-
-/* STATE3D_MAP_LOD_CONTROL, p180 */
-#define STATE3D_MAP_LOD_CNTL_CMD (CMD_3D|(0x1c<<24)|(0x04<<19))
-#define ENABLE_TEXLOD_BIAS (1<<7)
-#define MAP_LOD_MASK (0x7f)
-#define MAP_LOD_BIAS(x) (x)
-
-/* STATE3D_MAP_LOD_LIMITS, p181 */
-#define STATE3D_MAP_LOD_LIMITS_CMD (CMD_3D|(0x1c<<24)|(0x03<<19))
-#define ENABLE_MAX_MIP_LVL (1<<13)
-#define ENABLE_MIN_MIP_LVL (1<<4)
-#define LOD_MAX(x) ((x)<<5)
-#define LOD_MIN(x) (x)
-#define LOD_MAX_MASK (0x1fe0)
-#define LOD_MIN_MASK (0xf)
-
-/* STATE3D_MAP_PALETTE_LOAD, p183 TODO */
-/* STATE3D_MAP_PALETTE_LOAD_32, p184 TODO */
-/* STATE3D_MAP_STREAM_MODIFIER, p186 TODO */
-
-/* STATE3D_MAP_TEXEL_STREAM, p188 */
-#define STATE3D_MAP_TEX_STREAM_CMD (CMD_3D|(0x1c<<24)|(0x05<<19))
-#define DISABLE_TEX_STREAM_BUMP (1<<12)
-#define ENABLE_TEX_STREAM_BUMP ((1<<12)|(1<<11))
-#define TEX_MODIFY_UNIT_0 0
-#define TEX_MODIFY_UNIT_1 (1<<8)
-#define ENABLE_TEX_STREAM_COORD_SET (1<<7)
-#define TEX_STREAM_COORD_SET(x) ((x)<<4)
-#define ENABLE_TEX_STREAM_MAP_IDX (1<<3)
-#define TEX_STREAM_MAP_IDX(x) (x)
/* STATE3D_MODES_1, p190 */
#define STATE3D_MODES_1_CMD (CMD_3D|(0x08<<24))
@@ -722,62 +567,111 @@
#define I830PACKCOLOR8888(r,g,b,a) \
((a<<24) | (r<<16) | (g<<8) | b)
-#if 0
-/* We wont ever use this format, since we will never be using
- * more then 4 texture coords. It is here for reference.
+
+/* Stipple command, carried over from the i810, apparently:
*/
+#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define ST1_ENABLE (1<<16)
+#define ST1_MASK (0xffff)
+
+
+
+#define STATE3D_LOAD_STATE_IMMEDIATE_2 ((0x3<<29)|(0x1d<<24)|(0x03<<16))
+#define LOAD_TEXTURE_MAP0 (1<<11)
+
+#define TM0S0_ADDRESS_MASK 0xfffffffc
+#define TM0S0_USE_FENCE (1<<1)
+
+#define TM0S1_HEIGHT_SHIFT 21
+#define TM0S1_WIDTH_SHIFT 10
+#define TM0S1_PALETTE_SELECT (1<<9)
+#define TM0S1_MAPSURF_FORMAT_MASK (0x7 << 6)
+#define TM0S1_MAPSURF_FORMAT_SHIFT 6
+#define MAPSURF_8BIT_INDEXED (0<<6)
+#define MAPSURF_8BIT (1<<6)
+#define MAPSURF_16BIT (2<<6)
+#define MAPSURF_32BIT (3<<6)
+#define MAPSURF_411 (4<<6)
+#define MAPSURF_422 (5<<6)
+#define MAPSURF_COMPRESSED (6<<6)
+#define MAPSURF_4BIT_INDEXED (7<<6)
+#define TM0S1_MT_FORMAT_MASK (0x7 << 3)
+#define TM0S1_MT_FORMAT_SHIFT 3
+#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
+#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */
+#define MT_8BIT_IDX_ARGB1555 (1<<3)
+#define MT_8BIT_IDX_ARGB4444 (2<<3)
+#define MT_8BIT_IDX_AY88 (3<<3)
+#define MT_8BIT_IDX_ABGR8888 (4<<3)
+#define MT_8BIT_IDX_BUMP_88DVDU (5<<3)
+#define MT_8BIT_IDX_BUMP_655LDVDU (6<<3)
+#define MT_8BIT_IDX_ARGB8888 (7<<3)
+#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
+#define MT_8BIT_L8 (1<<3)
+#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
+#define MT_16BIT_ARGB1555 (1<<3)
+#define MT_16BIT_ARGB4444 (2<<3)
+#define MT_16BIT_AY88 (3<<3)
+#define MT_16BIT_DIB_ARGB1555_8888 (4<<3)
+#define MT_16BIT_BUMP_88DVDU (5<<3)
+#define MT_16BIT_BUMP_655LDVDU (6<<3)
+#define MT_16BIT_DIB_RGB565_8888 (7<<3)
+#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
+#define MT_32BIT_ABGR8888 (1<<3)
+#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
+#define MT_32BIT_DIB_8888 (7<<3)
+#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
+#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
+#define MT_422_YCRCB_NORMAL (1<<3)
+#define MT_422_YCRCB_SWAPUV (2<<3)
+#define MT_422_YCRCB_SWAPUVY (3<<3)
+#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
+#define MT_COMPRESS_DXT2_3 (1<<3)
+#define MT_COMPRESS_DXT4_5 (2<<3)
+#define MT_COMPRESS_FXT1 (3<<3)
+#define TM0S1_COLORSPACE_CONVERSION (1 << 2)
+#define TM0S1_TILED_SURFACE (1 << 1)
+#define TM0S1_TILE_WALK (1 << 0)
+
+#define TM0S2_PITCH_SHIFT 21
+#define TM0S2_CUBE_FACE_ENA_SHIFT 15
+#define TM0S2_MAP_FORMAT (1<<14)
+#define TM0S2_VERTICAL_LINE_STRIDE (1<<13)
+#define TM0S2_VERITCAL_LINE_STRIDE_OFF (1<<12)
+#define TM0S2_OUTPUT_CHAN_SHIFT 10
+#define TM0S2_OUTPUT_CHAN_MASK (3<<10)
+
+#define TM0S3_MIP_FILTER_MASK (0x3<<30)
+#define TM0S3_MIP_FILTER_SHIFT 30
+#define MIPFILTER_NONE 0
+#define MIPFILTER_NEAREST 1
+#define MIPFILTER_LINEAR 3
+#define TM0S3_MAG_FILTER_MASK (0x3<<28)
+#define TM0S3_MAG_FILTER_SHIFT 28
+#define TM0S3_MIN_FILTER_MASK (0x3<<26)
+#define TM0S3_MIN_FILTER_SHIFT 26
+#define FILTER_NEAREST 0
+#define FILTER_LINEAR 1
+#define FILTER_ANISOTROPIC 2
+
+#define TM0S3_LOD_BIAS_SHIFT 17
+#define TM0S3_LOD_BIAS_MASK (0x1ff<<17)
+#define TM0S3_MAX_MIP_SHIFT 9
+#define TM0S3_MAX_MIP_MASK (0xff<<9)
+#define TM0S3_MIN_MIP_SHIFT 3
+#define TM0S3_MIN_MIP_MASK (0x3f<<3)
+#define TM0S3_KILL_PIXEL (1<<2)
+#define TM0S3_KEYED_FILTER (1<<1)
+#define TM0S3_CHROMA_KEY (1<<0)
-typedef struct {
- float x;
- float y;
- float z;
- float z_bias;
- union {
- float w;
- float rhw;
- } w;
- float point_width;
- unsigned int argb;
- unsigned int fog_spec_rgb;
-
- float tu0;
- float tv0;
- float tq0;
- float t_4_0;
-
- float tu1;
- float tv1;
- float tq1;
- float t_4_1;
-
- float tu2;
- float tv2;
- float tq2;
- float t_4_2;
-
- float tu3;
- float tv3;
- float tq3;
- float t_4_3;
-
- float tu4;
- float tv4;
- float tq4;
- float t_4_4;
-
- float tu5;
- float tv5;
- float tq5;
- float t_4_5;
-
- float tu6;
- float tv6;
- float tq6;
- float t_4_6;
-
- float tu7;
- float tv7;
- float tq7;
- float t_4_7;
-} i830_full_vertex;
-#endif
+
+/* STATE3D_MAP_TEXEL_STREAM, p188 */
+#define STATE3D_MAP_TEX_STREAM_CMD (CMD_3D|(0x1c<<24)|(0x05<<19))
+#define DISABLE_TEX_STREAM_BUMP (1<<12)
+#define ENABLE_TEX_STREAM_BUMP ((1<<12)|(1<<11))
+#define TEX_MODIFY_UNIT_0 0
+#define TEX_MODIFY_UNIT_1 (1<<8)
+#define ENABLE_TEX_STREAM_COORD_SET (1<<7)
+#define TEX_STREAM_COORD_SET(x) ((x)<<4)
+#define ENABLE_TEX_STREAM_MAP_IDX (1<<3)
+#define TEX_STREAM_MAP_IDX(x) (x)
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_context.c b/xc/lib/GL/mesa/src/drv/i830/i830_context.c
index 2b87c6f3b..ad76579bc 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_context.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_context.c
@@ -24,7 +24,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* **************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.c,v 1.4 2002/09/12 02:20:08 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.c,v 1.9 2003/02/06 04:18:00 dawes Exp $ */
/*
* Authors:
@@ -69,9 +69,7 @@ int I830_DEBUG = (0);
* Mesa's Driver Functions
***************************************/
-#define PCI_CHIP_845_G 0x2562
-#define PCI_CHIP_I830_M 0x3577
-#define DRIVER_DATE "20021125"
+#define DRIVER_DATE "20021115"
static const GLubyte *i830DDGetString( GLcontext *ctx, GLenum name )
{
@@ -81,7 +79,7 @@ static const GLubyte *i830DDGetString( GLcontext *ctx, GLenum name )
case GL_VENDOR:
return (GLubyte *)"2d3D, Inc";
case GL_RENDERER:
- return (GLubyte *)"Mesa DRI I845 " DRIVER_DATE;
+ return (GLubyte *)"Mesa DRI Intel(R) 845G " DRIVER_DATE;
default:
return 0;
}
@@ -91,13 +89,41 @@ static const GLubyte *i830DDGetString( GLcontext *ctx, GLenum name )
case GL_VENDOR:
return (GLubyte *)"VA Linux, Inc";
case GL_RENDERER:
- return (GLubyte *)"Mesa DRI I830 " DRIVER_DATE;
+ return (GLubyte *)"Mesa DRI Intel(R) 830M " DRIVER_DATE;
+ default:
+ return 0;
+ }
+ break;
+ case PCI_CHIP_I855_GM:
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Tungsten Graphics, Inc";
+ case GL_RENDERER:
+ return (GLubyte *)"Mesa DRI Intel(R) 852GM/855GM " DRIVER_DATE;
+ default:
+ return 0;
+ }
+ break;
+ case PCI_CHIP_I865_G:
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Tungsten Graphics, Inc";
+ case GL_RENDERER:
+ return (GLubyte *)"Mesa DRI Intel(R) 865G " DRIVER_DATE;
default:
return 0;
}
break;
default:
- return 0;
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Tungsten Graphics, Inc";
+ case GL_RENDERER:
+ return (GLubyte *)"Mesa DRI Unknown Intel Chipset " DRIVER_DATE;
+ default:
+ return 0;
+ }
+ break;
}
}
@@ -123,8 +149,8 @@ static void i830InitExtensions( GLcontext *ctx )
_mesa_enable_extension( ctx, "GL_ARB_multitexture" );
_mesa_enable_extension( ctx, "GL_ARB_texture_env_add" );
_mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
- _mesa_enable_extension( ctx, "GL_ARB_texture_env_combine" );
- _mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
+ _mesa_enable_extension( ctx, "GL_ARB_texture_env_combine" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
_mesa_enable_extension( ctx, "GL_EXT_blend_color" );
_mesa_enable_extension( ctx, "GL_EXT_blend_minmax" );
_mesa_enable_extension( ctx, "GL_EXT_blend_subtract" );
@@ -320,8 +346,10 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
imesa->CurrentTexObj[0] = 0;
imesa->CurrentTexObj[1] = 0;
- _math_matrix_ctr (&imesa->ViewportMatrix);
+ imesa->do_irqs = (imesa->i830Screen->irq_active &&
+ !getenv("I830_NO_IRQS"));
+ _math_matrix_ctr (&imesa->ViewportMatrix);
i830InitExtensions (ctx);
i830DDInitStateFuncs( ctx );
@@ -339,6 +367,12 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
add_debug_flags( getenv("I830_DEBUG") );
#endif
+ if (getenv("I830_NO_RAST") ||
+ getenv("INTEL_NO_RAST")) {
+ fprintf(stderr, "disabling 3D rasterization\n");
+ FALLBACK(imesa, I830_FALLBACK_USER, 1);
+ }
+
return GL_TRUE;
}
@@ -381,7 +415,7 @@ void i830XMesaSetBackClipRects( i830ContextPtr imesa )
{
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
- if (dPriv->numBackClipRects == 0) {
+ if (imesa->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0) {
imesa->numClipRects = dPriv->numClipRects;
imesa->pClipRects = dPriv->pClipRects;
imesa->drawX = dPriv->x;
@@ -417,10 +451,11 @@ GLboolean i830UnbindContext(__DRIcontextPrivate *driContextPriv)
i830ContextPtr imesa = (i830ContextPtr) driContextPriv->driverPrivate;
if (imesa) {
/* Might want to change this so texblend isn't always updated */
- imesa->dirty = (I830_UPLOAD_CTX |
- I830_UPLOAD_BUFFERS |
- I830_UPLOAD_TEXBLEND0 |
- I830_UPLOAD_TEXBLEND1);
+ imesa->dirty |= (I830_UPLOAD_CTX |
+ I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_STIPPLE |
+ I830_UPLOAD_TEXBLEND0 |
+ I830_UPLOAD_TEXBLEND1);
if (imesa->CurrentTexObj[0]) imesa->dirty |= I830_UPLOAD_TEX0;
if (imesa->CurrentTexObj[1]) imesa->dirty |= I830_UPLOAD_TEX1;
@@ -456,6 +491,41 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
return GL_TRUE;
}
+/* Turn on/off page flipping according to the flags in the sarea:
+ */
+static void
+i830UpdatePageFlipping( i830ContextPtr imesa )
+{
+ GLcontext *ctx = imesa->glCtx;
+ int front = 0;
+
+ switch (ctx->Color.DriverDrawBuffer) {
+ case GL_FRONT_LEFT:
+ front = 1;
+ break;
+ case GL_BACK_LEFT:
+ front = 0;
+ break;
+ default:
+ return;
+ }
+
+ if ( imesa->sarea->pf_current_page == 1 )
+ front ^= 1;
+
+ if (front) {
+ imesa->BufferSetup[I830_DESTREG_CBUFADDR] = imesa->i830Screen->fbOffset;
+ imesa->drawMap = (char *)imesa->driScreen->pFB;
+ imesa->readMap = (char *)imesa->driScreen->pFB;
+ } else {
+ imesa->BufferSetup[I830_DESTREG_CBUFADDR] = imesa->i830Screen->backOffset;
+ imesa->drawMap = imesa->i830Screen->back.map;
+ imesa->readMap = imesa->i830Screen->back.map;
+ }
+
+ imesa->dirty |= I830_UPLOAD_BUFFERS;
+}
+
void i830GetLock( i830ContextPtr imesa, GLuint flags )
{
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
@@ -481,13 +551,15 @@ void i830GetLock( i830ContextPtr imesa, GLuint flags )
if (sarea->ctxOwner != me) {
imesa->upload_cliprects = GL_TRUE;
imesa->dirty |= (I830_UPLOAD_CTX |
- I830_UPLOAD_BUFFERS);
+ I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_STIPPLE);
if(imesa->CurrentTexObj[0]) imesa->dirty |= I830_UPLOAD_TEX0;
if(imesa->CurrentTexObj[1]) imesa->dirty |= I830_UPLOAD_TEX1;
if(imesa->TexBlendWordsUsed[0]) imesa->dirty |= I830_UPLOAD_TEXBLEND0;
if(imesa->TexBlendWordsUsed[1]) imesa->dirty |= I830_UPLOAD_TEXBLEND1;
+ sarea->perf_boxes = imesa->perf_boxes | I830_BOX_LOST_CONTEXT;
sarea->ctxOwner = me;
}
@@ -518,6 +590,7 @@ void i830GetLock( i830ContextPtr imesa, GLuint flags )
}
if (imesa->lastStamp != dPriv->lastStamp) {
+ i830UpdatePageFlipping( imesa );
i830XMesaWindowMoved( imesa );
imesa->lastStamp = dPriv->lastStamp;
}
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_context.h b/xc/lib/GL/mesa/src/drv/i830/i830_context.h
index 52c0e54cf..f4ccb1bf3 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_context.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_context.h
@@ -25,7 +25,7 @@
/* Adapted for use in the I830M driver:
* Jeff Hartmann <jhartmann@2d3d.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.h,v 1.2 2002/09/11 00:29:25 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.h,v 1.7 2003/02/06 04:18:01 dawes Exp $ */
#ifndef I830CONTEXT_INC
#define I830CONTEXT_INC
@@ -165,10 +165,11 @@ struct i830_context_t
GLuint dirty; /* I810_UPLOAD_* */
GLuint Setup[I830_CTX_SETUP_SIZE];
GLuint BufferSetup[I830_DEST_SETUP_SIZE];
+ GLuint StippleSetup[I830_STP_SETUP_SIZE];
int vertex_size;
int vertex_stride_shift;
unsigned int lastStamp;
- GLboolean stipple_in_hw;
+ GLboolean hw_stipple;
GLenum TexEnvImageFmt[2];
@@ -186,7 +187,6 @@ struct i830_context_t
*/
GLuint needClip;
GLframebuffer *glBuffer;
- GLboolean doPageFlip;
/* These refer to the current draw (front vs. back) buffer:
*/
@@ -201,7 +201,10 @@ struct i830_context_t
int texAge;
int ctxAge;
int dirtyAge;
+ int perf_boxes;
+ int do_irqs;
+
GLboolean scissor;
XF86DRIClipRectRec draw_rect;
XF86DRIClipRectRec scissor_rect;
@@ -240,9 +243,11 @@ do { \
/* Unlock the hardware using the global current context
*/
-#define UNLOCK_HARDWARE(imesa) \
- DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
-
+#define UNLOCK_HARDWARE(imesa) \
+do { \
+ imesa->perf_boxes |= imesa->sarea->perf_boxes; \
+ DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext); \
+} while (0)
/* This is the wrong way to do it, I'm sure. Otherwise the drm
* bitches that I've already got the heavyweight lock. At worst,
@@ -291,6 +296,13 @@ extern int I830_DEBUG;
#define DEBUG_SANITY 0x200
#define DEBUG_SYNC 0x400
#define DEBUG_SLEEP 0x800
+
+
+#define PCI_CHIP_845_G 0x2562
+#define PCI_CHIP_I830_M 0x3577
+#define PCI_CHIP_I855_GM 0x3582
+#define PCI_CHIP_I865_G 0x2572
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_debug.c b/xc/lib/GL/mesa/src/drv/i830/i830_debug.c
index b452ee414..dabd926da 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_debug.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_debug.c
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_debug.c,v 1.2 2002/09/11 00:29:25 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_debug.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -138,6 +138,14 @@ void i830DumpBufferState( i830ContextPtr imesa )
fprintf(stderr, "DR4 : 0x%08x\n", Buffer[I830_DESTREG_DR4]);
}
+void i830DumpStippleState( i830ContextPtr imesa )
+{
+ GLuint *Buffer = imesa->BufferSetup;
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ fprintf(stderr, "ST1 : 0x%08x\n", Buffer[I830_STPREG_ST1]);
+}
+
void i830DumpTextureState( i830ContextPtr imesa, int unit )
{
i830TextureObjectPtr t = imesa->CurrentTexObj[unit];
@@ -337,6 +345,13 @@ void i830EmitHwStateLockedDebug( i830ContextPtr imesa )
i830DumpBufferState(imesa);
}
+ if (imesa->dirty & I830_UPLOAD_STIPPLE) {
+ fprintf(stderr, "UPLOAD_STIPPLE\n");
+ memcpy( imesa->sarea->StippleState,imesa->StippleSetup,
+ sizeof(imesa->StippleSetup) );
+ i830DumpStippleState(imesa);
+ }
+
if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_SHARED) {
memcpy( imesa->sarea->Palette[0],imesa->palette,
sizeof(imesa->sarea->Palette[0]));
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_debug.h b/xc/lib/GL/mesa/src/drv/i830/i830_debug.h
index a49b82d0b..c61d82153 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_debug.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_debug.h
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_debug.h,v 1.2 2002/09/11 00:29:25 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_debug.h,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -41,6 +41,7 @@ void i830DumpContextState( i830ContextPtr imesa );
void i830DumpBufferState( i830ContextPtr imesa );
void i830DumpTextureState( i830ContextPtr imesa, int unit );
void i830DumpTextureBlendState( i830ContextPtr imesa, int unit );
+void i830DumpStippleState( i830ContextPtr imesa );
void i830VertexSanity( i830ContextPtr imesa, drmI830Vertex vertex );
void i830EmitHwStateLockedDebug( i830ContextPtr imesa );
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c b/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c
index b85622952..019f98c4c 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c
@@ -26,7 +26,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c,v 1.3 2002/09/11 00:29:25 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c,v 1.5 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -38,7 +38,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include <unistd.h> /* for usleep() */
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
#include "glheader.h"
#include "mtypes.h"
@@ -72,6 +74,7 @@ static drmBufPtr i830_get_buffer_ioctl( i830ContextPtr imesa )
break;
if (++i > 1000) {
+ imesa->sarea->perf_boxes |= I830_BOX_WAIT;
retcode = drmCommandNone(imesa->driFd, DRM_I830_FLUSH);
i = 0;
}
@@ -178,6 +181,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask,
memcpy(sarea->BufferState,
imesa->BufferSetup,
sizeof(imesa->BufferSetup) );
+ sarea->StippleState[I830_STPREG_ST1] = 0;
old_vertex_prim = imesa->hw_primitive;
imesa->hw_primitive = PRIM3D_TRIFAN;
@@ -538,6 +542,9 @@ void i830CopyBuffer( const __DRIdrawablePrivate *dPriv )
I830_FIREVERTICES( imesa );
LOCK_HARDWARE( imesa );
+ imesa->sarea->perf_boxes |= imesa->perf_boxes;
+ imesa->perf_boxes = 0;
+
pbox = dPriv->pClipRects;
nbox = dPriv->numClipRects;
@@ -566,12 +573,52 @@ void i830CopyBuffer( const __DRIdrawablePrivate *dPriv )
imesa->upload_cliprects = GL_TRUE;
}
-/*
- * XXX implement when full-screen extension is done.
+/* Flip the front & back buffes
*/
void i830PageFlip( const __DRIdrawablePrivate *dPriv )
{
- return;
+ i830ContextPtr imesa;
+ int tmp, ret;
+
+ if (I830_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (i830ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ I830_FIREVERTICES( imesa );
+ LOCK_HARDWARE( imesa );
+
+ imesa->sarea->perf_boxes |= imesa->perf_boxes;
+ imesa->perf_boxes = 0;
+
+ if (dPriv->pClipRects) {
+ *(XF86DRIClipRectRec *)imesa->sarea->boxes = dPriv->pClipRects[0];
+ imesa->sarea->nbox = 1;
+ }
+
+ ret = drmCommandNone(imesa->driFd, DRM_I830_FLIP);
+ if (ret) {
+ fprintf(stderr, "%s: %d\n", __FUNCTION__, ret);
+ UNLOCK_HARDWARE( imesa );
+ exit(1);
+ }
+
+ tmp = GET_ENQUEUE_AGE(imesa);
+ UNLOCK_HARDWARE( imesa );
+
+ /* multiarb will suck the life out of the server without this throttle:
+ */
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
+ i830WaitAge(imesa, imesa->lastSwap);
+ }
+
+ i830SetDrawBuffer( imesa->glCtx, imesa->glCtx->Color.DriverDrawBuffer );
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->lastSwap = tmp;
}
/* This waits for *everybody* to finish rendering -- overkill.
@@ -579,8 +626,7 @@ void i830PageFlip( const __DRIdrawablePrivate *dPriv )
void i830DmaFinish( i830ContextPtr imesa )
{
I830_FIREVERTICES( imesa );
- LOCK_HARDWARE( imesa );
- i830RegetLockQuiescent( imesa );
+ LOCK_HARDWARE_QUIESCENT( imesa );
UNLOCK_HARDWARE( imesa );
}
@@ -596,6 +642,7 @@ void i830WaitAgeLocked( i830ContextPtr imesa, int age )
while (++i < 5000) {
drmCommandNone(imesa->driFd, DRM_I830_GETAGE);
if (GET_DISPATCH_AGE(imesa) >= age) return;
+ imesa->sarea->perf_boxes |= I830_BOX_WAIT;
UNLOCK_HARDWARE( imesa );
if (I830_DEBUG & DEBUG_SLEEP) fprintf(stderr, ".");
usleep(1);
@@ -609,22 +656,37 @@ void i830WaitAgeLocked( i830ContextPtr imesa, int age )
void i830WaitAge( i830ContextPtr imesa, int age )
{
int i = 0;
- while (++i < 5000) {
- drmCommandNone(imesa->driFd, DRM_I830_GETAGE);
- if (GET_DISPATCH_AGE(imesa) >= age) return;
- }
+ if (GET_DISPATCH_AGE(imesa) >= age) return;
- i = 0;
- while (++i < 1000) {
+ while (1) {
drmCommandNone(imesa->driFd, DRM_I830_GETAGE);
if (GET_DISPATCH_AGE(imesa) >= age) return;
- if (I830_DEBUG & DEBUG_SLEEP) fprintf(stderr, ".");
- usleep(1000);
- }
+ imesa->perf_boxes |= I830_BOX_WAIT;
- LOCK_HARDWARE(imesa);
- drmCommandNone(imesa->driFd, DRM_I830_FLUSH);
- UNLOCK_HARDWARE(imesa);
+ if (imesa->do_irqs) {
+ drmI830IrqEmit ie;
+ drmI830IrqWait iw;
+ int ret;
+
+ ie.irq_seq = &iw.irq_seq;
+
+ LOCK_HARDWARE( imesa );
+ ret = drmCommandWriteRead( imesa->driFd, DRM_I830_IRQ_EMIT, &ie, sizeof(ie) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmI830IrqEmit: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+ UNLOCK_HARDWARE(imesa);
+
+ ret = drmCommandWrite( imesa->driFd, DRM_I830_IRQ_WAIT, &iw, sizeof(iw) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+ } else {
+ if (++i > 5000) usleep(1);
+ }
+ }
}
static void age_imesa( i830ContextPtr imesa, int age )
@@ -640,11 +702,25 @@ void i830FlushPrimsLocked( i830ContextPtr imesa )
drmBufPtr buffer = imesa->vertex_buffer;
I830SAREAPtr sarea = imesa->sarea;
drmI830Vertex vertex;
- int i;
+ int i, nr;
if (I830_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s dirty: %08x\n", __FUNCTION__, imesa->dirty);
+
+ vertex.idx = buffer->idx;
+ vertex.used = imesa->vertex_low;
+ vertex.discard = 0;
+ sarea->vertex_prim = imesa->hw_primitive;
+
+ /* Reset imesa vars:
+ */
+ imesa->vertex_buffer = 0;
+ imesa->vertex_addr = 0;
+ imesa->vertex_low = 0;
+ imesa->vertex_high = 0;
+ imesa->vertex_last_prim = 0;
+
if (imesa->dirty) {
if (I830_DEBUG & DEBUG_SANITY)
i830EmitHwStateLockedDebug(imesa);
@@ -652,25 +728,32 @@ void i830FlushPrimsLocked( i830ContextPtr imesa )
i830EmitHwStateLocked(imesa);
}
- vertex.idx = buffer->idx;
- vertex.used = imesa->vertex_low;
- vertex.discard = 0;
- sarea->vertex_prim = imesa->hw_primitive;
-
if (I830_DEBUG & DEBUG_IOCTL)
fprintf(stderr,"%s: Vertex idx %d used %d discard %d\n",
__FUNCTION__, vertex.idx, vertex.used, vertex.discard);
- if (!nbox)
+ if (!nbox) {
vertex.used = 0;
+ vertex.discard = 1;
+ if (drmCommandWrite (imesa->driFd, DRM_I830_VERTEX,
+ &vertex, sizeof(drmI830Vertex))) {
+ fprintf(stderr, "DRM_I830_VERTEX: %d\n", -errno);
+ UNLOCK_HARDWARE(imesa);
+ exit(1);
+ }
+ return;
+ }
- for (i = 0 ; i < nbox ; ) {
- int nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, nbox);
+ for (i = 0 ; i < nbox ; i = nr ) {
XF86DRIClipRectPtr b = sarea->boxes;
+ int j;
+ nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, nbox);
sarea->nbox = nr - i;
- for ( ; i < nr ; i++, b++)
- *b++ = pbox[i];
+
+ for ( j = i ; j < nr ; j++) {
+ b[j-i] = pbox[j];
+ }
/* Finished with the buffer?
*/
@@ -678,21 +761,20 @@ void i830FlushPrimsLocked( i830ContextPtr imesa )
vertex.discard = 1;
/* Do a bunch of sanity checks on the vertices sent to the hardware */
- if (I830_DEBUG & DEBUG_SANITY)
+ if (I830_DEBUG & DEBUG_SANITY) {
i830VertexSanity(imesa, vertex);
+ for ( j = 0 ; j < sarea->nbox ; j++) {
+ fprintf(stderr, "box %d/%d %d,%d %d,%d\n",
+ j, sarea->nbox, b[j].x1, b[j].y1, b[j].x2, b[j].y2);
+ }
+ }
+
drmCommandWrite (imesa->driFd, DRM_I830_VERTEX,
&vertex, sizeof(drmI830Vertex));
age_imesa(imesa, imesa->sarea->last_enqueue);
}
- /* Reset imesa vars:
- */
- imesa->vertex_buffer = 0;
- imesa->vertex_addr = 0;
- imesa->vertex_low = 0;
- imesa->vertex_high = 0;
- imesa->vertex_last_prim = 0;
imesa->dirty = 0;
imesa->upload_cliprects = GL_FALSE;
}
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h b/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h
index 824676c20..4c64b8d7a 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h
@@ -26,7 +26,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h,v 1.2 2002/09/09 19:18:48 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h,v 1.3 2002/10/30 12:51:35 alanh Exp $ */
/*
* Author:
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_render.c b/xc/lib/GL/mesa/src/drv/i830/i830_render.c
index bfd4fb6b8..84b453587 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_render.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_render.c
@@ -26,7 +26,7 @@
* Adapted for use on the I830:
* Jeff Hartmann <jhartmann@2d3d.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_render.c,v 1.1 2002/09/09 19:18:48 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_render.c,v 1.2 2002/12/10 01:26:53 dawes Exp $ */
/*
* Render unclipped vertex buffers by emitting vertices directly to
@@ -38,6 +38,7 @@
#include "macros.h"
#include "imports.h"
#include "mtypes.h"
+#include "enums.h"
#include "mmath.h"
#include "tnl/t_context.h"
@@ -72,9 +73,9 @@
#define HAVE_ELTS 0
static GLuint hw_prim[GL_POLYGON+1] = {
- PRIM3D_POINTLIST,
- PRIM3D_LINELIST,
0,
+ PRIM3D_LINELIST,
+ PRIM3D_LINESTRIP,
PRIM3D_LINESTRIP,
PRIM3D_TRILIST,
PRIM3D_TRISTRIP,
@@ -97,7 +98,20 @@ static const GLenum reduced_prim[GL_POLYGON+1] = {
GL_TRIANGLES
};
-/* Fallback to normal rendering.
+static const int scale_prim[GL_POLYGON+1] = {
+ 0, /* fallback case */
+ 1,
+ 2,
+ 2,
+ 1,
+ 3,
+ 3,
+ 0, /* fallback case */
+ 0, /* fallback case */
+ 3
+};
+
+/* Fallback to normal rendering. Should now never be called.
*/
static void VERT_FALLBACK( GLcontext *ctx,
GLuint start,
@@ -124,7 +138,7 @@ static void VERT_FALLBACK( GLcontext *ctx,
#define GET_CURRENT_VB_MAX_VERTS() \
(((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
#define GET_SUBSEQUENT_VB_MAX_VERTS() \
- (I830_DMA_BUF_SZ-4) / (imesa->vertex_size * 4)
+ (I830_DMA_BUF_SZ-8) / (imesa->vertex_size * 4)
#define EMIT_VERTS( ctx, j, nr ) \
i830_emit_contiguous_verts(ctx, j, (j)+(nr))
@@ -137,6 +151,46 @@ static void VERT_FALLBACK( GLcontext *ctx,
/* Render pipeline stage */
/**********************************************************************/
+/* Heuristic for i830, which can only emit a single primitive per dma
+ * buffer, and has only a small number of dma buffers.
+ */
+static GLboolean choose_render( struct vertex_buffer *VB, int bufsz )
+{
+ int nr_prims = 0;
+ int nr_rprims = 0;
+ int nr_rverts = 0;
+ int rprim = 0;
+ int i = 0, length, flags = 0;
+
+
+ for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length) {
+ flags = VB->Primitive[i];
+ length = VB->PrimitiveLength[i];
+ if (!length)
+ continue;
+
+ if (!hw_prim[flags & PRIM_MODE_MASK])
+ return GL_FALSE;
+
+ nr_prims++;
+ nr_rverts += length * scale_prim[flags & PRIM_MODE_MASK];
+
+ if (reduced_prim[flags&PRIM_MODE_MASK] != rprim) {
+ nr_rprims++;
+ rprim = reduced_prim[flags&PRIM_MODE_MASK];
+ }
+ }
+
+ nr_prims += i / bufsz;
+ nr_rprims += nr_rverts / bufsz;
+
+ if ((nr_prims > nr_rprims * 2) ||
+ (nr_prims > nr_rprims + 3))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
static GLboolean i830_run_render( GLcontext *ctx,
struct gl_pipeline_stage *stage )
@@ -147,7 +201,8 @@ static GLboolean i830_run_render( GLcontext *ctx,
GLuint i, length, flags = 0;
/* Don't handle clipping or indexed vertices.
*/
- if (VB->ClipOrMask || imesa->RenderIndex != 0 || VB->Elts) {
+ if (VB->ClipOrMask || imesa->RenderIndex != 0 || VB->Elts ||
+ !choose_render( VB, GET_SUBSEQUENT_VB_MAX_VERTS() )) {
return GL_TRUE;
}
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_screen.c b/xc/lib/GL/mesa/src/drv/i830/i830_screen.c
index 5929a2288..e112aa74c 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_screen.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_screen.c
@@ -24,7 +24,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* **************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_screen.c,v 1.2 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_screen.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
/*
* Authors:
@@ -140,8 +140,8 @@ static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
}
/* Check that the DRM driver version is compatible */
- if (sPriv->drmMajor != 1 || sPriv->drmMinor < 2) {
- __driUtilMessage("i830 DRI driver expected DRM driver version 1.2.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
+ if (sPriv->drmMajor != 1 || sPriv->drmMinor < 3) {
+ __driUtilMessage("i830 DRI driver expected DRM driver version 1.3.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
return GL_FALSE;
}
@@ -240,7 +240,26 @@ static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
}
i830Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
- if (1) i830PrintDRIInfo(i830Screen, sPriv, gDRIPriv);
+
+ if (0) i830PrintDRIInfo(i830Screen, sPriv, gDRIPriv);
+
+ i830Screen->drmMinor = sPriv->drmMinor;
+
+ if (sPriv->drmMinor >= 3) {
+ int ret;
+ drmI830GetParam gp;
+
+ gp.param = I830_PARAM_IRQ_ACTIVE;
+ gp.value = &i830Screen->irq_active;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_I830_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "drmI830GetParam: %d\n", ret);
+ return GL_FALSE;
+ }
+ }
+
return GL_TRUE;
}
@@ -325,3 +344,39 @@ void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
return (void *) psp;
}
+
+/* This function is called by libGL.so as soon as libGL.so is loaded.
+ * This is where we'd register new extension functions with the dispatcher.
+ *
+ * Note: Most of these are probably already registered - just doing
+ * this for the benefit of old libGL.so's out there.
+ */
+#include "glapioffsets.h"
+
+void __driRegisterExtensions( void )
+{
+ int i;
+ static struct { const char *name; int offset; } funcs[] = {
+ { "glSecondaryColor3bEXT", _gloffset_SecondaryColor3bEXT },
+ { "glSecondaryColor3dEXT", _gloffset_SecondaryColor3dEXT },
+ { "glSecondaryColor3fEXT", _gloffset_SecondaryColor3fEXT },
+ { "glSecondaryColor3iEXT", _gloffset_SecondaryColor3iEXT },
+ { "glSecondaryColor3sEXT", _gloffset_SecondaryColor3sEXT },
+ { "glSecondaryColor3ubEXT", _gloffset_SecondaryColor3ubEXT },
+ { "glSecondaryColor3uiEXT", _gloffset_SecondaryColor3uiEXT },
+ { "glSecondaryColor3usEXT", _gloffset_SecondaryColor3usEXT },
+ { "glSecondaryColor3bvEXT", _gloffset_SecondaryColor3bvEXT },
+ { "glSecondaryColor3dvEXT", _gloffset_SecondaryColor3dvEXT },
+ { "glSecondaryColor3fvEXT", _gloffset_SecondaryColor3fvEXT },
+ { "glSecondaryColor3ivEXT", _gloffset_SecondaryColor3ivEXT },
+ { "glSecondaryColor3svEXT", _gloffset_SecondaryColor3svEXT },
+ { "glSecondaryColor3ubvEXT", _gloffset_SecondaryColor3ubvEXT },
+ { "glSecondaryColor3uivEXT", _gloffset_SecondaryColor3uivEXT },
+ { "glSecondaryColor3usvEXT", _gloffset_SecondaryColor3usvEXT },
+ { "glSecondaryColorPointerEXT", _gloffset_SecondaryColorPointerEXT }
+ };
+
+ for (i = 0 ; i < sizeof(funcs) / sizeof(*funcs) ; i++ )
+ _glapi_add_entrypoint( funcs[i].name, funcs[i].offset );
+}
+
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_screen.h b/xc/lib/GL/mesa/src/drv/i830/i830_screen.h
index 270194c87..8153828ff 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_screen.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_screen.h
@@ -39,17 +39,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dri_util.h"
-/* All structures go here */
-typedef struct
-{
- GLubyte blue;
- GLubyte green;
- GLubyte red;
- GLubyte alpha;
-}i830_color;
-
-
-
typedef struct {
drmHandle handle;
drmSize size;
@@ -59,37 +48,40 @@ typedef struct {
typedef struct
{
- i830Region front;
- i830Region back;
- i830Region depth;
- i830Region tex;
+ i830Region front;
+ i830Region back;
+ i830Region depth;
+ i830Region tex;
- int deviceID;
- int width;
- int height;
- int mem;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
- int cpp; /* for front and back buffers */
- int bitsPerPixel;
+ int cpp; /* for front and back buffers */
+ int bitsPerPixel;
- int fbFormat;
- int fbOffset;
- int fbStride;
+ int fbFormat;
+ int fbOffset;
+ int fbStride;
- int backOffset;
- int depthOffset;
+ int backOffset;
+ int depthOffset;
- int backPitch;
- int backPitchBits;
+ int backPitch;
+ int backPitchBits;
- int textureOffset;
- int textureSize;
- int logTextureGranularity;
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
- __DRIscreenPrivate *driScrnPriv;
- drmBufMapPtr bufs;
- int use_copy_buf;
- unsigned int sarea_priv_offset;
+ __DRIscreenPrivate *driScrnPriv;
+ drmBufMapPtr bufs;
+ int use_copy_buf;
+ unsigned int sarea_priv_offset;
+
+ int drmMinor;
+ int irq_active;
}i830ScreenPrivate;
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_span.c b/xc/lib/GL/mesa/src/drv/i830/i830_span.c
index 2fe74ffc4..9fa71ca06 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_span.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_span.c
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_span.c,v 1.3 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_span.c,v 1.4 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -279,6 +279,7 @@ static void i830SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
imesa->readMap = imesa->i830Screen->back.map;
} else {
ASSERT(0);
+ break;
}
}
@@ -290,8 +291,8 @@ void i830SpanRenderStart( GLcontext *ctx )
{
i830ContextPtr imesa = I830_CONTEXT(ctx);
I830_FIREVERTICES(imesa);
- i830DmaFinish(imesa);
- LOCK_HARDWARE_QUIESCENT(imesa);
+ LOCK_HARDWARE(imesa);
+ i830RegetLockQuiescent( imesa );
}
void i830SpanRenderFinish( GLcontext *ctx )
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_state.c b/xc/lib/GL/mesa/src/drv/i830/i830_state.c
index 15e0dd495..2ded3b803 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_state.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_state.c
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_state.c,v 1.4 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_state.c,v 1.6 2003/01/28 22:47:06 dawes Exp $ */
/*
* Author:
@@ -730,15 +730,71 @@ static void i830DepthMask(GLcontext *ctx, GLboolean flag)
imesa->Setup[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
- if (flag)
+ if (flag && ctx->Depth.Test)
imesa->Setup[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE;
else
imesa->Setup[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
}
-/* The i830 has no stipple hardware */
-static void i830PolygonStipple(GLcontext *ctx, const GLubyte *mask)
+/* =============================================================
+ * Polygon stipple
+ *
+ * The i830 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ */
+static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag &&
+ imesa->reduced_primitive == GL_TRIANGLES);
+ GLuint newMask;
+
+ if (active) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_STIPPLE);
+ imesa->StippleSetup[I830_STPREG_ST1] &= ~ST1_ENABLE;
+ }
+
+ p[0] = mask[12] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[8] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[4] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[0] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 3 ; j >= 0; j--)
+ for (i = 0 ; i < 4 ; i++, m++)
+ if (*m != p[j]) {
+ imesa->hw_stipple = 0;
+ return;
+ }
+
+ newMask = (((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12));
+
+
+ if (newMask == 0xffff || newMask == 0x0) {
+ /* this is needed to make conform pass */
+ imesa->hw_stipple = 0;
+ return;
+ }
+
+ imesa->StippleSetup[I830_STPREG_ST1] &= ~0xffff;
+ imesa->StippleSetup[I830_STPREG_ST1] |= newMask;
+ imesa->hw_stipple = 1;
+
+ if (active)
+ imesa->StippleSetup[I830_STPREG_ST1] |= ST1_ENABLE;
+}
+
+static void i830PolygonStippleFallback( GLcontext *ctx, const GLubyte *mask )
{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ imesa->hw_stipple = 0;
+ (void) i830PolygonStipple;
}
/* =============================================================
@@ -762,6 +818,12 @@ static void i830Scissor(GLcontext *ctx, GLint x, GLint y,
if (x2 < 0) x2 = 0;
if (y2 < 0) y2 = 0;
+ if (x2 >= imesa->i830Screen->width) x2 = imesa->i830Screen->width-1;
+ if (y2 >= imesa->i830Screen->height) y2 = imesa->i830Screen->height-1;
+ if (x1 >= imesa->i830Screen->width) x1 = imesa->i830Screen->width-1;
+ if (y1 >= imesa->i830Screen->height) y1 = imesa->i830Screen->height-1;
+
+
I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
imesa->BufferSetup[I830_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff);
imesa->BufferSetup[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff);
@@ -845,9 +907,6 @@ static void i830RenderMode( GLcontext *ctx, GLenum mode )
}
static void i830DrawBuffer(GLcontext *ctx, GLenum mode )
-{
- i830ContextPtr imesa = I830_CONTEXT(ctx);
-
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
@@ -1109,6 +1168,10 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
imesa->Setup[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
else
imesa->Setup[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
+
+ /* Also turn off depth writes when GL_DEPTH_TEST is disabled:
+ */
+ i830DepthMask( ctx, state );
break;
case GL_SCISSOR_TEST:
@@ -1159,8 +1222,8 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
break;
case GL_TEXTURE_2D:
- I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
- imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK;
+/* I830_STATECHANGE(imesa, I830_UPLOAD_CTX); */
+/* imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK; */
break;
case GL_STENCIL_TEST:
@@ -1179,7 +1242,19 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
break;
case GL_POLYGON_STIPPLE:
- FALLBACK(imesa, I830_FALLBACK_STIPPLE, ctx->Polygon.StippleFlag);
+#if 0
+ /* The stipple command worked on my 855GM box, but not my 845G.
+ * I'll do more testing later to find out exactly which hardware
+ * supports it. Disabled for now.
+ */
+ if (imesa->hw_stipple && imesa->reduced_primitive == GL_TRIANGLES)
+ {
+ I830_STATECHANGE(imesa, I830_UPLOAD_STIPPLE);
+ imesa->StippleSetup[I830_STPREG_ST1] &= ~ST1_ENABLE;
+ if (state)
+ imesa->StippleSetup[I830_STPREG_ST1] |= ST1_ENABLE;
+ }
+#endif
break;
default:
@@ -1223,11 +1298,6 @@ void i830EmitDrawingRectangle( i830ContextPtr imesa )
/* Just add in our dirty flag, since we might be called when locked */
/* Might want to modify how this is done. */
-#if 0
- if (imesa->vertex_low != imesa->vertex_last_prim)
- i830FlushPrimsLocked(imesa);
-#endif
-
imesa->dirty |= I830_UPLOAD_BUFFERS;
if (0)
@@ -1273,7 +1343,7 @@ static void i830DepthRange( GLcontext *ctx,
void i830PrintDirty( const char *msg, GLuint state )
{
- fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s\n",
+ fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n",
msg,
(unsigned int) state,
(state & I830_UPLOAD_TEX0) ? "upload-tex0, " : "",
@@ -1281,7 +1351,8 @@ void i830PrintDirty( const char *msg, GLuint state )
(state & I830_UPLOAD_CTX) ? "upload-ctx, " : "",
(state & I830_UPLOAD_BUFFERS) ? "upload-bufs, " : "",
(state & I830_UPLOAD_TEXBLEND0) ? "upload-blend0, " : "",
- (state & I830_UPLOAD_TEXBLEND1) ? "upload-blend1, " : ""
+ (state & I830_UPLOAD_TEXBLEND1) ? "upload-blend1, " : "",
+ (state & I830_UPLOAD_STIPPLE) ? "stipple, " : ""
);
}
@@ -1310,7 +1381,8 @@ void i830EmitHwStateLocked( i830ContextPtr imesa )
imesa->CurrentTexObj[i]->Setup,
sizeof(imesa->sarea->TexState[i]));
/* Update the LRU usage */
- i830UpdateTexLRU(imesa, imesa->CurrentTexObj[i]);
+ if (imesa->CurrentTexObj[i]->MemBlock)
+ i830UpdateTexLRU(imesa, imesa->CurrentTexObj[i]);
}
}
/* Need to figure out if texturing state, or enable changed. */
@@ -1326,12 +1398,15 @@ void i830EmitHwStateLocked( i830ContextPtr imesa )
}
if (imesa->dirty & I830_UPLOAD_BUFFERS) {
- if (I830_DEBUG & DEBUG_STATE)
- fprintf(stderr,"\nCopying BufferState to shared area\n");
memcpy( imesa->sarea->BufferState,imesa->BufferSetup,
sizeof(imesa->BufferSetup) );
}
+ if (imesa->dirty & I830_UPLOAD_STIPPLE) {
+ memcpy( imesa->sarea->StippleState,imesa->StippleSetup,
+ sizeof(imesa->StippleSetup) );
+ }
+
if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_SHARED) {
memcpy( imesa->sarea->Palette[0],imesa->palette,
sizeof(imesa->sarea->Palette[0]));
@@ -1349,6 +1424,7 @@ void i830EmitHwStateLocked( i830ContextPtr imesa )
sizeof(imesa->sarea->Palette[1]));
}
}
+
imesa->sarea->dirty |= (imesa->dirty & ~(I830_UPLOAD_TEX_MASK |
I830_UPLOAD_TEXBLEND_MASK));
@@ -1575,10 +1651,11 @@ void i830DDInitState( GLcontext *ctx )
imesa->LcsCullMode = CULLMODE_CW; /* GL default */
memset(imesa->BufferSetup, 0, sizeof(imesa->BufferSetup));
+ memset(imesa->StippleSetup, 0, sizeof(imesa->StippleSetup));
- if (imesa->glCtx->Visual.doubleBufferMode) {
- /* use back buffer by default */
+ if (imesa->glCtx->Visual.doubleBufferMode &&
+ imesa->sarea->pf_current_page == 0) {
imesa->drawMap = i830Screen->back.map;
imesa->readMap = i830Screen->back.map;
imesa->BufferSetup[I830_DESTREG_CBUFADDR] = i830Screen->backOffset;
@@ -1665,7 +1742,7 @@ void i830DDInitStateFuncs(GLcontext *ctx)
ctx->Driver.LineWidth = i830LineWidth;
ctx->Driver.PointSize = i830PointSize;
ctx->Driver.LogicOpcode = i830LogicOp;
- ctx->Driver.PolygonStipple = i830PolygonStipple;
+ ctx->Driver.PolygonStipple = i830PolygonStippleFallback;
ctx->Driver.RenderMode = i830RenderMode;
ctx->Driver.Scissor = i830Scissor;
ctx->Driver.DrawBuffer = i830DrawBuffer;
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_state.h b/xc/lib/GL/mesa/src/drv/i830/i830_state.h
index 8a4baac26..edfcb3a8c 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_state.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_state.h
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_state.h,v 1.2 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_state.h,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -61,6 +61,7 @@ extern void i830DDInitState( GLcontext *ctx );
extern void i830DDInitStateFuncs( GLcontext *ctx );
extern void i830PrintDirty( const char *msg, GLuint state );
+extern void i830SetDrawBuffer(GLcontext *ctx, GLenum mode );
extern void i830Fallback( i830ContextPtr imesa, GLuint bit, GLboolean mode );
#define FALLBACK( imesa, bit, mode ) i830Fallback( imesa, bit, mode )
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_tex.c b/xc/lib/GL/mesa/src/drv/i830/i830_tex.c
index dc0baac86..e6722dc8e 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_tex.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_tex.c
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tex.c,v 1.3 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tex.c,v 1.4 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -56,12 +56,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
*/
-static GLuint i830ComputeLodBias(GLfloat bias)
+static void i830ComputeLodBias(i830ContextPtr imesa,
+ i830TextureObjectPtr t,
+ GLfloat bias)
{
- int b = (int) (bias * 16.0) + 12;
+ int b;
+
+ b = (int) (bias * 16.0);
if(b > 63) b = 63;
else if (b < -64) b = -64;
- return (GLuint) (b & MAP_LOD_MASK);
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_LOD_BIAS_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |= ((b << TM0S3_LOD_BIAS_SHIFT) &
+ TM0S3_LOD_BIAS_MASK);
}
static void i830SetTexWrapping(i830TextureObjectPtr tex,
@@ -124,9 +130,9 @@ static void i830SetTexFilter(i830ContextPtr imesa,
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NEAREST;
- if(magf == GL_LINEAR) {
- bias -= 0.5;
- }
+/* if(magf == GL_LINEAR && 0) { */
+/* bias -= 0.5; */
+/* } */
break;
case GL_LINEAR_MIPMAP_NEAREST:
@@ -137,9 +143,9 @@ static void i830SetTexFilter(i830ContextPtr imesa,
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_LINEAR;
- if(magf == GL_LINEAR) {
- bias -= 0.5;
- }
+/* if(magf == GL_LINEAR && 0) { */
+/* bias -= 0.5; */
+/* } */
break;
case GL_LINEAR_MIPMAP_LINEAR:
@@ -165,14 +171,14 @@ static void i830SetTexFilter(i830ContextPtr imesa,
break;
}
- I830_SET_FIELD(t->Setup[I830_TEXREG_MF],
- MIN_FILTER_MASK | MIP_FILTER_MASK,
- MIN_FILTER(minFilt) | mipFilt);
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIP_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAG_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
+ (mipFilt << TM0S3_MIP_FILTER_SHIFT) |
+ (magFilt << TM0S3_MAG_FILTER_SHIFT));
- I830_SET_FIELD(t->Setup[I830_TEXREG_MF],
- MAG_FILTER_MASK, MAG_FILTER(magFilt));
-
- t->Setup[I830_TEXREG_MLC] |= i830ComputeLodBias(bias);
+ i830ComputeLodBias(imesa, t, bias);
}
static void i830SetTexBorderColor(i830TextureObjectPtr t, GLubyte color[4])
@@ -180,7 +186,7 @@ static void i830SetTexBorderColor(i830TextureObjectPtr t, GLubyte color[4])
if(I830_DEBUG&DEBUG_DRI)
fprintf(stderr, "%s\n", __FUNCTION__);
- t->Setup[I830_TEXREG_MI5] =
+ t->Setup[I830_TEXREG_TM0S4] =
I830PACKCOLOR8888(color[0],color[1],color[2],color[3]);
}
@@ -226,11 +232,10 @@ static void i830TexParameter( GLcontext *ctx, GLenum target,
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
- /* This isn't the most efficient solution but there doesn't appear to
- * be a nice alternative for Radeon. Since there's no LOD clamping,
- * we just have to rely on loading the right subset of mipmap levels
- * to simulate a clamped LOD.
+ /* The i830 and its successors can do a lot of this without
+ * reloading the textures. A project for someone?
*/
+ I830_FIREVERTICES( I830_CONTEXT(ctx) );
i830SwapOutTexObj( imesa, t );
break;
@@ -279,8 +284,7 @@ static void i830TexEnv( GLcontext *ctx, GLenum target,
{
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
- t->Setup[I830_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
- t->Setup[I830_TEXREG_MLC] |= i830ComputeLodBias(*param);
+ i830ComputeLodBias(imesa, t, *param);
/* Do a state change */
if (t == imesa->CurrentTexObj[unit]) {
I830_STATECHANGE( imesa, I830_UPLOAD_TEX_N(unit) );
@@ -303,6 +307,7 @@ static void i830TexImage2D( GLcontext *ctx, GLenum target, GLint level,
{
i830TextureObjectPtr t = (i830TextureObjectPtr) texObj->DriverData;
if (t) {
+ I830_FIREVERTICES( I830_CONTEXT(ctx) );
i830SwapOutTexObj( I830_CONTEXT(ctx), t );
}
_mesa_store_teximage2d( ctx, target, level, internalFormat,
@@ -323,6 +328,7 @@ static void i830TexSubImage2D( GLcontext *ctx,
{
i830TextureObjectPtr t = (i830TextureObjectPtr) texObj->DriverData;
if (t) {
+ I830_FIREVERTICES( I830_CONTEXT(ctx) );
i830SwapOutTexObj( I830_CONTEXT(ctx), t );
}
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
@@ -345,17 +351,15 @@ static void i830BindTexture( GLcontext *ctx, GLenum target,
/* Initialize non-image-dependent parts of the state:
*/
t->globj = tObj;
- t->Setup[I830_TEXREG_MI0] = STATE3D_MAP_INFO_COLR_CMD;
- t->Setup[I830_TEXREG_MI1] = (MAP_INFO_TEX(0) |
- MAP_INFO_OUTMUX_F0F1F2F3 |
- MAP_INFO_VERTLINESTRIDE_0 |
- MAP_INFO_VERTLINESTRIDEOFS_0 |
- MAP_INFO_FORMAT_2D |
- MAP_INFO_USE_FENCE);
- t->Setup[I830_TEXREG_MLC] = (STATE3D_MAP_LOD_CNTL_CMD |
- MAP_UNIT(0) |
- ENABLE_TEXLOD_BIAS |
- MAP_LOD_BIAS(0));
+ t->Setup[I830_TEXREG_TM0LI] = STATE3D_LOAD_STATE_IMMEDIATE_2;
+ t->Setup[I830_TEXREG_TM0S0] = TM0S0_USE_FENCE;
+ t->Setup[I830_TEXREG_TM0S1] = 0;
+ t->Setup[I830_TEXREG_TM0S2] = 0;
+ t->Setup[I830_TEXREG_TM0S3] = 0;
+
+ t->Setup[I830_TEXREG_NOP0] = 0;
+ t->Setup[I830_TEXREG_NOP1] = 0;
+ t->Setup[I830_TEXREG_NOP2] = 0;
t->Setup[I830_TEXREG_MCS] = (STATE3D_MAP_COORD_SET_CMD |
MAP_UNIT(0) |
@@ -367,12 +371,6 @@ static void i830BindTexture( GLcontext *ctx, GLenum target,
ENABLE_ADDR_U_CNTL |
TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));
- t->Setup[I830_TEXREG_MF] = (STATE3D_MAP_FILTER_CMD |
- MAP_UNIT(0) |
- ENABLE_MIP_MODE_FILTER |
- MIPFILTER_NEAREST |
- ENABLE_MAG_MODE_FILTER |
- ENABLE_MIN_MODE_FILTER);
t->dirty_images = ~0;
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c b/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c
index c98327e87..ea87ba0a6 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_texmem.c,v 1.2 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_texmem.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -108,18 +108,22 @@ void i830SwapOutTexObj(i830ContextPtr imesa, i830TextureObjectPtr t)
/* Upload an image from mesa's internal copy.
*/
-static void i830UploadTexLevel( i830TextureObjectPtr t, int level )
+static void i830UploadTexLevel( i830TextureObjectPtr t, int hwlevel )
{
- const struct gl_texture_image *image = t->image[level].image;
+ int level = hwlevel + t->firstLevel;
+ const struct gl_texture_image *image = t->image[hwlevel].image;
int i,j;
+ if (!image || !image->Data)
+ return;
+
if (0) fprintf(stderr, "Uploading level : %d\n", level);
switch (image->TexFormat->MesaFormat) {
case MESA_FORMAT_I8:
case MESA_FORMAT_L8:
{
- GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
GLubyte *src = (GLubyte *)image->Data;
for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
@@ -136,7 +140,7 @@ static void i830UploadTexLevel( i830TextureObjectPtr t, int level )
case MESA_FORMAT_ARGB1555:
case MESA_FORMAT_ARGB4444:
{
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset);
GLushort *src = (GLushort *)image->Data;
for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
@@ -150,7 +154,7 @@ static void i830UploadTexLevel( i830TextureObjectPtr t, int level )
case MESA_FORMAT_ARGB8888:
{
- GLuint *dst = (GLuint *)(t->BufAddr + t->image[level].offset);
+ GLuint *dst = (GLuint *)(t->BufAddr + t->image[hwlevel].offset);
GLuint *src = (GLuint *)image->Data;
for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/4)) {
@@ -286,9 +290,10 @@ void i830TexturesGone( i830ContextPtr imesa,
fprintf(stderr, "%s\n", __FUNCTION__);
foreach_s ( t, tmp, &imesa->TexObjList ) {
- if (t->MemBlock->ofs >= offset + size ||
- t->MemBlock->ofs + t->MemBlock->size <= offset)
- continue;
+ if (t->MemBlock == 0 ||
+ t->MemBlock->ofs >= offset + size ||
+ t->MemBlock->ofs + t->MemBlock->size <= offset)
+ continue;
/* It overlaps - kick it off. Need to hold onto the currently bound
* objects, however.
@@ -328,13 +333,14 @@ int i830UploadTexImages( i830ContextPtr imesa, i830TextureObjectPtr t )
if (t->MemBlock)
break;
+/*
if (imesa->TexObjList.prev == imesa->CurrentTexObj[0] ||
imesa->TexObjList.prev == imesa->CurrentTexObj[1]) {
fprintf(stderr, "Hit bound texture in upload\n");
- i830PrintLocalLRU( imesa );
+ i830PrintLocalLRU( imesa );
return -1;
}
-
+*/
if (imesa->TexObjList.prev == &(imesa->TexObjList)) {
fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
mmDumpMemInfo( imesa->texHeap );
@@ -346,13 +352,14 @@ int i830UploadTexImages( i830ContextPtr imesa, i830TextureObjectPtr t )
ofs = t->MemBlock->ofs;
t->BufAddr = imesa->i830Screen->tex.map + ofs;
- t->Setup[I830_TEXREG_MI3] = imesa->i830Screen->textureOffset + ofs;
+ t->Setup[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE |
+ (imesa->i830Screen->textureOffset + ofs));
if (t == imesa->CurrentTexObj[0])
- I830_STATECHANGE(imesa, I830_UPLOAD_TEX0);
+ imesa->dirty |= I830_UPLOAD_TEX0;
if (t == imesa->CurrentTexObj[1])
- I830_STATECHANGE(imesa, I830_UPLOAD_TEX1);
+ imesa->dirty |= I830_UPLOAD_TEX1;
#if 0
if (t == imesa->CurrentTexObj[2])
I830_STATECHANGE(imesa, I830_UPLOAD_TEX2);
@@ -360,7 +367,8 @@ int i830UploadTexImages( i830ContextPtr imesa, i830TextureObjectPtr t )
if (t == imesa->CurrentTexObj[3])
I830_STATECHANGE(imesa, I830_UPLOAD_TEX3);
#endif
- i830UpdateTexLRU( imesa, t );
+ if (t->MemBlock)
+ i830UpdateTexLRU( imesa, t );
}
if (imesa->dirtyAge >= GET_DISPATCH_AGE(imesa))
@@ -368,10 +376,11 @@ int i830UploadTexImages( i830ContextPtr imesa, i830TextureObjectPtr t )
numLevels = t->lastLevel - t->firstLevel + 1;
for (i = 0 ; i < numLevels ; i++)
- if (t->dirty_images & (1<<i))
+ if (t->dirty_images & (1<<(i+t->firstLevel)))
i830UploadTexLevel( t, i );
t->dirty_images = 0;
+ imesa->sarea->perf_boxes |= I830_BOX_TEXTURE_LOAD;
return 0;
}
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c b/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c
index d2cbaf3f1..b4fda1baf 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c
@@ -25,7 +25,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_texstate.c,v 1.2 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_texstate.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
/*
* Author:
@@ -112,17 +112,13 @@ static void i830SetTexImages( i830ContextPtr imesa,
* GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
* Yes, this looks overly complicated, but it's all needed.
*/
- if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
- firstLevel = lastLevel = tObj->BaseLevel;
- } else {
- firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
- firstLevel = MAX2(firstLevel, tObj->BaseLevel);
- lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
- lastLevel = MAX2(lastLevel, tObj->BaseLevel);
- lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
- lastLevel = MIN2(lastLevel, tObj->MaxLevel);
- lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
- }
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
/* save these values */
t->firstLevel = firstLevel;
@@ -156,6 +152,9 @@ static void i830SetTexImages( i830ContextPtr imesa,
*/
for ( height = i = 0 ; i < numLevels ; i++ ) {
t->image[i].image = tObj->Image[firstLevel + i];
+ if (!t->image[i].image) {
+ break;
+ }
t->image[i].offset = height * pitch;
t->image[i].internalFormat = baseImage->Format;
height += t->image[i].image->Height;
@@ -165,23 +164,17 @@ static void i830SetTexImages( i830ContextPtr imesa,
t->totalSize = height*pitch;
t->max_level = i-1;
- t->Setup[I830_TEXREG_MI1] = (MAP_INFO_TEX(0) |
- textureFormat |
- MAP_INFO_OUTMUX_F0F1F2F3 |
- MAP_INFO_VERTLINESTRIDE_0 |
- MAP_INFO_VERTLINESTRIDEOFS_0 |
- MAP_INFO_FORMAT_2D |
- MAP_INFO_USE_FENCE);
- t->Setup[I830_TEXREG_MI2] = (((1 << log2Height) - 1) << 16) |
- ((1 << log2Width) - 1);
- t->Setup[I830_TEXREG_MI4] = ((pitch / 4) - 1) << 2;
-
- t->Setup[I830_TEXREG_MLL] = (STATE3D_MAP_LOD_LIMITS_CMD |
- MAP_UNIT(0) |
- ENABLE_MAX_MIP_LVL |
- LOD_MAX(0) |
- ENABLE_MIN_MIP_LVL |
- LOD_MIN(numLevels - 1));
+ t->Setup[I830_TEXREG_TM0S1] =
+ ((((1 << log2Height) - 1) << TM0S1_HEIGHT_SHIFT) |
+ (((1 << log2Width) - 1) << TM0S1_WIDTH_SHIFT) |
+ textureFormat);
+ t->Setup[I830_TEXREG_TM0S2] =
+ ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT));
+
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAX_MIP_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_MIP_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |=
+ ((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT;
t->dirty = I830_UPLOAD_TEX0 | I830_UPLOAD_TEX1;
LOCK_HARDWARE( imesa );
@@ -1036,85 +1029,147 @@ static void i830SetTexEnvCombine(i830ContextPtr imesa,
fprintf(stderr, "%s\n", __FUNCTION__);
switch(texUnit->CombineModeRGB) {
- case GL_REPLACE: blendop = TEXBLENDOP_ARG1; break;
- case GL_MODULATE: blendop = TEXBLENDOP_MODULATE; break;
- case GL_ADD: blendop = TEXBLENDOP_ADD; break;
+ case GL_REPLACE:
+ blendop = TEXBLENDOP_ARG1;
+ break;
+ case GL_MODULATE:
+ blendop = TEXBLENDOP_MODULATE;
+ break;
+ case GL_ADD:
+ blendop = TEXBLENDOP_ADD;
+ break;
case GL_ADD_SIGNED_ARB:
- blendop = TEXBLENDOP_ADDSIGNED; break;
+ blendop = TEXBLENDOP_ADDSIGNED;
+ break;
case GL_INTERPOLATE_ARB:
- blendop = TEXBLENDOP_BLEND; break;
- case GL_SUBTRACT_ARB: blendop = TEXBLENDOP_SUBTRACT; break;
- default: return;
+ blendop = TEXBLENDOP_BLEND;
+ break;
+ case GL_SUBTRACT_ARB:
+ blendop = TEXBLENDOP_SUBTRACT;
+ break;
+ default:
+ return;
}
switch(texUnit->CombineScaleShiftRGB) {
- case 0: blendop |= TEXOP_SCALE_1X; break;
- case 1: blendop |= TEXOP_SCALE_2X; break;
- case 2: blendop |= TEXOP_SCALE_4X; break;
- default: return;
+ case 0:
+ blendop |= TEXOP_SCALE_1X;
+ break;
+ case 1:
+ blendop |= TEXOP_SCALE_2X;
+ break;
+ case 2:
+ blendop |= TEXOP_SCALE_4X;
+ break;
+ default:
+ return;
}
switch(texUnit->CombineModeA) {
- case GL_REPLACE: ablendop = TEXBLENDOP_ARG1; break;
- case GL_MODULATE: ablendop = TEXBLENDOP_MODULATE; break;
- case GL_ADD: ablendop = TEXBLENDOP_ADD; break;
+ case GL_REPLACE:
+ ablendop = TEXBLENDOP_ARG1;
+ break;
+ case GL_MODULATE:
+ ablendop = TEXBLENDOP_MODULATE;
+ break;
+ case GL_ADD:
+ ablendop = TEXBLENDOP_ADD;
+ break;
case GL_ADD_SIGNED_ARB:
- ablendop = TEXBLENDOP_ADDSIGNED; break;
+ ablendop = TEXBLENDOP_ADDSIGNED;
+ break;
case GL_INTERPOLATE_ARB:
- ablendop = TEXBLENDOP_BLEND; break;
- case GL_SUBTRACT_ARB: ablendop = TEXBLENDOP_SUBTRACT; break;
- default: return;
+ ablendop = TEXBLENDOP_BLEND;
+ break;
+ case GL_SUBTRACT_ARB:
+ ablendop = TEXBLENDOP_SUBTRACT;
+ break;
+ default:
+ return;
}
switch(texUnit->CombineScaleShiftA) {
- case 0: ablendop |= TEXOP_SCALE_1X; break;
- case 1: ablendop |= TEXOP_SCALE_2X; break;
- case 2: ablendop |= TEXOP_SCALE_4X; break;
- default: return;
+ case 0:
+ ablendop |= TEXOP_SCALE_1X;
+ break;
+ case 1:
+ ablendop |= TEXOP_SCALE_2X;
+ break;
+ case 2:
+ ablendop |= TEXOP_SCALE_4X;
+ break;
+ default:
+ return;
}
/* Handle RGB args */
for(i = 0; i < 3; i++) {
switch(texUnit->CombineSourceRGB[i]) {
- case GL_TEXTURE: args_RGB[i] = texel_op; break;
+ case GL_TEXTURE:
+ args_RGB[i] = texel_op;
+ break;
case GL_CONSTANT_ARB:
- args_RGB[i] = TEXBLENDARG_FACTOR_N; break;
+ args_RGB[i] = TEXBLENDARG_FACTOR_N;
+ break;
case GL_PRIMARY_COLOR_ARB:
- args_RGB[i] = TEXBLENDARG_DIFFUSE; break;
+ args_RGB[i] = TEXBLENDARG_DIFFUSE;
+ break;
case GL_PREVIOUS_ARB:
- args_RGB[i] = TEXBLENDARG_CURRENT; break;
- default: return;
+ args_RGB[i] = TEXBLENDARG_CURRENT;
+ break;
+ default:
+ return;
+
}
switch(texUnit->CombineOperandRGB[i]) {
- case GL_SRC_COLOR: args_RGB[i] |= 0; break;
- case GL_ONE_MINUS_SRC_COLOR: args_RGB[i] |= TEXBLENDARG_INV_ARG; break;
- case GL_SRC_ALPHA: args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA; break;
+ case GL_SRC_COLOR:
+ args_RGB[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ args_RGB[i] |= TEXBLENDARG_INV_ARG;
+ break;
+ case GL_SRC_ALPHA:
+ args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA;
+ break;
case GL_ONE_MINUS_SRC_ALPHA:
- args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA |
- TEXBLENDARG_INV_ARG);
- break;
- default: return;
+ args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA |
+ TEXBLENDARG_INV_ARG);
+ break;
+ default:
+ return;
}
}
/* Handle A args */
for(i = 0; i < 3; i++) {
switch(texUnit->CombineSourceA[i]) {
- case GL_TEXTURE: args_A[i] = texel_op; break;
+ case GL_TEXTURE:
+ args_A[i] = texel_op;
+ break;
case GL_CONSTANT_ARB:
- args_A[i] = TEXBLENDARG_FACTOR_N; break;
+ args_A[i] = TEXBLENDARG_FACTOR_N;
+ break;
case GL_PRIMARY_COLOR_ARB:
- args_A[i] = TEXBLENDARG_DIFFUSE; break;
+ args_A[i] = TEXBLENDARG_DIFFUSE;
+ break;
case GL_PREVIOUS_ARB:
- args_A[i] = TEXBLENDARG_CURRENT; break;
- default: return;
+ args_A[i] = TEXBLENDARG_CURRENT;
+ break;
+ default:
+ return;
+
}
switch(texUnit->CombineOperandA[i]) {
- case GL_SRC_ALPHA: args_A[i] |= 0; break;
- case GL_ONE_MINUS_SRC_ALPHA: args_A[i] |= TEXBLENDARG_INV_ARG; break;
- default: return;
+ case GL_SRC_ALPHA:
+ args_A[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ args_A[i] |= TEXBLENDARG_INV_ARG;
+ break;
+ default:
+ return;
}
}
@@ -1256,14 +1311,10 @@ static void i830TexSetUnit( i830TextureObjectPtr t, GLuint unit )
if(I830_DEBUG&DEBUG_TEXTURE)
fprintf(stderr, "%s unit(%d)\n", __FUNCTION__, unit);
- /* This will need to be changed when I support more then 2 t units */
- I830_SET_FIELD(t->Setup[I830_TEXREG_MI1],
- MAP_INFO_MASK | MAP_INFO_USE_PALETTE_1,
- MAP_INFO_TEX(unit) | MAP_INFO_USE_PALETTE_N(unit));
- I830_SET_FIELD(t->Setup[I830_TEXREG_MLC], MAP_UNIT_MASK, MAP_UNIT(unit));
- I830_SET_FIELD(t->Setup[I830_TEXREG_MLL], MAP_UNIT_MASK, MAP_UNIT(unit));
+ t->Setup[I830_TEXREG_TM0LI] = (STATE3D_LOAD_STATE_IMMEDIATE_2 |
+ (LOAD_TEXTURE_MAP0 << unit) | 4);
+
I830_SET_FIELD(t->Setup[I830_TEXREG_MCS], MAP_UNIT_MASK, MAP_UNIT(unit));
- I830_SET_FIELD(t->Setup[I830_TEXREG_MF], MAP_UNIT_MASK, MAP_UNIT(unit));
t->current_unit = unit;
}
@@ -1289,10 +1340,16 @@ static void i830UpdateTexUnit( GLcontext *ctx, GLuint unit )
mcs |= TEXCOORDTYPE_CARTESIAN;
}
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[tObj->BaseLevel]->Border > 0 ) {
+ FALLBACK( imesa, I830_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+
/* Upload teximages (not pipelined)
*/
if (t->dirty_images) {
- I830_FIREVERTICES(imesa);
+/* I830_FIREVERTICES(imesa); */
i830SetTexImages( imesa, tObj );
if (!t->MemBlock) {
FALLBACK( imesa, I830_FALLBACK_TEXTURE, GL_TRUE );
@@ -1312,13 +1369,17 @@ static void i830UpdateTexUnit( GLcontext *ctx, GLuint unit )
}
/* Update texture environment if texture object image format or
- * texture environment state has changed.
+ * texture environment state has changed.
+ *
+ * KW: doesn't work -- change from tex0 only to tex0+tex1 gets
+ * missed (need to update last stage flag?). Call
+ * i830UpdateTexEnv always.
*/
if (tObj->Image[tObj->BaseLevel]->Format !=
imesa->TexEnvImageFmt[unit]) {
imesa->TexEnvImageFmt[unit] = tObj->Image[tObj->BaseLevel]->Format;
- i830UpdateTexEnv( ctx, unit );
}
+ i830UpdateTexEnv( ctx, unit );
imesa->TexEnabledMask |= I830_TEX_UNIT_ENABLED(unit);
}
else if (texUnit->_ReallyEnabled) {
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_tris.c b/xc/lib/GL/mesa/src/drv/i830/i830_tris.c
index 4ae95347b..d502035b9 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_tris.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_tris.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tris.c,v 1.3 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tris.c,v 1.4 2002/12/10 01:26:54 dawes Exp $ */
/**************************************************************************
Copyright 2001 VA Linux Systems Inc., Fremont, California.
@@ -546,7 +546,7 @@ static void i830FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
#define POINT_FALLBACK (0)
#define LINE_FALLBACK (DD_LINE_STIPPLE)
-#define TRI_FALLBACK (DD_TRI_STIPPLE)
+#define TRI_FALLBACK (0)
#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|\
DD_TRI_STIPPLE)
#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
@@ -585,8 +585,9 @@ static void i830ChooseRenderState(GLcontext *ctx)
if (flags & TRI_FALLBACK)
imesa->draw_tri = i830_fallback_tri;
- if (flags & DD_TRI_STIPPLE)
+ if ((flags & DD_TRI_STIPPLE) && !imesa->hw_stipple) {
imesa->draw_tri = i830_fallback_tri;
+ }
index |= I830_FALLBACK_BIT;
}
@@ -663,8 +664,10 @@ static void i830RunPipeline( GLcontext *ctx )
i830ContextPtr imesa = I830_CONTEXT(ctx);
if (imesa->new_state) {
- if (imesa->new_state & _NEW_TEXTURE)
+ if (imesa->new_state & _NEW_TEXTURE) {
+ I830_FIREVERTICES( imesa );
i830UpdateTextureState( ctx ); /* may modify imesa->new_state */
+ }
if (!imesa->Fallback) {
if (imesa->new_state & _I830_NEW_VERTEX)
@@ -707,6 +710,7 @@ void i830RasterPrimitive( GLcontext *ctx,
{
i830ContextPtr imesa = I830_CONTEXT(ctx);
GLuint aa = imesa->Setup[I830_CTXREG_AA];
+ GLuint st1 = imesa->StippleSetup[I830_STPREG_ST1];
aa &= ~AA_LINE_ENABLE;
@@ -749,8 +753,13 @@ void i830RasterPrimitive( GLcontext *ctx,
switch (rprim) {
case GL_TRIANGLES:
aa |= AA_LINE_DISABLE;
+ if (ctx->Polygon.StippleFlag)
+ st1 |= ST1_ENABLE;
+ else
+ st1 &= ~ST1_ENABLE;
break;
case GL_LINES:
+ st1 &= ~ST1_ENABLE;
if (ctx->Line.SmoothFlag) {
aa |= AA_LINE_ENABLE;
} else {
@@ -758,6 +767,7 @@ void i830RasterPrimitive( GLcontext *ctx,
}
break;
case GL_POINTS:
+ st1 &= ~ST1_ENABLE;
aa |= AA_LINE_DISABLE;
break;
default:
@@ -768,10 +778,17 @@ void i830RasterPrimitive( GLcontext *ctx,
if (aa != imesa->Setup[I830_CTXREG_AA]) {
I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
- imesa->hw_primitive = hwprim;
imesa->Setup[I830_CTXREG_AA] = aa;
}
- else if (hwprim != imesa->hw_primitive) {
+
+#if 0
+ if (st1 != imesa->StippleSetup[I830_STPREG_ST1]) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_STIPPLE);
+ imesa->StippleSetup[I830_STPREG_ST1] = st1;
+ }
+#endif
+
+ if (hwprim != imesa->hw_primitive) {
I830_STATECHANGE(imesa, 0);
imesa->hw_primitive = hwprim;
}
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_vb.c b/xc/lib/GL/mesa/src/drv/i830/i830_vb.c
index 1bf20d813..2208afe41 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_vb.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_vb.c
@@ -23,7 +23,7 @@
* Adapted for use on the I830M:
* Jeff Hartmann <jhartmann@2d3d.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_vb.c,v 1.4 2002/09/11 00:29:26 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_vb.c,v 1.5 2002/12/10 01:26:54 dawes Exp $ */
#include "glheader.h"
#include "mtypes.h"
@@ -500,6 +500,9 @@ void i830ChooseVertexState( GLcontext *ctx )
imesa->SetupIndex = ind;
+ if (I830_DEBUG & (DEBUG_VERTS|DEBUG_STATE))
+ i830PrintSetupFlags( __FUNCTION__, ind );
+
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
tnl->Driver.Render.Interp = i830_interp_extras;
tnl->Driver.Render.CopyPV = i830_copy_pv_extras;