1 /* $Id: nvvertexec.c,v 1.4 2003/03/25 00:00:29 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * \brief Code to execute vertex programs.
38 #include "nvvertexec.h"
39 #include "nvvertprog.h"
40 #include "math/m_matrix.h"
44 * Load/initialize the vertex program registers.
45 * This needs to be done per vertex.
48 _mesa_init_vp_registers(GLcontext
*ctx
)
50 struct vp_machine
*machine
= &(ctx
->VertexProgram
.Machine
);
53 /* Input registers get initialized from the current vertex attribs */
54 MEMCPY(machine
->Registers
[VP_INPUT_REG_START
],
56 16 * 4 * sizeof(GLfloat
));
58 /* Output and temp regs are initialized to [0,0,0,1] */
59 for (i
= VP_OUTPUT_REG_START
; i
<= VP_OUTPUT_REG_END
; i
++) {
60 machine
->Registers
[i
][0] = 0.0F
;
61 machine
->Registers
[i
][1] = 0.0F
;
62 machine
->Registers
[i
][2] = 0.0F
;
63 machine
->Registers
[i
][3] = 1.0F
;
65 for (i
= VP_TEMP_REG_START
; i
<= VP_TEMP_REG_END
; i
++) {
66 machine
->Registers
[i
][0] = 0.0F
;
67 machine
->Registers
[i
][1] = 0.0F
;
68 machine
->Registers
[i
][2] = 0.0F
;
69 machine
->Registers
[i
][3] = 1.0F
;
72 /* The program regs aren't touched */
78 * Copy the 16 elements of a matrix into four consecutive program
79 * registers starting at 'pos'.
82 load_matrix(GLfloat registers
[][4], GLuint pos
, const GLfloat mat
[16])
85 pos
+= VP_PROG_REG_START
;
86 for (i
= 0; i
< 4; i
++) {
87 registers
[pos
+ i
][0] = mat
[0 + i
];
88 registers
[pos
+ i
][1] = mat
[4 + i
];
89 registers
[pos
+ i
][2] = mat
[8 + i
];
90 registers
[pos
+ i
][3] = mat
[12 + i
];
96 * As above, but transpose the matrix.
99 load_transpose_matrix(GLfloat registers
[][4], GLuint pos
,
100 const GLfloat mat
[16])
102 pos
+= VP_PROG_REG_START
;
103 MEMCPY(registers
[pos
], mat
, 16 * sizeof(GLfloat
));
108 * Load all currently tracked matrices into the program registers.
109 * This needs to be done per glBegin/glEnd.
112 _mesa_init_tracked_matrices(GLcontext
*ctx
)
116 for (i
= 0; i
< VP_NUM_PROG_REGS
/ 4; i
++) {
117 /* point 'mat' at source matrix */
119 if (ctx
->VertexProgram
.TrackMatrix
[i
] == GL_MODELVIEW
) {
120 mat
= ctx
->ModelviewMatrixStack
.Top
;
122 else if (ctx
->VertexProgram
.TrackMatrix
[i
] == GL_PROJECTION
) {
123 mat
= ctx
->ProjectionMatrixStack
.Top
;
125 else if (ctx
->VertexProgram
.TrackMatrix
[i
] == GL_TEXTURE
) {
126 mat
= ctx
->TextureMatrixStack
[ctx
->Texture
.CurrentUnit
].Top
;
128 else if (ctx
->VertexProgram
.TrackMatrix
[i
] == GL_COLOR
) {
129 mat
= ctx
->ColorMatrixStack
.Top
;
131 else if (ctx
->VertexProgram
.TrackMatrix
[i
]==GL_MODELVIEW_PROJECTION_NV
) {
132 /* XXX verify the combined matrix is up to date */
133 mat
= &ctx
->_ModelProjectMatrix
;
135 else if (ctx
->VertexProgram
.TrackMatrix
[i
] >= GL_MATRIX0_NV
&&
136 ctx
->VertexProgram
.TrackMatrix
[i
] <= GL_MATRIX7_NV
) {
137 GLuint n
= ctx
->VertexProgram
.TrackMatrix
[i
] - GL_MATRIX0_NV
;
138 ASSERT(n
< MAX_PROGRAM_MATRICES
);
139 mat
= ctx
->ProgramMatrixStack
[n
].Top
;
142 /* no matrix is tracked, but we leave the register values as-is */
143 assert(ctx
->VertexProgram
.TrackMatrix
[i
] == GL_NONE
);
147 /* load the matrix */
148 if (ctx
->VertexProgram
.TrackMatrixTransform
[i
] == GL_IDENTITY_NV
) {
149 load_matrix(ctx
->VertexProgram
.Machine
.Registers
, i
*4, mat
->m
);
151 else if (ctx
->VertexProgram
.TrackMatrixTransform
[i
] == GL_INVERSE_NV
) {
152 _math_matrix_analyse(mat
); /* update the inverse */
153 assert((mat
->flags
& MAT_DIRTY_INVERSE
) == 0);
154 load_matrix(ctx
->VertexProgram
.Machine
.Registers
, i
*4, mat
->inv
);
156 else if (ctx
->VertexProgram
.TrackMatrixTransform
[i
] == GL_TRANSPOSE_NV
) {
157 load_transpose_matrix(ctx
->VertexProgram
.Machine
.Registers
, i
*4, mat
->m
);
160 assert(ctx
->VertexProgram
.TrackMatrixTransform
[i
]
161 == GL_INVERSE_TRANSPOSE_NV
);
162 _math_matrix_analyse(mat
); /* update the inverse */
163 assert((mat
->flags
& MAT_DIRTY_INVERSE
) == 0);
164 load_transpose_matrix(ctx
->VertexProgram
.Machine
.Registers
,
173 * For debugging. Dump the current vertex program machine registers.
176 _mesa_dump_vp_machine( const struct vp_machine
*machine
)
179 _mesa_printf("VertexIn:\n");
180 for (i
= 0; i
< VP_NUM_INPUT_REGS
; i
++) {
181 _mesa_printf("%d: %f %f %f %f ", i
,
182 machine
->Registers
[i
+ VP_INPUT_REG_START
][0],
183 machine
->Registers
[i
+ VP_INPUT_REG_START
][1],
184 machine
->Registers
[i
+ VP_INPUT_REG_START
][2],
185 machine
->Registers
[i
+ VP_INPUT_REG_START
][3]);
189 _mesa_printf("VertexOut:\n");
190 for (i
= 0; i
< VP_NUM_OUTPUT_REGS
; i
++) {
191 _mesa_printf("%d: %f %f %f %f ", i
,
192 machine
->Registers
[i
+ VP_OUTPUT_REG_START
][0],
193 machine
->Registers
[i
+ VP_OUTPUT_REG_START
][1],
194 machine
->Registers
[i
+ VP_OUTPUT_REG_START
][2],
195 machine
->Registers
[i
+ VP_OUTPUT_REG_START
][3]);
199 _mesa_printf("Registers:\n");
200 for (i
= 0; i
< VP_NUM_TEMP_REGS
; i
++) {
201 _mesa_printf("%d: %f %f %f %f ", i
,
202 machine
->Registers
[i
+ VP_TEMP_REG_START
][0],
203 machine
->Registers
[i
+ VP_TEMP_REG_START
][1],
204 machine
->Registers
[i
+ VP_TEMP_REG_START
][2],
205 machine
->Registers
[i
+ VP_TEMP_REG_START
][3]);
209 _mesa_printf("Parameters:\n");
210 for (i
= 0; i
< VP_NUM_PROG_REGS
; i
++) {
211 _mesa_printf("%d: %f %f %f %f ", i
,
212 machine
->Registers
[i
+ VP_PROG_REG_START
][0],
213 machine
->Registers
[i
+ VP_PROG_REG_START
][1],
214 machine
->Registers
[i
+ VP_PROG_REG_START
][2],
215 machine
->Registers
[i
+ VP_PROG_REG_START
][3]);
222 * Fetch a 4-element float vector from the given source register.
223 * Apply swizzling and negating as needed.
226 fetch_vector4( const struct vp_src_register
*source
,
227 const struct vp_machine
*machine
,
230 static const GLfloat zero
[4] = { 0, 0, 0, 0 };
233 if (source
->RelAddr
) {
234 GLint reg
= source
->Register
+ machine
->AddressReg
;
235 if (reg
< VP_PROG_REG_START
|| reg
> VP_PROG_REG_END
)
238 src
= machine
->Registers
[reg
];
241 src
= machine
->Registers
[source
->Register
];
244 if (source
->Negate
) {
245 result
[0] = -src
[source
->Swizzle
[0]];
246 result
[1] = -src
[source
->Swizzle
[1]];
247 result
[2] = -src
[source
->Swizzle
[2]];
248 result
[3] = -src
[source
->Swizzle
[3]];
251 result
[0] = src
[source
->Swizzle
[0]];
252 result
[1] = src
[source
->Swizzle
[1]];
253 result
[2] = src
[source
->Swizzle
[2]];
254 result
[3] = src
[source
->Swizzle
[3]];
260 * As above, but only return result[0] element.
263 fetch_vector1( const struct vp_src_register
*source
,
264 const struct vp_machine
*machine
,
267 static const GLfloat zero
[4] = { 0, 0, 0, 0 };
270 if (source
->RelAddr
) {
271 GLint reg
= source
->Register
+ machine
->AddressReg
;
272 if (reg
< VP_PROG_REG_START
|| reg
> VP_PROG_REG_END
)
275 src
= machine
->Registers
[reg
];
278 src
= machine
->Registers
[source
->Register
];
281 if (source
->Negate
) {
282 result
[0] = -src
[source
->Swizzle
[0]];
285 result
[0] = src
[source
->Swizzle
[0]];
291 * Store 4 floats into a register.
294 store_vector4( const struct vp_dst_register
*dest
, struct vp_machine
*machine
,
295 const GLfloat value
[4] )
297 GLfloat
*dst
= machine
->Registers
[dest
->Register
];
299 if (dest
->WriteMask
[0])
301 if (dest
->WriteMask
[1])
303 if (dest
->WriteMask
[2])
305 if (dest
->WriteMask
[3])
311 * Set x to positive or negative infinity.
314 #define SET_POS_INFINITY(x) ( *((GLuint *) &x) = 0x7F800000 )
315 #define SET_NEG_INFINITY(x) ( *((GLuint *) &x) = 0xFF800000 )
317 #define SET_POS_INFINITY(x) x = __MAXFLOAT
318 #define SET_NEG_INFINITY(x) x = -__MAXFLOAT
320 #define SET_POS_INFINITY(x) x = (GLfloat) HUGE_VAL
321 #define SET_NEG_INFINITY(x) x = (GLfloat) -HUGE_VAL
324 #define SET_FLOAT_BITS(x, bits) ((fi_type *) &(x))->i = bits
328 * Execute the given vertex program
331 _mesa_exec_vertex_program(GLcontext
*ctx
, const struct vertex_program
*program
)
333 struct vp_machine
*machine
= &ctx
->VertexProgram
.Machine
;
334 const struct vp_instruction
*inst
;
336 /* XXX load vertex fields into input registers */
337 /* and do other initialization */
340 for (inst
= program
->Instructions
; inst
->Opcode
!= VP_OPCODE_END
; inst
++) {
341 switch (inst
->Opcode
) {
345 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
346 store_vector4( &inst
->DstReg
, machine
, t
);
351 const GLfloat epsilon
= 1.0e-5F
; /* XXX fix? */
352 GLfloat t
[4], lit
[4];
353 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
354 if (t
[3] < -(128.0F
- epsilon
))
355 t
[3] = - (128.0F
- epsilon
);
356 else if (t
[3] > 128.0F
- epsilon
)
357 t
[3] = 128.0F
- epsilon
;
364 lit
[2] = (t
[0] > 0.0) ? (GLfloat
) exp(t
[3] * log(t
[1])) : 0.0F
;
366 store_vector4( &inst
->DstReg
, machine
, lit
);
372 fetch_vector1( &inst
->SrcReg
[0], machine
, t
);
374 t
[0] = 1.0F
/ t
[0]; /* div by zero is infinity! */
375 t
[1] = t
[2] = t
[3] = t
[0];
376 store_vector4( &inst
->DstReg
, machine
, t
);
382 fetch_vector1( &inst
->SrcReg
[0], machine
, t
);
383 t
[0] = INV_SQRTF(FABSF(t
[0]));
384 t
[1] = t
[2] = t
[3] = t
[0];
385 store_vector4( &inst
->DstReg
, machine
, t
);
390 GLfloat t
[4], q
[4], floor_t0
;
391 fetch_vector1( &inst
->SrcReg
[0], machine
, t
);
392 floor_t0
= (float) floor(t
[0]);
393 if (floor_t0
> FLT_MAX_EXP
) {
394 SET_POS_INFINITY(q
[0]);
396 SET_POS_INFINITY(q
[2]);
399 else if (floor_t0
< FLT_MIN_EXP
) {
407 GLint ii
= (GLint
) floor_t0
;
408 ii
= (ii
< 23) + 0x3f800000;
409 SET_FLOAT_BITS(q
[0], ii
);
410 q
[0] = *((GLfloat
*) &ii
);
412 q
[0] = (GLfloat
) pow(2.0, floor_t0
);
414 q
[1] = t
[0] - floor_t0
;
415 q
[2] = (GLfloat
) (q
[0] * LOG2(q
[1]));
418 store_vector4( &inst
->DstReg
, machine
, q
);
423 GLfloat t
[4], q
[4], abs_t0
;
424 fetch_vector1( &inst
->SrcReg
[0], machine
, t
);
425 abs_t0
= (GLfloat
) fabs(t
[0]);
426 if (abs_t0
!= 0.0F
) {
427 /* Since we really can't handle infinite values on VMS
428 * like other OSes we'll use __MAXFLOAT to represent
429 * infinity. This may need some tweaking.
432 if (abs_t0
== __MAXFLOAT
) {
434 if (IS_INF_OR_NAN(abs_t0
)) {
436 SET_POS_INFINITY(q
[0]);
438 SET_POS_INFINITY(q
[2]);
442 double mantissa
= frexp(t
[0], &exponent
);
443 q
[0] = (GLfloat
) (exponent
- 1);
444 q
[1] = (GLfloat
) (2.0 * mantissa
); /* map [.5, 1) -> [1, 2) */
445 q
[2] = (GLfloat
) (q
[0] + LOG2(q
[1]));
449 SET_NEG_INFINITY(q
[0]);
451 SET_NEG_INFINITY(q
[2]);
454 store_vector4( &inst
->DstReg
, machine
, q
);
459 GLfloat t
[4], u
[4], prod
[4];
460 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
461 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
462 prod
[0] = t
[0] * u
[0];
463 prod
[1] = t
[1] * u
[1];
464 prod
[2] = t
[2] * u
[2];
465 prod
[3] = t
[3] * u
[3];
466 store_vector4( &inst
->DstReg
, machine
, prod
);
471 GLfloat t
[4], u
[4], sum
[4];
472 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
473 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
474 sum
[0] = t
[0] + u
[0];
475 sum
[1] = t
[1] + u
[1];
476 sum
[2] = t
[2] + u
[2];
477 sum
[3] = t
[3] + u
[3];
478 store_vector4( &inst
->DstReg
, machine
, sum
);
483 GLfloat t
[4], u
[4], dot
[4];
484 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
485 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
486 dot
[0] = t
[0] * u
[0] + t
[1] * u
[1] + t
[2] * u
[2];
487 dot
[1] = dot
[2] = dot
[3] = dot
[0];
488 store_vector4( &inst
->DstReg
, machine
, dot
);
493 GLfloat t
[4], u
[4], dot
[4];
494 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
495 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
496 dot
[0] = t
[0] * u
[0] + t
[1] * u
[1] + t
[2] * u
[2] + t
[3] * u
[3];
497 dot
[1] = dot
[2] = dot
[3] = dot
[0];
498 store_vector4( &inst
->DstReg
, machine
, dot
);
503 GLfloat t
[4], u
[4], dst
[4];
504 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
505 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
507 dst
[1] = t
[1] * u
[1];
510 store_vector4( &inst
->DstReg
, machine
, dst
);
515 GLfloat t
[4], u
[4], min
[4];
516 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
517 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
518 min
[0] = (t
[0] < u
[0]) ? t
[0] : u
[0];
519 min
[1] = (t
[1] < u
[1]) ? t
[1] : u
[1];
520 min
[2] = (t
[2] < u
[2]) ? t
[2] : u
[2];
521 min
[3] = (t
[3] < u
[3]) ? t
[3] : u
[3];
522 store_vector4( &inst
->DstReg
, machine
, min
);
527 GLfloat t
[4], u
[4], max
[4];
528 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
529 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
530 max
[0] = (t
[0] > u
[0]) ? t
[0] : u
[0];
531 max
[1] = (t
[1] > u
[1]) ? t
[1] : u
[1];
532 max
[2] = (t
[2] > u
[2]) ? t
[2] : u
[2];
533 max
[3] = (t
[3] > u
[3]) ? t
[3] : u
[3];
534 store_vector4( &inst
->DstReg
, machine
, max
);
539 GLfloat t
[4], u
[4], slt
[4];
540 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
541 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
542 slt
[0] = (t
[0] < u
[0]) ? 1.0F
: 0.0F
;
543 slt
[1] = (t
[1] < u
[1]) ? 1.0F
: 0.0F
;
544 slt
[2] = (t
[2] < u
[2]) ? 1.0F
: 0.0F
;
545 slt
[3] = (t
[3] < u
[3]) ? 1.0F
: 0.0F
;
546 store_vector4( &inst
->DstReg
, machine
, slt
);
551 GLfloat t
[4], u
[4], sge
[4];
552 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
553 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
554 sge
[0] = (t
[0] >= u
[0]) ? 1.0F
: 0.0F
;
555 sge
[1] = (t
[1] >= u
[1]) ? 1.0F
: 0.0F
;
556 sge
[2] = (t
[2] >= u
[2]) ? 1.0F
: 0.0F
;
557 sge
[3] = (t
[3] >= u
[3]) ? 1.0F
: 0.0F
;
558 store_vector4( &inst
->DstReg
, machine
, sge
);
563 GLfloat t
[4], u
[4], v
[4], sum
[4];
564 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
565 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
566 fetch_vector4( &inst
->SrcReg
[2], machine
, v
);
567 sum
[0] = t
[0] * u
[0] + v
[0];
568 sum
[1] = t
[1] * u
[1] + v
[1];
569 sum
[2] = t
[2] * u
[2] + v
[2];
570 sum
[3] = t
[3] * u
[3] + v
[3];
571 store_vector4( &inst
->DstReg
, machine
, sum
);
577 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
578 machine
->AddressReg
= (GLint
) floor(t
[0]);
583 GLfloat t
[4], u
[4], dot
[4];
584 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
585 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
586 dot
[0] = t
[0] * u
[0] + t
[1] * u
[1] + t
[2] * u
[2] + u
[3];
587 dot
[1] = dot
[2] = dot
[3] = dot
[0];
588 store_vector4( &inst
->DstReg
, machine
, dot
);
594 fetch_vector1( &inst
->SrcReg
[0], machine
, t
);
600 if (u
> 1.884467e+019F
) {
601 u
= 1.884467e+019F
; /* IEEE 32-bit binary value 0x5F800000 */
603 else if (u
< 5.42101e-020F
) {
604 u
= 5.42101e-020F
; /* IEEE 32-bit binary value 0x1F800000 */
608 if (u
< -1.884467e+019F
) {
609 u
= -1.884467e+019F
; /* IEEE 32-bit binary value 0xDF800000 */
611 else if (u
> -5.42101e-020F
) {
612 u
= -5.42101e-020F
; /* IEEE 32-bit binary value 0x9F800000 */
615 t
[0] = t
[1] = t
[2] = t
[3] = u
;
616 store_vector4( &inst
->DstReg
, machine
, t
);
621 GLfloat t
[4], u
[4], sum
[4];
622 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
623 fetch_vector4( &inst
->SrcReg
[1], machine
, u
);
624 sum
[0] = t
[0] - u
[0];
625 sum
[1] = t
[1] - u
[1];
626 sum
[2] = t
[2] - u
[2];
627 sum
[3] = t
[3] - u
[3];
628 store_vector4( &inst
->DstReg
, machine
, sum
);
634 fetch_vector4( &inst
->SrcReg
[0], machine
, t
);
635 if (t
[0] < 0.0) t
[0] = -t
[0];
636 if (t
[1] < 0.0) t
[1] = -t
[1];
637 if (t
[2] < 0.0) t
[2] = -t
[2];
638 if (t
[3] < 0.0) t
[3] = -t
[3];
639 store_vector4( &inst
->DstReg
, machine
, t
);
646 /* bad instruction opcode */
647 _mesa_problem(ctx
, "Bad VP Opcode in _mesa_exec_vertex_program");
656 Thoughts on vertex program optimization:
658 The obvious thing to do is to compile the vertex program into X86/SSE/3DNow!
659 assembly code. That will probably be a lot of work.
661 Another approach might be to replace the vp_instruction->Opcode field with
662 a pointer to a specialized C function which executes the instruction.
663 In particular we can write functions which skip swizzling, negating,
664 masking, relative addressing, etc. when they're not needed.
668 void simple_add( struct vp_instruction *inst )
670 GLfloat *sum = machine->Registers[inst->DstReg.Register];
671 GLfloat *a = machine->Registers[inst->SrcReg[0].Register];
672 GLfloat *b = machine->Registers[inst->SrcReg[1].Register];
673 sum[0] = a[0] + b[0];
674 sum[1] = a[1] + b[1];
675 sum[2] = a[2] + b[2];
676 sum[3] = a[3] + b[3];
685 A first step would be to 'vectorize' the programs in the same way as
686 the normal transformation code in the tnl module. Thus each opcode
687 takes zero or more input vectors (registers) and produces one or more
690 These operations would intially be coded in C, with machine-specific
691 assembly following, as is currently the case for matrix
692 transformations in the math/ directory. The preprocessing scheme for
693 selecting simpler operations Brian describes above would also work
696 This should give reasonable performance without excessive effort.