New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for pbuffers on Windows and Unix. #885

Merged
merged 1 commit into from Sep 29, 2015

Conversation

Projects
None yet
4 participants
@binary1248
Member

binary1248 commented May 11, 2015

With p-buffer support, we can cut down on the number of hidden windows that have to be created. This is done by reusing the hidden window of the shared context as the drawable to bind the context to and a p-buffer as the surface onto which drawing operations are performed. Even in contexts which are not meant for drawing, OpenGL requires a valid framebuffer destination to exist, and we replace the window's surface with a p-buffer in this case. This will save on operating system resources as well and should fix #434.

@binary1248 binary1248 self-assigned this May 11, 2015

@binary1248 binary1248 added this to the 2.4 milestone May 11, 2015

@ekunuke

This comment has been minimized.

Show comment
Hide comment
@ekunuke

ekunuke Jun 16, 2015

Thanks for working on this, binary1248.

This does mean we will no longer have to keep RenderTextures in a pool to avoid #434, right? If so, this is the biggest feature I'm looking forward to for SFML 2.4.

ekunuke commented Jun 16, 2015

Thanks for working on this, binary1248.

This does mean we will no longer have to keep RenderTextures in a pool to avoid #434, right? If so, this is the biggest feature I'm looking forward to for SFML 2.4.

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Jun 16, 2015

Member

@egpaik If @LaurentGomila's assumption is true, then yes it does mean that. I tried to reproduce the issue myself, however I was unsuccessful. If you are experiencing that specific issue as well, you can build this branch and see if it changes anything for you. If it doesn't, I'll have to dig a little bit deeper.

Member

binary1248 commented Jun 16, 2015

@egpaik If @LaurentGomila's assumption is true, then yes it does mean that. I tried to reproduce the issue myself, however I was unsuccessful. If you are experiencing that specific issue as well, you can build this branch and see if it changes anything for you. If it doesn't, I'll have to dig a little bit deeper.

@ekunuke

This comment has been minimized.

Show comment
Hide comment
@ekunuke

ekunuke Jun 16, 2015

After some testing, I can verify that this feature fixes the flickering issue.

To confirm, I took the example code from #434 (with some additional debug information):

#include <iostream>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>


int main()
{
    sf::RenderWindow App(sf::VideoMode(640, 480, 32), "SFML Test", sf::Style::Fullscreen);
    App.setFramerateLimit(60);

    sf::RectangleShape rect(sf::Vector2f(300, 300));
    rect.setFillColor(sf::Color::White);
    rect.setPosition(170, 100);

    sf::RenderTexture *tex_ptr = NULL;

    while (App.isOpen())
    {
        sf::Event Event;

        while (App.pollEvent(Event))
        {
            // Close Window
            if (Event.type == sf::Event::Closed)
                return 1;

            if (Event.type == sf::Event::KeyPressed)
            {
                // Exit
                if (Event.key.code == sf::Keyboard::Escape)
                    return 1;

                // Each time F1 is pressed, screen goes black in some sort flickering
                if (Event.key.code == sf::Keyboard::F1)
                {
                    sf::RenderTexture tex;
                    tex.create(200, 200);
                    printf("F1 pressed.\n");
                }

                // Each time F2 is pressed, screen goes black in some sort flickering
                if (Event.key.code == sf::Keyboard::F2)
                {
                    tex_ptr = new sf::RenderTexture();
                    tex_ptr->create(200, 200);
                    delete tex_ptr; // if this line is commented, does not flick
                    printf("F2 pressed.\n");
                }
            }
        }

        App.clear();
        App.draw(rect);
        App.display();
    }

    return 0;
}

I tested my current (not quite up-to-date) version of SFML(b7c0af3) as well as feature/pbuffer. The older version produced the flickering whenever I pressed F1/F2, while the new branch did not flicker.

Compiled SFML and the test code using MSVC 2013.

The machine I reproduced and fixed the issue on was a Windows 8.1 machine with a NVIDIA GeForce GTX 750 graphics card.

I could not reproduce the issue on my other computer, a Windows 7 machine with a NVIDIA Geforce GT 650M.

My graphics drivers are up-to-date on both of these computers.

ekunuke commented Jun 16, 2015

After some testing, I can verify that this feature fixes the flickering issue.

To confirm, I took the example code from #434 (with some additional debug information):

#include <iostream>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>


int main()
{
    sf::RenderWindow App(sf::VideoMode(640, 480, 32), "SFML Test", sf::Style::Fullscreen);
    App.setFramerateLimit(60);

    sf::RectangleShape rect(sf::Vector2f(300, 300));
    rect.setFillColor(sf::Color::White);
    rect.setPosition(170, 100);

    sf::RenderTexture *tex_ptr = NULL;

    while (App.isOpen())
    {
        sf::Event Event;

        while (App.pollEvent(Event))
        {
            // Close Window
            if (Event.type == sf::Event::Closed)
                return 1;

            if (Event.type == sf::Event::KeyPressed)
            {
                // Exit
                if (Event.key.code == sf::Keyboard::Escape)
                    return 1;

                // Each time F1 is pressed, screen goes black in some sort flickering
                if (Event.key.code == sf::Keyboard::F1)
                {
                    sf::RenderTexture tex;
                    tex.create(200, 200);
                    printf("F1 pressed.\n");
                }

                // Each time F2 is pressed, screen goes black in some sort flickering
                if (Event.key.code == sf::Keyboard::F2)
                {
                    tex_ptr = new sf::RenderTexture();
                    tex_ptr->create(200, 200);
                    delete tex_ptr; // if this line is commented, does not flick
                    printf("F2 pressed.\n");
                }
            }
        }

        App.clear();
        App.draw(rect);
        App.display();
    }

    return 0;
}

I tested my current (not quite up-to-date) version of SFML(b7c0af3) as well as feature/pbuffer. The older version produced the flickering whenever I pressed F1/F2, while the new branch did not flicker.

Compiled SFML and the test code using MSVC 2013.

The machine I reproduced and fixed the issue on was a Windows 8.1 machine with a NVIDIA GeForce GTX 750 graphics card.

I could not reproduce the issue on my other computer, a Windows 7 machine with a NVIDIA Geforce GT 650M.

My graphics drivers are up-to-date on both of these computers.

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Sep 17, 2015

Member

Bump.

Member

binary1248 commented Sep 17, 2015

Bump.

@Bromeon

This comment has been minimized.

Show comment
Hide comment
@Bromeon

Bromeon Sep 19, 2015

Member

I tested both before and after binary1248's commit, neither version could reproduce the issue.
Intel HD Graphics 3000

Member

Bromeon commented Sep 19, 2015

I tested both before and after binary1248's commit, neither version could reproduce the issue.
Intel HD Graphics 3000

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Sep 19, 2015

Member

I guess this issue is specific to certain hardware/driver versions.

This pull request not only fixes the issue for those who are affected but also reduces application resource consumption by reducing the number of hidden windows that are created by SFML.

Member

binary1248 commented Sep 19, 2015

I guess this issue is specific to certain hardware/driver versions.

This pull request not only fixes the issue for those who are affected but also reduces application resource consumption by reducing the number of hidden windows that are created by SFML.

@ekunuke

This comment has been minimized.

Show comment
Hide comment
@ekunuke

ekunuke Sep 19, 2015

👍
Many of our players were affected by this issue, leading us to utilize an expensive RenderTexture pool up until now.

ekunuke commented Sep 19, 2015

👍
Many of our players were affected by this issue, leading us to utilize an expensive RenderTexture pool up until now.

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Sep 23, 2015

Member

Rebased onto current master.

Member

binary1248 commented Sep 23, 2015

Rebased onto current master.

@eXpl0it3r

This comment has been minimized.

Show comment
Hide comment
@eXpl0it3r

eXpl0it3r Sep 23, 2015

Member

@egpaik Now that the PR is uptodate again, could you give it a last try before merging?

Member

eXpl0it3r commented Sep 23, 2015

@egpaik Now that the PR is uptodate again, could you give it a last try before merging?

@ekunuke

This comment has been minimized.

Show comment
Hide comment
@ekunuke

ekunuke Sep 23, 2015

@eXpl0it3r Unfortunately I don't personally have access to the computer that can repro the issue anymore.

We did however recently deploy a new revision of our game, which features a fork of SFML that includes this PR. If a player reports any bugs related to this, I'll be sure to post it here.

ekunuke commented Sep 23, 2015

@eXpl0it3r Unfortunately I don't personally have access to the computer that can repro the issue anymore.

We did however recently deploy a new revision of our game, which features a fork of SFML that includes this PR. If a player reports any bugs related to this, I'll be sure to post it here.

@eXpl0it3r

This comment has been minimized.

Show comment
Hide comment
@eXpl0it3r

eXpl0it3r Sep 27, 2015

Member

This PR has been added to my merge list, meaning it will be merged soon, unless someone raises any concerns.

Member

eXpl0it3r commented Sep 27, 2015

This PR has been added to my merge list, meaning it will be merged soon, unless someone raises any concerns.

@eXpl0it3r eXpl0it3r merged commit 811dfe1 into master Sep 29, 2015

16 checks passed

sfml-debian-64-gcc Build #328 succeeded in 1 min 45 sec
Details
sfml-osx Build #195 succeeded in 2 min 52 sec
Details
sfml-ubuntu-64-gcc Build #182 succeeded in 1 min 47 sec
Details
sfml-windows7-32-mingw492 Build #267 succeeded in 1 min 25 sec
Details
sfml-windows7-32-msvc10 Build #247 succeeded in 1 min 59 sec
Details
sfml-windows7-32-msvc11 Build #244 succeeded in 3 min 19 sec
Details
sfml-windows7-32-msvc12 Build #239 succeeded in 2 min 42 sec
Details
sfml-windows7-32-tdm471 Build #243 succeeded in 6 min 17 sec
Details
sfml-windows7-32-tdm481 Build #241 succeeded in 1 min 8 sec
Details
sfml-windows7-64-mingw492 Build #252 succeeded in 1 min 45 sec
Details
sfml-windows7-64-msvc10 Build #244 succeeded in 2 min 46 sec
Details
sfml-windows7-64-msvc11 Build #239 succeeded in 2 min 40 sec
Details
sfml-windows7-64-msvc12 Build #256 succeeded in 2 min 14 sec
Details
sfml-windows7-64-tdm471 Build #238 succeeded in 6 min 27 sec
Details
sfml-windows7-64-tdm481 Build #257 succeeded in 1 min 31 sec
Details
test Build #161 succeeded in 1 min 26 sec
Details

@eXpl0it3r eXpl0it3r deleted the feature/pbuffer branch Sep 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment