remaining.
if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
vmesa->sarea->ctxOwner = vmesa->hHWContext;
- vmesa->newState = ~0;
+ vmesa->newEmitState = ~0;
}
if (vmesa->lastStamp != dPriv->lastStamp) {
/* State for via_vb.c and via_tris.c.
*/
GLuint newState; /* _NEW_* flags */
+ GLuint newEmitState; /* _NEW_* flags */
GLuint setupNewInputs;
GLuint setupIndex;
GLuint renderIndex;
#include "mm.h"
#include "via_context.h"
+#include "via_tris.h"
#include "via_ioctl.h"
#include "via_state.h"
*/
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);
}
}
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);
{
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;
}
}
} 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__)
(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)
-static void via_emit_state(viaContextPtr vmesa)
+void viaEmitState(viaContextPtr vmesa)
{
GLcontext *ctx = vmesa->glCtx;
GLuint i = 0;
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
+
+ vmesa->newEmitState = 0;
}
viaChooseStencilState(ctx);
if (!vmesa->Fallback) {
- viaChooseVertexState(ctx);
- viaChooseRenderState(ctx);
- via_emit_state(vmesa);
+ vmesa->newEmitState |= vmesa->newState;
vmesa->newState = 0;
}
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)
#include "via_context.h"
#include "via_tris.h"
#include "via_state.h"
+#include "via_span.h"
#include "via_vb.h"
#include "via_ioctl.h"
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);
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);
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);
}
viaVertexPtr v0)
{
GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaAllocDma(vmesa, 4 * vertsize);
+ GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
}
{
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;
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (vmesa->newState) {
+ viaChooseVertexState(ctx);
+ viaChooseRenderState(ctx);
viaValidateState( 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) {
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) {
OUT_RING( cmdA );
ADVANCE_RING();
}
- vmesa->dmaLastPrim = 0;
if (vmesa->dmaLow > VIA_DMA_HIGHWATER)
viaFlushDma( vmesa );
vmesa->dmaCliprectAddr = 0;
}
}
+
+ vmesa->renderPrimitive = GL_POLYGON + 1;
+ vmesa->hwPrimitive = GL_POLYGON + 1;
+ vmesa->dmaLastPrim = 0;
}