X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_cb_rasterpos.c;h=e266296a775c01582ea813a906385c919a819a0a;hb=5092610f29b9e10d3835af8b4ed1ca13809657b5;hp=32d465c5cceee5399c67054120409493337855c6;hpb=edc09358f72cd48cb2315daf23c82e7646aeaea3;p=mesa.git diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 32d465c5cce..e266296a775 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2007 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +18,7 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -38,20 +38,19 @@ #include "main/imports.h" #include "main/macros.h" -#include "main/mfeatures.h" #include "main/feedback.h" +#include "main/rastpos.h" #include "st_context.h" #include "st_atom.h" #include "st_draw.h" +#include "st_program.h" #include "st_cb_rasterpos.h" #include "draw/draw_context.h" #include "draw/draw_pipe.h" #include "vbo/vbo.h" -#if FEATURE_rastpos - /** * Our special drawing pipeline stage (replaces rasterization). */ @@ -61,13 +60,13 @@ struct rastpos_stage struct gl_context *ctx; /**< Rendering context */ /* vertex attrib info we can setup once and re-use */ - struct gl_client_array array[VERT_ATTRIB_MAX]; - const struct gl_client_array *arrays[VERT_ATTRIB_MAX]; + struct gl_vertex_array array[VERT_ATTRIB_MAX]; + const struct gl_vertex_array *arrays[VERT_ATTRIB_MAX]; struct _mesa_prim prim; }; -static INLINE struct rastpos_stage * +static inline struct rastpos_stage * rastpos_stage( struct draw_stage *stage ) { return (struct rastpos_stage *) stage; @@ -111,7 +110,7 @@ rastpos_destroy(struct draw_stage *stage) * else copy the current attrib. */ static void -update_attrib(struct gl_context *ctx, const GLuint *outputMapping, +update_attrib(struct gl_context *ctx, const ubyte *outputMapping, const struct vertex_header *vert, GLfloat *dest, GLuint result, GLuint defaultAttrib) @@ -136,7 +135,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) struct gl_context *ctx = rs->ctx; struct st_context *st = st_context(ctx); const GLfloat height = (GLfloat) ctx->DrawBuffer->Height; - const GLuint *outputMapping = st->vertex_result_to_slot; + const ubyte *outputMapping = st->vp->result_to_output; const GLfloat *pos; GLuint i; @@ -156,16 +155,16 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) /* update other raster attribs */ update_attrib(ctx, outputMapping, prim->v[0], ctx->Current.RasterColor, - VERT_RESULT_COL0, VERT_ATTRIB_COLOR0); + VARYING_SLOT_COL0, VERT_ATTRIB_COLOR0); update_attrib(ctx, outputMapping, prim->v[0], ctx->Current.RasterSecondaryColor, - VERT_RESULT_COL1, VERT_ATTRIB_COLOR1); + VARYING_SLOT_COL1, VERT_ATTRIB_COLOR1); 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); + VARYING_SLOT_TEX0 + i, VERT_ATTRIB_TEX0 + i); } if (ctx->RenderMode == GL_SELECT) { @@ -194,14 +193,12 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw) rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; - for (i = 0; i < Elements(rs->array); i++) { + for (i = 0; i < ARRAY_SIZE(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]; - rs->array[i].Enabled = GL_TRUE; rs->array[i].Normalized = GL_TRUE; rs->array[i].BufferObj = NULL; rs->arrays[i] = &rs->array[i]; @@ -223,8 +220,21 @@ static void st_RasterPos(struct gl_context *ctx, const GLfloat v[4]) { struct st_context *st = st_context(ctx); - struct draw_context *draw = st->draw; + struct draw_context *draw = st_get_draw_context(st); struct rastpos_stage *rs; + const struct gl_vertex_array **saved_arrays = ctx->Array._DrawArrays; + + if (!st->draw) + return; + + if (ctx->VertexProgram._Current == NULL || + ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) { + /* No vertex shader/program is enabled, used the simple/fast fixed- + * function implementation of RasterPos. + */ + _mesa_RasterPos(ctx, v); + return; + } if (st->rastpos_stage) { /* get rastpos stage info */ @@ -240,7 +250,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4]) draw_set_rasterize_stage(st->draw, st->rastpos_stage); /* make sure everything's up to date */ - st_validate_state(st); + st_validate_state(st, ST_PIPELINE_RENDER); /* This will get set only if rastpos_point(), above, gets called */ ctx->Current.RasterPosValid = GL_FALSE; @@ -250,8 +260,14 @@ st_RasterPos(struct gl_context *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, GL_TRUE, 0, 1); + /* Draw the point. + * + * Don't set DriverFlags.NewArray. + * st_feedback_draw_vbo doesn't check for that flag. */ + ctx->Array._DrawArrays = rs->arrays; + st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1, + NULL, 0, NULL); + ctx->Array._DrawArrays = saved_arrays; /* restore draw's rasterization stage depending on rendermode */ if (ctx->RenderMode == GL_FEEDBACK) { @@ -268,5 +284,3 @@ void st_init_rasterpos_functions(struct dd_function_table *functions) { functions->RasterPos = st_RasterPos; } - -#endif /* FEATURE_rastpos */