summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2004-12-29 21:17:06 +0000
committerKeith Whitwell <[email protected]>2004-12-29 21:17:06 +0000
commit5be14fd59a24612afd09da13688d611a1711d6da (patch)
tree26b559af8815b006de46711d10358a1f8a8176e4 /src/mesa/drivers/dri
parent490e764d7affc093feff80192ed3f3d4642fcb8f (diff)
Fix some wrapping bugs in the last commit. Probably there are more
remaining.
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c2
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.h1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_ioctl.c54
-rw-r--r--src/mesa/drivers/dri/unichrome/via_ioctl.h1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_render.c2
-rw-r--r--src/mesa/drivers/dri/unichrome/via_state.c8
-rw-r--r--src/mesa/drivers/dri/unichrome/via_state.h1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_tris.c27
8 files changed, 65 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index b6c2c37aedd..b3cc66f087c 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -681,7 +681,7 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags)
if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
vmesa->sarea->ctxOwner = vmesa->hHWContext;
- vmesa->newState = ~0;
+ vmesa->newEmitState = ~0;
}
if (vmesa->lastStamp != dPriv->lastStamp) {
diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h
index 995e20698ec..7cac40ed548 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.h
+++ b/src/mesa/drivers/dri/unichrome/via_context.h
@@ -123,6 +123,7 @@ struct via_context_t {
/* State for via_vb.c and via_tris.c.
*/
GLuint newState; /* _NEW_* flags */
+ GLuint newEmitState; /* _NEW_* flags */
GLuint setupNewInputs;
GLuint setupIndex;
GLuint renderIndex;
diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c
index 55220f18f6f..256349a12f2 100644
--- a/src/mesa/drivers/dri/unichrome/via_ioctl.c
+++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c
@@ -32,6 +32,7 @@ v * copy of this software and associated documentation files (the "Software"),
#include "mm.h"
#include "via_context.h"
+#include "via_tris.h"
#include "via_ioctl.h"
#include "via_state.h"
@@ -678,33 +679,36 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
*/
vmesa->dmaLow = 0;
vmesa->dmaCliprectAddr = 0;
- viaValidateState(vmesa->glCtx);
+ vmesa->newEmitState = ~0;
}
-void viaWrapPrimitive( viaContextPtr vmesa )
+static void viaWrapPrimitive( viaContextPtr vmesa )
{
+ GLenum renderPrimitive = vmesa->renderPrimitive;
+ GLenum hwPrimitive = vmesa->hwPrimitive;
+
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
- viaFinishPrimitive( vmesa );
- LOCK_HARDWARE(vmesa);
- viaFlushDmaLocked(vmesa, 0);
- UNLOCK_HARDWARE(vmesa);
+ if (vmesa->dmaLastPrim)
+ viaFinishPrimitive( vmesa );
+
+ viaFlushDma(vmesa);
+
+ if (renderPrimitive != GL_POLYGON + 1)
+ viaRasterPrimitive( vmesa->glCtx,
+ renderPrimitive,
+ hwPrimitive );
- viaRasterPrimitive( vmesa->glCtx,
- vmesa->renderPrimitive,
- vmesa->hwPrimitive );
}
void viaFlushDma(viaContextPtr vmesa)
{
if (vmesa->dmaLow) {
- if (vmesa->dmaLastPrim)
- viaWrapPrimitive(vmesa);
- else {
- LOCK_HARDWARE(vmesa);
- viaFlushDmaLocked(vmesa, 0);
- UNLOCK_HARDWARE(vmesa);
- }
+ assert(!vmesa->dmaLastPrim);
+
+ LOCK_HARDWARE(vmesa);
+ viaFlushDmaLocked(vmesa, 0);
+ UNLOCK_HARDWARE(vmesa);
}
}
@@ -739,6 +743,7 @@ void viaInitIoctlFuncs(GLcontext *ctx)
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line)
{
+ assert(!vmesa->dmaLastPrim);
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
if (VIA_DEBUG) fprintf(stderr, "buffer overflow in check dma = %d + %d = %d\n",
vmesa->dmaLow, bytes, vmesa->dmaLow + bytes);
@@ -748,8 +753,21 @@ GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int li
{
GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
vmesa->dmaLow += bytes;
- if (VIA_DEBUG && (vmesa->dmaLow & 0x4))
- fprintf(stderr, "%s/%d: alloc 0x%x --> dmaLow 0x%x\n", func, line, bytes, vmesa->dmaLow);
+ return start;
+ }
+}
+
+
+GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes)
+{
+ assert(vmesa->dmaLastPrim);
+ if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
+ viaWrapPrimitive(vmesa);
+ }
+
+ {
+ GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
+ vmesa->dmaLow += bytes;
return start;
}
}
diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.h b/src/mesa/drivers/dri/unichrome/via_ioctl.h
index ddb75ba6b81..b5dd9a8e5cb 100644
--- a/src/mesa/drivers/dri/unichrome/via_ioctl.h
+++ b/src/mesa/drivers/dri/unichrome/via_ioctl.h
@@ -49,6 +49,7 @@ void viaCheckDma(viaContextPtr vmesa, GLuint bytes);
} while (0)
+GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes);
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line);
#define viaAllocDma( v, b ) viaAllocDmaFunc(v, b, __FUNCTION__, __LINE__)
diff --git a/src/mesa/drivers/dri/unichrome/via_render.c b/src/mesa/drivers/dri/unichrome/via_render.c
index 0b4f512b26f..8e4efd220f9 100644
--- a/src/mesa/drivers/dri/unichrome/via_render.c
+++ b/src/mesa/drivers/dri/unichrome/via_render.c
@@ -70,7 +70,7 @@
(VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4)
#define ALLOC_VERTS( nr ) \
- viaAllocDma( vmesa, (nr) * vmesa->vertexSize * 4)
+ viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
#define EMIT_VERTS(ctx, j, nr, buf) \
via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c
index ef3846106d0..547bf8b7ff7 100644
--- a/src/mesa/drivers/dri/unichrome/via_state.c
+++ b/src/mesa/drivers/dri/unichrome/via_state.c
@@ -69,7 +69,7 @@ static GLuint ROP[16] = {
-static void via_emit_state(viaContextPtr vmesa)
+void viaEmitState(viaContextPtr vmesa)
{
GLcontext *ctx = vmesa->glCtx;
GLuint i = 0;
@@ -516,6 +516,8 @@ static void via_emit_state(viaContextPtr vmesa)
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
+
+ vmesa->newEmitState = 0;
}
@@ -1548,9 +1550,7 @@ void viaValidateState( GLcontext *ctx )
viaChooseStencilState(ctx);
if (!vmesa->Fallback) {
- viaChooseVertexState(ctx);
- viaChooseRenderState(ctx);
- via_emit_state(vmesa);
+ vmesa->newEmitState |= vmesa->newState;
vmesa->newState = 0;
}
diff --git a/src/mesa/drivers/dri/unichrome/via_state.h b/src/mesa/drivers/dri/unichrome/via_state.h
index da69d303a0b..2603c158719 100644
--- a/src/mesa/drivers/dri/unichrome/via_state.h
+++ b/src/mesa/drivers/dri/unichrome/via_state.h
@@ -31,6 +31,7 @@ extern void viaInitState(GLcontext *ctx);
extern void viaInitStateFuncs(GLcontext *ctx);
extern void viaCalcViewport(GLcontext *ctx);
extern void viaValidateState(GLcontext *ctx);
+extern void viaEmitState(viaContextPtr vmesa);
extern void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode);
#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode)
diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c
index 4d2092f3611..862c827300f 100644
--- a/src/mesa/drivers/dri/unichrome/via_tris.c
+++ b/src/mesa/drivers/dri/unichrome/via_tris.c
@@ -40,6 +40,7 @@
#include "via_context.h"
#include "via_tris.h"
#include "via_state.h"
+#include "via_span.h"
#include "via_vb.h"
#include "via_ioctl.h"
@@ -74,7 +75,7 @@ static void __inline__ via_draw_triangle(viaContextPtr vmesa,
viaVertexPtr v2)
{
GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaAllocDma(vmesa, 3 * 4 * vertsize);
+ GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize);
/* fprintf(stderr, "%s: %p %p %p\n", __FUNCTION__, v0, v1, v2); */
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
@@ -89,7 +90,7 @@ static void __inline__ via_draw_quad(viaContextPtr vmesa,
viaVertexPtr v3)
{
GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaAllocDma(vmesa, 6 * 4 * vertsize);
+ GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize);
/* fprintf(stderr, "%s: %p %p %p %p\n", __FUNCTION__, v0, v1, v2, v3); */
COPY_DWORDS(vb, vertsize, v0);
@@ -105,7 +106,7 @@ static __inline__ void via_draw_line(viaContextPtr vmesa,
viaVertexPtr v1)
{
GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaAllocDma(vmesa, 2 * 4 * vertsize);
+ GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
}
@@ -115,7 +116,7 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
viaVertexPtr v0)
{
GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaAllocDma(vmesa, 4 * vertsize);
+ GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
}
@@ -521,7 +522,7 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaAllocDma(vmesa, (n - 2) * 3 * 4 * vertsize);
+ GLuint *vb = viaExtendPrimitive(vmesa, (n - 2) * 3 * 4 * vertsize);
GLubyte *vertptr = (GLubyte *)vmesa->verts;
const GLuint *start = (const GLuint *)V(elts[0]);
int i;
@@ -632,6 +633,8 @@ static void viaRunPipeline(GLcontext *ctx)
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (vmesa->newState) {
+ viaChooseVertexState(ctx);
+ viaChooseRenderState(ctx);
viaValidateState( ctx );
}
@@ -672,8 +675,14 @@ void viaRasterPrimitive(GLcontext *ctx,
_mesa_lookup_enum_by_nr(hwprim));
VIA_FINISH_PRIM(vmesa);
+
viaCheckDma( vmesa, 1024 ); /* Ensure no wrapping inside this function */
+ if (vmesa->newEmitState) {
+ viaEmitState(vmesa);
+ }
+
+
regCmdB = vmesa->regCmdB;
switch (hwprim) {
@@ -782,12 +791,13 @@ void viaFinishPrimitive(viaContextPtr vmesa)
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
if (!vmesa->dmaLastPrim) {
- return;
}
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
RING_VARS;
+ vmesa->dmaLastPrim = 0;
+
/* KW: modified 0x1 to 0x4 below:
*/
if ((vmesa->dmaLow & 0x1) || !vmesa->useAgp) {
@@ -801,7 +811,6 @@ void viaFinishPrimitive(viaContextPtr vmesa)
OUT_RING( cmdA );
ADVANCE_RING();
}
- vmesa->dmaLastPrim = 0;
if (vmesa->dmaLow > VIA_DMA_HIGHWATER)
viaFlushDma( vmesa );
@@ -819,6 +828,10 @@ void viaFinishPrimitive(viaContextPtr vmesa)
vmesa->dmaCliprectAddr = 0;
}
}
+
+ vmesa->renderPrimitive = GL_POLYGON + 1;
+ vmesa->hwPrimitive = GL_POLYGON + 1;
+ vmesa->dmaLastPrim = 0;
}