On Tue, 2008-07-01 at 23:27 +0100, Matthew Allum wrote:
> I've never noticed high CPU usage with
> clutter_texture_set_from_rgb_data(). Have you tried profiling it to
> check if it really is set_from_rgb_data and if it is, if anything bad is
> happening below in COGL ?

I had profiled it insofar as commenting out the call to
clutter_texture_set_from_rgb_data(), which when doing so the CPU usage
dropped to zero.

On my system, the call itself takes about 1700us for a 640x480 image
(and uses about 35% cpu for 60fps), and a 1920x1080 image takes around
12000us (and uses ~80% cpu).

I'll do some better profiling inside clutter to figure out what's going
on.  Speeds that bad smells like maybe a mesa fallback.  I do know that
evas is much faster at updating textures, so there's nothing
intrinsically problematic with my card or driver.
 
I've attached a simple test to benchmark this.  I wonder how it compares
with other graphics cards / drivers?


> Path2 should ultimately be fastest and most portable hardware wise.

Yes, although path 1 is providing immediate gratification (at least for
nvidia), performs very well (it is viable to use for 1080p h264 video),
and has the benefit of not requiring to write custom VOs for the players
we want to support.

Unfortunately, it seems clutter_glx_texture_pixmap_new_with_window()
doesn't work on Intel GMA, although the x11 variant does.  (I had a
friend test it, and it segfaults.)  Might anyone know what's missing in
terms of support from the intel driver and/or mesa for this to work?

As an aside, I started playing with clutter for the first time on
Saturday, and the more I dig into it, the more I am impressed by it.
Very nice code and design, and I appreciate the fact that it provides
lower level hooks at various layers, right down to
cogl_texture_new_from_foreign().  Shows good foresight, as it's quite
frustrating to have your hands tied by an inflexible or immature API.
So kudos to the development team and contributors.

Thanks,
Jason.

// gcc clutter-rgb-benchmark.c `pkg-config clutter-0.7 --cflags --libs` -lXcomposite -o clutter-rgb-benchmark

#include <stdlib.h>
#include <string.h>

#include <clutter/clutter.h>

#define WIDTH 640
#define HEIGHT 480

guchar *data = 0;

static long long get_usecs()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return (long long)((tv.tv_sec * 1000000.0) + tv.tv_usec);
}

gboolean upload(ClutterActor *tex)
{
    GError *e = 0;
    long long t0 = get_usecs();
    clutter_texture_set_from_rgb_data(CLUTTER_TEXTURE(tex), data,
             TRUE, WIDTH, HEIGHT, WIDTH*4, 4, 0, &e);
    if (e)
        printf("UPLOAD FAILED: %s\n", e->message);
    printf("Upload took: %d\n", get_usecs() - t0);

    return TRUE;
}

int
main (int argc, char **argv)
{
    ClutterActor *stage, *tex;
    const ClutterColor black = { 0x00, 0x00, 0x00, 0xff };

    clutter_init (&argc, &argv);

    data = malloc(WIDTH*HEIGHT*4);
    memset(data, 155, WIDTH*HEIGHT*4);

    stage = clutter_stage_get_default();
    clutter_stage_set_color(CLUTTER_STAGE (stage), &black);

    tex = clutter_texture_new();
    clutter_actor_set_size(tex, WIDTH, HEIGHT);
    g_timeout_add(16, (GSourceFunc)upload, tex);
    clutter_container_add_actor(CLUTTER_CONTAINER(stage), tex);

    clutter_actor_show(stage);
    clutter_main();

    return EXIT_SUCCESS;
}

Reply via email to