summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src/drv
diff options
context:
space:
mode:
authorjhartmann <jhartmann>2000-04-04 22:08:12 +0000
committerjhartmann <jhartmann>2000-04-04 22:08:12 +0000
commit4fe5b7fbada2f73c1533e30f8abc5cf71e7c61c4 (patch)
treed526515e629abcae4e03e1c5c02b60243dc35f72 /xc/lib/GL/mesa/src/drv
parentd13b9c4ecba68ca9c63d94dbf48a395e3d39b847 (diff)
Merged mga branch with trunkmga-0-0-2-20000404-merge
Diffstat (limited to 'xc/lib/GL/mesa/src/drv')
-rw-r--r--xc/lib/GL/mesa/src/drv/Imakefile9
-rw-r--r--xc/lib/GL/mesa/src/drv/common/Imakefile6
-rw-r--r--xc/lib/GL/mesa/src/drv/common/depthtmp.h133
-rw-r--r--xc/lib/GL/mesa/src/drv/common/shared_texture_lru.c88
-rw-r--r--xc/lib/GL/mesa/src/drv/common/shared_texture_lru.h76
-rw-r--r--xc/lib/GL/mesa/src/drv/common/spantmp.h271
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/Imakefile246
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h77
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_init.c99
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_init.h197
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_inithw.c99
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c613
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810buf.h90
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810clear.c207
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810context.c126
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810context.h161
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810dd.c96
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810dd.h18
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810depth.c735
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810depth.h80
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810dma.c363
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810dma.h148
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810dmainit.c389
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810fastpath.c12
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810glx.h44
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810ioctl.c436
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810ioctl.h32
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810lib.h57
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810pipeline.c16
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810pipeline.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810ring.c162
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810span.c269
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810span.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810state.c803
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810state.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810swap.c315
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tex.c648
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tex.h72
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tris.c189
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tris.h168
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tritmp.h130
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810vb.c125
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810vb.h19
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/Imakefile242
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c281
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h54
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgabuffers.c315
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgabuffers.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c357
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgadd.c8
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgadepth.c116
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgafastpath.c10
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.c535
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.h21
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgalib.h131
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaspan.c132
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgastate.c360
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgastate.h7
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatex.c490
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatex.h11
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatris.c50
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatris.h20
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatritmp.h6
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgavb.c42
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgavb.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/Imakefile2
67 files changed, 5901 insertions, 5138 deletions
diff --git a/xc/lib/GL/mesa/src/drv/Imakefile b/xc/lib/GL/mesa/src/drv/Imakefile
index fadb29bb2..306bf16dc 100644
--- a/xc/lib/GL/mesa/src/drv/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/Imakefile
@@ -16,6 +16,12 @@ DRIVER += gamma
#if GlxBuiltInTdfx
DRIVER += tdfx
#endif
+#if GlxBuiltInMga
+DRIVER += common mga
+#endif
+#if GlxBuiltInI810
+DRIVER += common i810
+#endif
SUBDIRS = $(DRIVER)
#else
@@ -23,6 +29,9 @@ SUBDIRS += gamma
#if HasGlide3
SUBDIRS += tdfx
#endif
+SUBDIRS += common
+SUBDIRS += mga
+SUBDIRS += i810
#endif
MakeSubdirs($(SUBDIRS))
diff --git a/xc/lib/GL/mesa/src/drv/common/Imakefile b/xc/lib/GL/mesa/src/drv/common/Imakefile
index 5c3d40dd7..e96291842 100644
--- a/xc/lib/GL/mesa/src/drv/common/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/common/Imakefile
@@ -22,8 +22,7 @@ MESA_INCLUDES = -I. -I.. -I../../include
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
- INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \
- -I/usr/include/glide
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
DRISRCS = hwlog.c mm.c
DRIOBJS = hwlog.o mm.o
@@ -44,7 +43,8 @@ LibraryObjectRule()
SubdirLibraryRule($(OBJS))
NormalLintTarget($(SRCS))
-#if !GlxUseBuiltInDRIDriver
+XCOMM #if !GlxUseBuiltInDRIDriver
+#if 0
LIBNAME = i810_dri.so
ALL_OBJS = $(OBJS)
ALL_DEPS = DONE
diff --git a/xc/lib/GL/mesa/src/drv/common/depthtmp.h b/xc/lib/GL/mesa/src/drv/common/depthtmp.h
new file mode 100644
index 000000000..3aa307904
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/common/depthtmp.h
@@ -0,0 +1,133 @@
+#ifndef DBG
+#define DBG 0
+#endif
+
+
+
+static void TAG(WriteDepthSpan)( GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLdepth *depth,
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint x1;
+ GLint n1;
+ LOCAL_DEPTH_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_DEPTH( x1, y, depth[i] );
+ }
+ else
+ {
+ for (;i<n1;i++,x1++)
+ WRITE_DEPTH( x1, y, depth[i] );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+static void TAG(WriteDepthPixels)( GLcontext *ctx,
+ GLuint n,
+ const GLint x[],
+ const GLint y[],
+ const GLdepth depth[],
+ const GLubyte mask[] )
+{
+ HW_LOCK()
+ {
+ GLint i;
+ LOCAL_DEPTH_VARS;
+
+ if (DBG) fprintf(stderr, "WriteDepthPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ {
+ if (mask[i]) {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_DEPTH( x[i], fy, depth[i] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+
+
+/* Read depth spans and pixels
+ */
+static void TAG(ReadDepthSpan)( GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ GLdepth depth[])
+{
+ HW_LOCK()
+ {
+ GLint x1,n1;
+ LOCAL_DEPTH_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadDepthSpan\n");
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;i<n1;i++)
+ READ_DEPTH( depth[i], (x1+i), y );
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLdepth depth[] )
+{
+ HW_LOCK()
+ {
+ GLint i;
+ LOCAL_DEPTH_VARS;
+
+ if (DBG) fprintf(stderr, "ReadDepthPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_DEPTH( depth[i], x[i], fy );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
+}
+
+
+#undef WRITE_DEPTH
+#undef READ_DEPTH
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/common/shared_texture_lru.c b/xc/lib/GL/mesa/src/drv/common/shared_texture_lru.c
new file mode 100644
index 000000000..2fd80eb3e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/common/shared_texture_lru.c
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include "shared_texture_lru.h"
+
+/* (Re)initialize the global circular LRU list. The last element
+ * in the array (heap->nrRegions) is the sentinal. Keeping it
+ * at the end of the array allows the other elements of the array
+ * to be addressed rationally when looking up objects at a
+ * particular location in texture memory.
+ */
+static void resetGlobalLRU( driHeapPtr heap )
+{
+ driTexRegion *list = heap->shared->list;
+ int sz = 1 << heap->logGranularity;
+ int i;
+
+ heap->localAge = ++heap->shared->texAge;
+
+ for (i = 0 ; (i+1) * sz <= heap->size ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = heap->shared->texAge;
+ }
+
+ i--;
+ list[0].prev = heap->nrRegions;
+ list[i].prev = i-1;
+ list[i].next = heap->nrRegions;
+ list[heap->nrRegions].prev = i;
+ list[heap->nrRegions].next = 0;
+}
+
+/* Called by the client whenever it touches a local texture.
+ */
+void driUpdateHeap( driHeapPtr heap, int start, int end )
+{
+ driTexRegion *list = heap->shared->list;
+ int i;
+
+ heap->localAge = ++heap->shared->globalAge;
+
+ for (i = start ; i <= end ; i++)
+ {
+ list[i].in_use = 1;
+ list[i].age = heap->localAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = heap->nrRegions;
+ list[i].next = list[heap->nrRegions].next;
+ list[(unsigned)list[heap->nrRegions].next].prev = i;
+ list[heap->nrRegions].next = i;
+ }
+}
+
+
+/* Called by the client on lock contention to determine whether
+ * textures have been stolen
+ */
+void driAgeTextures( driHeapPtr heap )
+{
+ driTexRegion *list = heap->shared->list;
+ int sz = 1 << (heap->logGranularity);
+ int i, nr = 0;
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in the local list... Fix with a cursor pointer.
+ */
+ for (i = list[heap->nrRegions].prev ;
+ i != heap->nrRegions && nr < heap->nrRegions ;
+ i = list[i].prev, nr++)
+ {
+ if (list[i].age > heap->localAge)
+ heap->texturesGone( heap->driverContext, heap->heapId, i * sz, sz, 1);
+ }
+
+ /* Loop or uninitialized heap detected. Reset.
+ */
+ if (nr == heap->nrRegions) {
+ heap->texturesGone( heap->driverContext, heap->heapId, 0, heap->size, 0);
+ resetGlobalLRU( heap );
+ }
+}
+
diff --git a/xc/lib/GL/mesa/src/drv/common/shared_texture_lru.h b/xc/lib/GL/mesa/src/drv/common/shared_texture_lru.h
new file mode 100644
index 000000000..e6cee567d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/common/shared_texture_lru.h
@@ -0,0 +1,76 @@
+#ifndef DRI_TEX_HEAP_H
+#define DRI_TEX_HEAP_H
+
+
+/* Private struct.
+ */
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} driTexRegion;
+
+
+/* This is the global part of the shared texture mechanism.
+ *
+ * Do not use this struct directly - declare an equivalent one with a
+ * larger list[] array, tuned to suit your application.
+ *
+ * Your expanded struct should be placed in the driver-specific
+ * portion of the sarea.
+ */
+struct {
+ int globalAge;
+ driTexRegion list[1]; /* drivers will want to define a larger list */
+} driGlobalList;
+
+
+/* This is the client-private part of the mechanism.
+ *
+ * Clients will place one or more of these structs in their driver
+ * context struct to manage one or more global texture heaps. All
+ * fields except print_local_lru must be filled in.
+ */
+struct dri_tex_heap_t {
+
+ int heapId; /* client-supplied identifier */
+ void *driverContext; /* pointer to the client's context private */
+ int size; /* heap size in bytes */
+ int logGranularity; /* log base 2 of size of single heap region */
+ int nrRegions; /* number of elements in global list */
+ driGlobalList *shared; /* pointer to sarea driGlobalList struct */
+ int localAge; /* initialize to zero */
+
+ /* Callback to the client to let it know a region of texture
+ * space has changed age. The client must integrate this
+ * information with its local texture knowledge, in particular
+ * checking whether any of its own textures have been
+ * invalidated.
+ */
+ void (*textures_gone)( void *driverContext,
+ int heapId,
+ int offset,
+ int size,
+ int inUse );
+
+ /* Optional hook for debugging.
+ */
+ void (*print_local_lru)( void *driverContext,
+ int heapId );
+} driTexHeap;
+
+
+#define DRI_AGE_TEXTURES( heap ) \
+ if ((heap)->localAge > (heap)->shared->globalAge) \
+ driAgeTextures( heap );
+
+
+/* This should be called whenever there has been contention on the
+ * hardware lock. Clients can shortcircuit this slightly by using
+ * DRI_AGE_TEXTURES, above.
+ */
+void driAgeTextures( driTexHeap *heap );
+
+#endif
+
+
diff --git a/xc/lib/GL/mesa/src/drv/common/spantmp.h b/xc/lib/GL/mesa/src/drv/common/spantmp.h
index e10dca1a2..b475c6b18 100644
--- a/xc/lib/GL/mesa/src/drv/common/spantmp.h
+++ b/xc/lib/GL/mesa/src/drv/common/spantmp.h
@@ -1,37 +1,48 @@
+#ifndef DBG
+#define DBG 0
+#endif
static void TAG(WriteRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
- GLuint x1,n1;
- LOCAL_VARS;
-
- y = Y_FLIP(y);
-
- if (DBG) fprintf(stderr, "WriteRGBASpan\n");
-
- HW_CLIPLOOP()
+ HW_LOCK()
{
- GLuint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
- if (mask)
- {
- for (i=0;i<n1;i++,x1++)
- if (mask[i])
- WRITE_RGBA( x1, y,
- rgba[i][0], rgba[i][1],
- rgba[i][2], rgba[i][3] );
- }
- else
- {
- for (i=0;i<n1;i++,x1++)
- WRITE_RGBA( x1, y,
- rgba[i][0], rgba[i][1],
- rgba[i][2], rgba[i][3] );
- }
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ else
+ {
+ for (;i<n1;i++,x1++)
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ HW_ENDCLIPLOOP();
}
- HW_ENDCLIPLOOP();
+ HW_UNLOCK();
}
static void TAG(WriteRGBSpan)( const GLcontext *ctx,
@@ -39,32 +50,37 @@ static void TAG(WriteRGBSpan)( const GLcontext *ctx,
const GLubyte rgb[][3],
const GLubyte mask[] )
{
- GLuint x1,n1;
- LOCAL_VARS;
-
- y = Y_FLIP(y);
-
-
- if (DBG) fprintf(stderr, "WriteRGBSpan\n");
-
- HW_CLIPLOOP()
+ HW_LOCK()
{
- GLuint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
-
- if (mask)
- {
- for (;i<n1;i++,x1++)
- if (mask[i])
- WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 0 );
- }
- else
- {
- for (;i<n1;i++,x1++)
- WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 0 );
- }
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 0 );
+ }
+ else
+ {
+ for (;i<n1;i++,x1++)
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 0 );
+ }
+ }
+ HW_ENDCLIPLOOP();
}
- HW_ENDCLIPLOOP();
+ HW_UNLOCK();
}
static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
@@ -74,25 +90,29 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
- GLuint i;
- LOCAL_VARS;
-
- if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
-
- HW_CLIPLOOP()
+ HW_LOCK()
{
- for (i=0;i<n;i++)
- {
- if (mask[i]) {
- const int fy = Y_FLIP(y[i]);
- if (CLIPPIXEL(x[i],fy))
- WRITE_RGBA( x[i], fy,
- rgba[i][0], rgba[i][1],
- rgba[i][2], rgba[i][3] );
+ GLint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ {
+ if (mask[i]) {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_RGBA( x[i], fy,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
}
- }
+ HW_ENDCLIPLOOP();
}
- HW_ENDCLIPLOOP();
+ HW_UNLOCK();
}
@@ -100,23 +120,28 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte mask[] )
{
- GLuint x1,n1;
- LOCAL_VARS;
- INIT_MONO_PIXEL(p);
-
- y = Y_FLIP( y );
-
- if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
-
- HW_CLIPLOOP()
+ HW_LOCK()
{
- GLuint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
- for (;i<n1;i++,x1++)
- if (mask[i])
- WRITE_PIXEL( x1, y, p );
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p);
+
+ y = Y_FLIP( y );
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;i<n1;i++,x1++)
+ if (mask[i])
+ WRITE_PIXEL( x1, y, p );
+ }
+ HW_ENDCLIPLOOP();
}
- HW_ENDCLIPLOOP();
+ HW_UNLOCK();
}
@@ -125,22 +150,26 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
const GLint x[], const GLint y[],
const GLubyte mask[] )
{
- GLuint i;
- LOCAL_VARS;
- INIT_MONO_PIXEL(p);
-
- if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
-
- HW_CLIPLOOP()
+ HW_LOCK()
{
- for (i=0;i<n;i++)
- if (mask[i]) {
- int fy = Y_FLIP(y[i]);
- if (CLIPPIXEL( x[i], fy ))
- WRITE_PIXEL( x[i], fy, p );
+ GLint i;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p);
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL( x[i], fy ))
+ WRITE_PIXEL( x[i], fy, p );
+ }
}
- }
- HW_ENDCLIPLOOP();
+ HW_ENDCLIPLOOP();
+ }
+ HW_UNLOCK();
}
@@ -152,42 +181,50 @@ static void TAG(ReadRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
- GLuint x1,n1;
- LOCAL_VARS;
+ HW_LOCK()
+ {
+ GLint x1,n1;
+ LOCAL_VARS;
- y = Y_FLIP(y);
+ y = Y_FLIP(y);
- if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
- HW_CLIPLOOP()
- {
- GLuint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
- for (;i<n1;i++)
- READ_RGBA( rgba[i], x1+i, y );
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;i<n1;i++)
+ READ_RGBA( rgba[i], (x1+i), y );
+ }
+ HW_ENDCLIPLOOP();
}
- HW_ENDCLIPLOOP();
+ HW_UNLOCK();
}
static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[] )
{
- GLuint i;
- LOCAL_VARS;
+ HW_LOCK()
+ {
+ GLint i;
+ LOCAL_VARS;
- if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
+ if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
- HW_CLIPLOOP()
- {
- for (i=0;i<n;i++)
- if (mask[i]) {
- int fy = Y_FLIP( y[i] );
- if (CLIPPIXEL( x[i], fy ))
- READ_RGBA( rgba[i], x[i], fy );
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_RGBA( rgba[i], x[i], fy );
+ }
}
+ HW_ENDCLIPLOOP();
}
- HW_ENDCLIPLOOP();
+ HW_UNLOCK();
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/Imakefile b/xc/lib/GL/mesa/src/drv/i810/Imakefile
index 5f1d93072..5c6a33796 100644
--- a/xc/lib/GL/mesa/src/drv/i810/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/i810/Imakefile
@@ -1,4 +1,6 @@
+#include <Threads.tmpl>
+
#define DoNormalLib NormalLibGlx
#define DoSharedLib SharedLibGlx
#define DoExtraLib SharedLibGlx
@@ -10,12 +12,14 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines -DFX -DFX_GLIDE3 -DGLIDE3 -DDRIVERTS
+ DRI_DEFINES = GlxDefines -DDRIVERTS
DRI_INCLUDES = -I../../../../dri -I../../../../glx \
+ -I../../../dri \
-I$(TOP)/include -I$(TOP)/include/GL \
-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
- -I$(XF86DRIVERSRC)/i810 \
- -I../../../include -I../.. -I../../X
+ -I$(XF86DRIVERSRC)/i810 \
+ -I../../../include -I../.. -I../common -I../../X \
+ -I$(XF86OSSRC)/linux/drm/kernel
#endif
MESA_INCLUDES = -I. -I.. -I../../include
@@ -23,20 +27,234 @@ MESA_INCLUDES = -I. -I.. -I../../include
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
- INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \
- -I/usr/include/glide
- DRISRCS = i810_init.c i810_inithw.c i810_xmesa.c i810clear.c \
- i810context.c i810dd.c i810depth.c i810dma.c \
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+ DRISRCS = ../../../dri/dri_mesa.c \
+ ../../../../dri/dri_tmm.c
+
+ DRIOBJS = ../../../dri/dri_mesa.o \
+ ../../../../dri/dri_tmm.o
+
+ DRMSRCS = ../../../../dri/drm/xf86drm.c \
+ ../../../../dri/drm/xf86drmHash.c \
+ ../../../../dri/drm/xf86drmRandom.c \
+ ../../../../dri/drm/xf86drmSL.c
+
+ DRMOBJS = ../../../../dri/drm/xf86drm.o \
+ ../../../../dri/drm/xf86drmHash.o \
+ ../../../../dri/drm/xf86drmRandom.o \
+ ../../../../dri/drm/xf86drmSL.o
+
+
+ I810SRCS = i810_xmesa.c i810clear.c \
+ i810dd.c \
i810pipeline.c i810span.c i810state.c i810swap.c \
- i810tex.c i810tris.c i810vb.c
+ i810tex.c i810tris.c i810vb.c i810fastpath.c i810ioctl.c
- DRIOBJS = i810_init.o i810_inithw.o i810_xmesa.o i810clear.o \
- i810context.o i810dd.o i810depth.o i810dma.o \
+ I810OBJS = i810_xmesa.o i810clear.o \
+ i810dd.o \
i810pipeline.o i810span.o i810state.o i810swap.o \
- i810tex.o i810tris.o i810vb.o
+ i810tex.o i810tris.o i810vb.o i810fastpath.o i810ioctl.o
+
+ MESASRCS = ../../accum.c \
+ ../../alpha.c \
+ ../../alphabuf.c \
+ ../../attrib.c \
+ ../../bbox.c \
+ ../../bitmap.c \
+ ../../blend.c \
+ ../../buffers.c \
+ ../../clip.c \
+ ../../colortab.c \
+ ../../config.c \
+ ../../context.c \
+ ../../copypix.c \
+ ../../cva.c \
+ ../../debug_xform.c \
+ ../../depth.c \
+ ../../dlist.c \
+ ../../drawpix.c \
+ ../../enable.c \
+ ../../enums.c \
+ ../../eval.c \
+ ../../extensions.c \
+ ../../feedback.c \
+ ../../fog.c \
+ ../../get.c \
+ ../../glapi.c \
+ ../../glapinoop.c \
+ ../../glthread.c \
+ ../../hash.c \
+ ../../image.c \
+ ../../imaging.o \
+ ../../light.c \
+ ../../lines.c \
+ ../../logic.c \
+ ../../masking.c \
+ ../../matrix.c \
+ ../../mem.c \
+ ../../mmath.c \
+ ../../pb.c \
+ ../../pipeline.c \
+ ../../pixel.c \
+ ../../points.c \
+ ../../polygon.c \
+ ../../quads.c \
+ ../../rastpos.c \
+ ../../readpix.c \
+ ../../rect.c \
+ ../../scissor.c \
+ ../../shade.c \
+ ../../span.c \
+ ../../stages.c \
+ ../../state.c \
+ ../../stencil.c \
+ ../../teximage.c \
+ ../../texobj.c \
+ ../../texstate.c \
+ ../../texture.c \
+ ../../translate.c \
+ ../../triangle.c \
+ ../../varray.c \
+ ../../vb.c \
+ ../../vbcull.c \
+ ../../vbfill.c \
+ ../../vbindirect.c \
+ ../../vbrender.c \
+ ../../vbxform.c \
+ ../../vector.c \
+ ../../vertices.c \
+ ../../winpos.c \
+ ../../xform.c \
+ ../../zoom.c \
+ ../../X86/common_x86.c
+
+ MESAOBJS = ../../accum.o \
+ ../../alpha.o \
+ ../../alphabuf.o \
+ ../../attrib.o \
+ ../../bbox.o \
+ ../../bitmap.o \
+ ../../blend.o \
+ ../../buffers.o \
+ ../../clip.o \
+ ../../colortab.o \
+ ../../config.o \
+ ../../context.o \
+ ../../copypix.o \
+ ../../cva.o \
+ ../../debug_xform.o \
+ ../../depth.o \
+ ../../dlist.o \
+ ../../drawpix.o \
+ ../../enable.o \
+ ../../enums.o \
+ ../../eval.o \
+ ../../extensions.o \
+ ../../feedback.o \
+ ../../fog.o \
+ ../../get.o \
+ ../../hash.o \
+ ../../hint.o \
+ ../../image.o \
+ ../../imaging.o \
+ ../../light.o \
+ ../../lines.o \
+ ../../logic.o \
+ ../../masking.o \
+ ../../matrix.o \
+ ../../mem.o \
+ ../../mmath.o \
+ ../../pb.o \
+ ../../pipeline.o \
+ ../../pixel.o \
+ ../../points.o \
+ ../../polygon.o \
+ ../../quads.o \
+ ../../rastpos.o \
+ ../../readpix.o \
+ ../../rect.o \
+ ../../scissor.o \
+ ../../shade.o \
+ ../../span.o \
+ ../../stages.o \
+ ../../state.o \
+ ../../stencil.o \
+ ../../teximage.o \
+ ../../texobj.o \
+ ../../texstate.o \
+ ../../texture.o \
+ ../../translate.o \
+ ../../triangle.o \
+ ../../varray.o \
+ ../../vb.o \
+ ../../vbcull.o \
+ ../../vbfill.o \
+ ../../vbindirect.o \
+ ../../vbrender.o \
+ ../../vbxform.o \
+ ../../vector.o \
+ ../../vertices.o \
+ ../../winpos.o \
+ ../../xform.o \
+ ../../zoom.o
+
+#ifdef i386Architecture
+ X86_SRCS = ../../X86/x86.c \
+ ../../X86/x86a.S \
+ ../../X86/common_x86.c \
+ ../../X86/common_x86asm.S \
+ ../../X86/vertex.S
+
+ X86_OBJS = ../../X86/x86.o \
+ ../../X86/x86a.o \
+ ../../X86/common_x86.o \
+ ../../X86/common_x86asm.o \
+ ../../X86/vertex.o
+
+ MMX_SRCS = ../../X86/mmx_blend.S
+
+ MMX_OBJS = ../../X86/mmx_blend.o
+
+XCOMM Disabling 3Dnow code for the time being.
+#if 0
+ 3DNOW_SRCS = ../../X86/3dnow.c \
+ ../../X86/3dnow_norm_raw.S \
+ ../../X86/3dnow_xform_masked1.S \
+ ../../X86/3dnow_xform_masked2.S \
+ ../../X86/3dnow_xform_masked3.S \
+ ../../X86/3dnow_xform_masked4.S \
+ ../../X86/3dnow_xform_raw1.S \
+ ../../X86/3dnow_xform_raw2.S \
+ ../../X86/3dnow_xform_raw3.S \
+ ../../X86/3dnow_xform_raw4.S \
+ ../../X86/vertex_3dnow.S
+
+ 3DNOW_OBJS = ../../X86/3dnow.o \
+ ../../X86/3dnow_norm_raw.o \
+ ../../X86/3dnow_xform_masked1.o \
+ ../../X86/3dnow_xform_masked2.o \
+ ../../X86/3dnow_xform_masked3.o \
+ ../../X86/3dnow_xform_masked4.o \
+ ../../X86/3dnow_xform_raw1.o \
+ ../../X86/3dnow_xform_raw2.o \
+ ../../X86/3dnow_xform_raw3.o \
+ ../../X86/3dnow_xform_raw4.o \
+ ../../X86/vertex_3dnow.o
+#endif
+
+#endif
+
+ ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
+ ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+
+ COMMONSRCS = ../common/mm.c ../common/hwlog.c
+ COMMONOBJS = ../common/mm.o ../common/hwlog.o
+
+ SRCS = $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) $(COMMONSRCS) $(I810SRCS)
+ OBJS = $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) $(COMMONOBJS) $(I810OBJS)
- SRCS = $(DRISRCS)
- OBJS = $(DRIOBJS)
+REQUIREDLIBS += -lm
#if !GlxUseBuiltInDRIDriver
#undef DoNormalLib NormalLibGlx
@@ -57,7 +275,7 @@ LIBNAME = i810_dri.so
ALL_OBJS = $(OBJS)
ALL_DEPS = DONE
SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
-InstallDynamicModule($(LIBNAME),$(MODULEDIR),.)
+InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.)
#endif
DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h b/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
index 677a35222..e4e274e9a 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
@@ -75,7 +75,8 @@
* 4: DR4_*
*/
#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
-#define DR1_RECT_CLIP_ENABLE (0x1<<31)
+#define DR1_RECT_CLIP_ENABLE (0x0<<31)
+#define DR1_RECT_CLIP_DISABLE (0x1<<31)
#define DR1_X_DITHER_BIAS_MASK (0x3<<26)
#define DR1_X_DITHER_BIAS_SHIFT 26
#define DR1_Y_DITHER_BIAS_MASK (0x3<<24)
@@ -107,6 +108,8 @@
#define LCS_UPDATE_LINEWIDTH (0x1<<15)
#define LCS_LINEWIDTH_MASK (0x7<<12)
#define LCS_LINEWIDTH_SHIFT 12
+#define LCS_LINEWIDTH_0_5 (0x1<<12)
+#define LCS_LINEWIDTH_1_0 (0x2<<12)
#define LCS_UPDATE_ALPHA_INTERP (0x1<<11)
#define LCS_ALPHA_FLAT (0x0<<10)
#define LCS_ALPHA_INTERP (0x1<<10)
@@ -238,18 +241,6 @@
#define SDM_DST_BOTH_SRC_ALPHA (0xc<<0)
#define SDM_DST_BOTH_INV_SRC_ALPHA (0xd<<0)
-/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135
- */
-#define GFX_OP_COLOR_CHROMA_KEY ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1)
-#define CC1_UPDATE_CC_TEST_ENABLE (1<<28)
-#define CC1_CC_TEST_ENABLE (1<<27)
-#define CC1_UPDATE_CI_VALUE (1<<26)
-#define CC1_UPDATE_CK_LOW_VALUE (1<<25)
-#define CC1_UPDATE_CK_HI_VALUE (1<<24)
-#define CC1_CK_LOW_VALUE_MASK ((1<<24)-1)
-#define CC2_CI_VALUE_MASK (0xff<<24)
-#define CC2_CI_VALUE_SHIFT 24
-#define CC2_CK_HIGH_VALUE_MASK ((1<<24)-1)
/* GFXRENDERSTATE_COLOR_FACTOR, p134
*
@@ -628,13 +619,43 @@ typedef struct {
#define DV_PF_565 (0x2<<8)
+
+
+#define GFX_OP_ANTIALIAS ((0x3<<29)|(0x6<<24))
+#define AA_UPDATE_EDGEFLAG (1<<13)
+#define AA_ENABLE_EDGEFLAG (1<<12)
+#define AA_UPDATE_POLYWIDTH (1<<11)
+#define AA_POLYWIDTH_05 (1<<9)
+#define AA_POLYWIDTH_10 (2<<9)
+#define AA_POLYWIDTH_20 (3<<9)
+#define AA_POLYWIDTH_40 (4<<9)
+#define AA_UPDATE_LINEWIDTH (1<<8)
+#define AA_LINEWIDTH_05 (1<<6)
+#define AA_LINEWIDTH_10 (2<<6)
+#define AA_LINEWIDTH_20 (3<<6)
+#define AA_LINEWIDTH_40 (4<<6)
+#define AA_UPDATE_BB_EXPANSION (1<<5)
+#define AA_BB_EXPANSION_SHIFT 2
+#define AA_UPDATE_AA_ENABLE (1<<1)
+#define AA_ENABLE (1<<0)
+
+#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define ST1_ENABLE (1<<16)
+#define ST1_MASK (0xffff)
+
+
/* Indices into buf.Setup where various bits of state are mirrored per
* context and per buffer. These can be fired at the card as a unit,
* or in a piecewise fashion as required.
*/
-/* Destbuffer state (includes zbuffer). Drawrect is the only thing
- * that needs to be restored for 2d???
+/* Destbuffer state
+ * - backbuffer linear offset and pitch -- invarient in the current dri
+ * - zbuffer linear offset and pitch -- also invarient
+ * - drawing origin in back and depth buffers.
+ *
+ * Keep the depth/back buffer state here to acommodate private buffers
+ * in the future.
*/
#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
#define I810_DESTREG_DI1 1
@@ -667,14 +688,24 @@ typedef struct {
#define I810_CTXREG_B1 12 /* GFX_OP_BOOL_1 */
#define I810_CTXREG_B2 13 /* GFX_OP_BOOL_2 */
#define I810_CTXREG_LCS 14 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
-#define I810_CTXREG_SCI0 15 /* GFX_OP_SCISSOR_INFO (3 dwords) */
-#define I810_CTXREG_SCI1 16
-#define I810_CTXREG_SCI2 17
-#define I810_CTXREG_SC 18 /* GFX_OP_SCISSOR */
-#define I810_CTXREG_PV 19 /* GFX_OP_PV_RULE -- Invarient! */
-#define I810_CTXREG_ZA 20 /* GFX_OP_ZBIAS_ALPHAFUNC */
-
-#define I810_CTX_SETUP_SIZE (21+1) /* pad to qword */
+#define I810_CTXREG_PV 15 /* GFX_OP_PV_RULE -- Invarient! */
+#define I810_CTXREG_ZA 16 /* GFX_OP_ZBIAS_ALPHAFUNC */
+#define I810_CTXREG_ST0 17 /* GFX_OP_STIPPLE */
+#define I810_CTXREG_ST1 18
+#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
+#define I810_CTX_SETUP_SIZE (20) /* pad to qword */
+
+
+/* Cliprect state - keep seperate from context as it is used for
+ * drawing triangles to the shared backbuffer, and
+ * changes more frequently than the 'normal' context.
+ */
+#define I810_CLIPREG_SCI0 0 /* GFX_OP_SCISSOR_INFO (3 dwords) */
+#define I810_CLIPREG_SCI1 1
+#define I810_CLIPREG_SCI2 2
+#define I810_CLIPREG_SC 3 /* GFX_OP_SCISSOR */
+
+#define I810_CLIP_SETUP_SIZE 4
/* Texture state (per tex_buffer)
*/
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_init.c b/xc/lib/GL/mesa/src/drv/i810/i810_init.c
deleted file mode 100644
index 5f37cd769..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810_init.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-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, sub license, 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 NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <keithw@precisioninsight.com>
- *
- * based on tdfx driver by
- * Daryll Strauss <daryll@precisioninsight.com>
- *
- * $PI: #
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xlibint.h>
-#include "xf86dri.h"
-#include "i810_dri.h"
-#include "i810_init.h"
-
-#ifdef DEBUG_LOCKING
-char *prevLockFile=0;
-int prevLockLine=0;
-#endif
-
-static void performMagic(__DRIscreenPrivate *driScrnPriv)
-{
- i810ScreenPrivate *gPriv = (i810ScreenPrivate *)driScrnPriv->private;
- I810DRIPtr gDRIPriv = (I810DRIPtr)driScrnPriv->pDevPriv;
-
- gPriv->regs.handle=gDRIPriv->regs;
- gPriv->regs.size=gDRIPriv->regsSize;
- gPriv->deviceID=gDRIPriv->deviceID;
- gPriv->width=gDRIPriv->width;
- gPriv->height=gDRIPriv->height;
- gPriv->mem=gDRIPriv->mem;
- gPriv->cpp=gDRIPriv->cpp;
- gPriv->stride=gDRIPriv->stride;
- gPriv->fbOffset=gDRIPriv->fbOffset;
- gPriv->backOffset=gDRIPriv->backOffset;
- gPriv->depthOffset=gDRIPriv->depthOffset;
- gPriv->textureOffset=gDRIPriv->textureOffset;
- gPriv->textureSize=gDRIPriv->textureSize;
-}
-
-GLboolean i810MapAllRegions(__DRIscreenPrivate *driScrnPriv)
-{
- i810ScreenPrivate *gPriv = (i810ScreenPrivate *)driScrnPriv->private;
-
- /* First, pick apart pDevPriv & friends */
- performMagic(driScrnPriv);
-
- if (drmMap(driScrnPriv->fd, gPriv->regs.handle, gPriv->regs.size,
- &gPriv->regs.map)) {
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-void i810UnmapAllRegions(__DRIscreenPrivate *driScrnPriv)
-{
- i810ScreenPrivate *gPriv = (i810ScreenPrivate *)driScrnPriv->private;
-
- drmUnmap(gPriv->regs.map, gPriv->regs.size);
-}
-
-/*
- * Shutdown hardware - nothing to do...
- */
-void i810CloseHardware(void)
-{
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_init.h b/xc/lib/GL/mesa/src/drv/i810/i810_init.h
index c7af9c443..804f66889 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810_init.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810_init.h
@@ -27,7 +27,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Daryll Strauss <daryll@precisioninsight.com>
+ * Keith Whitwell <keithw@precisioninsight.com>
*
*/
@@ -37,7 +37,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
#include <sys/time.h>
-#include <glide.h>
#include "dri_tmm.h"
#include "dri_mesaint.h"
#include "dri_mesa.h"
@@ -45,148 +44,88 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xmesaP.h"
typedef struct {
- drmHandle handle;
- drmSize size;
- drmAddress map;
+ drmHandle handle;
+ drmSize size;
+ char *map;
} i810Region, *i810RegionPtr;
typedef struct {
- i810Region regs;
- int deviceID;
- int width;
- int height;
- int mem;
- int cpp;
- int stride;
- int fbOffset;
- int backOffset;
- int depthOffset;
- int textureOffset;
- int textureSize;
- __DRIscreenPrivate *driScrnPriv;
-} i810ScreenPrivate;
+ i810Region front;
+ i810Region back;
+ i810Region depth;
+ i810Region tex;
-typedef struct {
- volatile int *fifoPtr;
- volatile int *fifoRead;
- volatile int fifoOwner;
- volatile int ctxOwner;
- volatile int texOwner;
-} I810SAREAPriv;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+
+ int cpp; /* for front and back buffers */
+ int bitsPerPixel;
+
+ int fbFormat;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int backPitch;
+ int backPitchBits;
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+ __DRIscreenPrivate *driScrnPriv;
+ drmBufMapPtr bufs;
+
+} i810ScreenPrivate;
#include "i810context.h"
-extern GLboolean i810MapAllRegions(__DRIscreenPrivate *driScrnPriv);
-extern void i810UnmapAllRegions(__DRIscreenPrivate *driScrnPriv);
-extern GLboolean i810InitHW(XMesaContext c);
-
-extern void XMesaWindowMoved(XMesaContext *c);
-extern void XMesaUpdateState(XMesaContext *c, int windowMoved);
-extern void XMesaSetSAREA(XMesaContext *c);
-
-extern XMesaContext gCC;
-extern i810ContextPtr i810Ctx;
-
-/*
-You can turn this on to find locking conflicts.
-#define DEBUG_LOCKING
-*/
-
-#ifdef 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
+extern void i810GetLock( i810ContextPtr imesa, GLuint flags );
+extern void i810EmitHwStateLocked( i810ContextPtr imesa );
+extern void i810EmitScissorValues( i810ContextPtr imesa, int box_nr, int emit );
+extern void i810EmitDrawingRectangle( i810ContextPtr imesa );
+extern void i810XMesaSetBackClipRects( i810ContextPtr imesa );
+extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa );
-/* !!! 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)
-
-/* Lock the hardware using the global current context */
-#define LOCK_HARDWARE() \
- do { \
- int stamp; \
- char __ret=0; \
- __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \
- __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \
- DEBUG_CHECK_LOCK(); \
- DRM_LIGHT_LOCK_RETURN(sPriv->fd, &sPriv->pSAREA->lock, \
- dPriv->driContextPriv->hHWContext, __ret); \
- if (__ret) __ret=1; \
- stamp=dPriv->lastStamp; \
- XMESA_VALIDATE_DRAWABLE_INFO(gCC->display, sPriv, dPriv); \
- if (*(dPriv->pStamp)!=stamp) __ret=2; \
- if (__ret) XMesaUpdateState(gCC, __ret==2); \
- DEBUG_LOCK(); \
- } while (0)
-/* Unlock the hardware using the global current context */
-#define UNLOCK_HARDWARE() \
- do { \
- __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \
- __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \
- XMesaSetSAREA(gCC); \
- DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, \
- dPriv->driContextPriv->hHWContext); \
- DEBUG_RESET(); \
- } while (0)
+#define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
-#define BEGIN_BOARD_LOCK() LOCK_HARDWARE()
-#define END_BOARD_LOCK() UNLOCK_HARDWARE()
-/*
- 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() \
- do { \
- __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \
- int _nc = dPriv->numClipRects; \
- LOCK_HARDWARE(); \
- while (_nc--) { \
- if (i810Ctx->needClip) { \
- i810Ctx->clipMinX=dPriv->pClipRects[_nc].x1; \
- i810Ctx->clipMaxX=dPriv->pClipRects[_nc].x2; \
- i810Ctx->clipMinY=dPriv->pClipRects[_nc].y1; \
- i810Ctx->clipMaxY=dPriv->pClipRects[_nc].y2; \
- i810SetScissorValues(i810Ctx->glCtx); \
- }
-
-#define END_CLIP_LOOP() \
- } \
- UNLOCK_HARDWARE(); \
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( imesa ) \
+ do { \
+ char __ret=0; \
+ DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
+ (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
+ if (__ret) \
+ i810GetLock( imesa, 0 ); \
} while (0)
+
+
+/* Unlock the hardware using the global current context
+ */
+#define UNLOCK_HARDWARE(imesa) \
+ DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
+
+
+/* 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,
+ * this is 3 ioctls. The best solution probably only gets me down
+ * to 2 ioctls in the worst case.
+ */
+#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
+ LOCK_HARDWARE( imesa ); \
+ i810RegetLockQuiescent( imesa ); \
+} while(0)
+
+
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_inithw.c b/xc/lib/GL/mesa/src/drv/i810/i810_inithw.c
deleted file mode 100644
index 6bcae44c7..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810_inithw.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-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, sub license, 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 NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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:
- * Daryll Strauss <daryll@precisioninsight.com>
- *
- * $PI: $
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "i810_init.h"
-#include <glide.h>
-
-GLboolean i810InitHW(XMesaContext c)
-{
- /* KW: Would be nice to make one of these a member of the other.
- */
- i810ContextPtr cPriv = (i810ContextPtr)c->private;
- __DRIdrawablePrivate *driDrawPriv = c->driContextPriv->driDrawablePriv;
- __DRIscreenPrivate *driScrnPriv = driDrawPriv->driScreenPriv;
- i810ScreenPrivate *sPriv = (i810ScreenPrivate*)driScrnPriv->private;
-
-#ifdef DEBUG_LOCKING
- fprintf(stderr, "Debug locking enabled\n");
-#endif
-
- if (cPriv->initDone) return GL_TRUE;
-
- cPriv->width=driDrawPriv->w;
- cPriv->height=driDrawPriv->h;
-
- DRM_LIGHT_LOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock,
- driDrawPriv->driContextPriv->hHWContext);
- FX_grGlideInit_NoLock();
-
-
- if (sPriv->deviceID==0x3)
- cPriv->haveTwoTMUs=GL_FALSE;
- else
- cPriv->haveTwoTMUs=GL_TRUE;
-
- /* !!! We are forcing these !!! */
- cPriv->haveDoubleBuffer=GL_TRUE;
- cPriv->haveAlphaBuffer=GL_FALSE;
- cPriv->haveZBuffer=GL_TRUE;
- cPriv->haveGlobalPaletteTexture=GL_FALSE;
-
- cPriv->glideContext = FX_grSstWinOpen_NoLock((FxU32)-1, GR_RESOLUTION_NONE,
- GR_REFRESH_NONE,
- GR_COLORFORMAT_ARGB,
- GR_ORIGIN_LOWER_LEFT, 2, 1);
-
-
- grDRIResetSAREA();
-
- DRM_UNLOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock,
- driDrawPriv->driContextPriv->hHWContext);
-
- cPriv->needClip=1;
-
- if (!fxDDInitFxMesaContext( fxMesa ))
- return GL_FALSE;
-
- cPriv->initDone=GL_TRUE;
- return GL_TRUE;
-
-}
-
-#endif
-
-
-
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c
index d4b540507..7716b4634 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c
@@ -27,21 +27,54 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Daryll Strauss <daryll@precisioninsight.com>
+ * Keith Whitwell <keithw@precisioninsight.com>
*
*/
#ifdef GLX_DIRECT_RENDERING
#include <X11/Xlibint.h>
-#include <glide.h>
+#include <stdio.h>
+
#include "i810_init.h"
#include "context.h"
#include "vbxform.h"
#include "matrix.h"
+#include "simple_list.h"
+
+#include "i810dd.h"
+#include "i810state.h"
+#include "i810tex.h"
+#include "i810span.h"
+#include "i810tris.h"
+#include "i810swap.h"
+#include "i810pipeline.h"
+#include "i810ioctl.h"
+
+#include "i810_dri.h"
+
+
+
+#ifndef I810_DEBUG
+int I810_DEBUG = (0
+/* | DEBUG_ALWAYS_SYNC */
+/* | DEBUG_VERBOSE_RING */
+/* | DEBUG_VERBOSE_OUTREG */
+/* | DEBUG_VERBOSE_MSG */
+/* | DEBUG_NO_OUTRING */
+/* | DEBUG_NO_OUTREG */
+/* | DEBUG_VERBOSE_API */
+/* | DEBUG_VERBOSE_2D */
+/* | DEBUG_VERBOSE_DRI */
+/* | DEBUG_VALIDATE_RING */
+/* | DEBUG_VERBOSE_IOCTL */
+ );
+#endif
+
+
+static i810ContextPtr i810Ctx = 0;
-XMesaContext gCC = 0;
-i810ContextPtr *i810Ctx = 0;
+i810Glx_t i810glx;
static int count_bits(unsigned int n)
{
@@ -76,32 +109,106 @@ static int count_bits(unsigned int n)
*/
-GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv)
+GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
{
- i810ScreenPrivate *gsp;
+ i810ScreenPrivate *i810Screen;
+ I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
/* Allocate the private area */
- gsp = (i810ScreenPrivate *)Xmalloc(sizeof(i810ScreenPrivate));
- if (!gsp) return GL_FALSE;
+ i810Screen = (i810ScreenPrivate *)Xmalloc(sizeof(i810ScreenPrivate));
+ if (!i810Screen) return GL_FALSE;
+
+ i810Screen->driScrnPriv = sPriv;
+ sPriv->private = (void *)i810Screen;
+
+ i810Screen->deviceID=gDRIPriv->deviceID;
+ i810Screen->width=gDRIPriv->width;
+ i810Screen->height=gDRIPriv->height;
+ i810Screen->mem=gDRIPriv->mem;
+ i810Screen->cpp=gDRIPriv->cpp;
+ i810Screen->fbStride=gDRIPriv->fbStride;
+ i810Screen->fbOffset=gDRIPriv->fbOffset;
+
+ if (gDRIPriv->bitsPerPixel == 15)
+ i810Screen->fbFormat = DV_PF_555;
+ else
+ i810Screen->fbFormat = DV_PF_565;
+
+ i810Screen->backOffset=gDRIPriv->backOffset;
+ i810Screen->depthOffset=gDRIPriv->depthOffset;
+ i810Screen->backPitch = gDRIPriv->auxPitch;
+ i810Screen->backPitchBits = gDRIPriv->auxPitchBits;
+ i810Screen->textureOffset=gDRIPriv->textureOffset;
+ i810Screen->textureSize=gDRIPriv->textureSize;
+ i810Screen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+
+ if (1)
+ fprintf(stderr, "Tex heap size %x, granularity %x bytes\n",
+ i810Screen->textureSize, 1<<(i810Screen->logTextureGranularity));
+
+ i810Screen->bufs = drmMapBufs(sPriv->fd);
+
+
+ i810Screen->back.handle = gDRIPriv->backbuffer;
+ i810Screen->back.size = gDRIPriv->backbufferSize;
+
+ if (drmMap(sPriv->fd,
+ i810Screen->back.handle,
+ i810Screen->back.size,
+ (drmAddress *)&i810Screen->back.map) != 0)
+ {
+ Xfree(i810Screen);
+ return GL_FALSE;
+ }
+
+ i810Screen->depth.handle = gDRIPriv->depthbuffer;
+ i810Screen->depth.size = gDRIPriv->depthbufferSize;
- gsp->driScrnPriv = driScrnPriv;
+ if (drmMap(sPriv->fd,
+ i810Screen->depth.handle,
+ i810Screen->depth.size,
+ (drmAddress *)&i810Screen->depth.map) != 0)
+ {
+ Xfree(i810Screen);
+ return GL_FALSE;
+ }
- driScrnPriv->private = (void *)gsp;
+ i810Screen->tex.handle = gDRIPriv->textures;
+ i810Screen->tex.size = gDRIPriv->textureSize;
- if (!i810MapAllRegions(driScrnPriv)) {
- Xfree(driScrnPriv->private);
+ if (drmMap(sPriv->fd,
+ i810Screen->tex.handle,
+ i810Screen->tex.size,
+ (drmAddress *)&i810Screen->tex.map) != 0)
+ {
+ Xfree(i810Screen);
return GL_FALSE;
}
+
+ /* Ditch i810glx in favor of i810Screen?
+ */
+ memset(&i810glx, 0, sizeof(i810glx));
+ i810glx.texVirtual = i810Screen->tex.map;
+
+ i810DDFastPathInit();
+ i810DDTrifuncInit();
+ i810DDSetupInit();
+
return GL_TRUE;
}
/* Accessed by dlsym from dri_mesa_init.c
*/
-void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv)
+void XMesaResetDriver(__DRIscreenPrivate *sPriv)
{
- i810UnmapAllRegions(driScrnPriv); /* in i810_init.c */
- Xfree(driScrnPriv->private);
+ i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
+
+ /* Need to unmap all the bufs and maps here:
+ */
+
+
+ Xfree(i810Screen);
}
/* Accessed by dlsym from dri_mesa_init.c
@@ -135,27 +242,18 @@ XMesaVisual XMesaCreateVisual(XMesaDisplay *display,
v->display = display;
v->level = level;
-
- v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual));
+ v->gl_visual = gl_create_visual(rgb_flag, GL_FALSE, db_flag, stereo_flag,
+ depth_size, stencil_size, accum_size, 0,
+ count_bits(visinfo->red_mask),
+ count_bits(visinfo->green_mask),
+ count_bits(visinfo->blue_mask),
+ GL_FALSE);
if (!v->gl_visual) {
Xfree(v->visinfo);
- XFree(v);
- return 0;
+ Xfree(v);
+ return NULL;
}
-
- v->gl_visual->RGBAflag = rgb_flag;
- v->gl_visual->DBflag = db_flag;
- v->gl_visual->StereoFlag = stereo_flag;
-
- v->gl_visual->RedBits = count_bits(visinfo->red_mask);
- v->gl_visual->GreenBits = count_bits(visinfo->green_mask);
- v->gl_visual->BlueBits = count_bits(visinfo->blue_mask);
- v->gl_visual->AlphaBits = 0; /* Not currently supported */
-
- v->gl_visual->AccumBits = accum_size;
- v->gl_visual->DepthBits = depth_size;
- v->gl_visual->StencilBits = stencil_size;
-
+
return v;
}
@@ -169,71 +267,143 @@ void XMesaDestroyVisual(XMesaVisual v)
XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
__DRIcontextPrivate *driContextPriv)
{
+ GLcontext *ctx;
XMesaContext c;
- i810ContextPtr cPriv;
- __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
- i810ScreenPrivate *sPriv = (i810ScreenPrivate *)driScrnPriv->private;
- I810SAREAPriv *saPriv;
- GLcontext *shareCtx;
-/* int **fifoPtr; */
+ i810ContextPtr imesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
+ drm_i810_sarea_t *saPriv=(drm_i810_sarea_t *)(((char*)sPriv->pSAREA)+
+ sizeof(XF86DRISAREARec));
+
+ GLcontext *shareCtx = 0;
c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context));
- if (!c) return 0;
+ if (!c) {
+ return 0;
+ }
+
+ imesa = (i810ContextPtr)Xcalloc(sizeof(i810Context), 1);
+ if (!imesa) {
+ Xfree(c);
+ return 0;
+ }
c->driContextPriv = driContextPriv;
c->xm_visual = v;
c->xm_buffer = 0; /* Set by MakeCurrent */
c->display = v->display;
+ c->private = (void *)imesa;
- cPriv = (i810ContextPtr)Xmalloc(sizeof(i810Context));
- if (!cPriv) {
- Xfree(c);
- return NULL;
- }
+ if (share_list)
+ shareCtx=((i810ContextPtr)(share_list->private))->glCtx;
- cPriv->hHWContext = driContextPriv->hHWContext;
- cPriv->i810ScrnPriv = sPriv;
- c->private = (void *)cPriv;
+ ctx = imesa->glCtx = gl_create_context(v->gl_visual, shareCtx,
+ (void*)imesa, GL_TRUE);
- cPriv->glVis=v->gl_visual;
- cPriv->glBuffer=gl_create_framebuffer(v->gl_visual);
- cPriv->screen_width=sPriv->width;
- cPriv->screen_height=sPriv->height;
- cPriv->new_state = ~0;
+ /* Set the maximum texture size small enough that we can guarentee
+ * that both texture units can bind a maximal texture and have them
+ * in memory at once.
+ */
+ if (i810Screen->textureSize < 2*1024*1024) {
+ ctx->Const.MaxTextureLevels = 8;
+ ctx->Const.MaxTextureSize = 1<<8;
+ } else if (i810Screen->textureSize < 8*1024*1024) {
+ ctx->Const.MaxTextureLevels = 9;
+ ctx->Const.MaxTextureSize = 1<<9;
+ } else {
+ ctx->Const.MaxTextureLevels = 10;
+ ctx->Const.MaxTextureSize = 1<<10;
+ }
- if (share_list)
- shareCtx=((i810ContextPtr)(share_list->private))->glCtx;
- else
- shareCtx=0;
- cPriv->glCtx=gl_create_context(v->gl_visual, shareCtx, (void*)cPriv, GL_TRUE);
- cPriv->initDone=GL_FALSE;
- saPriv=(I810SAREAPriv*)((void*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec));
+ /* Dri stuff
+ */
+ imesa->display = v->display;
+ imesa->hHWContext = driContextPriv->hHWContext;
+ imesa->driFd = sPriv->fd;
+ imesa->driHwLock = &sPriv->pSAREA->lock;
+ imesa->i810Screen = i810Screen;
+ imesa->driScreen = sPriv;
+ imesa->sarea = saPriv;
- fprintf(stderr, "would call grDRIOpen here\n");
+ imesa->glBuffer = gl_create_framebuffer(v->gl_visual,
+ GL_FALSE,
+ v->gl_visual->StencilBits > 0,
+ v->gl_visual->AccumBits > 0,
+ v->gl_visual->AlphaBits > 0);
-/*
- grDRIOpen(driScrnPriv->pFB, sPriv->regs.map, sPriv->deviceID,
- sPriv->width, sPriv->height, sPriv->mem, sPriv->cpp, sPriv->stride,
- sPriv->fifoOffset, sPriv->fifoSize, sPriv->fbOffset,
- sPriv->backOffset, sPriv->depthOffset, sPriv->textureOffset,
- sPriv->textureSize, &saPriv->fifoPtr, &saPriv->fifoRead);
-*/
+ imesa->texHeap = mmInit( 0, i810Screen->textureSize );
+
+
+ /* Utah stuff
+ */
+ imesa->renderindex = -1; /* impossible value */
+ imesa->new_state = ~0;
+ imesa->dirty = ~0;
+
+ make_empty_list(&imesa->TexObjList);
+ make_empty_list(&imesa->SwappedOut);
+
+ imesa->TextureMode = ctx->Texture.Unit[0].EnvMode;
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
+
+ i810DDExtensionsInit( ctx );
+
+ i810DDInitStateFuncs( ctx );
+ i810DDInitTextureFuncs( ctx );
+ i810DDInitSpanFuncs( ctx );
+ i810DDInitDriverFuncs( ctx );
+ i810DDInitIoctlFuncs( ctx );
+
+ ctx->Driver.TriangleCaps = (DD_TRI_CULL|
+ DD_TRI_LIGHT_TWOSIDE|
+ DD_TRI_STIPPLE|
+ DD_TRI_OFFSET);
+
+ /* Ask mesa to clip fog coordinates for us.
+ */
+ ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
+
+ ctx->Shared->DefaultD[2][0].DriverData = 0;
+ ctx->Shared->DefaultD[2][1].DriverData = 0;
+
+ if (ctx->VB)
+ i810DDRegisterVB( ctx->VB );
+
+ if (ctx->NrPipelineStages)
+ ctx->NrPipelineStages =
+ i810DDRegisterPipelineStages(ctx->PipelineStage,
+ ctx->PipelineStage,
+ ctx->NrPipelineStages);
+
+ i810DDInitState( imesa );
return c;
}
void XMesaDestroyContext(XMesaContext c)
{
- i810ContextPtr cPriv;
+ i810ContextPtr imesa = (i810ContextPtr) c->private;
+
+ if (imesa) {
+ i810TextureObjectPtr next_t, t;
- cPriv=(i810ContextPtr)c->private;
- if (cPriv) {
- gl_destroy_context(cPriv->glCtx);
- gl_destroy_framebuffer(cPriv->glBuffer);
+ gl_destroy_context(imesa->glCtx);
+ gl_destroy_framebuffer(imesa->glBuffer);
+
+ foreach_s (t, next_t, &(imesa->TexObjList))
+ i810DestroyTexObj(imesa, t);
+
+ foreach_s (t, next_t, &(imesa->SwappedOut))
+ i810DestroyTexObj(imesa, t);
+
+ Xfree(imesa);
+
+ c->private = 0;
}
}
@@ -254,137 +424,232 @@ void XMesaDestroyBuffer(XMesaBuffer b)
{
}
-void XMesaSwapBuffers(XMesaBuffer b)
+void XMesaSwapBuffers(XMesaBuffer bogus)
{
- FxI32 result;
- XMesaContext *xmc = b->xm_context;
- i810ContextPtr imesa;
-
- if (!xmc || !xmc->private) return;
+ i810ContextPtr imesa = i810Ctx;
- imesa = (i810ContextPtr) xmc->private;
+ FLUSH_VB( imesa->glCtx, "swap buffers" );
+ i810SwapBuffers(imesa);
+}
+
+static void i810InitClipRects( i810ContextPtr imesa )
+{
+ switch (imesa->numClipRects) {
+ case 0:
+ imesa->ClipSetup[I810_CLIPREG_SC] = ( GFX_OP_SCISSOR |
+ SC_UPDATE_SCISSOR );
+ imesa->ClipSetup[I810_CLIPREG_SCI1] = 0;
+ imesa->ClipSetup[I810_CLIPREG_SCI2] = 0;
+ break;
+ case 1:
+ break;
+ default:
+ break;
+ }
+ imesa->dirty |= I810_EMIT_CLIPRECT;
+}
- fprintf(stderr, "imesa %x i810Ctx %x\n", imesa, i810Ctx );
- FLUSH_VB( imesa->glCtx, "swap buffers" );
- if (imesa->haveDoubleBuffer) {
- i810BackToFront(imesa);
- i810Ctx->stats.swapBuffer++;
+void i810XMesaSetFrontClipRects( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+
+ imesa->drawMap = imesa->driScreen->pFB;
+ i810EmitDrawingRectangle( imesa );
+ i810InitClipRects( imesa );
+}
+
+
+void i810XMesaSetBackClipRects( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ int i;
+
+ if (dPriv->numBackClipRects == 0)
+ {
+ if (I810_DEBUG & DEBUG_VERBOSE_DRI)
+ fprintf(stderr, "FRONT_CLIPRECTS, %d rects\n",
+ dPriv->numClipRects);
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
} else {
- fprintf(stderr, "No double buffer\n");
+ if (I810_DEBUG & DEBUG_VERBOSE_DRI)
+ fprintf(stderr, "BACK_RECTS, %d rects\n",
+ dPriv->numBackClipRects);
+
+ imesa->numClipRects = dPriv->numBackClipRects;
+ imesa->pClipRects = dPriv->pBackClipRects;
+ imesa->drawX = dPriv->backX;
+ imesa->drawY = dPriv->backY;
}
+
+ imesa->drawMap = imesa->i810Screen->back.map;
+ i810EmitDrawingRectangle( imesa );
+ i810InitClipRects( imesa );
+
+ if (I810_DEBUG & DEBUG_VERBOSE_DRI)
+ for (i = 0 ; i < imesa->numClipRects ; i++)
+ fprintf(stderr, "cliprect %d: %d,%d - %d,%d\n",
+ i,
+ imesa->pClipRects[i].x1,
+ imesa->pClipRects[i].y1,
+ imesa->pClipRects[i].x2,
+ imesa->pClipRects[i].y2);
+}
+
+
+static void i810XMesaWindowMoved( i810ContextPtr imesa )
+{
+ if (0)
+ fprintf(stderr, "i810XMesaWindowMoved\n\n");
+
+ switch (imesa->glCtx->Color.DriverDrawBuffer) {
+ case GL_FRONT_LEFT:
+ i810XMesaSetFrontClipRects( imesa );
+ break;
+ case GL_BACK_LEFT:
+ i810XMesaSetBackClipRects( imesa );
+ break;
+ default:
+ fprintf(stderr, "fallback buffer\n");
+ break;
+ }
+}
+
+
+GLboolean XMesaUnbindContext(XMesaContext c)
+{
+ if (c->private)
+ ((i810ContextPtr)c->private)->dirty = ~0;
+
+ return GL_TRUE;
}
-/* This looks buggy to me:
+
+/* This looks buggy to me - the 'b' variable isn't used anywhere...
+ * Hmm - It seems that the drawable is already hooked in to
+ * driDrawablePriv.
*/
GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b)
{
- __DRIdrawablePrivate *driDrawPriv;
+
+ if (c->private==(void *)i810Ctx) return GL_TRUE;
if (c) {
- if (c==gCC) return GL_TRUE;
- gCC = c;
- i810Ctx = (i810ContextPtr)c->private;
+ __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv;
- fprintf(stderr, "Make current\n");
- driDrawPriv = c->driContextPriv->driDrawablePriv;
- if (!i810Ctx->initDone) {
- i810Ctx->width=driDrawPriv->w;
- i810Ctx->height=driDrawPriv->h;
- if (!i810InitHW(c)) return GL_FALSE;
- /* Zap the width to force XMesaWindowMoved to execute */
- i810Ctx->width=0;
- }
- FX_grSstSelect(i810Ctx->board);
- XMesaWindowMoved();
+ i810Ctx = (i810ContextPtr)c->private;
- FX_grGlideSetState((GrState*)i810Ctx->state);
gl_make_current(i810Ctx->glCtx, i810Ctx->glBuffer);
- fxSetupDDPointers(i810Ctx->glCtx);
+
+ i810Ctx->driDrawable = dPriv;
+ i810Ctx->dirty = ~0;
+
+ i810XMesaWindowMoved( i810Ctx );
+
if (!i810Ctx->glCtx->Viewport.Width)
- gl_Viewport(i810Ctx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h);
+ gl_Viewport(i810Ctx->glCtx, 0, 0, dPriv->w, dPriv->h);
+
} else {
gl_make_current(0,0);
- gCC = NULL;
i810Ctx = NULL;
}
return GL_TRUE;
}
-void i810XMesaWindowMoved( XMesaContext xmc )
+
+void i810GetLock( i810ContextPtr imesa, GLuint flags )
{
- i810ContextPtr imesa = (i810ContextPtr) xmc->private;
- __DRIdrawablePrivate *dPriv = xmc->driContextPriv->driDrawablePriv;
- GLcontext *ctx=imesa->glCtx;
-
-/* grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h, */
-/* dPriv->numClipRects, dPriv->pClipRects); */
-
-
- imesa->numClipRects=dPriv->numClipRects;
- imesa->pClipRects=dPriv->pClipRects;
- if (dPriv->x!=imesa->x_offset || dPriv->y!=imesa->y_offset ||
- dPriv->w!=imesa->width || dPriv->h!=imesa->height) {
- imesa->x_offset=dPriv->x;
- imesa->y_offset=dPriv->y;
- imesa->width=dPriv->w;
- imesa->height=dPriv->h;
- imesa->y_delta=imesa->screen_height-imesa->y_offset-imesa->height;
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ __DRIscreenPrivate *sPriv = imesa->driScreen;
+ drm_i810_sarea_t *sarea = imesa->sarea;
+ int me = imesa->hHWContext;
+ int stamp = dPriv->lastStamp;
+
+
+ if (0) fprintf(stderr, ".\n");
+
+ /* We know there has been contention.
+ */
+ drmGetLock(imesa->driFd, imesa->hHWContext, flags);
+
+
+ /* Note contention for throttling hint
+ */
+ imesa->any_contend = 1;
+
+ /* If the window moved, may need to set a new cliprect now.
+ *
+ * NOTE: This releases and regains the hw lock, so all state
+ * checking must be done *after* this call:
+ */
+ XMESA_VALIDATE_DRAWABLE_INFO(imesa->display, sPriv, dPriv);
+
+
+ if (0)
+ fprintf(stderr, "i810GetLock, last enque: %d last dispatch: %d\n",
+ sarea->last_enqueue,
+ sarea->last_dispatch);
+
+ /* If we lost context, need to dump all registers to hardware.
+ * Note that we don't care about 2d contexts, even if they perform
+ * accelerated commands, so the DRI locking in the X server is even
+ * more broken than usual.
+ */
+ if (sarea->ctxOwner != me) {
+ i810glx.c_ctxlost++;
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->dirty |= I810_EMIT_CLIPRECT;
+ imesa->dirty |= I810_UPLOAD_BUFFERS;
+ sarea->ctxOwner = me;
}
- switch (dPriv->numClipRects) {
- case 0:
- imesa->clipMinX=dPriv->x;
- imesa->clipMaxX=dPriv->x+dPriv->w;
- imesa->clipMinY=dPriv->y;
- imesa->clipMaxY=dPriv->y+dPriv->h;
- fxSetScissorValues(ctx);
- imesa->needClip=0;
- break;
- case 1:
- imesa->clipMinX=dPriv->pClipRects[0].x1;
- imesa->clipMaxX=dPriv->pClipRects[0].x2;
- imesa->clipMinY=dPriv->pClipRects[0].y1;
- imesa->clipMaxY=dPriv->pClipRects[0].y2;
- fxSetScissorValues(ctx);
- imesa->needClip=0;
- break;
- default:
- imesa->needClip=1;
- }
-}
-void i810XMesaUpdateState(XMesaContext *xmc, int windowMoved) {
- __DRIdrawablePrivate *dPriv = xmc->driContextPriv->driDrawablePriv;
- __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
- I810SAREAPriv *saPriv=(I810SAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec));
-
- /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */
- if (saPriv->fifoOwner!=dPriv->driContextPriv->hHWContext) {
- grDRIImportFifo(saPriv->fifoPtr, saPriv->fifoRead);
- }
- if (saPriv->ctxOwner!=dPriv->driContextPriv->hHWContext) {
- grDRIInvalidateAll();
- /* This shouldn't be needed if the state is reset by Glide */
- /* FX_grConstantColorValue_NoLock(FXCOLOR4(&i810Ctx->constColor)); */
- }
- if (saPriv->texOwner!=dPriv->driContextPriv->hHWContext) {
- fxTMRestoreTextures(i810Ctx);
- }
- if (windowMoved)
- XMesaWindowMoved( xmc );
-}
+ /* Shared texture managment - if another client has played with
+ * texture space, figure out which if any of our textures have been
+ * ejected, and update our global LRU.
+ */
+ if (sarea->texAge != imesa->texAge) {
+ int sz = 1 << (imesa->i810Screen->logTextureGranularity);
+ int idx, nr = 0;
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in our local list...
+ */
+ for (idx = sarea->texList[I810_NR_TEX_REGIONS].prev ;
+ idx != I810_NR_TEX_REGIONS && nr < I810_NR_TEX_REGIONS ;
+ idx = sarea->texList[idx].prev, nr++)
+ {
+ if (sarea->texList[idx].age > imesa->texAge)
+ i810TexturesGone(imesa, idx * sz, sz, sarea->texList[idx].in_use);
+ }
-void i810XMesaSetSAREA( XMesaContext *xmc ) {
- __DRIdrawablePrivate *dPriv = xmc->driContextPriv->driDrawablePriv;
- __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
- I810SAREAPriv *saPriv=(I810SAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec));
+ if (nr == I810_NR_TEX_REGIONS) {
+ i810TexturesGone(imesa, 0, imesa->i810Screen->textureSize, 0);
+ i810ResetGlobalLRU( imesa );
+ }
+
+ if (0) fprintf(stderr, "imesa %d sarea %d\n", imesa->texAge, sarea->texAge);
+ imesa->dirty |= I810_UPLOAD_TEX0IMAGE;
+ imesa->dirty |= I810_UPLOAD_TEX1IMAGE;
+ imesa->texAge = sarea->texAge;
+ }
- saPriv->fifoOwner=dPriv->driContextPriv->hHWContext;
- saPriv->ctxOwner=dPriv->driContextPriv->hHWContext;
- saPriv->texOwner=dPriv->driContextPriv->hHWContext;
- grDRIResetSAREA();
- /* fprintf(stderr, "Out FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */
+
+ if (dPriv->lastStamp != stamp)
+ i810XMesaWindowMoved( imesa );
+
+
+ sarea->last_quiescent = -1; /* just kill it for now */
}
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810buf.h b/xc/lib/GL/mesa/src/drv/i810/i810buf.h
deleted file mode 100644
index e72b0f225..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810buf.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * GLX Hardware Device Driver for Intel 810
- * 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.
- *
- * Keith Whitwell <keithw@precisioninsight.com>
- *
- * based on matrox driver by
- * Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
- * and others.
- */
-
-#ifndef I810BUF_INC
-#define I810BUF_INC
-
-#include "i810common.h"
-#include "i810_3d_reg.h"
-#include "types.h"
-#include "mm.h"
-
-#define VALID_I810_BUFFER(b) (b)
-
-
-struct i810_dest_buffer
-{
- int refcount;
- PMemBlock MemBlock;
- GLuint Setup[I810_DEST_SETUP_SIZE];
-
- int Format;
- int Width; /* in pixels */
- int Height;
- int Pitch;
- int BytesPerPixel;
- int Size;
- int Drawable;
- char *BufAddr;
- struct i810_z_buffer *ZBuffer;
-};
-
-struct i810_z_buffer
-{
- int refcount;
- PMemBlock MemBlock;
-
- int Format;
- char *BufAddr;
-
- int Pitch;
-};
-
-
-
-/* Don't bother trying to hide the differences between these types of
- * buffer.
- */
-struct i810_dest_buffer *i810CreateDestBuffer(int Format,
- int Width,
- int Height);
-void i810DestroyDestBuffer(struct i810_dest_buffer *buf);
-
-
-
-/* Parent is a dest-buffer, supplies geometry info.
- */
-struct i810_z_buffer *i810CreateZBuffer( struct i810_dest_buffer *parent );
-void i810FreeZBuffer(struct i810_z_buffer *buf);
-
-
-
-
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810clear.c b/xc/lib/GL/mesa/src/drv/i810/i810clear.c
index 3749b9659..f6e74beb8 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810clear.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810clear.c
@@ -1,144 +1,145 @@
-#include "xsmesaP.h"
-#include "mesaglx/types.h"
+#include "types.h"
#include "vbrender.h"
-#include "glx_log.h"
-
-#include "vga.h"
-#include "vgaPCI.h"
+#include "i810log.h"
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include "mm.h"
#include "i810lib.h"
#include "i810dd.h"
-#include "i810glx.h"
#include "i810clear.h"
#include "i810state.h"
#include "i810tris.h"
+#include "i810ioctl.h"
+
+#define DEPTH_SCALE 65535.0F
+
+static void i810_clear_buffer( GLcontext *ctx,
+ GLboolean all,
+ GLint cx, GLint cy,
+ GLint cwidth,
+ GLint cheight,
+ GLushort value,
+ GLuint offset )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ int _nc = imesa->numClipRects;
+ XF86DRIClipRectPtr box = imesa->pClipRects;
+
+ cy = dPriv->h-cy-cheight;
+ cx += imesa->drawX;
+ cy += imesa->drawY;
+
+ while (_nc--) {
+ GLint x = box[_nc].x1;
+ GLint y = box[_nc].y1;
+ GLint width = box[_nc].x2 - x;
+ GLint height = box[_nc].y2 - y;
+
+ if (!all) {
+ if (x < cx) width -= cx - x, x = cx;
+ if (y < cy) height -= cy - y, y = cy;
+ if (x + width > cx + cwidth) width = cx + cwidth - x;
+ if (y + height > cy + cheight) height = cy + cheight - y;
+ if (width <= 0) continue;
+ if (height <= 0) continue;
+ }
+
+ if (I810_DEBUG&DEBUG_VERBOSE_2D)
+ fprintf(stderr, "clear color rect %d,%d %dx%d\n",
+ (int) x, (int) y, (int) width, (int) height);
+
+
+ {
+ int start = (offset +
+ y * i810Screen->backPitch +
+ x * i810Screen->cpp);
+
+ BEGIN_BATCH( imesa, 6 );
+
+ OUT_BATCH( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
+ OUT_BATCH( BR13_SOLID_PATTERN |
+ (0xF0 << 16) |
+ i810Screen->backPitch );
+ OUT_BATCH( (height << 16) | (width * i810Screen->cpp));
+ OUT_BATCH( start );
+ OUT_BATCH( value );
+ OUT_BATCH( 0 );
+
+ ADVANCE_BATCH();
+ }
+ }
+}
+
/*
* i810Clear
- * perform hardware accelerated clearing of the color and/or depth
- * buffer. Software may still clear stencil buffers.
- * If all==GL_TRUE, clear whole buffer, else just clear region defined
- * by x,y,width,height
+ *
+ * Clear the color and/or depth buffers. If 'all' is GL_TRUE, clear
+ * whole buffer, otherwise clear the region defined by the remaining
+ * parameters.
*/
-
-
GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+ GLint cx, GLint cy, GLint cwidth, GLint cheight )
{
- XSMesaContext xsmesa = (XSMesaContext) ctx->DriverCtx;
- GLubyte *c;
- GLuint zval;
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- i810Msg(10, "i810Clear( %i, %i, %i, %i, %i )\n",
- mask, x, y, width, height );
+ if (I810_DEBUG&DEBUG_VERBOSE_API)
+ fprintf(stderr, "i810Clear( %d, %d, %d, %d, %d )\n",
+ (int)mask, (int)cx, (int)cy, (int)cwidth, (int)cheight );
- CHECK_CONTEXT( return mask; );
-
- if (all == GL_TRUE) {
- x = 0;
- y = 0;
- width = i810DB->Width;
- height = i810DB->Height;
- }
-
- if ( y + height > i810DB->Height ) {
- height = i810DB->Height - y;
- }
- if ( x + width > i810DB->Width ) {
- width = i810DB->Width - x;
- }
- if ( x < 0 ) {
- width += x;
- x = 0;
- }
- if ( y < 0 ) {
- height += y;
- y = 0;
- }
- if ( x >= i810DB->Width || y >= i810DB->Height || width < 1 || height < 1 ) {
- return 0;
- }
-
- /* flip top to bottom */
- y = i810DB->Height-y-height;
- c = xsmesa->clearcolor;
- zval = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE);
-
- i810FinishPrimitive();
+ FLUSH_BATCH(imesa);
+
+ LOCK_HARDWARE(imesa);
+ i810GetGeneralDmaBufferLocked( imesa );
- if (1)
{
- BEGIN_BATCH(2);
+ BEGIN_BATCH( imesa, 2 );
OUT_BATCH( INST_PARSER_CLIENT | INST_OP_FLUSH );
- OUT_BATCH( 0 ); /* pad to quadword */
+ OUT_BATCH( 0 );
ADVANCE_BATCH();
}
- /* color buffer */
- if (mask & GL_COLOR_BUFFER_BIT)
- {
- int start = (i810DB->MemBlock->ofs +
- y * i810DB->Pitch +
- x * vgaBytesPerPixel);
-
- BEGIN_BATCH(6);
-
- OUT_BATCH( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
- OUT_BATCH( BR13_SOLID_PATTERN |
- (0xF0 << 16) |
- i810DB->Pitch );
- OUT_BATCH( (height << 16) | (width * vgaBytesPerPixel));
- OUT_BATCH( start );
- OUT_BATCH( i810PackColor( i810DB->Format, c[0], c[1], c[2], c[3] ) );
- OUT_BATCH( 0 );
-
- ADVANCE_BATCH();
-
- mask &= ~GL_COLOR_BUFFER_BIT;
+ if ( (mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
+ i810_clear_buffer( ctx, all, cx, cy, cwidth, cheight,
+ imesa->ClearColor,
+ imesa->i810Screen->fbOffset);
+ mask &= ~DD_FRONT_LEFT_BIT;
}
- /* depth buffer */
- if ( (mask & GL_DEPTH_BUFFER_BIT) &&
- i810DB->ZBuffer &&
- ctx->Depth.Mask )
- {
- int start = (i810DB->ZBuffer->MemBlock->ofs +
- y * i810DB->ZBuffer->Pitch +
- x * 2);
-
- BEGIN_BATCH(6);
-
- OUT_BATCH( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
- OUT_BATCH( BR13_SOLID_PATTERN |
- (0xF0 << 16) |
- i810DB->ZBuffer->Pitch );
- OUT_BATCH( (height << 16) | (width * 2));
- OUT_BATCH( start );
- OUT_BATCH( zval );
- OUT_BATCH( 0 );
-
- ADVANCE_BATCH();
-
- mask &= ~GL_DEPTH_BUFFER_BIT;
+ if ( (mask & DD_BACK_LEFT_BIT) && colorMask == ~0) {
+ i810_clear_buffer( ctx, all, cx, cy, cwidth, cheight,
+ imesa->ClearColor,
+ imesa->i810Screen->backOffset);
+ mask &= ~DD_BACK_LEFT_BIT;
}
- if (1)
+ if ( (mask & DD_DEPTH_BIT) && ctx->Depth.Mask ) {
+ i810_clear_buffer( ctx, all, cx, cy, cwidth, cheight,
+ ctx->Depth.Clear * DEPTH_SCALE,
+ imesa->i810Screen->depthOffset);
+ mask &= ~DD_DEPTH_BIT;
+ }
+
{
- BEGIN_BATCH(2);
+ BEGIN_BATCH( imesa, 2 );
OUT_BATCH( INST_PARSER_CLIENT | INST_OP_FLUSH );
- OUT_BATCH( 0 ); /* pad to quadword */
+ OUT_BATCH( 0 );
ADVANCE_BATCH();
}
+ i810FlushGeneralLocked(imesa);
+ UNLOCK_HARDWARE( imesa );
return mask;
}
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.c b/xc/lib/GL/mesa/src/drv/i810/i810context.c
deleted file mode 100644
index a9bd855d5..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810context.c
+++ /dev/null
@@ -1,126 +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.
- *
- */
-
-#include "xsmesaP.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <GL/gl.h>
-
-#include "i810context.h"
-#include "i810lib.h"
-#include "i810log.h"
-#include "i810dd.h"
-#include "i810pipeline.h"
-/* #include "i810render.h" */
-#include "i810state.h"
-#include "i810tris.h"
-#include "simple_list.h"
-
-
-
-i810ContextPtr i810CreateContext(GLcontext *ctx)
-{
- i810ContextPtr c;
-
- c = (i810ContextPtr) calloc(1,sizeof(i810Context));
- if (!c)
- return NULL;
-
- c->gl_ctx = ctx;
-
- c->renderindex = -1; /* impossible value */
- c->new_state = ~0;
- c->reg_dirty = ~0;
-
- make_empty_list(&c->SwappedOut);
- make_empty_list(&c->TexObjList);
-
- c->TextureMode = ctx->Texture.Unit[0].EnvMode;
-
- c->CurrentTex0Obj = 0;
- c->CurrentTex1Obj = 0;
- ctx->Shared->DefaultD[2][0].DriverData = 0;
- ctx->Shared->DefaultD[2][1].DriverData = 0;
-
- if (ctx->VB)
- i810DDRegisterVB( ctx->VB );
-
- if (ctx->NrPipelineStages)
- ctx->NrPipelineStages =
- i810DDRegisterPipelineStages(ctx->PipelineStage,
- ctx->PipelineStage,
- ctx->NrPipelineStages);
-
-
- /* Ask mesa to clip fog coordinates for us.
- */
- ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
-
-
-#if 0
- if (!getenv("I810_NO_FAST_PATH"))
- ctx->Driver.BuildPrecalcPipeline = i810DDBuildPrecalcPipeline;
-
- i810DDRenderInit();
- i810DDFastPathInit();
-#endif
-
-
- i810DDTrifuncInit();
- i810DDSetupInit();
- i810DDExtensionsInit( ctx );
-
- i810_setup_DD_pointers( ctx );
- i810DDInitState( c );
-
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr,"i810CreateContext(): successful.\n");
-
- return c;
-}
-
-int i810DestroyContext(i810ContextPtr ctx)
-{
- i810TextureObjectPtr next_t, t;
-
- if (!ctx)
- return 0;
-
- if (--(ctx->refcount) > 0)
- return 0;
-
- foreach_s (t, next_t, &(ctx->TexObjList))
- i810DestroyTexObj(ctx, t);
-
- foreach_s (t, next_t, &(ctx->SwappedOut))
- i810DestroyTexObj(ctx, t);
-
- free(ctx);
-
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr,"i810DestroyContext(): successfully destroyed.\n");
-
- return 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.h b/xc/lib/GL/mesa/src/drv/i810/i810context.h
index 754a0e3f1..6a7ffa968 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810context.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810context.h
@@ -26,60 +26,82 @@
#ifndef I810CONTEXT_INC
#define I810CONTEXT_INC
+typedef struct i810_context_t i810Context;
+typedef struct i810_context_t *i810ContextPtr;
+
+#include <X11/Xlibint.h>
+#include "dri_tmm.h"
+#include "dri_mesaint.h"
+#include "dri_mesa.h"
+#include "xmesaP.h"
-#include "mesaglx/types.h"
+#include "types.h"
+#include "i810_init.h"
+#include "drm.h"
-#include "i810common.h"
-#include "i810buf.h"
#include "i810tex.h"
#include "i810vb.h"
-#include "xsmesaP.h"
-/* Hmmm */
-#define FALLBACK_TEXTURE 1
+
+#define I810_FALLBACK_TEXTURE 0x1
+#define I810_FALLBACK_DRAW_BUFFER 0x2
+#define I810_FALLBACK_READ_BUFFER 0x4
+#define I810_FALLBACK_COLORMASK 0x8
+#define I810_FALLBACK_STIPPLE 0x10
+#define I810_FALLBACK_SPECULAR 0x20
+
+/* for i810ctx.new_state - manage GL->driver state changes
+ */
+#define I810_NEW_TEXTURE 0x1
+
+/* for i810ctx.dirty - manage driver->hw state changes, including
+ * lost contexts.
+ */
+#define I810_WAIT_AGE 0x1
+#define I810_UPLOAD_TEX0IMAGE 0x2
+#define I810_UPLOAD_TEX1IMAGE 0x4
+#define I810_UPLOAD_CTX 0x8
+#define I810_UPLOAD_BUFFERS 0x10
+#define I810_REFRESH_RING 0x20
+#define I810_EMIT_CLIPRECT 0x40
-#define I810_NEW_TEXTURE 0x20
-#define I810_NEW_CONTEXT 0x100
+typedef void (*i810_interp_func)( GLfloat t,
+ GLfloat *result,
+ const GLfloat *in,
+ const GLfloat *out );
+
struct i810_context_t {
GLint refcount;
- struct i810_dest_buffer *DB;
- GLcontext *gl_ctx;
+ GLcontext *glCtx;
- i810TextureObjectPtr CurrentTex0Obj;
- i810TextureObjectPtr CurrentTex1Obj;
+ i810TextureObjectPtr CurrentTexObj[2];
- struct i810_texture_object_t TexObjList, SwappedOut;
+ struct i810_texture_object_t TexObjList;
+ struct i810_texture_object_t SwappedOut;
int TextureMode;
- /* flags
- */
- int GlobalPaletteUpdated:1;
-
-
/* Hardware state
*/
GLuint Setup[I810_CTX_SETUP_SIZE];
+ GLuint BufferSetup[I810_DEST_SETUP_SIZE];
+ GLuint ClipSetup[I810_CLIP_SETUP_SIZE];
- /* Context hardware state mirrors.
- */
- GLushort GlobalPalette[256];
-
/* Support for CVA and the fast paths.
*/
GLuint setupdone;
GLuint setupindex;
GLuint renderindex;
GLuint using_fast_path;
-/* gl_vertex_interp_func interp; */
+ i810_interp_func interp;
/* Shortcircuit some state changes.
*/
@@ -90,39 +112,98 @@ struct i810_context_t {
/* Manage our own state */
GLuint new_state;
- GLuint reg_dirty;
-
+
+ /* Manage hardware state */
+ GLuint dirty;
+ memHeap_t *texHeap;
+
/* One of the few bits of hardware state that can't be calculated
* completely on the fly:
*/
GLuint LcsCullMode;
- /* For mono span and pixel funcs.
+ /* Funny mesa mirrors
*/
- GLushort CurrentColor;
+ GLushort MonoColor;
+ GLushort ClearColor;
/* DRI stuff
*/
- GLuint needClip;
- GLuint clipMinX;
- GLuint clipMaxX;
- GLuint clipMinY;
- GLuint clipMaxY;
+ drmBufPtr dma_buffer;
+ drmBufPtr vertex_dma_buffer;
+
+ GLframebuffer *glBuffer;
+ /* Two flags to keep track of fallbacks.
+ */
+ GLuint IndirectTriangles;
+ GLuint Fallback;
- drmContext hHWContext;
- int numClipRects;
+
+ GLuint needClip;
+
+ /* These refer to the current draw (front vs. back) buffer:
+ */
+ char *drawMap; /* draw buffer address in virtual mem */
+ char *readMap;
+ int drawX; /* origin of drawable in draw buffer */
+ int drawY;
+ GLuint numClipRects; /* cliprects for that buffer */
XF86DRIClipRectPtr pClipRects;
- i810ScreenPrivate *i810ScrnPriv;
+
+ int lastSwap;
+ int secondLastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+ int any_contend; /* throttle me harder */
+
+ int scissor;
+
+ int lines_are_tris; /* not used */
+ int horiz_line_stipple;
+ int vert_line_stipple;
+
+ int poly_stipple;
+
+ drm_clip_rect_t draw_rect;
+ drm_clip_rect_t scissor_rect;
+
+ drmContext hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+ Display *display;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIscreenPrivate *driScreen;
+ i810ScreenPrivate *i810Screen;
+ drm_i810_sarea_t *sarea;
};
-typedef struct i810_context_t i810Context;
-typedef struct i810_context_t *i810ContextPtr;
+
+/* To remove all debugging, make sure I810_DEBUG is defined as a
+ * preprocessor symbol, and equal to zero.
+ */
+#define I810_DEBUG 0
+#ifndef I810_DEBUG
+#warning "Debugging enabled - expect reduced performance"
+extern int I810_DEBUG;
+#endif
+
+#define DEBUG_VERBOSE_2D 0x1
+#define DEBUG_VERBOSE_RING 0x8
+#define DEBUG_VERBOSE_OUTREG 0x10
+#define DEBUG_ALWAYS_SYNC 0x40
+#define DEBUG_VERBOSE_MSG 0x80
+#define DEBUG_NO_OUTRING 0x100
+#define DEBUG_NO_OUTREG 0x200
+#define DEBUG_VERBOSE_API 0x400
+#define DEBUG_VALIDATE_RING 0x800
+#define DEBUG_VERBOSE_LRU 0x1000
+#define DEBUG_VERBOSE_DRI 0x2000
+#define DEBUG_VERBOSE_IOCTL 0x4000
-i810ContextPtr i810CreateContext(GLcontext *ctx); /* Do I need visual info? */
-int i810DestroyContext(i810ContextPtr ctx);
-int i810BindBuffer(i810ContextPtr ctx, struct i810_dest_buffer *buf);
extern GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
const struct gl_pipeline_stage *in,
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dd.c b/xc/lib/GL/mesa/src/drv/i810/i810dd.c
index 7a762ce9b..954f60a79 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810dd.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810dd.c
@@ -30,17 +30,15 @@
#include "mm.h"
#include "i810lib.h"
-#include "i810glx.h"
#include "i810clear.h"
#include "i810dd.h"
-#include "i810direct.h"
-#include "i810depth.h"
#include "i810log.h"
#include "i810state.h"
#include "i810span.h"
#include "i810tex.h"
#include "i810tris.h"
#include "i810vb.h"
+#include "i810pipeline.h"
#include "extensions.h"
#include "vb.h"
#include "dd.h"
@@ -54,18 +52,39 @@ extern int xf86VTSema;
***************************************/
-const GLubyte *i810DDGetString( GLcontext *ctx, GLenum name )
+static const GLubyte *i810DDGetString( GLcontext *ctx, GLenum name )
{
switch (name) {
case GL_VENDOR:
return "Keith Whitwell, Precision Insight Inc.";
case GL_RENDERER:
- return "GLX-I810";
+ return "DRI-I810";
default:
return 0;
}
}
+static GLint i810GetParameteri(const GLcontext *ctx, GLint param)
+{
+ switch (param) {
+ case DD_HAVE_HARDWARE_FOG:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
+
+static void i810BufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ *width = imesa->driDrawable->w;
+ *height = imesa->driDrawable->h;
+}
+
+
+
void i810DDExtensionsInit( GLcontext *ctx )
{
@@ -86,77 +105,26 @@ void i810DDExtensionsInit( GLcontext *ctx )
gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
+ if (0) gl_extensions_disable( ctx, "GL_ARB_multitexture" );
+
+
/* We do support tex_env_add, however
*/
gl_extensions_enable( ctx, "GL_EXT_texture_env_add" );
}
-static GLint i810GetParameteri(const GLcontext *ctx, GLint param)
-{
- switch (param) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- return 0;
- }
-}
-GLboolean i810IsTextureResident( GLcontext *ctx, struct gl_texture_object *t )
+void i810DDInitDriverFuncs( GLcontext *ctx )
{
- i810TextureObjectPtr mt = (i810TextureObjectPtr)t->DriverData;
- return mt && mt->MemBlock;
-}
-
-
-
-
-void i810_setup_DD_pointers( GLcontext *ctx )
-{
- i810DDInitStatePointers(ctx);
-
+ ctx->Driver.GetBufferSize = i810BufferSize;
ctx->Driver.GetString = i810DDGetString;
- ctx->Driver.UpdateState = i810DDUpdateState;
+ ctx->Driver.GetParameteri = i810GetParameteri;
ctx->Driver.RegisterVB = i810DDRegisterVB;
ctx->Driver.UnregisterVB = i810DDUnregisterVB;
ctx->Driver.Clear = i810Clear;
- ctx->Driver.GetParameteri = i810GetParameteri;
- ctx->Driver.TexEnv = i810TexEnv;
- ctx->Driver.TexImage = i810TexImage;
- ctx->Driver.TexSubImage = i810TexSubImage;
- ctx->Driver.BindTexture = i810BindTexture;
- ctx->Driver.DeleteTexture = i810DeleteTexture;
- ctx->Driver.TexParameter = i810TexParameter;
- ctx->Driver.UpdateTexturePalette = i810UpdateTexturePalette;
- ctx->Driver.IsTextureResident = i810IsTextureResident;
-
- ctx->Driver.TriangleCaps = (DD_TRI_CULL|
- DD_TRI_LIGHT_TWOSIDE|
- DD_TRI_OFFSET);
-
- i810DDInitSpans( ctx );
-
- ctx->Driver.ReadDepthSpanFloat = i810_read_depth_span_float;
- ctx->Driver.ReadDepthSpanInt = i810_read_depth_span_int;
- if (ctx->Depth.Test) {
- switch (ctx->Depth.Func) {
- case GL_LESS:
- ctx->Driver.DepthTestSpan = i810_depth_test_span_less;
- ctx->Driver.DepthTestPixels = i810_depth_test_pixels_less;
- break;
- case GL_GREATER:
- ctx->Driver.DepthTestSpan = i810_depth_test_span_greater;
- ctx->Driver.DepthTestPixels = i810_depth_test_pixels_greater;
- break;
- default:
- ctx->Driver.DepthTestSpan = i810_depth_test_span_generic;
- ctx->Driver.DepthTestPixels = i810_depth_test_pixels_generic;
- break;
- }
- }
- /* Also do the normal GL state-change checks.
- */
- i810DDUpdateState( ctx );
+
+ ctx->Driver.BuildPrecalcPipeline = i810DDBuildPrecalcPipeline;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dd.h b/xc/lib/GL/mesa/src/drv/i810/i810dd.h
index 1274e66e2..86a8618d0 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810dd.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810dd.h
@@ -25,23 +25,9 @@
#ifndef I810DD_INC
#define I810DD_INC
-#include "mesaglx/context.h"
+#include "context.h"
-#include "i810buf.h"
-
-void i810_setup_DD_pointers( GLcontext *ctx );
-void i810DDRegisterVB( struct vertex_buffer *VB );
-
-void i810DDFastPath( struct vertex_buffer *VB );
-void i810DDImmediateFastPath( struct vertex_buffer *VB );
-void i810DDFastPathInit();
void i810DDExtensionsInit( GLcontext *ctx );
-
-void i810_setup_DD_pointers_no_accel( GLcontext *ctx );
-/* void i810FinishPrimitive( void ); */
-
-#define i810FinishPrimitive()
-
-
+void i810DDInitDriverFuncs( GLcontext *ctx );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810depth.c b/xc/lib/GL/mesa/src/drv/i810/i810depth.c
deleted file mode 100644
index 9b089f7de..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810depth.c
+++ /dev/null
@@ -1,735 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 3.1
- *
- * Copyright (C) 1999 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.
- */
-
-/*
- * This file has been modified by Wittawat Yamwong for GLX module.
- */
-
-/*
- * Depth buffer functions
- */
-
-
-#ifdef PC_HEADER
-#include "all.h"
-#else
-#include <stdlib.h>
-#include <string.h>
-#include "mesaglx/context.h"
-#include "i810depth.h"
-#include "mesaglx/types.h"
-#include "mm.h"
-#include "i810lib.h"
-#endif
-
-
-
-/*
- * Return the address of the Z-buffer value for window coordinate (x,y):
- */
-#define Z_SETUP \
- GLdepth *zbstart = (GLdepth *)i810DB->ZBuffer->BufAddr; \
- GLint zbpitch = i810DB->ZBuffer->Pitch;
-#define Z_ADDRESS( X, Y ) \
- (zbstart + zbpitch * (Y) + (X))
-
-
-/**********************************************************************/
-/***** Depth Testing Functions *****/
-/**********************************************************************/
-
-
-/*
- * Depth test horizontal spans of fragments. These functions are called
- * via ctx->Driver.depth_test_span only.
- *
- * Input: n - number of pixels in the span
- * x, y - location of leftmost pixel in span in window coords
- * z - array [n] of integer depth values
- * In/Out: mask - array [n] of flags (1=draw pixel, 0=don't draw)
- * Return: number of pixels which passed depth test
- */
-
-
-/*
- * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
- */
-GLuint i810_depth_test_span_generic( GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- const GLdepth z[],
- GLubyte mask[] )
-{
- Z_SETUP
- GLdepth *zptr = Z_ADDRESS( x, y );
- GLubyte *m = mask;
- GLuint i;
- GLuint passed = 0;
-
- i810WaitDrawingEngine();
-
- /* switch cases ordered from most frequent to less frequent */
- switch (ctx->Depth.Func) {
- case GL_LESS:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++,zptr++,m++) {
- if (*m) {
- if (z[i] < *zptr) {
- /* pass */
- *zptr = z[i];
- passed++;
- }
- else {
- /* fail */
- *m = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++,zptr++,m++) {
- if (*m) {
- if (z[i] < *zptr) {
- /* pass */
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- break;
- case GL_LEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] <= *zptr) {
- *zptr = z[i];
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] <= *zptr) {
- /* pass */
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- break;
- case GL_GEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] >= *zptr) {
- *zptr = z[i];
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] >= *zptr) {
- /* pass */
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- break;
- case GL_GREATER:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] > *zptr) {
- *zptr = z[i];
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] > *zptr) {
- /* pass */
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- break;
- case GL_NOTEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] != *zptr) {
- *zptr = z[i];
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] != *zptr) {
- /* pass */
- passed++;
- }
- else {
- *m = 0;
- }
- }
- }
- }
- break;
- case GL_EQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] == *zptr) {
- *zptr = z[i];
- passed++;
- }
- else {
- *m =0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- if (z[i] == *zptr) {
- /* pass */
- passed++;
- }
- else {
- *m =0;
- }
- }
- }
- }
- break;
- case GL_ALWAYS:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0;i<n;i++,zptr++,m++) {
- if (*m) {
- *zptr = z[i];
- passed++;
- }
- }
- }
- else {
- /* Don't update Z buffer or mask */
- passed = n;
- }
- break;
- case GL_NEVER:
- for (i=0;i<n;i++) {
- mask[i] = 0;
- }
- break;
- default:
- gl_problem(ctx, "Bad depth func in gl_depth_test_span_generic");
- } /*switch*/
-
- return passed;
-}
-
-
-
-/*
- * glDepthFunc(GL_LESS) and glDepthMask(GL_TRUE).
- */
-GLuint i810_depth_test_span_less( GLcontext* ctx,
- GLuint n, GLint x, GLint y, const GLdepth z[],
- GLubyte mask[] )
-{
- Z_SETUP
- GLdepth *zptr = Z_ADDRESS( x, y );
- GLuint i;
- GLuint passed = 0;
-
- i810WaitDrawingEngine();
-
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] < zptr[i]) {
- /* pass */
- zptr[i] = z[i];
- passed++;
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- return passed;
-}
-
-
-/*
- * glDepthFunc(GL_GREATER) and glDepthMask(GL_TRUE).
- */
-GLuint i810_depth_test_span_greater( GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- const GLdepth z[],
- GLubyte mask[] )
-{
- Z_SETUP
- GLdepth *zptr = Z_ADDRESS( x, y );
- GLuint i;
- GLuint passed = 0;
-
- i810WaitDrawingEngine();
-
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] > zptr[i]) {
- /* pass */
- zptr[i] = z[i];
- passed++;
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- return passed;
-}
-
-
-
-/*
- * Depth test an array of randomly positioned fragments.
- */
-
-/*
- * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
- */
-void i810_depth_test_pixels_generic( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] )
-{
- Z_SETUP
- register GLdepth *zptr;
- register GLuint i;
-
- i810WaitDrawingEngine();
-
- /* switch cases ordered from most frequent to less frequent */
- switch (ctx->Depth.Func) {
- case GL_LESS:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] < *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] < *zptr) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_LEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] <= *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] <= *zptr) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_GEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] >= *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] >= *zptr) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_GREATER:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] > *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] > *zptr) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_NOTEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] != *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] != *zptr) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_EQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] == *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] == *zptr) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_ALWAYS:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- *zptr = z[i];
- }
- }
- }
- else {
- /* Don't update Z buffer or mask */
- }
- break;
- case GL_NEVER:
- /* depth test never passes */
- for (i=0;i<n;i++) {
- mask[i] = 0;
- }
- break;
- default:
- gl_problem(ctx, "Bad depth func in gl_depth_test_pixels_generic");
- } /*switch*/
-}
-
-
-
-/*
- * glDepthFunc( GL_LESS ) and glDepthMask( GL_TRUE ).
- */
-void i810_depth_test_pixels_less( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] )
-{
- Z_SETUP
- GLdepth *zptr;
- GLuint i;
-
- i810WaitDrawingEngine();
-
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] < *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
-}
-
-
-/*
- * glDepthFunc( GL_GREATER ) and glDepthMask( GL_TRUE ).
- */
-void i810_depth_test_pixels_greater( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] )
-{
- Z_SETUP
- GLdepth *zptr;
- GLuint i;
-
- i810WaitDrawingEngine();
-
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zptr = Z_ADDRESS(x[i],y[i]);
- if (z[i] > *zptr) {
- /* pass */
- *zptr = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
-}
-
-
-
-
-/**********************************************************************/
-/***** Read Depth Buffer *****/
-/**********************************************************************/
-
-
-/*
- * Return a span of depth values from the depth buffer as floats in [0,1].
- * This function is only called through Driver.read_depth_span_float()
- * Input: n - how many pixels
- * x,y - location of first pixel
- * Output: depth - the array of depth values
- */
-void i810_read_depth_span_float( GLcontext* ctx,
- GLuint n, GLint x, GLint y, GLfloat depth[] )
-{
- Z_SETUP
- GLdepth *zptr;
- GLfloat scale;
- GLuint i;
-
- i810WaitDrawingEngine();
-
- scale = 1.0F / DEPTH_SCALE;
-
- if (ctx->Buffer->Depth) {
- zptr = Z_ADDRESS( x, y );
- for (i=0;i<n;i++) {
- depth[i] = (GLfloat) zptr[i] * scale;
- }
- }
- else {
- for (i=0;i<n;i++) {
- depth[i] = 0.0F;
- }
- }
-}
-
-
-/*
- * Return a span of depth values from the depth buffer as integers in
- * [0,MAX_DEPTH].
- * This function is only called through Driver.read_depth_span_int()
- * Input: n - how many pixels
- * x,y - location of first pixel
- * Output: depth - the array of depth values
- */
-void i810_read_depth_span_int( GLcontext* ctx,
- GLuint n, GLint x, GLint y, GLdepth depth[] )
-{
- Z_SETUP
-
- i810WaitDrawingEngine();
-
- if (ctx->Buffer->Depth) {
- GLdepth *zptr = Z_ADDRESS( x, y );
- MEMCPY( depth, zptr, n * sizeof(GLdepth) );
- }
- else {
- GLuint i;
- for (i=0;i<n;i++) {
- depth[i] = 0;
- }
- }
-}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810depth.h b/xc/lib/GL/mesa/src/drv/i810/i810depth.h
deleted file mode 100644
index 878fbefe8..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810depth.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 3.1
- *
- * Copyright (C) 1999 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.
- */
-
-/*
- * This file has been modified by Wittawat Yamwong for GLX module.
- */
-
-
-#ifndef I810DEPTH_INC
-#define I810DEPTH_INC
-
-
-#include "mesaglx/types.h"
-
-
-
-
-
-extern GLuint
-i810_depth_test_span_generic( GLcontext* ctx, GLuint n, GLint x, GLint y,
- const GLdepth z[], GLubyte mask[] );
-
-extern GLuint
-i810_depth_test_span_less( GLcontext* ctx, GLuint n, GLint x, GLint y,
- const GLdepth z[], GLubyte mask[] );
-
-extern GLuint
-i810_depth_test_span_greater( GLcontext* ctx, GLuint n, GLint x, GLint y,
- const GLdepth z[], GLubyte mask[] );
-
-
-
-extern void
-i810_depth_test_pixels_generic( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] );
-
-extern void
-i810_depth_test_pixels_less( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] );
-
-extern void
-i810_depth_test_pixels_greater( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] );
-
-
-extern void i810_read_depth_span_float( GLcontext* ctx,
- GLuint n, GLint x, GLint y,
- GLfloat depth[] );
-
-
-extern void i810_read_depth_span_int( GLcontext* ctx, GLuint n, GLint x, GLint y,
- GLdepth depth[] );
-
-
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dma.c b/xc/lib/GL/mesa/src/drv/i810/i810dma.c
deleted file mode 100644
index f745d272f..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810dma.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/* -*- mode: C; c-basic-offset:8 -*- */
-/*
- * 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.
- *
- * based on the original mgadma.c by Jeff Hartmann <slicer@ionet.net>
- * as rewritten by John Carmack <johnc@idsoftware.com>
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include "mm.h"
-#include "i810buf.h"
-#include "i810dd.h"
-#include "i810lib.h"
-#include "i810log.h"
-#include "i810tris.h"
-#include "i810direct.h"
-#include "i810state.h"
-
-#include "pb.h"
-
-/* X server include:
- */
-#include "i810.h"
-
-
-
-/* This will be overwritten from the default values when glx.so is
- * loaded on the client.
- */
-void i810ServerDmaFlush( int wait );
-GLuint i810ActiveDmaBuffer = 0;
-
-
-
-#ifndef I810_DEBUG
-int I810_DEBUG = (0
-/* | DEBUG_ALWAYS_SYNC */
-/* | DEBUG_VERBOSE_ACCEL */
-/* | DEBUG_VERBOSE_SYNC */
-/* | DEBUG_VERBOSE_VGA */
-/* | DEBUG_VERBOSE_RING */
-/* | DEBUG_VERBOSE_OUTREG */
-/* | DEBUG_VERBOSE_MEMORY */
-/* | DEBUG_ALWAYS_SYNC */
-/* | DEBUG_VERBOSE_MSG */
- );
-#endif
-
-
-
-static void delay( void ) {
-}
-
-
-
-int i810WaitForDmaCompletion( void )
-{
- int start, end;
-
- if (I810LpRing.head == I810LpRing.tail && I810LpRing.space)
- return 0;
-
- start = i810_usec();
- I810LpRing.head = INREG(I810LpRing.base_reg + RING_HEAD);
- end = i810_usec();
-
- if (0 && start + 100 < end)
- fprintf(stderr, "INREG in WaitForDma: %d usec\n", end - start);
-
- I810LpRing.head &= HEAD_ADDR;
- I810LpRing.space = I810LpRing.head - (I810LpRing.tail + 8);
- if (I810LpRing.space < 0)
- I810LpRing.space += I810LpRing.mem.Size;
-
- if (I810LpRing.head == I810LpRing.tail)
- return 0;
-
- start = i810_usec();
- I810Sync();
- end = i810_usec();
-
- return 1;
-}
-
-
-
-/*
- * i810DmaResetBuffer
- */
-void i810DmaResetBuffer( void ) {
-
- i810glx.dma_buffer = dmaBuffers[ i810ActiveDmaBuffer ];
- i810glx.dma_buffer->head = 0;
- i810glx.dma_buffer->space = 0;
- i810glx.dma_buffer->additional_space =
- i810glx.dma_buffer->mem.Size - 256;
-
- i810DmaOverflow( 0 );
-
- if (i810glx.dma_buffer_age < i810glx.dma_buffer->texture_age)
- i810glx.dma_buffer_age = i810glx.dma_buffer->texture_age;
-}
-
-
-
-
-/*
- * i810FlushRealDma
- */
-void i810FlushRealDma( void ) {
-
- GLuint start;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER)
- fprintf(stderr, "i810FlushRealDma()\n" );
-
-
- if ( i810glx.skipDma || !I810_USE_BATCH )
- return;
-
-
- if (i810glx.dma_buffer->head & 0x4) {
- FatalError( "Misaligned batch buffer\n" );
- }
-
- if ( (I810_DEBUG&DEBUG_VERBOSE_OUTREG) && 0)
- {
- int i;
- for (i = 0 ; i <= i810glx.dma_buffer->head ; i+=4)
- fprintf(stderr,
- " 0x%05x : 0x%08x\n",
- i/4,
- *(GLuint *)(i810glx.dma_buffer->virtual_start +
- i));
- }
-
-
- /* fire the batch buffer */
- for (start = 0 ; start < i810glx.dma_buffer->head ; start += MAX_BATCH)
- {
- GLuint ofs = i810glx.dma_buffer->mem.Start;
- GLuint end = MIN2(start + MAX_BATCH, i810glx.dma_buffer->head);
-
- BEGIN_LP_RING(4);
- OUT_RING( CMD_OP_BATCH_BUFFER );
- OUT_RING( (ofs + start) | BB1_PROTECTED );
- OUT_RING( (ofs + end) - 4 );
- OUT_RING( 0 );
- ADVANCE_LP_RING();
- }
-
- {
- BEGIN_LP_RING(2);
- OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH |
- INST_FLUSH_MAP_CACHE );
- OUT_RING( 0 );
- }
-}
-
-/*
- * i810DmaFlush
- * Send all pending commands off to the hardware.
- * If we are running async, the hardware will be drawing
- * while we return to do other things.
- */
-void i810ServerDmaFlush( int wait ) {
- int start, end;
-
- if (I810_DEBUG)
- fprintf(stderr,
- "i810ServerDmaFlush, buffer %d, head %x space %x\n",
- i810ActiveDmaBuffer,
- i810glx.dma_buffer->head,
- i810glx.dma_buffer->space);
-
- if ( i810glx.dma_buffer->head == 0 )
- {
- if (wait && !i810WaitForDmaCompletion())
- i810glx.hardwareWentIdle = 1;
-
- return;
- }
-
- i810glx.c_dmaFlush++;
-
- /* wait for the last buffer to complete */
- if ( !i810WaitForDmaCompletion() )
- i810glx.hardwareWentIdle = 1;
-
-
- /* collect timing information if we are going syncronously */
- if ( i810glx.dmaDriver != 3 ) {
- start = i810_usec();
- } else {
- start = end = 0;
- }
-
- i810FlushRealDma();
-
- if ( i810glx.dmaDriver == 2 ) {
- /* wait until the dma completes */
- i810WaitForDmaCompletion();
- }
-
- if ( i810glx.dmaDriver != 3 ) {
- end = i810_usec();
- }
-
- i810Msg(10, "flushmode %i, buffer %i: prim dwords:%i usec:%i\n",
- i810glx.dmaDriver, i810ActiveDmaBuffer,
- i810glx.dma_buffer->head / 4,
- end - start );
-
- /* swap to using the other buffer */
- i810ActiveDmaBuffer ^= 1;
- i810DmaResetBuffer();
-
- if ( wait )
- i810WaitForDmaCompletion();
-}
-
-
-/*
- * i810DmaFlush
- */
-void i810DmaFlush( void ) {
- i810FinishPrimitive();
- i810glx.dma_buffer->texture_age = ++i810glx.current_texture_age;
-
- if ( i810Ctx && i810Ctx->CurrentTex0Obj )
- i810Ctx->CurrentTex0Obj->age = ++i810glx.current_texture_age;
-
- if ( i810Ctx && i810Ctx->CurrentTex1Obj )
- i810Ctx->CurrentTex1Obj->age = ++i810glx.current_texture_age;
-
- i810ServerDmaFlush( 0 );
-}
-
-
-/*
- * i810DmaFinish
- */
-void i810DmaFinish( void ) {
- i810FinishPrimitive();
- i810ServerDmaFlush( 1 );
-
- i810glx.dma_buffer_age = ++i810glx.current_texture_age;
-
- if ( i810Ctx && i810Ctx->CurrentTex0Obj )
- i810Ctx->CurrentTex0Obj->age = ++i810glx.current_texture_age;
-
- if ( i810Ctx && i810Ctx->CurrentTex1Obj )
- i810Ctx->CurrentTex1Obj->age = ++i810glx.current_texture_age;
-}
-
-
-/*
- * i810DmaOverflow
- * This is called when I810DMAGETPTR is at the end of the buffer
- */
-void i810DmaOverflow( int newDwords ) {
-
- if (i810glx.dma_buffer->additional_space) {
- GLuint incr = MAX_BATCH;
-
- if (i810glx.dma_buffer->additional_space < incr)
- incr = i810glx.dma_buffer->additional_space;
-
- while (i810glx.dma_buffer->head & (MAX_BATCH - 1)) {
- GLuint outbatch = i810glx.dma_buffer->head;
- GLubyte *virt = i810glx.dma_buffer->virtual_start;
-
- *(volatile unsigned int *)(virt + outbatch) = 0;
- i810glx.dma_buffer->head += 4;
- }
-
- i810glx.dma_buffer->space += incr;
- i810glx.dma_buffer->additional_space -= incr;
-
- if (0)
- fprintf(stderr, "overflow, head %x space %x\n",
- i810glx.dma_buffer->head,
- i810glx.dma_buffer->space);
- return;
- }
-
- i810Msg( 9, "i810DmaOverflow(%i)\n", newDwords );
-
- /* flush all the current commands so we will have another
- empty buffer */
- i810DmaFlush();
-
- i810glx.c_overflows++;
-
- if ( newDwords > i810glx.dma_buffer->space )
- FatalError("i810DmaOverflow > maxPrimaryDwords");
-}
-
-
-/*
- * i810WaitDrawingEngine
- * This will not return until the drawing engine has completed
- * drawing pixels and it is safe to read or write the framebuffer
- * for software rendering.
- */
-int i810WaitDrawingEngine( void ) {
- /* note this for the performance block display */
- i810glx.c_drawWaits++;
-
- /* make sure all pending dma has completed */
- i810DmaFinish();
- return 0;
-}
-
-
-/*
- * i810DmaExecute
- * Add a block of data to the dma buffer
- */
-void i810DmaExecute( GLuint *code, int dwords )
-{
- int i;
- BEGIN_BATCH(dwords);
-
- if (dwords & 1)
- FatalError( "Misaligned buffer in i810DmaExecute\n" );
-
- for ( i = 0 ; i < dwords ; i++ )
- OUT_BATCH( code[i] );
- ADVANCE_BATCH();
-}
-
-
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dma.h b/xc/lib/GL/mesa/src/drv/i810/i810dma.h
index 55adbcddd..3fd995cb3 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810dma.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810dma.h
@@ -1,138 +1,44 @@
-/*
- GLX Hardware Device Driver for Intel i810
- Copyright (C) 1999 Keith Whitwell <keithw@precisioninsight.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- original by Jeff Hartmann <slicer@ionet.net>
- 6/16/99: rewrite by John Carmack <johnc@idsoftware.com>
- Oct 99: port to i180 by Keith Whitwell <keithw@precisioninsight.com>
-*/
#ifndef I810DMA_H
#define I810DMA_H
-#include "i810common.h"
#include "i810lib.h"
-#include "i810.h"
+#include "i810_init.h"
#include "mm.h"
-/* the main initialization of the entire i810 hardware driver */
-GLboolean i810InitGLX( void );
-/* a flush command will guarantee that all data added to the dma buffer
-is on its way to the card, and will eventually complete with no more
-intervention.
-*/
-void i810DmaFlush(void);
-
-/* the overflow function is called when a block can't be allocated
-in the current dma buffer. It flushes the current buffer and
-records some information */
-void i810DmaOverflow(int newDwords);
-
-/* a finish command will guarantee that all dma commands have actually
-been consumed by the card. Note that there may still be a couple primitives
-that have not yet been executed out of the internal FIFO, so this does not
-guarantee that the drawing engine is idle. */
-void i810DmaFinish( void );
-
-/* a i810WaitDrawingEngine command will guarantee that the framebuffer
-is safe to read or write for software rendering */
-int i810WaitDrawingEngine( void );
-
-
-
-
-
-typedef struct {
- I810MemRange mem;
- char *virtual_start;
- int head;
- int space;
- int additional_space;
- int texture_age;
-} i810BatchBuffer;
-
-
-
-#define I810_USE_BATCH 1
-#if I810_USE_BATCH
-
-#define BEGIN_BATCH(n) \
+/* Vertex data does not use these macros.
+ */
+#define BEGIN_BATCH( imesa, n ) \
unsigned int outbatch; \
volatile char *virt; \
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
- fprintf(stderr, \
- "BEGIN_BATCH(%d) in %s\n" \
- "(spc left %d/%d, head %x vstart %x start %x)\n", \
- n, __FUNCTION__, i810glx.dma_buffer->space, \
- i810glx.dma_buffer->mem.Size - i810glx.dma_buffer->head, \
- i810glx.dma_buffer->head, \
- i810glx.dma_buffer->virtual_start, \
- i810glx.dma_buffer->mem.Start ); \
- if (i810glx.dma_buffer->space < n*4) \
- i810DmaOverflow(n); \
- outbatch = i810glx.dma_buffer->head; \
- virt = i810glx.dma_buffer->virtual_start;
-
-
-#define OUT_BATCH(val) { \
- *(volatile unsigned int *)(virt + outbatch) = val; \
- if (I810_DEBUG & DEBUG_VERBOSE_RING) \
- fprintf(stderr, "OUT_BATCH %x: %x\n", outbatch/4, val); \
- outbatch += 4; \
-}
+ fprintf(stderr, "BEGIN_BATCH(%d) in %s\n", n, __FUNCTION__); \
+ if (imesa->dma_buffer->total - imesa->dma_buffer->used < n*4) { \
+ i810FlushGeneralLocked( imesa ); \
+ i810GetGeneralDmaBufferLocked( imesa ); \
+ } \
+ outbatch = imesa->dma_buffer->used; \
+ virt = imesa->dma_buffer->address;
+
+
+#define OUT_BATCH(val) do { \
+ *(volatile unsigned int *)(virt + outbatch) = val; \
+ if (I810_DEBUG & DEBUG_VERBOSE_RING) \
+ fprintf(stderr, "OUT_BATCH %x: %x\n", \
+ (int)(outbatch/4), (int)(val)); \
+ outbatch += 4; \
+} while (0)
-#define ADVANCE_BATCH() { \
- if (I810_DEBUG & DEBUG_VERBOSE_RING) \
- fprintf(stderr, "ADVANCE_BATCH(%f) in %s\n", \
- (outbatch - i810glx.dma_buffer->head) / 4.0, \
- __FUNCTION__); \
- i810glx.dma_buffer->space -= outbatch - i810glx.dma_buffer->head; \
- i810glx.dma_buffer->head = outbatch; \
-}
+#define ADVANCE_BATCH() do { \
+ if (I810_DEBUG & DEBUG_VERBOSE_RING) \
+ fprintf(stderr, "ADVANCE_BATCH(%.1f) in %s\n", \
+ (outbatch - imesa->dma_buffer->used) / 4.0, \
+ __FUNCTION__); \
+ imesa->dma_buffer->used = outbatch; \
+} while(0)
#define FINISH_PRIM()
-#else
-
-/* Need some work to be able to do primitives this way.
- */
-#define BEGIN_BATCH(n) BEGIN_LP_RING(n)
-#define ADVANCE_BATCH() ADVANCE_LP_RING()
-#define OUT_BATCH(val) OUT_RING(val)
-#define FINISH_PRIM() OUTREG(I810LpRing.base_reg + RING_TAIL, I810LpRing.tail)
-
-#endif
-
-
-/* These are only required by i810direct.c:
- */
-extern GLuint i810ActiveDmaBuffer;
-extern void (*i810DoDmaFlush)( int );
-extern i810BatchBuffer *dmaBuffers[2];
-
-extern int i810WaitForDmaCompletion( void );
-extern void i810DmaResetBuffer( void );
-
-extern void i810DmaExecute( GLuint *code, int dwords );
-
-extern void I810Sync( void ) ;
-extern void I810WaitLpRing( int n );
-
-
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dmainit.c b/xc/lib/GL/mesa/src/drv/i810/i810dmainit.c
deleted file mode 100644
index 335c4a612..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810dmainit.c
+++ /dev/null
@@ -1,389 +0,0 @@
-
-/* -*- mode: C; c-basic-offset:8 -*- */
-/*
- * 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.
- *
- *
- * based on the original by Jeff Hartmann <slicer@ionet.net>
- * as rewritten by John Carmack <johnc@idsoftware.com>
- */
-
-/*
-
-This file is only entered at startup. After i810GlxInit completes,
-nothing here will be executed again.
-
-*/
-
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include "context.h"
-#include "depth.h"
-#include "macros.h"
-#include "texstate.h"
-#include "triangle.h"
-#include "vb.h"
-#include "types.h"
-
-#include "xsmesaP.h"
-#include "glx_log.h"
-#include "mesaglx/context.h"
-#include "mesaglx/matrix.h"
-#include "mesaglx/types.h"
-
-#define GC XXGC
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "servermd.h" /* PixmapBytePad */
-#include "scrnintstr.h"
-#include "regionstr.h"
-#include "windowstr.h"
-#undef GC
-
-#include "vga.h"
-#include "vgaPCI.h"
-#include "i810.h"
-#include "xaa/xf86xaa.h"
-
-#include "mm.h"
-#include "i810buf.h"
-#include "i810dd.h"
-#include "i810lib.h"
-#include "i810log.h"
-#include "i810direct.h"
-#include "i810glx.h"
-
-#include <agpgart.h>
-
-/* private vars */
-i810BatchBuffer *dmaBuffers[2];
-static I810MemRange I810SysMem2;
-
-
-static const char *getenvSafe(const char *name ) {
- const char *r;
-
- r = getenv( name );
- if ( !r ) {
- return "";
- }
- return r;
-}
-
-
-static void AllocateCommandBuffers( void )
-{
- PMemBlock block;
- GLuint bufferBytes = i810glx.cmdSize;
- GLuint start, i;
-
- if ( 1 || !bufferBytes ) {
- fprintf(stderr,"temporarily hardwiring GLX_I810_CMDSIZE = 1\n" );
- bufferBytes = 1;
- }
-
- bufferBytes *= 0x100000;
-
- block = mmAllocMem( i810glx.sysmemHeap, bufferBytes, 8, 0 );
-
- if ( !block ) {
- fprintf(stderr,
- "failed to allocate 0x%x bytes from "
- "sysmemHeap for command buffers.\n",
- bufferBytes );
-
- FatalError("Couldn't get dma buffer\n");
- }
-
- start = block->ofs;
-
- /* setup the two buffers that will be ping-ponged
- */
- for (i = 0 ; i < 2 ; i++) {
- dmaBuffers[i] = calloc(1,sizeof(i810BatchBuffer));
- dmaBuffers[i]->virtual_start = i810glx.sysmemVirtual + start;
- dmaBuffers[i]->mem.Start = start;
- dmaBuffers[i]->mem.Size = bufferBytes / 2;
- dmaBuffers[i]->mem.End = (start += bufferBytes / 2);
- }
-
- i810DmaResetBuffer();
-}
-
-
-/* Another bit of duplication caused by 'static' code in the X server.
- */
-static int gartfd;
-static struct gart_info gartinf;
-static char *gart_buf;
-
-static int AllocateGARTMemory( int size )
-{
- int i, pages = size / 4096;
- int start = vga256InfoRec.videoRam / 4; /* a crock! */
- struct stat sb;
-
- if (stat("/dev/agpgart", &sb) != 0) {
- ErrorF("Stat failed on /dev/agpgart: %s\n",
- sys_errlist[errno]);
- return -1;
- }
-
- gartfd = open("/dev/agpgart", O_RDWR);
- if (gartfd == -1) {
- ErrorF("unable to open /dev/agpgart: %s\n",
- sys_errlist[errno]);
- FatalError("Aborting");
- }
-
- if (ioctl(gartfd, GARTIOCINFO, &gartinf) != 0) {
- ErrorF("error doing ioctl(GARTIOCINFO): %s\n",
- sys_errlist[errno]);
- FatalError("Aborting");
- }
-
- /* Treat the gart like video memory - we assume we own all that is
- * there, so ignore EBUSY errors. Don't try to remove it on
- * failure, either.
- */
- for (i = start; i < start+pages; i++)
- if (ioctl(gartfd, GARTIOCINSERT, &i) != 0) {
- if (errno != EBUSY)
- {
- perror("gart insert");
- ErrorF("GART: allocation of %d pages failed at page %d\n",
- pages, i);
- FatalError("Aborting");
- }
- }
-
- ErrorF("GART: allocated %dK system ram\n", pages * 4);
-
- I810SysMem2.Start = start * 4096;
- I810SysMem2.End = (start + pages) * 4096;
- I810SysMem2.Size = pages * 4096;
-
- gart_buf = mmap( 0,
- gartinf.size * 0x100000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- gartfd,
- 0 );
-
- if ((unsigned int)gart_buf == ~0) {
- perror("/dev/agpgart");
- FatalError("Couldn't mmap /dev/agpgart - aborting");
- }
-
- return 0;
-}
-
-
-/*
- * AllocateSystemMemory
- * Looks at environment variables to determine if a block
- * of physical memory has been left for graphics after the
- * memory available to the kernel.
- * System memory can be used for dma command buffers or
- * textures.
- */
-static void AllocateSystemMemory( void )
-{
- GLuint sysmemBytes = i810glx.dmaSize;
-
- if ( !sysmemBytes )
- sysmemBytes = 8;
-
- sysmemBytes *= 0x100000;
-
- if (AllocateGARTMemory(sysmemBytes) != 0)
- FatalError( "AllocateGARTMemory failed.\n" );
-
-
- i810glx.sysmemVirtual = (unsigned char *)gart_buf;
-
- /* Suck in any leftover memory from the 2d server.
-
- i810glx.sysmemHeap = mmInit( I810SysMem.Start,
- I810SysMem.Size );
- */
-
- /* Add our new memory.
- */
- i810glx.sysmemHeap =
-/* mmAddRange( i810glx.sysmemHeap, */
- mmInit(
- I810SysMem2.Start,
- I810SysMem2.Size );
-
-
- /* Manage dcache mem via. a seperate heap.
- */
- i810glx.cardHeap = mmInit( I810DcacheMem.Start,
- I810DcacheMem.Size );
-
- i810Msg( 1, "sysmemSize: 0x%x\n", sysmemBytes );
- i810Msg( 1, "cardSize: 0x%lx\n", I810DcacheMem.Size );
-}
-
-
-
-/*
- * i810DmaInit
- *
-*/
-void i810DmaInit(void) {
-
- /* Server init - queries environment variables. The client
- * gets these values from the sever and initializes them in
- * i810direct.c
- */
- if (__glx_is_server) {
- i810glx.dmaDriver = atoi( getenvSafe("GLX_I810_DMA") );
- i810glx.dmaSize = atoi( getenvSafe("GLX_I810_DMASIZE") );
- i810glx.cmdSize = atoi( getenvSafe("GLX_I810_CMDSIZE") );
-
- if (i810glx.dmaDriver != 3)
- FatalError("GLX_I810_DMA not set\n");
- }
-
- /* get some system memory and make it write combining if we can */
- AllocateSystemMemory();
-
- /* read the command environment variable */
- i810Msg(1,"i810DmaInit: GLX_I810_DMA = %i\n", i810glx.dmaDriver );
-
- /* setup the two command buffers in the apropriate memory space */
- AllocateCommandBuffers();
-
- /* prepare the first buffer for use */
- i810DmaResetBuffer();
-}
-
-
-/*
- * This function should only verify that the current hardware is supported.
- * It should do no setup.
- */
-static GLboolean i810_detect_hw( void )
-{
- if (I810Chipset == -1)
- return GL_FALSE;
-
- if (vga256InfoRec.depth != 15 &&
- vga256InfoRec.depth != 16)
- {
- i810Error("Unsupported depth: %d, only 15 and 16d bpp "
- "are supported right now\n",
- vga256InfoRec.depth);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-/*
- * i810InitLogging
- *
- */
-void i810InitLogging( void )
-{
- i810glx.logLevel = 100;
-}
-
-
-
-/*
- * i810InitGLX
- * This is the initial entry point for the i810 hardware driver,
- * called at X server module load time, or libGL direct rendering
- * init time.
- */
-GLboolean i810InitGLX( void ) {
-
- fprintf(stderr, "\n\n\n\ni810InitGLX\n");
-
- i810InitLogging();
-
- i810Msg(1,"virtual (x, y) (%d, %d)\n", vga256InfoRec.virtualX,
- vga256InfoRec.virtualY);
- i810Msg(1,"width: %d\n", vga256InfoRec.displayWidth);
- i810Msg(1,"depth: %d\n", vga256InfoRec.depth);
- i810Msg(1,"memBase: %p\n", vgaLinearBase);
- i810Msg(1,"videoRam: 0x%08x\n", vga256InfoRec.videoRam);
-
- if (!i810_detect_hw()) {
- ErrorF("Couldn't find i810 hardware\n\n\n");
- return GL_FALSE;
- }
-
- /* init the dma system */
- i810DmaInit();
-
- /* Register as a glx driver */
- GLXProcs.CreateContext = i810GLXCreateContext;
- GLXProcs.DestroyContext = i810GLXDestroyContext;
- GLXProcs.SwapBuffers = i810GLXSwapBuffers;
- GLXProcs.CreateImage = i810GLXCreateImage;
- GLXProcs.DestroyImage = i810GLXDestroyImage;
- GLXProcs.CreateDepthBuffer = i810GLXCreateDepthBuffer;
- GLXProcs.MakeCurrent = i810GLXMakeCurrent;
- GLXProcs.BindBuffer = i810GLXBindBuffer;
- GLXProcs.SwapBuffers = i810GLXSwapBuffers;
- GLXProcs.VendorPrivate = i810GLXVendorPrivate;
- GLXProcs.AllowDirect = i810GLXAllowDirect;
-
- if (!__glx_is_server) {
- GLXProcs.ValidateFrontBuffer = i810ClientGetGeometry;
- }
-
- /* these vars can be changed between invocations of direct clients */
- if (getenv("GLX_I810_NULLPRIMS") ) {
- i810Msg( 1, "enabling GLX_I810_NULLPRIMS\n" );
- i810glx.nullprims = 1;
- }
- if (getenv("GLX_I810_SKIPDMA") ) {
- i810Msg( 1, "enabling GLX_I810_SKIPDMA\n" );
- i810glx.skipDma = 1;
- }
- if (getenv("GLX_I810_BOXES") ) {
- i810Msg( 1, "enabling GLX_I810_BOXES\n" );
- i810glx.boxes = 1;
- }
- if (getenv("GLX_I810_NOFALLBACK") ) {
- i810Msg( 1, "enabling GLX_I810_NOFALLBACK\n" );
- i810glx.noFallback = 1;
- }
-
- i810Error("i810InitGLX completed\n");
- return GL_TRUE;
-}
-
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c b/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c
index 9223060e7..3e4887619 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c
@@ -116,14 +116,10 @@ static void i810_render_elements_direct( struct vertex_buffer *VB )
if (imesa->new_state)
i810DDUpdateHwState( ctx );
- BEGIN_CLIP_LOOP(imesa)
- {
- do {
- func( VB, 0, nr, 0 );
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ));
- }
- END_CLIP_LOOP(imesa);
+ do {
+ func( VB, 0, nr, 0 );
+ } while (ctx->Driver.MultipassFunc &&
+ ctx->Driver.MultipassFunc( VB, ++p ));
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810glx.h b/xc/lib/GL/mesa/src/drv/i810/i810glx.h
deleted file mode 100644
index df5c08674..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810glx.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Wittawat Yamwong
- *
- * 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
- * WITTAWAT YAMWONG, 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.
- *
- *
- */
-
-#ifndef I810GLX_INC
-#define I810GLX_INC
-
-void i810DumpDB(struct i810_dest_buffer *buf);
-void i810GLXCreateDepthBuffer(GLcontext* ctx);
-void i810GLXDestroyImage(GLXImage* image);
-GLXImage* i810GLXCreateImage(WindowPtr pwindow, int depth, int width, int height);
-GLboolean i810GLXMakeCurrent( XSMesaContext c );
-GLboolean i810GLXBindBuffer( XSMesaContext c, XSMesaBuffer b );
-XSMesaContext i810GLXCreateContext( XSMesaVisual v,
- XSMesaContext share_list );
-void i810GLXDestroyContext( XSMesaContext c );
-
-extern int i810BackToFront(DrawablePtr drawable, struct i810_dest_buffer *buf);
-extern void (*i810GLXSwapBuffers)(XSMesaBuffer b);
-extern void i810PerformanceBoxes( int is_direct );
-
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
new file mode 100644
index 000000000..93e2f4492
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
@@ -0,0 +1,436 @@
+#include <stdio.h>
+
+
+#include "types.h"
+#include "pb.h"
+#include "dd.h"
+
+#include "mm.h"
+#include "i810context.h"
+#include "i810log.h"
+#include "i810ioctl.h"
+
+#include "drm.h"
+#include <sys/ioctl.h>
+
+static int _tot_used, _tot_size;
+
+void i810FlushGeneralLocked( i810ContextPtr imesa )
+{
+ int retcode;
+ drm_i810_general_t dma;
+ drmBufPtr buf = imesa->dma_buffer;
+
+ if (!buf) {
+ fprintf(stderr, "i810FlushGeneralLocked: no buffer\n");
+ return;
+ }
+
+ _tot_used += buf->used;
+ _tot_size += buf->total;
+
+ dma.idx = buf->idx;
+ dma.used = buf->used;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "DRM_IOCTL_I810_DMA idx %d used %d\n",
+ dma.idx, dma.used);
+
+ if ((retcode = ioctl(imesa->driFd, DRM_IOCTL_I810_DMA, &dma))) {
+ printf("send dma retcode = %d\n", retcode);
+ exit(1);
+ }
+
+ imesa->dma_buffer = 0;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished general dma put\n");
+}
+
+static drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
+{
+ int idx = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int retcode;
+ drmBufPtr buf;
+ int cnt = 0;
+
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Getting dma buffer\n");
+
+ dma.context = imesa->hHWContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = I810_DMA_BUF_SZ;
+ dma.request_list = &idx;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n",
+ dma.context, dma.request_count,
+ dma.request_size);
+
+ while (1) {
+ retcode = drmDMA(imesa->driFd, &dma);
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "retcode %d sz %d idx %d count %d\n",
+ retcode,
+ dma.request_sizes[0],
+ dma.request_list[0],
+ dma.granted_count);
+
+ if (retcode == 0 &&
+ dma.request_list[0] &&
+ dma.request_sizes[0] &&
+ dma.granted_count)
+ break;
+
+ if (++cnt > 1000) {
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL) {
+ fprintf(stderr, "\n\nflush retcode %d idx %d sz %d count %d\n",
+ retcode, dma.request_list[0],
+ dma.request_sizes[0], dma.granted_count);
+
+ fprintf(stderr, "used %d size %d (ratio %.3f)\n",
+ _tot_used, _tot_size, (float)_tot_size / (float)_tot_used);
+ }
+
+ ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
+ }
+ }
+
+
+
+ buf = &(imesa->i810Screen->bufs->list[idx]);
+ buf->used = 0;
+
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr,
+ "drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
+ "dma_buffer now: buf idx: %d size: %d used: %d\n",
+ dma.request_sizes[0], dma.request_list[0],
+ buf->idx, buf->total,
+ buf->used);
+
+ return buf;
+}
+
+
+
+void i810GetGeneralDmaBufferLocked( i810ContextPtr imesa )
+{
+ if (imesa->dma_buffer) {
+ fprintf(stderr, "i810GetGeneralDmaBufferLocked - dma_buffer not zero\n");
+ exit(1);
+ }
+
+ imesa->dma_buffer = i810_get_buffer_ioctl( imesa );
+}
+
+
+
+/* This waits for *everybody* to finish rendering -- overkill.
+ */
+void i810DmaFinish( i810ContextPtr imesa )
+{
+ FLUSH_BATCH( imesa );
+
+ if (imesa->sarea->last_quiescent != imesa->sarea->last_enqueue) {
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "i810DmaFinish\n");
+
+ LOCK_HARDWARE( imesa );
+ i810RegetLockQuiescent( imesa );
+ UNLOCK_HARDWARE( imesa );
+ imesa->sarea->last_quiescent = imesa->sarea->last_enqueue;
+ }
+}
+
+
+void i810RegetLockQuiescent( i810ContextPtr imesa )
+{
+ if (imesa->sarea->last_quiescent != imesa->sarea->last_enqueue) {
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "i810RegetLockQuiescent\n");
+
+ drmUnlock(imesa->driFd, imesa->hHWContext);
+ i810GetLock( imesa, DRM_LOCK_QUIESCENT );
+ imesa->sarea->last_quiescent = imesa->sarea->last_enqueue;
+ }
+}
+
+void i810WaitAgeLocked( i810ContextPtr imesa, int age )
+{
+ int i = 0;
+
+ if (0) fprintf(stderr, "waitagelocked\n");
+
+ while (++i < 500000 && GET_DISPATCH_AGE(imesa) < age) {
+ ioctl(imesa->driFd, DRM_IOCTL_I810_GETAGE);
+ }
+
+ if (GET_DISPATCH_AGE(imesa) < age) {
+ if (0)
+ fprintf(stderr, "wait locked %d %d\n", age, GET_DISPATCH_AGE(imesa));
+ ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
+ }
+}
+
+
+void i810WaitAge( i810ContextPtr imesa, int age )
+{
+ int i = 0;
+
+ while (++i < 500000 && GET_DISPATCH_AGE(imesa) < age) {
+ ioctl(imesa->driFd, DRM_IOCTL_I810_GETAGE);
+ }
+
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
+
+ i = 0;
+ while (++i < 1000 && GET_DISPATCH_AGE(imesa) < age) {
+ ioctl(imesa->driFd, DRM_IOCTL_I810_GETAGE);
+ usleep(1000);
+ }
+
+ /* To be effective at letting other clients at the hardware,
+ * particularly the X server which regularly needs quiescence to
+ * touch the framebuffer, we really need to sleep *beyond* the
+ * point where our last buffer clears the hardware.
+ */
+ if (imesa->any_contend) {
+ usleep(3000);
+ }
+
+ imesa->any_contend = 0;
+
+ if (GET_DISPATCH_AGE(imesa) < age) {
+ LOCK_HARDWARE(imesa);
+ if (GET_DISPATCH_AGE(imesa) < age)
+ ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
+ UNLOCK_HARDWARE(imesa);
+ }
+}
+
+
+
+void i810FlushVertices( i810ContextPtr imesa )
+{
+ if (!imesa->vertex_dma_buffer) return;
+
+ LOCK_HARDWARE( imesa );
+ i810FlushVerticesLocked( imesa );
+ UNLOCK_HARDWARE( imesa );
+}
+
+
+static int intersect_rect( drm_clip_rect_t *out,
+ drm_clip_rect_t *a,
+ 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;
+}
+
+
+static void age_imesa( i810ContextPtr imesa, int age )
+{
+ if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->age = age;
+ if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->age = age;
+}
+
+void i810FlushVerticesLocked( i810ContextPtr imesa )
+{
+ drm_clip_rect_t *pbox = (drm_clip_rect_t *)imesa->pClipRects;
+ int nbox = imesa->numClipRects;
+ drmBufPtr buffer = imesa->vertex_dma_buffer;
+ drm_i810_vertex_t vertex;
+ int i;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "i810FlushVerticesLocked, buf %p\n", buffer);
+
+ if (!buffer)
+ return;
+
+ if (imesa->dirty & ~I810_EMIT_CLIPRECT)
+ i810EmitHwStateLocked( imesa );
+
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "i810FlushVerticesLocked, used %d\n",
+ buffer->used);
+
+ _tot_used += buffer->used;
+ _tot_size += buffer->total;
+
+ imesa->vertex_dma_buffer = 0;
+
+ vertex.idx = buffer->idx;
+ vertex.used = buffer->used;
+ vertex.discard = 0;
+
+ if (!nbox)
+ vertex.used = 0;
+
+ if (nbox > I810_NR_SAREA_CLIPRECTS)
+ imesa->dirty |= I810_EMIT_CLIPRECT;
+
+ if (!vertex.used || !(imesa->dirty & I810_EMIT_CLIPRECT))
+ {
+ if (nbox == 1)
+ imesa->sarea->nbox = 0;
+ else
+ imesa->sarea->nbox = nbox;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "DRM_IOCTL_I810_VERTEX CASE1 nbox %d used %d\n",
+ nbox, vertex.used);
+
+ vertex.discard = 1;
+ ioctl(imesa->driFd, DRM_IOCTL_I810_VERTEX, &vertex);
+ age_imesa(imesa, imesa->sarea->last_enqueue);
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, nbox);
+ drm_clip_rect_t *b = imesa->sarea->boxes;
+
+ if (imesa->scissor) {
+ imesa->sarea->nbox = 0;
+
+ for ( ; i < nr ; i++) {
+ b->x1 = pbox[i].x1 - imesa->drawX;
+ b->y1 = pbox[i].y1 - imesa->drawY;
+ b->x2 = pbox[i].x2 - imesa->drawX;
+ b->y2 = pbox[i].y2 - imesa->drawY;
+
+ if (intersect_rect(b, b, &imesa->scissor_rect)) {
+ imesa->sarea->nbox++;
+ b++;
+ }
+ }
+
+ /* Culled?
+ */
+ if (!imesa->sarea->nbox) {
+ if (nr < nbox) continue;
+ vertex.used = 0;
+ }
+ } else {
+ imesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++, b++) {
+ b->x1 = pbox[i].x1 - imesa->drawX;
+ b->y1 = pbox[i].y1 - imesa->drawY;
+ b->x2 = pbox[i].x2 - imesa->drawX;
+ b->y2 = pbox[i].y2 - imesa->drawY;
+ }
+ }
+
+ /* Finished with the buffer?
+ */
+ if (nr == nbox)
+ vertex.discard = 1;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "DRM_IOCTL_I810_VERTEX nbox %d used %d\n",
+ nbox, vertex.used);
+
+ ioctl(imesa->driFd, DRM_IOCTL_I810_VERTEX, &vertex);
+ age_imesa(imesa, imesa->sarea->last_enqueue);
+ }
+ }
+
+ imesa->dirty = 0;
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished i810FlushVerticesLocked\n");
+}
+
+
+GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords )
+{
+ GLuint orig_dwords = dwords;
+ GLuint *start;
+
+ dwords++;
+ dwords&=~1;
+
+ if (!imesa->vertex_dma_buffer)
+ {
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "i810AllocPrimitiveVerts -- get buf\n");
+ LOCK_HARDWARE(imesa);
+ imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
+ UNLOCK_HARDWARE(imesa);
+ }
+ else if (imesa->vertex_dma_buffer->used + dwords * 4 >
+ imesa->vertex_dma_buffer->total)
+ {
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "i810AllocPrimitiveVerts -- flush\n");
+ i810FlushVertices( imesa );
+ LOCK_HARDWARE(imesa);
+ imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
+ UNLOCK_HARDWARE(imesa);
+ }
+
+ if (0)
+ fprintf(stderr, "i810AllocPrimitiveVerts %d, buf %d, used %d\n",
+ dwords, imesa->vertex_dma_buffer->idx,
+ imesa->vertex_dma_buffer->used);
+
+
+ start = (GLuint *)((char *)imesa->vertex_dma_buffer->address +
+ imesa->vertex_dma_buffer->used);
+
+ imesa->vertex_dma_buffer->used += dwords * 4;
+
+ if (orig_dwords & 1)
+ *start++ = 0;
+
+ return start;
+}
+
+
+
+
+
+
+static void i810DDFlush( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ FLUSH_BATCH( imesa );
+}
+
+
+static void i810DDFinish( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ i810DmaFinish( imesa );
+}
+
+
+void i810DDInitIoctlFuncs( GLcontext *ctx )
+{
+ ctx->Driver.Flush = i810DDFlush;
+ ctx->Driver.Finish = i810DDFinish;
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h
new file mode 100644
index 000000000..ac213bf1e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h
@@ -0,0 +1,32 @@
+#ifndef MGA_IOCTL_H
+#define MGA_IOCTL_H
+
+#include "i810context.h"
+
+
+GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords );
+
+void i810GetGeneralDmaBufferLocked( i810ContextPtr mmesa );
+
+void i810FlushVertices( i810ContextPtr mmesa );
+void i810FlushVerticesLocked( i810ContextPtr mmesa );
+
+void i810FlushGeneralLocked( i810ContextPtr imesa );
+void i810WaitAgeLocked( i810ContextPtr imesa, int age );
+void i810WaitAge( i810ContextPtr imesa, int age );
+
+void i810DmaFinish( i810ContextPtr imesa );
+
+void i810RegetLockQuiescent( i810ContextPtr imesa );
+
+void i810DDInitIoctlFuncs( GLcontext *ctx );
+
+
+#define FLUSH_BATCH(imesa) do { \
+ if (I810_DEBUG&DEBUG_VERBOSE_IOCTL) \
+ fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
+ if (imesa->vertex_dma_buffer) i810FlushVertices(imesa); \
+} while (0)
+
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810lib.h b/xc/lib/GL/mesa/src/drv/i810/i810lib.h
index ec07995a0..ad80674f0 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810lib.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810lib.h
@@ -28,29 +28,34 @@
#include <stdio.h>
-#include "i810common.h"
-#include "i810buf.h"
#include "i810context.h"
#include "mm.h"
#include "i810log.h"
-#include "i810dma.h"
-#ifndef MESA31
-#error "The I810 driver now requires Mesa 3.1 or higher"
-#endif
+struct i810_mem_range {
+ unsigned long Start;
+ unsigned long End;
+ unsigned long Size;
+};
+
+struct i810_batch_buffer;
+
+struct i810_ring_buffer {
+ int tail_mask;
+ struct i810_mem_range mem;
+ char *virtual_start;
+ int head;
+ int tail;
+ int space;
+ int synced;
+};
typedef struct {
/* logging stuff */
GLuint logLevel;
FILE *logFile;
- /* dma stuff */
- GLuint dmaDriver;
- GLuint dmaSize;
- GLuint dmaAdr;
- GLuint cmdSize;
-
/* bookkeeping for texture swaps */
GLuint dma_buffer_age;
GLuint current_texture_age;
@@ -68,37 +73,28 @@ typedef struct {
GLuint c_lines;
GLuint c_drawWaits;
GLuint c_textureSwaps;
- GLuint c_signals;
GLuint c_dmaFlush;
GLuint c_overflows;
+
+ GLuint c_ringlost;
+ GLuint c_texlost;
+ GLuint c_ctxlost;
GLuint hardwareWentIdle; /* cleared each swapbuffers, set if a
waitfordmacompletion ever exited
without having to wait */
- /* Primitive managment (like warpSerie) */
- GLuint prim_start;
- GLuint prim_dwords;
-
- /* card == dcache
- * sysmem == normal gart memory
- */
- memHeap_t *cardHeap;
- memHeap_t *sysmemHeap;
- unsigned char *sysmemVirtual;
+ unsigned char *texVirtual;
- i810BatchBuffer *dma_buffer;
+
+ struct i810_batch_buffer *dma_buffer;
+ struct i810_ring_buffer LpRing;
+ unsigned char *MMIOBase;
} i810Glx_t;
extern i810Glx_t i810glx;
-int i810_usec( void );
-void i810LibInit();
-void i810SoftReset();
-
-int i810MakeCurrent(i810ContextPtr ctx, struct i810_dest_buffer *buf);
-void i810LoadTexturePalette(unsigned short *pal, int start, int len);
#define I810PACKCOLOR1555(r,g,b,a) \
((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
@@ -123,6 +119,7 @@ static __inline__ GLuint i810PackColor(GLuint format,
case DV_PF_565:
return I810PACKCOLOR565(r,g,b);
default:
+ fprintf(stderr, "unknown format %d\n", (int)format);
return 0;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c b/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c
index 2cd53b42e..06269a818 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c
@@ -1,15 +1,16 @@
/* #include "i810pipeline.h" */
#include <stdio.h>
-#include "xsmesaP.h"
+
+#include "types.h"
+#include "fog.h"
+
#include "i810vb.h"
#include "i810dd.h"
#include "i810lib.h"
#include "i810tris.h"
+#include "i810pipeline.h"
-#include "fog.h"
-
-#if 0
static struct gl_pipeline_stage i810_fast_stage = {
"I810 fast path",
@@ -68,11 +69,6 @@ GLboolean i810DDBuildPrecalcPipeline( GLcontext *ctx )
}
-#endif
-
-
-
-
GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
const struct gl_pipeline_stage *in,
@@ -83,7 +79,6 @@ GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
for (i = o = 0 ; i < nr ; i++) {
switch (in[i].ops) {
-#if 0
case PIPE_OP_RAST_SETUP_0:
out[o] = in[i];
out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
@@ -98,7 +93,6 @@ GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
out[o].run = i810DDDoRasterSetup;
o++;
break;
-#endif
/* Completely replace Mesa's fog processing to generate fog
* coordinates instead of messing with colors.
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h b/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h
index 350f23431..87b95455d 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h
@@ -7,4 +7,8 @@ extern GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
extern GLboolean i810DDBuildPrecalcPipeline( GLcontext *ctx );
+extern void i810DDFastPath( struct vertex_buffer *VB );
+extern void i810DDFastPathInit( void );
+
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810ring.c b/xc/lib/GL/mesa/src/drv/i810/i810ring.c
deleted file mode 100644
index 2e5909e9f..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810ring.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include "mm.h"
-#include "i810dd.h"
-#include "i810lib.h"
-#include "i810state.h"
-
-
-#include "i810dma.h"
-
-static void
-I810PrintErrorState( void )
-{
- fprintf(stderr, "pgetbl_ctl: 0x%x pgetbl_err: 0x%x\n",
- INREG(PGETBL_CTL),
- INREG(PGE_ERR));
-
- fprintf(stderr, "ipeir: %x iphdr: %x\n",
- INREG(IPEIR),
- INREG(IPEHR));
-
- fprintf(stderr, "LP ring tail: %x head: %x len: %x start %x\n",
- INREG(LP_RING + RING_TAIL),
- INREG(LP_RING + RING_HEAD) & HEAD_ADDR,
- INREG(LP_RING + RING_LEN),
- INREG(LP_RING + RING_START));
-
- fprintf(stderr, "eir: %x esr: %x emr: %x\n",
- INREG16(EIR),
- INREG16(ESR),
- INREG16(EMR));
-
- fprintf(stderr, "instdone: %x instpm: %x\n",
- INREG16(INST_DONE),
- INREG8(INST_PM));
-
- fprintf(stderr, "memmode: %x instps: %x\n",
- INREG(MEMMODE),
- INREG(INST_PS));
-
- fprintf(stderr, "hwstam: %x ier: %x imr: %x iir: %x\n",
- INREG16(HWSTAM),
- INREG16(IER),
- INREG16(IMR),
- INREG16(IIR));
-}
-
-
-
-
-static int
-I810USec( void )
-{
- struct timeval tv;
- struct timezone tz;
- gettimeofday( &tv, &tz );
- return (tv.tv_sec & 2047) * 1000000 + tv.tv_usec;
-}
-
-
-
-void
-_I810RefreshLpRing( i810ContextPtr imesa, int update )
-{
- struct i810_ring_buffer *ring = &(i810glx.LpRing);
-
- ring->head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
- ring->tail = INREG(LP_RING + RING_TAIL);
- ring->space = ring->head - (ring->tail+8);
-
- if (ring->space < 0) {
- ring->space += ring->mem.Size;
- if (update)
- imesa->sarea->lastWrap = ++imesa->sarea->ringAge;
- }
-}
-
-int
-_I810WaitLpRing( i810ContextPtr imesa, int n, int timeout_usec )
-{
- struct i810_ring_buffer *ring = &(i810glx.LpRing);
- int iters = 0;
- int startTime = 0;
- int curTime = 0;
-
- if (timeout_usec == 0)
- timeout_usec = 15000000;
-
- if (I810_DEBUG & DEBUG_VERBOSE_API)
- fprintf(stderr, "I810WaitLpRing %d\n", n);
-
- while (ring->space < n)
- {
- int i;
-
- ring->head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
- ring->space = ring->head - (ring->tail+8);
-
- if (ring->space < 0) {
- imesa->sarea->lastWrap = ++imesa->sarea->ringAge;
- ring->space += ring->mem.Size;
- }
-
- iters++;
- curTime = I810USec();
- if ( startTime == 0 || curTime < startTime /*wrap case*/) {
- startTime = curTime;
- } else if ( curTime - startTime > timeout_usec ) {
- I810PrintErrorState();
- fprintf(stderr, "space: %d wanted %d\n",
- ring->space, n );
- UNLOCK_HARDWARE(imesa);
- exit(1);
- }
-
- for (i = 0 ; i < 2000 ; i++)
- ;
- }
-
- return iters;
-}
-
-int
-_I810Sync( i810ContextPtr imesa )
-{
- int rv;
-
- if (I810_DEBUG & DEBUG_VERBOSE_API)
- fprintf(stderr, "I810Sync\n");
-
- /* Send a flush instruction and then wait till the ring is empty.
- * This is stronger than waiting for the blitter to finish as it also
- * flushes the internal graphics caches.
- */
- {
- BEGIN_LP_RING( imesa, 2 );
- OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH );
- OUT_RING( 0 ); /* pad to quadword */
- ADVANCE_LP_RING();
- }
-
-
- i810glx.LpRing.synced = 1; /* ?? */
-
- rv = _I810WaitLpRing( imesa, i810glx.LpRing.mem.Size - 8, 0 );
- imesa->sarea->lastSync = ++imesa->sarea->ringAge;
-
- return rv;
-}
-
-
-
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810span.c b/xc/lib/GL/mesa/src/drv/i810/i810span.c
index ce55c6f70..c47bf2f40 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810span.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810span.c
@@ -1,149 +1,174 @@
#include "types.h"
-#include "i810buf.h"
#include "i810dd.h"
#include "i810lib.h"
#include "i810dma.h"
#include "i810log.h"
+#include "i810span.h"
+#include "i810ioctl.h"
-static void (*xsmWriteRGBASpan)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgba[][4],
- const GLubyte mask[] );
-static void (*xsmWriteRGBSpan)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgb[][3], const GLubyte mask[] );
-static void (*xsmWriteMonoRGBASpan)(const GLcontext *ctx, GLuint n,
- GLint x, GLint y,const GLubyte mask[] );
-static void (*xsmWriteRGBAPixels)(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4],
- const GLubyte mask[] );
-static void (*xsmWriteMonoRGBAPixels)(const GLcontext *ctx,GLuint n,
- const GLint x[], const GLint y[],
- const GLubyte mask[] );
-static void (*xsmReadRGBASpan)(const GLcontext *ctx, GLuint n,
- GLint x, GLint y,GLubyte rgba[][4] );
-static void (*xsmReadRGBAPixels)(const GLcontext *ctx,GLuint n,
- const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] );
-
-/* Wrapper functions */
-
-static void WriteRGBASpan( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgba[][4],
- const GLubyte mask[] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmWriteRGBASpan)(ctx,n,x,y,rgba,mask);
-}
-static void WriteRGBSpan( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgb[][3], const GLubyte mask[] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmWriteRGBSpan)(ctx,n,x,y,rgb,mask);
-}
+#define DBG 0
-static void WriteMonoRGBASpan(const GLcontext *ctx, GLuint n,
- GLint x, GLint y,const GLubyte mask[] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmWriteMonoRGBASpan)(ctx,n,x,y,mask);
-}
+#define LOCAL_VARS \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
+ i810ScreenPrivate *i810Screen = imesa->i810Screen; \
+ GLuint pitch = i810Screen->backPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(imesa->drawMap + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch); \
+ char *read_buf = (char *)(imesa->readMap + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch); \
+ GLushort p = I810_CONTEXT( ctx )->MonoColor; \
+ (void) read_buf; (void) buf; (void) p
-static void WriteRGBAPixels(const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4],
- const GLubyte mask[] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmWriteRGBAPixels)(ctx,n,x,y,rgba,mask);
-}
+#define LOCAL_DEPTH_VARS \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
+ i810ScreenPrivate *i810Screen = imesa->i810Screen; \
+ GLuint pitch = i810Screen->backPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(i810Screen->depth.map + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch)
-static void WriteMonoRGBAPixels(const GLcontext *ctx,GLuint n,
- const GLint x[], const GLint y[],
- const GLubyte mask[] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmWriteMonoRGBAPixels)(ctx,n,x,y,mask);
-}
+#define INIT_MONO_PIXEL(p)
-static void ReadRGBASpan(const GLcontext *ctx, GLuint n,
- GLint x, GLint y,GLubyte rgba[][4] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmReadRGBASpan)(ctx,n,x,y,rgba);
-}
+#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
+ _y >= miny && _y < maxy)
-static void ReadRGBAPixels(const GLcontext *ctx,GLuint n,
- const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] )
-{
- i810Msg(12,__FUNCTION__ "\n");
- i810WaitDrawingEngine();
- (*xsmReadRGBAPixels)(ctx,n,x,y,rgba,mask);
-}
-#define WRAP(x) \
- xsm ## x = ctx->Driver.x; \
- ctx->Driver.x = x
+#define CLIPSPAN(_x,_y,_n,_x1,_n1,_i) \
+ if (_y < miny || _y >= maxy) _n1 = 0, _x1 = x; \
+ else { \
+ _n1 = _n; \
+ _x1 = _x; \
+ if (_x1 < minx) _i += (minx - _x1), _x1 = minx; \
+ if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1; \
+ }
-void i810DDInitSpans( GLcontext *ctx )
-{
- /* Need another hook from mesa to synchronize hardware before
- * write-pixels and read-spans/pixels.
- */
- WRAP(WriteRGBASpan);
- WRAP(WriteRGBSpan);
- WRAP(WriteMonoRGBASpan);
- WRAP(WriteRGBAPixels);
- WRAP(WriteMonoRGBAPixels);
- WRAP(ReadRGBASpan);
- WRAP(ReadRGBAPixels);
-}
+#define Y_FLIP(_y) (height - _y - 1)
+#define HW_LOCK() \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ LOCK_HARDWARE_QUIESCENT(imesa);
+#define HW_CLIPLOOP() \
+ do { \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
+ int _nc = dPriv->numClipRects; \
+ while (_nc--) { \
+ int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
+ int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
+ int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
+ int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+#define HW_UNLOCK() \
+ UNLOCK_HARDWARE(imesa);
-void fxUpdateDDSpanPointers(GLcontext *ctx)
-{
- ctx->Driver.DepthTestSpan=fxDDDepthTestSpanGeneric;
- ctx->Driver.DepthTestPixels=fxDDDepthTestPixelsGeneric;
- ctx->Driver.ReadDepthSpanFloat=fxDDReadDepthSpanFloat;
- ctx->Driver.ReadDepthSpanInt=fxDDReadDepthSpanInt;
-}
+/* 16 bit, 565 rgb color spanline and pixel functions
+ */
+#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 *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 8) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p << 3) & 0xf8; \
+ rgba[3] = 0; /* or 255? */ \
+} while(0)
+
+#define TAG(x) i810##x##_565
+#include "spantmp.h"
+
+
+
+
+/* 15 bit, 555 rgb color spanline and pixel functions
+ */
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \
+ ((g & 0xf8) << 3) | \
+ ((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 *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 7) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xf8; \
+ rgba[2] = (p << 3) & 0xf8; \
+ rgba[3] = 0; /* or 255? */ \
+} while(0)
+
+#define TAG(x) i810##x##_555
+#include "spantmp.h"
+
+
+
+
+/* 16 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLdepth *)(buf + _x*2 + _y*pitch) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLdepth *)(buf + _x*2 + _y*pitch);
+
+/* d = 0xffff; */
+
+#define TAG(x) i810##x##_16
+#include "depthtmp.h"
+
+
-void fxSetupDDSpanPointers(GLcontext *ctx)
+void i810DDInitSpanFuncs( GLcontext *ctx )
{
- ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan;
- ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan;
- ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan;
- ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels;
- ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels;
-
- ctx->Driver.WriteCI8Span =NULL;
- ctx->Driver.WriteCI32Span =NULL;
- ctx->Driver.WriteMonoCISpan =NULL;
- ctx->Driver.WriteCI32Pixels =NULL;
- ctx->Driver.WriteMonoCIPixels =NULL;
-
- ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;
- ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels;
-
- ctx->Driver.ReadCI32Span =NULL;
- ctx->Driver.ReadCI32Pixels =NULL;
+ if (1) {
+ ctx->Driver.WriteRGBASpan = i810WriteRGBASpan_565;
+ ctx->Driver.WriteRGBSpan = i810WriteRGBSpan_565;
+ ctx->Driver.WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
+ ctx->Driver.WriteRGBAPixels = i810WriteRGBAPixels_565;
+ ctx->Driver.WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_565;
+ ctx->Driver.ReadRGBASpan = i810ReadRGBASpan_565;
+ ctx->Driver.ReadRGBAPixels = i810ReadRGBAPixels_565;
+ } else {
+ ctx->Driver.WriteRGBASpan = i810WriteRGBASpan_555;
+ ctx->Driver.WriteRGBSpan = i810WriteRGBSpan_555;
+ ctx->Driver.WriteMonoRGBASpan = i810WriteMonoRGBASpan_555;
+ ctx->Driver.WriteRGBAPixels = i810WriteRGBAPixels_555;
+ ctx->Driver.WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_555;
+ ctx->Driver.ReadRGBASpan = i810ReadRGBASpan_555;
+ ctx->Driver.ReadRGBAPixels = i810ReadRGBAPixels_555;
+ }
+
+ ctx->Driver.ReadDepthSpan = i810ReadDepthSpan_16;
+ ctx->Driver.WriteDepthSpan = i810WriteDepthSpan_16;
+ ctx->Driver.ReadDepthPixels = i810ReadDepthPixels_16;
+ ctx->Driver.WriteDepthPixels = i810WriteDepthPixels_16;
+
+ ctx->Driver.WriteCI8Span =NULL;
+ ctx->Driver.WriteCI32Span =NULL;
+ ctx->Driver.WriteMonoCISpan =NULL;
+ ctx->Driver.WriteCI32Pixels =NULL;
+ ctx->Driver.WriteMonoCIPixels =NULL;
+ ctx->Driver.ReadCI32Span =NULL;
+ ctx->Driver.ReadCI32Pixels =NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810span.h b/xc/lib/GL/mesa/src/drv/i810/i810span.h
index 07276cd86..17a52085b 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810span.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810span.h
@@ -1,6 +1,6 @@
#ifndef _I810_SPAN_H
#define _I810_SPAN_H
-extern void i810DDInitSpans( GLcontext *ctx );
+extern void i810DDInitSpanFuncs( GLcontext *ctx );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810state.c b/xc/lib/GL/mesa/src/drv/i810/i810state.c
index e4a77efc1..caf9fafd6 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810state.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810state.c
@@ -1,33 +1,33 @@
#include <stdio.h>
-#include "xsmesaP.h"
-
#include "types.h"
+#include "enums.h"
#include "pb.h"
#include "dd.h"
-#include "glx_log.h"
#include "mm.h"
#include "i810lib.h"
-#include "i810glx.h"
#include "i810dd.h"
#include "i810context.h"
#include "i810state.h"
-#include "i810depth.h"
#include "i810tex.h"
#include "i810log.h"
#include "i810vb.h"
#include "i810tris.h"
+#include "i810ioctl.h"
+
+
static void i810DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
-
CARD32 a = (ZA_UPDATE_ALPHAFUNC|ZA_UPDATE_ALPHAREF);
+ FLUSH_BATCH(imesa);
+
switch (ctx->Color.AlphaFunc) {
case GL_NEVER: a |= ZA_ALPHA_NEVER; break;
case GL_LESS: a |= ZA_ALPHA_LESS; break;
@@ -42,21 +42,17 @@ static void i810DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
a |= ctx->Color.AlphaRef << ZA_ALPHAREF_SHIFT;
- imesa->reg_dirty |= (1<<I810_CTXREG_ZA);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_ZA] &= ~(ZA_ALPHA_MASK|ZA_ALPHAREF_MASK);
imesa->Setup[I810_CTXREG_ZA] |= a;
}
-/* This shouldn't get called, as the extension is disabled. However,
- * there are internal Mesa calls, and rouge use of the api which must be
- * caught.
- */
static void i810DDBlendEquation(GLcontext *ctx, GLenum mode)
{
if (mode != GL_FUNC_ADD_EXT) {
ctx->Color.BlendEquation = GL_FUNC_ADD_EXT;
- FatalError("Unsupported blend equation");
- gl_error( ctx, GL_INVALID_OPERATION, "glBlendEquation (disabled)");
+ i810Error("Unsupported blend equation");
+ exit(1);
}
}
@@ -65,6 +61,9 @@ static void i810DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
i810ContextPtr imesa = I810_CONTEXT(ctx);
GLuint a;
+ FLUSH_BATCH(imesa);
+
+
a = SDM_UPDATE_SRC_BLEND | SDM_UPDATE_DST_BLEND;
switch (ctx->Color.BlendSrcRGB) {
@@ -80,7 +79,8 @@ static void i810DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
a |= SDM_SRC_SRC_ALPHA; /* use GFXRENDERSTATE_COLOR_FACTOR ??? */
break;
default:
- FatalError("unknown blend source func");
+ i810Error("unknown blend source func");
+ exit(1);
return;
}
@@ -94,11 +94,12 @@ static void i810DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
case GL_DST_ALPHA: a |= SDM_DST_ONE; break;
case GL_ONE_MINUS_DST_ALPHA: a |= SDM_DST_ZERO; break;
default:
- FatalError("unknown blend dst func");
+ i810Error( "unknown blend dst func");
+ exit(1);
return;
}
- imesa->reg_dirty |= (1<<I810_CTXREG_SDM);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_SDM] &= ~(SDM_SRC_MASK|SDM_DST_MASK);
imesa->Setup[I810_CTXREG_SDM] |= a;
}
@@ -124,6 +125,8 @@ static void i810DDDepthFunc(GLcontext *ctx, GLenum func)
i810ContextPtr imesa = I810_CONTEXT(ctx);
int zmode;
+ FLUSH_BATCH(imesa);
+
switch(func) {
case GL_NEVER: zmode = LCS_Z_NEVER; break;
case GL_ALWAYS: zmode = LCS_Z_ALWAYS; break;
@@ -135,43 +138,161 @@ static void i810DDDepthFunc(GLcontext *ctx, GLenum func)
case GL_NOTEQUAL: zmode = LCS_Z_NOTEQUAL; break;
default: return;
}
-
- /* Could just fire it off now...
- */
+
imesa->Setup[I810_CTXREG_LCS] &= ~LCS_Z_MASK;
imesa->Setup[I810_CTXREG_LCS] |= LCS_UPDATE_ZMODE | zmode;
- imesa->reg_dirty |= (1<<I810_CTXREG_LCS);
+
+ imesa->dirty |= I810_UPLOAD_CTX;
}
static void i810DDDepthMask(GLcontext *ctx, GLboolean flag)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- imesa->reg_dirty |= (1<<I810_CTXREG_B2);
+ FLUSH_BATCH(imesa);
+
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_B2] &= ~B2_ZB_WRITE_ENABLE;
- imesa->Setup[I810_CTXREG_B2] |= B2_UPDATE_ZB_WRITE_ENABLE;
if (flag)
imesa->Setup[I810_CTXREG_B2] |= B2_ZB_WRITE_ENABLE;
+}
-/*
- Possible technique to reduce the amount of checking for small state
- changes. Large ones detect wrap on update_count & just send the
- whole state...
- {
- imesa->Update[imesa->update_count & MAX_UPDATE] =
- ( imesa->Setup[I810_CTXREG_B2] &
- (B1_ZB_WRITE_ENABLE | B1_UPDATE_ZB_WRITE_ENABLE | GFX_OP_BOOL_1)
- );
- imesa->update_count++;
- }
-*/
+/* =============================================================
+ * Polygon stipple
+ *
+ * The i810 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern. Could
+ * also consider using a multitexturing mechanism for this, but
+ * that has real issues, too.
+ */
+static void i810DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON);
+
+ FLUSH_BATCH(imesa);
+ ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
+
+ if (active) {
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ }
+
+ p[0] = mask[0] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[4] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[8] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[12] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 0 ; j < 4; j++)
+ for (i = 0 ; i < 4 ; i++)
+ if (*m++ != p[j]) {
+ ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
+ return;
+ }
+
+
+
+ imesa->poly_stipple = ( ((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12) );
+
+ if (1) {
+ imesa->Setup[I810_CTXREG_ST1] &= ~0xffff;
+ imesa->Setup[I810_CTXREG_ST1] |= ( ((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12) );
+ }
+
+ if (active)
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
}
+/* ============================================================
+ * Line stipple -- not completed
+ * - need to cope with stipplecounter
+ */
+#if 0
+static void i810DDLineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLushort p, h, test;
+
+ FLUSH_BATCH(imesa);
+ ctx->Driver.TriangleCaps |= DD_LINE_STIPPLE;
+
+ if (ctx->Line.StippleFlag) {
+ imesa->lines_are_tris |= I810_LINE_STIPPLE;
+
+ if (ctx->PB->primitive == GL_LINE) {
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ }
+ }
+
+ switch (factor) {
+ case 1:
+ p = pattern & 0xf;
+ p |= p << 4;
+ p |= p << 8;
+ test = p;
+ break;
+ case 2:
+ p = pattern & 1;
+ p |= (pattern & 2) << 2;
+ p |= p << 1;
+ p |= p << 4;
+ p |= p << 8;
+ test = pattern & 3;
+ test |= test << 2;
+ test |= test << 4;
+ test |= test << 8;
+ break;
+ default:
+ p = 0;
+ if (pattern)
+ p = 0xffff;
+ test = p;
+ break;
+ }
+
+ if (pattern != test) {
+ ctx->Driver.TriangleCaps &= ~DD_LINE_STIPPLE;
+ imesa->lines_are_tris &= ~I810_LINE_STIPPLE;
+ return;
+ }
+
+ h = (((p & 1) << 0) |
+ ((p & 2) << 4) |
+ ((p & 3) << 8) |
+ ((p & 4) << 12));
+
+ h |= h << 1;
+ h |= h << 2;
+
+ imesa->vert_line_stipple = p;
+ imesa->horiz_line_stipple = h;
+
+ if (ctx->Line.Stipple && ctx->PB->primitive == GL_LINE)
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+}
+#endif
+
+/* ============================================================
+ * Antialiased lines and triangles
+ */
+/* Nothing to do...
+ */
@@ -184,36 +305,105 @@ static void i810DDDepthMask(GLcontext *ctx, GLboolean flag)
static void i810DDScissor( GLcontext *ctx, GLint x, GLint y,
- GLsizei w, GLsizei h )
+ GLsizei w, GLsizei h )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ FLUSH_BATCH(imesa);
+ imesa->scissor_rect.x1 = x;
+ imesa->scissor_rect.y1 = imesa->driDrawable->h - (y+h);
+ imesa->scissor_rect.x2 = x+w;
+ imesa->scissor_rect.y2 = imesa->driDrawable->h - y;
+
+
+ if (I810_DEBUG&DEBUG_VERBOSE_2D)
+ fprintf(stderr, "SET SCISSOR %d,%d-%d,%d\n",
+ imesa->scissor_rect.x1,
+ imesa->scissor_rect.y1,
+ imesa->scissor_rect.x2,
+ imesa->scissor_rect.y2);
+
+
+ imesa->dirty |= I810_EMIT_CLIPRECT;
+}
+
+
+static void i810DDDither(GLcontext *ctx, GLboolean enable)
+{
+}
+
+
+static GLboolean i810DDSetDrawBuffer(GLcontext *ctx, GLenum mode )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- int x1,x2,y1,y2;
- x1 = ctx->Scissor.X;
- x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
- y1 = i810DB->Height - ctx->Scissor.Y - ctx->Scissor.Height;
- y2 = i810DB->Height - ctx->Scissor.Y - 1;
-
- if (x1 < 0) x1 = 0;
- if (y1 < 0) y1 = 0;
- if (x2 >= i810DB->Width) x2 = i810DB->Width-1;
- if (y2 >= i810DB->Height) y2 = i810DB->Height-1;
-
- if (x1 > x2 || y1 > y2) {
- x1 = 0; x2 = 0;
- y2 = 0; y1 = 1;
+ FLUSH_BATCH(imesa);
+
+ imesa->Fallback &= ~I810_FALLBACK_DRAW_BUFFER;
+
+ if (mode == GL_FRONT_LEFT)
+ {
+ imesa->drawMap = imesa->driScreen->pFB;
+ imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->fbOffset |
+ imesa->i810Screen->backPitchBits);
+ imesa->dirty |= I810_UPLOAD_BUFFERS;
+ i810XMesaSetFrontClipRects( imesa );
+ return GL_TRUE;
+ }
+ else if (mode == GL_BACK_LEFT)
+ {
+ imesa->drawMap = imesa->i810Screen->back.map;
+ imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->backOffset |
+ imesa->i810Screen->backPitchBits);
+ imesa->dirty |= I810_UPLOAD_BUFFERS;
+ i810XMesaSetBackClipRects( imesa );
+ return GL_TRUE;
}
- /* Turn it off if full screen?
- */
- imesa->Setup[I810_CTXREG_SCI0] = GFX_OP_SCISSOR_INFO;
- imesa->Setup[I810_CTXREG_SCI1] = (y1<<16)|x1;
- imesa->Setup[I810_CTXREG_SCI2] = (y2<<16)|x2;
+ imesa->Fallback |= I810_FALLBACK_DRAW_BUFFER;
+ return GL_FALSE;
+}
+static void i810DDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum mode )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
- imesa->reg_dirty |= ((1<<I810_CTXREG_SCI0) |
- (1<<I810_CTXREG_SCI1) |
- (1<<I810_CTXREG_SCI2));
+ if (mode == GL_FRONT_LEFT)
+ {
+ imesa->readMap = imesa->driScreen->pFB;
+ imesa->Fallback &= ~I810_FALLBACK_READ_BUFFER;
+ }
+ else if (mode == GL_BACK_LEFT)
+ {
+ imesa->readMap = imesa->i810Screen->back.map;
+ imesa->Fallback &= ~I810_FALLBACK_READ_BUFFER;
+ }
+ else
+ imesa->Fallback |= I810_FALLBACK_READ_BUFFER;
+}
+
+
+
+static void i810DDSetColor(GLcontext *ctx,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ imesa->MonoColor = i810PackColor( imesa->i810Screen->fbFormat,
+ r, g, b, a );
+}
+
+
+static void i810DDClearColor(GLcontext *ctx,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ imesa->ClearColor = i810PackColor( imesa->i810Screen->fbFormat,
+ r, g, b, a );
}
@@ -226,6 +416,8 @@ static void i810DDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
i810ContextPtr imesa = I810_CONTEXT(ctx);
GLuint mode = LCS_CULL_BOTH;
+ FLUSH_BATCH(imesa);
+
if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
mode = LCS_CULL_CW;
if (ctx->Polygon.CullFaceMode == GL_FRONT)
@@ -238,25 +430,55 @@ static void i810DDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
if (ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON)
{
- imesa->reg_dirty |= (1<<I810_CTXREG_LCS);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
- imesa->Setup[I810_CTXREG_LCS] |= (LCS_UPDATE_CULL_MODE | mode);
+ imesa->Setup[I810_CTXREG_LCS] |= mode;
}
}
static void i810DDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
{
- if (ctx->Polygon.CullFlag) {
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- GLuint mode = imesa->LcsCullMode;
-
- if (ctx->PB->primitive != GL_POLYGON)
- mode = LCS_CULL_DISABLE;
-
- imesa->reg_dirty |= (1<<I810_CTXREG_LCS);
- imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
- imesa->Setup[I810_CTXREG_LCS] |= (LCS_UPDATE_CULL_MODE | mode);
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ FLUSH_BATCH(imesa);
+
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+
+ switch (ctx->PB->primitive) {
+ case GL_POLYGON:
+ if (ctx->Polygon.StippleFlag &&
+ (ctx->Driver.TriangleCaps & DD_TRI_STIPPLE))
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+ if (ctx->Polygon.CullFlag)
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsCullMode;
+ else
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ if (ctx->Polygon.SmoothFlag)
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ break;
+ case GL_LINES:
+#if 0
+ if (ctx->Line.StippleFlag && (ctx->Driver.TriangleCaps & DD_LINE_STIPPLE))
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+#endif
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
+ if (ctx->Line.SmoothFlag) {
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5;
+ }
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ break;
+ case GL_POINTS:
+ if (ctx->Point.SmoothFlag)
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ break;
+ default:
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ break;
}
}
@@ -266,15 +488,36 @@ static void i810DDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
* Color masks
*/
-/* Mesa calls this from the wrong place.
+/* Mesa calls this from the wrong place - it is called a very large
+ * number of redundant times.
*
- * Its a fallback...
+ * Colormask can be simulated by multipass or multitexture techniques.
*/
static GLboolean i810DDColorMask(GLcontext *ctx,
GLboolean r, GLboolean g,
GLboolean b, GLboolean a )
{
- return 1;
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint tmp = 0;
+ GLuint rv = 1;
+
+ imesa->Fallback &= ~I810_FALLBACK_COLORMASK;
+
+ if (r && g && b) {
+ tmp = imesa->Setup[I810_CTXREG_B2] | B2_FB_WRITE_ENABLE;
+ } else if (!r && !g && !b) {
+ tmp = imesa->Setup[I810_CTXREG_B2] & ~B2_FB_WRITE_ENABLE;
+ } else {
+ rv = 0;
+ imesa->Fallback |= I810_FALLBACK_COLORMASK;
+ }
+
+ if (tmp != imesa->Setup[I810_CTXREG_B2]) {
+ FLUSH_BATCH(imesa);
+ imesa->Setup[I810_CTXREG_B2] = tmp;
+ }
+
+ return rv;
}
/* Seperate specular not fully implemented in hardware... Needs
@@ -284,7 +527,16 @@ static GLboolean i810DDColorMask(GLcontext *ctx,
static void i810DDLightModelfv(GLcontext *ctx, GLenum pname,
const GLfloat *param)
{
- if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
+ {
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ FLUSH_BATCH(imesa);
+
+ imesa->Fallback &= ~I810_FALLBACK_SPECULAR;
+
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ imesa->Fallback |= I810_FALLBACK_SPECULAR;
+
I810_CONTEXT(ctx)->new_state |= I810_NEW_TEXTURE;
}
}
@@ -295,7 +547,7 @@ static void i810DDLightModelfv(GLcontext *ctx, GLenum pname,
* Fog
*/
-void i810DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+static void i810DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
@@ -304,7 +556,7 @@ void i810DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
- imesa->reg_dirty |= (1<<I810_CTXREG_FOG);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_FOG] = ((GFX_OP_FOG_COLOR | color) &
~FOG_RESERVED_MASK);
}
@@ -320,66 +572,126 @@ static void i810DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
switch(cap) {
case GL_ALPHA_TEST:
- imesa->reg_dirty |= (1<<I810_CTXREG_B1);
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_B1] &= ~B1_ALPHA_TEST_ENABLE;
- imesa->Setup[I810_CTXREG_B1] |= B1_UPDATE_ALPHA_TEST_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_ALPHA_TEST_ENABLE;
break;
case GL_BLEND:
- imesa->reg_dirty |= (1<<I810_CTXREG_B1);
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_B1] &= ~B1_BLEND_ENABLE;
- imesa->Setup[I810_CTXREG_B1] |= B1_UPDATE_BLEND_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_BLEND_ENABLE;
break;
case GL_DEPTH_TEST:
- imesa->reg_dirty |= (1<<I810_CTXREG_B1);
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_B1] &= ~B1_Z_TEST_ENABLE;
- imesa->Setup[I810_CTXREG_B1] |= B1_UPDATE_Z_TEST_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_Z_TEST_ENABLE;
break;
case GL_SCISSOR_TEST:
- imesa->reg_dirty |= (1<<I810_CTXREG_SC);
- imesa->Setup[I810_CTXREG_SC] &= ~SC_ENABLE_MASK;
- imesa->Setup[I810_CTXREG_SC] |= SC_UPDATE_SCISSOR;
- if (state)
- imesa->Setup[I810_CTXREG_SC] |= SC_ENABLE;
+ FLUSH_BATCH(imesa);
+ imesa->scissor = state;
+ imesa->dirty |= I810_EMIT_CLIPRECT;
+ break;
+ case GL_POLYGON_STIPPLE:
+ if ((ctx->Driver.TriangleCaps & DD_TRI_STIPPLE) &&
+ ctx->PB->primitive == GL_POLYGON)
+ {
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+ }
+ break;
+ case GL_LINE_STIPPLE:
+#if 0
+ if (ctx->Driver.TriangleCaps & DD_LINE_STIPPLE)
+ {
+ imesa->lines_are_tris &= ~I810_LINE_STIPPLE;
+ if (state)
+ imesa->lines_are_tris |= I810_LINE_STIPPLE;
+
+ if (ctx->PB->primitive == GL_LINE) {
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+ }
+ }
+#endif
+ break;
+ case GL_LINE_SMOOTH:
+ if (ctx->PB->primitive == GL_LINE) {
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
+ if (state) {
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5;
+ }
+ }
+ break;
+ case GL_POINT_SMOOTH:
+ if (ctx->PB->primitive == GL_POINT) {
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ }
+ break;
+ case GL_POLYGON_SMOOTH:
+ if (ctx->PB->primitive == GL_POLYGON) {
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ }
break;
case GL_FOG:
- imesa->reg_dirty |= (1<<I810_CTXREG_B1);
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_B1] &= ~B1_FOG_ENABLE;
- imesa->Setup[I810_CTXREG_B1] |= B1_UPDATE_FOG_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_FOG_ENABLE;
break;
case GL_CULL_FACE:
if (ctx->PB->primitive == GL_POLYGON) {
- imesa->reg_dirty |= (1<<I810_CTXREG_LCS);
+ FLUSH_BATCH(imesa);
+ imesa->dirty |= I810_UPLOAD_CTX;
imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
- imesa->Setup[I810_CTXREG_LCS] |= LCS_UPDATE_CULL_MODE;
if (state)
imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsCullMode;
else
imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
}
break;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_3D:
+ FLUSH_BATCH(imesa);
+ imesa->new_state |= I810_NEW_TEXTURE;
+ break;
case GL_TEXTURE_2D:
- imesa->reg_dirty |= (1<<I810_CTXREG_MT);
+ FLUSH_BATCH(imesa);
+ imesa->new_state |= I810_NEW_TEXTURE;
+ imesa->dirty |= I810_UPLOAD_CTX;
if (ctx->Texture.CurrentUnit == 0) {
imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL0_ENABLE;
- imesa->Setup[I810_CTXREG_MT] |= MT_UPDATE_TEXEL0_STATE;
if (state)
imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL0_ENABLE;
} else {
imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL1_ENABLE;
- imesa->Setup[I810_CTXREG_MT] |= MT_UPDATE_TEXEL1_STATE;
if (state)
imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL1_ENABLE;
}
-
- I810_CONTEXT(ctx)->new_state |= I810_NEW_TEXTURE;
break;
default:
;
@@ -387,26 +699,6 @@ static void i810DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
}
-/* Don't use the regs parm yet.
- */
-static void i810UpdateRegs( GLcontext *ctx, GLuint regs )
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- int i;
-
- {
- BEGIN_BATCH( I810_CTX_SETUP_SIZE );
-
- for (i = 0 ; i < I810_CTX_SETUP_SIZE ; i++) {
- OUT_BATCH( imesa->Setup[i] );
- }
-
- ADVANCE_BATCH();
- }
-
- imesa->reg_dirty = 0;
-}
-
/* =============================================================
*/
@@ -417,50 +709,158 @@ void i810DDPrintState( const char *msg, GLuint state )
{
fprintf(stderr, "%s (0x%x): %s\n",
msg,
- state,
+ (unsigned int) state,
(state & I810_NEW_TEXTURE) ? "texture, " : "");
}
+
+
void i810DDUpdateHwState( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- if (imesa->new_state & I810_NEW_TEXTURE)
+ if (imesa->new_state & I810_NEW_TEXTURE) {
+ FLUSH_BATCH(imesa);
i810UpdateTextureState( ctx );
+ }
imesa->new_state = 0;
+}
+
- if (imesa->reg_dirty) {
- i810FinishPrimitive();
- i810UpdateRegs( ctx, imesa->reg_dirty );
+
+/*
+ * i810DmaExecute
+ * Add a block of data to the dma buffer
+ *
+ * -- In ring buffer mode, must be called with lock held, and translates to
+ * OUT_RING rather than outbatch
+ *
+ * -- In dma mode, probably won't be used because state updates will have
+ * to be done via the kernel for security...
+ */
+static void i810DmaExecute( i810ContextPtr imesa,
+ GLuint *code, int dwords, const char *where )
+{
+ if (I810_DEBUG & DEBUG_VERBOSE_RING)
+ fprintf(stderr, "i810DmaExecute (%s)\n", where);
+
+ if (dwords & 1) {
+ i810Error( "Misaligned buffer in i810DmaExecute\n" );
+ exit(1);
+ }
+
+ {
+ int i;
+ BEGIN_BATCH( imesa, dwords);
+
+ for ( i = 0 ; i < dwords ; i++ ) {
+ OUT_BATCH( code[i] );
+ }
+
+ ADVANCE_BATCH();
}
}
-void i810DDInitStatePointers(GLcontext *ctx)
+
+void i810EmitDrawingRectangle( i810ContextPtr imesa )
{
- ctx->Driver.Enable = i810DDEnable;
- ctx->Driver.LightModelfv = i810DDLightModelfv;
- ctx->Driver.AlphaFunc = i810DDAlphaFunc;
- ctx->Driver.BlendEquation = i810DDBlendEquation;
- ctx->Driver.BlendFunc = i810DDBlendFunc;
- ctx->Driver.BlendFuncSeparate = i810DDBlendFuncSeparate;
- ctx->Driver.DepthFunc = i810DDDepthFunc;
- ctx->Driver.DepthMask = i810DDDepthMask;
- ctx->Driver.Fogfv = i810DDFogfv;
- ctx->Driver.Scissor = i810DDScissor;
- ctx->Driver.CullFace = i810DDCullFaceFrontFace;
- ctx->Driver.FrontFace = i810DDCullFaceFrontFace;
- ctx->Driver.ColorMask = i810DDColorMask;
- ctx->Driver.ReducedPrimitiveChange = i810DDReducedPrimitiveChange;
- ctx->Driver.RenderStart = i810DDUpdateHwState;
- ctx->Driver.RenderFinish = 0;
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
+
+ int x0 = imesa->drawX;
+ int y0 = imesa->drawY;
+ int x1 = x0 + dPriv->w;
+ int y1 = y0 + dPriv->h;
+
+
+ /* Coordinate origin of the window - may be offscreen.
+ */
+ imesa->BufferSetup[I810_DESTREG_DR4] = ((y0<<16) |
+ (((unsigned)x0)&0xFFFF));
+
+ /* Clip to screen.
+ */
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > i810Screen->width-1) x1 = i810Screen->width-1;
+ if (y1 > i810Screen->height-1) y1 = i810Screen->height-1;
+
+
+ /* Onscreen drawing rectangle.
+ */
+ imesa->BufferSetup[I810_DESTREG_DR2] = ((y0<<16) | x0);
+ imesa->BufferSetup[I810_DESTREG_DR3] = (((y1+1)<<16) | (x1+1));
+ imesa->dirty |= I810_UPLOAD_BUFFERS;
+}
+
+
+static void i810DDPrintDirty( const char *msg, GLuint state )
+{
+ fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n",
+ msg,
+ (unsigned int) state,
+ (state & I810_REFRESH_RING) ? "read-lp-ring, " : "",
+ (state & I810_WAIT_AGE) ? "wait-age, " : "",
+ (state & I810_UPLOAD_TEX0IMAGE) ? "upload-tex0, " : "",
+ (state & I810_UPLOAD_TEX1IMAGE) ? "upload-tex1, " : "",
+ (state & I810_UPLOAD_CTX) ? "upload-ctx, " : "",
+ (state & I810_UPLOAD_BUFFERS) ? "upload-bufs, " : "",
+ (state & I810_EMIT_CLIPRECT) ? "emit-single-cliprect, " : ""
+ );
}
+/* Spew the state onto the ring/batch buffer and/or texture memory.
+ */
+void i810EmitHwStateLocked( i810ContextPtr imesa )
+{
+ if (I810_DEBUG & DEBUG_VERBOSE_API)
+ i810DDPrintDirty( "\n\n\ni810EmitHwStateLocked", imesa->dirty );
+
+ if (imesa->dirty & ~(I810_WAIT_AGE|I810_EMIT_CLIPRECT))
+ {
+ i810GetGeneralDmaBufferLocked( imesa );
+
+ if ((imesa->dirty & I810_UPLOAD_TEX0IMAGE) && imesa->CurrentTexObj[0])
+ i810UploadTexImages(imesa, imesa->CurrentTexObj[0]);
+
+ if ((imesa->dirty & I810_UPLOAD_TEX1IMAGE) && imesa->CurrentTexObj[1])
+ i810UploadTexImages(imesa, imesa->CurrentTexObj[1]);
+
+ if ((imesa->dirty & I810_UPLOAD_CTX)) {
+ i810DmaExecute( imesa, imesa->Setup, I810_CTX_SETUP_SIZE, "context" );
+
+ if (imesa->CurrentTexObj[0])
+ i810DmaExecute( imesa, imesa->CurrentTexObj[0]->Setup,
+ I810_TEX_SETUP_SIZE, "tex-0");
+
+ if (imesa->CurrentTexObj[1])
+ i810DmaExecute( imesa, imesa->CurrentTexObj[1]->Setup,
+ I810_TEX_SETUP_SIZE, "tex-1");
+ }
+
+ if (imesa->dirty & I810_UPLOAD_BUFFERS)
+ i810DmaExecute( imesa, imesa->BufferSetup,
+ I810_DEST_SETUP_SIZE, "buffers" );
+
+ i810FlushGeneralLocked( imesa );
+ }
+
+ /* Clear everything but the cliprect dirty flag:
+ */
+ imesa->dirty &= (I810_EMIT_CLIPRECT|I810_WAIT_AGE);
+}
+
+
+
void i810DDInitState( i810ContextPtr imesa )
{
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
+
+ memset(imesa->Setup, 0, sizeof(imesa->Setup));
imesa->Setup[I810_CTXREG_VF] = (GFX_OP_VERTEX_FMT |
VF_TEXCOORD_COUNT_2 |
@@ -562,6 +962,8 @@ void i810DDInitState( i810ContextPtr imesa )
imesa->Setup[I810_CTXREG_SDM] = ( GFX_OP_SRC_DEST_MONO |
+ SDM_UPDATE_MONO_ENABLE |
+ 0 |
SDM_UPDATE_SRC_BLEND |
SDM_SRC_ONE |
SDM_UPDATE_DST_BLEND |
@@ -627,7 +1029,7 @@ void i810DDInitState( i810ContextPtr imesa )
LCS_UPDATE_ZMODE |
LCS_Z_LESS |
LCS_UPDATE_LINEWIDTH |
- (0x2<<LCS_LINEWIDTH_SHIFT) |
+ LCS_LINEWIDTH_1_0 |
LCS_UPDATE_ALPHA_INTERP |
LCS_ALPHA_INTERP |
LCS_UPDATE_FOG_INTERP |
@@ -641,14 +1043,6 @@ void i810DDInitState( i810ContextPtr imesa )
imesa->LcsCullMode = LCS_CULL_CW;
- imesa->Setup[I810_CTXREG_SCI0] = GFX_OP_SCISSOR_INFO;
- imesa->Setup[I810_CTXREG_SCI1] = 0;
- imesa->Setup[I810_CTXREG_SCI2] = 0;
-
- imesa->Setup[I810_CTXREG_SC] = ( GFX_OP_SCISSOR |
- SC_UPDATE_SCISSOR |
- 0 );
-
imesa->Setup[I810_CTXREG_PV] = ( GFX_OP_PV_RULE |
PV_UPDATE_PIXRULE |
PV_PIXRULE_ENABLE |
@@ -659,8 +1053,59 @@ void i810DDInitState( i810ContextPtr imesa )
PV_UPDATE_TRISTRIP |
PV_TRISTRIP_PV0 );
-}
+ imesa->Setup[I810_CTXREG_ST0] = GFX_OP_STIPPLE;
+ imesa->Setup[I810_CTXREG_ST1] = 0;
+
+
+
+ imesa->Setup[I810_CTXREG_AA] = ( GFX_OP_ANTIALIAS |
+ AA_UPDATE_EDGEFLAG |
+ AA_ENABLE_EDGEFLAG | /* ? */
+ AA_UPDATE_POLYWIDTH |
+ AA_POLYWIDTH_05 |
+ AA_UPDATE_LINEWIDTH |
+ AA_LINEWIDTH_05 |
+ AA_UPDATE_BB_EXPANSION |
+ 0 |
+ AA_UPDATE_AA_ENABLE |
+ 0 );
+
+
+
+ /* This stuff is all invarient as long as we are using
+ * shared back and depth buffers.
+ */
+ memset(imesa->BufferSetup, 0, sizeof(imesa->BufferSetup));
+ imesa->BufferSetup[I810_DESTREG_DI0] = CMD_OP_DESTBUFFER_INFO;
+
+ if (imesa->glCtx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
+ imesa->drawMap = i810Screen->back.map;
+ imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset |
+ i810Screen->backPitchBits);
+ } else {
+ imesa->drawMap = imesa->driScreen->pFB;
+ imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset |
+ i810Screen->backPitchBits);
+ }
+
+ if (imesa->glCtx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
+ imesa->readMap = i810Screen->back.map;
+ } else {
+ imesa->readMap = imesa->driScreen->pFB;
+ }
+
+ imesa->BufferSetup[I810_DESTREG_DV0] = GFX_OP_DESTBUFFER_VARS;
+ imesa->BufferSetup[I810_DESTREG_DV1] = (DV_HORG_BIAS_OGL |
+ DV_VORG_BIAS_OGL |
+ i810Screen->fbFormat);
+ imesa->BufferSetup[I810_DESTREG_ZB0] = CMD_OP_Z_BUFFER_INFO;
+ imesa->BufferSetup[I810_DESTREG_ZB1] = (i810Screen->depthOffset |
+ i810Screen->backPitchBits);
+
+ imesa->BufferSetup[I810_DESTREG_DR0] = GFX_OP_DRAWRECT_INFO;
+ imesa->BufferSetup[I810_DESTREG_DR1] = DR1_RECT_CLIP_ENABLE;
+}
#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\
@@ -672,16 +1117,66 @@ void i810DDUpdateState( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
+ /* Have to do this here to detect texture fallbacks in time:
+ */
+ if (I810_CONTEXT(ctx)->new_state & I810_NEW_TEXTURE)
+ i810DDUpdateHwState( ctx );
+
+
if (ctx->NewState & INTERESTED) {
- i810FinishPrimitive();
i810DDChooseRenderState(ctx);
i810ChooseRasterSetupFunc(ctx);
}
+
+ if (0)
+ fprintf(stderr, "IndirectTriangles %x Fallback %x\n",
+ imesa->IndirectTriangles, imesa->Fallback);
- /* TODO: stop mesa from clobbering these.
- */
- ctx->Driver.PointsFunc=imesa->PointsFunc;
- ctx->Driver.LineFunc=imesa->LineFunc;
- ctx->Driver.TriangleFunc=imesa->TriangleFunc;
- ctx->Driver.QuadFunc=imesa->QuadFunc;
+ if (!imesa->Fallback)
+ {
+ ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+ ctx->IndirectTriangles |= imesa->IndirectTriangles;
+
+ ctx->Driver.PointsFunc=imesa->PointsFunc;
+ ctx->Driver.LineFunc=imesa->LineFunc;
+ ctx->Driver.TriangleFunc=imesa->TriangleFunc;
+ ctx->Driver.QuadFunc=imesa->QuadFunc;
+ }
+}
+
+
+void i810DDInitStateFuncs(GLcontext *ctx)
+{
+ ctx->Driver.UpdateState = i810DDUpdateState;
+ ctx->Driver.Enable = i810DDEnable;
+ ctx->Driver.LightModelfv = i810DDLightModelfv;
+ ctx->Driver.AlphaFunc = i810DDAlphaFunc;
+ ctx->Driver.BlendEquation = i810DDBlendEquation;
+ ctx->Driver.BlendFunc = i810DDBlendFunc;
+ ctx->Driver.BlendFuncSeparate = i810DDBlendFuncSeparate;
+ ctx->Driver.DepthFunc = i810DDDepthFunc;
+ ctx->Driver.DepthMask = i810DDDepthMask;
+ ctx->Driver.Fogfv = i810DDFogfv;
+ ctx->Driver.Scissor = i810DDScissor;
+ ctx->Driver.CullFace = i810DDCullFaceFrontFace;
+ ctx->Driver.FrontFace = i810DDCullFaceFrontFace;
+ ctx->Driver.ColorMask = i810DDColorMask;
+ ctx->Driver.ReducedPrimitiveChange = i810DDReducedPrimitiveChange;
+ ctx->Driver.RenderStart = i810DDUpdateHwState;
+ ctx->Driver.RenderFinish = 0;
+
+ ctx->Driver.PolygonStipple = i810DDPolygonStipple;
+ ctx->Driver.LineStipple = 0;
+
+ ctx->Driver.SetReadBuffer = i810DDSetReadBuffer;
+ ctx->Driver.SetDrawBuffer = i810DDSetDrawBuffer;
+
+ ctx->Driver.Color = i810DDSetColor;
+ ctx->Driver.ClearColor = i810DDClearColor;
+ ctx->Driver.Dither = i810DDDither;
+
+ ctx->Driver.Index = 0;
+ ctx->Driver.ClearIndex = 0;
+ ctx->Driver.IndexMask = 0;
}
+
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810state.h b/xc/lib/GL/mesa/src/drv/i810/i810state.h
index 1cccb44bb..d0551631e 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810state.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810state.h
@@ -2,10 +2,12 @@
#define _I810_STATE_H
-extern void i810DDInitStatePointers(GLcontext *ctx);
extern void i810DDUpdateHwState( GLcontext *ctx );
extern void i810DDUpdateState( GLcontext *ctx );
extern void i810DDInitState( i810ContextPtr imesa );
+extern void i810DDInitStateFuncs( GLcontext *ctx );
+
+extern void i810DDPrintState( const char *msg, GLuint state );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810swap.c b/xc/lib/GL/mesa/src/drv/i810/i810swap.c
index 3c78921e3..a0f6d8938 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810swap.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810swap.c
@@ -1,66 +1,71 @@
+
+#include "types.h"
+#include "vbrender.h"
+#include "i810log.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mm.h"
+#include "i810lib.h"
+#include "i810dd.h"
+#include "i810dma.h"
+#include "i810state.h"
+#include "i810swap.h"
+#include "i810dma.h"
+#include "i810ioctl.h"
+
/*
* i810BackToFront
*
- * Blit the visible rectangles from the back buffer to the screen
- * Can't really do this from a direct context - don't have the clip
- * info, and getting it would be a lot slower than just sending a
- * request to the server to do the blit there.
- *
- * drawable -- front buffer
- * buf -- back buffer
+ * Blit the visible rectangles from the back buffer to the screen.
+ * Respects the frontbuffer cliprects, and applies the offset
+ * necessary if the backbuffer is positioned elsewhere in the screen.
*/
-int i810BackToFront(DrawablePtr drawable,
- struct i810_dest_buffer *buf)
+static int i810BackToFront( i810ContextPtr imesa )
{
- RegionPtr prgnClip;
- BoxPtr pbox;
- int i,nbox;
- int ofs, xorg, yorg, pitch;
-
- if ( !xf86VTSema ) {
- i810Error("BackToFront(): !xf86VTSema\n");
- return BadMatch; /* Is this really an error? */
- }
-
- if ( drawable->width != buf->Width ||
- drawable->height != buf->Height ||
- drawable->type != DRAWABLE_WINDOW ) {
- i810Error("BackToFront(): bad drawable\n");
- return BadMatch;
- }
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
- prgnClip = &((WindowPtr)drawable)->clipList;
- pbox = REGION_RECTS(prgnClip);
- nbox = REGION_NUM_RECTS(prgnClip);
- if( !nbox ) return Success;
- xorg = drawable->x;
- yorg = drawable->y;
- pitch = buf->Pitch;
- ofs = buf->MemBlock->ofs;
+ /* Use the frontbuffer cliprects:
+ */
+ XF86DRIClipRectPtr pbox = dPriv->pClipRects;
+ int nbox = dPriv->numClipRects;
+ if( nbox )
{
- unsigned int BR13 = ((vga256InfoRec.displayWidth * vgaBytesPerPixel) |
+ int i;
+ int pitch = i810Screen->backPitch;
+
+ int dx = dPriv->backX - dPriv->x;
+ int dy = dPriv->backY - dPriv->y;
+ int ofs = ( i810Screen->backOffset +
+ dy * i810Screen->backPitch +
+ dx * i810Screen->cpp);
+
+ unsigned int BR13 = ((i810Screen->fbStride) |
(0xCC << 16));
for (i=0; i < nbox; i++, pbox++) {
- int x = pbox->x1 - xorg;
- int y = pbox->y1 - yorg;
int w = pbox->x2 - pbox->x1;
int h = pbox->y2 - pbox->y1;
- int start = ofs + x*vgaBytesPerPixel + y*pitch;
- int dst = ((pbox->x1 + pbox->y1 * vga256InfoRec.displayWidth) *
- vgaBytesPerPixel);
+ int start = ofs + pbox->x1*i810Screen->cpp + pbox->y1*pitch;
+ int dst = pbox->x1*i810Screen->cpp + pbox->y1*i810Screen->fbStride;
+
+ if (I810_DEBUG&DEBUG_VERBOSE_2D)
+ fprintf(stderr, "i810BackToFront %d,%d-%dx%d\n",
+ pbox->x1,pbox->y1,w,h);
{
- BEGIN_BATCH( 6 );
+ BEGIN_BATCH( imesa, 6 );
OUT_BATCH( BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4 );
OUT_BATCH( BR13 ); /* dest pitch, rop */
- OUT_BATCH( (h << 16) | (w * vgaBytesPerPixel));
+ OUT_BATCH( (h << 16) | (w * i810Screen->cpp));
OUT_BATCH( dst );
OUT_BATCH( pitch ); /* src pitch */
@@ -76,33 +81,70 @@ int i810BackToFront(DrawablePtr drawable,
/*
* ClearBox
- * Add hardware commands to draw a filled box for the
- * debugging display.
+ *
+ * Add hardware commands to draw a filled box for the debugging
+ * display. These are drawn into the current drawbuffer, so should
+ * work with both front and backbuffer rendering. (However, it
+ * is only ever called on swapbuffer - ie backbuffer rendering).
*/
-static void ClearBox( int x, int y, int w, int h, int r, int g, int b )
+static void ClearBox( i810ContextPtr imesa,
+ int cx, int cy, int cw, int ch,
+ int r, int g, int b )
{
- int start = (i810DB->MemBlock->ofs +
- y * i810DB->Pitch +
- x * vgaBytesPerPixel);
-
- BEGIN_BATCH(6);
-
- OUT_BATCH( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
- OUT_BATCH( BR13_SOLID_PATTERN |
- (0xF0 << 16) |
- i810DB->Pitch );
- OUT_BATCH( (h << 16) | (w * vgaBytesPerPixel));
- OUT_BATCH( start );
- OUT_BATCH( i810PackColor( i810DB->Format, r, g, b, 0 ) );
- OUT_BATCH( 0 );
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
+
+ int _nc = imesa->numClipRects;
+
+ while (_nc--) {
+ int x1 = cx + dPriv->x;
+ int y1 = cy + dPriv->y;
+ int x2 = x1 + cw;
+ int y2 = y1 + ch;
+
+ {
+ int rx1 = imesa->pClipRects[_nc].x1;
+ int ry1 = imesa->pClipRects[_nc].y1;
+ int rx2 = imesa->pClipRects[_nc].x2;
+ int ry2 = imesa->pClipRects[_nc].y2;
+
+
+ if (x2 < rx1) continue;
+ if (y2 < ry1) continue;
+ if (x1 > rx2) continue;
+ if (y1 > ry2) continue;
+ if (x1 < rx1) x1 = rx1;
+ if (y1 < ry1) y1 = ry1;
+ if (x2 > rx2) x2 = rx2;
+ if (y2 > ry2) y2 = ry2;
+ }
- if (0)
- fprintf(stderr, "box %d,%x %dx%d col %x (%d,%d,%d)\n", x,y,w,h,
- i810PackColor( i810DB->Format, r, g, b, 0 ), r, g, b);
- ADVANCE_BATCH();
+ {
+ int start = (0 +
+ y1 * i810Screen->backPitch +
+ x1 * i810Screen->cpp);
+ BEGIN_BATCH( imesa, 6 );
+ OUT_BATCH( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
+ OUT_BATCH( BR13_SOLID_PATTERN |
+ (0xF0 << 16) |
+ i810Screen->backPitch );
+ OUT_BATCH( ((y2-y1) << 16) | ((x2-x1) * i810Screen->cpp));
+ OUT_BATCH( start );
+ OUT_BATCH( i810PackColor( i810Screen->fbFormat, r, g, b, 0 ) );
+ OUT_BATCH( 0 );
+
+ if (I810_DEBUG&DEBUG_VERBOSE_2D)
+ fprintf(stderr, "box %d,%x %d,%d col %x (%d,%d,%d)\n",
+ (int)x1,(int)y1, (int)x2,(int)y2,
+ (int)i810PackColor( i810Screen->fbFormat, r, g, b, 0 ),
+ (int)r, (int)g, (int)b);
+
+ ADVANCE_BATCH();
+ }
+ }
}
@@ -111,143 +153,110 @@ static void ClearBox( int x, int y, int w, int h, int r, int g, int b )
* Draw some small boxesin the corner of the buffer
* based on some performance information
*/
-void i810PerformanceBoxes( int is_direct ) {
- int w, t;
+static void i810PerformanceBoxes( i810ContextPtr imesa ) {
- if ( !i810glx.boxes )
- return;
-
-
- /* draw a box to show we are active, so if it is't seen
- it means that it is completely software based rendering */
- /* draw a purple box if we are direct rendering */
- if ( is_direct ) { /* purple = direct (client dma) rendering */
- ClearBox( 4, 4, 8, 8, 255, 0, 255 );
- } else if ( i810glx.dmaDriver ) { /* white = server dma rendering */
- ClearBox( 4, 4, 8, 8, 255, 255, 255 );
- } else { /* grey = servery PDMA */
- ClearBox( 4, 4, 8, 8, 128, 128, 128 );
- }
+
+ /* draw a box to show we are active, so if it is't seen it means
+ that it is completely software based. Purple is traditional for
+ direct rendering */
+ ClearBox( imesa, 4, 4, 8, 8, 255, 0, 255 );
/* draw a red box if we had to wait for drawing to complete
(software render or texture swap) */
if ( i810glx.c_drawWaits ) {
- ClearBox( 16, 4, 8, 8, 255, 0, 0 );
+ ClearBox( imesa, 16, 4, 8, 8, 255, 0, 0 );
i810glx.c_drawWaits = 0;
}
- /* draw a blue box if the register protection signal was hit */
- if ( i810glx.c_signals ) {
- ClearBox( 28, 4, 8, 8, 0, 0, 255 );
- i810glx.c_signals = 0;
+ /* draw a blue box if the 3d context was lost
+ */
+ if ( i810glx.c_ctxlost ) {
+ ClearBox( imesa, 28, 4, 8, 8, 0, 0, 255 );
+ i810glx.c_ctxlost = 0;
}
+ /* draw an orange box if texture state was stomped */
+ if ( i810glx.c_texlost ) {
+ ClearBox( imesa, 40, 4, 8, 8, 255, 128, 0 );
+ i810glx.c_texlost = 0;
+ }
+
/* draw a yellow box if textures were swapped */
if ( i810glx.c_textureSwaps ) {
- ClearBox( 40, 4, 8, 8, 255, 255, 0 );
+ ClearBox( imesa, 56, 4, 8, 8, 255, 255, 0 );
i810glx.c_textureSwaps = 0;
}
-
-
+
/* draw a green box if we had to wait for dma to complete (full utilization)
on the previous frame */
if ( !i810glx.hardwareWentIdle ) {
- ClearBox( 64, 4, 8, 8, 0, 255, 0 );
+ ClearBox( imesa, 72, 4, 8, 8, 0, 255, 0 );
}
i810glx.hardwareWentIdle = 0;
+#if 0
/* show buffer utilization */
if ( i810glx.c_dmaFlush > 1 ) {
/* draw a solid bar if we flushed more than one buffer */
- ClearBox( 4, 16, 252, 4, 255, 32, 32 );
+ ClearBox( imesa, 4, 16, 252, 4, 255, 32, 32 );
} else {
- /* draw bars to represent the utilization of primary and secondary buffers */
- ClearBox( 4, 16, 252, 4, 32, 32, 32 );
+ /* draw bars to represent the utilization of primary and
+ secondary buffers */
+ ClearBox( imesa, 4, 16, 252, 4, 32, 32, 32 );
t = i810glx.dma_buffer->mem.Size;
w = 252 * i810glx.dma_buffer->head / t;
if ( w < 1 ) {
w = 1;
}
- ClearBox( 4, 16, w, 4, 196, 128, 128 );
+ ClearBox( imesa, 4, 16, w, 4, 196, 128, 128 );
}
+#endif
+
i810glx.c_dmaFlush = 0;
}
-static void i810SendDmaFlush( void )
+
+static void i810EmitFlush( i810ContextPtr imesa )
{
- BEGIN_BATCH(2);
+ BEGIN_BATCH( imesa, 2 );
OUT_BATCH( INST_PARSER_CLIENT | INST_OP_FLUSH );
OUT_BATCH( 0 );
ADVANCE_BATCH();
}
-
-/*
- * Copy the back buffer to the front buffer. If there's no back buffer
- * this is a no-op. Only called in indirect contexts.
- */
-static void i810ServerSwapBuffers( XSMesaBuffer b )
+void i810SwapBuffers( i810ContextPtr imesa )
{
- /* make sure mesa gives us everything */
- if (i810Ctx && i810Ctx->gl_ctx)
- glFlush();
+ int tmp;
- if ( !b->db_state ) {
- /* not double buffered, so do nothing */
- } else {
- ValidateGC(b->frontbuffer, b->cleargc);
- if ( b->backimage ) {
-
- struct i810_dest_buffer *buf =
- (struct i810_dest_buffer *)b->backimage->devPriv;
+ if (I810_DEBUG & DEBUG_VERBOSE_API)
+ fprintf(stderr, "i810SwapBuffers()\n");
- if ( buf && buf->Drawable ) {
+ FLUSH_BATCH( imesa );
+ LOCK_HARDWARE( imesa );
+
+ i810GetGeneralDmaBufferLocked( imesa );
+ i810EmitFlush( imesa );
- /* flush the last primitive */
- i810FinishPrimitive();
+ if ( i810glx.boxes )
+ i810PerformanceBoxes( imesa );
- /* Drop a flush op into the dma stream */
- i810SendDmaFlush();
+ i810BackToFront( imesa );
+ i810EmitFlush( imesa );
+ i810FlushGeneralLocked( imesa );
- /* diagnostic drawing tools */
- i810PerformanceBoxes( 0 );
+ /* Throttle app if the last swap hasn't dispatched yet
+ */
+ if (0)
+ fprintf(stderr, "dispatch age: %d last swap: %d\n",
+ GET_DISPATCH_AGE(imesa), imesa->lastSwap);
+
+ tmp = GET_ENQUEUE_AGE(imesa);
- /* hardware accelerated back to front blit */
- i810BackToFront( (DrawablePtr)b->frontbuffer,buf );
+ UNLOCK_HARDWARE( imesa );
- /* make sure all dma is going to get executed if
- * everything has gone well, this will be the only flush
- * each frame
- */
- i810DmaFlush();
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap)
+ i810WaitAge(imesa, imesa->lastSwap);
- } else {
- /* Use backimage's dimension (not buffer's) */
- (*b->cleargc->ops->PutImage)((DrawablePtr)b->frontbuffer,
- b->cleargc,
- b->frontbuffer->depth,
- 0, 0,
- b->backimage->width,
- b->backimage->height,
- 0, ZPixmap, b->backimage->data);
- }
- } else {
- /* Copy pixmap to window on server */
- (*b->cleargc->ops->CopyArea)((DrawablePtr)b->backpixmap,
- b->frontbuffer,
- b->cleargc,
- 0, 0, b->width, b->height,
- 0, 0);
- }
- }
-
- /* report performance counters */
- i810Msg(10, "swapBuffers: c_triangles:%i c_lines:%i c_points:%i c_setup:%i c_textures:%i\n",
- i810glx.c_triangles, i810glx.c_lines, i810glx.c_points, i810glx.c_setupPointers,
- i810glx.c_textureSwaps );
- i810glx.c_triangles = 0;
- i810glx.c_lines = 0;
- i810glx.c_points = 0;
- i810glx.c_setupPointers = 0;
- i810Msg(10, "---------------------------------------------------------\n" );
+ imesa->secondLastSwap = imesa->lastSwap;
+ imesa->lastSwap = tmp;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.c b/xc/lib/GL/mesa/src/drv/i810/i810tex.c
index 5b1d00398..35c395296 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tex.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.c
@@ -22,7 +22,6 @@
*
*/
-#include "xsmesaP.h"
#include <stdlib.h>
#include <stdio.h>
@@ -32,6 +31,7 @@
#include "i810lib.h"
#include "i810tex.h"
#include "i810log.h"
+#include "i810ioctl.h"
#include "simple_list.h"
#include "enums.h"
@@ -49,7 +49,6 @@ static void i810SetTexWrapping(i810TextureObjectPtr tex, GLenum s, GLenum t)
val ^= (MCS_V_WRAP^MCS_V_CLAMP);
tex->Setup[I810_TEXREG_MCS] = val;
- tex->reg_dirty |= (1 << I810_TEXREG_MCS);
}
static void i810SetTexFilter(i810TextureObjectPtr t, GLenum minf, GLenum magf)
@@ -136,10 +135,6 @@ static void i810SetTexFilter(i810TextureObjectPtr t, GLenum minf, GLenum magf)
MLC_LOD_BIAS_MASK,
0x0);
}
-
- t->reg_dirty |= ((1<<I810_TEXREG_MLC) |
- (1<<I810_TEXREG_MLL) |
- (1<<I810_TEXREG_MF));
}
@@ -161,8 +156,8 @@ static void ReplicateMesaTexState(i810TextureObjectPtr t,
i810SetTexBorderColor(t,mesatex->BorderColor);
}
-i810TextureObjectPtr i810CreateTexObj(i810ContextPtr ctx,
- struct gl_texture_object *tObj)
+static i810TextureObjectPtr i810CreateTexObj(i810ContextPtr imesa,
+ struct gl_texture_object *tObj)
{
i810TextureObjectPtr t;
GLuint height, width, pitch, i, textureFormat, log_pitch;
@@ -194,7 +189,6 @@ i810TextureObjectPtr i810CreateTexObj(i810ContextPtr ctx,
case GL_COLOR_INDEX:
textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444;
t->texelBytes = 1;
- t->UsePalette = 1;
break;
default:
i810Error( "i810CreateTexObj: bad image->Format\n" );
@@ -211,6 +205,7 @@ i810TextureObjectPtr i810CreateTexObj(i810ContextPtr ctx,
log_pitch++;
t->dirty_images = 0;
+ t->bound = 0;
for ( height = i = 0 ; i < I810_TEX_MAXLEVELS && tObj->Image[i] ; i++ ) {
t->image[i].image = tObj->Image[i];
@@ -226,7 +221,6 @@ i810TextureObjectPtr i810CreateTexObj(i810ContextPtr ctx,
t->min_level = 0;
t->globj = tObj;
t->age = 0;
- t->reg_dirty = ~0;
t->Setup[I810_TEXREG_MI0] = GFX_OP_MAP_INFO;
@@ -279,89 +273,72 @@ i810TextureObjectPtr i810CreateTexObj(i810ContextPtr ctx,
ReplicateMesaTexState(t,tObj);
tObj->DriverData = t;
- insert_at_head(&ctx->SwappedOut, t);
+ imesa->dirty |= I810_UPLOAD_CTX;
+ make_empty_list( t );
return t;
}
-int i810DestroyTexObj(i810ContextPtr ctx, i810TextureObjectPtr t)
+void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
{
- if (t) {
- if (t->age > i810glx.dma_buffer_age)
- i810WaitDrawingEngine();
+ if (!t) return;
+ /* This is sad - need to sync *in case* we upload a texture
+ * to this newly free memory...
+ */
+ if (t->MemBlock) {
mmFreeMem(t->MemBlock);
- t->MemBlock = 0;
- remove_from_list(t);
- free(t);
+ t->MemBlock = 0;
+
+ if (t->age > imesa->dirtyAge)
+ imesa->dirtyAge = t->age;
}
- return 0;
+
+ if (t->globj)
+ t->globj->DriverData = 0;
+
+ if (t->bound)
+ imesa->CurrentTexObj[t->bound - 1] = 0;
+
+ remove_from_list(t);
+ free(t);
}
-/* Card memory management
- */
-static void i810SwapOutOldestTexObj( i810ContextPtr ctx )
+static void i810SwapOutTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
{
- i810TextureObjectPtr t = ctx->TexObjList.prev;
-
- fprintf(stderr, "swap out oldest, age %d, dma age %d\n",
- t->age, i810glx.dma_buffer_age);
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
- if (t->age > i810glx.dma_buffer_age)
- i810WaitDrawingEngine();
+ if (t->age > imesa->dirtyAge)
+ imesa->dirtyAge = t->age;
+ }
- mmFreeMem( t->MemBlock );
- t->MemBlock = 0;
t->dirty_images = ~0;
- move_to_tail(&ctx->SwappedOut, t);
+ move_to_tail(&(imesa->SwappedOut), t);
}
-/* Just allocates the memory - doesn't do the upload.
- */
-static int i810SwapInTexObj( i810ContextPtr ctx, i810TextureObjectPtr t)
-{
- i810Msg(10," Swapping in texture.\n");
- i810glx.c_textureSwaps++;
-
- /* Try to allocate textureHeap memory, swapping out stuff until we
- * can.
- */
- while (1)
- {
- t->MemBlock = mmAllocMem( i810glx.sysmemHeap, t->totalSize, 12, 0 );
-
- if (t->MemBlock)
- break;
- if (is_empty_list(&ctx->TexObjList))
- return -1;
-
- i810SwapOutOldestTexObj( ctx );
- }
-
- t->Setup[I810_TEXREG_MI3] = t->MemBlock->ofs;
- t->BufAddr = i810glx.sysmemVirtual + t->MemBlock->ofs;
- t->reg_dirty |= ((1<<I810_TEXREG_MI0) |
- (1<<I810_TEXREG_MI1) |
- (1<<I810_TEXREG_MI2) |
- (1<<I810_TEXREG_MI3));
- return 0;
-}
/* Upload an image from mesa's internal copy.
*/
-static int i810UploadTexLevel( i810TextureObjectPtr t, int level )
+static void i810UploadTexLevel( i810TextureObjectPtr t, int level )
{
const struct gl_texture_image *image = t->image[level].image;
int i,j;
- i810Msg(10,"CopyImage():\n");
+ if (I810_DEBUG & DEBUG_VERBOSE_LRU)
+ fprintf(stderr, "i810UploadTexLevel %d, BufAddr %p offset %x\n",
+ level, t->BufAddr, t->image[level].offset);
/* Need triangle (rather than pixel) fallbacks to simulate this using
* normal textured triangles.
- */
+ *
+ * DO THIS IN DRIVER STATE MANAGMENT, not hardware state.
+ *
if (image->Border != 0)
- i810Error("Not supported texture border %d.\n",image->Border);
+ i810Error("Not supported texture border %d.\n", (int) image->Border);
+ */
switch (t->image[level].internalFormat) {
case GL_RGB:
@@ -440,6 +417,8 @@ static int i810UploadTexLevel( i810TextureObjectPtr t, int level )
}
break;
+ /* TODO: Translate color indices *now*:
+ */
case GL_COLOR_INDEX:
{
GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
@@ -452,38 +431,221 @@ static int i810UploadTexLevel( i810TextureObjectPtr t, int level )
src += 1;
}
}
-
- t->UsePalette = I810_USE_PALETTE;
}
break;
default:
- i810Error("Not supported texture format %d\n",image->Format);
- FatalError("bummer");
- return -1;
+ i810Error("Not supported texture format %d\n",(int)image->Format);
+ exit(1);
}
+}
- return 0;
+
+
+void i810PrintLocalLRU( i810ContextPtr imesa )
+{
+ i810TextureObjectPtr t;
+ int sz = 1 << (imesa->i810Screen->logTextureGranularity);
+
+ foreach( t, &imesa->TexObjList ) {
+ if (!t->globj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture (bound %d) at %x sz %x\n",
+ t->bound,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+}
+
+void i810PrintGlobalLRU( i810ContextPtr imesa )
+{
+ int i, j;
+ drm_i810_tex_region_t *list = imesa->sarea->texList;
+
+ for (i = 0, j = I810_NR_TEX_REGIONS ; i < I810_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev);
+ j = list[j].next;
+ if (j == I810_NR_TEX_REGIONS) break;
+ }
+
+ if (j != I810_NR_TEX_REGIONS)
+ fprintf(stderr, "Loop detected in global LRU\n");
+}
+
+
+void i810ResetGlobalLRU( i810ContextPtr imesa )
+{
+ drm_i810_tex_region_t *list = imesa->sarea->texList;
+ int sz = 1 << imesa->i810Screen->logTextureGranularity;
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element
+ * in the array (I810_NR_TEX_REGIONS) is the sentinal. Keeping it
+ * at the end of the array allows it to be addressed rationally
+ * when looking up objects at a particular location in texture
+ * memory.
+ */
+ for (i = 0 ; (i+1) * sz <= imesa->i810Screen->textureSize ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = I810_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = I810_NR_TEX_REGIONS;
+ list[I810_NR_TEX_REGIONS].prev = i;
+ list[I810_NR_TEX_REGIONS].next = 0;
+ imesa->sarea->texAge = 0;
}
+static void i810UpdateTexLRU( i810ContextPtr imesa, i810TextureObjectPtr t )
+{
+ int i;
+ int logsz = imesa->i810Screen->logTextureGranularity;
+ int start = t->MemBlock->ofs >> logsz;
+ int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+ drm_i810_tex_region_t *list = imesa->sarea->texList;
+
+ imesa->texAge = ++imesa->sarea->texAge;
+
+ /* Update our local LRU
+ */
+ move_to_head( &(imesa->TexObjList), t );
+
+ /* Update the global LRU
+ */
+ for (i = start ; i <= end ; i++) {
+
+ list[i].in_use = 1;
+ list[i].age = imesa->texAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = I810_NR_TEX_REGIONS;
+ list[i].next = list[I810_NR_TEX_REGIONS].next;
+ list[(unsigned)list[I810_NR_TEX_REGIONS].next].prev = i;
+ list[I810_NR_TEX_REGIONS].next = i;
+ }
+}
+
-static int i810UploadTexImages( i810ContextPtr ctx, i810TextureObjectPtr t )
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent
+ * the other client's textures.
+ */
+void i810TexturesGone( i810ContextPtr imesa,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
+{
+ i810TextureObjectPtr t, tmp;
+
+ foreach_s ( t, tmp, &imesa->TexObjList ) {
+
+ if (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.
+ */
+ if (t->bound)
+ i810SwapOutTexObj( imesa, t );
+ else
+ i810DestroyTexObj( imesa, t );
+ }
+
+
+ if (in_use) {
+ t = (i810TextureObjectPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->MemBlock = mmAllocMem( imesa->texHeap, size, 0, offset);
+ insert_at_head( &imesa->TexObjList, t );
+ }
+}
+
+
+
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+int i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t )
{
int i;
+ int ofs;
i810glx.c_textureSwaps++;
- if (!t->MemBlock)
- i810SwapInTexObj( ctx, t );
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->MemBlock) {
+ while (1)
+ {
+ t->MemBlock = mmAllocMem( imesa->texHeap, t->totalSize, 12, 0 );
+ if (t->MemBlock)
+ break;
- if (t->age > i810glx.dma_buffer_age)
- i810WaitDrawingEngine();
+ if (imesa->TexObjList.prev->bound) {
+ fprintf(stderr, "Hit bound texture in upload\n");
+ i810PrintLocalLRU( imesa );
+ return -1;
+ }
- for (i = t->min_level ; i <= t->max_level ; i++)
- if (t->dirty_images & (1<<i)) {
- if (i810UploadTexLevel( t, i ) != 0)
+ if (imesa->TexObjList.prev == &(imesa->TexObjList)) {
+ fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
+ mmDumpMemInfo( imesa->texHeap );
return -1;
+ }
+
+ i810DestroyTexObj( imesa, imesa->TexObjList.prev );
}
+
+ ofs = t->MemBlock->ofs;
+ t->Setup[I810_TEXREG_MI3] = imesa->i810Screen->textureOffset + ofs;
+ t->BufAddr = i810glx.texVirtual + ofs;
+ imesa->dirty |= I810_UPLOAD_CTX;
+ }
+
+ /* Let the world know we've used this memory recently.
+ */
+ i810UpdateTexLRU( imesa, t );
+
+ if (I810_DEBUG & DEBUG_VERBOSE_LRU)
+ fprintf(stderr, "dispatch age: %d age freed memory: %d\n",
+ GET_DISPATCH_AGE(imesa), imesa->dirtyAge);
+
+ if (imesa->dirtyAge >= GET_DISPATCH_AGE(imesa))
+ i810WaitAgeLocked( imesa, imesa->dirtyAge );
+
+
+ if (t->dirty_images) {
+ if (I810_DEBUG & DEBUG_VERBOSE_LRU)
+ fprintf(stderr, "*");
+
+ for (i = t->min_level ; i <= t->max_level ; i++)
+ if (t->dirty_images & (1<<i))
+ i810UploadTexLevel( t, i );
+ }
+
t->dirty_images = 0;
return 0;
@@ -499,7 +661,6 @@ static void i810TexSetUnit( i810TextureObjectPtr t, GLuint unit )
t->Setup[I810_TEXREG_MCS] ^= (MCS_COORD_0 ^ MCS_COORD_1);
t->Setup[I810_TEXREG_MF] ^= (MF_MAP_0 ^ MF_MAP_1);
- t->reg_dirty = ~0;
t->current_unit = unit;
}
@@ -519,30 +680,29 @@ static void i810UpdateTex0State( GLcontext *ctx )
if ( tObj != ctx->Texture.Unit[0].CurrentD[2] )
tObj = 0;
- if (!(ctx->Texture.Enabled & 0xf) || !tObj || !tObj->Complete) {
-
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_ITERATED_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ONE |
- MC_UPDATE_OP |
- MC_OP_ARG1 );
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX0_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
+ imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ITERATED_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 );
+
+ imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 );
- imesa->reg_dirty |= ((1<<I810_CTXREG_MA0) |
- (1<<I810_CTXREG_MC0));
+
+ if (!(ctx->Texture.Enabled & 0xf) || !tObj || !tObj->Complete) {
return;
}
@@ -557,30 +717,13 @@ static void i810UpdateTex0State( GLcontext *ctx )
i810TexSetUnit( t, 0 );
if (t->dirty_images)
- i810UploadTexImages(imesa, t);
-
- t->age = ++i810glx.current_texture_age;
- move_to_head(&imesa->TexObjList, t);
-
- imesa->CurrentTex0Obj = t;
-
- if (0)
- if (t->UsePalette == I810_USE_PALETTE) {
- if (ctx->Texture.SharedPalette) {
- if (imesa->GlobalPaletteUpdated)
- i810LoadTexturePalette(imesa->GlobalPalette,0,256);
- imesa->GlobalPaletteUpdated = 0;
- }
- else {
- i810LoadTexturePalette(t->Palette,0,256);
- imesa->GlobalPaletteUpdated = 1;
- }
- }
-
-
- if (t->reg_dirty)
- i810DmaExecute(t->Setup,I810_TEX_SETUP_SIZE);
+ imesa->dirty |= I810_UPLOAD_TEX0IMAGE;
+
+ imesa->CurrentTexObj[0] = t;
+ t->bound = 1;
+ if (t->MemBlock)
+ i810UpdateTexLRU( imesa, t );
switch (ctx->Texture.Unit[0].EnvMode) {
case GL_REPLACE:
@@ -730,15 +873,10 @@ static void i810UpdateTex0State( GLcontext *ctx )
break;
default:
- FatalError("unkown tex env mode");
+ fprintf(stderr, "unknown tex env mode");
+ exit(1);
break;
}
-
-
-
- imesa->reg_dirty |= ((1<<I810_CTXREG_MA0) |
- (1<<I810_CTXREG_MC0));
-
}
@@ -756,36 +894,34 @@ static void i810UpdateTex1State( GLcontext *ctx )
if ( tObj != ctx->Texture.Unit[1].CurrentD[2] )
tObj = 0;
- if (!(ctx->Texture.Enabled & 0xf0) || !tObj || !tObj->Complete) {
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_ONE |
- MC_ARG1_DONT_REPLICATE_ALPHA |
- MC_ARG1_DONT_INVERT |
- MC_UPDATE_ARG2 |
- MC_ARG2_ONE |
- MC_ARG2_DONT_REPLICATE_ALPHA |
- MC_ARG2_DONT_INVERT |
- MC_UPDATE_OP |
- MC_OP_DISABLE );
+ imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ONE |
+ MC_ARG1_DONT_REPLICATE_ALPHA |
+ MC_ARG1_DONT_INVERT |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_ARG2_DONT_REPLICATE_ALPHA |
+ MC_ARG2_DONT_INVERT |
+ MC_UPDATE_OP |
+ MC_OP_DISABLE );
+
+ imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_ARG1_DONT_INVERT |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_ARG2_DONT_INVERT |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 );
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_CURRENT_ALPHA |
- MA_ARG1_DONT_INVERT |
- MA_UPDATE_ARG2 |
- MA_ARG2_CURRENT_ALPHA |
- MA_ARG2_DONT_INVERT |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
-
- imesa->reg_dirty |= ((1<<I810_CTXREG_MA1) |
- (1<<I810_CTXREG_MC1));
+ if (!(ctx->Texture.Enabled & 0xf0) || !tObj || !tObj->Complete) {
return;
}
@@ -796,35 +932,18 @@ static void i810UpdateTex1State( GLcontext *ctx )
if (!t) return;
}
- if (t->dirty_images)
- i810UploadTexImages(imesa, t);
-
if (t->current_unit != 1)
i810TexSetUnit( t, 1 );
- t->age = ++i810glx.current_texture_age;
- move_to_head(&imesa->TexObjList, t);
- imesa->CurrentTex1Obj = t;
-
- if (0)
- if (t->UsePalette == I810_USE_PALETTE) {
- if (ctx->Texture.SharedPalette) {
- if (imesa->GlobalPaletteUpdated)
- i810LoadTexturePalette(imesa->GlobalPalette,0,256);
- imesa->GlobalPaletteUpdated = 0;
- }
- else {
- i810LoadTexturePalette(t->Palette,0,256);
- imesa->GlobalPaletteUpdated = 1;
- }
- }
-
+ if (t->dirty_images)
+ imesa->dirty |= I810_UPLOAD_TEX1IMAGE;
- if (t->reg_dirty)
- i810DmaExecute(t->Setup,I810_TEX_SETUP_SIZE);
+ imesa->CurrentTexObj[1] = t;
+ t->bound = 2;
+ if (t->MemBlock)
+ i810UpdateTexLRU( imesa, t );
-
switch (ctx->Texture.Unit[1].EnvMode) {
case GL_REPLACE:
imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
@@ -980,64 +1099,70 @@ static void i810UpdateTex1State( GLcontext *ctx )
break;
default:
- FatalError("unkown tex 1 env mode");
+ fprintf(stderr, "unkown tex 1 env mode\n");
+ exit(1);
break;
}
-
- imesa->reg_dirty |= ((1<<I810_CTXREG_MA1) |
- (1<<I810_CTXREG_MC1));
}
void i810UpdateTextureState( GLcontext *ctx )
{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound = 0;
+ if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound = 0;
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
i810UpdateTex0State( ctx );
i810UpdateTex1State( ctx );
+ I810_CONTEXT( ctx )->dirty |= I810_UPLOAD_CTX;
}
/*****************************************
- * Driver functions
+ * DRIVER functions
*****************************************/
-void i810TexEnv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+static void i810TexEnv( GLcontext *ctx, GLenum pname, const GLfloat *param )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
if (pname == GL_TEXTURE_ENV_MODE) {
+ FLUSH_BATCH(imesa);
imesa->new_state |= I810_NEW_TEXTURE;
} else if (pname == GL_TEXTURE_ENV_COLOR) {
struct gl_texture_unit *texUnit =
&ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- GLubyte c[4];
+ GLfloat *fc = texUnit->EnvColor;
GLuint col;
- FLOAT_RGBA_TO_UBYTE_RGBA(texUnit->EnvColor, c);
- col = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]);
+ col = ((((GLubyte)fc[3])<<24) |
+ (((GLubyte)fc[0])<<16) |
+ (((GLubyte)fc[1])<<8) |
+ (((GLubyte)fc[2])<<0));
if (imesa->Setup[I810_CTXREG_CF1] != col) {
+ FLUSH_BATCH(imesa);
imesa->Setup[I810_CTXREG_CF1] = col;
- imesa->reg_dirty |= (1<<I810_CTXREG_CF1);
+ imesa->dirty |= I810_UPLOAD_CTX;
}
}
}
-void i810TexImage( GLcontext *ctx,
- GLenum target,
- struct gl_texture_object *tObj,
- GLint level,
- GLint internalFormat,
- const struct gl_texture_image *image )
+static void i810TexImage( GLcontext *ctx,
+ GLenum target,
+ struct gl_texture_object *tObj,
+ GLint level,
+ GLint internalFormat,
+ const struct gl_texture_image *image )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
i810TextureObjectPtr t;
- CHECK_CONTEXT( return; );
-
i810Msg(10,"i810TexImage(%d): level %d internalFormat %x\n",
tObj->Name, level, internalFormat);
@@ -1049,6 +1174,7 @@ void i810TexImage( GLcontext *ctx,
t = (i810TextureObjectPtr) tObj->DriverData;
if (t) {
+ if (t->bound) FLUSH_BATCH(imesa);
/* if this is the current object, it will force an update */
i810DestroyTexObj( imesa, t );
tObj->DriverData = 0;
@@ -1056,12 +1182,12 @@ void i810TexImage( GLcontext *ctx,
}
}
-void i810TexSubImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLint internalFormat,
- const struct gl_texture_image *image )
+static void i810TexSubImage( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLint internalFormat,
+ const struct gl_texture_image *image )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
i810TextureObjectPtr t;
@@ -1070,13 +1196,12 @@ void i810TexSubImage( GLcontext *ctx, GLenum target,
width, height, image->Width,image->Height,
level);
- CHECK_CONTEXT( return; );
-
if ( target != GL_TEXTURE_2D )
return;
t = (i810TextureObjectPtr) tObj->DriverData;
if (t) {
+ if (t->bound) FLUSH_BATCH( imesa );
i810DestroyTexObj( imesa, t );
tObj->DriverData = 0;
imesa->new_state |= I810_NEW_TEXTURE;
@@ -1084,9 +1209,9 @@ void i810TexSubImage( GLcontext *ctx, GLenum target,
}
}
-void i810TexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params )
+static void i810TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
{
i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
i810ContextPtr imesa = I810_CONTEXT( ctx );
@@ -1097,97 +1222,82 @@ void i810TexParameter( GLcontext *ctx, GLenum target,
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
+ if (t->bound) FLUSH_BATCH( imesa );
i810SetTexFilter(t,tObj->MinFilter,tObj->MagFilter);
break;
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
+ if (t->bound) FLUSH_BATCH( imesa );
i810SetTexWrapping(t,tObj->WrapS,tObj->WrapT);
break;
case GL_TEXTURE_BORDER_COLOR:
+ if (t->bound) FLUSH_BATCH( imesa );
i810SetTexBorderColor(t,tObj->BorderColor);
break;
default:
return;
}
+
imesa->new_state |= I810_NEW_TEXTURE;
}
-void i810BindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj )
+static void i810BindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
+
+ FLUSH_BATCH(imesa);
- if (target != GL_TEXTURE_2D)
- return;
+ if (imesa->CurrentTexObj[ctx->Texture.CurrentUnit]) {
+ imesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
+ imesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0;
+ }
imesa->new_state |= I810_NEW_TEXTURE;
}
-void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData;
i810ContextPtr imesa = I810_CONTEXT( ctx );
- i810DestroyTexObj(imesa,t);
- tObj->DriverData=0;
-}
-
-void i810UpdateTexturePalette( GLcontext *ctx, struct gl_texture_object *tObj )
-{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- i810TextureObjectPtr t;
- GLushort *dst;
- GLubyte *src;
- int i, size, next;
- GLenum format;
+ if (t) {
+ if (t->bound) {
+ FLUSH_BATCH(imesa);
+ imesa->CurrentTexObj[t->bound-1] = 0;
+ imesa->new_state |= I810_NEW_TEXTURE;
+ }
- return;
+ i810DestroyTexObj(imesa,t);
+ tObj->DriverData=0;
+ }
+}
- if (tObj)
- {
- i810Msg(8,"i810UpdateTexturePalette(): size %d\n", tObj->PaletteSize);
- t = (i810TextureObjectPtr) tObj->DriverData;;
- if (!t) return;
- size = tObj->PaletteSize;
- format = tObj->PaletteFormat;
- dst = t->Palette;
- src = (GLubyte *) tObj->Palette;
- }
- else
- {
- /* shared palette */
- imesa->GlobalPaletteUpdated = 1;
- size = ctx->Texture.PaletteSize;
- format = ctx->Texture.PaletteFormat;
- dst = imesa->GlobalPalette;
- src = (GLubyte *) ctx->Texture.Palette;
-
- i810Msg(8, "i810UpdateTexturePalette(): size %d intFormat %x format %x\n",
- size, ctx->Texture.PaletteIntFormat, ctx->Texture.PaletteFormat);
- }
+static GLboolean i810IsTextureResident( GLcontext *ctx,
+ struct gl_texture_object *t )
+{
+ i810TextureObjectPtr mt;
- if (size > 256) {
- i810Error("i810UpdateTexturePalette(): palette > 256 entries!\n");
- return;
- }
+/* LOCK_HARDWARE; */
+ mt = (i810TextureObjectPtr)t->DriverData;
+/* UNLOCK_HARDWARE; */
- switch (format)
- {
- case GL_RGB: next = 3; break;
- case GL_RGBA:next = 4; break;
- default :
- i810Error("i810UpdateTexturePalette(): unsupported palette format %x\n");
- next = 4;
- }
+ return mt && mt->MemBlock;
+}
- for (i=0; i < size; i++) {
- *dst = I810PACKCOLOR565(src[RCOMP],src[GCOMP],src[BCOMP]);
- dst++;
- src += next;
- }
+void i810DDInitTextureFuncs( GLcontext *ctx )
+{
+ ctx->Driver.TexEnv = i810TexEnv;
+ ctx->Driver.TexImage = i810TexImage;
+ ctx->Driver.TexSubImage = i810TexSubImage;
+ ctx->Driver.BindTexture = i810BindTexture;
+ ctx->Driver.DeleteTexture = i810DeleteTexture;
+ ctx->Driver.TexParameter = i810TexParameter;
+ ctx->Driver.UpdateTexturePalette = 0;
+ ctx->Driver.IsTextureResident = i810IsTextureResident;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.h b/xc/lib/GL/mesa/src/drv/i810/i810tex.h
index ed9875be8..5261d0b1b 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tex.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.h
@@ -26,16 +26,31 @@
#ifndef I810TEX_INC
#define I810TEX_INC
-#include "mesaglx/types.h"
+#include "types.h"
#include "mmath.h"
+#include "mm.h"
-#include "i810common.h"
-#include "i810buf.h"
+#include "i810context.h"
+#include "i810_3d_reg.h"
#define VALID_I810_TEXTURE_OBJECT(tobj) (tobj)
#define I810_TEX_MAXLEVELS 10
+
+
+/* For shared texture space managment, these texture objects may also
+ * be used as proxies for regions of texture memory containing other
+ * client's textures. Such proxy textures (not to be confused with GL
+ * proxy textures) are subject to the same LRU aging we use for our
+ * own private textures, and thus we have a mechanism where we can
+ * fairly decide between kicking out our own textures and those of
+ * other clients.
+ *
+ * Non-local texture objects have a valid MemBlock to describe the
+ * region managed by the other client, and can be identified by
+ * 't->globj == 0'
+ */
struct i810_texture_object_t {
struct i810_texture_object_t *next, *prev;
@@ -46,11 +61,11 @@ struct i810_texture_object_t {
int Height;
int texelBytes;
int totalSize;
+ int bound;
- PMemBlock MemBlock;
-
+ PMemBlock MemBlock;
char *BufAddr;
-
+
GLuint min_level;
GLuint max_level;
GLuint dirty_images;
@@ -64,13 +79,8 @@ struct i810_texture_object_t {
/* Support for multitexture.
*/
- GLuint current_unit;
-
+ GLuint current_unit;
GLuint Setup[I810_TEX_SETUP_SIZE];
- GLuint reg_dirty;
-
- GLushort Palette[256];
- int UsePalette;
};
#define I810_NO_PALETTE 0x0
@@ -80,38 +90,20 @@ struct i810_texture_object_t {
typedef struct i810_texture_object_t *i810TextureObjectPtr;
-i810TextureObjectPtr i810CreateTexObj(i810ContextPtr ctx,
- struct gl_texture_object *tObj);
-int i810DestroyTexObj(i810ContextPtr ctx, i810TextureObjectPtr t);
-void i810UpdateTextureState(GLcontext *ctx);
-
-
-/* Driver functions */
-
-void i810TexEnv( GLcontext *ctx, GLenum pname, const GLfloat *param );
-
-void i810TexImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint internalFormat,
- const struct gl_texture_image *image );
+void i810UpdateTextureState( GLcontext *ctx );
+void i810DDInitTextureFuncs( GLcontext *ctx );
-void i810TexSubImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLint internalFormat,
- const struct gl_texture_image *image );
+void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t);
+int i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t );
-void i810TexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params );
+void i810ResetGlobalLRU( i810ContextPtr imesa );
+void i810TexturesGone( i810ContextPtr imesa,
+ GLuint start, GLuint end,
+ GLuint in_use );
-void i810BindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj );
+void i810PrintLocalLRU( i810ContextPtr imesa );
+void i810PrintGlobalLRU( i810ContextPtr imesa );
-void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj );
-void i810UpdateTexturePalette( GLcontext *ctx, struct gl_texture_object *tObj );
-void i810UseGlobalTexturePalette( GLcontext *ctx, GLboolean state );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.c b/xc/lib/GL/mesa/src/drv/i810/i810tris.c
index 1c81b9549..d970e3a36 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tris.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <math.h>
+#include "types.h"
#include "vb.h"
#include "pipeline.h"
@@ -34,28 +35,9 @@
#include "i810tris.h"
#include "i810vb.h"
#include "i810log.h"
-#include "xsmesaP.h"
-
-
-static void i810_null_quad( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint v3, GLuint pv )
-{
-}
-
-static void i810_null_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
-}
-
-static void i810_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
-{
-}
-
-static void i810_null_points( GLcontext *ctx, GLuint first, GLuint last )
-{
-}
-
+/* Used in i810tritmp.h
+ */
#define I810_COLOR(to, from) { \
(to)[0] = (from)[2]; \
(to)[1] = (from)[1]; \
@@ -70,17 +52,6 @@ static quad_func quad_tab[0x20];
static line_func line_tab[0x20];
static points_func points_tab[0x20];
-void i810PrintRenderState( const char *msg, GLuint state )
-{
- fprintf(stderr, "%s: (%x) %s%s%s%s%s%s\n",
- msg, state,
- (state & I810_FLAT_BIT) ? "flat, " : "",
- (state & I810_OFFSET_BIT) ? "offset, " : "",
- (state & I810_TWOSIDE_BIT) ? "twoside, " : "",
- (state & I810_ANTIALIAS_BIT) ? "antialias, " : "",
- (state & I810_NODRAW_BIT) ? "no-draw, " : "",
- (state & I810_FALLBACK_BIT) ? "fallback" : "");
-}
#define IND (0)
#define TAG(x) x
@@ -90,33 +61,32 @@ void i810PrintRenderState( const char *msg, GLuint state )
#define TAG(x) x##_flat
#include "i810tritmp.h"
-#define IND (I810_OFFSET_BIT)
+#define IND (I810_OFFSET_BIT) /* wide */
#define TAG(x) x##_offset
#include "i810tritmp.h"
-#define IND (I810_OFFSET_BIT|I810_FLAT_BIT)
+#define IND (I810_OFFSET_BIT|I810_FLAT_BIT) /* wide|flat */
#define TAG(x) x##_offset_flat
#include "i810tritmp.h"
-#define IND (I810_TWOSIDE_BIT)
+#define IND (I810_TWOSIDE_BIT) /* stipple */
#define TAG(x) x##_twoside
#include "i810tritmp.h"
-#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT)
+#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT) /* stipple|flat */
#define TAG(x) x##_twoside_flat
#include "i810tritmp.h"
-#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT)
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT) /* stipple|wide */
#define TAG(x) x##_twoside_offset
#include "i810tritmp.h"
-#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT)
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT) /* stip|wide|flat*/
#define TAG(x) x##_twoside_offset_flat
#include "i810tritmp.h"
void i810DDTrifuncInit()
{
- int i;
init();
init_flat();
init_offset();
@@ -125,113 +95,9 @@ void i810DDTrifuncInit()
init_twoside_flat();
init_twoside_offset();
init_twoside_offset_flat();
-
- /* Hmmm...
- */
- for (i = 0 ; i < 0x20 ; i++) {
- if (i & ~I810_FLAT_BIT) {
- points_tab[i] = points_tab[i&I810_FLAT_BIT];
- line_tab[i] = line_tab[i&I810_FLAT_BIT];
- }
- }
-
- for (i = 0 ; i < 0x20 ; i++)
- if ((i & (I810_NODRAW_BIT|I810_FALLBACK_BIT)) == I810_NODRAW_BIT ||
- i810glx.nullprims)
- {
- quad_tab[i] = i810_null_quad;
- tri_tab[i] = i810_null_triangle;
- line_tab[i] = i810_null_line;
- points_tab[i] = i810_null_points;
- }
-
- if (i810glx.noFallback) {
- for (i = 0 ; i < 0x10 ; i++) {
- points_tab[i|I810_FALLBACK_BIT] = points_tab[i];
- line_tab[i|I810_FALLBACK_BIT] = line_tab[i];
- tri_tab[i|I810_FALLBACK_BIT] = tri_tab[i];
- quad_tab[i|I810_FALLBACK_BIT] = quad_tab[i];
- }
- }
-
}
-/* Everything is done via single triangle instructiopns at the moment;
- * this can change fairly easily.
- */
-#if I810_USE_BATCH
-
-GLuint *i810AllocPrimitiveVerts( int dwords )
-{
- GLuint orig_dwords = dwords;
-
- dwords+=2;
- dwords&=~1;
-
- while (1) {
- if (i810glx.dma_buffer->space < dwords * 4)
- {
- if (I810_DEBUG & DEBUG_VERBOSE_RING)
- fprintf(stderr, "i810AllocPrimitiveVerts: dma buffer overflow\n");
- i810DmaOverflow( dwords );
- }
- else
- {
- GLuint start = i810glx.dma_buffer->head;
- i810glx.dma_buffer->head += dwords * 4;
- i810glx.dma_buffer->space -= dwords * 4;
-
- if ((orig_dwords & 1) == 0) {
- *(GLuint *)(i810glx.dma_buffer->virtual_start + start ) = 0;
- start += 4;
- }
-
- *(GLuint *)(i810glx.dma_buffer->virtual_start + start ) =
- GFX_OP_PRIMITIVE | PR_TRIANGLES | (orig_dwords-1);
-
- return (GLuint *)(i810glx.dma_buffer->virtual_start + start + 4);
- }
- }
-}
-
-#else
-GLuint *i810AllocPrimitiveVerts( int dwords )
-{
- GLuint orig_dwords = dwords;
-
- dwords+=2;
- dwords&=~1;
-
- while (1)
- {
- BEGIN_LP_RING( dwords );
-
- if (outring + dwords * 4 != ((outring + dwords * 4) & ringmask))
- {
- int i;
-
- if (I810_DEBUG & DEBUG_VERBOSE_RING)
- fprintf(stderr, "\n\nwrap case in i810AllocPrimitiveVerts\n\n");
-
- for (i = 0 ; i < dwords ; i++)
- OUT_RING( 0 );
- ADVANCE_LP_RING();
- }
- else
- {
- I810LpRing.tail = outring + dwords * 4;
-
- if ((orig_dwords & 1) == 0)
- OUT_RING(0);
-
- OUT_RING( GFX_OP_PRIMITIVE | PR_TRIANGLES | (orig_dwords-1) );
- return (GLuint *)(virt + outring);
- }
- }
-}
-#endif
-
void i810DDChooseRenderState( GLcontext *ctx )
@@ -239,50 +105,41 @@ void i810DDChooseRenderState( GLcontext *ctx )
i810ContextPtr imesa = I810_CONTEXT( ctx );
GLuint flags = ctx->TriangleCaps;
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+ imesa->IndirectTriangles = 0;
if (flags) {
GLuint ind = 0;
GLuint shared = 0;
- GLuint setup = imesa->setupindex;
- GLuint fallback = I810_FALLBACK_BIT;
-
- if (i810glx.noFallback) fallback = 0;
- if ((flags & DD_FLATSHADE) && (setup & I810_RGBA_BIT)) shared |= I810_FLAT_BIT;
- if (flags & DD_MULTIDRAW) shared |= fallback;
+ if (flags & DD_FLATSHADE) shared |= I810_FLAT_BIT;
+ if (flags & DD_MULTIDRAW) shared |= I810_FALLBACK_BIT;
if (flags & DD_SELECT) shared |= I810_FALLBACK_BIT;
if (flags & DD_FEEDBACK) shared |= I810_FALLBACK_BIT;
- ind = shared;
- if (flags & DD_POINT_SMOOTH) ind |= I810_ANTIALIAS_BIT;
- if (flags & DD_POINT_ATTEN) ind |= fallback;
-
- imesa->renderindex = ind;
- imesa->PointsFunc = points_tab[ind];
- if (ind & I810_FALLBACK_BIT)
- ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+ imesa->renderindex = shared;
+ imesa->PointsFunc = points_tab[shared];
ind = shared;
- if (flags & DD_LINE_SMOOTH) ind |= I810_ANTIALIAS_BIT;
- if (flags & DD_LINE_STIPPLE) ind |= fallback;
+ if (flags & DD_LINE_WIDTH) ind |= I810_WIDE_LINE_BIT;
+ if (flags & DD_LINE_STIPPLE) ind |= I810_FALLBACK_BIT;
imesa->renderindex |= ind;
imesa->LineFunc = line_tab[ind];
if (ind & I810_FALLBACK_BIT)
- ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+ imesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
ind = shared;
- if (flags & DD_TRI_SMOOTH) ind |= I810_ANTIALIAS_BIT;
if (flags & DD_TRI_OFFSET) ind |= I810_OFFSET_BIT;
if (flags & DD_TRI_LIGHT_TWOSIDE) ind |= I810_TWOSIDE_BIT;
- if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE)) ind |= fallback;
+ if (flags & DD_TRI_UNFILLED) ind |= I810_FALLBACK_BIT;
+ if ((flags & DD_TRI_STIPPLE) &&
+ (ctx->IndirectTriangles & DD_TRI_STIPPLE)) ind |= I810_FALLBACK_BIT;
imesa->renderindex |= ind;
imesa->TriangleFunc = tri_tab[ind];
imesa->QuadFunc = quad_tab[ind];
if (ind & I810_FALLBACK_BIT)
- ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE);
+ imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE);
}
else if (imesa->renderindex)
{
@@ -293,9 +150,9 @@ void i810DDChooseRenderState( GLcontext *ctx )
imesa->QuadFunc = quad_tab[0];
}
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
+
+ if (I810_DEBUG&DEBUG_VERBOSE_API) {
gl_print_tri_caps("tricaps", ctx->TriangleCaps);
- i810PrintRenderState("i810: Render state", imesa->renderindex);
}
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.h b/xc/lib/GL/mesa/src/drv/i810/i810tris.h
index 12e0ec7fd..5b73b7676 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tris.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.h
@@ -23,107 +23,76 @@
*
*/
-#ifndef I810TIS_INC
-#define I810TIS_INC
+#ifndef I810TRIS_INC
+#define I810TRIS_INC
-#include "mesaglx/types.h"
+#include "types.h"
+#include "i810dma.h"
+#include "i810ioctl.h"
+extern void i810PrintRenderState( const char *msg, GLuint state );
extern void i810DDChooseRenderState(GLcontext *ctx);
-extern void i810DDTrifuncInit();
+extern void i810DDTrifuncInit( void );
-/* extern void i810FinishPrimitive( void ); */
-extern void i810NaughtyFinishPrimitive( void );
-extern GLuint *i810AllocPrimitiveVerts( int dwords );
+/* shared */
+#define I810_FLAT_BIT 0x1
+/* triangle */
+#define I810_OFFSET_BIT 0x2
+#define I810_TWOSIDE_BIT 0x4
-/* Todo:
- * - multidraw, ...
- * - Antialiasing (?)
- * - line and polygon stipple
- * - select and feedback
- * - stencil
- * - point parameters
- * -
- */
-#define I810_ANTIALIAS_BIT 0 /* ignored for now, no fallback */
-#define I810_FLAT_BIT 0x1
-#define I810_OFFSET_BIT 0x2 /* 3.1 only */
-#define I810_TWOSIDE_BIT 0x4 /* 3.1 only */
-#define I810_NODRAW_BIT 0x8
-#define I810_FALLBACK_BIT 0x10
-
-/* Not in use:
- */
-#define I810_FEEDBACK_BIT 0x20
-#define I810_SELECT_BIT 0x40
-#define I810_POINT_PARAM_BIT 0x80 /* not needed? */
+/* line */
+#define I810_WIDE_LINE_BIT 0x2
+#define I810_STIPPLE_LINE_BIT 0x4
+/* shared */
+#define I810_FALLBACK_BIT 0x8
-static inline void i810_draw_triangle( i810_vertex *v0,
- i810_vertex *v1,
- i810_vertex *v2 )
-{
-#if 0
- fprintf(stderr, "i810_draw_triangle( %p, %p, %p )\n", v0, v1, v2);
-#endif
+static i810_vertex __inline__ *i810AllocTriangles( i810ContextPtr imesa, int nr)
+{
+ GLuint *start = i810AllocDwords( imesa, 30*nr+1 );
+ *start++ = GFX_OP_PRIMITIVE | PR_TRIANGLES | (30*nr-1);
+ return (i810_vertex *)start;
+}
-#if 0
-#define WID 640
-#define HI 480
- {
- GLuint print = 1, draw = 1;
- GLfloat area = ((v0->x - v2->x) * (v1->y - v2->y) -
- (v0->y - v2->y) * (v1->x - v2->x));
-
- if (v0->x < -.501 || v0->x > WID || v0->y < -.501 || v0->y > HI ||
- v1->x < -.501 || v1->x > WID || v1->y < -.501 || v1->y > HI ||
- v2->x < -.501 || v2->x > WID || v2->y < -.501 || v2->y > HI) {
- fprintf(stderr, "not clipped\n");
- print = 1;
- }
-
- if (area == 0 && ((v0 == v1) || (v1 == v2))) {
- fprintf(stderr, "zero area %p %p %p\n", v0, v1, v2);
- draw = 0;
- }
-
- if (print) {
- fprintf(stderr," v0: %f %f %f %f tex: %f %f\n",
- v0->x, v0->y, v0->z, v0->oow, v0->tu0, v0->tv0);
- fprintf(stderr," v1: %f %f %f %f tex: %f %f\n",
- v1->x, v1->y, v1->z, v1->oow, v1->tu0, v1->tv0);
- fprintf(stderr," v2: %f %f %f %f tex: %f %f\n",
- v2->x, v2->y, v2->z, v2->oow, v2->tu0, v2->tv0);
- return;
- }
-
- if (!draw) return;
- }
-#endif
+static i810_vertex __inline__ *i810AllocLine( i810ContextPtr imesa )
+{
+ GLuint *start = i810AllocDwords( imesa, 21 );
+ *start++ = GFX_OP_PRIMITIVE | PR_LINESTRIP | (20-1);
+ return (i810_vertex *)start;
+}
- {
- i810_vertex *wv = (i810_vertex *)i810AllocPrimitiveVerts( 3 * 10 );
- wv[0] = *v0;
- wv[1] = *v1;
- wv[2] = *v2;
- FINISH_PRIM();
- }
+static i810_vertex __inline__ *i810AllocRect( i810ContextPtr imesa )
+{
+ GLuint *start = i810AllocDwords( imesa, 31 );
+ *start++ = GFX_OP_PRIMITIVE | PR_RECTS | (30-1);
+ return (i810_vertex *)start;
}
+static void __inline__ i810_draw_triangle( i810ContextPtr imesa,
+ i810_vertex *v0,
+ i810_vertex *v1,
+ i810_vertex *v2 )
+{
+ i810_vertex *wv = i810AllocTriangles( imesa, 1 );
+ wv[0] = *v0;
+ wv[1] = *v1;
+ wv[2] = *v2;
+ FINISH_PRIM();
+}
-/* These can go soon, but for the meantime we're using triangles for
- * everything.
- */
-static inline void i810_draw_point( i810_vertex *tmp, float sz )
+
+static __inline__ void i810_draw_point( i810ContextPtr imesa,
+ i810_vertex *tmp, float sz )
{
- i810_vertex *wv = (i810_vertex *)i810AllocPrimitiveVerts(6*10);
+ i810_vertex *wv = i810AllocTriangles( imesa, 2 );
wv[0] = *tmp;
wv[0].x = tmp->x - sz;
@@ -153,11 +122,23 @@ static inline void i810_draw_point( i810_vertex *tmp, float sz )
}
-static inline void i810_draw_line( i810_vertex *tmp0,
- i810_vertex *tmp1,
- float width )
+static __inline__ void i810_draw_line_line( i810ContextPtr imesa,
+ i810_vertex *tmp0,
+ i810_vertex *tmp1 )
+{
+ i810_vertex *wv = i810AllocLine( imesa );
+ wv[0] = *tmp0;
+ wv[1] = *tmp1;
+ FINISH_PRIM();
+}
+
+static __inline__ void i810_draw_tri_line( i810ContextPtr imesa,
+ i810_vertex *tmp0,
+ i810_vertex *tmp1,
+ float width )
{
- i810_vertex *wv = (i810_vertex *)i810AllocPrimitiveVerts( 6 * 10 );
+ i810_vertex *wv = i810AllocTriangles( imesa, 2 );
+
float dx, dy, ix, iy;
dx = tmp0->x - tmp1->x;
@@ -168,15 +149,6 @@ static inline void i810_draw_line( i810_vertex *tmp0,
iy = ix; ix = 0;
}
-#if 0
- fprintf(stderr,"tmp0: %f %f %f %f col: %x tex: %f %f\n",
- tmp0->x, tmp0->y, tmp0->z, tmp0->oow, *(GLuint*)&tmp0->color, tmp0->tu0, tmp0->tv0);
- fprintf(stderr,"tmp1: %f %f %f %f col: %x tex: %f %f\n",
- tmp1->x, tmp1->y, tmp1->z, tmp1->oow, *(GLuint*)&tmp1->color, tmp1->tu0, tmp1->tv0);
- fprintf(stderr, "ix: %f, iy: %f\n", ix, iy);
-#endif
-
-
wv[0] = *tmp0;
wv[0].x = tmp0->x - ix;
wv[0].y = tmp0->y - iy;
@@ -200,8 +172,16 @@ static inline void i810_draw_line( i810_vertex *tmp0,
wv[5] = *tmp1;
wv[5].x = tmp1->x + ix;
wv[5].y = tmp1->y + iy;
-
FINISH_PRIM();
}
+
+static __inline__ void i810_draw_line( i810ContextPtr imesa,
+ i810_vertex *tmp0,
+ i810_vertex *tmp1,
+ float width )
+{
+ i810_draw_line_line( imesa, tmp0, tmp1 );
+}
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h b/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h
index c8ec01d49..ebe1ef5ea 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h
@@ -1,19 +1,20 @@
-static inline void TAG(triangle)( GLcontext *ctx, GLuint e0,
- GLuint e1, GLuint e2, GLuint pv )
+static __inline__ void TAG(triangle)( GLcontext *ctx, GLuint e0,
+ GLuint e1, GLuint e2, GLuint pv )
{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
struct vertex_buffer *VB = ctx->VB;
i810VertexPtr i810VB = I810_DRIVER_DATA(VB)->verts;
- const i810_vertex *v0 = &i810VB[e0].v.v;
- const i810_vertex *v1 = &i810VB[e1].v.v;
- const i810_vertex *v2 = &i810VB[e2].v.v;
+ const i810_vertex *v0 = &i810VB[e0].v;
+ const i810_vertex *v1 = &i810VB[e1].v;
+ const i810_vertex *v2 = &i810VB[e2].v;
#if (IND & I810_OFFSET_BIT)
GLfloat offset = ctx->Polygon.OffsetUnits * 1.0/0x10000;
#endif
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
- int c0 = *(int *)&i810VB[pv].v.v.color;
+ int c0 = *(int *)&i810VB[pv].v.color;
int c1 = c0;
int c2 = c0;
#endif
@@ -64,78 +65,39 @@ static inline void TAG(triangle)( GLcontext *ctx, GLuint e0,
i810glx.c_triangles++;
-#if 0
-#define WID 512
-#define HI 384
- {
- GLuint print = 0, draw = 1;
- GLfloat area = ((v0->x - v2->x) * (v1->y - v2->y) -
- (v0->y - v2->y) * (v1->x - v2->x));
-
- if (v0->x < -.501 || v0->x > WID || v0->y < -.501 || v0->y > HI ||
- v1->x < -.501 || v1->x > WID || v1->y < -.501 || v1->y > HI ||
- v2->x < -.501 || v2->x > WID || v2->y < -.501 || v2->y > HI) {
- fprintf(stderr, "not clipped\n");
- print = 1;
- }
-
- if (area == 0 && ((v0 == v1) || (v1 == v2))) {
- fprintf(stderr, "zero area %p %p %p\n", v0, v1, v2);
- draw = 0;
- }
-
- if (print) {
- fprintf(stderr,"v0: %f %f %f %f col: %x tex: %f %f\n",
- v0->x, v0->y, v0->z, v0->oow,
- *(GLuint*)&v0->color, v0->tu0, v0->tv0);
- fprintf(stderr,"v1: %f %f %f %f col: %x tex: %f %f\n",
- v1->x, v1->y, v1->z, v1->oow,
- *(GLuint*)&v1->color, v1->tu0, v1->tv0);
- fprintf(stderr,"v2: %f %f %f %f col: %x tex: %f %f\n",
- v2->x, v2->y, v2->z, v2->oow,
- *(GLuint*)&v2->color, v2->tu0, v2->tv0);
-/* return; */
- }
-
- if (!draw) return;
- }
-#endif
- BEGIN_CLIP_LOOP()
- {
- i810_vertex *wv = (i810_vertex *)i810AllocPrimitiveVerts( 3 * 10 );
- wv[0] = *v0;
+ {
+ i810_vertex *wv = i810AllocTriangles( imesa, 1 );
+ wv[0] = *v0;
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
- *((int *)(&wv[0].color)) = c0;
+ *((int *)(&wv[0].color)) = c0;
#endif
#if (IND & I810_OFFSET_BIT)
- wv[0].z = v0->z + offset;
+ wv[0].z = v0->z + offset;
#endif
- wv[1] = *v1;
+ wv[1] = *v1;
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
- *((int *)(&wv[1].color)) = c1;
+ *((int *)(&wv[1].color)) = c1;
#endif
#if (IND & I810_OFFSET_BIT)
- wv[1].z = v1->z + offset;
+ wv[1].z = v1->z + offset;
#endif
- wv[2] = *v2;
+ wv[2] = *v2;
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
- *((int *)(&wv[2].color)) = c2;
+ *((int *)(&wv[2].color)) = c2;
#endif
#if (IND & I810_OFFSET_BIT)
- wv[2].z = v2->z + offset;
+ wv[2].z = v2->z + offset;
#endif
- FINISH_PRIM();
- }
- END_CLIP_LOOP();
+ FINISH_PRIM();
+ }
}
-
static void TAG(quad)( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint v3,
GLuint pv )
@@ -144,60 +106,66 @@ static void TAG(quad)( GLcontext *ctx, GLuint v0,
TAG(triangle)( ctx, v1, v2, v3, pv );
}
-
-#if ((IND & ~I810_FLAT_BIT) == 0)
-
static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
i810VertexPtr i810VB = I810_DRIVER_DATA(ctx->VB)->verts;
- i810_vertex tmp0 = i810VB[v0].v.v;
- i810_vertex tmp1 = i810VB[v1].v.v;
- float width = ctx->Line.Width;
+ int tmp0, tmp1;
+ (void) tmp0; (void) tmp1;
+
if (IND & I810_FLAT_BIT) {
- *(int *)&tmp1.color = *(int *)&tmp0.color =
- *(int *)&i810VB[pv].v.v.color;
- }
+ tmp0 = *(int *)&i810VB[v0].v.color;
+ tmp1 = *(int *)&i810VB[v1].v.color;
+ i810VB[v0].v.color = i810VB[pv].v.color;
+ i810VB[v1].v.color = i810VB[pv].v.color;
+ }
- BEGIN_CLIP_LOOP()
- i810_draw_line( &tmp0, &tmp1, width );
- END_CLIP_LOOP();
+ if (IND & I810_WIDE_LINE_BIT)
+ {
+ i810_draw_tri_line( imesa, &i810VB[v0].v, &i810VB[v1].v,
+ ctx->Line.Width );
+ }
+ else
+ {
+ i810_draw_line_line( imesa, &i810VB[v0].v, &i810VB[v1].v );
+ }
+
+ if (IND & I810_FLAT_BIT) {
+ *(int *)&i810VB[v0].v.color = tmp0;
+ *(int *)&i810VB[v1].v.color = tmp1;
+ }
}
static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
{
- int i;
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
struct vertex_buffer *VB = ctx->VB;
i810VertexPtr i810VB = I810_DRIVER_DATA(VB)->verts;
GLfloat sz = ctx->Point.Size * .5;
+ int i;
/* Culling is disabled automatically via. the
* ctx->Driver.ReducedPrimitiveChange() callback.
*/
-
+
for(i=first;i<=last;i++) {
if(VB->ClipMask[i]==0) {
- i810_vertex *tmp = &i810VB[i].v.v;
- BEGIN_CLIP_LOOP()
- i810_draw_point( tmp, sz );
- END_CLIP_LOOP();
+ i810_vertex *tmp = &i810VB[i].v;
+ i810_draw_point( imesa, tmp, sz );
}
}
}
-#endif
-static void TAG(init)()
+static void TAG(init)( void )
{
tri_tab[IND] = TAG(triangle);
quad_tab[IND] = TAG(quad);
-
-#if ((IND & ~I810_FLAT_BIT) == 0)
line_tab[IND] = TAG(line);
points_tab[IND] = TAG(points);
-#endif
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810vb.c b/xc/lib/GL/mesa/src/drv/i810/i810vb.c
index b41ad0960..6ba7eb9a5 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810vb.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810vb.c
@@ -28,46 +28,43 @@
#include "i810vb.h"
#include "i810log.h"
#include "i810dma.h"
-#include "xsmesaP.h"
-#include "xsmesa.h"
#include "stages.h"
-#include "os.h"
#include <stdio.h>
#include <stdlib.h>
#define TEX0 { \
- v->v.v.tu0 = tc0[i][0]; \
- v->v.v.tv0 = tc0[i][1]; \
+ v->v.tu0 = tc0[i][0]; \
+ v->v.tv0 = tc0[i][1]; \
}
#define TEX1 { \
- v->v.v.tu1 = tc1[i][0]; \
- v->v.v.tv1 = tc1[i][1]; \
+ v->v.tu1 = tc1[i][0]; \
+ v->v.tv1 = tc1[i][1]; \
}
/* Doesn't seem to work very well (golly).
*/
#define SPC { \
GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.v.specular.red = spec[0]; \
- v->v.v.specular.green = spec[1]; \
- v->v.v.specular.blue = spec[2]; \
+ v->v.specular.red = spec[0]; \
+ v->v.specular.green = spec[1]; \
+ v->v.specular.blue = spec[2]; \
}
#define FOG { \
GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.v.specular.alpha = spec[3]; \
+ v->v.specular.alpha = spec[3]; \
}
#define COL { \
GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->v.v.color.blue = col[2]; \
- v->v.v.color.green = col[1]; \
- v->v.v.color.red = col[0]; \
- v->v.v.color.alpha = col[3]; \
+ v->v.color.blue = col[2]; \
+ v->v.color.green = col[1]; \
+ v->v.color.red = col[0]; \
+ v->v.color.alpha = col[3]; \
}
/* The vertex formats we have don't seem to support projective texturing
@@ -82,19 +79,19 @@
imesa->setupdone &= ~I810_WIN_BIT; \
for (i=start; i < end; i++, v++) { \
float oow = 1.0 / tc[i][3]; \
- v->v.v.oow *= tc[i][3]; \
- v->v.v.tu0 *= oow; \
- v->v.v.tv0 *= oow; \
+ v->v.oow *= tc[i][3]; \
+ v->v.tu0 *= oow; \
+ v->v.tv0 *= oow; \
} \
}
#define COORD \
GLfloat *win = VB->Win.data[i]; \
- v->v.v.x = win[0]; \
- v->v.v.y = i810height - win[1]; \
- v->v.v.z = (1.0/0x10000) * win[2]; \
- v->v.v.oow = win[3];
+ v->v.x = win[0]; \
+ v->v.y = i810height - win[1]; \
+ v->v.z = (1.0/0x10000) * win[2]; \
+ v->v.oow = win[3];
@@ -104,15 +101,15 @@
#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,spec,fog) \
static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
{ \
- i810ContextPtr imesa = I810_CONTEXT( ctx ); \
+ i810ContextPtr imesa = I810_CONTEXT( VB->ctx ); \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
i810VertexPtr v; \
GLfloat (*tc0)[4]; \
GLfloat (*tc1)[4]; \
- GLfloat i810height = i810DB->Height; \
+ GLfloat i810height = dPriv->h; \
int i; \
- (void) i810height; \
+ (void) i810height; (void) imesa; \
\
- CHECK_CONTEXT( return; ); \
\
gl_import_client_data( VB, VB->ctx->RenderFlags, \
(VB->ClipOrMask \
@@ -143,7 +140,7 @@ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
tex1; \
} \
col; \
- } \
+ } \
tex0_4; \
}
@@ -155,11 +152,13 @@ SETUPFUNC(rs_wt0t1, COORD,NOP,TEX0,TEX1,TEX0_4,NOP,NOP)
SETUPFUNC(rs_wft0, COORD,NOP,TEX0,NOP,TEX0_4,NOP,FOG)
SETUPFUNC(rs_wft0t1, COORD,NOP,TEX0,TEX1,TEX0_4,NOP,FOG)
SETUPFUNC(rs_wg, COORD,COL,NOP,NOP,NOP,NOP,NOP)
+SETUPFUNC(rs_wgs, COORD,COL,NOP,NOP,NOP,SPC,NOP)
SETUPFUNC(rs_wgt0, COORD,COL,TEX0,NOP,TEX0_4,NOP,NOP)
SETUPFUNC(rs_wgt0t1, COORD,COL,TEX0,TEX1,TEX0_4,NOP,NOP)
SETUPFUNC(rs_wgst0, COORD,COL,TEX0,NOP,TEX0_4,SPC,NOP)
SETUPFUNC(rs_wgst0t1, COORD,COL,TEX0,TEX1,TEX0_4,SPC,NOP)
SETUPFUNC(rs_wgf, COORD,COL,NOP,NOP,NOP,NOP,FOG)
+SETUPFUNC(rs_wgfs, COORD,COL,NOP,NOP,NOP,SPC,FOG)
SETUPFUNC(rs_wgft0, COORD,COL,TEX0,NOP,TEX0_4,NOP,FOG)
SETUPFUNC(rs_wgft0t1, COORD,COL,TEX0,TEX1,TEX0_4,NOP,FOG)
SETUPFUNC(rs_wgfst0, COORD,COL,TEX0,NOP,TEX0_4,SPC,FOG)
@@ -171,11 +170,13 @@ SETUPFUNC(rs_f, NOP,NOP,NOP,NOP,NOP,NOP,FOG)
SETUPFUNC(rs_ft0, NOP,NOP,TEX0,NOP,TEX0_4,NOP,FOG)
SETUPFUNC(rs_ft0t1, NOP,NOP,TEX0,TEX1,TEX0_4,NOP,FOG)
SETUPFUNC(rs_g, NOP,COL,NOP,NOP,NOP,NOP,NOP)
+SETUPFUNC(rs_gs, NOP,COL,NOP,NOP,NOP,SPC,NOP)
SETUPFUNC(rs_gt0, NOP,COL,TEX0,NOP,TEX0_4,NOP,NOP)
SETUPFUNC(rs_gt0t1, NOP,COL,TEX0,TEX1,TEX0_4,NOP,NOP)
SETUPFUNC(rs_gst0, NOP,COL,TEX0,NOP,TEX0_4,SPC,NOP)
SETUPFUNC(rs_gst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,NOP)
SETUPFUNC(rs_gf, NOP,COL,NOP,NOP,NOP,NOP,FOG)
+SETUPFUNC(rs_gfs, NOP,COL,NOP,NOP,NOP,SPC,FOG)
SETUPFUNC(rs_gft0, NOP,COL,TEX0,NOP,TEX0_4,NOP,FOG)
SETUPFUNC(rs_gft0t1, NOP,COL,TEX0,TEX1,TEX0_4,NOP,FOG)
SETUPFUNC(rs_gfst0, NOP,COL,TEX0,NOP,TEX0_4,SPC,FOG)
@@ -206,11 +207,13 @@ void i810DDSetupInit( void )
setup_func[I810_WIN_BIT|I810_FOG_BIT|I810_TEX0_BIT] = rs_wft0;
setup_func[I810_WIN_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wft0t1;
setup_func[I810_WIN_BIT|I810_RGBA_BIT] = rs_wg;
+ setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_SPEC_BIT] = rs_wgs;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_TEX0_BIT] = rs_wgt0;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgt0t1;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_wgst0;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgst0t1;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT] = rs_wgf;
+ setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT] = rs_wgfs;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT] = rs_wgft0;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgft0t1;
setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_wgfst0;
@@ -223,11 +226,13 @@ void i810DDSetupInit( void )
setup_func[I810_FOG_BIT|I810_TEX0_BIT] = rs_ft0;
setup_func[I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_ft0t1;
setup_func[I810_RGBA_BIT] = rs_g;
+ setup_func[I810_RGBA_BIT|I810_SPEC_BIT] = rs_gs;
setup_func[I810_RGBA_BIT|I810_TEX0_BIT] = rs_gt0;
setup_func[I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gt0t1;
setup_func[I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_gst0;
setup_func[I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gst0t1;
setup_func[I810_RGBA_BIT|I810_FOG_BIT] = rs_gf;
+ setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT] = rs_gfs;
setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT] = rs_gft0;
setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gft0t1;
setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_gfst0;
@@ -240,7 +245,7 @@ void i810PrintSetupFlags(char *msg, GLuint flags )
{
fprintf(stderr, "%s: %d %s%s%s%s%s%s%s\n",
msg,
- flags,
+ (int)flags,
(flags & I810_WIN_BIT) ? " xyzw," : "",
(flags & I810_RGBA_BIT) ? " rgba," : "",
(flags & I810_SPEC_BIT) ? " spec," : "",
@@ -274,7 +279,7 @@ void i810ChooseRasterSetupFunc(GLcontext *ctx)
if (ctx->FogMode == FOG_FRAGMENT)
funcindex |= I810_FOG_BIT;
- if (MESA_VERBOSE || I810_DEBUG)
+ if (MESA_VERBOSE)
i810PrintSetupFlags("xsmesa: full setup function", funcindex);
imesa->setupindex = funcindex;
@@ -312,6 +317,7 @@ void i810DDCheckPartialRasterSetup( GLcontext *ctx,
*/
void i810DDPartialRasterSetup( struct vertex_buffer *VB )
{
+ i810ContextPtr imesa = I810_CONTEXT( VB->ctx );
GLuint new = VB->pipeline->new_outputs;
GLuint available = VB->pipeline->outputs;
GLuint ind = 0;
@@ -337,7 +343,7 @@ void i810DDPartialRasterSetup( struct vertex_buffer *VB )
ind &= imesa->setupindex;
imesa->setupdone |= ind;
- i810PrintSetupFlags("xsmesa: partial setup function", ind);
+ if (0) i810PrintSetupFlags("xsmesa: partial setup function", ind);
if (ind)
setup_func[ind&~I810_ALPHA_BIT]( VB, VB->Start, VB->Count );
@@ -366,28 +372,37 @@ void i810DDResizeVB( struct vertex_buffer *VB, GLuint size )
free( mvb->vert_store );
mvb->vert_store = malloc( sizeof(i810Vertex) * mvb->size + 31);
- if (!mvb->vert_store)
- FatalError("i810-glx: out of memory !\n");
+ if (!mvb->vert_store) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
mvb->verts = (i810VertexPtr)(((unsigned long)mvb->vert_store + 31) & ~31);
gl_vector1ui_free( &mvb->clipped_elements );
gl_vector1ui_alloc( &mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32 );
- if (!mvb->clipped_elements.start)
- FatalError("i810-glx: out of memory !\n");
+ if (!mvb->clipped_elements.start) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
free( VB->ClipMask );
VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
- if (!VB->ClipMask)
- FatalError("i810-glx: out of memory !\n");
+ if (!VB->ClipMask) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
+
if (VB->Type == VB_IMMEDIATE) {
free( mvb->primitive );
free( mvb->next_primitive );
mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
- if (!mvb->primitive || !mvb->next_primitive)
- FatalError("i810-glx: out of memory!");
+ if (!mvb->primitive || !mvb->next_primitive) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
}
}
@@ -398,31 +413,35 @@ void i810DDRegisterVB( struct vertex_buffer *VB )
mvb = (i810VertexBufferPtr)calloc( 1, sizeof(*mvb) );
- /* This looks like it allocates a lot of memory, but it basically
- * just sets an upper limit on how much can be used - nothing like
- * this amount will ever be turned into 'real' memory.
- */
- mvb->size = VB->Size * 5;
+ mvb->size = VB->Size * 2;
mvb->vert_store = malloc( sizeof(i810Vertex) * mvb->size + 31);
- if (!mvb->vert_store)
- FatalError("i810-glx: out of memory !\n");
+ if (!mvb->vert_store) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
mvb->verts = (i810VertexPtr)(((unsigned long)mvb->vert_store + 31) & ~31);
gl_vector1ui_alloc( &mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32 );
- if (!mvb->clipped_elements.start)
- FatalError("i810-glx: out of memory !\n");
-
+ if (!mvb->clipped_elements.start) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
+
free( VB->ClipMask );
VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
- if (!VB->ClipMask)
- FatalError("i810-glx: out of memory !\n");
+ if (!VB->ClipMask) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
- if (!mvb->primitive || !mvb->next_primitive)
- FatalError("i810-glx: out of memory!");
-
+ if (!mvb->primitive || !mvb->next_primitive) {
+ fprintf(stderr, "i810-glx: out of memory !\n");
+ exit(1);
+ }
+
VB->driver_data = mvb;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810vb.h b/xc/lib/GL/mesa/src/drv/i810/i810vb.h
index 640afa678..23685f106 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810vb.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810vb.h
@@ -26,7 +26,8 @@
#ifndef I810VB_INC
#define I810VB_INC
-#include "mesaglx/vb.h"
+#include "vb.h"
+#include "types.h"
/*
* color type for the vertex data
@@ -56,15 +57,13 @@ typedef struct {
/* Unfortunately only have assembly for 16-stride vertices.
*/
-struct i810_vertex_t {
- union {
- i810_vertex v;
- float f[16];
- } v;
+union i810_vertex_t {
+ i810_vertex v;
+ float f[16];
};
-typedef struct i810_vertex_t i810Vertex;
-typedef struct i810_vertex_t *i810VertexPtr;
+typedef union i810_vertex_t i810Vertex;
+typedef union i810_vertex_t *i810VertexPtr;
struct i810_vertex_buffer_t {
GLvector1ui clipped_elements;
@@ -79,7 +78,7 @@ struct i810_vertex_buffer_t {
typedef struct i810_vertex_buffer_t *i810VertexBufferPtr;
-#define I810_CONTEXT(ctx) ((i810ContextPtr)(((XSMesaContext)(ctx)->DriverCtx)->hw_ctx))
+#define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
#define I810_DRIVER_DATA(vb) ((i810VertexBufferPtr)((vb)->driver_data))
@@ -97,7 +96,7 @@ extern void i810PrintSetupFlags(char *msg, GLuint flags );
extern void i810DDDoRasterSetup( struct vertex_buffer *VB );
extern void i810DDPartialRasterSetup( struct vertex_buffer *VB );
extern void i810DDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d );
+ struct gl_pipeline_stage *d );
extern void i810DDViewport( GLcontext *ctx,
GLint x, GLint y,
diff --git a/xc/lib/GL/mesa/src/drv/mga/Imakefile b/xc/lib/GL/mesa/src/drv/mga/Imakefile
index e4e39b747..1ca3bde8a 100644
--- a/xc/lib/GL/mesa/src/drv/mga/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/mga/Imakefile
@@ -1,4 +1,6 @@
+#include <Threads.tmpl>
+
#define DoNormalLib NormalLibGlx
#define DoSharedLib SharedLibGlx
#define DoExtraLib SharedLibGlx
@@ -12,6 +14,7 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#if BuildXF86DRI
DRI_DEFINES = GlxDefines -DDRIVERTS
DRI_INCLUDES = -I../../../../dri -I../../../../glx \
+ -I../../../dri \
-I$(TOP)/include -I$(TOP)/include/GL \
-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
-I$(XF86DRIVERSRC)/mga \
@@ -24,23 +27,244 @@ MESA_INCLUDES = -I. -I.. -I../../include
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
- INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \
- -I/usr/include/glide
- DRISRCS = mgaclear.c mgacnvtex.c mgadd.c mgadepth.c \
+ INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+#if 0
+ LOSRC = ../../../../lowpc.c
+ LOOBJ = ../../../../lowpc.o
+
+ HISRC = ../../../../highpc.c
+ HIOBJ = ../../../../highpc.o
+#endif
+
+ DRISRCS = ../../../dri/dri_mesa.c \
+ ../../../../dri/dri_tmm.c
+
+ DRIOBJS = ../../../dri/dri_mesa.o \
+ ../../../../dri/dri_tmm.o
+
+ DRMSRCS = ../../../../dri/drm/xf86drm.c \
+ ../../../../dri/drm/xf86drmHash.c \
+ ../../../../dri/drm/xf86drmRandom.c \
+ ../../../../dri/drm/xf86drmSL.c
+
+ DRMOBJS = ../../../../dri/drm/xf86drm.o \
+ ../../../../dri/drm/xf86drmHash.o \
+ ../../../../dri/drm/xf86drmRandom.o \
+ ../../../../dri/drm/xf86drmSL.o
+
+
+ MGASRCS = mgaclear.c mgacnvtex.c mgadd.c \
mgafastpath.c \
mgapipeline.c \
mgaspan.c mgastate.c mgatex.c \
- mgatris.c mgavb.c mgaioctl.c mga_xmesa.c
+ mgatris.c mgavb.c mgaioctl.c mga_xmesa.c mgabuffers.c
- DRIOBJS = mgaclear.o mgacnvtex.o mgadd.o mgadepth.o \
+ MGAOBJS = mgaclear.o mgacnvtex.o mgadd.o \
mgafastpath.o \
mgapipeline.o \
mgaspan.o mgastate.o mgatex.o \
- mgatris.o mgavb.o mgaioctl.o mga_xmesa.o
+ mgatris.o mgavb.o mgaioctl.o mga_xmesa.o mgabuffers.o
+
+ MESASRCS = ../../accum.c \
+ ../../alpha.c \
+ ../../alphabuf.c \
+ ../../attrib.c \
+ ../../bbox.c \
+ ../../bitmap.c \
+ ../../blend.c \
+ ../../buffers.c \
+ ../../clip.c \
+ ../../colortab.c \
+ ../../config.c \
+ ../../context.c \
+ ../../copypix.c \
+ ../../cva.c \
+ ../../debug_xform.c \
+ ../../depth.c \
+ ../../dlist.c \
+ ../../drawpix.c \
+ ../../enable.c \
+ ../../enums.c \
+ ../../eval.c \
+ ../../extensions.c \
+ ../../feedback.c \
+ ../../fog.c \
+ ../../get.c \
+ ../../glapi.c \
+ ../../glapinoop.c \
+ ../../glthread.c \
+ ../../hash.c \
+ ../../image.c \
+ ../../imaging.o \
+ ../../light.c \
+ ../../lines.c \
+ ../../logic.c \
+ ../../masking.c \
+ ../../matrix.c \
+ ../../mem.c \
+ ../../mmath.c \
+ ../../pb.c \
+ ../../pipeline.c \
+ ../../pixel.c \
+ ../../points.c \
+ ../../polygon.c \
+ ../../quads.c \
+ ../../rastpos.c \
+ ../../readpix.c \
+ ../../rect.c \
+ ../../scissor.c \
+ ../../shade.c \
+ ../../span.c \
+ ../../stages.c \
+ ../../state.c \
+ ../../stencil.c \
+ ../../teximage.c \
+ ../../texobj.c \
+ ../../texstate.c \
+ ../../texture.c \
+ ../../translate.c \
+ ../../triangle.c \
+ ../../varray.c \
+ ../../vb.c \
+ ../../vbcull.c \
+ ../../vbfill.c \
+ ../../vbindirect.c \
+ ../../vbrender.c \
+ ../../vbxform.c \
+ ../../vector.c \
+ ../../vertices.c \
+ ../../winpos.c \
+ ../../xform.c \
+ ../../zoom.c \
+ ../../X86/common_x86.c
+
+ MESAOBJS = ../../accum.o \
+ ../../alpha.o \
+ ../../alphabuf.o \
+ ../../attrib.o \
+ ../../bbox.o \
+ ../../bitmap.o \
+ ../../blend.o \
+ ../../buffers.o \
+ ../../clip.o \
+ ../../colortab.o \
+ ../../config.o \
+ ../../context.o \
+ ../../copypix.o \
+ ../../cva.o \
+ ../../debug_xform.o \
+ ../../depth.o \
+ ../../dlist.o \
+ ../../drawpix.o \
+ ../../enable.o \
+ ../../enums.o \
+ ../../eval.o \
+ ../../extensions.o \
+ ../../feedback.o \
+ ../../fog.o \
+ ../../get.o \
+ ../../hash.o \
+ ../../hint.o \
+ ../../image.o \
+ ../../imaging.o \
+ ../../light.o \
+ ../../lines.o \
+ ../../logic.o \
+ ../../masking.o \
+ ../../matrix.o \
+ ../../mem.o \
+ ../../mmath.o \
+ ../../pb.o \
+ ../../pipeline.o \
+ ../../pixel.o \
+ ../../points.o \
+ ../../polygon.o \
+ ../../quads.o \
+ ../../rastpos.o \
+ ../../readpix.o \
+ ../../rect.o \
+ ../../scissor.o \
+ ../../shade.o \
+ ../../span.o \
+ ../../stages.o \
+ ../../state.o \
+ ../../stencil.o \
+ ../../teximage.o \
+ ../../texobj.o \
+ ../../texstate.o \
+ ../../texture.o \
+ ../../translate.o \
+ ../../triangle.o \
+ ../../varray.o \
+ ../../vb.o \
+ ../../vbcull.o \
+ ../../vbfill.o \
+ ../../vbindirect.o \
+ ../../vbrender.o \
+ ../../vbxform.o \
+ ../../vector.o \
+ ../../vertices.o \
+ ../../winpos.o \
+ ../../xform.o \
+ ../../zoom.o
+
+#ifdef i386Architecture
+ X86_SRCS = ../../X86/x86.c \
+ ../../X86/x86a.S \
+ ../../X86/common_x86.c \
+ ../../X86/common_x86asm.S \
+ ../../X86/vertex.S
+
+ X86_OBJS = ../../X86/x86.o \
+ ../../X86/x86a.o \
+ ../../X86/common_x86.o \
+ ../../X86/common_x86asm.o \
+ ../../X86/vertex.o
+
+ MMX_SRCS = ../../X86/mmx_blend.S
+
+ MMX_OBJS = ../../X86/mmx_blend.o
+
+XCOMM Disabling 3Dnow code for the time being.
+#if 0
+ 3DNOW_SRCS = ../../X86/3dnow.c \
+ ../../X86/3dnow_norm_raw.S \
+ ../../X86/3dnow_xform_masked1.S \
+ ../../X86/3dnow_xform_masked2.S \
+ ../../X86/3dnow_xform_masked3.S \
+ ../../X86/3dnow_xform_masked4.S \
+ ../../X86/3dnow_xform_raw1.S \
+ ../../X86/3dnow_xform_raw2.S \
+ ../../X86/3dnow_xform_raw3.S \
+ ../../X86/3dnow_xform_raw4.S \
+ ../../X86/vertex_3dnow.S
+
+ 3DNOW_OBJS = ../../X86/3dnow.o \
+ ../../X86/3dnow_norm_raw.o \
+ ../../X86/3dnow_xform_masked1.o \
+ ../../X86/3dnow_xform_masked2.o \
+ ../../X86/3dnow_xform_masked3.o \
+ ../../X86/3dnow_xform_masked4.o \
+ ../../X86/3dnow_xform_raw1.o \
+ ../../X86/3dnow_xform_raw2.o \
+ ../../X86/3dnow_xform_raw3.o \
+ ../../X86/3dnow_xform_raw4.o \
+ ../../X86/vertex_3dnow.o
+#endif
+
+#endif
+
+ ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
+ ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+
+ COMMONSRCS = ../common/mm.c ../common/hwlog.c
+ COMMONOBJS = ../common/mm.o ../common/hwlog.o
+ SRCS = $(LOWSRC) $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) $(COMMONSRCS) $(MGASRCS) $(HISRC)
+ OBJS = $(LOWOBJ) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) $(COMMONOBJS) $(MGAOBJS) $(HIOBJ)
- SRCS = $(DRISRCS)
- OBJS = $(DRIOBJS)
+REQUIREDLIBS += -lm
#if !GlxUseBuiltInDRIDriver
#undef DoNormalLib NormalLibGlx
@@ -61,7 +285,7 @@ LIBNAME = mga_dri.so
ALL_OBJS = $(OBJS)
ALL_DEPS = DONE
SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
-InstallDynamicModule($(LIBNAME),$(MODULEDIR),.)
+InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.)
#endif
DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
index 496c29a05..996dc3819 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
@@ -27,7 +27,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Daryll Strauss <daryll@precisioninsight.com>
+ * Keith Whitwell <keithw@precisioninsight.com>
*
*/
@@ -36,6 +36,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xlibint.h>
#include <stdio.h>
+#include "drm.h"
#include "mga_xmesa.h"
#include "context.h"
#include "vbxform.h"
@@ -49,20 +50,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "mgadepth.h"
#include "mgatris.h"
#include "mgapipeline.h"
+#include "mgabuffers.h"
#include "xf86dri.h"
-#include "mga_dri.h"
-#include "mga_drm_public.h"
#include "mga_xmesa.h"
+#include "mga_dri.h"
+
#ifndef MGA_DEBUG
int MGA_DEBUG = (0
-/* | MGA_DEBUG_ALWAYS_SYNC */
-/* | MGA_DEBUG_VERBOSE_MSG */
+/* | DEBUG_ALWAYS_SYNC */
+/* | DEBUG_VERBOSE_MSG */
+/* | DEBUG_VERBOSE_LRU */
+/* | DEBUG_VERBOSE_DRI */
+/* | DEBUG_VERBOSE_IOCTL */
+/* | DEBUG_VERBOSE_2D */
);
#endif
@@ -107,7 +113,10 @@ static int count_bits(unsigned int n)
GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
{
mgaScreenPrivate *mgaScreen;
- MGADRIPtr gDRIPriv = (MGADRIPtr)sPriv->pDevPriv;
+ MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv;
+
+
+ fprintf(stderr, "XMesaInitDriver\n");
/* Allocate the private area */
mgaScreen = (mgaScreenPrivate *)Xmalloc(sizeof(mgaScreenPrivate));
@@ -116,20 +125,68 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
mgaScreen->sPriv = sPriv;
sPriv->private = (void *)mgaScreen;
- mgaScreen->chipset=gDRIPriv->chipset;
- mgaScreen->width=gDRIPriv->width;
- mgaScreen->height=gDRIPriv->height;
- mgaScreen->mem=gDRIPriv->mem;
- mgaScreen->cpp=gDRIPriv->cpp;
- mgaScreen->frontPitch=gDRIPriv->frontPitch;
- mgaScreen->frontOffset=gDRIPriv->frontOffset;
- mgaScreen->backOffset=gDRIPriv->backOffset;
- mgaScreen->backPitch = gDRIPriv->backPitch;
- mgaScreen->depthOffset=gDRIPriv->depthOffset;
- mgaScreen->depthPitch = gDRIPriv->depthPitch;
- mgaScreen->textureOffset=gDRIPriv->textureOffset;
- mgaScreen->textureSize=gDRIPriv->textureSize;
- mgaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+ fprintf(stderr, "serverInfo->chipset: %d\n", serverInfo->chipset);
+
+ if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
+ serverInfo->chipset != MGA_CARD_TYPE_G400)
+ return GL_FALSE;
+
+ mgaScreen->chipset = serverInfo->chipset;
+ mgaScreen->width = serverInfo->width;
+ mgaScreen->height = serverInfo->height;
+ mgaScreen->mem = serverInfo->mem;
+ mgaScreen->cpp = serverInfo->cpp;
+ mgaScreen->frontPitch = serverInfo->frontPitch;
+ mgaScreen->frontOffset = serverInfo->frontOffset;
+ mgaScreen->backOffset = serverInfo->backOffset;
+ mgaScreen->backPitch = serverInfo->backPitch;
+ mgaScreen->depthOffset = serverInfo->depthOffset;
+ mgaScreen->depthPitch = serverInfo->depthPitch;
+
+
+ mgaScreen->agp_tex.handle = serverInfo->agp;
+ mgaScreen->agp_tex.size = serverInfo->agpSize;
+
+ if (drmMap(sPriv->fd,
+ mgaScreen->agp_tex.handle,
+ mgaScreen->agp_tex.size,
+ (drmAddress *)&mgaScreen->agp_tex.map) != 0)
+ {
+ Xfree(mgaScreen);
+ return GL_FALSE;
+ }
+
+
+
+ mgaScreen->textureOffset[MGA_CARD_HEAP] = serverInfo->textureOffset;
+ mgaScreen->textureOffset[MGA_AGP_HEAP] = (mgaScreen->agp_tex.handle |
+ PDEA_pagpxfer_enable | 1);
+
+ fprintf(stderr, "CARD texture size %x, granul %d --> %x\n",
+ serverInfo->textureSize, serverInfo->logTextureGranularity,
+ 1<<serverInfo->logTextureGranularity);
+
+ mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize;
+ mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize;
+
+ mgaScreen->logTextureGranularity[MGA_CARD_HEAP] =
+ serverInfo->logTextureGranularity;
+ mgaScreen->logTextureGranularity[MGA_AGP_HEAP] =
+ serverInfo->logAgpTextureGranularity;
+
+ mgaScreen->texVirtual[MGA_CARD_HEAP] = (mgaScreen->sPriv->pFB +
+ mgaScreen->textureOffset[0]);
+ mgaScreen->texVirtual[MGA_AGP_HEAP] = mgaScreen->agp_tex.map;
+
+ mgaScreen->mAccess = serverInfo->mAccess;
+
+
+ fprintf(stderr, "\n\n\nbackOffset: %x pitch %x\n",
+ mgaScreen->backOffset,
+ mgaScreen->backPitch);
+
+
+ mgaScreen->Attrib = MGA_PF_565;
mgaScreen->bufs = drmMapBufs(sPriv->fd);
@@ -169,6 +226,8 @@ XMesaVisual XMesaCreateVisual(XMesaDisplay *display,
{
XMesaVisual v;
+ fprintf(stderr, "XMesaCreateVisual\n");
+
/* Only RGB visuals are supported on the MGA boards */
if (!rgb_flag) return 0;
@@ -183,28 +242,19 @@ XMesaVisual XMesaCreateVisual(XMesaDisplay *display,
memcpy(v->visinfo, visinfo, sizeof(*visinfo));
v->display = display;
- v->level = level;
-
- v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual));
+ v->level = level;
+ v->gl_visual = gl_create_visual(rgb_flag, GL_FALSE, db_flag, stereo_flag,
+ depth_size, stencil_size, accum_size, 0,
+ count_bits(visinfo->red_mask),
+ count_bits(visinfo->green_mask),
+ count_bits(visinfo->blue_mask),
+ GL_FALSE);
if (!v->gl_visual) {
Xfree(v->visinfo);
- XFree(v);
- return 0;
+ Xfree(v);
+ return NULL;
}
- v->gl_visual->RGBAflag = rgb_flag;
- v->gl_visual->DBflag = db_flag;
- v->gl_visual->StereoFlag = stereo_flag;
-
- v->gl_visual->RedBits = count_bits(visinfo->red_mask);
- v->gl_visual->GreenBits = count_bits(visinfo->green_mask);
- v->gl_visual->BlueBits = count_bits(visinfo->blue_mask);
- v->gl_visual->AlphaBits = 0; /* Not currently supported */
-
- v->gl_visual->AccumBits = accum_size;
- v->gl_visual->DepthBits = depth_size;
- v->gl_visual->StencilBits = stencil_size;
-
return v;
}
@@ -218,6 +268,7 @@ void XMesaDestroyVisual(XMesaVisual v)
XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
__DRIcontextPrivate *driContextPriv)
{
+ int i;
GLcontext *ctx;
XMesaContext c;
mgaContextPtr mmesa;
@@ -227,12 +278,15 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
sizeof(XF86DRISAREARec));
GLcontext *shareCtx = 0;
+ fprintf(stderr, "XMesaCreateContext\n");
+
+
c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context));
if (!c) {
return 0;
}
- mmesa = (mgaContextPtr)Xmalloc(sizeof(mgaContext));
+ mmesa = (mgaContextPtr)Xcalloc(sizeof(mgaContext), 1);
if (!mmesa) {
Xfree(c);
return 0;
@@ -250,8 +304,6 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
ctx = mmesa->glCtx = gl_create_context(v->gl_visual, shareCtx,
(void*)mmesa, GL_TRUE);
- /* Dri stuff
- */
mmesa->display = v->display;
mmesa->hHWContext = driContextPriv->hHWContext;
mmesa->driFd = sPriv->fd;
@@ -261,40 +313,45 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
mmesa->driScreen = sPriv;
mmesa->sarea = saPriv;
- mmesa->glBuffer=gl_create_framebuffer(v->gl_visual);
+ mmesa->glBuffer=gl_create_framebuffer(v->gl_visual,
+ GL_FALSE, /* software depth buffer? */
+ v->gl_visual->StencilBits > 0,
+ v->gl_visual->AccumBits > 0,
+ v->gl_visual->AlphaBits > 0);
+
+ make_empty_list(&mmesa->SwappedOut);
- mmesa->needClip=1;
+ mmesa->lastTexHeap = mgaScreen->texVirtual[MGA_AGP_HEAP] ? 2 : 1;
- mmesa->texHeap = mmInit( 0, mgaScreen->textureSize );
+ for (i = 0 ; i < mmesa->lastTexHeap ; i++) {
+ mmesa->texHeap[i] = mmInit( 0, mgaScreen->textureSize[i]);
+ make_empty_list(&mmesa->TexObjList[i]);
+ }
- /* Utah stuff
- */
mmesa->renderindex = -1; /* impossible value */
mmesa->new_state = ~0;
mmesa->dirty = ~0;
-
- mmesa->warp_pipe = 0;
-
-
- make_empty_list(&mmesa->SwappedOut);
- make_empty_list(&mmesa->TexObjList);
-
+ mmesa->warp_pipe = 0;
mmesa->CurrentTexObj[0] = 0;
mmesa->CurrentTexObj[1] = 0;
+ mmesa->texAge[0] = 0;
+ mmesa->texAge[1] = 0;
+
+
mgaDDExtensionsInit( ctx );
mgaDDInitStateFuncs( ctx );
mgaDDInitTextureFuncs( ctx );
mgaDDInitSpanFuncs( ctx );
- mgaDDInitDepthFuncs( ctx );
mgaDDInitDriverFuncs( ctx );
mgaDDInitIoctlFuncs( ctx );
ctx->Driver.TriangleCaps = (DD_TRI_CULL|
DD_TRI_LIGHT_TWOSIDE|
+ DD_TRI_STIPPLE|
DD_TRI_OFFSET);
/* Ask mesa to clip fog coordinates for us.
@@ -312,6 +369,9 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list,
mgaDDRegisterPipelineStages(ctx->PipelineStage,
ctx->PipelineStage,
ctx->NrPipelineStages);
+
+ mgaInitState( mmesa );
+
return c;
}
@@ -364,59 +424,12 @@ void XMesaSwapBuffers(XMesaBuffer bogus_value_do_not_use)
-
-void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa )
+GLboolean XMesaUnbindContext(XMesaContext c)
{
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
-
- mmesa->numClipRects = dPriv->numClipRects;
- mmesa->pClipRects = dPriv->pClipRects;
- mmesa->drawX = dPriv->x;
- mmesa->drawY = dPriv->y;
-
- mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
-}
-
-
-void mgaXMesaSetBackClipRects( mgaContextPtr mmesa )
-{
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
-
- if (dPriv->numAuxClipRects == 0)
- {
- mmesa->numClipRects = dPriv->numClipRects;
- mmesa->pClipRects = dPriv->pClipRects;
- mmesa->drawX = dPriv->x;
- mmesa->drawY = dPriv->y;
- } else {
- mmesa->numClipRects = dPriv->numAuxClipRects;
- mmesa->pClipRects = dPriv->pAuxClipRects;
- mmesa->drawX = dPriv->auxX;
- mmesa->drawY = dPriv->auxY;
- }
-
- mmesa->drawOffset = mmesa->mgaScreen->backOffset;
-}
-
-
-static void mgaXMesaWindowMoved( mgaContextPtr mmesa )
-{
- /* Clear any contaminated CVA data.
- */
- mmesa->setupdone = 0;
-
- switch (mmesa->glCtx->Color.DriverDrawBuffer) {
- case GL_FRONT_LEFT:
- mgaXMesaSetFrontClipRects( mmesa );
- break;
- case GL_BACK_LEFT:
- mgaXMesaSetBackClipRects( mmesa );
- break;
- default:
- fprintf(stderr, "fallback buffer\n");
- break;
- }
+ if (c->private)
+ ((mgaContextPtr)c->private)->dirty = ~0;
+ return GL_TRUE;
}
@@ -439,9 +452,9 @@ GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b)
gl_make_current(mgaCtx->glCtx, mgaCtx->glBuffer);
- mgaXMesaWindowMoved( mgaCtx );
mgaCtx->driDrawable = dPriv;
mgaCtx->dirty = ~0;
+ mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK);
if (!mgaCtx->glCtx->Viewport.Width)
gl_Viewport(mgaCtx->glCtx, 0, 0, dPriv->w, dPriv->h);
@@ -455,54 +468,36 @@ GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b)
}
-void mgaXMesaUpdateState( mgaContextPtr mmesa )
+void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
{
__DRIdrawablePrivate *dPriv = mmesa->driDrawable;
- __DRIscreenPrivate *sPriv = mmesa->driScreen;
drm_mga_sarea_t *sarea = mmesa->sarea;
-
int me = mmesa->hHWContext;
- int stamp = dPriv->lastStamp;
+ int i;
- /* If the window moved, may need to set a new cliprect now.
- *
- * NOTE: This releases and regains the hw lock, so all state
- * checking must be done *after* this call:
- */
- XMESA_VALIDATE_DRAWABLE_INFO(mmesa->display, sPriv, dPriv);
+ drmGetLock(mmesa->driFd, mmesa->hHWContext, flags);
- if (sarea->ctxOwner != me) {
- mmesa->dirty |= MGA_UPLOAD_CTX;
+ if (*(dPriv->pStamp) != dPriv->lastStamp) {
+ mmesa->setupdone = 0;
+ mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+ mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) );
}
- if (sarea->texAge != mmesa->texAge) {
- int sz = 1 << (mmesa->mgaScreen->logTextureGranularity);
- int idx, nr = 0;
-
- /* Have to go right round from the back to ensure stuff ends up
- * LRU in our local list...
- */
- for (idx = sarea->texList[MGA_NR_TEX_REGIONS].prev ;
- idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ;
- idx = sarea->texList[idx].prev, nr++)
- {
- if (sarea->texList[idx].age > mmesa->texAge)
- mgaTexturesGone(mmesa, idx * sz, sz, 1);
- }
-
- if (nr == MGA_NR_TEX_REGIONS) {
- mgaTexturesGone(mmesa, 0, mmesa->mgaScreen->textureSize, 0);
- mgaResetGlobalLRU( mmesa );
- }
-
- mmesa->texAge = sarea->texAge;
- mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE;
+ mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_CLIPRECTS;
+
+ mmesa->sarea->dirty |= MGA_UPLOAD_CTX;
+
+ if (sarea->ctxOwner != me) {
+ mmesa->dirty |= (MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0 |
+ MGA_UPLOAD_TEX1 | MGA_UPLOAD_PIPE);
+ sarea->ctxOwner=me;
}
- if (dPriv->lastStamp != stamp)
- mgaXMesaWindowMoved( mmesa );
+ for (i = 0 ; i < mmesa->lastTexHeap ; i++)
+ if (sarea->texAge[i] != mmesa->texAge[i])
+ mgaAgeTextures( mmesa, i );
- sarea->ctxOwner=me;
+ sarea->last_quiescent = -1; /* just kill it for now */
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
index d563bd429..1379f48d9 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
@@ -28,7 +28,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Keith Whitwell <keithw@precisioninsight.com>
- * Daryll Strauss <daryll@precisioninsight.com> (Origninal tdfx driver).
*
*/
@@ -43,6 +42,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dri_mesa.h"
#include "types.h"
#include "xmesaP.h"
+#include "mgaregs.h"
+
+typedef struct {
+ drmHandle handle;
+ drmSize size;
+ char *map;
+} mgaRegion, *mgaRegionPtr;
typedef struct {
@@ -54,6 +60,7 @@ typedef struct {
int cpp; /* for front and back buffers */
int Attrib;
+ int mAccess;
int frontOffset;
int frontPitch;
@@ -64,43 +71,54 @@ typedef struct {
int depthPitch;
int depthCpp;
- int textureOffset;
- int textureSize;
- int logTextureGranularity;
+ int textureOffset[MGA_NR_TEX_HEAPS];
+ int textureSize[MGA_NR_TEX_HEAPS];
+ int logTextureGranularity[MGA_NR_TEX_HEAPS];
+ char *texVirtual[MGA_NR_TEX_HEAPS];
+
__DRIscreenPrivate *sPriv;
drmBufMapPtr bufs;
+ mgaRegion agp_tex;
+
} mgaScreenPrivate;
#include "mgalib.h"
-extern void mgaXMesaUpdateState( mgaContextPtr mmesa );
+extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
extern void mgaEmitHwStateLocked( mgaContextPtr mmesa );
extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit );
-extern void mgaXMesaSetBackClipRects( mgaContextPtr mmesa );
-extern void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa );
+
+#define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE( mmesa ) mmesa->sarea->last_enqueue
/* Lock the hardware and validate our state.
*/
-#define LOCK_HARDWARE( mmesa ) \
- do { \
- char __ret=0; \
- DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
- (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
- if (__ret) { \
- drmGetLock(mmesa->driFd, mmesa->hHWContext, 0); \
- mgaXMesaUpdateState( mmesa ); \
- } \
+#define LOCK_HARDWARE( mmesa ) \
+ do { \
+ char __ret=0; \
+ DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
+ (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
+ if (__ret) \
+ mgaGetLock( mmesa, 0 ); \
} while (0)
+/*
+ */
+#define LOCK_HARDWARE_QUIESCENT( mmesa ) do { \
+ LOCK_HARDWARE( mmesa ); \
+ mgaUpdateLock( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); \
+} while (0)
+
+
/* Unlock the hardware using the global current context
*/
-#define UNLOCK_HARDWARE(mmesa) \
+#define UNLOCK_HARDWARE(mmesa) \
DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
@@ -109,6 +127,8 @@ extern void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa );
#define REFRESH_DRAWABLE_INFO( mmesa ) \
do { \
LOCK_HARDWARE( mmesa ); \
+ mmesa->lastX = mmesa->drawX; \
+ mmesa->lastY = mmesa->drawY; \
UNLOCK_HARDWARE( mmesa ); \
} while (0)
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
new file mode 100644
index 000000000..276c5df85
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
@@ -0,0 +1,315 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+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, sub license, 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 NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <keithw@precisioninsight.com>
+ *
+ * $PI: $
+ */
+
+#include <stdio.h>
+#include "mgalib.h"
+#include "mgabuffers.h"
+#include "mgastate.h"
+
+static void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+
+ mmesa->numClipRects = driDrawable->numClipRects;
+ mmesa->pClipRects = driDrawable->pClipRects;
+ mmesa->drawX = driDrawable->x;
+ mmesa->drawY = driDrawable->y;
+
+ mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->drawOffset;
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+}
+
+
+static void mgaXMesaSetBackClipRects( mgaContextPtr mmesa )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+
+ if (driDrawable->numBackClipRects == 0)
+ {
+ mmesa->numClipRects = driDrawable->numClipRects;
+ mmesa->pClipRects = driDrawable->pClipRects;
+ mmesa->drawX = driDrawable->x;
+ mmesa->drawY = driDrawable->y;
+ } else {
+ mmesa->numClipRects = driDrawable->numBackClipRects;
+ mmesa->pClipRects = driDrawable->pBackClipRects;
+ mmesa->drawX = driDrawable->backX;
+ mmesa->drawY = driDrawable->backY;
+ }
+
+ mmesa->drawOffset = mmesa->mgaScreen->backOffset;
+ mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->drawOffset;
+
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+}
+
+
+
+static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+ __DRIscreenPrivate *driScreen = mmesa->driScreen;
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+ int i = 0, top = 0;
+
+
+ if (sarea->exported_buffers & MGA_BACK) {
+ XF86DRIClipRectPtr boxes =
+ (XF86DRIClipRectPtr)malloc( sarea->exported_nback * sizeof(*boxes) );
+
+ if (driDrawable->pBackClipRects)
+ free(driDrawable->pBackClipRects);
+
+ driDrawable->numBackClipRects = sarea->exported_nback;
+ driDrawable->pBackClipRects = boxes;
+
+ top = sarea->exported_nback;
+ for (i = 0 ; i < top ; i++)
+ boxes[i] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
+ }
+
+
+ if (sarea->exported_buffers & MGA_FRONT)
+ {
+ int start = top;
+ XF86DRIClipRectPtr boxes =
+ (XF86DRIClipRectPtr)malloc( sarea->exported_nfront * sizeof(*boxes) );
+
+ if (driDrawable->pClipRects)
+ free(driDrawable->pClipRects);
+
+ driDrawable->numClipRects = sarea->exported_nfront;
+ driDrawable->pClipRects = boxes;
+
+ top += sarea->exported_nfront;
+ for ( ; i < top ; i++)
+ boxes[i-start] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
+
+ }
+
+
+
+ driDrawable->index = sarea->exported_index;
+ driDrawable->lastStamp = sarea->exported_stamp;
+ driDrawable->x = sarea->exported_front_x;
+ driDrawable->y = sarea->exported_front_y;
+ driDrawable->backX = sarea->exported_back_x;
+ driDrawable->backY = sarea->exported_back_y;
+ driDrawable->w = sarea->exported_w;
+ driDrawable->h = sarea->exported_h;
+ driDrawable->pStamp =
+ &(driScreen->pSAREA->drawableTable[driDrawable->index].stamp);
+
+ mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK) & ~(sarea->exported_buffers);
+}
+
+
+
+static void printSareaRects( mgaContextPtr mmesa )
+{
+ __DRIscreenPrivate *driScreen = mmesa->driScreen;
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+ int i;
+
+ fprintf(stderr, "sarea->exported: %d\n", sarea->exported_drawable);
+ fprintf(stderr, "sarea->exported_index: %d\n", sarea->exported_index);
+ fprintf(stderr, "sarea->exported_stamp: %d\n", sarea->exported_stamp);
+ fprintf(stderr, "sarea->exported_front_x: %d\n", sarea->exported_front_x);
+ fprintf(stderr, "sarea->exported_front_y: %d\n", sarea->exported_front_y);
+ fprintf(stderr, "sarea->exported_back_x: %d\n", sarea->exported_back_x);
+ fprintf(stderr, "sarea->exported_back_y: %d\n", sarea->exported_back_y);
+ fprintf(stderr, "sarea->exported_w: %d\n", sarea->exported_w);
+ fprintf(stderr, "sarea->exported_h: %d\n", sarea->exported_h);
+ fprintf(stderr, "sarea->exported_buffers: %d\n", sarea->exported_buffers);
+ fprintf(stderr, "sarea->exported_nfront: %d\n", sarea->exported_nfront);
+ fprintf(stderr, "sarea->exported_nback: %d\n", sarea->exported_nback);
+
+ i = 0;
+ if (sarea->exported_buffers & MGA_BACK)
+ for ( ; i < sarea->exported_nback ; i++)
+ fprintf(stderr, "back %d: %d,%d-%d,%d\n", i,
+ sarea->exported_boxes[i].x1, sarea->exported_boxes[i].y1,
+ sarea->exported_boxes[i].x2, sarea->exported_boxes[i].y2);
+
+ if (sarea->exported_buffers & MGA_FRONT) {
+ int start = i;
+ int top = i + sarea->exported_nfront;
+ for ( ; i < top ; i++)
+ fprintf(stderr, "front %d: %d,%d-%d,%d\n",
+ i - start,
+ sarea->exported_boxes[i].x1, sarea->exported_boxes[i].y1,
+ sarea->exported_boxes[i].x2, sarea->exported_boxes[i].y2);
+ }
+
+ fprintf(stderr, "drawableTable[%d].stamp: %d\n",
+ sarea->exported_index,
+ driScreen->pSAREA->drawableTable[sarea->exported_index].stamp);
+}
+
+static void printMmesaRects( mgaContextPtr mmesa )
+{
+ __DRIscreenPrivate *driScreen = mmesa->driScreen;
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+ int nr = mmesa->numClipRects;
+ int i;
+
+ fprintf(stderr, "driDrawable->draw: %ld\n", driDrawable->draw);
+ fprintf(stderr, "driDrawable->index: %d\n", driDrawable->index);
+ fprintf(stderr, "driDrawable->lastStamp: %d\n", driDrawable->lastStamp);
+ fprintf(stderr, "mmesa->drawX: %d\n", mmesa->drawX);
+ fprintf(stderr, "mmesa->drawY: %d\n", mmesa->drawY);
+ fprintf(stderr, "driDrawable->w: %d\n", driDrawable->w);
+ fprintf(stderr, "driDrawable->h: %d\n", driDrawable->h);
+
+ for (i = 0 ; i < nr ; i++)
+ fprintf(stderr, "box %d: %d,%d-%d,%d\n", i,
+ mmesa->pClipRects[i].x1, mmesa->pClipRects[i].y1,
+ mmesa->pClipRects[i].x2, mmesa->pClipRects[i].y2);
+
+ fprintf(stderr, "mmesa->draw_buffer: %d\n", mmesa->draw_buffer);
+ fprintf(stderr, "drawableTable[%d].stamp: %d\n",
+ driDrawable->index,
+ driScreen->pSAREA->drawableTable[driDrawable->index].stamp);
+}
+
+
+
+void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+
+ /* The MGA X driver will try to push one set of cliprects (back or
+ * front, the last active) for one drawable (the last used) into
+ * the sarea. See if that window was ours, else retrieve both back
+ * and front rects from the X server via a protocol request.
+ *
+ * If there isn't room for the cliprects in the sarea, the X server
+ * clears the drawable value to indicate failure.
+ */
+ if (0) printSareaRects(mmesa);
+
+ if (sarea->exported_drawable == driDrawable->draw &&
+ (sarea->exported_buffers & buffers) == buffers)
+ {
+ mgaUpdateRectsFromSarea( mmesa );
+ }
+ else
+ {
+ if(MGA_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf(stderr, "^");
+ driDrawable->lastStamp = 0;
+
+ XMESA_VALIDATE_DRAWABLE_INFO(mmesa->display,
+ mmesa->driScreen,
+ driDrawable);
+ mmesa->dirty_cliprects = 0;
+ }
+
+ if (mmesa->draw_buffer == MGA_FRONT)
+ mgaXMesaSetFrontClipRects( mmesa );
+ else
+ mgaXMesaSetBackClipRects( mmesa );
+
+
+ if (0) printMmesaRects(mmesa);
+
+ sarea->req_drawable = driDrawable->draw;
+ sarea->req_draw_buffer = mmesa->draw_buffer;
+
+
+ mgaUpdateClipping( mmesa->glCtx );
+
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+}
+
+
+
+GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
+
+ mmesa->Fallback &= ~MGA_FALLBACK_BUFFER;
+
+ if (mode == GL_FRONT_LEFT)
+ {
+ mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->mgaScreen->frontOffset;
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+ mmesa->draw_buffer = MGA_FRONT;
+ mgaXMesaSetFrontClipRects( mmesa );
+ return GL_TRUE;
+ }
+ else if (mode == GL_BACK_LEFT)
+ {
+ mmesa->drawOffset = mmesa->mgaScreen->backOffset;
+ mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->mgaScreen->backOffset;
+ mmesa->draw_buffer = MGA_BACK;
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+ mgaXMesaSetBackClipRects( mmesa );
+ return GL_TRUE;
+ }
+ else
+ {
+ mmesa->Fallback |= MGA_FALLBACK_BUFFER;
+ return GL_FALSE;
+ }
+}
+
+GLboolean mgaDDSetReadBuffer(GLcontext *ctx, GLenum mode )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (mode == GL_FRONT_LEFT)
+ {
+ mmesa->readOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->read_buffer = MGA_FRONT;
+ return GL_TRUE;
+ }
+ else if (mode == GL_BACK_LEFT)
+ {
+ mmesa->readOffset = mmesa->mgaScreen->backOffset;
+ mmesa->read_buffer = MGA_BACK;
+ return GL_TRUE;
+ }
+ else
+ {
+ return GL_FALSE;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h
new file mode 100644
index 000000000..9345fd9c4
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h
@@ -0,0 +1,9 @@
+#ifndef MGA_BUFFERS_H
+#define MGA_BUFFERS_H
+
+GLboolean mgaDDSetReadBuffer(GLcontext *ctx, GLenum mode );
+GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode );
+
+void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers );
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c b/xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c
index ae8d95037..428b65d06 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c
@@ -46,205 +46,206 @@
*/
void mgaConvertTexture( mgaUI32 *destPtr, int texelBytes,
struct gl_texture_image *image,
- int x, int y, int width, int height ) {
+ int x, int y, int width, int height )
+{
register int i, j;
mgaUI8 *src;
int stride;
/* FIXME: g400 luminance_alpha internal format */
switch (texelBytes) {
- case 1:
- switch (image->Format) {
- case GL_COLOR_INDEX:
- case GL_INTENSITY:
- case GL_LUMINANCE:
- case GL_ALPHA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 2 ; j ; j-- ) {
+ case 1:
+ switch (image->Format) {
+ case GL_COLOR_INDEX:
+ case GL_INTENSITY:
+ case GL_LUMINANCE:
+ case GL_ALPHA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 2 ; j ; j-- ) {
- *destPtr++ = src[0] | ( src[1] << 8 ) | ( src[2] << 16 ) | ( src[3] << 24 );
- src += 4;
- }
- src += stride;
- }
- break;
- default:
- goto format_error;
- }
- break;
- case 2:
- switch (image->Format) {
- case GL_RGB:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 3;
- stride = (image->Width - width) * 3;
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
+ *destPtr++ = src[0] | ( src[1] << 8 ) | ( src[2] << 16 ) | ( src[3] << 24 );
+ src += 4;
+ }
+ src += stride;
+ }
+ break;
+ default:
+ goto format_error;
+ }
+ break;
+ case 2:
+ switch (image->Format) {
+ case GL_RGB:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 3;
+ stride = (image->Width - width) * 3;
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 1 ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR565(src[0],src[1],src[2]) |
- ( MGAPACKCOLOR565(src[3],src[4],src[5]) << 16 );
- src += 6;
- }
- src += stride;
- }
- break;
- case GL_RGBA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 4;
- stride = (image->Width - width) * 4;
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR565(src[0],src[1],src[2]) |
+ ( MGAPACKCOLOR565(src[3],src[4],src[5]) << 16 );
+ src += 6;
+ }
+ src += stride;
+ }
+ break;
+ case GL_RGBA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 4;
+ stride = (image->Width - width) * 4;
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 1 ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |
- ( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
- src += 8;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
- /* FIXME: should probably use 555 texture to get true grey */
- *destPtr++ = MGAPACKCOLOR565(src[0],src[0],src[0]) |
- ( MGAPACKCOLOR565(src[1],src[1],src[1]) << 16 );
- src += 2;
- }
- src += stride;
- }
- break;
- case GL_INTENSITY:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |
+ ( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
+ src += 8;
+ }
+ src += stride;
+ }
+ break;
+ case GL_LUMINANCE:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 1 ; j ; j-- ) {
+ /* FIXME: should probably use 555 texture to get true grey */
+ *destPtr++ = MGAPACKCOLOR565(src[0],src[0],src[0]) |
+ ( MGAPACKCOLOR565(src[1],src[1],src[1]) << 16 );
+ src += 2;
+ }
+ src += stride;
+ }
+ break;
+ case GL_INTENSITY:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 1 ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[0]) |
- ( MGAPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16 );
- src += 2;
- }
- src += stride;
- }
- break;
- case GL_ALPHA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[0]) |
+ ( MGAPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16 );
+ src += 2;
+ }
+ src += stride;
+ }
+ break;
+ case GL_ALPHA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 1 ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR4444(255,255,255,src[0]) |
- ( MGAPACKCOLOR4444(255,255,255,src[1]) << 16 );
- src += 2;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 2;
- stride = (image->Width - width) * 2;
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR4444(255,255,255,src[0]) |
+ ( MGAPACKCOLOR4444(255,255,255,src[1]) << 16 );
+ src += 2;
+ }
+ src += stride;
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 2;
+ stride = (image->Width - width) * 2;
+ for ( i = height ; i ; i-- ) {
+ for ( j = width >> 1 ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[1]) |
- ( MGAPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16 );
- src += 4;
- }
- src += stride;
- }
- break;
- default:
- goto format_error;
- }
- break;
- case 4:
- switch (image->Format) {
- case GL_RGB:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 3;
- stride = (image->Width - width) * 3;
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[1]) |
+ ( MGAPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16 );
+ src += 4;
+ }
+ src += stride;
+ }
+ break;
+ default:
+ goto format_error;
+ }
+ break;
+ case 4:
+ switch (image->Format) {
+ case GL_RGB:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 3;
+ stride = (image->Width - width) * 3;
+ for ( i = height ; i ; i-- ) {
+ for ( j = width ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2], 255);
- src += 3;
- }
- src += stride;
- }
- break;
- case GL_RGBA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 4;
- stride = (image->Width - width) * 4;
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2], 255);
+ src += 3;
+ }
+ src += stride;
+ }
+ break;
+ case GL_RGBA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 4;
+ stride = (image->Width - width) * 4;
+ for ( i = height ; i ; i-- ) {
+ for ( j = width ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2],src[3]);
- src += 4;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2],src[3]);
+ src += 4;
+ }
+ src += stride;
+ }
+ break;
+ case GL_LUMINANCE:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0], 255);
- src += 1;
- }
- src += stride;
- }
- break;
- case GL_INTENSITY:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0], 255);
+ src += 1;
+ }
+ src += stride;
+ }
+ break;
+ case GL_INTENSITY:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0],src[0]);
- src += 1;
- }
- src += stride;
- }
- break;
- case GL_ALPHA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0],src[0]);
+ src += 1;
+ }
+ src += stride;
+ }
+ break;
+ case GL_ALPHA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x );
+ stride = (image->Width - width);
+ for ( i = height ; i ; i-- ) {
+ for ( j = width ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR8888(255,255,255,src[0]);
- src += 1;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 2;
- stride = (image->Width - width) * 2;
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
+ *destPtr++ = MGAPACKCOLOR8888(255,255,255,src[0]);
+ src += 1;
+ }
+ src += stride;
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 2;
+ stride = (image->Width - width) * 2;
+ for ( i = height ; i ; i-- ) {
+ for ( j = width ; j ; j-- ) {
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],
- src[0],src[1]);
- src += 2;
- }
- src += stride;
- }
- break;
- default:
- goto format_error;
- }
- break;
- default:
- goto format_error;
+ *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],
+ src[0],src[1]);
+ src += 2;
+ }
+ src += stride;
+ }
+ break;
+ default:
+ goto format_error;
+ }
+ break;
+ default:
+ goto format_error;
}
return;
-format_error:
+ format_error:
- mgaError( "Unsupported texelBytes %i, image->Format %i\n",
- texelBytes, image->Format );
+ mgaError( "Unsupported texelBytes %i, image->Format %i\n",
+ (int)texelBytes, (int)image->Format );
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadd.c b/xc/lib/GL/mesa/src/drv/mga/mgadd.c
index ad56cbbc3..bdae9a2bf 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgadd.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgadd.c
@@ -61,11 +61,11 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
switch (name) {
case GL_VENDOR:
- return "Utah GLX";
+ return "Precision Insight";
case GL_RENDERER:
- if (MGA_IS_G200(mmesa)) return "GLX-MGA-G200";
- if (MGA_IS_G400(mmesa)) return "GLX-MGA-G400";
- return "GLX-MGA";
+ if (MGA_IS_G200(mmesa)) return "DRI-MGA-G200";
+ if (MGA_IS_G400(mmesa)) return "DRI-MGA-G400";
+ return "DRI-MGA";
default:
return 0;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadepth.c b/xc/lib/GL/mesa/src/drv/mga/mgadepth.c
index 0d55137d1..2dfc3e00c 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgadepth.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgadepth.c
@@ -43,20 +43,24 @@
#include "mgalib.h"
#endif
-
+#define DEPTH_SCALE 65535.0F
/*
* Return the address of the Z-buffer value for window coordinate (x,y):
*/
-#define Z_SETUP \
- mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
- __DRIscreenPrivate *sPriv = mmesa->driScreen; \
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
- GLdepth *zbstart = (GLdepth *)(sPriv->pFB + mgaScreen->depthOffset);\
- GLint zbpitch = mgaScreen->depthPitch
+#define Z_SETUP \
+ __DRIscreenPrivate *sPriv = mmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ GLuint height = dPriv->h; \
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
+ GLint zbpitch = mgaScreen->depthPitch; \
+ char *zbstart = (char *)(sPriv->pFB + \
+ mgaScreen->depthOffset + \
+ dPriv->x * 2 + \
+ dPriv->y * zbpitch)
#define Z_ADDRESS( X, Y ) \
- (zbstart + zbpitch * (Y) + (X))
+ (GLdepth *)(zbstart + zbpitch * (height - (Y)) + (X) * 2)
/**********************************************************************/
@@ -84,16 +88,18 @@ static GLuint mga_depth_test_span_generic( GLcontext* ctx,
const GLdepth z[],
GLubyte mask[] )
{
- Z_SETUP;
- GLdepth *zptr = Z_ADDRESS( x, y );
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
GLubyte *m = mask;
GLuint i;
GLuint passed = 0;
- LOCK_HARDWARE(mmesa);
+ LOCK_HARDWARE_QUIESCENT(mmesa);
+ {
+ Z_SETUP;
+ GLdepth *zptr = Z_ADDRESS( x, y );
- /* switch cases ordered from most frequent to less frequent */
- switch (ctx->Depth.Func) {
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
case GL_LESS:
if (ctx->Depth.Mask) {
/* Update Z buffer */
@@ -297,8 +303,8 @@ static GLuint mga_depth_test_span_generic( GLcontext* ctx,
}
break;
default:
+ }
}
-
UNLOCK_HARDWARE(mmesa);
return passed;
@@ -320,14 +326,16 @@ static void mga_depth_test_pixels_generic( GLcontext* ctx,
const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
- Z_SETUP;
- register GLdepth *zptr;
- register GLuint i;
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ LOCK_HARDWARE_QUIESCENT(mmesa);
+ {
+ Z_SETUP;
+ register GLdepth *zptr;
+ register GLuint i;
- LOCK_HARDWARE(mmesa);
- /* switch cases ordered from most frequent to less frequent */
- switch (ctx->Depth.Func) {
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
case GL_LESS:
if (ctx->Depth.Mask) {
/* Update Z buffer */
@@ -547,8 +555,8 @@ static void mga_depth_test_pixels_generic( GLcontext* ctx,
}
break;
default:
- }
-
+ }
+ }
UNLOCK_HARDWARE(mmesa);
}
@@ -570,27 +578,29 @@ static void mga_read_depth_span_float( GLcontext* ctx,
GLuint n, GLint x, GLint y,
GLfloat depth[] )
{
- Z_SETUP;
- GLdepth *zptr;
- GLfloat scale;
- GLuint i;
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ LOCK_HARDWARE_QUIESCENT(mmesa);
+ {
- LOCK_HARDWARE(mmesa);
+ Z_SETUP;
+ GLdepth *zptr;
+ GLfloat scale;
+ GLuint i;
- scale = 1.0F / DEPTH_SCALE;
+ scale = 1.0F / DEPTH_SCALE;
- if (ctx->Buffer->Depth) {
- zptr = Z_ADDRESS( x, y );
- for (i=0;i<n;i++) {
- depth[i] = (GLfloat) zptr[i] * scale;
+ if (ctx->ReadBuffer->Depth) {
+ zptr = Z_ADDRESS( x, y );
+ for (i=0;i<n;i++) {
+ depth[i] = (GLfloat) zptr[i] * scale;
+ }
}
- }
- else {
- for (i=0;i<n;i++) {
- depth[i] = 0.0F;
+ else {
+ for (i=0;i<n;i++) {
+ depth[i] = 0.0F;
+ }
}
}
-
UNLOCK_HARDWARE(mmesa);
}
@@ -607,30 +617,32 @@ static void mga_read_depth_span_int( GLcontext* ctx,
GLuint n, GLint x, GLint y,
GLdepth depth[] )
{
- Z_SETUP;
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ LOCK_HARDWARE_QUIESCENT(mmesa);
+ {
+ Z_SETUP;
- LOCK_HARDWARE(mmesa);
- if (ctx->Buffer->Depth) {
- GLdepth *zptr = Z_ADDRESS( x, y );
- MEMCPY( depth, zptr, n * sizeof(GLdepth) );
- }
- else {
- GLuint i;
- for (i=0;i<n;i++) {
- depth[i] = 0;
+ if (ctx->ReadBuffer->Depth) {
+ GLdepth *zptr = Z_ADDRESS( x, y );
+ MEMCPY( depth, zptr, n * sizeof(GLdepth) );
+ }
+ else {
+ GLuint i;
+ for (i=0;i<n;i++) {
+ depth[i] = 0;
+ }
}
}
-
UNLOCK_HARDWARE(mmesa);
}
void mgaDDInitDepthFuncs( GLcontext *ctx )
{
- ctx->Driver.ReadDepthSpanFloat = mga_read_depth_span_float;
- ctx->Driver.ReadDepthSpanInt = mga_read_depth_span_int;
- ctx->Driver.DepthTestSpan = mga_depth_test_span_generic;
- ctx->Driver.DepthTestPixels = mga_depth_test_pixels_generic;
+ ctx->Driver.ReadDepthSpan = mga_read_depth_span_float;
+ ctx->Driver.WriteDepthSpan = mga_read_depth_span_float;
+ ctx->Driver.ReadDepthPixels mga_read_depth_span_float;
+ ctx->Driver.WriteDepthPixels = mga_read_depth_span_float;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
index 8017e7f02..5e237bb01 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
@@ -380,6 +380,8 @@ static void mga_project_vertices( struct vertex_buffer *VB )
GLmatrix *mat = &ctx->Viewport.WindowMap;
GLfloat m[16];
+ REFRESH_DRAWABLE_INFO(mmesa);
+
m[MAT_SX] = mat->m[MAT_SX];
m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX - .5;
m[MAT_SY] = (- mat->m[MAT_SY]);
@@ -401,6 +403,8 @@ static void mga_project_clipped_vertices( struct vertex_buffer *VB )
GLmatrix *mat = &ctx->Viewport.WindowMap;
GLfloat m[16];
+ REFRESH_DRAWABLE_INFO(mmesa);
+
m[MAT_SX] = mat->m[MAT_SX];
m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX - .5;
m[MAT_SY] = (- mat->m[MAT_SY]);
@@ -507,18 +511,12 @@ void mgaDDFastPath( struct vertex_buffer *VB )
ctx->CVA.elt_mode = gl_reduce_prim[prim];
VB->EltPtr = &(MGA_DRIVER_DATA(VB)->clipped_elements);
- LOCK_HARDWARE( mmesa );
mga_project_clipped_vertices( VB ); /* clip->device space */
mga_render_elements_direct( VB ); /* render using new list */
- mgaFlushVerticesLocked( mmesa );
- UNLOCK_HARDWARE( mmesa );
}
} else {
- LOCK_HARDWARE( mmesa );
mga_project_vertices( VB ); /* clip->device space */
mga_render_elements_direct( VB ); /* render using orig list */
- mgaFlushVerticesLocked( mmesa );
- UNLOCK_HARDWARE( mmesa );
}
/* This indicates that there is no cached data to reuse.
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h b/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h
index 43caddcac..1fb177694 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h
@@ -87,6 +87,8 @@ static void TAG(mga_setup_full)( struct vertex_buffer *VB, GLuint do_cliptest )
STRIDE_F(tex0_data, tex0_stride);
}
if (TYPE & MGA_TEX1_BIT) {
+ /* Hits a second cache line.
+ */
f[CLIP_S1] = tex1_data[0];
f[CLIP_T1] = tex1_data[1];
STRIDE_F(tex1_data, tex1_stride);
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
index c1819924d..f9ef24310 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
@@ -14,114 +14,137 @@
#include "mgalog.h"
#include "mgavb.h"
#include "mgatris.h"
+#include "mgabuffers.h"
+
#include "drm.h"
#include <sys/ioctl.h>
+#define DEPTH_SCALE 65535.0F
+
static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
- int x1, int y1, int x2, int y2,
- unsigned long dest, unsigned int maccess)
+ unsigned long dest,
+ int length)
{
int retcode;
drm_mga_iload_t iload;
- drmBufPtr buf = mmesa->dma_buffer;
+ drmBufPtr buf = mmesa->iload_buffer;
iload.idx = buf->idx;
iload.destOrg = dest;
- iload.mAccess = maccess;
- iload.texture.x1 = x1;
- iload.texture.y1 = y1;
- iload.texture.y2 = x2;
- iload.texture.x2 = y2;
+ iload.length = length;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "DRM_IOCTL_MGA_ILOAD idx %d dst %x length %d\n",
+ iload.idx, iload.destOrg, iload.length);
+
if ((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_ILOAD, &iload))) {
printf("send iload retcode = %d\n", retcode);
exit(1);
}
-}
+ mmesa->iload_buffer = 0;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished iload dma put\n");
-static void mga_vertex_dma_ioctl(mgaContextPtr mmesa)
+}
+
+int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags )
{
- int retcode;
- int size = MGA_DMA_BUF_SZ;
- drmDMAReq dma;
- drmBufPtr buf = mmesa->dma_buffer;
+ drm_lock_t lock;
+
+ lock.flags = 0;
- dma.context = mmesa->hHWContext;
- dma.send_count = 1;
- dma.send_list = &buf->idx;
- dma.send_sizes = &size;
- dma.flags = DRM_DMA_WAIT;
- dma.request_count = 0;
- dma.request_size = 0;
- dma.request_list = 0;
- dma.request_sizes = 0;
-
- if ((retcode = drmDMA(mmesa->driFd, &dma))) {
- printf("send iload retcode = %d\n", retcode);
- exit(1);
+ if (mmesa->sarea->last_quiescent != mmesa->sarea->last_enqueue &&
+ flags & DRM_LOCK_QUIESCENT) {
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "mgaLockQuiescent\n");
+ lock.flags |= _DRM_LOCK_QUIESCENT;
+ }
+
+ if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
+ if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL;
+
+ if (!lock.flags)
+ return 0;
+
+ if(ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock)) {
+ printf("Lockupdate failed\n");
+ return -1;
}
+
+ if(flags & DRM_LOCK_QUIESCENT)
+ mmesa->sarea->last_quiescent = mmesa->sarea->last_enqueue;
+
+ return 0;
}
-
-static void mga_get_buffer_ioctl( mgaContextPtr mmesa )
+static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
{
int idx = 0;
int size = 0;
drmDMAReq dma;
int retcode;
+ drmBufPtr buf;
- fprintf(stderr, "Getting dma buffer\n");
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Getting dma buffer\n");
dma.context = mmesa->hHWContext;
dma.send_count = 0;
dma.send_list = NULL;
dma.send_sizes = NULL;
- dma.flags = DRM_DMA_WAIT;
+ dma.flags = 0;
dma.request_count = 1;
dma.request_size = MGA_DMA_BUF_SZ;
dma.request_list = &idx;
dma.request_sizes = &size;
-
- if ((retcode = drmDMA(mmesa->driFd, &dma))) {
- fprintf(stderr, "request drmDMA retcode = %d\n", retcode);
- exit(1);
- }
+ dma.granted_count = 0;
- mmesa->dma_buffer = &mmesa->mgaScreen->bufs->list[idx];
-}
-static void mga_swap_ioctl( mgaContextPtr mmesa )
-{
- int retcode;
- drm_mga_swap_t swap;
-
- if((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_SWAP, &swap))) {
- printf("send swap retcode = %d\n", retcode);
- exit(1);
- }
-}
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n",
+ dma.context, dma.request_count,
+ dma.request_size);
+ while (1) {
+ retcode = drmDMA(mmesa->driFd, &dma);
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "retcode %d sz %d idx %d count %d\n",
+ retcode,
+ dma.request_sizes[0],
+ dma.request_list[0],
+ dma.granted_count);
-static void mga_clear_ioctl( mgaContextPtr mmesa, int flags, int col, int zval )
-{
- int retcode;
- drm_mga_clear_t clear;
-
- clear.flags = flags;
- clear.clear_color = col;
- clear.clear_depth = zval;
-
- if((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_CLEAR, &clear))) {
- printf("send clear retcode = %d\n", retcode);
- exit(1);
+ if (retcode == 0 &&
+ dma.request_sizes[0] &&
+ dma.granted_count)
+ break;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "\n\nflush");
+ mgaUpdateLock( mmesa, DRM_LOCK_FLUSH );
}
-}
+ buf = &(mmesa->mgaScreen->bufs->list[idx]);
+ buf->used = 0;
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr,
+ "drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
+ "dma_buffer now: buf idx: %d size: %d used: %d\n",
+ dma.request_sizes[0], dma.request_list[0],
+ buf->idx, buf->total,
+ buf->used);
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished getbuffer\n");
+
+ return buf;
+}
@@ -130,52 +153,57 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- GLuint c = mmesa->ClearColor;
- mgaUI32 zval = (mgaUI32) (ctx->Depth.Clear * DEPTH_SCALE);
__DRIdrawablePrivate *dPriv = mmesa->driDrawable;
- int flags = 0;
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ drm_mga_clear_t clear;
+ int retcode;
int i;
+ static int nrclears;
- mgaMsg( 10, "mgaClear( %i, %i, %i, %i, %i )\n",
- mask, x, y, width, height );
-
-
- mgaFlushVertices( mmesa );
+ clear.flags = 0;
+ clear.clear_color = mmesa->ClearColor;
+ clear.clear_depth = (mgaUI32) (ctx->Depth.Clear * DEPTH_SCALE);
+ FLUSH_BATCH( mmesa );
+
+ if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
+ clear.flags |= MGA_FRONT;
+ mask &= ~DD_FRONT_LEFT_BIT;
+ }
- if (mask & GL_COLOR_BUFFER_BIT) {
- if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) {
- flags |= MGA_CLEAR_FRONT;
- mask &= ~GL_COLOR_BUFFER_BIT;
- } else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
- flags |= MGA_CLEAR_BACK;
- mask &= ~GL_COLOR_BUFFER_BIT;
- }
+ if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) {
+ clear.flags |= MGA_BACK;
+ mask &= ~DD_BACK_LEFT_BIT;
}
- if ((flags & GL_DEPTH_BUFFER_BIT) && ctx->Depth.Mask) {
- flags |= MGA_CLEAR_DEPTH;
- mask &= ~GL_DEPTH_BUFFER_BIT;
+ if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
+ clear.flags |= MGA_DEPTH;
+ mask &= ~DD_DEPTH_BIT;
}
- if (!flags)
+ if (!clear.flags)
return mask;
LOCK_HARDWARE( mmesa );
-
+
+ if (mmesa->dirty_cliprects)
+ mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK));
+
/* flip top to bottom */
cy = dPriv->h-cy-ch;
cx += mmesa->drawX;
cy += mmesa->drawY;
- for (i = 0 ; i < dPriv->numClipRects ; ) {
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Clear, bufs %x nbox %d\n",
+ (int)clear.flags, (int)mmesa->numClipRects);
- /* Use the cliprects for the current draw buffer
- */
+ for (i = 0 ; i < mmesa->numClipRects ; )
+ {
int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, mmesa->numClipRects);
XF86DRIClipRectRec *box = mmesa->pClipRects;
- xf86drmClipRectRec *b = mmesa->sarea->boxes;
- mmesa->sarea->nbox = nr - i;
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ int n = 0;
if (!all) {
for ( ; i < nr ; i++) {
@@ -196,16 +224,37 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
b->x2 = x + w;
b->y2 = y + h;
b++;
+ n++;
}
} else {
- for ( ; i < nr ; i++)
- *b++ = *(xf86drmClipRectRec *)&box[i];
+ for ( ; i < nr ; i++) {
+ *b++ = *(drm_clip_rect_t *)&box[i];
+ n++;
+ }
}
- mga_clear_ioctl( mmesa, mask, c, zval );
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr,
+ "DRM_IOCTL_MGA_CLEAR flag 0x%x color %x depth %x nbox %d\n",
+ clear.flags, clear.clear_color,
+ clear.clear_depth, mmesa->sarea->nbox);
+
+
+ mmesa->sarea->nbox = n;
+
+ retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_CLEAR, &clear);
+ if (retcode) {
+ printf("send clear retcode = %d\n", retcode);
+ exit(1);
+ }
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished clear %d\n", ++nrclears);
}
UNLOCK_HARDWARE( mmesa );
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+
return mask;
}
@@ -218,50 +267,62 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
void mgaSwapBuffers( mgaContextPtr mmesa )
{
__DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ XF86DRIClipRectPtr pbox;
+ int nbox;
+ drm_mga_swap_t swap;
+ static int nrswaps;
+ int retcode;
int i;
+ int tmp;
- mgaFlushVertices( mmesa );
- LOCK_HARDWARE( mmesa );
- {
- /* Use the frontbuffer cliprects
- */
- XF86DRIClipRectPtr pbox = dPriv->pClipRects;
- int nbox = dPriv->numClipRects;
+ FLUSH_BATCH( mmesa );
- for (i = 0 ; i < nbox ; )
- {
- int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
- XF86DRIClipRectRec *b = (XF86DRIClipRectRec *)mmesa->sarea->boxes;
- mmesa->sarea->nbox = nr - i;
+ LOCK_HARDWARE( mmesa );
+
+ /* Use the frontbuffer cliprects
+ */
+ if (mmesa->dirty_cliprects & MGA_FRONT)
+ mgaUpdateRects( mmesa, MGA_FRONT );
+
- for ( ; i < nr ; i++)
- *b++ = pbox[i];
-
- mga_swap_ioctl( mmesa );
- }
- }
+ pbox = dPriv->pClipRects;
+ nbox = dPriv->numClipRects;
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "swap, nbox %d\n", nbox);
-#if 1
- UNLOCK_HARDWARE(mmesa);
-#else
+ for (i = 0 ; i < nbox ; )
{
- last_enqueue = mmesa->sarea->lastEnqueue;
- last_dispatch = mmesa->sarea->lastDispatch;
- UNLOCK_HARDWARE;
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
+ XF86DRIClipRectRec *b = (XF86DRIClipRectRec *)mmesa->sarea->boxes;
+
+ mmesa->sarea->nbox = nr - i;
+
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
- /* Throttle runaway apps - there should be an easier way to sleep
- * on dma without locking out the rest of the system!
- */
- if (mmesa->lastSwap > last_dispatch) {
- drmGetLock(mmesa->driFd, mmesa->hHWContext, DRM_LOCK_QUIESCENT);
- DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
+ if (0)
+ fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n");
+
+ if((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_SWAP, &swap))) {
+ printf("send swap retcode = %d\n", retcode);
+ exit(1);
}
- mmesa->lastSwap = last_enqueue;
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished swap %d\n", ++nrswaps);
}
-#endif
+
+ tmp = GET_ENQUEUE_AGE(mmesa);
+
+ UNLOCK_HARDWARE( mmesa );
+
+ if (GET_DISPATCH_AGE(mmesa) < mmesa->lastSwap)
+ mgaWaitAge(mmesa, mmesa->lastSwap);
+
+ mmesa->lastSwap = tmp;
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
}
@@ -269,53 +330,243 @@ void mgaSwapBuffers( mgaContextPtr mmesa )
*/
void mgaDDFinish( GLcontext *ctx )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- drmGetLock(mmesa->driFd, mmesa->hHWContext, DRM_LOCK_QUIESCENT);
- DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (mmesa->sarea->last_quiescent != mmesa->sarea->last_enqueue) {
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "mgaRegetLockQuiescent\n");
+
+ LOCK_HARDWARE( mmesa );
+ mgaUpdateLock( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH);
+ UNLOCK_HARDWARE( mmesa );
+
+ mmesa->sarea->last_quiescent = mmesa->sarea->last_enqueue;
+ }
}
+void mgaWaitAgeLocked( mgaContextPtr mmesa, int age )
+{
+ if (GET_DISPATCH_AGE(mmesa) < age) {
+ if (0) fprintf(stderr, "\n\n\nmgaWaitAgeLocked\n");
+ mgaUpdateLock( mmesa, DRM_LOCK_FLUSH );
+ }
+}
+void mgaWaitAge( mgaContextPtr mmesa, int age )
+{
+ if (GET_DISPATCH_AGE(mmesa) < age) {
+ LOCK_HARDWARE(mmesa);
+ if (GET_DISPATCH_AGE(mmesa) < age) {
+ if (0) fprintf(stderr, "\n\n\nmgaWaitAge\n");
+ mgaUpdateLock( mmesa, DRM_LOCK_FLUSH );
+ }
+ UNLOCK_HARDWARE(mmesa);
+ }
+}
-void mgaFlushVertices( mgaContextPtr mmesa )
+
+static int intersect_rect( drm_clip_rect_t *out,
+ drm_clip_rect_t *a,
+ drm_clip_rect_t *b )
{
- LOCK_HARDWARE( mmesa );
- mgaFlushVerticesLocked( mmesa );
- UNLOCK_HARDWARE( mmesa );
+ *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;
}
+
+
+static void age_mmesa( mgaContextPtr mmesa, int age )
+{
+ if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->age = age;
+ if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->age = age;
+}
+
void mgaFlushVerticesLocked( mgaContextPtr mmesa )
{
- XF86DRIClipRectPtr pbox = mmesa->pClipRects;
+ drm_clip_rect_t *pbox = (drm_clip_rect_t *)mmesa->pClipRects;
int nbox = mmesa->numClipRects;
+ drmBufPtr buffer = mmesa->vertex_dma_buffer;
+ drm_mga_vertex_t vertex;
int i;
- if (mmesa->dirty)
+ if (!buffer)
+ return;
+
+ if (mmesa->dirty_cliprects & mmesa->draw_buffer)
+ mgaUpdateRects( mmesa, mmesa->draw_buffer );
+
+ if (mmesa->dirty & ~MGA_UPLOAD_CLIPRECTS)
mgaEmitHwStateLocked( mmesa );
- for (i = 0 ; i < nbox ; )
+ /* FIXME: Workaround bug in kernel module.
+ */
+ mmesa->sarea->dirty |= MGA_UPLOAD_CTX;
+
+ /* FIXME: dstorg bug
+ */
+ if (0)
+ if (mmesa->lastX != mmesa->drawX || mmesa->lastY != mmesa->drawY)
+ fprintf(stderr, "****** last: %d,%d current: %d,%d\n",
+ mmesa->lastX, mmesa->lastY,
+ mmesa->drawX, mmesa->drawY);
+
+
+ mmesa->vertex_dma_buffer = 0;
+ vertex.idx = buffer->idx;
+ vertex.used = buffer->used;
+ vertex.discard = 0;
+
+ if (!nbox)
+ vertex.used = 0;
+
+ if (nbox >= MGA_NR_SAREA_CLIPRECTS)
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+
+ if (!vertex.used || !(mmesa->dirty & MGA_UPLOAD_CLIPRECTS))
{
- int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox);
- XF86DRIClipRectRec *b = (XF86DRIClipRectRec *)mmesa->sarea->boxes;
- mmesa->sarea->nbox = nr - i;
+ if (nbox == 1)
+ mmesa->sarea->nbox = 0;
+ else
+ mmesa->sarea->nbox = nbox;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox);
+
+ vertex.discard = 1;
+ ioctl(mmesa->driFd, DRM_IOCTL_MGA_VERTEX, &vertex);
+ age_mmesa(mmesa, mmesa->sarea->last_enqueue);
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox);
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+
+ if (mmesa->scissor) {
+ mmesa->sarea->nbox = 0;
+
+ for ( ; i < nr ; i++) {
+ *b = pbox[i];
+ if (intersect_rect(b, b, &mmesa->scissor_rect)) {
+ mmesa->sarea->nbox++;
+ b++;
+ }
+ }
+
+ /* Culled?
+ */
+ if (!mmesa->sarea->nbox) {
+ if (nr < nbox) continue;
+ vertex.used = 0;
+ }
+ } else {
+ mmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
+ }
- for ( ; i < nr ; i++)
- *b++ = pbox[i];
-
- mga_vertex_dma_ioctl( mmesa );
+ /* Finished with the buffer?
+ */
+ if (nr == nbox)
+ vertex.discard = 1;
+
+ mmesa->sarea->dirty |= MGA_UPLOAD_CLIPRECTS;
+ ioctl(mmesa->driFd, DRM_IOCTL_MGA_VERTEX, &vertex);
+ age_mmesa(mmesa, mmesa->sarea->last_enqueue);
+ }
+ }
+
+ mmesa->dirty &= ~MGA_UPLOAD_CLIPRECTS;
+}
+
+void mgaFlushVertices( mgaContextPtr mmesa )
+{
+ LOCK_HARDWARE( mmesa );
+ mgaFlushVerticesLocked( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+}
+
+
+mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
+{
+ int bytes = dwords * 4;
+ mgaUI32 *head;
+
+ if (!mmesa->vertex_dma_buffer) {
+ LOCK_HARDWARE( mmesa );
+ mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+ } else if (mmesa->vertex_dma_buffer->used + bytes >
+ mmesa->vertex_dma_buffer->total) {
+ LOCK_HARDWARE( mmesa );
+ mgaFlushVerticesLocked( mmesa );
+ mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+ }
+
+ head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address +
+ mmesa->vertex_dma_buffer->used);
+
+ mmesa->vertex_dma_buffer->used += bytes;
+ return head;
+}
- break; /* fix dma multiple dispatch */
+
+void mgaFireILoadLocked( mgaContextPtr mmesa,
+ GLuint offset, GLuint length )
+{
+ if (!mmesa->iload_buffer) {
+ fprintf(stderr, "mgaFireILoad: no buffer\n");
+ return;
}
- mga_get_buffer_ioctl( mmesa );
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "mgaFireILoad idx %d ofs 0x%x length %d\n",
+ mmesa->iload_buffer->idx, (int)offset, (int)length );
+
+ mga_iload_dma_ioctl( mmesa, offset, length );
}
+void mgaGetILoadBufferLocked( mgaContextPtr mmesa )
+{
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "mgaGetIloadBuffer (buffer now %p)\n",
+ mmesa->iload_buffer);
+
+ mmesa->iload_buffer = mga_get_buffer_ioctl( mmesa );
+}
+
+
+static void mgaDDFlush( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ FLUSH_BATCH( mmesa );
+
+ /* This may be called redundantly - dispatch_age may trail what
+ * has actually been sent and processed by the hardware.
+ */
+ if (GET_DISPATCH_AGE( mmesa ) < mmesa->sarea->last_enqueue) {
+ LOCK_HARDWARE( mmesa );
+ if (0) fprintf(stderr, "mgaDDFlush\n");
+ mgaUpdateLock( mmesa, DRM_LOCK_FLUSH );
+ UNLOCK_HARDWARE( mmesa );
+ }
+}
void mgaDDInitIoctlFuncs( GLcontext *ctx )
{
ctx->Driver.Clear = mgaClear;
- ctx->Driver.Flush = 0;
+ ctx->Driver.Flush = mgaDDFlush;
ctx->Driver.Finish = mgaDDFinish;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
index 22ca26e17..13cec59d7 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
@@ -9,6 +9,21 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
void mgaSwapBuffers( mgaContextPtr mmesa );
+
+
+mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
+
+
+void mgaGetILoadBufferLocked( mgaContextPtr mmesa );
+
+
+void mgaFireILoadLocked( mgaContextPtr mmesa,
+ GLuint offset, GLuint length );
+
+void mgaWaitAgeLocked( mgaContextPtr mmesa, int age );
+void mgaWaitAge( mgaContextPtr mmesa, int age );
+int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags );
+
void mgaFlushVertices( mgaContextPtr mmesa );
void mgaFlushVerticesLocked( mgaContextPtr mmesa );
@@ -19,5 +34,11 @@ void mgaDDFinish( GLcontext *ctx );
void mgaDDInitIoctlFuncs( GLcontext *ctx );
+#define FLUSH_BATCH(mmesa) do { \
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \
+ fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
+ if (mmesa->vertex_dma_buffer) mgaFlushVertices(mmesa); \
+} while (0)
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgalib.h b/xc/lib/GL/mesa/src/drv/mga/mgalib.h
index 4600a69a0..176c126bd 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgalib.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgalib.h
@@ -36,6 +36,7 @@
#include "types.h"
+#include "drm.h"
#include "mgacommon.h"
#include "mm.h"
#include "mgalog.h"
@@ -43,7 +44,6 @@
#include "mgatex.h"
#include "mgavb.h"
-#include "mga_drm_public.h"
#include "mga_xmesa.h"
@@ -51,11 +51,8 @@
#define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
#define MGA_GET_FIELD(field, val) ((val & ~(field ## _MASK)) >> (field ## _SHIFT))
-#define MGA_CHIP_MGAG200 0
-#define MGA_CHIP_MGAG400 1
-
-#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CHIP_MGAG200)
-#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CHIP_MGAG400)
+#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G200)
+#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400)
/* SoftwareFallback
@@ -65,6 +62,7 @@
*/
#define MGA_FALLBACK_TEXTURE 0x1
#define MGA_FALLBACK_BUFFER 0x2
+#define MGA_FALLBACK_STIPPLE 0x3
/* For mgaCtx->new_state.
@@ -97,17 +95,30 @@ typedef void (*mga_interp_func)( GLfloat t,
#define MGA_PF_8888 (10 << 4)
#define MGA_PF_HASALPHA (8 << 4)
+
+
+/* Reasons why the GL_BLEND fallback mightn't work:
+ */
+#define MGA_BLEND_ENV_COLOR 0x1
+#define MGA_BLEND_MULTITEX 0x2
+
+
struct mga_context_t {
GLcontext *glCtx;
- /* Hardware state - moved from mgabuf.h
- */
- mgaUI32 Setup[MGA_CTX_SETUP_SIZE];
- /* Variable sized vertices
+ /* Bookkeeping for texturing
*/
- mgaUI32 vertsize;
+ int lastTexHeap;
+ struct mga_texture_object_s TexObjList[MGA_NR_TEX_HEAPS];
+ struct mga_texture_object_s SwappedOut;
+ struct mga_texture_object_s *CurrentTexObj[2];
+ memHeap_t *texHeap[MGA_NR_TEX_HEAPS];
+ int c_texupload;
+ int c_texusage;
+ int tex_thrash;
+
/* Map GL texture units onto hardware.
*/
@@ -116,68 +127,84 @@ struct mga_context_t {
mgaUI32 tex_dest[2];
+ /* Manage fallbacks
+ */
+ mgaUI32 IndirectTriangles;
+ int Fallback;
- /* bookkeeping for textureing */
- struct mga_texture_object_s TexObjList;
- struct mga_texture_object_s SwappedOut;
- struct mga_texture_object_s *CurrentTexObj[2];
-
-
- /* shared texture palette */
- mgaUI16 GlobalPalette[256];
-
- int Fallback; /* or'ed values of FALLBACK_* */
- /* Support for CVA and the fast paths */
+ /* Support for CVA and the fastpath
+ */
unsigned int setupdone;
unsigned int setupindex;
unsigned int renderindex;
unsigned int using_fast_path;
- unsigned int using_immediate_fast_path;
mga_interp_func interp;
- /* Shortcircuit some state changes */
+
+ /* Support for limited GL_BLEND fallback
+ */
+ unsigned int blend_flags;
+ unsigned int envcolor;
+
+
+ /* Shortcircuit some state changes
+ */
points_func PointsFunc;
line_func LineFunc;
triangle_func TriangleFunc;
quad_func QuadFunc;
- /* Manage our own state */
+
+ /* Manage driver and hardware state
+ */
GLuint new_state;
GLuint dirty;
-
- GLubyte clearcolor[4];
- GLushort MonoColor;
- GLushort ClearColor;
+ GLuint Setup[MGA_CTX_SETUP_SIZE];
+ GLuint warp_pipe;
+ GLuint vertsize;
+ GLushort MonoColor;
+ GLushort ClearColor;
+ GLuint poly_stipple;
- /* DRI stuff
+ /* Dma buffers
*/
- drmBufPtr dma_buffer;
+ drmBufPtr vertex_dma_buffer;
+ drmBufPtr iload_buffer;
- GLframebuffer *glBuffer;
- memHeap_t *texHeap;
+
+ /* Drawable, cliprect and scissor information
+ */
+ int dirty_cliprects; /* which sets of cliprects are uptodate? */
+ int draw_buffer; /* which buffer are we rendering to */
+ int drawOffset; /* draw buffer address in space */
+ int read_buffer;
+ int readOffset;
+ int drawX, drawY; /* origin of drawable in draw buffer */
+ int lastX, lastY; /* detect DSTORG bug */
+ GLuint numClipRects; /* cliprects for the draw buffer */
+ XF86DRIClipRectPtr pClipRects;
+ XF86DRIClipRectRec draw_rect;
+ drm_clip_rect_t scissor_rect;
+ int scissor;
- GLuint needClip;
- GLuint warp_pipe;
- /* These refer to the current draw (front vs. back) buffer:
+ /* Texture aging and DMA based aging.
*/
- int drawOffset; /* draw buffer address in agp space */
- int drawX; /* origin of drawable in draw buffer */
- int drawY;
- GLuint numClipRects; /* cliprects for that buffer */
- XF86DRIClipRectPtr pClipRects;
+ unsigned int texAge[MGA_NR_TEX_HEAPS];/* texture LRU age */
+ int dirtyAge; /* buffer age for synchronization */
+ int lastSwap; /* throttling runaway apps */
- int texAge;
- XF86DRIClipRectRec draw_rect;
+ /* Mirrors of some DRI state.
+ */
+ GLframebuffer *glBuffer;
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
Display *display;
-
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
mgaScreenPrivate *mgaScreen;
@@ -191,16 +218,12 @@ typedef struct {
/* dma stuff */
mgaUI32 systemTexture;
- mgaUI32 noSetupDma;
mgaUI32 default32BitTextures;
- mgaUI32 swapBuffersCount;
/* options */
mgaUI32 nullprims; /* skip all primitive generation */
- mgaUI32 noFallback; /* don't fall back to software, do
- best-effort rendering */
- mgaUI32 skipDma; /* don't send anything to the hardware */
+ mgaUI32 noFallback;
/* performance counters */
mgaUI32 c_textureUtilization;
@@ -240,10 +263,12 @@ extern mgaGlx_t mgaglx;
extern int MGA_DEBUG;
#endif
-#define MGA_DEBUG_ALWAYS_SYNC 0x1
-#define MGA_DEBUG_VERBOSE_MSG 0x2
-#define MGA_DEBUG_VERBOSE_LRU 0x4
-#define MGA_DEBUG_VERBOSE_DRI 0x8
+#define DEBUG_ALWAYS_SYNC 0x1
+#define DEBUG_VERBOSE_MSG 0x2
+#define DEBUG_VERBOSE_LRU 0x4
+#define DEBUG_VERBOSE_DRI 0x8
+#define DEBUG_VERBOSE_IOCTL 0x10
+#define DEBUG_VERBOSE_2D 0x20
static __inline__ mgaUI32 mgaPackColor(mgaUI32 format,
mgaUI8 r, mgaUI8 g,
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
index 38e3cdde8..9bf62391c 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
@@ -5,70 +5,99 @@
#include "mgalog.h"
#include "mgaspan.h"
+#define DBG 0
+
#define LOCAL_VARS \
- mgaContextPtr mmesa = MGA_CONTEXT( ctx ); \
__DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
- __DRIscreenPrivate *sPriv = mmesa->driScreen; \
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
- GLuint pitch = mgaScreen->backPitch; \
+ __DRIscreenPrivate *sPriv = mmesa->driScreen; \
+ GLuint pitch = mgaScreen->frontPitch; \
GLuint height = dPriv->h; \
+ char *read_buf = (char *)(sPriv->pFB + \
+ mmesa->readOffset + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch); \
char *buf = (char *)(sPriv->pFB + \
mmesa->drawOffset + \
dPriv->x * 2 + \
+ dPriv->y * pitch); \
+ GLushort p = MGA_CONTEXT( ctx )->MonoColor; \
+ (void) read_buf; (void) buf; (void) p
+
+
+
+#define LOCAL_DEPTH_VARS \
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
+ __DRIscreenPrivate *sPriv = mmesa->driScreen; \
+ GLuint pitch = mgaScreen->frontPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ mgaScreen->depthOffset + \
+ dPriv->x * 2 + \
dPriv->y * pitch)
-#define INIT_MONO_PIXEL(p) \
- GLushort p = MGA_CONTEXT( ctx )->MonoColor;
+#define INIT_MONO_PIXEL(p)
-#define CLIPPIXEL(_x,_y) (_x >= minx && _x <= maxx && \
- _y >= miny && _y <= maxy)
+#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
+ _y >= miny && _y < maxy)
-#define CLIPSPAN(_x,_y,_n,_x1,_n1) \
+#define CLIPSPAN(_x,_y,_n,_x1,_n1,_i) \
if (_y < miny || _y >= maxy) _n1 = 0, _x1 = x; \
else { \
_n1 = _n; \
_x1 = _x; \
- if (_x1 < minx) _n1 -= (minx - _x1), _x1 = minx; \
- if (_x1 + _n1 > maxx) n1 -= (_x1 + n1 - maxx); \
+ if (_x1 < minx) _i += (minx - _x1), _x1 = minx; \
+ if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1; \
}
-
+#define HW_LOCK() \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ LOCK_HARDWARE_QUIESCENT(mmesa);
#define HW_CLIPLOOP() \
do { \
int _nc = mmesa->numClipRects; \
- LOCK_HARDWARE_QUIESCENT(mmesa); \
while (_nc--) { \
- int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \
- int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \
- int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \
+ int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \
+ int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \
+ int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \
int maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY;
-
#define HW_ENDCLIPLOOP() \
} \
- UNLOCK_HARDWARE(mmesa); \
} while (0)
+#define HW_UNLOCK() \
+ UNLOCK_HARDWARE(mmesa);
+
+
+
-#define Y_FLIP(_y) (height - _y)
+
+
+
+/* 16 bit, 565 rgb color spanline and pixel functions
+ */
+#define Y_FLIP(_y) (height - _y - 1)
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0x1f) << 11) | \
- ((g & 0x3f) << 5) | \
- ((b & 0x1f)))
+ *(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; \
- rgba[1] = (p >> 5) & 0x3f; \
- rgba[2] = (p >> 0) & 0x1f; \
+ GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 8) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p << 3) & 0xf8; \
rgba[3] = 0; /* or 255? */ \
} while(0)
@@ -78,21 +107,21 @@ do { \
-
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0x1f) << 10) | \
- ((g & 0x1f) << 5) | \
- ((b & 0x1f)))
-
+/* 15 bit, 555 rgb color spanline and pixel functions
+ */
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \
+ ((g & 0xf8) << 3) | \
+ ((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 >> 10) & 0x1f; \
- rgba[1] = (p >> 5) & 0x1f; \
- rgba[2] = (p >> 0) & 0x1f; \
+ GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 7) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xf8; \
+ rgba[2] = (p << 3) & 0xf8; \
rgba[3] = 0; /* or 255? */ \
} while(0)
@@ -101,27 +130,19 @@ do { \
-#if 0
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLuint *)(buf + _x*4 + _y*pitch) = ( ((r) << 16) | \
- ((g) << 8) | \
- ((b)))
+/* 16 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLdepth *)(buf + _x*2 + _y*pitch) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLdepth *)(buf + _x*2 + _y*pitch);
+
+#define TAG(x) mga##x##_16
+#include "depthtmp.h"
-#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] = 0; /* or 255? */ \
-} while(0)
-#define TAG(x) mga##x##_888
-#include "spantmp.h"
-#endif
void mgaDDInitSpanFuncs( GLcontext *ctx )
{
@@ -143,6 +164,11 @@ void mgaDDInitSpanFuncs( GLcontext *ctx )
ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_555;
}
+ ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_16;
+ ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_16;
+ ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_16;
+ ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_16;
+
ctx->Driver.WriteCI8Span =NULL;
ctx->Driver.WriteCI32Span =NULL;
ctx->Driver.WriteMonoCISpan =NULL;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.c b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
index ff9063e0b..0dacd7646 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgastate.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
@@ -16,7 +16,7 @@
#include "mgavb.h"
#include "mgatris.h"
#include "mgaregs.h"
-#include "mga_drm_public.h"
+#include "mgabuffers.h"
static void mgaUpdateZMode(const GLcontext *ctx)
{
@@ -60,17 +60,20 @@ static void mgaUpdateZMode(const GLcontext *ctx)
static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
static void mgaDDBlendEquation(GLcontext *ctx, GLenum mode)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
@@ -78,6 +81,7 @@ static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
GLenum dfactorRGB, GLenum sfactorA,
GLenum dfactorA )
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
@@ -87,6 +91,7 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname,
const GLfloat *param)
{
if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
}
}
@@ -95,6 +100,7 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname,
static void mgaDDShadeModel(GLcontext *ctx, GLenum mode)
{
if (1) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
mgaMsg(8, "mgaDDShadeModel: %x\n", mode);
}
@@ -103,11 +109,13 @@ static void mgaDDShadeModel(GLcontext *ctx, GLenum mode)
static void mgaDDDepthFunc(GLcontext *ctx, GLenum func)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
}
static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
}
@@ -134,6 +142,7 @@ static void mgaUpdateFogAttrib( GLcontext *ctx )
static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_FOG;
}
@@ -148,10 +157,11 @@ static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
static void mgaUpdateAlphaMode(GLcontext *ctx)
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
int a = 0;
/* determine source of alpha for blending and testing */
- if ( !ctx->Texture.Enabled || (mmesa->Fallback & MGA_FALLBACK_TEXTURE))
+ if ( !ctx->Texture.Enabled )
a |= AC_alphasel_diffused;
else {
switch (ctx->Texture.Unit[0].EnvMode) {
@@ -168,7 +178,7 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
}
- /* alpha test control - disabled by default.
+ /* alpha test control.
*/
if (ctx->Color.AlphaEnabled) {
GLubyte ref = ctx->Color.AlphaRef;
@@ -219,13 +229,13 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
case GL_ONE_MINUS_SRC_ALPHA:
a |= AC_src_om_src_alpha; break;
case GL_DST_ALPHA:
- if (0) /*(mgaScreen->Attrib & MGA_PF_HASALPHA)*/
+ if (mgaScreen->Attrib & MGA_PF_HASALPHA)
a |= AC_src_dst_alpha;
else
a |= AC_src_one;
break;
case GL_ONE_MINUS_DST_ALPHA:
- if (0) /*(mgaScreen->Attrib & MGA_PF_HASALPHA)*/
+ if (mgaScreen->Attrib & MGA_PF_HASALPHA)
a |= AC_src_om_dst_alpha;
else
a |= AC_src_zero;
@@ -250,13 +260,13 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
case GL_ONE_MINUS_SRC_COLOR:
a |= AC_dst_om_src_color; break;
case GL_DST_ALPHA:
- if (0) /*(mgaDB->Attrib & MGA_PF_HASALPHA)*/
+ if (mgaScreen->Attrib & MGA_PF_HASALPHA)
a |= AC_dst_dst_alpha;
else
a |= AC_dst_one;
break;
case GL_ONE_MINUS_DST_ALPHA:
- if (0) /*(mgaScreen->Attrib & MGA_PF_HASALPHA)*/
+ if (mgaScreen->Attrib & MGA_PF_HASALPHA)
a |= AC_dst_om_dst_alpha;
else
a |= AC_dst_zero;
@@ -282,50 +292,44 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
* Hardware clipping
*/
-static void mgaUpdateClipping(const GLcontext *ctx)
+void mgaUpdateClipping(const GLcontext *ctx)
{
-#if 0
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
- int x1,x2,y1,y2;
-
- if ( ctx->Scissor.Enabled) {
- x1 = ctx->Scissor.X;
- x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
- y1 = dPriv->Height - ctx->Scissor.Y - ctx->Scissor.Height;
- y2 = dPriv->Height - ctx->Scissor.Y - 1;
- } else {
- x1 = 0;
- y1 = 0;
- x2 = mgaDB->Width-1;
- y2 = mgaDB->Height-1;
- }
-
- if (x1 < 0) x1 = 0;
- if (y1 < 0) y1 = 0;
- if (x2 >= mgaDB->Width) x2 = mgaDB->Width-1;
- if (y2 >= mgaDB->Height) y2 = mgaDB->Height-1;
-
- if (x1 > x2 || y1 > y2) {
- x1 = 0; x2 = 0;
- y2 = 0; y1 = 1;
- }
-
-
- mmesa->Setup[MGA_CTXREG_CXBNDRY] = (MGA_FIELD(CXB_cxright,x2) |
- MGA_FIELD(CXB_cxleft,x1));
- mmesa->Setup[MGA_CTXREG_YTOP] = y1*mgaDB->Pitch;
- mmesa->Setup[MGA_CTXREG_YBOT] = y2*mgaDB->Pitch;
-
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- mmesa->dirty |= MGA_UPLOAD_CTX;
-#endif
+ if (mmesa->driDrawable)
+ {
+ int x1 = mmesa->driDrawable->x + ctx->Scissor.X;
+ int y1 = mmesa->driDrawable->y + mmesa->driDrawable->h - (ctx->Scissor.Y+
+ ctx->Scissor.Height);
+ int x2 = mmesa->driDrawable->x + ctx->Scissor.X+ctx->Scissor.Width;
+ int y2 = mmesa->driDrawable->y + mmesa->driDrawable->h - ctx->Scissor.Y;
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+
+ mmesa->scissor_rect.x1 = x1;
+ mmesa->scissor_rect.y1 = y1;
+ mmesa->scissor_rect.x2 = x2;
+ mmesa->scissor_rect.y2 = y2;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_2D)
+ fprintf(stderr, "SET SCISSOR %d,%d-%d,%d\n",
+ mmesa->scissor_rect.x1,
+ mmesa->scissor_rect.y1,
+ mmesa->scissor_rect.x2,
+ mmesa->scissor_rect.y2);
+
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+ }
}
static void mgaDDScissor( GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h )
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CLIP;
}
@@ -339,35 +343,6 @@ static void mgaDDDither(GLcontext *ctx, GLboolean enable)
}
-static GLboolean mgaDDSetBuffer(GLcontext *ctx, GLenum mode )
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-
- mmesa->Fallback &= ~MGA_FALLBACK_BUFFER;
-
- if (mode == GL_FRONT_LEFT)
- {
- mmesa->drawOffset = mmesa->mgaScreen->fbOffset;
- mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->mgaScreen->fbOffset;
- mmesa->dirty |= MGA_UPLOAD_CTX;
- mgaXMesaSetFrontClipRects( mmesa );
- return GL_TRUE;
- }
- else if (mode == GL_BACK_LEFT)
- {
- mmesa->drawOffset = mmesa->mgaScreen->backOffset;
- mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->mgaScreen->backOffset;
- mmesa->dirty |= MGA_UPLOAD_CTX;
- mgaXMesaSetBackClipRects( mmesa );
- return GL_TRUE;
- }
- else
- {
- mmesa->Fallback |= MGA_FALLBACK_BUFFER;
- return GL_FALSE;
- }
-}
-
static void mgaDDSetColor(GLcontext *ctx,
@@ -376,7 +351,7 @@ static void mgaDDSetColor(GLcontext *ctx,
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- mmesa->MonoColor = mgaPackColor( mmesa->mgaScreen->fbFormat,
+ mmesa->MonoColor = mgaPackColor( mmesa->mgaScreen->Attrib,
r, g, b, a );
}
@@ -387,7 +362,7 @@ static void mgaDDClearColor(GLcontext *ctx,
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->fbFormat,
+ mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->Attrib,
r, g, b, a );
}
@@ -426,6 +401,7 @@ static void mgaUpdateCull( GLcontext *ctx )
static void mgaDDCullFaceFrontFace(GLcontext *ctx, GLenum mode)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CULL;
}
@@ -461,6 +437,7 @@ static GLboolean mgaDDColorMask(GLcontext *ctx,
}
if (mmesa->Setup[MGA_CTXREG_PLNWT] != mask) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
mmesa->Setup[MGA_CTXREG_PLNWT] = mask;
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_MASK;
mmesa->dirty |= MGA_UPLOAD_CTX;
@@ -470,6 +447,85 @@ static GLboolean mgaDDColorMask(GLcontext *ctx,
}
/* =============================================================
+ * Polygon stipple
+ *
+ * The mga supports a subset of possible 4x4 stipples natively, GL
+ * wants 32x32. Fortunately stipple is usually a repeating pattern.
+ * Could also consider using a multitexturing mechanism for this, but
+ * that has real issues, too.
+ */
+static int mgaStipples[16] = {
+ 0xffff,
+ 0xa5a5,
+ 0x5a5a,
+ 0xa0a0,
+ 0x5050,
+ 0x0a0a,
+ 0x0505,
+ 0x8020,
+ 0x0401,
+ 0x1040,
+ 0x0208,
+ 0x0802,
+ 0x4010,
+ 0x0104,
+ 0x2080,
+ 0x0000
+};
+
+static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON);
+ GLuint stipple;
+
+ FLUSH_BATCH(mmesa);
+ ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
+
+ if (active) {
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+ mmesa->Setup[MGA_CTXREG_DWGCTL] &= ~(0xf<<20);
+ }
+
+ p[0] = mask[0] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[4] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[8] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[12] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 0 ; j < 4; j++)
+ for (i = 0 ; i < 4 ; i++)
+ if (*m++ != p[j]) {
+ ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
+ return;
+ }
+
+ stipple = ( ((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12) );
+
+ for (i = 0 ; i < 16 ; i++)
+ if (mgaStipples[i] == stipple) {
+ mmesa->poly_stipple = i<<20;
+ break;
+ }
+
+ if (i == 16) {
+ ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
+ return;
+ }
+
+ if (active) {
+ mmesa->Setup[MGA_CTXREG_DWGCTL] &= ~(0xf<<20);
+ mmesa->Setup[MGA_CTXREG_DWGCTL] |= mmesa->poly_stipple;
+ }
+}
+
+/* =============================================================
*/
@@ -477,15 +533,16 @@ static GLboolean mgaDDColorMask(GLcontext *ctx,
static void mgaDDPrintDirty( 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 & MGA_REQUIRE_QUIESCENT) ? "req-quiescent, " : "",
+ (state & MGA_WAIT_AGE) ? "wait-age, " : "",
(state & MGA_UPLOAD_TEX0IMAGE) ? "upload-tex0-img, " : "",
(state & MGA_UPLOAD_TEX1IMAGE) ? "upload-tex1-img, " : "",
(state & MGA_UPLOAD_CTX) ? "upload-ctx, " : "",
(state & MGA_UPLOAD_TEX0) ? "upload-tex0, " : "",
- (state & MGA_UPLOAD_TEX1) ? "upload-tex1, " : ""
+ (state & MGA_UPLOAD_TEX1) ? "upload-tex1, " : "",
+ (state & MGA_UPLOAD_PIPE) ? "upload-pipe, " : ""
);
}
@@ -494,7 +551,7 @@ static void mgaDDPrintDirty( const char *msg, GLuint state )
*/
void mgaEmitHwStateLocked( mgaContextPtr mmesa )
{
- if (MGA_DEBUG & MGA_DEBUG_VERBOSE_MSG)
+ if (MGA_DEBUG & DEBUG_VERBOSE_MSG)
mgaDDPrintDirty( "mgaEmitHwStateLocked", mmesa->dirty );
if ((mmesa->dirty & MGA_UPLOAD_TEX0IMAGE) && mmesa->CurrentTexObj[0])
@@ -503,27 +560,28 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
if ((mmesa->dirty & MGA_UPLOAD_TEX1IMAGE) && mmesa->CurrentTexObj[1])
mgaUploadTexImages(mmesa, mmesa->CurrentTexObj[1]);
- if (mmesa->dirty & MGA_UPLOAD_CTX) {
+ if (mmesa->dirty & MGA_UPLOAD_CTX)
memcpy( mmesa->sarea->ContextState,
mmesa->Setup,
sizeof(mmesa->Setup));
- if (mmesa->CurrentTexObj[0])
+ if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0])
memcpy(mmesa->sarea->TexState[0],
mmesa->CurrentTexObj[0]->Setup,
sizeof(mmesa->sarea->TexState[0]));
- if (mmesa->CurrentTexObj[1])
+ if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1])
memcpy(mmesa->sarea->TexState[1],
mmesa->CurrentTexObj[1]->Setup,
sizeof(mmesa->sarea->TexState[1]));
- }
- if (mmesa->dirty & MGA_UPLOAD_PIPE)
- mmesa->sarea->WarpPipe = mmesa->setupindex & MGA_WARP_T2GZSAF;
-
+ mmesa->sarea->WarpPipe = mmesa->setupindex & MGA_WARP_T2GZSAF;
mmesa->sarea->dirty |= mmesa->dirty;
- mmesa->dirty = 0;
+#if 0
+ fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n",
+ mmesa->sarea->dirty);
+#endif
+ mmesa->dirty &= (MGA_UPLOAD_CLIPRECTS|MGA_WAIT_AGE);
}
@@ -533,29 +591,50 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
switch(cap) {
case GL_ALPHA_TEST:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MGA_NEW_ALPHA;
break;
case GL_BLEND:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MGA_NEW_ALPHA;
break;
case GL_DEPTH_TEST:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MGA_NEW_DEPTH;
break;
case GL_SCISSOR_TEST:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CLIP;
+ FLUSH_BATCH( mmesa );
+ mmesa->scissor = state;
+ mmesa->new_state |= MGA_NEW_CLIP;
break;
case GL_FOG:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_FOG;
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MGA_NEW_FOG;
break;
case GL_CULL_FACE:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CULL;
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MGA_NEW_CULL;
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MGA_NEW_TEXTURE;
+ break;
+ case GL_POLYGON_STIPPLE:
+ if ((ctx->Driver.TriangleCaps & DD_TRI_STIPPLE) &&
+ ctx->PB->primitive == GL_POLYGON)
+ {
+ FLUSH_BATCH(mmesa);
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+ mmesa->Setup[MGA_CTXREG_DWGCTL] &= ~(0xf<<20);
+ if (state)
+ mmesa->Setup[MGA_CTXREG_DWGCTL] |= mmesa->poly_stipple;
+ }
break;
default:
;
@@ -581,6 +660,7 @@ static void mgaWarpUpdateState( GLcontext *ctx )
{
mmesa->warp_pipe = index;
mmesa->new_state |= MGA_NEW_WARP;
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
}
}
@@ -611,21 +691,15 @@ void mgaDDUpdateHwState( GLcontext *ctx )
if (new_state)
{
- mmesa->new_state = 0;
+ FLUSH_BATCH( mmesa );
- /* Emit any vertices for the current state. This will also
- * push the current state into the sarea.
- */
-/* mgaFlushVertices( mmesa ); */
+ mmesa->new_state = 0;
if (MESA_VERBOSE&VERBOSE_DRIVER)
mgaDDPrintState("UpdateHwState", new_state);
if (new_state & MGA_NEW_DEPTH)
- {
mgaUpdateZMode(ctx);
- mgaDDInitDepthFuncs(ctx);
- }
if (new_state & MGA_NEW_ALPHA)
mgaUpdateAlphaMode(ctx);
@@ -641,8 +715,6 @@ void mgaDDUpdateHwState( GLcontext *ctx )
if (new_state & (MGA_NEW_WARP|MGA_NEW_TEXTURE))
mgaUpdateTextureState(ctx);
-
- mmesa->new_state = 0; /* tex uploads scribble newstate */
}
}
@@ -654,8 +726,17 @@ void mgaDDUpdateHwState( GLcontext *ctx )
void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
{
- mgaFlushVertices( MGA_CONTEXT(ctx) );
- mgaUpdateCull(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mgaUpdateCull(ctx);
+
+ if (ctx->Polygon.StippleFlag && (ctx->Driver.TriangleCaps & DD_TRI_STIPPLE))
+ {
+ mmesa->Setup[MGA_CTXREG_DWGCTL] &= ~(0xf<<20);
+ if (ctx->PB->primitive == GL_POLYGON)
+ mmesa->Setup[MGA_CTXREG_DWGCTL] |= mmesa->poly_stipple;
+ }
}
@@ -677,10 +758,16 @@ void mgaDDUpdateState( GLcontext *ctx )
/* Have to do this here to detect texture fallbacks in time:
*/
- if (MGA_CONTEXT(ctx)->new_state & MGA_NEW_TEXTURE)
+ if (mmesa->new_state & MGA_NEW_TEXTURE)
mgaDDUpdateHwState( ctx );
- if (!mmesa->Fallback || mgaglx.noFallback) {
+ if (0) fprintf(stderr, "fallback %x indirect %x\n", mmesa->Fallback,
+ mmesa->IndirectTriangles);
+
+ if (!mmesa->Fallback) {
+ ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+ ctx->IndirectTriangles |= mmesa->IndirectTriangles;
+
ctx->Driver.PointsFunc=mmesa->PointsFunc;
ctx->Driver.LineFunc=mmesa->LineFunc;
ctx->Driver.TriangleFunc=mmesa->TriangleFunc;
@@ -689,6 +776,60 @@ void mgaDDUpdateState( GLcontext *ctx )
}
+
+void mgaInitState( mgaContextPtr mmesa )
+{
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
+ GLcontext *ctx = mmesa->glCtx;
+
+ if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
+ mmesa->draw_buffer = MGA_BACK;
+ mmesa->read_buffer = MGA_BACK;
+ mmesa->drawOffset = mmesa->mgaScreen->backOffset;
+ mmesa->readOffset = mmesa->mgaScreen->backOffset;
+ mmesa->Setup[MGA_CTXREG_DSTORG] = mgaScreen->backOffset;
+ } else {
+ mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->readOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->draw_buffer = MGA_FRONT;
+ mmesa->read_buffer = MGA_FRONT;
+ mmesa->Setup[MGA_CTXREG_DSTORG] = mgaScreen->frontOffset;
+ }
+
+/* mmesa->Setup[MGA_CTXREG_MACCESS] = mgaScreen->mAccess; */
+/* mmesa->Setup[MGA_CTXREG_DWGCTL] = ( DC_clipdis_disable | */
+/* (0xC << DC_bop_SHIFT) | */
+/* DC_shftzero_enable | */
+/* DC_zmode_nozcmp | */
+/* DC_atype_zi ); */
+
+
+ mmesa->Setup[MGA_CTXREG_MACCESS] = 0x1;
+ mmesa->Setup[MGA_CTXREG_DWGCTL] = 0xc4074;
+
+
+ mmesa->Setup[MGA_CTXREG_PLNWT] = ~0;
+ mmesa->Setup[MGA_CTXREG_ALPHACTRL] = ( AC_src_one |
+ AC_dst_zero |
+ AC_amode_FCOL |
+ AC_astipple_disable |
+ AC_aten_disable |
+ AC_atmode_noacmp |
+ AC_alphasel_fromtex );
+
+ mmesa->Setup[MGA_CTXREG_FOGCOLOR] =
+ MGAPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F),
+ (GLubyte)(ctx->Fog.Color[1]*255.0F),
+ (GLubyte)(ctx->Fog.Color[2]*255.0F));
+
+ mmesa->Setup[MGA_CTXREG_WFLAG] = 0;
+ mmesa->Setup[MGA_CTXREG_TDUAL0] = 0;
+ mmesa->Setup[MGA_CTXREG_TDUAL1] = 0;
+ mmesa->Setup[MGA_CTXREG_FCOL] = 0;
+ mmesa->new_state = ~0;
+}
+
+
void mgaDDInitStateFuncs( GLcontext *ctx )
{
ctx->Driver.UpdateState = mgaDDUpdateState;
@@ -710,11 +851,14 @@ void mgaDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.RenderStart = mgaDDUpdateHwState;
ctx->Driver.RenderFinish = 0;
- ctx->Driver.SetBuffer = mgaDDSetBuffer;
+ ctx->Driver.SetDrawBuffer = mgaDDSetDrawBuffer;
+ ctx->Driver.SetReadBuffer = mgaDDSetReadBuffer;
ctx->Driver.Color = mgaDDSetColor;
ctx->Driver.ClearColor = mgaDDClearColor;
ctx->Driver.Dither = mgaDDDither;
+ ctx->Driver.PolygonStipple = mgaDDPolygonStipple;
+
ctx->Driver.Index = 0;
ctx->Driver.ClearIndex = 0;
ctx->Driver.IndexMask = 0;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.h b/xc/lib/GL/mesa/src/drv/mga/mgastate.h
index 5ada1b23c..ac92cb0c2 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgastate.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.h
@@ -7,9 +7,10 @@ extern void mgaDDUpdateHwState( GLcontext *ctx );
extern void mgaDDUpdateState( GLcontext *ctx );
extern void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim );
-/* reprograms the current registers without updating them, used to
-reset state after a dma buffer overflow */
-void mgaUpdateRegs( GLuint regs );
+extern void mgaInitState( mgaContextPtr mmesa );
+
+extern void mgaUpdateClipping(const GLcontext *ctx);
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.c b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
index be7ad6018..3afb70bad 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatex.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
@@ -47,22 +47,25 @@
* to it.
*/
static void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) {
- int i;
if ( !t ) return;
/* free the texture memory */
- mmFreeMem( t->MemBlock );
+ if (t->MemBlock) {
+ mmFreeMem( t->MemBlock );
+ t->MemBlock = 0;
+
+ if (t->age > mmesa->dirtyAge)
+ mmesa->dirtyAge = t->age;
+ }
/* free mesa's link */
- t->tObj->DriverData = NULL;
+ if (t->tObj)
+ t->tObj->DriverData = NULL;
/* see if it was the driver's current object */
- for ( i = 0 ; i < 2 ; i++ ) {
- if ( mmesa->CurrentTexObj[i] == t ) {
- mmesa->CurrentTexObj[i] = NULL;
- }
- }
+ if (t->bound)
+ mmesa->CurrentTexObj[t->bound - 1] = 0;
remove_from_list(t);
free( t );
@@ -73,6 +76,9 @@ static void mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t)
if (t->MemBlock) {
mmFreeMem(t->MemBlock);
t->MemBlock = 0;
+
+ if (t->age > mmesa->dirtyAge)
+ mmesa->dirtyAge = t->age;
}
t->dirty_images = ~0;
@@ -80,22 +86,76 @@ static void mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t)
}
-void mgaResetGlobalLRU( mgaContextPtr mmesa )
+static void mgaPrintLocalLRU( mgaContextPtr mmesa, int heap )
+{
+ mgaTextureObjectPtr t;
+ int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
+
+ fprintf(stderr, "\nLocal LRU, heap %d:\n", heap);
+
+ foreach( t, &(mmesa->TexObjList[heap]) ) {
+ if (!t->tObj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture (bound %d) at %x sz %x\n",
+ t->bound,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+
+ fprintf(stderr, "\n\n");
+}
+
+static void mgaPrintGlobalLRU( mgaContextPtr mmesa, int heap )
+{
+ int i, j;
+ drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
+
+ fprintf(stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list);
+
+ for (i = 0, j = MGA_NR_TEX_REGIONS ; i < MGA_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev);
+ j = list[j].next;
+ if (j == MGA_NR_TEX_REGIONS) break;
+ }
+
+ if (j != MGA_NR_TEX_REGIONS) {
+ fprintf(stderr, "Loop detected in global LRU\n\n\n");
+ for (i = 0 ; i < MGA_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ i, list[i].age, list[i].next, list[i].prev);
+ }
+ }
+
+ fprintf(stderr, "\n\n");
+}
+
+
+static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap )
{
- mgaTexRegion *list = mmesa->sarea->texList;
- int sz = 1 << mmesa->mgaScreen->logTextureGranularity;
+ drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
+ int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap];
int i;
+ mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
+
+ if (0) fprintf(stderr, "mgaResetGlobalLRU %d\n", (int)heap);
+
/* (Re)initialize the global circular LRU list. The last element
* in the array (MGA_NR_TEX_REGIONS) is the sentinal. Keeping it
* at the end of the array allows it to be addressed rationally
* when looking up objects at a particular location in texture
* memory.
*/
- for (i = 0 ; (i+1) * sz < mmesa->mgaScreen->textureSize ; i++) {
+ for (i = 0 ; (i+1) * sz <= mmesa->mgaScreen->textureSize[heap] ; i++) {
list[i].prev = i-1;
list[i].next = i+1;
- list[i].age = 0;
+ list[i].age = mmesa->sarea->texAge[heap];
}
i--;
@@ -104,30 +164,41 @@ void mgaResetGlobalLRU( mgaContextPtr mmesa )
list[i].next = MGA_NR_TEX_REGIONS;
list[MGA_NR_TEX_REGIONS].prev = i;
list[MGA_NR_TEX_REGIONS].next = 0;
- mmesa->sarea->texAge = 0;
+
}
static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t )
{
int i;
- int logsz = mmesa->mgaScreen->logTextureGranularity;
+ int heap = t->heap;
+ int logsz = mmesa->mgaScreen->logTextureGranularity[heap];
int start = t->MemBlock->ofs >> logsz;
int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
- mgaTexRegion *list = mmesa->sarea->texList;
+ drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
- mmesa->texAge = ++mmesa->sarea->texAge;
+ mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
+
+ if (!t->MemBlock) {
+ fprintf(stderr, "no memblock\n\n");
+ return;
+ }
/* Update our local LRU
*/
- move_to_head( &(mmesa->TexObjList), t );
+ move_to_head( &(mmesa->TexObjList[heap]), t );
+
+
+ if (0)
+ fprintf(stderr, "mgaUpdateTexLRU heap %d list %p\n", heap, list);
+
/* Update the global LRU
*/
for (i = start ; i <= end ; i++) {
list[i].in_use = 1;
- list[i].age = mmesa->texAge;
+ list[i].age = mmesa->texAge[heap];
/* remove_from_list(i)
*/
@@ -141,8 +212,12 @@ static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t )
list[(unsigned)list[MGA_NR_TEX_REGIONS].next].prev = i;
list[MGA_NR_TEX_REGIONS].next = i;
}
-}
+ if (0) {
+ mgaPrintGlobalLRU(mmesa, t->heap);
+ mgaPrintLocalLRU(mmesa, t->heap);
+ }
+}
/* Called for every shared texture region which has increased in age
* since we last held the lock.
@@ -151,23 +226,29 @@ static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t )
* and pushes a placeholder texture onto the LRU list to represent
* the other client's textures.
*/
-void mgaTexturesGone( mgaContextPtr mmesa,
- GLuint offset,
- GLuint size,
- GLuint in_use )
+static void mgaTexturesGone( mgaContextPtr mmesa,
+ GLuint heap,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
{
mgaTextureObjectPtr t, tmp;
-
- foreach_s ( t, tmp, &mmesa->TexObjList ) {
+
+
+
+ foreach_s ( t, tmp, &(mmesa->TexObjList[heap]) ) {
if (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.
*/
- if (t == mmesa->CurrentTexObj[0] || t == mmesa->CurrentTexObj[1])
+ if (t->bound)
mgaSwapOutTexObj( mmesa, t );
else
mgaDestroyTexObj( mmesa, t );
@@ -178,12 +259,54 @@ void mgaTexturesGone( mgaContextPtr mmesa,
t = (mgaTextureObjectPtr) calloc(1,sizeof(*t));
if (!t) return;
- t->MemBlock = mmAllocMem( mmesa->texHeap, size, 0, offset);
- insert_at_head( &mmesa->TexObjList, t );
+ t->heap = heap;
+ t->MemBlock = mmAllocMem( mmesa->texHeap[heap], size, 0, offset);
+ if (!t->MemBlock) {
+ fprintf(stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
+ (int)size, (int)offset);
+ mmDumpMemInfo( mmesa->texHeap[heap]);
+ return;
+ }
+ insert_at_head( &(mmesa->TexObjList[heap]), t );
}
}
+void mgaAgeTextures( mgaContextPtr mmesa, int heap )
+{
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+ int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
+ int idx, nr = 0;
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in our local list... Fix with a cursor pointer.
+ */
+ for (idx = sarea->texList[heap][MGA_NR_TEX_REGIONS].prev ;
+ idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ;
+ idx = sarea->texList[heap][idx].prev, nr++)
+ {
+ if (sarea->texList[heap][idx].age > mmesa->texAge[heap]) {
+ mgaTexturesGone(mmesa, heap, idx * sz, sz, 1);
+ }
+ }
+
+ if (nr == MGA_NR_TEX_REGIONS) {
+ mgaTexturesGone(mmesa, heap, 0,
+ mmesa->mgaScreen->textureSize[heap], 0);
+ mgaResetGlobalLRU( mmesa, heap );
+ }
+
+
+ if (0) {
+ mgaPrintGlobalLRU( mmesa, heap );
+ mgaPrintLocalLRU( mmesa, heap );
+ }
+
+ mmesa->texAge[heap] = sarea->texAge[heap];
+ mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE;
+}
+
+
/*
* mgaSetTexWrappings
*/
@@ -281,22 +404,22 @@ static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) {
/*
- * mgaUploadSubImage
+ * mgaUploadSubImageLocked
*
* Perform an iload based update of a resident buffer. This is used for
* both initial loading of the entire image, and texSubImage updates.
*
* Performed with the hardware lock held.
*/
-static void mgaUploadSubImage( mgaContextPtr mmesa,
- mgaTextureObjectPtr t,
- int level,
- int x, int y, int width, int height ) {
+static void mgaUploadSubImageLocked( mgaContextPtr mmesa,
+ mgaTextureObjectPtr t,
+ int level,
+ int x, int y, int width, int height ) {
int x2;
int dwords;
- int dstorg;
+ int offset;
struct gl_texture_image *image;
- int texelBytes, texelsPerDword, texelMaccess;
+ int texelBytes, texelsPerDword, texelMaccess, length;
if ( level < 0 || level >= MGA_TEX_MAXLEVELS ) {
mgaMsg( 1, "mgaUploadSubImage: bad level: %i\n", level );
@@ -310,15 +433,9 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
}
/* find the proper destination offset for this level */
- dstorg = (mmesa->mgaScreen->textureOffset + t->MemBlock->ofs +
+ offset = (t->MemBlock->ofs +
t->offsets[level]);
- /* turn on PCI/AGP if needed
- if ( textureHeapPhysical ) {
- dstorg |= 1 | mgaglx.use_agp;
- }
- */
-
texelBytes = t->texelBytes;
switch( texelBytes ) {
case 1:
@@ -363,7 +480,7 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
x = (x + (texelsPerDword-1)) & ~(texelsPerDword-1);
width = x2 - x;
}
-
+
/* we may not be able to upload the entire texture in one
batch due to register limits or dma buffer limits.
Recursively split it up. */
@@ -374,7 +491,8 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
}
mgaMsg(10, "mgaUploadSubImage: recursively subdividing\n" );
- mgaUploadSubImage( mmesa, t, level, x, y, width, height >> 1 );
+ mgaUploadSubImageLocked( mmesa, t, level, x, y,
+ width, height >> 1 );
y += ( height >> 1 );
height -= ( height >> 1 );
}
@@ -385,31 +503,50 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
/* bump the performance counter */
mgaglx.c_textureSwaps += ( dwords << 2 );
-
-#if 0
-
- /* fill in the secondary buffer with properly converted texels
- from the mesa buffer */
- mgaConvertTexture( dest, texelBytes, image, x, y, width, height );
-
- /* send the secondary data */
- mgaSecondaryDma( TT_BLIT, dest, dwords );
-#endif
-
+ length = dwords * 4;
+
+ /* Fill in the secondary buffer with properly converted texels
+ * from the mesa buffer. */
+ if(t->heap == MGA_CARD_HEAP) {
+ mgaGetILoadBufferLocked( mmesa );
+ mgaConvertTexture( (mgaUI32 *)mmesa->iload_buffer->address,
+ texelBytes, image, x, y, width, height );
+ if(length < 64) length = 64;
+ mgaMsg(10, "TexelBytes : %d, offset: %d, length : %d\n",
+ texelBytes,
+ mmesa->mgaScreen->textureOffset[t->heap] +
+ offset +
+ y * width * 4/texelsPerDword,
+ length);
+
+ mgaFireILoadLocked( mmesa,
+ mmesa->mgaScreen->textureOffset[t->heap] +
+ offset +
+ y * width * 4/texelsPerDword,
+ length);
+ } else {
+ /* This works, is slower for uploads to card space and needs
+ * additional synchronization with the dma stream.
+ */
+ mgaConvertTexture( (mgaUI32 *)
+ (mmesa->mgaScreen->texVirtual[t->heap] +
+ offset +
+ y * width * 4/texelsPerDword),
+ texelBytes, image, x, y, width, height );
+ }
}
-
static void mgaUploadTexLevel( mgaContextPtr mmesa,
- mgaTextureObjectPtr t,
- int l )
+ mgaTextureObjectPtr t,
+ int l )
{
- mgaUploadSubImage( mmesa,
- t,
- l,
- 0, 0,
- t->tObj->Image[l]->Width,
- t->tObj->Image[l]->Height);
+ mgaUploadSubImageLocked( mmesa,
+ t,
+ l,
+ 0, 0,
+ t->tObj->Image[l]->Width,
+ t->tObj->Image[l]->Height);
}
@@ -527,9 +664,11 @@ static void mgaCreateTexObj(mgaContextPtr mmesa, struct gl_texture_object *tObj)
/* fill in our mga texture object */
t->tObj = tObj;
t->ctx = mmesa;
+ t->age = 0;
+ t->bound = 0;
- insert_at_tail(&(mmesa->TexObjList), t);
+ insert_at_tail(&(mmesa->SwappedOut), t);
t->MemBlock = 0;
@@ -596,34 +735,61 @@ static void mgaCreateTexObj(mgaContextPtr mmesa, struct gl_texture_object *tObj)
tObj->DriverData = t;
}
+static void mgaMigrateTexture( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+ /* NOT DONE */
+}
-int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+static int mgaChooseTexHeap( mgaContextPtr mmesa, mgaTextureObjectPtr t )
{
+ return 0;
+}
+
+int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+ int heap;
int i;
int ofs;
mgaglx.c_textureSwaps++;
+ heap = t->heap = mgaChooseTexHeap( mmesa, t );
+
/* Do we need to eject LRU texture objects?
*/
if (!t->MemBlock) {
while (1)
{
- t->MemBlock = mmAllocMem( mmesa->texHeap, t->totalSize, 12, 0 );
+ mgaTextureObjectPtr tmp = mmesa->TexObjList[heap].prev;
+
+ t->MemBlock = mmAllocMem( mmesa->texHeap[heap],
+ t->totalSize,
+ 6, 0 );
if (t->MemBlock)
break;
- if (mmesa->TexObjList.prev == &(mmesa->TexObjList)) {
- fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
- mmDumpMemInfo( mmesa->texHeap );
+ if (mmesa->TexObjList[heap].prev->bound) {
+ fprintf(stderr,
+ "Hit bound texture in upload\n");
return -1;
}
- mgaDestroyTexObj( mmesa, mmesa->TexObjList.prev );
+ if (mmesa->TexObjList[heap].prev ==
+ &(mmesa->TexObjList[heap]))
+ {
+ fprintf(stderr, "Failed to upload texture, "
+ "sz %d\n", t->totalSize);
+ mmDumpMemInfo( mmesa->texHeap[heap] );
+ return -1;
+ }
+
+ mgaDestroyTexObj( mmesa, tmp );
}
- ofs = t->MemBlock->ofs;
+ ofs = t->MemBlock->ofs
+ + mmesa->mgaScreen->textureOffset[heap]
+ ;
t->Setup[MGA_TEXREG_ORG] = ofs;
t->Setup[MGA_TEXREG_ORG1] = ofs + t->offsets[1];
@@ -638,8 +804,16 @@ int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
*/
mgaUpdateTexLRU( mmesa, t );
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
+ fprintf(stderr, "dispatch age: %d age freed memory: %d\n",
+ GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge);
+
+ if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa))
+ mgaWaitAgeLocked( mmesa, mmesa->dirtyAge );
+
if (t->dirty_images) {
- if (MGA_DEBUG & MGA_DEBUG_VERBOSE_MSG)
+ if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
fprintf(stderr, "*");
for (i = 0 ; i <= t->lastLevel ; i++)
@@ -692,12 +866,10 @@ static void mgaUpdateTextureEnvG200( GLcontext *ctx )
}
}
-/* I don't have the alpha values correct yet:
- */
static void mgaUpdateTextureStage( GLcontext *ctx, int unit )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaUI32 *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit];
+ GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit];
GLuint source = mmesa->tmu_source[unit];
struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current;
@@ -725,13 +897,13 @@ static void mgaUpdateTextureStage( GLcontext *ctx, int unit )
*reg = ( TD0_color_arg2_diffuse |
TD0_color_sel_mul |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg1);
+ TD0_alpha_sel_mul);
else
*reg = ( TD0_color_arg2_prevstage |
TD0_color_alpha_prevstage |
TD0_color_sel_mul |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg1);
+ TD0_alpha_sel_mul);
break;
case GL_DECAL:
*reg = (TD0_color_arg2_fcol |
@@ -751,20 +923,49 @@ static void mgaUpdateTextureStage( GLcontext *ctx, int unit )
TD0_color_add_add |
TD0_color_sel_add |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg1);
+ TD0_alpha_sel_add);
else
*reg = ( TD0_color_arg2_prevstage |
TD0_color_alpha_prevstage |
TD0_color_add_add |
TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg1);
+ TD0_alpha_sel_add);
break;
case GL_BLEND:
- /* Use a multipass mechanism to do this:
+ if (0)
+ fprintf(stderr, "GL_BLEND unit %d flags %x\n", unit,
+ mmesa->blend_flags);
+
+ if (mmesa->blend_flags)
+ mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+ return;
+
+ /* Do singletexture GL_BLEND with 'all ones' env-color
+ * by using both texture units. Multitexture gl_blend
+ * is a fallback.
*/
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+ if (unit == 0) {
+ /* Part 1: R1 = Rf ( 1 - Rt )
+ * A1 = Af At
+ */
+ *reg = ( TD0_color_arg2_diffuse |
+ TD0_color_arg1_inv_enable |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg1);
+ } else {
+ /* Part 2: R2 = R1 + Rt
+ * A2 = A1
+ */
+ *reg = ( TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ }
+
break;
default:
}
@@ -782,9 +983,8 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
mgaMsg(15,"mgaUpdateTextureState %d\n", unit);
/* disable texturing until it is known to be good */
- mmesa->Setup[MGA_CTXREG_DWGCTL] =
- (( mmesa->Setup[MGA_CTXREG_DWGCTL] & DC_opcod_MASK ) |
- DC_opcod_trap);
+ mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK;
+ mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_trap;
enabled = (ctx->Texture.Enabled>>(source*4))&TEXTURE0_ANY;
if (enabled != TEXTURE0_2D) {
@@ -804,7 +1004,6 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
if ( !tObj->DriverData ) {
/* clear the current pointer so that texture object can be
swapped out if necessary to make room */
- mmesa->CurrentTexObj[source] = NULL;
mgaCreateTexObj( mmesa, tObj );
if ( !tObj->DriverData ) {
@@ -815,9 +1014,8 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
}
/* we definately have a valid texture now */
- mmesa->Setup[MGA_CTXREG_DWGCTL] =
- (( mmesa->Setup[MGA_CTXREG_DWGCTL] & DC_opcod_MASK ) |
- DC_opcod_texture_trap);
+ mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK;
+ mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_texture_trap;
t = (mgaTextureObjectPtr)tObj->DriverData;
@@ -825,6 +1023,11 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit);
mmesa->CurrentTexObj[unit] = t;
+ t->bound = unit+1;
+
+ if (t->MemBlock)
+ mgaUpdateTexLRU( mmesa, t );
+
t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable;
if (ctx->Texture.Enabled == (TEXTURE0_2D|TEXTURE1_2D))
@@ -848,23 +1051,31 @@ void mgaUpdateTextureState( GLcontext *ctx )
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE;
+ if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->bound = 0;
+ if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->bound = 0;
+ mmesa->CurrentTexObj[0] = 0;
+ mmesa->CurrentTexObj[1] = 0;
+
if (MGA_IS_G400(mmesa)) {
mgaUpdateTextureObject( ctx, 0 );
mgaUpdateTextureStage( ctx, 0 );
- mmesa->Setup[MGA_CTXREG_TDUAL1] = mmesa->Setup[MGA_CTXREG_TDUAL0];
+ mmesa->Setup[MGA_CTXREG_TDUAL1] =
+ mmesa->Setup[MGA_CTXREG_TDUAL0];
if (mmesa->multitex) {
mgaUpdateTextureObject( ctx, 1 );
mgaUpdateTextureStage( ctx, 1 );
}
+
+ mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1;
} else {
mgaUpdateTextureObject( ctx, 0 );
- mgaUpdateTextureEnvG200( ctx );
+ mgaUpdateTextureEnvG200( ctx );
}
/* schedule the register writes */
- mmesa->dirty |= MGA_UPLOAD_CTX;
+ mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0;
}
@@ -880,14 +1091,57 @@ Driver functions called directly from mesa
/*
* mgaTexEnv
*/
-void mgaTexEnv( GLcontext *ctx, GLenum pname, const GLfloat *param ) {
+void mgaTexEnv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
mgaMsg( 10, "mgaTexEnv( %i )\n", pname );
+
if (pname == GL_TEXTURE_ENV_MODE) {
/* force the texture state to be updated */
- MGA_CONTEXT(ctx)->CurrentTexObj[0] = 0;
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
}
+ else if (pname == GL_TEXTURE_ENV_COLOR)
+ {
+ struct gl_texture_unit *texUnit =
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ GLfloat *fc = texUnit->EnvColor;
+ GLubyte c[4];
+ GLuint col;
+
+
+ c[0] = fc[0];
+ c[1] = fc[1];
+ c[2] = fc[2];
+ c[3] = fc[3];
+
+ /* No alpha at 16bpp?
+ */
+ col = mgaPackColor( mmesa->mgaScreen->Attrib,
+ c[0], c[1], c[2], c[3] );
+
+ mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]);
+
+ if (mmesa->Setup[MGA_CTXREG_FCOL] != col) {
+ FLUSH_BATCH(mmesa);
+ mmesa->Setup[MGA_CTXREG_FCOL] = col;
+ mmesa->dirty |= MGA_UPLOAD_CTX;
+
+ mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR;
+
+ /* Actually just require all four components to be
+ * equal. This permits a single-pass GL_BLEND.
+ *
+ * More complex multitexture/multipass fallbacks
+ * for blend can be done later.
+ */
+ if (mmesa->envcolor != 0x0 &&
+ mmesa->envcolor != 0xffffffff)
+ mmesa->blend_flags |= MGA_BLEND_ENV_COLOR;
+ }
+ }
+
}
/*
@@ -907,6 +1161,7 @@ void mgaTexImage( GLcontext *ctx, GLenum target,
mgaUpdateTextureState time. */
t = (mgaTextureObjectPtr) tObj->DriverData;
if ( t ) {
+ if (t->bound) FLUSH_BATCH(mmesa);
/* if this is the current object, it will force an update */
mgaDestroyTexObj( mmesa, t );
mmesa->new_state |= MGA_NEW_TEXTURE;
@@ -936,6 +1191,7 @@ void mgaTexSubImage( GLcontext *ctx, GLenum target,
mgaUpdateTextureState time. */
t = (mgaTextureObjectPtr) tObj->DriverData;
if ( t ) {
+ if (t->bound) FLUSH_BATCH(mmesa);
/* if this is the current object, it will force an update */
mgaDestroyTexObj( mmesa, t );
mmesa->new_state |= MGA_NEW_TEXTURE;
@@ -956,7 +1212,9 @@ void mgaTexSubImage( GLcontext *ctx, GLenum target,
*/
void mgaTexParameter( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params ) {
+ GLenum pname, const GLfloat *params )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mgaTextureObjectPtr t;
mgaMsg( 10, "mgaTexParameter( %p, %i )\n", tObj, pname );
@@ -973,52 +1231,68 @@ void mgaTexParameter( GLcontext *ctx, GLenum target,
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
+ if (t->bound) FLUSH_BATCH(mmesa);
mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
break;
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
+ if (t->bound) FLUSH_BATCH(mmesa);
mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT);
break;
case GL_TEXTURE_BORDER_COLOR:
+ if (t->bound) FLUSH_BATCH(mmesa);
mgaSetTexBorderColor(t,tObj->BorderColor);
break;
default:
return;
}
- /* force the texture state to be updated */
- MGA_CONTEXT(ctx)->CurrentTexObj[0] = NULL;
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
+
+ mmesa->new_state |= MGA_NEW_TEXTURE;
}
/*
* mgaBindTexture
*/
void mgaBindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj ) {
+ struct gl_texture_object *tObj )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mgaMsg( 10, "mgaBindTexture( %p )\n", tObj );
-
+
+ FLUSH_BATCH(mmesa);
+
+ if (mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]) {
+ mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
+ mmesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0;
+ }
+
/* force the texture state to be updated
*/
- MGA_CONTEXT(ctx)->CurrentTexObj[0] = NULL;
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
}
/*
* mgaDeleteTexture
*/
-void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) {
+void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData;
mgaMsg( 10, "mgaDeleteTexture( %p )\n", tObj );
- /* delete our driver data */
- if ( tObj->DriverData ) {
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaDestroyTexObj( mmesa,
- (mgaTextureObjectPtr)(tObj->DriverData) );
+ if ( t ) {
+ if (t->bound) {
+ FLUSH_BATCH(mmesa);
+ mmesa->CurrentTexObj[t->bound-1] = 0;
+ mmesa->new_state |= MGA_NEW_TEXTURE;
+ }
+
+ mgaDestroyTexObj( mmesa, t );
mmesa->new_state |= MGA_NEW_TEXTURE;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.h b/xc/lib/GL/mesa/src/drv/mga/mgatex.h
index 1e8e7e86f..7873146c0 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatex.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.h
@@ -28,7 +28,6 @@
#ifndef MGATEX_INC
#define MGATEX_INC
-#include "mga_drm_public.h"
#include "types.h"
#include "mgacommon.h"
#include "mm.h"
@@ -48,7 +47,9 @@ typedef struct mga_texture_object_s {
mgaUI32 dirty_images;
mgaUI32 totalSize;
int texelBytes;
- mgaUI32 age;
+ mgaUI32 age;
+ int bound;
+ int heap; /* agp or card */
mgaUI32 Setup[MGA_TEX_SETUP_SIZE];
} mgaTextureObject_t;
@@ -96,7 +97,7 @@ void mgaUpdateTexturePalette( GLcontext *ctx, struct gl_texture_object *tObj );
GLboolean mgaIsTextureResident( GLcontext *ctx, struct gl_texture_object *t );
-void mgaConvertTexture( mgaUI32 *destPtr, int texelBytes,
+void mgaConvertTexture( mgaUI32 *dest, int texelBytes,
struct gl_texture_image *image,
int x, int y, int width, int height );
@@ -107,9 +108,7 @@ int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t );
-void mgaResetGlobalLRU( mgaContextPtr mmesa );
-void mgaTexturesGone( mgaContextPtr mmesa, GLuint offset,
- GLuint size, GLuint in_use );
+void mgaAgeTextures( mgaContextPtr mmesa, int heap );
void mgaDDInitTextureFuncs( GLcontext *ctx );
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.c b/xc/lib/GL/mesa/src/drv/mga/mgatris.c
index bd8ef083f..b83aaf2ea 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatris.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <math.h>
+#include "types.h"
#include "vb.h"
#include "pipeline.h"
@@ -122,34 +123,14 @@ void mgaDDTrifuncInit()
init_twoside_offset();
init_twoside_offset_flat();
- /* Hmmm...
- */
- for (i = 0 ; i < 0x20 ; i++) {
- if (i & ~MGA_FLAT_BIT) {
- points_tab[i] = points_tab[i&MGA_FLAT_BIT];
- line_tab[i] = line_tab[i&MGA_FLAT_BIT];
- }
- }
-
for (i = 0 ; i < 0x20 ; i++)
- if ((i & (MGA_NODRAW_BIT|MGA_FALLBACK_BIT)) == MGA_NODRAW_BIT ||
- mgaglx.nullprims)
+ if ((i & (MGA_NODRAW_BIT|MGA_FALLBACK_BIT)) == MGA_NODRAW_BIT)
{
quad_tab[i] = mga_null_quad;
tri_tab[i] = mga_null_triangle;
line_tab[i] = mga_null_line;
points_tab[i] = mga_null_points;
}
-
- if (mgaglx.noFallback) {
- for (i = 0 ; i < 0x10 ; i++) {
- points_tab[i|MGA_FALLBACK_BIT] = points_tab[i];
- line_tab[i|MGA_FALLBACK_BIT] = line_tab[i];
- tri_tab[i|MGA_FALLBACK_BIT] = tri_tab[i];
- quad_tab[i|MGA_FALLBACK_BIT] = quad_tab[i];
- }
- }
-
}
@@ -162,50 +143,53 @@ void mgaDDChooseRenderState( GLcontext *ctx )
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
GLuint flags = ctx->TriangleCaps;
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+ if (mmesa->Fallback)
+ return;
+
+ mmesa->IndirectTriangles &= ~DD_SW_RASTERIZE;
if (flags) {
GLuint ind = 0;
GLuint shared = 0;
- GLuint fallback = MGA_FALLBACK_BIT;
-
- if (mgaglx.noFallback) fallback = 0;
if (flags & DD_Z_NEVER) shared |= MGA_NODRAW_BIT;
if (flags & DD_FLATSHADE) shared |= MGA_FLAT_BIT;
- if (flags & DD_MULTIDRAW) shared |= fallback;
- if (flags & (DD_SELECT|DD_FEEDBACK)) shared |= MGA_FALLBACK_BIT;
+ if (flags & (DD_MULTIDRAW|
+ DD_SELECT|
+ DD_FEEDBACK)) shared |= MGA_FALLBACK_BIT;
if (flags & DD_STENCIL) shared |= MGA_FALLBACK_BIT;
ind = shared;
if (flags & DD_POINT_SMOOTH) ind |= MGA_ANTIALIAS_BIT;
- if (flags & DD_POINT_ATTEN) ind |= fallback;
mmesa->renderindex = ind;
mmesa->PointsFunc = points_tab[ind];
if (ind & MGA_FALLBACK_BIT)
- ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+ mmesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
ind = shared;
if (flags & DD_LINE_SMOOTH) ind |= MGA_ANTIALIAS_BIT;
- if (flags & DD_LINE_STIPPLE) ind |= fallback;
+ if (flags & DD_LINE_STIPPLE) ind |= MGA_FALLBACK_BIT;
mmesa->renderindex |= ind;
mmesa->LineFunc = line_tab[ind];
if (ind & MGA_FALLBACK_BIT)
- ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+ mmesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
ind = shared;
if (flags & DD_TRI_SMOOTH) ind |= MGA_ANTIALIAS_BIT;
if (flags & DD_TRI_OFFSET) ind |= MGA_OFFSET_BIT;
if (flags & DD_TRI_LIGHT_TWOSIDE) ind |= MGA_TWOSIDE_BIT;
- if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE)) ind |= fallback;
+ if (flags & DD_TRI_UNFILLED) ind |= MGA_FALLBACK_BIT;
+ if ((flags & DD_TRI_STIPPLE) &&
+ (ctx->IndirectTriangles & DD_TRI_STIPPLE)) ind |= MGA_FALLBACK_BIT;
mmesa->renderindex |= ind;
mmesa->TriangleFunc = tri_tab[ind];
mmesa->QuadFunc = quad_tab[ind];
if (ind & MGA_FALLBACK_BIT)
- ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE | DD_QUAD_SW_RASTERIZE);
+ mmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+ DD_QUAD_SW_RASTERIZE);
}
else if (mmesa->renderindex)
{
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.h b/xc/lib/GL/mesa/src/drv/mga/mgatris.h
index 3b41900f1..dcf697409 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatris.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.h
@@ -34,26 +34,16 @@ extern void mgaDDTrifuncInit( void );
/* Todo:
- * - multidraw, ...
* - Antialiasing (?)
* - line and polygon stipple
- * - select and feedback
* - stencil
- * - point parameters
- * -
*/
#define MGA_ANTIALIAS_BIT 0 /* ignored for now, no fallback */
-#define MGA_FLAT_BIT 0x1
-#define MGA_OFFSET_BIT 0x2 /* 3.1 only */
-#define MGA_TWOSIDE_BIT 0x4 /* 3.1 only */
-#define MGA_NODRAW_BIT 0x8
-#define MGA_FALLBACK_BIT 0x10
-
-/* Not in use:
- */
-#define MGA_FEEDBACK_BIT 0x20
-#define MGA_SELECT_BIT 0x40
-#define MGA_POINT_PARAM_BIT 0x80 /* not needed? */
+#define MGA_FLAT_BIT 0x1
+#define MGA_OFFSET_BIT 0x2
+#define MGA_TWOSIDE_BIT 0x4
+#define MGA_NODRAW_BIT 0x8
+#define MGA_FALLBACK_BIT 0x10
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h b/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h
index ac5a545d2..ba2410914 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h
@@ -98,8 +98,6 @@ static void TAG(quad)( GLcontext *ctx, GLuint v0,
}
-#if ((IND & ~MGA_FLAT_BIT) == 0)
-
static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
@@ -131,7 +129,6 @@ static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
mga_draw_point( mmesa, &mgaVB[i], sz );
}
-#endif
static void TAG(init)( void )
@@ -139,10 +136,9 @@ static void TAG(init)( void )
tri_tab[IND] = TAG(triangle);
quad_tab[IND] = TAG(quad);
-#if ((IND & ~MGA_FLAT_BIT) == 0)
line_tab[IND] = TAG(line);
points_tab[IND] = TAG(points);
-#endif
+
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
index f78c542c8..0b703a184 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
@@ -260,11 +260,21 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx)
mmesa->tex_dest[0] = MGA_TEX0_BIT;
mmesa->tex_dest[1] = MGA_TEX1_BIT;
mmesa->multitex = 0;
+ mmesa->blend_flags &= ~MGA_BLEND_MULTITEX;
if (ctx->Texture.Enabled & 0xf) {
if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
funcindex &= ~MGA_RGBA_BIT;
+ if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+ mmesa->envcolor)
+ {
+ mmesa->multitex = 1;
+ mmesa->vertsize = 10;
+ mmesa->tmu_source[1] = 0;
+ funcindex |= MGA_TEX1_BIT;
+ }
+
funcindex |= MGA_TEX0_BIT;
}
@@ -272,7 +282,8 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx)
if (ctx->Texture.Enabled & 0xf) {
mmesa->multitex = 1;
mmesa->vertsize = 10;
- funcindex |= MGA_TEX1_BIT;
+ mmesa->blend_flags |= MGA_BLEND_MULTITEX;
+ funcindex |= MGA_TEX1_BIT;
} else {
/* Just a funny way of doing single texturing
*/
@@ -281,11 +292,25 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx)
if (ctx->Texture.Unit[1].EnvMode == GL_REPLACE)
funcindex &= ~MGA_RGBA_BIT;
+
+ if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+ mmesa->envcolor)
+ {
+ mmesa->multitex = 1;
+ mmesa->vertsize = 10;
+ mmesa->tmu_source[1] = 1;
+ funcindex |= MGA_TEX1_BIT;
+ }
funcindex |= MGA_TEX0_BIT;
}
}
+ /* Not really a good place to do this - need to make the mga state
+ * management code more event-driven so this can be calculated for
+ * free.
+ */
+
if (ctx->Color.BlendEnabled)
funcindex |= MGA_ALPHA_BIT;
@@ -298,6 +323,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx)
if (0)
mgaPrintSetupFlags("xsmesa: full setup function", funcindex);
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
mmesa->setupindex = funcindex;
/* Called by mesa's clip functons:
@@ -477,17 +503,3 @@ void mgaDDUnregisterVB( struct vertex_buffer *VB )
}
-mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
-{
- int bytes = dwords * 4;
- mgaUI32 *head;
-
- if (mmesa->dma_buffer->used + bytes > mmesa->dma_buffer->total)
- mgaFlushVertices( mmesa );
-
- head = (mgaUI32 *)((char *)mmesa->dma_buffer->address +
- mmesa->dma_buffer->used);
-
- mmesa->dma_buffer->used += bytes;
- return head;
-}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.h b/xc/lib/GL/mesa/src/drv/mga/mgavb.h
index 8d7c65207..675c1779c 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgavb.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.h
@@ -27,6 +27,7 @@
#ifndef MGAVB_INC
#define MGAVB_INC
+#include "types.h"
#include "vb.h"
#include "mgacommon.h"
@@ -126,7 +127,4 @@ extern void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size );
extern void mgaDDSetupInit( void );
-extern mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
-
-
#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile
index 982ca93e8..a8fe76fe7 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile
@@ -278,7 +278,7 @@ XCOMM Disabling 3Dnow code for the time being.
SRCS = $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS)
OBJS = $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS)
-REQUIREDLIBS += -lglide3x
+REQUIREDLIBS += -lglide3x -lm
#if !GlxUseBuiltInDRIDriver
#undef DoNormalLib NormalLibGlx