Very slow rendering

"nmapp" <[email protected]>
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
I'm experiencing very slow rendering on my Debian 8 system (SDL2 version 2.0.4). Here's an example:

Code:

#define _GNU_SOURCE 

#include <stdio.h>
#include <SDL.h>

#include <time.h>

int main(void)
{
    SDL_version version;
    SDL_GetVersion(&version);
    printf("%d.%d.%d\n", (int) version.major, (int) version.minor, (int) version.patch);

    SDL_Init(SDL_INIT_VIDEO);

    SDL_Window *window = SDL_CreateWindow( "An SDL2 window",
        SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
        640, 480,
        SDL_WINDOW_SHOWN);

    SDL_Renderer *renderer = SDL_CreateRenderer(window,
        -1, SDL_RENDERER_ACCELERATED);

    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);

    for (int i = 0; i < 60; i++) {
        SDL_RenderClear(renderer);

        struct timespec start_get_time, end_get_time;
        Uint32 start_get_ticks, end_get_ticks;

        start_get_ticks = SDL_GetTicks();
        clock_gettime(CLOCK_MONOTONIC, &start_get_time);

        SDL_RenderPresent(renderer); /* TOO SLOW */

        clock_gettime(CLOCK_MONOTONIC, &end_get_time);
        end_get_ticks = SDL_GetTicks();

        long nsecs = end_get_time.tv_nsec - start_get_time.tv_nsec;

        printf("nsecs: %ld\n", nsecs);
        printf("msecs: %u\n", (unsigned) end_get_ticks - start_get_ticks);
    }

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}



and here's some of the output:

Code:

2.0.4
nsecs: 407449
msecs: 0
nsecs: 306949
msecs: 1
nsecs: 483087
msecs: 0
...
nsecs: 30375208
msecs: 31
nsecs: 4968098
msecs: 5
nsecs: 28803868
msecs: 29
nsecs: 5190540
msecs: 5
nsecs: 25599449
msecs: 26
nsecs: 28874268
msecs: 30
nsecs: 5098142
msecs: 5
nsecs: 27725881
msecs: 28
nsecs: 29498292
msecs: 29
nsecs: 5148706
msecs: 5
nsecs: 25935731
msecs: 26
nsecs: 1477544
msecs: 1



is that... normal? i assume not? in the real applications, these slowdowns are a lot more consistent. 12-25 milliseconds per call to RenderPresent. strace shows the following:

Code:

socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_LOCAL, sun_path=@"/tmp/.X11-unix/X0"}, 20) = 0  
...
recvmsg(3, 0x7ffd9801e220, 0)  = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(3, 0x7ffd9801e220, 0)  = -1 EAGAIN (Resource temporarily unavailable)



Again, there is a lot more "Resource unavailable" in the real program. Any advice?

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.