2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file t_arb_program.c
27 * Compile vertex programs to an intermediate representation.
28 * Execute vertex programs over a buffer of vertices.
29 * \author Keith Whitwell, Brian Paul
33 #ifndef _T_VB_ARBPROGRAM_H_
34 #define _T_VB_ARBPROGRAM_H_
37 /* New, internal instructions:
39 #define RSW (VP_MAX_OPCODE)
40 #define MSK (VP_MAX_OPCODE+1)
41 #define REL (VP_MAX_OPCODE+2)
44 /* Layout of register file:
49 4 -- Program Temporary 0
50 16 -- Program Temporary 12 (max for NV_VERTEX_PROGRAM)
52 31 -- Output 15 (max for NV_VERTEX_PROGRAM) (Last writeable register)
55 127 -- Parameter 63 (max for NV_VERTEX_PROGRAM)
60 #define FILE_LOCAL_PARAM 1
61 #define FILE_ENV_PARAM 2
62 #define FILE_STATE_PARAM 3
76 #define REG_ID 48 /* 0,0,0,1 */
78 #define REG_INVALID ~0
80 /* ARB_vp instructions are broken down into one or more of the
81 * following micro-instructions, each representable in a 32 bit packed
108 GLuint swz
:8; /* xyzw only */
123 #define RSW_NOOP ((0<<0) | (1<<2) | (2<<4) | (3<<6))
124 #define GET_RSW(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
130 union instruction
*csr
;
131 struct vertex_buffer
*VB
; /* for input sizes! */
146 /*--------------------------------------------------------------------------- */
149 * Private storage for the vertex program pipeline stage.
151 struct arb_vp_machine
{
152 GLfloat reg
[REG_MAX
][4]; /* Program temporaries, inputs and outputs */
153 GLfloat (*File
[4])[4]; /* All values reference-able from the program. */
156 struct input input
[16];
159 struct output output
[15];
162 union instruction store
[1024];
163 union instruction
*instructions
;
164 GLint nr_instructions
;
166 GLvector4f attribs
[VERT_RESULT_MAX
]; /**< result vectors. */
167 GLvector4f ndcCoords
; /**< normalized device coords */
168 GLubyte
*clipmask
; /**< clip flags */
169 GLubyte ormask
, andmask
; /**< for clipping */
171 GLuint vtx_nr
; /**< loop counter */
173 struct vertex_buffer
*VB
;