Advertisement

SDL_GL_Swapbuffers() performance issue

Started by January 21, 2002 05:15 AM
0 comments, last by alargeduck 23 years, 1 month ago
I have a rather simple scene set up as a test bed for my camera system. It consists of a transparent floor, with a couple of crates on the top, as well as their reflections underneath. This runs at an appalling ~40 fps on my p3 700mhz, GeForce DDR Linux box at 800*600*32. Id expect atleast twice that framerate, probably considerably more. A more complex scene renders at 120+ fps at the same resolution in an older program. Both programs use essentially the same base code which lhas me utterly confused. I set up a simple timer with SDL_GetTicks() to time the execution of various parts of the main loop. Apparently almost all of the roughly 25ms per frame is spent in SDL_GL_SwapBuffers().In the other program described, SDL_GL_SwapBuffers() completes nearly instantaneously, 0 - 1 ms. As I was writing this, it came to me that perhaps OpenGL calls are simply qued, and then sent to the X server in the buffer swap call. But if this were an issue, I think a particle system pushing 2000 blended particles with an inverse square based gravity system would run considerably slower than some cubes and a floor. Since it is very much relevant, here is my window creation code:
  
WINDOW make_window(int resx, int resy, int bpp, int vid_flags, char * title)
	{
	WINDOW w;
	
	memset(&w, 0, sizeof(WINDOW));
	
	w.resx = resx;
	w.resy = resy;
	w.bpp = bpp;
	
	w.video_flags  = vid_flags;
	w.video_flags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
	
	w.video_info = (SDL_VideoInfo *)SDL_GetVideoInfo();	
	
	if(!w.video_info) return w;
	
	if(w.video_info->hw_available) w.video_flags |= SDL_HWSURFACE;
	else w.video_flags |= SDL_SWSURFACE;
	
	if(w.video_info->blit_hw) w.video_flags |= SDL_HWACCEL;
	
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	
	w.surface = SDL_SetVideoMode(w.resx, w.resy, w.bpp, w.video_flags);	
	if(!w.surface) return w;
	
	set_window_caption(&w, title);
	
	return w;	
	}
  
I am getting a software blitter (i''d imagine a hardware blitter exists) and a hardware surface, which might explain the sluggish performance, but the other program described also had a software blitter. I''m completely lost. All ideas appreciated.
quote:

pparently almost all of the roughly 25ms per frame is spent in SDL_GL_SwapBuffers().In the other program described, SDL_GL_SwapBuffers() completes nearly instantaneously, 0 - 1 ms



Sounds very much like a vsync issue.

This topic is closed to new replies.

Advertisement