Multisample broken?

Ello.

After upgrading to SDL 1.2.6, I noticed the frame rates in my simple OpenGL
game have halved, from ~550FPS to ~260FPS.
(not that it matters at this point, but once I have more effects
implemented, that’ll make a difference, maybe from 70FPS to 30FPS)
I looked all through my code, but couldn’t find any bugs or undefined
behaviors that could have caused it, until I noticed something:
All the lines in game were antialiased, in rather ugly way. (They weren’t
before)
I’ve checked all my driver options, and antialiasing is set to Application
Controlled.
I wasn’t setting the SDL_GL_MULTISAMPLESAMPLES and SDL_GL_MULTISAMPLEBUFFERS
gl options.
I tried doing this:
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0);
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0);
but it stays on.
The only setting I could get to make it turn off was
SDL_GL_MULTISAMPLESAMPLES=2 and SDL_GL_MULTISAMPLEBUFFERS=2.
Is multisampling supposed to default to ON? And why would 2,2 turn it off?

I’m using MSVC 6 with service packs, win98SE, and a nVidia geForce 3 ti200.

Philip D. Bober wrote:

I’ve checked all my driver options, and antialiasing is set to Application
Controlled.
I wasn’t setting the SDL_GL_MULTISAMPLESAMPLES and SDL_GL_MULTISAMPLEBUFFERS
gl options.
I tried doing this:
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0);
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0);
but it stays on.

No problem here, w2k, SDL 1.2.6, Nvidia GeforceFX5200, Nvidia drivers
4.5.2.3, vs6 (intel compiler 7.0).

I do set the multisample attributes though.

int sdl_flags = SDL_OPENGL;
int win_width = 800, win_height = 600, bpp = 32;
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24; //8, 16, 24
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1); //boolean 0, 1
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1); //boolean 0, 1
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4); //0, 2, 4

SDL_Surface *screen = SDL_SetVideoMode(win_width, win_height, bpp,
sdl_flags);

Regards,
\Mikkel Gjoel

SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1); //boolean 0, 1
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4); //0, 2, 4

But you’re turning it on, it looks like.
I haven’t had any problems turning it on, just it won’t turn off (unless I
use 2,2) and it’s on by default!

----- Original Message -----
From: s971661@student.dtu.dk (Mikkel Gjol)
To:
Sent: Saturday, October 04, 2003 5:50 PM
Subject: Re: [SDL] Multisample broken?

Philip D. Bober wrote:

SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1); //boolean 0, 1
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4); //0, 2, 4

But you’re turning it on, it looks like.
I haven’t had any problems turning it on, just it won’t turn off (unless I
use 2,2) and it’s on by default!

Indeed - it works setting it to (0, 0) too though. I have no idea why 2,
2 would turn it off, especially since SDL_GL_MULTISAMPLEBUFFERS is a
boolean value AFAIK. You are using latest drivers and all, right?

A funny thing though, is that using multisample-buffers alone has a
performance-impact. My application runs a great deal slower with
multisample-buffers and disabled multisampling in GL, than without
multisampling at all.
( glDisable / glEnable(GL_MULTISAMPLE_ARB) )

Regards,
\Mikkel Gjoel

Even though I probably know the answer (“you can’t, it’a s wm-feature”)
I still need to ask the question :slight_smile:

Is it possible to set an SDL-window “always on top”. I need this
primarily for fullscreen, where other “always on top”-windows overlap my
sdl-window :frowning:

Any suggestions?

Oh, and it’s Windoze.

Regards,
\Mikkel Gjoel

Philip D. Bober wrote:

SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1); //boolean 0, 1
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4); //0, 2, 4

But you’re turning it on, it looks like.
I haven’t had any problems turning it on, just it won’t turn off (unless I
use 2,2) and it’s on by default!

Indeed - it works setting it to (0, 0) too though. I have no idea why 2,
2 would turn it off, especially since SDL_GL_MULTISAMPLEBUFFERS is a
boolean value AFAIK. You are using latest drivers and all, right?

A funny thing though, is that using multisample-buffers alone has a
performance-impact. My application runs a great deal slower with
multisample-buffers and disabled multisampling in GL, than without
multisampling at all.
( glDisable / glEnable(GL_MULTISAMPLE_ARB) )

Multisample buffers can be quite large. If the total video memory used
by you program without multisample buffers is just small enough to fit
in your video memory then all you resources stay in video memory while
you program is running. Adding multisample buffers will make it so that
all of your resources can’t fit in video memory and your textures can
be swapped back and forth. So, in some special cases you can get a
significant slowdown by requesting the buffers, and not using them.

The slow down could also be caused by a change in access patterns to the
ZS buffer. Requesting multisample buffers forces the ZS buffer to be as
large as the multisample buffers.

I can think of a few other things that can cause a slow down like the
one you describe. But, I have to start guessing about design decisions
to make those sound reasonable. :slight_smile:

		Bob PendletonOn Sun, 2003-10-05 at 05:38, Mikkel Gj?l wrote:

Regards,
\Mikkel Gjoel


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±----------------------------------+

Bob Pendleton wrote:> On Sun, 2003-10-05 at 05:38, Mikkel Gj?l wrote:

I can think of a few other things that can cause a slow down like the
one you describe. But, I have to start guessing about design decisions
to make those sound reasonable. :slight_smile:

The slowdown is there just clearing and flipping the framebuffer.
Actually I’ve been wondering about this for some time, as it seems
incredibly slow.

A 1024x768, rgba (32bpp), 24bit depth-buffer gives me the following:
~150fps with no multisampling
~40fps with 4x multisampling

CG is loaded but no shaders are enabled. Disabling CG altogether gives
me ~200fps with no multisampling. Fullscreen about 210fps. It seems a
buffer-swap takes about 25ms.

Not clearing any buffers ups to about
~300fps no multisampling
~85fps with 4x multisampling

This is the code run each frame:
timer = SDL_GetTicks() - starttime;
++framecount;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();

P4-2GHz, GeforceFX5200, SDL 1.2.6, Nvidia drivers 4.5.2.3.

I don’t get it.

Regards,
\Mikkel Gjoel

Mikkel Gj?l wrote:

This is the code run each frame:
timer = SDL_GetTicks() - starttime;
++framecount;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();

P4-2GHz, GeforceFX5200, SDL 1.2.6, Nvidia drivers 4.5.2.3.

same code type (more control handle event ecc … but only clear and swap on
graphic)

amd athlon 1600+ sdl 126 radeon 9700pro windows (no fsaa config in sdl, driver
is set to handle application config)

FPS MIN : 4207.28
FPS MAX : 4494.01
FPS MED : 4409.38

on 1 minut run

Hi!

Am Sonntag, 05 Oktober 2003 schrieb Mikkel Gj?l
:

[…] I need this
primarily for fullscreen, where other “always on top”-windows overlap
my
sdl-window :frowning:
[…]
Oh, and it’s Windoze.

How do you do "Always on Top" in Windows? Or do you mean popups?

regards
Matthias

Matthias Bach wrote:

Am Sonntag, 05 Oktober 2003 schrieb Mikkel Gj?l <@Mikkel_Gjol>
:

[…] I need this
primarily for fullscreen, where other “always on top”-windows overlap
my sdl-window :frowning:
[…]

How do you do "Always on Top" in Windows? Or do you mean popups?

I guess it needs to be a part of the program. E.g. Winamp has an “always
on top” feature. Modal-popups are usually only “on top” within the program.

I still don’t know how, or if it’s possible, to use SDL for this purpose
though.

Regards,
\Mikkel Gjoel

I still don’t know how, or if it’s possible, to use SDL for this purpose
though.

I think you can use the SDL_syswm interface to get the SDL window handle
and change it’s style using platform specific code.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Bob Pendleton wrote:

I can think of a few other things that can cause a slow down like the
one you describe. But, I have to start guessing about design decisions
to make those sound reasonable. :slight_smile:

The slowdown is there just clearing and flipping the framebuffer.
Actually I’ve been wondering about this for some time, as it seems
incredibly slow.

A 1024x768, rgba (32bpp), 24bit depth-buffer gives me the following:
~150fps with no multisampling
~40fps with 4x multisampling

With 4x multisampling the multisample buffer and the Z buffer are
actually 2048x1536 by 32 bits each. As I understand it each graphics
operation, even clearing, must first be done in the multisample buffer,
and then the result must be sampled and moved to the buffer you thought
you were working in. Just clearing the multisample buffer and the Z
buffer now take 4 times as long, plus there is the sampling step. So, I
would expect a slow down of at least 4 to 1 just to account for the
difference in buffer sizes. You are seeing a slow down of 3.75 to 1.
Which is perfectly reasonable and indicates that the sampling is being
done very quickly.

	Bob PendletonOn Sun, 2003-10-05 at 16:35, Mikkel Gj?l wrote:

On Sun, 2003-10-05 at 05:38, Mikkel Gj?l wrote:

CG is loaded but no shaders are enabled. Disabling CG altogether gives
me ~200fps with no multisampling. Fullscreen about 210fps. It seems a
buffer-swap takes about 25ms.

Not clearing any buffers ups to about
~300fps no multisampling
~85fps with 4x multisampling

This is the code run each frame:
timer = SDL_GetTicks() - starttime;
++framecount;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();

P4-2GHz, GeforceFX5200, SDL 1.2.6, Nvidia drivers 4.5.2.3.

I don’t get it.

Regards,
\Mikkel Gjoel


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±----------------------------------+

Bob Pendleton wrote:> On Sun, 2003-10-05 at 16:35, Mikkel Gj?l wrote:

This is the code run each frame:
timer = SDL_GetTicks() - starttime;
++framecount;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();

P4-2GHz, GeforceFX5200, SDL 1.2.6, Nvidia drivers 4.5.2.3.

A 1024x768, rgba (32bpp), 24bit depth-buffer gives me the following:
~150fps with no multisampling
~40fps with 4x multisampling

With 4x multisampling the multisample buffer and the Z buffer are
actually 2048x1536 by 32 bits each. As I understand it each graphics
operation, even clearing, must first be done in the multisample buffer,
and then the result must be sampled and moved to the buffer you thought
you were working in. Just clearing the multisample buffer and the Z
buffer now take 4 times as long, plus there is the sampling step. So, I
would expect a slow down of at least 4 to 1 just to account for the
difference in buffer sizes. You are seeing a slow down of 3.75 to 1.
Which is perfectly reasonable and indicates that the sampling is being
done very quickly.

Thanks a lot for the detailed analysis - makes much more sense now. I am
a bit confused about the low maximum framerate of about 300fps. But it
might just be, that the fx5200 really is that slow.

Best regards,
\Mikkel Gjoel

I just noticed that while DarkWorld hasthis bug, Spear doesn’t.
I compared their init code, and this is the only difference:

SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 0 );
(In Spear, which doesn’t have the bug)

DarkWorld doesn’t set a depth size. I changed the depth size to 16 in Spear,
and it started showing the bug too.
Setting it to 32 or 8 makes the bug go away.
I looked through the SDL code (in CVS), and I can’t see why this would
happen.

Any ideas?

Philip> ----- Original Message -----

From: @Philip_D_Bober (Philip D. Bober)
To:
Sent: Saturday, October 04, 2003 5:02 PM
Subject: [SDL] Multisample broken?

Ello.

After upgrading to SDL 1.2.6, I noticed the frame rates in my simple
OpenGL
game have halved, from ~550FPS to ~260FPS.
(not that it matters at this point, but once I have more effects
implemented, that’ll make a difference, maybe from 70FPS to 30FPS)
I looked all through my code, but couldn’t find any bugs or undefined
behaviors that could have caused it, until I noticed something:
All the lines in game were antialiased, in rather ugly way. (They weren’t
before)
I’ve checked all my driver options, and antialiasing is set to Application
Controlled.
I wasn’t setting the SDL_GL_MULTISAMPLESAMPLES and
SDL_GL_MULTISAMPLEBUFFERS
gl options.
I tried doing this:
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0);
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0);
but it stays on.
The only setting I could get to make it turn off was
SDL_GL_MULTISAMPLESAMPLES=2 and SDL_GL_MULTISAMPLEBUFFERS=2.
Is multisampling supposed to default to ON? And why would 2,2 turn it off?

I’m using MSVC 6 with service packs, win98SE, and a nVidia geForce 3
ti200.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl