SFML community forums

Help => General => Topic started by: TheEvent on December 02, 2012, 08:09:48 am

Title: Massive performance boost after unknown event
Post by: TheEvent on December 02, 2012, 08:09:48 am
Post below
Title: Re: Massive performance boost after unknown event
Post by: TheEvent on December 04, 2012, 07:44:56 am
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int main(){
    sf::Vector2i s(640,360);
    sf::RenderWindow window(sf::VideoMode(s.x, s.y),"TheEvent");
    sf::VertexArray graph; graph.setPrimitiveType(sf::LinesStrip);
    for (int x = 0; x < s.x; ++x) graph.append(sf::Vertex());
    sf::Texture texture; texture.create(16,16);
    sf::Clock clock; int frame = 0;
    while (true){
        sf::Event e; while (window.pollEvent(e));
        window.clear();
        ++frame; clock.restart();
        for (int i = 0; i < s.x*s.y/256;++i){
            sf::Uint8 buffer[1024];
            for (int i = 0; i < 1024; i++)
                buffer[i] = rand()%256;
            texture.update(buffer); // <<----randomly super slow
        }
        graph[frame%s.x].position = sf::Vector2f(frame%s.x,
            s.y-s.y*clock.getElapsedTime().asMicroseconds()/33333);
        window.draw(graph);
        window.display();
    }
    return 0;
}
 
Title: Re: Massive performance boost after unknown event
Post by: Laurent on December 04, 2012, 07:59:44 am
Thanks a lot for your tests. Unfortunately, I don't see what could be causing this in Texture::update. You'll have to investigate further if you want to find out what happens :-\
Title: Re: Massive performance boost after unknown event
Post by: Laurent on December 04, 2012, 08:30:42 pm
Have you tried to remove all the glGet calls? You can safely remove glGetError() and all glGet related to the preservation of texture/shader binding.
Title: Re: Massive performance boost after unknown event
Post by: Laurent on December 05, 2012, 08:07:29 am
Great. Could you create a task in the tracker which summarizes what you found, with a link to this forum thread? So that it doesn't get forgotten, and hopefully "fixed" one day :)
Title: Re: Massive performance boost after unknown event
Post by: eXpl0it3r on December 05, 2012, 08:30:23 pm
Laurent meant that you should make a new issue on the issue tracker (https://github.com/SFML/SFML/issues). ;)
I guess the pull request is also a nice way to share the possible changes, but an issue might work additionally too. ;)
Title: Re: Massive performance boost after unknown event
Post by: Laurent on December 05, 2012, 08:46:25 pm
Since I can't merge your code (see my comments in your pull request), yes, you should rather create a new task.