~ubuntu-branches/ubuntu/raring/mesa/raring-proposed

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/i965/gen6_sf_state.c

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2011-06-19 21:26:00 UTC
  • mfrom: (1.6.1 upstream) (3.3.18 sid)
  • mto: (3.3.20 sid)
  • mto: This revision was merged to the branch mainline in revision 145.
  • Revision ID: james.westby@ubuntu.com-20110619212600-rleaapdmnbtstekb
Tags: 7.11~0-2
Thank you sbuild for giving a green light when that's not actually the
case. Fix missing Pre-Depends for the libegl1-mesa-drivers package
(multiarch-support).

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "main/macros.h"
33
33
#include "intel_batchbuffer.h"
34
34
 
35
 
static uint32_t
 
35
uint32_t
36
36
get_attr_override(struct brw_context *brw, int fs_attr, int two_side_color)
37
37
{
38
38
   int attr_index = 0, i, vs_attr;
100
100
   int i;
101
101
   /* _NEW_BUFFER */
102
102
   GLboolean render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
103
 
   int attr = 0;
 
103
   int attr = 0, input_index = 0;
104
104
   int urb_start;
105
105
   int two_side_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
 
106
   float point_size;
 
107
   uint16_t attr_overrides[FRAG_ATTRIB_MAX];
106
108
 
107
109
   /* _NEW_TRANSFORM */
108
110
   if (ctx->Transform.ClipPlanesEnabled)
209
211
         ctx->Point._Attenuated))
210
212
      dw4 |= GEN6_SF_USE_STATE_POINT_WIDTH;
211
213
 
212
 
   dw4 |= U_FIXED(CLAMP(ctx->Point.Size, 0.125, 255.875), 3) <<
213
 
      GEN6_SF_POINT_WIDTH_SHIFT;
 
214
   /* Clamp to ARB_point_parameters user limits */
 
215
   point_size = CLAMP(ctx->Point.Size, ctx->Point.MinSize, ctx->Point.MaxSize);
 
216
 
 
217
   /* Clamp to the hardware limits and convert to fixed point */
 
218
   dw4 |= U_FIXED(CLAMP(point_size, 0.125, 255.875), 3);
 
219
 
214
220
   if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT)
215
221
      dw1 |= GEN6_SF_POINT_SPRITE_LOWERLEFT;
216
222
 
225
231
         (1 << GEN6_SF_TRIFAN_PROVOKE_SHIFT);
226
232
   }
227
233
 
228
 
   if (ctx->Point.PointSprite) {
229
 
       for (i = 0; i < 8; i++) { 
230
 
           if (ctx->Point.CoordReplace[i])
231
 
               dw16 |= (1 << i);
232
 
       }
233
 
   }
234
 
 
235
234
   /* flat shading */
236
235
   if (ctx->Light.ShadeModel == GL_FLAT) {
237
236
       dw17 |= ((brw->fragment_program->Base.InputsRead & (FRAG_BIT_COL0 | FRAG_BIT_COL1)) >>
238
237
                ((brw->fragment_program->Base.InputsRead & FRAG_BIT_WPOS) ? 0 : 1));
239
238
   }
240
239
 
 
240
   /* Create the mapping from the FS inputs we produce to the VS outputs
 
241
    * they source from.
 
242
    */
 
243
   for (; attr < FRAG_ATTRIB_MAX; attr++) {
 
244
      if (!(brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)))
 
245
         continue;
 
246
 
 
247
      /* _NEW_POINT */
 
248
      if (ctx->Point.PointSprite &&
 
249
          (attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) &&
 
250
          ctx->Point.CoordReplace[attr - FRAG_ATTRIB_TEX0]) {
 
251
         dw16 |= (1 << input_index);
 
252
      }
 
253
 
 
254
      if (attr == FRAG_ATTRIB_PNTC)
 
255
         dw16 |= (1 << input_index);
 
256
 
 
257
      /* The hardware can only do the overrides on 16 overrides at a
 
258
       * time, and the other up to 16 have to be lined up so that the
 
259
       * input index = the output index.  We'll need to do some
 
260
       * tweaking to make sure that's the case.
 
261
       */
 
262
      assert(input_index < 16 || attr == input_index);
 
263
 
 
264
      attr_overrides[input_index++] = get_attr_override(brw, attr,
 
265
                                                        two_side_color);
 
266
   }
 
267
 
 
268
   for (; input_index < FRAG_ATTRIB_MAX; input_index++)
 
269
      attr_overrides[input_index] = 0;
 
270
 
241
271
   BEGIN_BATCH(20);
242
 
   OUT_BATCH(CMD_3D_SF_STATE << 16 | (20 - 2));
 
272
   OUT_BATCH(_3DSTATE_SF << 16 | (20 - 2));
243
273
   OUT_BATCH(dw1);
244
274
   OUT_BATCH(dw2);
245
275
   OUT_BATCH(dw3);
248
278
   OUT_BATCH_F(ctx->Polygon.OffsetFactor); /* scale */
249
279
   OUT_BATCH_F(0.0); /* XXX: global depth offset clamp */
250
280
   for (i = 0; i < 8; i++) {
251
 
      uint32_t attr_overrides = 0;
252
 
 
253
 
      for (; attr < 64; attr++) {
254
 
         if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)) {
255
 
            attr_overrides |= get_attr_override(brw, attr, two_side_color);
256
 
            attr++;
257
 
            break;
258
 
         }
259
 
      }
260
 
 
261
 
      for (; attr < 64; attr++) {
262
 
         if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)) {
263
 
            attr_overrides |= get_attr_override(brw, attr, two_side_color) << 16;
264
 
            attr++;
265
 
            break;
266
 
         }
267
 
      }
268
 
      OUT_BATCH(attr_overrides);
 
281
      OUT_BATCH(attr_overrides[i * 2] | attr_overrides[i * 2 + 1] << 16);
269
282
   }
270
283
   OUT_BATCH(dw16); /* point sprite texcoord bitmask */
271
284
   OUT_BATCH(dw17); /* constant interp bitmask */