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

« back to all changes in this revision

Viewing changes to src/gallium/drivers/llvmpipe/lp_rast_debug.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
#include "util/u_math.h"
 
2
#include "lp_rast_priv.h"
 
3
#include "lp_state_fs.h"
 
4
 
 
5
static INLINE int u_bit_scan(unsigned *mask)
 
6
{
 
7
   int i = ffs(*mask) - 1;
 
8
   *mask &= ~(1 << i);
 
9
   return i;
 
10
}
 
11
 
 
12
struct tile {
 
13
   int coverage;
 
14
   int overdraw;
 
15
   char data[TILE_SIZE][TILE_SIZE];
 
16
};
 
17
 
 
18
static char get_label( int i )
 
19
{
 
20
   static const char *cmd_labels = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
21
   unsigned max_label = (2*26+10);
 
22
 
 
23
   if (i < max_label)
 
24
      return cmd_labels[i];
 
25
   else
 
26
      return '?';
 
27
}
 
28
 
 
29
 
 
30
 
 
31
static const char *cmd_names[LP_RAST_OP_MAX] = 
 
32
{
 
33
   "clear_color",
 
34
   "clear_zstencil",
 
35
   "triangle_1",
 
36
   "triangle_2",
 
37
   "triangle_3",
 
38
   "triangle_4",
 
39
   "triangle_5",
 
40
   "triangle_6",
 
41
   "triangle_7",
 
42
   "triangle_8",
 
43
   "triangle_3_16",
 
44
   "shade_tile",
 
45
   "shade_tile_opaque",
 
46
   "begin_query",
 
47
   "end_query",
 
48
};
 
49
 
 
50
static const char *cmd_name(unsigned cmd)
 
51
{
 
52
   assert(Elements(cmd_names) > cmd);
 
53
   return cmd_names[cmd];
 
54
}
 
55
 
 
56
static const struct lp_fragment_shader_variant *
 
57
get_variant(  const struct cmd_block *block,
 
58
              int k )
 
59
{
 
60
   if (block->cmd[k] == LP_RAST_OP_SHADE_TILE ||
 
61
       block->cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE)
 
62
      return  block->arg[k].shade_tile->state->variant;
 
63
 
 
64
   if (block->cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
 
65
       block->cmd[k] == LP_RAST_OP_TRIANGLE_2 ||
 
66
       block->cmd[k] == LP_RAST_OP_TRIANGLE_3 ||
 
67
       block->cmd[k] == LP_RAST_OP_TRIANGLE_4 ||
 
68
       block->cmd[k] == LP_RAST_OP_TRIANGLE_5 ||
 
69
       block->cmd[k] == LP_RAST_OP_TRIANGLE_6 ||
 
70
       block->cmd[k] == LP_RAST_OP_TRIANGLE_7)
 
71
      return block->arg[k].triangle.tri->inputs.state->variant;
 
72
 
 
73
   return NULL;
 
74
}
 
75
 
 
76
 
 
77
static boolean
 
78
is_blend( const struct cmd_block *block,
 
79
          int k )
 
80
{
 
81
   const struct lp_fragment_shader_variant *variant = get_variant(block, k);
 
82
 
 
83
   if (variant)
 
84
      return  variant->key.blend.rt[0].blend_enable;
 
85
 
 
86
   return FALSE;
 
87
}
 
88
 
 
89
 
 
90
 
 
91
static void
 
92
debug_bin( const struct cmd_bin *bin )
 
93
{
 
94
   const struct cmd_block *head = bin->head;
 
95
   int i, j = 0;
 
96
 
 
97
   debug_printf("bin %d,%d:\n", bin->x, bin->y);
 
98
                
 
99
   while (head) {
 
100
      for (i = 0; i < head->count; i++, j++) {
 
101
         debug_printf("%d: %s %s\n", j,
 
102
                      cmd_name(head->cmd[i]),
 
103
                      is_blend(head, i) ? "blended" : "");
 
104
      }
 
105
      head = head->next;
 
106
   }
 
107
}
 
108
 
 
109
 
 
110
static void plot(struct tile *tile,
 
111
                 int x, int y,
 
112
                 char val,
 
113
                 boolean blend)
 
114
{
 
115
   if (tile->data[x][y] == ' ')
 
116
      tile->coverage++;
 
117
   else
 
118
      tile->overdraw++;
 
119
 
 
120
   tile->data[x][y] = val;
 
121
}
 
122
 
 
123
 
 
124
 
 
125
 
 
126
 
 
127
 
 
128
static int
 
129
debug_shade_tile(int x, int y,
 
130
                 const union lp_rast_cmd_arg arg,
 
131
                 struct tile *tile,
 
132
                 char val)
 
133
{
 
134
   const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
 
135
   boolean blend = inputs->state->variant->key.blend.rt[0].blend_enable;
 
136
   unsigned i,j;
 
137
 
 
138
   if (inputs->disable)
 
139
      return 0;
 
140
 
 
141
   for (i = 0; i < TILE_SIZE; i++)
 
142
      for (j = 0; j < TILE_SIZE; j++)
 
143
         plot(tile, i, j, val, blend);
 
144
 
 
145
   return TILE_SIZE * TILE_SIZE;
 
146
}
 
147
 
 
148
static int
 
149
debug_clear_tile(int x, int y,
 
150
                 const union lp_rast_cmd_arg arg,
 
151
                 struct tile *tile,
 
152
                 char val)
 
153
{
 
154
   unsigned i,j;
 
155
 
 
156
   for (i = 0; i < TILE_SIZE; i++)
 
157
      for (j = 0; j < TILE_SIZE; j++)
 
158
         plot(tile, i, j, val, FALSE);
 
159
 
 
160
   return TILE_SIZE * TILE_SIZE;
 
161
 
 
162
}
 
163
 
 
164
 
 
165
static int
 
166
debug_triangle(int tilex, int tiley,
 
167
               const union lp_rast_cmd_arg arg,
 
168
               struct tile *tile,
 
169
               char val)
 
170
{
 
171
   const struct lp_rast_triangle *tri = arg.triangle.tri;
 
172
   unsigned plane_mask = arg.triangle.plane_mask;
 
173
   struct lp_rast_plane plane[8];
 
174
   int x, y;
 
175
   int count = 0;
 
176
   unsigned i, nr_planes = 0;
 
177
   boolean blend = tri->inputs.state->variant->key.blend.rt[0].blend_enable;
 
178
 
 
179
   if (tri->inputs.disable) {
 
180
      /* This triangle was partially binned and has been disabled */
 
181
      return 0;
 
182
   }
 
183
 
 
184
   while (plane_mask) {
 
185
      plane[nr_planes] = tri->plane[u_bit_scan(&plane_mask)];
 
186
      plane[nr_planes].c = (plane[nr_planes].c +
 
187
                            plane[nr_planes].dcdy * tiley -
 
188
                            plane[nr_planes].dcdx * tilex);
 
189
      nr_planes++;
 
190
   }
 
191
 
 
192
   for(y = 0; y < TILE_SIZE; y++)
 
193
   {
 
194
      for(x = 0; x < TILE_SIZE; x++)
 
195
      {
 
196
         for (i = 0; i < nr_planes; i++)
 
197
            if (plane[i].c <= 0)
 
198
               goto out;
 
199
         
 
200
         plot(tile, x, y, val, blend);
 
201
         count++;
 
202
 
 
203
      out:
 
204
         for (i = 0; i < nr_planes; i++)
 
205
            plane[i].c -= plane[i].dcdx;
 
206
      }
 
207
 
 
208
      for (i = 0; i < nr_planes; i++) {
 
209
         plane[i].c += plane[i].dcdx * TILE_SIZE;
 
210
         plane[i].c += plane[i].dcdy;
 
211
      }
 
212
   }
 
213
   return count;
 
214
}
 
215
 
 
216
 
 
217
 
 
218
 
 
219
 
 
220
static void
 
221
do_debug_bin( struct tile *tile,
 
222
              const struct cmd_bin *bin,
 
223
              boolean print_cmds)
 
224
{
 
225
   unsigned k, j = 0;
 
226
   const struct cmd_block *block;
 
227
 
 
228
   int tx = bin->x * TILE_SIZE;
 
229
   int ty = bin->y * TILE_SIZE;
 
230
 
 
231
   memset(tile->data, ' ', sizeof tile->data);
 
232
   tile->coverage = 0;
 
233
   tile->overdraw = 0;
 
234
 
 
235
   for (block = bin->head; block; block = block->next) {
 
236
      for (k = 0; k < block->count; k++, j++) {
 
237
         boolean blend = is_blend(block, k);
 
238
         char val = get_label(j);
 
239
         int count = 0;
 
240
            
 
241
         if (print_cmds)
 
242
            debug_printf("%c: %15s", val, cmd_name(block->cmd[k]));
 
243
         
 
244
         if (block->cmd[k] == LP_RAST_OP_CLEAR_COLOR ||
 
245
             block->cmd[k] == LP_RAST_OP_CLEAR_ZSTENCIL)
 
246
            count = debug_clear_tile(tx, ty, block->arg[k], tile, val);
 
247
 
 
248
         if (block->cmd[k] == LP_RAST_OP_SHADE_TILE ||
 
249
             block->cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE)
 
250
            count = debug_shade_tile(tx, ty, block->arg[k], tile, val);
 
251
 
 
252
         if (block->cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
 
253
             block->cmd[k] == LP_RAST_OP_TRIANGLE_2 ||
 
254
             block->cmd[k] == LP_RAST_OP_TRIANGLE_3 ||
 
255
             block->cmd[k] == LP_RAST_OP_TRIANGLE_4 ||
 
256
             block->cmd[k] == LP_RAST_OP_TRIANGLE_5 ||
 
257
             block->cmd[k] == LP_RAST_OP_TRIANGLE_6 ||
 
258
             block->cmd[k] == LP_RAST_OP_TRIANGLE_7)
 
259
            count = debug_triangle(tx, ty, block->arg[k], tile, val);
 
260
 
 
261
         if (print_cmds) {
 
262
            debug_printf(" % 5d", count);
 
263
 
 
264
            if (blend)
 
265
               debug_printf(" blended");
 
266
            
 
267
            debug_printf("\n");
 
268
         }
 
269
      }
 
270
   }
 
271
}
 
272
 
 
273
void
 
274
lp_debug_bin( const struct cmd_bin *bin)
 
275
{
 
276
   struct tile tile;
 
277
   int x,y;
 
278
 
 
279
   if (bin->head) {
 
280
      do_debug_bin(&tile, bin, TRUE);
 
281
 
 
282
      debug_printf("------------------------------------------------------------------\n");
 
283
      for (y = 0; y < TILE_SIZE; y++) {
 
284
         for (x = 0; x < TILE_SIZE; x++) {
 
285
            debug_printf("%c", tile.data[y][x]);
 
286
         }
 
287
         debug_printf("|\n");
 
288
      }
 
289
      debug_printf("------------------------------------------------------------------\n");
 
290
 
 
291
      debug_printf("each pixel drawn avg %f times\n",
 
292
                   ((float)tile.overdraw + tile.coverage)/(float)tile.coverage);
 
293
   }
 
294
}
 
295
 
 
296
 
 
297
 
 
298
 
 
299
 
 
300
 
 
301
/** Return number of bytes used for a single bin */
 
302
static unsigned
 
303
lp_scene_bin_size( const struct lp_scene *scene, unsigned x, unsigned y )
 
304
{
 
305
   struct cmd_bin *bin = lp_scene_get_bin((struct lp_scene *) scene, x, y);
 
306
   const struct cmd_block *cmd;
 
307
   unsigned size = 0;
 
308
   for (cmd = bin->head; cmd; cmd = cmd->next) {
 
309
      size += (cmd->count *
 
310
               (sizeof(uint8_t) + sizeof(union lp_rast_cmd_arg)));
 
311
   }
 
312
   return size;
 
313
}
 
314
 
 
315
 
 
316
 
 
317
void
 
318
lp_debug_draw_bins_by_coverage( struct lp_scene *scene )
 
319
{
 
320
   unsigned x, y;
 
321
   unsigned total = 0;
 
322
   unsigned possible = 0;
 
323
   static unsigned long long _total;
 
324
   static unsigned long long _possible;
 
325
 
 
326
   for (x = 0; x < scene->tiles_x; x++)
 
327
      debug_printf("-");
 
328
   debug_printf("\n");
 
329
 
 
330
   for (y = 0; y < scene->tiles_y; y++) {
 
331
      for (x = 0; x < scene->tiles_x; x++) {
 
332
         struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
 
333
         const char *bits = "0123456789";
 
334
         struct tile tile;
 
335
 
 
336
         if (bin->head) {
 
337
            //lp_debug_bin(bin);
 
338
 
 
339
            do_debug_bin(&tile, bin, FALSE);
 
340
 
 
341
            total += tile.coverage;
 
342
            possible += 64*64;
 
343
 
 
344
            if (tile.coverage == 64*64)
 
345
               debug_printf("*");
 
346
            else if (tile.coverage) {
 
347
               int bit = tile.coverage/(64.0*64.0)*10;
 
348
               debug_printf("%c", bits[MIN2(bit,10)]);
 
349
            }
 
350
            else
 
351
               debug_printf("?");
 
352
         }
 
353
         else {
 
354
            debug_printf(" ");
 
355
         }
 
356
      }
 
357
      debug_printf("|\n");
 
358
   }
 
359
 
 
360
   for (x = 0; x < scene->tiles_x; x++)
 
361
      debug_printf("-");
 
362
   debug_printf("\n");
 
363
 
 
364
   debug_printf("this tile total: %u possible %u: percentage: %f\n",
 
365
                total,
 
366
                possible,
 
367
                total * 100.0 / (float)possible);
 
368
 
 
369
   _total += total;
 
370
   _possible += possible;
 
371
 
 
372
   debug_printf("overall   total: %llu possible %llu: percentage: %f\n",
 
373
                _total,
 
374
                _possible,
 
375
                _total * 100.0 / (double)_possible);
 
376
}
 
377
 
 
378
 
 
379
void
 
380
lp_debug_draw_bins_by_cmd_length( struct lp_scene *scene )
 
381
{
 
382
   unsigned x, y;
 
383
 
 
384
   for (y = 0; y < scene->tiles_y; y++) {
 
385
      for (x = 0; x < scene->tiles_x; x++) {
 
386
         const char *bits = " ...,-~:;=o+xaw*#XAWWWWWWWWWWWWWWWW";
 
387
         int sz = lp_scene_bin_size(scene, x, y);
 
388
         int sz2 = util_unsigned_logbase2(sz);
 
389
         debug_printf("%c", bits[MIN2(sz2,32)]);
 
390
      }
 
391
      debug_printf("\n");
 
392
   }
 
393
}
 
394
 
 
395
 
 
396
void
 
397
lp_debug_bins( struct lp_scene *scene )
 
398
{
 
399
   unsigned x, y;
 
400
 
 
401
   for (y = 0; y < scene->tiles_y; y++) {
 
402
      for (x = 0; x < scene->tiles_x; x++) {
 
403
         struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
 
404
         if (bin->head) {
 
405
            debug_bin(bin);
 
406
         }
 
407
      }
 
408
   }
 
409
}