gallium: Have pipe_buffer_* receive a pipe_screen instead of a pipe_context.
[mesa.git] / src / mesa / state_tracker / st_cb_feedback.c
index b97b2bb0271605a91294205cca60b16c76620c23..19021411cfc9ec9fc6581d6c4cd2400ad3768d84 100644 (file)
@@ -43,7 +43,6 @@
 #include "main/macros.h"
 
 #include "vbo/vbo.h"
-#include "vbo/vbo_context.h"
 
 #include "st_context.h"
 #include "st_atom.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_winsys.h"
-#include "pipe/tgsi/exec/tgsi_attribs.h"
-#include "vf/vf.h"
+#include "cso_cache/cso_cache.h"
 
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_private.h"
+#include "draw/draw_context.h"
+#include "draw/draw_pipe.h"
 
 
 /**
@@ -87,24 +85,31 @@ static void
 feedback_vertex(GLcontext *ctx, const struct draw_context *draw,
                 const struct vertex_header *v)
 {
+   const struct st_context *st = ctx->st;
    GLfloat win[4];
    const GLfloat *color, *texcoord;
    const GLfloat ci = 0;
    GLuint slot;
 
+   /* Recall that Y=0=Top of window for Gallium wincoords */
    win[0] = v->data[0][0];
-   win[1] = v->data[0][1];
+   win[1] = ctx->DrawBuffer->Height - v->data[0][1];
    win[2] = v->data[0][2];
    win[3] = 1.0F / v->data[0][3];
 
-   slot = draw->vertex_info.attrib_to_slot[TGSI_ATTRIB_COLOR0];
-   if (slot)
+   /* XXX
+    * When we compute vertex layout, save info about position of the
+    * color and texcoord attribs to use here.
+    */
+
+   slot = st->vertex_result_to_slot[VERT_RESULT_COL0];
+   if (slot != ~0U)
       color = v->data[slot];
    else
       color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
 
-   slot = draw->vertex_info.attrib_to_slot[TGSI_ATTRIB_TEX0];
-   if (slot)
+   slot = st->vertex_result_to_slot[VERT_RESULT_TEX0];
+   if (slot != ~0U)
       texcoord = v->data[slot];
    else
       texcoord = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
@@ -154,27 +159,26 @@ feedback_point( struct draw_stage *stage, struct prim_header *prim )
 
 
 static void
-feedback_end( struct draw_stage *stage )
+feedback_flush( struct draw_stage *stage, unsigned flags )
 {
    /* no-op */
 }
 
 
 static void
-feedback_begin( struct draw_stage *stage )
+feedback_reset_stipple_counter( struct draw_stage *stage )
 {
-   /* no-op */
+   struct feedback_stage *fs = feedback_stage(stage);
+   fs->reset_stipple_counter = GL_TRUE;
 }
 
 
 static void
-feedback_reset_stipple_counter( struct draw_stage *stage )
+feedback_destroy( struct draw_stage *stage )
 {
-   struct feedback_stage *fs = feedback_stage(stage);
-   fs->reset_stipple_counter = GL_TRUE;
+   /* no-op */
 }
 
-
 /**
  * Create GL feedback drawing stage.
  */
@@ -185,12 +189,12 @@ draw_glfeedback_stage(GLcontext *ctx, struct draw_context *draw)
 
    fs->stage.draw = draw;
    fs->stage.next = NULL;
-   fs->stage.begin = feedback_begin;
    fs->stage.point = feedback_point;
    fs->stage.line = feedback_line;
    fs->stage.tri = feedback_tri;
-   fs->stage.end = feedback_end;
+   fs->stage.flush = feedback_flush;
    fs->stage.reset_stipple_counter = feedback_reset_stipple_counter;
+   fs->stage.destroy = feedback_destroy;
    fs->ctx = ctx;
 
    return &fs->stage;
@@ -229,21 +233,20 @@ select_point( struct draw_stage *stage, struct prim_header *prim )
 
 
 static void
-select_begin( struct draw_stage *stage )
+select_flush( struct draw_stage *stage, unsigned flags )
 {
    /* no-op */
 }
 
 
 static void
-select_end( struct draw_stage *stage )
+select_reset_stipple_counter( struct draw_stage *stage )
 {
    /* no-op */
 }
 
-
 static void
-select_reset_stipple_counter( struct draw_stage *stage )
+select_destroy( struct draw_stage *stage )
 {
    /* no-op */
 }
@@ -259,12 +262,12 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw)
 
    fs->stage.draw = draw;
    fs->stage.next = NULL;
-   fs->stage.begin = select_begin;
    fs->stage.point = select_point;
    fs->stage.line = select_line;
    fs->stage.tri = select_tri;
-   fs->stage.end = select_end;
+   fs->stage.flush = select_flush;
    fs->stage.reset_stipple_counter = select_reset_stipple_counter;
+   fs->stage.destroy = select_destroy;
    fs->ctx = ctx;
 
    return &fs->stage;
@@ -275,26 +278,27 @@ static void
 st_RenderMode(GLcontext *ctx, GLenum newMode )
 {
    struct st_context *st = ctx->st;
-   struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im;
    struct draw_context *draw = st->draw;
 
    if (newMode == GL_RENDER) {
       /* restore normal VBO draw function */
-      vbo->draw_prims = st_draw_vbo;
+      vbo_set_draw_func(ctx, st_draw_vbo);
    }
    else if (newMode == GL_SELECT) {
       if (!st->selection_stage)
          st->selection_stage = draw_glselect_stage(ctx, draw);
-      draw_set_setup_stage(draw, st->selection_stage);
+      draw_set_rasterize_stage(draw, st->selection_stage);
       /* Plug in new vbo draw function */
-      vbo->draw_prims = st_feedback_draw_vbo;
+      vbo_set_draw_func(ctx, st_feedback_draw_vbo);
    }
    else {
       if (!st->feedback_stage)
          st->feedback_stage = draw_glfeedback_stage(ctx, draw);
-      draw_set_setup_stage(draw, st->feedback_stage);
+      draw_set_rasterize_stage(draw, st->feedback_stage);
       /* Plug in new vbo draw function */
-      vbo->draw_prims = st_feedback_draw_vbo;
+      vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+      /* need to generate/use a vertex program that emits pos/color/tex */
+      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
    }
 }