Merge branch '7.8'
[mesa.git] / src / mesa / state_tracker / st_cb_rasterpos.c
index 3eaccb74e17fff4b1697734a816d2b7ebdbafbab..843f3200278d3f79a9bdc76d669451c6e69ac5dd 100644 (file)
@@ -47,7 +47,6 @@
 #include "st_draw.h"
 #include "draw/draw_context.h"
 #include "draw/draw_pipe.h"
-#include "shader/prog_instruction.h"
 #include "vbo/vbo.h"
 
 
@@ -134,7 +133,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
 {
    struct rastpos_stage *rs = rastpos_stage(stage);
    GLcontext *ctx = rs->ctx;
-   struct st_context *st = ctx->st;
+   struct st_context *st = st_context(ctx);
    const GLfloat height = (GLfloat) ctx->DrawBuffer->Height;
    const GLuint *outputMapping = st->vertex_result_to_slot;
    const GLfloat *pos;
@@ -162,7 +161,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
                  ctx->Current.RasterSecondaryColor,
                  VERT_RESULT_COL1, VERT_ATTRIB_COLOR1);
 
-   for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
       update_attrib(ctx, outputMapping, prim->v[0],
                     ctx->Current.RasterTexCoords[i],
                     VERT_RESULT_TEX0 + i, VERT_ATTRIB_TEX0 + i);
@@ -180,7 +179,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
 static struct rastpos_stage *
 new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
 {
-   struct rastpos_stage *rs = CALLOC_STRUCT(rastpos_stage);
+   struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
    GLuint i;
 
    rs->stage.draw = draw;
@@ -194,9 +193,10 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
    rs->stage.destroy = rastpos_destroy;
    rs->ctx = ctx;
 
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+   for (i = 0; i < Elements(rs->array); i++) {
       rs->array[i].Size = 4;
       rs->array[i].Type = GL_FLOAT;
+      rs->array[i].Format = GL_RGBA;
       rs->array[i].Stride = 0;
       rs->array[i].StrideB = 0;
       rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
@@ -221,7 +221,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
 static void
 st_RasterPos(GLcontext *ctx, const GLfloat v[4])
 {
-   struct st_context *st = ctx->st;
+   struct st_context *st = st_context(ctx);
    struct draw_context *draw = st->draw;
    struct rastpos_stage *rs;
 
@@ -239,7 +239,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4])
    draw_set_rasterize_stage(st->draw, st->rastpos_stage);
 
    /* make sure everything's up to date */
-   st_validate_state(ctx->st);
+   st_validate_state(st);
 
    /* This will get set only if rastpos_point(), above, gets called */
    ctx->Current.RasterPosValid = GL_FALSE;
@@ -250,7 +250,15 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4])
    rs->array[0].Ptr = (GLubyte *) v;
 
    /* draw the point */
-   st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, 0, 1);
+   st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, GL_TRUE, 0, 1);
+
+   /* restore draw's rasterization stage depending on rendermode */
+   if (ctx->RenderMode == GL_FEEDBACK) {
+      draw_set_rasterize_stage(draw, st->feedback_stage);
+   }
+   else if (ctx->RenderMode == GL_SELECT) {
+      draw_set_rasterize_stage(draw, st->selection_stage);
+   }
 }