llvmpipe: implement the new can_create_resource() function
[mesa.git] / src / gallium / drivers / llvmpipe / lp_rast_debug.c
index 3113e196c408ff89431f117b596b80032ba4ec61..86f5f6415e8c826da6eef7accb139263977a1f87 100644 (file)
@@ -2,13 +2,6 @@
 #include "lp_rast_priv.h"
 #include "lp_state_fs.h"
 
-static INLINE int u_bit_scan(unsigned *mask)
-{
-   int i = ffs(*mask) - 1;
-   *mask &= ~(1 << i);
-   return i;
-}
-
 struct tile {
    int coverage;
    int overdraw;
@@ -62,6 +55,9 @@ get_variant( const struct lp_rast_state *state,
              const struct cmd_block *block,
              int k )
 {
+   if (!state)
+      return NULL;
+
    if (block->cmd[k] == LP_RAST_OP_SHADE_TILE ||
        block->cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE ||
        block->cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
@@ -95,7 +91,7 @@ is_blend( const struct lp_rast_state *state,
 static void
 debug_bin( const struct cmd_bin *bin )
 {
-   const struct lp_rast_state *state;
+   const struct lp_rast_state *state = NULL;
    const struct cmd_block *head = bin->head;
    int i, j = 0;
 
@@ -140,9 +136,14 @@ debug_shade_tile(int x, int y,
                  char val)
 {
    const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
-   boolean blend = tile->state->variant->key.blend.rt[0].blend_enable;
+   boolean blend;
    unsigned i,j;
 
+   if (!tile->state)
+      return 0;
+
+   blend = tile->state->variant->key.blend.rt[0].blend_enable;
+
    if (inputs->disable)
       return 0;
 
@@ -178,6 +179,7 @@ debug_triangle(int tilex, int tiley,
 {
    const struct lp_rast_triangle *tri = arg.triangle.tri;
    unsigned plane_mask = arg.triangle.plane_mask;
+   const struct lp_rast_plane *tri_plane = GET_PLANES(tri);
    struct lp_rast_plane plane[8];
    int x, y;
    int count = 0;
@@ -190,7 +192,7 @@ debug_triangle(int tilex, int tiley,
    }
 
    while (plane_mask) {
-      plane[nr_planes] = tri->plane[u_bit_scan(&plane_mask)];
+      plane[nr_planes] = tri_plane[u_bit_scan(&plane_mask)];
       plane[nr_planes].c = (plane[nr_planes].c +
                             plane[nr_planes].dcdy * tiley -
                             plane[nr_planes].dcdx * tilex);
@@ -239,6 +241,7 @@ do_debug_bin( struct tile *tile,
    memset(tile->data, ' ', sizeof tile->data);
    tile->coverage = 0;
    tile->overdraw = 0;
+   tile->state = NULL;
 
    for (block = bin->head; block; block = block->next) {
       for (k = 0; k < block->count; k++, j++) {
@@ -395,8 +398,8 @@ lp_debug_draw_bins_by_cmd_length( struct lp_scene *scene )
    for (y = 0; y < scene->tiles_y; y++) {
       for (x = 0; x < scene->tiles_x; x++) {
          const char *bits = " ...,-~:;=o+xaw*#XAWWWWWWWWWWWWWWWW";
-         int sz = lp_scene_bin_size(scene, x, y);
-         int sz2 = util_unsigned_logbase2(sz);
+         unsigned sz = lp_scene_bin_size(scene, x, y);
+         unsigned sz2 = util_logbase2(sz);
          debug_printf("%c", bits[MIN2(sz2,32)]);
       }
       debug_printf("\n");