Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [2.0] VSYNC bug on AMD cards  (Read 3199 times)

0 Members and 1 Guest are viewing this topic.

trilavia

  • Newbie
  • *
  • Posts: 28
    • View Profile
[2.0] VSYNC bug on AMD cards
« on: November 04, 2012, 10:31:30 pm »
Hey I have a problem. When I use vsync in SFML window on amd hd 6870 i get 97-99% gpu usage @60 fps, and without vsync i have like 30% gpu usage @ 300 fps. The problem exist on both pre compiled sfml 2.0 version and latest git compiled few days ago. It happens on both newest drivers and those 1 year old. What's more, it happens both on windows 32 bit and linux 64 bit. Of course the problem only exist with SFML apps, in games like guild wars or any other when i enable vsync the gpu usage is low as it should be (you can check usage in ati catalyst control center/afterburner/gpu-z).

IMPORTANT THING: When I used nvidia gts 450 gpu I didn't have any problem at all (I mean, with vsync enabled in that 2d sfml application gpu usage was about 15%). 

So here's the code that is enough to make it happen:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "VSYNC AMD BUG");
    window.setVerticalSyncEnabled(true);
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }

    return 0;
}
 

And thats enough. At first i thought it was something with my drawing code, but the bug exist even on empty window with vsync. When you compile it without vsync, gpu usage is 30%. Enable vsync and boom 99% is used all the time.

And please remember, this is only amd related bug (well, hd 6xxx for sure, i don't know about others) and I think this bug may be crucial as enabling vsync in small 2d game causes powerful gpu to run into high temps (and despite visual advantages of vsync, the another purpose is just to reduce fps = reduce gpu usage = reduce temps and power consumption and the problem is that using sfml's vsync on amd card does exactly the opposite, because without vsync the gpu usage is 3x lower than with vsync enabled).

What's more, when I once run pure opengl app with vsync on my amd 6870, gpu usage was about 35% I think, so it may be something related to how SFML implements OpenGL vsync. It also probably is in some way related to amd catalyst drivers (as SFML vsync works as it should on nvidia cards), but as I said i seen opengl application with vsync where the problem wasn't present on amd card, so maybe there is another possible way of implementating vsync in opengl that will work flawlessy on both amd and nvidia.

Thanks for help!
« Last Edit: November 04, 2012, 10:54:22 pm by trilavia »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: [2.0] VSYNC bug on AMD cards
« Reply #1 on: November 05, 2012, 12:52:45 am »
I'm not sure, but is there some Threading option in th AMD drivers? I'm having a similar issue, if I'm running with Threading enabled in driver options: With VSync enabled, rendering (actually "glClear()") takes all available CPU time without slowing down the program. If Threading is forced off, my program runs at 0% CPU load.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [2.0] VSYNC bug on AMD cards
« Reply #2 on: November 05, 2012, 08:02:11 am »
Quote
it may be something related to how SFML implements OpenGL vsync
It's very unlikely. V-sync is internally just a single, very simple function to call. It can't be wrong.
Laurent Gomila - SFML developer

trilavia

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: [2.0] VSYNC bug on AMD cards
« Reply #3 on: November 05, 2012, 08:20:59 am »
@Mario
It's not that, it's not related to cpu load. Cpu load with vsync is kinda ok (its MUCH lower with nvidia vsync though).

@Laurent
Maybe there are two extensions for that, like ext and wgl/glx one? And one of them works a bit worse?
And also I heard something about glFinish() with vsync and that it can make difference in resource usage, do you know something about it?

Because damn dx games have no problems with vsync and unfortunately my sfml game has :( and without vsync tearing is just terrible in fast paced game and I don't know what to do... I also read that there is blocking and non-blocking buffer swap in vsync but I think it's driver related and there is no way to change it in code. But could you just look into it Laurent?

Thanks
« Last Edit: November 05, 2012, 08:23:00 am by trilavia »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [2.0] VSYNC bug on AMD cards
« Reply #4 on: November 05, 2012, 08:41:55 am »
I thought it was CPU load too. If you're talking about GPU load, then it's definitely between you and the graphics driver.

If all other games that run fine with v-sync use DirectX, then try to find an OpenGL game instead. The comparison is not relevant, they are two totally different APIs -- although they end up using the same stuff in the end. For example, you could test all the code examples that you can find in OpenGL v-sync tutorials.

I really don't have the time to investigate this further, I'm sorry. But since it's so specific and focuses on a single function, maybe you can try to find more information yourself :)
Laurent Gomila - SFML developer

trilavia

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: [2.0] VSYNC bug on AMD cards
« Reply #5 on: November 05, 2012, 02:40:31 pm »
Okay thanks, I'll try to get some info and test vsync in pure opengl. I will post here if I discover something.