#include <stdio.h>
-#include "glheader.h"
-#include "buffers.h"
-#include "context.h"
-#include "macros.h"
-#include "colormac.h"
-#include "enums.h"
-#include "dd.h"
-
-#include "mm.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/colormac.h"
+#include "main/enums.h"
+#include "main/dd.h"
+#include "main/mm.h"
+
#include "via_context.h"
#include "via_state.h"
#include "via_tex.h"
#include "via_3d_reg.h"
#include "swrast/swrast.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "swrast_setup/swrast_setup.h"
/* KW: This test never succeeds:
*/
if (t->regTexFM == HC_HTXnFM_Index8) {
- struct gl_color_table *table = &texObj->Palette;
- GLfloat *tableF = (GLfloat *)table->Table;
+ const struct gl_color_table *table = &texObj->Palette;
+ const GLfloat *tableF = table->TableF;
BEGIN_RING(2 + table->Size);
OUT_RING( HC_HEADER2 );
/* KW: This test never succeeds:
*/
if (t->regTexFM == HC_HTXnFM_Index8) {
- struct gl_color_table *table = &texObj->Palette;
- GLfloat *tableF = (GLfloat *)table->Table;
+ const struct gl_color_table *table = &texObj->Palette;
+ const GLfloat *tableF = table->TableF;
BEGIN_RING(2 + table->Size);
OUT_RING( HC_HEADER2 );
}
}
+#if 0
+ /* Polygon stipple is broken - for certain stipple values,
+ * eg. 0xf0f0f0f0, the hardware will refuse to accept the stipple.
+ * Coincidentally, conform generates just such a stipple.
+ */
if (ctx->Polygon.StippleFlag) {
GLuint *stipple = &ctx->PolygonStipple[0];
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ struct via_renderbuffer *const vrb =
+ (struct via_renderbuffer *) dPriv->driverPrivate;
+ GLint i;
BEGIN_RING(38);
OUT_RING( HC_HEADER2 );
+
OUT_RING( ((HC_ParaType_Palette << 16) | (HC_SubType_Stipple << 24)) );
- OUT_RING( stipple[31] );
- OUT_RING( stipple[30] );
- OUT_RING( stipple[29] );
- OUT_RING( stipple[28] );
- OUT_RING( stipple[27] );
- OUT_RING( stipple[26] );
- OUT_RING( stipple[25] );
- OUT_RING( stipple[24] );
- OUT_RING( stipple[23] );
- OUT_RING( stipple[22] );
- OUT_RING( stipple[21] );
- OUT_RING( stipple[20] );
- OUT_RING( stipple[19] );
- OUT_RING( stipple[18] );
- OUT_RING( stipple[17] );
- OUT_RING( stipple[16] );
- OUT_RING( stipple[15] );
- OUT_RING( stipple[14] );
- OUT_RING( stipple[13] );
- OUT_RING( stipple[12] );
- OUT_RING( stipple[11] );
- OUT_RING( stipple[10] );
- OUT_RING( stipple[9] );
- OUT_RING( stipple[8] );
- OUT_RING( stipple[7] );
- OUT_RING( stipple[6] );
- OUT_RING( stipple[5] );
- OUT_RING( stipple[4] );
- OUT_RING( stipple[3] );
- OUT_RING( stipple[2] );
- OUT_RING( stipple[1] );
- OUT_RING( stipple[0] );
+ for (i = 31; i >= 0; i--) {
+ GLint j;
+ GLuint k = 0;
+
+ /* Need to flip bits left to right:
+ */
+ for (j = 0 ; j < 32; j++)
+ if (stipple[i] & (1<<j))
+ k |= 1 << (31-j);
+
+ OUT_RING( k );
+ }
+
OUT_RING( HC_HEADER2 );
OUT_RING( (HC_ParaType_NotTex << 16) );
- OUT_RING( (HC_SubA_HSPXYOS << 24) |
- (((31 - vmesa->drawX) & 0x1f) << HC_HSPXOS_SHIFT));
- OUT_RING( (HC_SubA_HSPXYOS << 24) |
- (((31 - vmesa->drawX) & 0x1f) << HC_HSPXOS_SHIFT));
+ OUT_RING( (HC_SubA_HSPXYOS << 24) );
+ OUT_RING( (HC_SubA_HSPXYOS << 24) );
+
ADVANCE_RING();
}
+#endif
vmesa->newEmitState = 0;
}
-static __inline__ GLuint viaPackColor(GLuint bpp,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a)
+static INLINE GLuint viaPackColor(GLuint bpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
{
switch (bpp) {
case 16:
static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
{
- struct via_context *vmesa = VIA_CONTEXT(ctx);
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
- if (VIA_DEBUG & (DEBUG_DRI|DEBUG_STATE))
- fprintf(stderr, "%s in\n", __FUNCTION__);
+ if (VIA_DEBUG & (DEBUG_DRI|DEBUG_STATE))
+ fprintf(stderr, "%s in\n", __FUNCTION__);
- if (mode == GL_FRONT) {
- VIA_FLUSH_DMA(vmesa);
- vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
- FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
- return;
- }
- else if (mode == GL_BACK) {
- VIA_FLUSH_DMA(vmesa);
- vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
- FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
- return;
- }
- else {
- FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE);
- return;
- }
+ if (!ctx->DrawBuffer)
+ return;
+
+ if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE);
+ return;
+ }
- viaXMesaWindowMoved(vmesa);
+ switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+ case BUFFER_FRONT_LEFT:
+ VIA_FLUSH_DMA(vmesa);
+ vmesa->drawBuffer = &vmesa->front;
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
+ break;
+ case BUFFER_BACK_LEFT:
+ VIA_FLUSH_DMA(vmesa);
+ vmesa->drawBuffer = &vmesa->back;
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
+ break;
+ default:
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE);
+ return;
+ }
- /* We want to update the s/w rast state too so that viaSetBuffer()
- * gets called.
- */
- _swrast_DrawBuffer(ctx, mode);
+
+ viaXMesaWindowMoved(vmesa);
}
static void viaClearColor(GLcontext *ctx, const GLfloat color[4])
}
-/* =============================================================
- */
-
-/* Using drawXoff like this is incorrect outside of locked regions.
- * This hardware just isn't capable of private back buffers without
+/* This hardware just isn't capable of private back buffers without
* glitches and/or a hefty locking scheme.
*/
void viaCalcViewport(GLcontext *ctx)
{
struct via_context *vmesa = VIA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ struct via_renderbuffer *const vrb =
+ (struct via_renderbuffer *) dPriv->driverPrivate;
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat *m = vmesa->ViewportMatrix.m;
- /* See also via_translate_vertex.
- */
m[MAT_SX] = v[MAT_SX];
- m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X + vmesa->drawXoff;
+ m[MAT_TX] = v[MAT_TX] + vrb->drawX + SUBPIXEL_X;
m[MAT_SY] = - v[MAT_SY];
- m[MAT_TY] = - v[MAT_TY] + vmesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_TY] = - v[MAT_TY] + vrb->drawY + SUBPIXEL_Y + vrb->drawH;
m[MAT_SZ] = v[MAT_SZ] * (1.0 / vmesa->depth_max);
m[MAT_TZ] = v[MAT_TZ] * (1.0 / vmesa->depth_max);
}
GLint x, GLint y,
GLsizei width, GLsizei height)
{
- /* update size of Mesa/software ancillary buffers */
- _mesa_ResizeBuffersMESA();
viaCalcViewport(ctx);
}
/**
* Convert S and T texture coordinate wrap modes to hardware bits.
*/
-static u_int32_t
+static uint32_t
get_wrap_mode( GLenum sWrap, GLenum tWrap )
{
- u_int32_t v = 0;
+ uint32_t v = 0;
switch( sWrap ) {
return v;
}
-static u_int32_t
+static uint32_t
get_minmag_filter( GLenum min, GLenum mag )
{
- u_int32_t v = 0;
+ uint32_t v = 0;
switch (min) {
case GL_NEAREST:
{
struct via_context *vmesa = VIA_CONTEXT(ctx);
+#if 0
+ /* Polygon stipple is broken - see via_state.c
+ */
if (ctx->Polygon.StippleFlag) {
vmesa->regEnable |= HC_HenSP_MASK;
}
else {
vmesa->regEnable &= ~HC_HenSP_MASK;
}
+#else
+ FALLBACK(vmesa, VIA_FALLBACK_POLY_STIPPLE,
+ ctx->Polygon.StippleFlag);
+#endif
if (ctx->Polygon.CullFlag) {
vmesa->regEnable |= HC_HenFBCull_MASK;
{
struct via_context *vmesa = VIA_CONTEXT(ctx);
- if (ctx->Stencil.Enabled) {
+ if (ctx->Stencil._Enabled) {
GLuint temp;
vmesa->regEnable |= HC_HenST_MASK;
_swrast_InvalidateState(ctx, newState);
_swsetup_InvalidateState(ctx, newState);
- _ac_InvalidateState(ctx, newState);
+ _vbo_InvalidateState(ctx, newState);
_tnl_InvalidateState(ctx, newState);
}
ctx->Driver.Viewport = viaViewport;
ctx->Driver.Enable = viaEnable;
- /* Pixel path fallbacks.
- */
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ /* XXX this should go away */
ctx->Driver.ResizeBuffers = viaReAllocateBuffers;
-
- /* Swrast hooks for imaging extensions:
- */
- ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
}