i965: Fix occlusion query on sandybridge
[mesa.git] / src / mesa / drivers / dri / i810 / i810render.c
index d1c1adc3b7cae62ad41c8470423a44ee5d245a22..45f0954bbe26369b158ae5e5ba06953b27c47159 100644 (file)
  * dma buffers.  Use strip/fan hardware acceleration where possible.
  *
  */
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+
+#include "math/m_xform.h"
 
 #include "tnl/t_context.h"
 
@@ -44,7 +46,6 @@
 
 #include "i810context.h"
 #include "i810tris.h"
-#include "i810state.h"
 #include "i810vb.h"
 #include "i810ioctl.h"
 
@@ -93,20 +94,6 @@ static const GLenum reduced_prim[GL_POLYGON+1] = {
    GL_TRIANGLES
 };
 
-/* Fallback to normal rendering.
- */
-static void VERT_FALLBACK( GLcontext *ctx,
-                          GLuint start,
-                          GLuint count,
-                          GLuint flags )
-{
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-   tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
-   tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
-   tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, 
-                                                         count, flags );
-   I810_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS;
-}
 
 
 
@@ -115,16 +102,17 @@ static void VERT_FALLBACK( GLcontext *ctx,
    I810_STATECHANGE(imesa, 0);                                         \
    i810RasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] );      \
 } while (0)
-#define NEW_PRIMITIVE()  I810_STATECHANGE( imesa, 0 )
-#define NEW_BUFFER()  I810_FIREVERTICES( imesa )
 #define GET_CURRENT_VB_MAX_VERTS() \
   (((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
   (I810_DMA_BUF_SZ-4) / (imesa->vertex_size * 4)
 
+#define ALLOC_VERTS( nr ) \
+  i810AllocDmaLow( imesa, (nr) * imesa->vertex_size * 4)
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+  i810_emit_contiguous_verts(ctx, j, (j)+(nr), buf)
 
-#define EMIT_VERTS( ctx, j, nr ) \
-  i810_emit_contiguous_verts(ctx, j, (j)+(nr))
+#define FLUSH()  I810_FIREVERTICES( imesa )
 
 
 #define TAG(x) i810_##x
@@ -136,7 +124,7 @@ static void VERT_FALLBACK( GLcontext *ctx,
 /**********************************************************************/
 
 
-static GLboolean i810_run_render( GLcontext *ctx,
+static GLboolean i810_run_render( struct gl_context *ctx,
                                  struct tnl_pipeline_stage *stage )
 {
    i810ContextPtr imesa = I810_CONTEXT(ctx);
@@ -146,7 +134,8 @@ static GLboolean i810_run_render( GLcontext *ctx,
 
    /* Don't handle clipping or indexed vertices.
     */
-   if (VB->ClipOrMask || imesa->RenderIndex != 0 || VB->Elts) {
+   if (imesa->RenderIndex != 0 || 
+       !i810_validate_render( ctx, VB )) {
       return GL_TRUE;
    }
 
@@ -156,7 +145,7 @@ static GLboolean i810_run_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
@@ -173,46 +162,13 @@ static GLboolean i810_run_render( GLcontext *ctx,
 }
 
 
-static void i810_check_render( GLcontext *ctx, struct tnl_pipeline_stage *stage )
-{
-   GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
-
-   if (ctx->RenderMode == GL_RENDER) {
-      if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
-        inputs |= VERT_BIT_COLOR1;
-
-      if (ctx->Texture.Unit[0]._ReallyEnabled)
-        inputs |= VERT_BIT_TEX0;
-
-      if (ctx->Texture.Unit[1]._ReallyEnabled)
-        inputs |= VERT_BIT_TEX1;
-
-      if (ctx->Fog.Enabled)
-        inputs |= VERT_BIT_FOG;
-   }
-
-   stage->inputs = inputs;
-}
-
-
-static void dtr( struct tnl_pipeline_stage *stage )
-{
-   (void)stage;
-}
-
 
 const struct tnl_pipeline_stage _i810_render_stage =
 {
    "i810 render",
-   (_DD_NEW_SEPARATE_SPECULAR |
-    _NEW_TEXTURE|
-    _NEW_FOG|
-    _NEW_RENDERMODE),          /* re-check (new inputs) */
-   0,                          /* re-run (always runs) */
-   GL_TRUE,                    /* active */
-   0, 0,                       /* inputs (set in check_render), outputs */
-   0, 0,                       /* changed_inputs, private */
-   dtr,                                /* destructor */
-   i810_check_render,          /* check - initially set to alloc data */
+   NULL,
+   NULL,
+   NULL,
+   NULL,
    i810_run_render             /* run */
 };