17117f1b4Smrg/*
2af69d88dSmrg * Copyright 2003 VMware, Inc.
37117f1b4Smrg * All Rights Reserved.
47117f1b4Smrg *
57117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
67117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
77117f1b4Smrg * to deal in the Software without restriction, including without limitation
87117f1b4Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub
97117f1b4Smrg * license, and/or sell copies of the Software, and to permit persons to whom
107117f1b4Smrg * the Software is furnished to do so, subject to the following conditions:
117117f1b4Smrg *
127117f1b4Smrg * The above copyright notice and this permission notice (including the next
137117f1b4Smrg * paragraph) shall be included in all copies or substantial portions of the
147117f1b4Smrg * Software.
157117f1b4Smrg *
167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177117f1b4Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
207117f1b4Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
217117f1b4Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
227117f1b4Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
237117f1b4Smrg *
247117f1b4Smrg * Authors:
25af69d88dSmrg *    Keith Whitwell <keithw@vmware.com>
267117f1b4Smrg */
277117f1b4Smrg
287117f1b4Smrg#ifndef _TNL_VERTEX_H
297117f1b4Smrg#define _TNL_VERTEX_H
307117f1b4Smrg
313464ebd5Sriastradh#include "main/glheader.h"
327117f1b4Smrg#include "t_context.h"
337117f1b4Smrg
343464ebd5Sriastradhstruct gl_context;
353464ebd5Sriastradhstruct tnl_clipspace;
363464ebd5Sriastradh
377117f1b4Smrg/* New mechanism to specify hardware vertices so that tnl can build
387117f1b4Smrg * and manipulate them directly.
397117f1b4Smrg */
407117f1b4Smrg
417117f1b4Smrg
427117f1b4Smrg/* It will probably be necessary to allow drivers to specify new
4301e04c3fSmrg * emit-styles to cover all the weird and wacky things out there.
447117f1b4Smrg */
457117f1b4Smrgenum tnl_attr_format {
467117f1b4Smrg   EMIT_1F,
477117f1b4Smrg   EMIT_2F,
487117f1b4Smrg   EMIT_3F,
497117f1b4Smrg   EMIT_4F,
507117f1b4Smrg   EMIT_2F_VIEWPORT,		/* do viewport transform and emit */
517117f1b4Smrg   EMIT_3F_VIEWPORT,		/* do viewport transform and emit */
527117f1b4Smrg   EMIT_4F_VIEWPORT,		/* do viewport transform and emit */
537117f1b4Smrg   EMIT_3F_XYW,			/* for projective texture */
547117f1b4Smrg   EMIT_1UB_1F,			/* for fog coordinate */
557117f1b4Smrg   EMIT_3UB_3F_RGB,		/* for specular color */
567117f1b4Smrg   EMIT_3UB_3F_BGR,		/* for specular color */
577117f1b4Smrg   EMIT_4UB_4F_RGBA,		/* for color */
587117f1b4Smrg   EMIT_4UB_4F_BGRA,		/* for color */
597117f1b4Smrg   EMIT_4UB_4F_ARGB,		/* for color */
607117f1b4Smrg   EMIT_4UB_4F_ABGR,		/* for color */
617117f1b4Smrg   EMIT_4CHAN_4F_RGBA,		/* for swrast color */
627117f1b4Smrg   EMIT_PAD,			/* leave a hole of 'offset' bytes */
637117f1b4Smrg   EMIT_MAX
647117f1b4Smrg};
657117f1b4Smrg
667117f1b4Smrgstruct tnl_attr_map {
677117f1b4Smrg   GLuint attrib;			/* _TNL_ATTRIB_ enum */
687117f1b4Smrg   enum tnl_attr_format format;
697117f1b4Smrg   GLuint offset;
707117f1b4Smrg};
717117f1b4Smrg
727117f1b4Smrgstruct tnl_format_info {
737117f1b4Smrg   const char *name;
747117f1b4Smrg   tnl_extract_func extract;
757117f1b4Smrg   tnl_insert_func insert[4];
767117f1b4Smrg   const GLuint attrsize;
777117f1b4Smrg};
787117f1b4Smrg
797117f1b4Smrgextern const struct tnl_format_info _tnl_format_info[EMIT_MAX];
807117f1b4Smrg
817117f1b4Smrg
827117f1b4Smrg/* Interpolate between two vertices to produce a third:
837117f1b4Smrg */
843464ebd5Sriastradhextern void _tnl_interp( struct gl_context *ctx,
857117f1b4Smrg			 GLfloat t,
867117f1b4Smrg			 GLuint edst, GLuint eout, GLuint ein,
877117f1b4Smrg			 GLboolean force_boundary );
887117f1b4Smrg
897117f1b4Smrg/* Copy colors from one vertex to another:
907117f1b4Smrg */
913464ebd5Sriastradhextern void _tnl_copy_pv(  struct gl_context *ctx, GLuint edst, GLuint esrc );
927117f1b4Smrg
937117f1b4Smrg
947117f1b4Smrg/* Extract a named attribute from a hardware vertex.  Will have to
957117f1b4Smrg * reverse any viewport transformation, swizzling or other conversions
967117f1b4Smrg * which may have been applied:
977117f1b4Smrg */
983464ebd5Sriastradhextern void _tnl_get_attr( struct gl_context *ctx, const void *vertex, GLenum attrib,
997117f1b4Smrg			   GLfloat *dest );
1007117f1b4Smrg
1017117f1b4Smrg/* Complementary to the above.
1027117f1b4Smrg */
1033464ebd5Sriastradhextern void _tnl_set_attr( struct gl_context *ctx, void *vout, GLenum attrib,
1047117f1b4Smrg			   const GLfloat *src );
1057117f1b4Smrg
1067117f1b4Smrg
1073464ebd5Sriastradhextern void *_tnl_get_vertex( struct gl_context *ctx, GLuint nr );
1087117f1b4Smrg
1093464ebd5Sriastradhextern GLuint _tnl_install_attrs( struct gl_context *ctx,
1107117f1b4Smrg				  const struct tnl_attr_map *map,
1117117f1b4Smrg				  GLuint nr, const GLfloat *vp,
1127117f1b4Smrg				  GLuint unpacked_size );
1137117f1b4Smrg
1143464ebd5Sriastradhextern void _tnl_free_vertices( struct gl_context *ctx );
1157117f1b4Smrg
1163464ebd5Sriastradhextern void _tnl_init_vertices( struct gl_context *ctx,
1177117f1b4Smrg				GLuint vb_size,
1187117f1b4Smrg				GLuint max_vertex_size );
1197117f1b4Smrg
1203464ebd5Sriastradhextern void *_tnl_emit_vertices_to_buffer( struct gl_context *ctx,
1217117f1b4Smrg					   GLuint start,
1227117f1b4Smrg					   GLuint end,
1237117f1b4Smrg					   void *dest );
1247117f1b4Smrg
125c1f859d4Smrg/* This function isn't optimal. Check out
126c1f859d4Smrg * gallium/auxilary/translate for a more comprehensive implementation of
127c1f859d4Smrg * the same functionality.
128c1f859d4Smrg */
129c1f859d4Smrg
1303464ebd5Sriastradhextern void *_tnl_emit_indexed_vertices_to_buffer( struct gl_context *ctx,
131c1f859d4Smrg						   const GLuint *elts,
132c1f859d4Smrg						   GLuint start,
133c1f859d4Smrg						   GLuint end,
134c1f859d4Smrg						   void *dest );
135c1f859d4Smrg
136c1f859d4Smrg
1373464ebd5Sriastradhextern void _tnl_build_vertices( struct gl_context *ctx,
1387117f1b4Smrg				 GLuint start,
1397117f1b4Smrg				 GLuint end,
1407117f1b4Smrg				 GLuint newinputs );
1417117f1b4Smrg
1423464ebd5Sriastradhextern void _tnl_invalidate_vertices( struct gl_context *ctx, GLuint newinputs );
1437117f1b4Smrg
1443464ebd5Sriastradhextern void _tnl_invalidate_vertex_state( struct gl_context *ctx, GLuint new_state );
1457117f1b4Smrg
1463464ebd5Sriastradhextern void _tnl_notify_pipeline_output_change( struct gl_context *ctx );
1477117f1b4Smrg
1487117f1b4Smrg
1497117f1b4Smrg#define GET_VERTEX_STATE(ctx)  &(TNL_CONTEXT(ctx)->clipspace)
1507117f1b4Smrg
1517117f1b4Smrg/* Internal function:
1527117f1b4Smrg */
1537117f1b4Smrgvoid _tnl_register_fastpath( struct tnl_clipspace *vtx,
1547117f1b4Smrg			     GLboolean match_strides );
1557117f1b4Smrg
1567117f1b4Smrg
1577117f1b4Smrg/* t_vertex_generic.c -- Internal functions for t_vertex.c
1587117f1b4Smrg */
1593464ebd5Sriastradhvoid _tnl_generic_copy_pv_extras( struct gl_context *ctx,
1607117f1b4Smrg				  GLuint dst, GLuint src );
1617117f1b4Smrg
1623464ebd5Sriastradhvoid _tnl_generic_interp_extras( struct gl_context *ctx,
1637117f1b4Smrg				 GLfloat t,
1647117f1b4Smrg				 GLuint dst, GLuint out, GLuint in,
1657117f1b4Smrg				 GLboolean force_boundary );
1667117f1b4Smrg
1673464ebd5Sriastradhvoid _tnl_generic_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc );
1687117f1b4Smrg
1693464ebd5Sriastradhvoid _tnl_generic_interp( struct gl_context *ctx,
1707117f1b4Smrg			  GLfloat t,
1717117f1b4Smrg			  GLuint edst, GLuint eout, GLuint ein,
1727117f1b4Smrg			  GLboolean force_boundary );
1737117f1b4Smrg
1743464ebd5Sriastradhvoid _tnl_generic_emit( struct gl_context *ctx,
1757117f1b4Smrg			GLuint count,
1767117f1b4Smrg			GLubyte *v );
1777117f1b4Smrg
1783464ebd5Sriastradhvoid _tnl_generate_hardwired_emit( struct gl_context *ctx );
1797117f1b4Smrg
1807117f1b4Smrg/* t_vertex_sse.c -- Internal functions for t_vertex.c
1817117f1b4Smrg */
1823464ebd5Sriastradhvoid _tnl_generate_sse_emit( struct gl_context *ctx );
1837117f1b4Smrg
1847117f1b4Smrg#endif
185