Sign in to follow this  
Tsumuji

SDL is not getting a SDL_HWACCEL flag.

Recommended Posts

When I try to start a window here with SDL_HWACCEL flag, the VideoInfo->blit_hw is not getting true. I'm really neading this to speedup my application. This is a pure SDL window mode, so no OpenGL. What is wrong? the x11 driver? I create the window in the following manner:
int NTE_window::start( int xr, int yr, int dc, char* wt, bool fs ){
	if ( SDL_Init( SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_EVENTTHREAD ) < 0 ){
		std::cout << SDL_GetError( ) << std::endl;
		SDL_Quit( );
		return 1;
	}
	
	const SDL_VideoInfo* VideoInfo;
	
	VideoInfo = SDL_GetVideoInfo( );
	if ( !VideoInfo ){
		std::cout << SDL_GetError( ) << std::endl;
		return 1;
	}
	
	FlagsVideo = SDL_HWPALETTE;
	if ( fs )
		FlagsVideo |= SDL_FULLSCREEN;
	
	if ( VideoInfo->hw_available ){
		FlagsVideo |= SDL_HWSURFACE;
		FlagsVideo |= SDL_DOUBLEBUF;
		DBuff = true;
		cout << "Hardware surface - Doublebuffered Window!" << endl;
	}else{
		FlagsVideo |= SDL_SWSURFACE;
		DBuff = false;
		cout << "Software surface - Singlebuffered Window!" << endl;
	}
	if ( VideoInfo->blit_hw ){
		FlagsVideo |= SDL_HWACCEL;
		cout << "Hardware accelerated blitting!" << endl;
	}
	
	sdlSURFACE = SDL_SetVideoMode( xr, yr, dc, FlagsVideo );
	if ( !sdlSURFACE ){
		std::cout << SDL_GetError( ) << std::endl;
		return 1;
	}
	
	char* vdn = new char[10];
	SDL_VideoDriverName( vdn, 10 );
	cout << "Video driver used: " << vdn ;//<< endl << "===========================" << endl;
	
	SDL_WM_SetCaption( wt, NULL);
	//SDL_EnableKeyRepeat( 5, 135 );
	
	
	w = xr;
	h = yr;
	fulls = fs;
	deph = dc;
	
	return 0;
}


Another thing, is that I can't get double buffering using the x11 driver. In full or windowed mode. Just using fbcon video driver trough directfb. Using here SDL-1.2.11 in slackware 10.2.

Share this post


Link to post
Share on other sites
The X11 backend doesn't provide HW acceleration. Windowed applications also don't have HW acceleration nor double buffering, AFAIK. Note that HW acceleration doesn't mean that you'll get better framerates. Quite often it's the contrary.

Hope this helps.

Share this post


Link to post
Share on other sites
But I get low frame rates, about 50 in windowed mode and 30 using directfb in console. And to just do nothing! The application is just blitering, nothing more!
How can I accelerate this thing?
Force some type of SDL video driver?

Oh, I'm running here in a ASUS KVM400 motherboard, so I have a GeForce 4 on-board.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tsumuji
But I get low frame rates, about 50 in windowed mode and 30 using directfb in console. And to just do nothing! The application is just blitering, nothing more!


But is there a significant drop if you do more complex operations?


Quote:

How can I accelerate this thing?
Force some type of SDL video driver?

Oh, I'm running here in a ASUS KVM400 motherboard, so I have a GeForce 4 on-board.


What is the refresh rate of your monitor? Are you converting all your surfaces with SDL_DisplayFormat or SDL_DisplayFormatAlpha? Which bit depth are you passing to SDL_SetVideoMode? I'd suggest always passing zero to use the current depth, otherwise SDL might have to convert things on the fly.

I usually go for a software surface with "double buffering" (that is, I let SDL emulate double buffering for me), and I pass 0 for the depth. Then I convert all the surfaces to the current depth with the aforementioned functions. I've never had to complain about the speed, though you can't expect a 1024x768x32 game to give you 500 FPS. 2D games on Windows were typically 640x480x16 when they weren't 640x480x8, and that was with DirectX (which bypasses a good bunch of the OS).

Also, the last time I checked (a long while ago), DirectFB only had support for Matrox cards and some ATI ones. If that hasn't changed, you're likely using a generic VESA framebuffer.


Hope this helps.

Share this post


Link to post
Share on other sites
yes, I have a drop, but not too great since I developed very optimized operations. (I was programming this thing ins that way since beginning)
But if I for example fill the screen 3 times with a image every frame, the software pratically stops :)

In KDE my refresh is 75Hz, and in framebuffer(console), 60Hz.
I'm converting all my sprites with SDL_DisplayFormatAlpha().
I was passing 24.
I'm running app at 640x480x32.

I followed what you say about depth colors, and worked! My frames goes to 250-333!
what a mess! Thank you very much!
I tried now with fbcon driver, and worked better than using directfb. funny :)

EDIT: One more question: When I run in framebuffer, the app does not printf very correctly here. It printf the first messages and after this does not print for example the FPS that I say ti print every frame. App works very well in KDE...

Share this post


Link to post
Share on other sites
Quote:
Original post by Tsumuji
EDIT: One more question: When I run in framebuffer, the app does not printf very correctly here. It printf the first messages and after this does not print for example the FPS that I say ti print every frame. App works very well in KDE...


Sorry, I didn't see that you'd edited your post.

Are the first messages printed before the call to SDL_SetVideoMode? I have no experience using the framebuffer device, so this is just a guess, but I suspect that nothing prints because the display is being used by your game. That is, you've acquired a more or less exclusive lock on the display for that console.

As I said though, this is just a guess. My advice to you would be to log to a file. If you need to read the log while the game is running, switch to another virtual console and use "tail -f the_log_file" to display the log file.

Hope this helps.

Share this post


Link to post
Share on other sites
Source.
Quote:

[SDL] SDL_HWACCEL flag
Stephane Marchesin stephane.marchesin at wanadoo.fr
Mon Sep 20 15:54:23 PDT 2004

* Previous message: [SDL] SDL_HWACCEL flag
* Next message: [SDL] Hardware blit with doublebuffer strange
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Carlos Alvarez wrote:

>I found the flag SDL_HWACCEL used in some SDL opensourced apps.
>
>But this flag doesn't seem to be documented in the official Docproject.
>Is it deprecated or has it just been forgot ?
>
>What is the usage for this flag ?
>
This flag is read only.
SDL_HWACCEL means that the blit that just happened with this surface as
source used hardware acceleration.
Sometimes I see it used in SDL_SetVideoMode(). It has no effect there.

Stephane




* Previous message: [SDL] SDL_HWACCEL flag
* Next message: [SDL] Hardware blit with doublebuffer strange
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the SDL mailing list

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this