/**************************************************************************
*
- * 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
* 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.
*/
-#include "main/imports.h"
+#include "util/imports.h"
#include "main/macros.h"
+#include "main/arrayobj.h"
#include "main/feedback.h"
+#include "main/rastpos.h"
+#include "main/state.h"
+#include "main/varray.h"
#include "st_context.h"
#include "st_atom.h"
#include "st_draw.h"
+#include "st_program.h"
#include "st_cb_rasterpos.h"
-#include "st_draw.h"
+#include "st_util.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).
*/
struct rastpos_stage
{
struct draw_stage stage; /**< Base class */
- GLcontext *ctx; /**< Rendering context */
+ 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_object *VAO;
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;
static void
rastpos_destroy(struct draw_stage *stage)
{
+ struct rastpos_stage *rstage = (struct rastpos_stage*)stage;
+ _mesa_reference_vao(rstage->ctx, &rstage->VAO, NULL);
free(stage);
}
* else copy the current attrib.
*/
static void
-update_attrib(GLcontext *ctx, const GLuint *outputMapping,
+update_attrib(struct gl_context *ctx, const ubyte *outputMapping,
const struct vertex_header *vert,
GLfloat *dest,
GLuint result, GLuint defaultAttrib)
rastpos_point(struct draw_stage *stage, struct prim_header *prim)
{
struct rastpos_stage *rs = rastpos_stage(stage);
- GLcontext *ctx = rs->ctx;
+ 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;
+ struct st_vertex_program *stvp = (struct st_vertex_program *)st->vp;
+ const ubyte *outputMapping = stvp->result_to_output;
const GLfloat *pos;
GLuint i;
/* 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) {
* Create rasterpos "drawing" stage.
*/
static struct rastpos_stage *
-new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
+new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
{
struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
- GLuint i;
rs->stage.draw = draw;
rs->stage.next = NULL;
rs->stage.destroy = rastpos_destroy;
rs->ctx = ctx;
- 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];
- rs->array[i].Enabled = GL_TRUE;
- rs->array[i].Normalized = GL_TRUE;
- rs->array[i].BufferObj = NULL;
- rs->arrays[i] = &rs->array[i];
- }
+ rs->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
+ _mesa_vertex_attrib_binding(ctx, rs->VAO, VERT_ATTRIB_POS, 0);
+ _mesa_update_array_format(ctx, rs->VAO, VERT_ATTRIB_POS, 4, GL_FLOAT,
+ GL_RGBA, GL_FALSE, GL_FALSE, GL_FALSE, 0);
+ _mesa_enable_vertex_array_attrib(ctx, rs->VAO, 0);
rs->prim.mode = GL_POINTS;
- rs->prim.indexed = 0;
rs->prim.begin = 1;
rs->prim.end = 1;
- rs->prim.weak = 0;
rs->prim.start = 0;
rs->prim.count = 1;
static void
-st_RasterPos(GLcontext *ctx, const GLfloat v[4])
+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;
+ 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 */
rs = rastpos_stage(st->rastpos_stage);
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;
/* All vertex attribs but position were previously initialized above.
* Just plug in position pointer now.
*/
- rs->array[0].Ptr = (GLubyte *) v;
+ rs->VAO->VertexAttrib[VERT_ATTRIB_POS].Ptr = (GLubyte *) v;
+ rs->VAO->NewArrays |= VERT_BIT_POS;
+ _mesa_set_draw_vao(ctx, rs->VAO, VERT_BIT_POS);
- /* draw the point */
- st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, GL_TRUE, 0, 1);
+ /* Draw the point. */
+ st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1, 1, 0,
+ NULL, 0);
/* restore draw's rasterization stage depending on rendermode */
if (ctx->RenderMode == GL_FEEDBACK) {
{
functions->RasterPos = st_RasterPos;
}
-
-#endif /* FEATURE_rastpos */