~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/draw/draw_gs.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**************************************************************************
2
2
 *
3
 
 * Copyright 2009 VMWare Inc.
 
3
 * Copyright 2009 VMware, Inc.
4
4
 * All Rights Reserved.
5
5
 *
6
6
 * Permission is hereby granted, free of charge, to any person obtaining a
37
37
 
38
38
#include "util/u_math.h"
39
39
#include "util/u_memory.h"
 
40
#include "util/u_prim.h"
40
41
 
41
 
#define MAX_PRIM_VERTICES 6
42
42
/* fixme: move it from here */
43
43
#define MAX_PRIMITIVES 64
44
44
 
75
75
                      const void *constants,
76
76
                      unsigned size)
77
77
{
 
78
   /* noop. added here for symmetry with the VS
 
79
    * code and in case we'll ever want to allign
 
80
    * the constants, e.g. when we'll change to a
 
81
    * different interpreter */
78
82
}
79
83
 
80
84
 
90
94
   if (!gs)
91
95
      return NULL;
92
96
 
 
97
   gs->draw = draw;
93
98
   gs->state = *state;
94
99
   gs->state.tokens = tgsi_dup_tokens(state->tokens);
95
100
   if (!gs->state.tokens) {
112
117
               TGSI_PROPERTY_GS_OUTPUT_PRIM)
113
118
         gs->output_primitive = gs->info.properties[i].data[0];
114
119
      else if (gs->info.properties[i].name ==
115
 
               TGSI_PROPERTY_GS_MAX_VERTICES)
 
120
               TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES)
116
121
         gs->max_output_vertices = gs->info.properties[i].data[0];
117
122
   }
118
123
 
154
159
   FREE(dgs);
155
160
}
156
161
 
157
 
static INLINE int num_vertices_for_prim(int prim)
158
 
{
159
 
   switch(prim) {
160
 
   case PIPE_PRIM_POINTS:
161
 
      return 1;
162
 
   case PIPE_PRIM_LINES:
163
 
      return 2;
164
 
   case PIPE_PRIM_LINE_LOOP:
165
 
      return 2;
166
 
   case PIPE_PRIM_LINE_STRIP:
167
 
      return 2;
168
 
   case PIPE_PRIM_TRIANGLES:
169
 
      return 3;
170
 
   case PIPE_PRIM_TRIANGLE_STRIP:
171
 
      return 3;
172
 
   case PIPE_PRIM_TRIANGLE_FAN:
173
 
      return 3;
174
 
   case PIPE_PRIM_LINES_ADJACENCY:
175
 
   case PIPE_PRIM_LINE_STRIP_ADJACENCY:
176
 
      return 4;
177
 
   case PIPE_PRIM_TRIANGLES_ADJACENCY:
178
 
   case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
179
 
      return 6;
180
 
   default:
181
 
      assert(!"Bad geometry shader input");
182
 
      return 0;
183
 
   }
184
 
}
185
 
 
186
 
static void draw_fetch_geometry_input(struct draw_geometry_shader *shader,
187
 
                                      int start_primitive,
188
 
                                      int num_primitives,
189
 
                                      const float (*input_ptr)[4],
190
 
                                      unsigned input_vertex_stride,
191
 
                                      unsigned inputs_from_vs)
192
 
{
193
 
   struct tgsi_exec_machine *machine = shader->machine;
194
 
   unsigned slot, vs_slot, k, j;
195
 
   unsigned num_vertices = num_vertices_for_prim(shader->input_primitive);
196
 
   int idx = 0;
197
 
 
198
 
   for (slot = 0, vs_slot = 0; slot < shader->info.num_inputs; slot++) {
199
 
      /*debug_printf("Slot = %d (semantic = %d)\n", slot,
200
 
        shader->info.input_semantic_name[slot]);*/
201
 
      if (shader->info.input_semantic_name[slot] ==
202
 
          TGSI_SEMANTIC_PRIMID) {
203
 
         for (j = 0; j < num_primitives; ++j) {
204
 
            machine->Inputs[idx].xyzw[0].f[j] = (float)start_primitive + j;
205
 
            machine->Inputs[idx].xyzw[1].f[j] = (float)start_primitive + j;
206
 
            machine->Inputs[idx].xyzw[2].f[j] = (float)start_primitive + j;
207
 
            machine->Inputs[idx].xyzw[3].f[j] = (float)start_primitive + j;
208
 
         }
209
 
         ++idx;
210
 
      } else {
211
 
         for (j = 0; j < num_primitives; ++j) {
212
 
            int vidx = idx;
213
 
            const float (*prim_ptr)[4];
214
 
            /*debug_printf("    %d) Prim (num_verts = %d)\n", start_primitive + j,
215
 
              num_vertices);*/
216
 
            prim_ptr = (const float (*)[4])(
217
 
               (const char *)input_ptr +
218
 
               (j * num_vertices * input_vertex_stride));
219
 
 
220
 
            for (k = 0; k < num_vertices; ++k, ++vidx) {
221
 
               const float (*input)[4];
222
 
               input = (const float (*)[4])(
223
 
                  (const char *)prim_ptr + (k * input_vertex_stride));
224
 
               vidx = k * TGSI_EXEC_MAX_INPUT_ATTRIBS + slot;
225
 
               /*debug_printf("\t%d)(%d) Input vert:\n", vidx, k);*/
226
 
#if 1
227
 
               assert(!util_is_inf_or_nan(input[vs_slot][0]));
228
 
               assert(!util_is_inf_or_nan(input[vs_slot][1]));
229
 
               assert(!util_is_inf_or_nan(input[vs_slot][2]));
230
 
               assert(!util_is_inf_or_nan(input[vs_slot][3]));
231
 
#endif
232
 
               machine->Inputs[vidx].xyzw[0].f[j] = input[vs_slot][0];
233
 
               machine->Inputs[vidx].xyzw[1].f[j] = input[vs_slot][1];
234
 
               machine->Inputs[vidx].xyzw[2].f[j] = input[vs_slot][2];
235
 
               machine->Inputs[vidx].xyzw[3].f[j] = input[vs_slot][3];
236
 
#if 0
237
 
               debug_printf("\t\t%d %f %f %f %f\n", slot,
238
 
                            machine->Inputs[vidx].xyzw[0].f[j],
239
 
                            machine->Inputs[vidx].xyzw[1].f[j],
240
 
                            machine->Inputs[vidx].xyzw[2].f[j],
241
 
                            machine->Inputs[vidx].xyzw[3].f[j]);
242
 
#endif
243
 
            }
244
 
         }
245
 
         ++vs_slot;
246
 
         idx += num_vertices;
247
 
      }
248
 
   }
249
 
}
250
 
 
 
162
/*#define DEBUG_OUTPUTS 1*/
251
163
static INLINE void
252
164
draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
253
165
                            int num_primitives,
254
 
                            float (*output)[4],
255
 
                            unsigned vertex_size)
 
166
                            float (**p_output)[4])
256
167
{
257
168
   struct tgsi_exec_machine *machine = shader->machine;
258
169
   unsigned prim_idx, j, slot;
 
170
   float (*output)[4];
 
171
 
 
172
   output = *p_output;
259
173
 
260
174
   /* Unswizzle all output results.
261
175
    */
262
 
   /* FIXME: handle all the primitives produced by the gs, not just
263
 
    * the first one
264
 
    unsigned prim_count =
265
 
    mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0];*/
 
176
 
266
177
   for (prim_idx = 0; prim_idx < num_primitives; ++prim_idx) {
267
 
      unsigned num_verts_per_prim = machine->Primitives[0];
 
178
      unsigned num_verts_per_prim = machine->Primitives[prim_idx];
 
179
      shader->primitive_lengths[prim_idx +   shader->emitted_primitives] =
 
180
         machine->Primitives[prim_idx];
 
181
      shader->emitted_vertices += num_verts_per_prim;
268
182
      for (j = 0; j < num_verts_per_prim; j++) {
269
183
         int idx = (prim_idx * num_verts_per_prim + j) *
270
184
                   shader->info.num_outputs;
271
185
#ifdef DEBUG_OUTPUTS
272
 
         debug_printf("%d) Output vert:\n", idx);
 
186
         debug_printf("%d) Output vert:\n", idx / shader->info.num_outputs);
273
187
#endif
274
188
         for (slot = 0; slot < shader->info.num_outputs; slot++) {
275
 
            output[slot][0] = machine->Outputs[idx + slot].xyzw[0].f[prim_idx];
276
 
            output[slot][1] = machine->Outputs[idx + slot].xyzw[1].f[prim_idx];
277
 
            output[slot][2] = machine->Outputs[idx + slot].xyzw[2].f[prim_idx];
278
 
            output[slot][3] = machine->Outputs[idx + slot].xyzw[3].f[prim_idx];
 
189
            output[slot][0] = machine->Outputs[idx + slot].xyzw[0].f[0];
 
190
            output[slot][1] = machine->Outputs[idx + slot].xyzw[1].f[0];
 
191
            output[slot][2] = machine->Outputs[idx + slot].xyzw[2].f[0];
 
192
            output[slot][3] = machine->Outputs[idx + slot].xyzw[3].f[0];
279
193
#ifdef DEBUG_OUTPUTS
280
194
            debug_printf("\t%d: %f %f %f %f\n", slot,
281
195
                         output[slot][0],
285
199
#endif
286
200
            debug_assert(!util_is_inf_or_nan(output[slot][0]));
287
201
         }
288
 
         output = (float (*)[4])((char *)output + vertex_size);
289
 
      }
290
 
   }
291
 
}
292
 
 
293
 
void draw_geometry_shader_run(struct draw_geometry_shader *shader,
294
 
                              const float (*input)[4],
295
 
                              float (*output)[4],
296
 
                              const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
297
 
                              unsigned count,
298
 
                              unsigned input_stride,
299
 
                              unsigned vertex_size)
300
 
{
301
 
   struct tgsi_exec_machine *machine = shader->machine;
302
 
   unsigned int i;
303
 
   unsigned num_vertices = num_vertices_for_prim(shader->input_primitive);
304
 
   unsigned num_primitives = count/num_vertices;
305
 
   unsigned inputs_from_vs = 0;
306
 
 
307
 
   for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
308
 
      machine->Consts[i] = constants[i];
309
 
   }
310
 
 
311
 
   for (i = 0; i < shader->info.num_inputs; ++i) {
312
 
      if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID)
313
 
         ++inputs_from_vs;
314
 
   }
315
 
 
316
 
   for (i = 0; i < num_primitives; ++i) {
317
 
      unsigned int max_primitives = 1;
318
 
 
319
 
      draw_fetch_geometry_input(shader, i, max_primitives, input,
320
 
                                input_stride, inputs_from_vs);
321
 
 
322
 
      tgsi_set_exec_mask(machine,
323
 
                         1,
324
 
                         max_primitives > 1,
325
 
                         max_primitives > 2,
326
 
                         max_primitives > 3);
327
 
 
328
 
      /* run interpreter */
329
 
      tgsi_exec_machine_run(machine);
330
 
 
331
 
      draw_geometry_fetch_outputs(shader, max_primitives,
332
 
                                  output, vertex_size);
333
 
   }
 
202
         output = (float (*)[4])((char *)output + shader->vertex_size);
 
203
      }
 
204
   }
 
205
   *p_output = output;
 
206
         shader->emitted_primitives += num_primitives;
 
207
}
 
208
 
 
209
/*#define DEBUG_INPUTS 1*/
 
210
static void draw_fetch_gs_input(struct draw_geometry_shader *shader,
 
211
                                unsigned *indices,
 
212
                                unsigned num_vertices,
 
213
                                unsigned prim_idx)
 
214
{
 
215
   struct tgsi_exec_machine *machine = shader->machine;
 
216
   unsigned slot, vs_slot, i;
 
217
   unsigned input_vertex_stride = shader->input_vertex_stride;
 
218
   const float (*input_ptr)[4];
 
219
 
 
220
   input_ptr = shader->input;
 
221
 
 
222
   for (i = 0; i < num_vertices; ++i) {
 
223
      const float (*input)[4];
 
224
#if DEBUG_INPUTS
 
225
      debug_printf("%d) vertex index = %d (prim idx = %d)\n",
 
226
                   i, indices[i], prim_idx);
 
227
#endif
 
228
      input = (const float (*)[4])(
 
229
         (const char *)input_ptr + (indices[i] * input_vertex_stride));
 
230
      for (slot = 0, vs_slot = 0; slot < shader->info.num_inputs; ++slot) {
 
231
         unsigned idx = i * TGSI_EXEC_MAX_INPUT_ATTRIBS + slot;
 
232
         if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_PRIMID) {
 
233
            machine->Inputs[idx].xyzw[0].f[prim_idx] =
 
234
               (float)shader->in_prim_idx;
 
235
            machine->Inputs[idx].xyzw[1].f[prim_idx] =
 
236
               (float)shader->in_prim_idx;
 
237
            machine->Inputs[idx].xyzw[2].f[prim_idx] =
 
238
               (float)shader->in_prim_idx;
 
239
            machine->Inputs[idx].xyzw[3].f[prim_idx] =
 
240
               (float)shader->in_prim_idx;
 
241
         } else {
 
242
#if DEBUG_INPUTS
 
243
            debug_printf("\tSlot = %d, vs_slot = %d, idx = %d:\n",
 
244
                         slot, vs_slot, idx);
 
245
#endif
 
246
#if 1
 
247
            assert(!util_is_inf_or_nan(input[vs_slot][0]));
 
248
            assert(!util_is_inf_or_nan(input[vs_slot][1]));
 
249
            assert(!util_is_inf_or_nan(input[vs_slot][2]));
 
250
            assert(!util_is_inf_or_nan(input[vs_slot][3]));
 
251
#endif
 
252
            machine->Inputs[idx].xyzw[0].f[prim_idx] = input[vs_slot][0];
 
253
            machine->Inputs[idx].xyzw[1].f[prim_idx] = input[vs_slot][1];
 
254
            machine->Inputs[idx].xyzw[2].f[prim_idx] = input[vs_slot][2];
 
255
            machine->Inputs[idx].xyzw[3].f[prim_idx] = input[vs_slot][3];
 
256
#if DEBUG_INPUTS
 
257
            debug_printf("\t\t%f %f %f %f\n",
 
258
                         machine->Inputs[idx].xyzw[0].f[prim_idx],
 
259
                         machine->Inputs[idx].xyzw[1].f[prim_idx],
 
260
                         machine->Inputs[idx].xyzw[2].f[prim_idx],
 
261
                         machine->Inputs[idx].xyzw[3].f[prim_idx]);
 
262
#endif
 
263
            ++vs_slot;
 
264
         }
 
265
      }
 
266
   }
 
267
}
 
268
 
 
269
static void gs_flush(struct draw_geometry_shader *shader,
 
270
                     unsigned input_primitives)
 
271
{
 
272
   unsigned out_prim_count;
 
273
   struct tgsi_exec_machine *machine = shader->machine;
 
274
 
 
275
   debug_assert(input_primitives > 0 &&
 
276
                input_primitives < 4);
 
277
 
 
278
   tgsi_set_exec_mask(machine,
 
279
                      1,
 
280
                      input_primitives > 1,
 
281
                      input_primitives > 2,
 
282
                      input_primitives > 3);
 
283
 
 
284
   /* run interpreter */
 
285
   tgsi_exec_machine_run(machine);
 
286
 
 
287
   out_prim_count =
 
288
      machine->Temps[TGSI_EXEC_TEMP_PRIMITIVE_I].xyzw[TGSI_EXEC_TEMP_PRIMITIVE_C].u[0];
 
289
 
 
290
#if 0
 
291
   debug_printf("PRIM emitted prims = %d (verts=%d), cur prim count = %d\n",
 
292
                shader->emitted_primitives, shader->emitted_vertices,
 
293
                out_prim_count);
 
294
#endif
 
295
   draw_geometry_fetch_outputs(shader, out_prim_count,
 
296
                               &shader->tmp_output);
 
297
}
 
298
 
 
299
static void gs_point(struct draw_geometry_shader *shader,
 
300
                     int idx)
 
301
{
 
302
   unsigned indices[1];
 
303
 
 
304
   indices[0] = idx;
 
305
 
 
306
   draw_fetch_gs_input(shader, indices, 1, 0);
 
307
   ++shader->in_prim_idx;
 
308
 
 
309
   gs_flush(shader, 1);
 
310
}
 
311
 
 
312
static void gs_line(struct draw_geometry_shader *shader,
 
313
                    int i0, int i1)
 
314
{
 
315
   unsigned indices[2];
 
316
 
 
317
   indices[0] = i0;
 
318
   indices[1] = i1;
 
319
 
 
320
   draw_fetch_gs_input(shader, indices, 2, 0);
 
321
   ++shader->in_prim_idx;
 
322
 
 
323
   gs_flush(shader, 1);
 
324
}
 
325
 
 
326
static void gs_line_adj(struct draw_geometry_shader *shader,
 
327
                        int i0, int i1, int i2, int i3)
 
328
{
 
329
   unsigned indices[4];
 
330
 
 
331
   indices[0] = i0;
 
332
   indices[1] = i1;
 
333
   indices[2] = i2;
 
334
   indices[3] = i3;
 
335
 
 
336
   draw_fetch_gs_input(shader, indices, 4, 0);
 
337
   ++shader->in_prim_idx;
 
338
 
 
339
   gs_flush(shader, 1);
 
340
}
 
341
 
 
342
static void gs_tri(struct draw_geometry_shader *shader,
 
343
                   int i0, int i1, int i2)
 
344
{
 
345
   unsigned indices[3];
 
346
 
 
347
   indices[0] = i0;
 
348
   indices[1] = i1;
 
349
   indices[2] = i2;
 
350
 
 
351
   draw_fetch_gs_input(shader, indices, 3, 0);
 
352
   ++shader->in_prim_idx;
 
353
 
 
354
   gs_flush(shader, 1);
 
355
}
 
356
 
 
357
static void gs_tri_adj(struct draw_geometry_shader *shader,
 
358
                       int i0, int i1, int i2,
 
359
                       int i3, int i4, int i5)
 
360
{
 
361
   unsigned indices[6];
 
362
 
 
363
   indices[0] = i0;
 
364
   indices[1] = i1;
 
365
   indices[2] = i2;
 
366
   indices[3] = i3;
 
367
   indices[4] = i4;
 
368
   indices[5] = i5;
 
369
 
 
370
   draw_fetch_gs_input(shader, indices, 6, 0);
 
371
   ++shader->in_prim_idx;
 
372
 
 
373
   gs_flush(shader, 1);
 
374
}
 
375
 
 
376
#define FUNC         gs_run
 
377
#define GET_ELT(idx) (idx)
 
378
#include "draw_gs_tmp.h"
 
379
 
 
380
 
 
381
#define FUNC         gs_run_elts
 
382
#define LOCAL_VARS   const ushort *elts = input_prims->elts;
 
383
#define GET_ELT(idx) (elts[idx])
 
384
#include "draw_gs_tmp.h"
 
385
 
 
386
 
 
387
/**
 
388
 * Execute geometry shader using TGSI interpreter.
 
389
 */
 
390
int draw_geometry_shader_run(struct draw_geometry_shader *shader,
 
391
                             const void *constants[PIPE_MAX_CONSTANT_BUFFERS], 
 
392
                             const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS], 
 
393
                             const struct draw_vertex_info *input_verts,
 
394
                             const struct draw_prim_info *input_prim,
 
395
                             struct draw_vertex_info *output_verts,
 
396
                             struct draw_prim_info *output_prims )
 
397
{
 
398
   const float (*input)[4] = (const float (*)[4])input_verts->verts->data;
 
399
   unsigned input_stride = input_verts->vertex_size;
 
400
   unsigned vertex_size = input_verts->vertex_size;
 
401
   struct tgsi_exec_machine *machine = shader->machine;
 
402
   unsigned num_input_verts = input_prim->linear ?
 
403
                              input_verts->count :
 
404
                              input_prim->count;
 
405
   unsigned num_in_primitives =
 
406
      MAX2(u_gs_prims_for_vertices(input_prim->prim, num_input_verts),
 
407
           u_gs_prims_for_vertices(shader->input_primitive, num_input_verts));
 
408
   unsigned max_out_prims = u_gs_prims_for_vertices(shader->output_primitive,
 
409
                                                    shader->max_output_vertices)
 
410
                            * num_in_primitives;
 
411
 
 
412
   output_verts->vertex_size = input_verts->vertex_size;
 
413
   output_verts->stride = input_verts->vertex_size;
 
414
   output_verts->verts =
 
415
      (struct vertex_header *)MALLOC(input_verts->vertex_size *
 
416
                                     num_in_primitives *
 
417
                                     shader->max_output_vertices);
 
418
 
 
419
 
 
420
#if 0
 
421
   debug_printf("%s count = %d (in prims # = %d)\n",
 
422
                __FUNCTION__, num_input_verts, num_in_primitives);
 
423
   debug_printf("\tlinear = %d, prim_info->count = %d\n",
 
424
                input_prim->linear, input_prim->count);
 
425
   debug_printf("\tprimt pipe = %d, shader in = %d, shader out = %d, max out = %d\n",
 
426
                input_prim->prim, shader->input_primitive,
 
427
                shader->output_primitive,
 
428
                shader->max_output_vertices);
 
429
#endif
 
430
 
 
431
   shader->emitted_vertices = 0;
 
432
   shader->emitted_primitives = 0;
 
433
   shader->vertex_size = vertex_size;
 
434
   shader->tmp_output = (float (*)[4])output_verts->verts->data;
 
435
   shader->in_prim_idx = 0;
 
436
   shader->input_vertex_stride = input_stride;
 
437
   shader->input = input;
 
438
   if (shader->primitive_lengths) {
 
439
      FREE(shader->primitive_lengths);
 
440
   }
 
441
   shader->primitive_lengths = MALLOC(max_out_prims * sizeof(unsigned));
 
442
 
 
443
   tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
 
444
                                  constants, constants_size);
 
445
 
 
446
   if (input_prim->linear)
 
447
      gs_run(shader, input_prim, input_verts,
 
448
             output_prims, output_verts);
 
449
   else
 
450
      gs_run_elts(shader, input_prim, input_verts,
 
451
                  output_prims, output_verts);
 
452
 
 
453
   /* Update prim_info:
 
454
    */
 
455
   output_prims->linear = TRUE;
 
456
   output_prims->elts = NULL;
 
457
   output_prims->start = 0;
 
458
   output_prims->count = shader->emitted_vertices;
 
459
   output_prims->prim = shader->output_primitive;
 
460
   output_prims->flags = 0x0;
 
461
   output_prims->primitive_lengths = shader->primitive_lengths;
 
462
   output_prims->primitive_count = shader->emitted_primitives;
 
463
   output_verts->count = shader->emitted_vertices;
 
464
 
 
465
#if 0
 
466
   debug_printf("GS finished, prims = %d, verts = %d\n",
 
467
                output_prims->primitive_count,
 
468
                output_verts->count);
 
469
#endif
 
470
 
 
471
   return shader->emitted_vertices;
334
472
}
335
473
 
336
474
void draw_geometry_shader_delete(struct draw_geometry_shader *shader)
342
480
void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
343
481
                                  struct draw_context *draw)
344
482
{
345
 
    if (shader->machine->Tokens != shader->state.tokens) {
346
 
       tgsi_exec_machine_bind_shader(shader->machine,
347
 
                                     shader->state.tokens,
348
 
                                     draw->gs.num_samplers,
349
 
                                     draw->gs.samplers);
350
 
    }
 
483
   if (shader && shader->machine->Tokens != shader->state.tokens) {
 
484
      tgsi_exec_machine_bind_shader(shader->machine,
 
485
                                    shader->state.tokens,
 
486
                                    draw->gs.num_samplers,
 
487
                                    draw->gs.samplers);
 
488
   }
351
489
}