~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/tnl/t_vb_arbprogram.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Mesa 3-D graphics library
3
 
 * Version:  6.5
 
3
 * Version:  6.5.1
4
4
 *
5
5
 * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
6
6
 *
108
108
   return (GLfloat) _mesa_pow(x, y);
109
109
}
110
110
 
111
 
static GLfloat rough_approx_log2_0_1(GLfloat x)
112
 
{
113
 
   return LOG2(x);
114
 
}
115
 
 
116
111
 
117
112
/**
118
113
 * Perform a reduced swizzle:
121
116
{
122
117
   GLfloat *result = m->File[0][op.rsw.dst];
123
118
   const GLfloat *arg0 = m->File[op.rsw.file0][op.rsw.idx0];
124
 
   GLuint swz = op.rsw.swz;
125
 
   GLuint neg = op.rsw.neg;
 
119
   const GLuint swz = op.rsw.swz;
 
120
   const GLuint neg = op.rsw.neg;
126
121
   GLfloat tmp[4];
127
122
 
128
123
   /* Need a temporary to be correct in the case where result == arg0.
149
144
{
150
145
   GLfloat *result = m->File[0][op.rsw.dst];
151
146
   const GLfloat *arg0 = m->File[op.rsw.file0][op.rsw.idx0];
152
 
   GLuint swz = op.rsw.swz;
153
 
   GLuint neg = op.rsw.neg;
 
147
   const GLuint swz = op.rsw.swz;
 
148
   const GLuint neg = op.rsw.neg;
154
149
   GLfloat tmp[6];
155
150
   tmp[4] = 0.0;
156
151
   tmp[5] = 1.0;
308
303
{
309
304
   GLfloat *result = m->File[0][op.alu.dst];
310
305
   const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
311
 
   GLfloat tmp = arg0[0];
312
 
   GLfloat flr_tmp = FLOORF(tmp);
313
 
   GLfloat frac_tmp = tmp - flr_tmp;
 
306
   const GLfloat tmp = arg0[0];
 
307
   const GLfloat flr_tmp = FLOORF(tmp);
 
308
   const GLfloat frac_tmp = tmp - flr_tmp;
314
309
 
315
310
   result[0] = LDEXPF(1.0, (int)flr_tmp);
316
311
   result[1] = frac_tmp;
317
 
   result[2] = LDEXPF(rough_approx_log2_0_1(frac_tmp), (int)flr_tmp);
 
312
   result[2] = RoughApproxExp2(tmp);
318
313
   result[3] = 1.0F;
319
314
}
320
315
 
357
352
{
358
353
   GLfloat *result = m->File[0][op.alu.dst];
359
354
   const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
360
 
   GLfloat tmp[4];
 
355
   GLfloat tmp[4]; /* use temp in case arg0 == result register */
361
356
 
362
357
   tmp[0] = 1.0;
363
358
   tmp[1] = arg0[0];
369
364
   }
370
365
   tmp[3] = 1.0;
371
366
 
372
 
 
373
367
   COPY_4V(result, tmp);
374
368
}
375
369
 
380
374
{
381
375
   GLfloat *result = m->File[0][op.alu.dst];
382
376
   const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
383
 
   GLfloat tmp = FABSF(arg0[0]);
 
377
   const GLfloat tmp = FABSF(arg0[0]);
384
378
   int exponent;
385
 
   GLfloat mantissa = FREXPF(tmp, &exponent);
 
379
   const GLfloat mantissa = FREXPF(tmp, &exponent);
386
380
 
387
381
   result[0] = (GLfloat) (exponent - 1);
388
382
   result[1] = 2.0 * mantissa; /* map [.5, 1) -> [1, 2) */
454
448
static void do_REL( struct arb_vp_machine *m, union instruction op )
455
449
{
456
450
   GLfloat *result = m->File[0][op.alu.dst];
457
 
   GLuint idx = (op.alu.idx0 + (GLint)m->File[0][REG_ADDR][0]) & (MAX_NV_VERTEX_PROGRAM_PARAMS-1);
 
451
   const GLuint idx = (op.alu.idx0 + (GLint)m->File[0][REG_ADDR][0]) & (MAX_NV_VERTEX_PROGRAM_PARAMS-1);
458
452
   const GLfloat *arg0 = m->File[op.alu.file0][idx];
459
453
 
460
454
   result[0] = arg0[0];
1188
1182
 
1189
1183
   /* Test userclip planes.  This contributes to VB->ClipMask.
1190
1184
    */
1191
 
   if (ctx->Transform.ClipPlanesEnabled && !ctx->VertexProgram._Enabled) {
 
1185
   if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled ||
 
1186
      ctx->VertexProgram.Current->IsPositionInvariant)) {
1192
1187
      userclip( ctx,
1193
1188
                VB->ClipPtr,
1194
1189
                m->clipmask,
1253
1248
 
1254
1249
   m->nr_inputs = m->nr_outputs = 0;
1255
1250
 
1256
 
   for (i = 0; i < _TNL_ATTRIB_MAX; i++) {
 
1251
   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
1257
1252
      if (program->Base.InputsRead & (1<<i) ||
1258
1253
          (i == VERT_ATTRIB_POS && program->IsPositionInvariant)) {
1259
1254
         GLuint j = m->nr_inputs++;
1534
1529
void
1535
1530
_tnl_program_string(GLcontext *ctx, GLenum target, struct gl_program *program)
1536
1531
{
1537
 
   if (program->Target == GL_VERTEX_PROGRAM_ARB) {
 
1532
   if (target == GL_VERTEX_PROGRAM_ARB) {
1538
1533
      /* free any existing tnl data hanging off the program */
1539
1534
      struct gl_vertex_program *vprog = (struct gl_vertex_program *) program;
1540
1535
      if (vprog->TnlData) {