VERY slow SDL_SetColors() changes when using bittorrent

Win32

I was trying to fix a bad bug related to SDL in Gordon’s Duke Nukem 3D port.
It’s an amazing bug that makes a terrible lag in the SDL_SetColors() when some
other applications are running at the same time.

EG: One of the application slowing down SDL_SetColors() is Bittorent when
downloading. I guess this is something related to the progess bar of Bittorrent.
If Bittorrent doesn’t download then SDL_SetColors() will be fast.

SDL_SetColors() is slowed by approximately 50 to 100 times.

This bug is only noticable when: some app are running (like bittorent) and
when doing loops on the SDL_SetColors() to create fading effects. You won’t see
the lag by issuing only 1 instance of SDL_SetColors() of course.

Any idea?

Regards,–
mk

It’s also possible that Bittorrent is taking up a lot of CPU time, which
would lag other things running.On 1/14/06, Matt Klein wrote:

Win32

I was trying to fix a bad bug related to SDL in Gordon’s Duke Nukem 3D
port.
It’s an amazing bug that makes a terrible lag in the SDL_SetColors()
when some
other applications are running at the same time.

EG: One of the application slowing down SDL_SetColors() is Bittorent when
downloading. I guess this is something related to the progess bar of
Bittorrent.
If Bittorrent doesn’t download then SDL_SetColors() will be fast.

SDL_SetColors() is slowed by approximately 50 to 100 times.

This bug is only noticable when: some app are running (like bittorent)
and
when doing loops on the SDL_SetColors() to create fading effects. You
won’t see
the lag by issuing only 1 instance of SDL_SetColors() of course.

Any idea?

Regards,


mk


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


Cheers,
Josh

PGP: http://revvy.box43.net/Josh_Matthews.asc

Josh Matthews <mrlachatte gmail.com> writes:

It’s also possible that Bittorrent is taking up a lot of CPU time, which would
lag other things running.

Dear Josh,

Thanks for your answer.

Unfortunately, it is not. Bittorrent uses 10% CPU on a PIII 550 Mhz. Replacing
Bittorrent by another application that uses even +50% CPU won’t make any lag in
the fading effect.

Various info that could help regarding this bug:

  1. The application is the ‘Duke Nukem 3D’ game. It will work fine at its full
    speed with bittorrent until the Duke 3D orders a fading effect with
    SDL_SetColors().

  2. This bugs occured on at least 3 different PCs managed by different people,
    from 550 Mhz to +3.4Ghz, using both Intel and AMD, using different graphic cards.

  3. I could easily reproduce this bug from user’s reports.

  4. Only a very few applications can make SDL_SetColors()lag. Known applications
    to date are: Bittorrent and the Longhorn Inspirat theme for Win XP.

  5. SDL_SetColors() is the same as SDL_SetPalette but uses SDL_LOGPAL |
    SDL_PHYSPAL. Using SDL_SetPalette shows that only the SDL_PHYSPAL lags, not
    SDL_LOGPAL. (!)

  6. You can test the issue by running XP (and surely any Win32) and Duke3d
    Rancidmeat reloaded v19.6 at http://duke3d.m-klein.com (you’ll need the provided
    shareware GRP file as well) and bittorrent http://www.bittorrent.com.
    Alternatively, you can check out Icculus version (http://www.icculus.org/) of
    Duke3d that is also affected.

Various info that could help regarding this bug:

  1. The application is the ‘Duke Nukem 3D’ game. It will work fine at its full
    speed with bittorrent until the Duke 3D orders a fading effect with
    SDL_SetColors().

Is this using a software renderer? What version of SDL are you using?
If you’re using one built from CVS, try 1.2.9 released code.

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Is this using a software renderer? What version of SDL are you using?
If you’re using one built from CVS, try 1.2.9 released code.

(It’s a software renderer, writing to an 8-bit, palettized framebuffer)
I’m wondering if it’s a bad interaction with his DirectX drivers, and if
turning off the hardware palette in Duke3D would help.

In buildengine/sdl_driver.c, find this around line 1297:
sdl_flags |= SDL_HWPALETTE;

And delete it. Rebuild and see if the problem goes away.

–ryan.

Ryan C. Gordon <icculus icculus.org> writes:

Is this using a software renderer? What version of SDL are you using?
If you’re using one built from CVS, try 1.2.9 released code.

(It’s a software renderer, writing to an 8-bit, palettized framebuffer)
I’m wondering if it’s a bad interaction with his DirectX drivers, and if
turning off the hardware palette in Duke3D would help.

In buildengine/sdl_driver.c, find this around line 1297:
sdl_flags |= SDL_HWPALETTE;

And delete it. Rebuild and see if the problem goes away.

–ryan.

Hi Sam and Ryan. Thanks again for your ideas. We are getting closer. Here are
the answers following your suggestions + more relevant informations:

// SDL libs are embedded in exe to allow an easier putenv under Win32 and
// to avoid users to mess up with the various version of the SDL dll.

if( BFullScreen )
putenv(“SDL_VIDEODRIVER=directx”); // FullScreen Mode, trying
else
putenv(“SDL_VIDEODRIVER=windib”); // Window Mode, trying windib

sdl_flags = BFullScreen ? SDL_FULLSCREEN : 0;
sdl_flags |= SDL_HWPALETTE;

The conditions for the palette lag to happen must be:----
SDL_FULLSCREEN + SDL_VIDEODRIVER=directx + bittorent (must display an active
progress bar by downloading something) + game’s FPS below 100. In this case
the fadding effect (palette changes loop) will drop the game’s FPS down to
2 or 3 FPS. Makes the game unplayable when getting hurt or picking up
new weapons.

  • Doing a (fullscreen + Windib) or a (Windowed mode + Directx) is all good.

  • The SDL_HWPALETTE can be used or removed, it doesn’t change anything.

  • Issue happens in both stable SDL 1.2.4 and 1.2.9 (I have not tryed any top
    tree version of the CVS archive yet. I will try a top version though and let you
    know).

  • If the game’s FPS is huge (say +400 fps) then the lag effect is less noticable
    but it’s still there.

  • The Jonof port of duke3d (in fact of the Ken Silverman’s Build Engine) uses
    DirectX full screen, but no SDL. Palette changes are always fine.