Пример #1
0
/**
 * Clear the rasterizer's current color tile.
 * This is a bin command called during bin processing.
 */
static void
lp_rast_clear_color(struct lp_rasterizer_task *task,
                    const union lp_rast_cmd_arg arg)
{
    const struct lp_scene *scene = task->scene;
    const uint8_t *clear_color = arg.clear_color;

    unsigned i;

    LP_DBG(DEBUG_RAST, "%s 0x%x,0x%x,0x%x,0x%x\n", __FUNCTION__,
           clear_color[0],
           clear_color[1],
           clear_color[2],
           clear_color[3]);

    if (clear_color[0] == clear_color[1] &&
            clear_color[1] == clear_color[2] &&
            clear_color[2] == clear_color[3]) {
        /* clear to grayscale value {x, x, x, x} */
        for (i = 0; i < scene->fb.nr_cbufs; i++) {
            uint8_t *ptr =
                lp_rast_get_color_tile_pointer(task, i, LP_TEX_USAGE_WRITE_ALL);
            memset(ptr, clear_color[0], TILE_SIZE * TILE_SIZE * 4);
        }
    }
    else {
        /* Non-gray color.
         * Note: if the swizzled tile layout changes (see TILE_PIXEL) this code
         * will need to change.  It'll be pretty obvious when clearing no longer
         * works.
         */
        const unsigned chunk = TILE_SIZE / 4;
        for (i = 0; i < scene->fb.nr_cbufs; i++) {
            uint8_t *c =
                lp_rast_get_color_tile_pointer(task, i, LP_TEX_USAGE_WRITE_ALL);
            unsigned j;

            for (j = 0; j < 4 * TILE_SIZE; j++) {
                memset(c, clear_color[0], chunk);
                c += chunk;
                memset(c, clear_color[1], chunk);
                c += chunk;
                memset(c, clear_color[2], chunk);
                c += chunk;
                memset(c, clear_color[3], chunk);
                c += chunk;
            }
        }
    }

    LP_COUNT(nr_color_tile_clear);
}
Пример #2
0
/**
 * Run the shader on all blocks in a tile.  This is used when a tile is
 * completely contained inside a triangle, and the shader is opaque.
 * This is a bin command called during bin processing.
 */
static void
lp_rast_shade_tile_opaque(struct lp_rasterizer_task *task,
                          const union lp_rast_cmd_arg arg)
{
   const struct lp_scene *scene = task->scene;
   unsigned i;

   LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);

   /* this will prevent converting the layout from tiled to linear */
   for (i = 0; i < scene->fb.nr_cbufs; i++) {
      (void)lp_rast_get_color_tile_pointer(task, i, LP_TEX_USAGE_WRITE_ALL);
   }

   lp_rast_shade_tile(task, arg);
}