Fix some wrapping bugs in the last commit. Probably there are more
remaining.
This commit is contained in:
parent
490e764d7a
commit
5be14fd59a
|
@ -681,7 +681,7 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags)
|
||||||
|
|
||||||
if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
|
if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
|
||||||
vmesa->sarea->ctxOwner = vmesa->hHWContext;
|
vmesa->sarea->ctxOwner = vmesa->hHWContext;
|
||||||
vmesa->newState = ~0;
|
vmesa->newEmitState = ~0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmesa->lastStamp != dPriv->lastStamp) {
|
if (vmesa->lastStamp != dPriv->lastStamp) {
|
||||||
|
|
|
@ -123,6 +123,7 @@ struct via_context_t {
|
||||||
/* State for via_vb.c and via_tris.c.
|
/* State for via_vb.c and via_tris.c.
|
||||||
*/
|
*/
|
||||||
GLuint newState; /* _NEW_* flags */
|
GLuint newState; /* _NEW_* flags */
|
||||||
|
GLuint newEmitState; /* _NEW_* flags */
|
||||||
GLuint setupNewInputs;
|
GLuint setupNewInputs;
|
||||||
GLuint setupIndex;
|
GLuint setupIndex;
|
||||||
GLuint renderIndex;
|
GLuint renderIndex;
|
||||||
|
|
|
@ -32,6 +32,7 @@ v * copy of this software and associated documentation files (the "Software"),
|
||||||
|
|
||||||
#include "mm.h"
|
#include "mm.h"
|
||||||
#include "via_context.h"
|
#include "via_context.h"
|
||||||
|
#include "via_tris.h"
|
||||||
#include "via_ioctl.h"
|
#include "via_ioctl.h"
|
||||||
#include "via_state.h"
|
#include "via_state.h"
|
||||||
|
|
||||||
|
@ -678,33 +679,36 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
|
||||||
*/
|
*/
|
||||||
vmesa->dmaLow = 0;
|
vmesa->dmaLow = 0;
|
||||||
vmesa->dmaCliprectAddr = 0;
|
vmesa->dmaCliprectAddr = 0;
|
||||||
viaValidateState(vmesa->glCtx);
|
vmesa->newEmitState = ~0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void viaWrapPrimitive( viaContextPtr vmesa )
|
static void viaWrapPrimitive( viaContextPtr vmesa )
|
||||||
{
|
{
|
||||||
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
|
GLenum renderPrimitive = vmesa->renderPrimitive;
|
||||||
viaFinishPrimitive( vmesa );
|
GLenum hwPrimitive = vmesa->hwPrimitive;
|
||||||
|
|
||||||
LOCK_HARDWARE(vmesa);
|
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
|
||||||
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)
|
void viaFlushDma(viaContextPtr vmesa)
|
||||||
{
|
{
|
||||||
if (vmesa->dmaLow) {
|
if (vmesa->dmaLow) {
|
||||||
if (vmesa->dmaLastPrim)
|
assert(!vmesa->dmaLastPrim);
|
||||||
viaWrapPrimitive(vmesa);
|
|
||||||
else {
|
LOCK_HARDWARE(vmesa);
|
||||||
LOCK_HARDWARE(vmesa);
|
viaFlushDmaLocked(vmesa, 0);
|
||||||
viaFlushDmaLocked(vmesa, 0);
|
UNLOCK_HARDWARE(vmesa);
|
||||||
UNLOCK_HARDWARE(vmesa);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,6 +743,7 @@ void viaInitIoctlFuncs(GLcontext *ctx)
|
||||||
|
|
||||||
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line)
|
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line)
|
||||||
{
|
{
|
||||||
|
assert(!vmesa->dmaLastPrim);
|
||||||
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
|
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
|
||||||
if (VIA_DEBUG) fprintf(stderr, "buffer overflow in check dma = %d + %d = %d\n",
|
if (VIA_DEBUG) fprintf(stderr, "buffer overflow in check dma = %d + %d = %d\n",
|
||||||
vmesa->dmaLow, bytes, vmesa->dmaLow + bytes);
|
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);
|
GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
|
||||||
vmesa->dmaLow += bytes;
|
vmesa->dmaLow += bytes;
|
||||||
if (VIA_DEBUG && (vmesa->dmaLow & 0x4))
|
return start;
|
||||||
fprintf(stderr, "%s/%d: alloc 0x%x --> dmaLow 0x%x\n", func, line, bytes, vmesa->dmaLow);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
return start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ void viaCheckDma(viaContextPtr vmesa, GLuint bytes);
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes);
|
||||||
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line);
|
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line);
|
||||||
#define viaAllocDma( v, b ) viaAllocDmaFunc(v, b, __FUNCTION__, __LINE__)
|
#define viaAllocDma( v, b ) viaAllocDmaFunc(v, b, __FUNCTION__, __LINE__)
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
(VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4)
|
(VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4)
|
||||||
|
|
||||||
#define ALLOC_VERTS( nr ) \
|
#define ALLOC_VERTS( nr ) \
|
||||||
viaAllocDma( vmesa, (nr) * vmesa->vertexSize * 4)
|
viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
|
||||||
|
|
||||||
#define EMIT_VERTS(ctx, j, nr, buf) \
|
#define EMIT_VERTS(ctx, j, nr, buf) \
|
||||||
via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
|
via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
|
||||||
|
|
|
@ -69,7 +69,7 @@ static GLuint ROP[16] = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void via_emit_state(viaContextPtr vmesa)
|
void viaEmitState(viaContextPtr vmesa)
|
||||||
{
|
{
|
||||||
GLcontext *ctx = vmesa->glCtx;
|
GLcontext *ctx = vmesa->glCtx;
|
||||||
GLuint i = 0;
|
GLuint i = 0;
|
||||||
|
@ -516,6 +516,8 @@ static void via_emit_state(viaContextPtr vmesa)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||||
|
|
||||||
|
vmesa->newEmitState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1548,9 +1550,7 @@ void viaValidateState( GLcontext *ctx )
|
||||||
viaChooseStencilState(ctx);
|
viaChooseStencilState(ctx);
|
||||||
|
|
||||||
if (!vmesa->Fallback) {
|
if (!vmesa->Fallback) {
|
||||||
viaChooseVertexState(ctx);
|
vmesa->newEmitState |= vmesa->newState;
|
||||||
viaChooseRenderState(ctx);
|
|
||||||
via_emit_state(vmesa);
|
|
||||||
vmesa->newState = 0;
|
vmesa->newState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ extern void viaInitState(GLcontext *ctx);
|
||||||
extern void viaInitStateFuncs(GLcontext *ctx);
|
extern void viaInitStateFuncs(GLcontext *ctx);
|
||||||
extern void viaCalcViewport(GLcontext *ctx);
|
extern void viaCalcViewport(GLcontext *ctx);
|
||||||
extern void viaValidateState(GLcontext *ctx);
|
extern void viaValidateState(GLcontext *ctx);
|
||||||
|
extern void viaEmitState(viaContextPtr vmesa);
|
||||||
|
|
||||||
extern void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode);
|
extern void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode);
|
||||||
#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode)
|
#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode)
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "via_context.h"
|
#include "via_context.h"
|
||||||
#include "via_tris.h"
|
#include "via_tris.h"
|
||||||
#include "via_state.h"
|
#include "via_state.h"
|
||||||
|
#include "via_span.h"
|
||||||
#include "via_vb.h"
|
#include "via_vb.h"
|
||||||
#include "via_ioctl.h"
|
#include "via_ioctl.h"
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ static void __inline__ via_draw_triangle(viaContextPtr vmesa,
|
||||||
viaVertexPtr v2)
|
viaVertexPtr v2)
|
||||||
{
|
{
|
||||||
GLuint vertsize = vmesa->vertexSize;
|
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); */
|
/* fprintf(stderr, "%s: %p %p %p\n", __FUNCTION__, v0, v1, v2); */
|
||||||
COPY_DWORDS(vb, vertsize, v0);
|
COPY_DWORDS(vb, vertsize, v0);
|
||||||
COPY_DWORDS(vb, vertsize, v1);
|
COPY_DWORDS(vb, vertsize, v1);
|
||||||
|
@ -89,7 +90,7 @@ static void __inline__ via_draw_quad(viaContextPtr vmesa,
|
||||||
viaVertexPtr v3)
|
viaVertexPtr v3)
|
||||||
{
|
{
|
||||||
GLuint vertsize = vmesa->vertexSize;
|
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); */
|
/* fprintf(stderr, "%s: %p %p %p %p\n", __FUNCTION__, v0, v1, v2, v3); */
|
||||||
COPY_DWORDS(vb, vertsize, v0);
|
COPY_DWORDS(vb, vertsize, v0);
|
||||||
|
@ -105,7 +106,7 @@ static __inline__ void via_draw_line(viaContextPtr vmesa,
|
||||||
viaVertexPtr v1)
|
viaVertexPtr v1)
|
||||||
{
|
{
|
||||||
GLuint vertsize = vmesa->vertexSize;
|
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, v0);
|
||||||
COPY_DWORDS(vb, vertsize, v1);
|
COPY_DWORDS(vb, vertsize, v1);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +116,7 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
|
||||||
viaVertexPtr v0)
|
viaVertexPtr v0)
|
||||||
{
|
{
|
||||||
GLuint vertsize = vmesa->vertexSize;
|
GLuint vertsize = vmesa->vertexSize;
|
||||||
GLuint *vb = viaAllocDma(vmesa, 4 * vertsize);
|
GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
|
||||||
COPY_DWORDS(vb, vertsize, v0);
|
COPY_DWORDS(vb, vertsize, v0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +522,7 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
|
||||||
{
|
{
|
||||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||||
GLuint vertsize = vmesa->vertexSize;
|
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;
|
GLubyte *vertptr = (GLubyte *)vmesa->verts;
|
||||||
const GLuint *start = (const GLuint *)V(elts[0]);
|
const GLuint *start = (const GLuint *)V(elts[0]);
|
||||||
int i;
|
int i;
|
||||||
|
@ -632,6 +633,8 @@ static void viaRunPipeline(GLcontext *ctx)
|
||||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||||
|
|
||||||
if (vmesa->newState) {
|
if (vmesa->newState) {
|
||||||
|
viaChooseVertexState(ctx);
|
||||||
|
viaChooseRenderState(ctx);
|
||||||
viaValidateState( ctx );
|
viaValidateState( ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,8 +675,14 @@ void viaRasterPrimitive(GLcontext *ctx,
|
||||||
_mesa_lookup_enum_by_nr(hwprim));
|
_mesa_lookup_enum_by_nr(hwprim));
|
||||||
|
|
||||||
VIA_FINISH_PRIM(vmesa);
|
VIA_FINISH_PRIM(vmesa);
|
||||||
|
|
||||||
viaCheckDma( vmesa, 1024 ); /* Ensure no wrapping inside this function */
|
viaCheckDma( vmesa, 1024 ); /* Ensure no wrapping inside this function */
|
||||||
|
|
||||||
|
if (vmesa->newEmitState) {
|
||||||
|
viaEmitState(vmesa);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
regCmdB = vmesa->regCmdB;
|
regCmdB = vmesa->regCmdB;
|
||||||
|
|
||||||
switch (hwprim) {
|
switch (hwprim) {
|
||||||
|
@ -782,12 +791,13 @@ void viaFinishPrimitive(viaContextPtr vmesa)
|
||||||
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
|
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
|
||||||
|
|
||||||
if (!vmesa->dmaLastPrim) {
|
if (!vmesa->dmaLastPrim) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
|
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
|
||||||
GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
|
GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
|
||||||
RING_VARS;
|
RING_VARS;
|
||||||
|
|
||||||
|
vmesa->dmaLastPrim = 0;
|
||||||
|
|
||||||
/* KW: modified 0x1 to 0x4 below:
|
/* KW: modified 0x1 to 0x4 below:
|
||||||
*/
|
*/
|
||||||
if ((vmesa->dmaLow & 0x1) || !vmesa->useAgp) {
|
if ((vmesa->dmaLow & 0x1) || !vmesa->useAgp) {
|
||||||
|
@ -801,7 +811,6 @@ void viaFinishPrimitive(viaContextPtr vmesa)
|
||||||
OUT_RING( cmdA );
|
OUT_RING( cmdA );
|
||||||
ADVANCE_RING();
|
ADVANCE_RING();
|
||||||
}
|
}
|
||||||
vmesa->dmaLastPrim = 0;
|
|
||||||
|
|
||||||
if (vmesa->dmaLow > VIA_DMA_HIGHWATER)
|
if (vmesa->dmaLow > VIA_DMA_HIGHWATER)
|
||||||
viaFlushDma( vmesa );
|
viaFlushDma( vmesa );
|
||||||
|
@ -819,6 +828,10 @@ void viaFinishPrimitive(viaContextPtr vmesa)
|
||||||
vmesa->dmaCliprectAddr = 0;
|
vmesa->dmaCliprectAddr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vmesa->renderPrimitive = GL_POLYGON + 1;
|
||||||
|
vmesa->hwPrimitive = GL_POLYGON + 1;
|
||||||
|
vmesa->dmaLastPrim = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue