{"action":"created","issue":{"url":"https://api.github.com/repos/SFML/SFML/issues/1379","repository_url":"https://api.github.com/repos/SFML/SFML","labels_url":"https://api.github.com/repos/SFML/SFML/issues/1379/labels{/name}","comments_url":"https://api.github.com/repos/SFML/SFML/issues/1379/comments","events_url":"https://api.github.com/repos/SFML/SFML/issues/1379/events","html_url":"https://github.com/SFML/SFML/pull/1379","id":301178695,"number":1379,"title":"Optimized RenderTexture performance","user":{"login":"binary1248","id":949359,"avatar_url":"https://avatars1.githubusercontent.com/u/949359?v=4","gravatar_id":"","url":"https://api.github.com/users/binary1248","html_url":"https://github.com/binary1248","followers_url":"https://api.github.com/users/binary1248/followers","following_url":"https://api.github.com/users/binary1248/following{/other_user}","gists_url":"https://api.github.com/users/binary1248/gists{/gist_id}","starred_url":"https://api.github.com/users/binary1248/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binary1248/subscriptions","organizations_url":"https://api.github.com/users/binary1248/orgs","repos_url":"https://api.github.com/users/binary1248/repos","events_url":"https://api.github.com/users/binary1248/events{/privacy}","received_events_url":"https://api.github.com/users/binary1248/received_events","type":"User","site_admin":false},"labels":[{"id":85850,"url":"https://api.github.com/repos/SFML/SFML/labels/feature","name":"feature","color":"23BA35","default":false},{"id":85856,"url":"https://api.github.com/repos/SFML/SFML/labels/m:sfml-graphics","name":"m:sfml-graphics","color":"cccccc","default":false},{"id":85855,"url":"https://api.github.com/repos/SFML/SFML/labels/m:sfml-window","name":"m:sfml-window","color":"cccccc","default":false}],"state":"open","locked":false,"assignee":{"login":"binary1248","id":949359,"avatar_url":"https://avatars1.githubusercontent.com/u/949359?v=4","gravatar_id":"","url":"https://api.github.com/users/binary1248","html_url":"https://github.com/binary1248","followers_url":"https://api.github.com/users/binary1248/followers","following_url":"https://api.github.com/users/binary1248/following{/other_user}","gists_url":"https://api.github.com/users/binary1248/gists{/gist_id}","starred_url":"https://api.github.com/users/binary1248/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binary1248/subscriptions","organizations_url":"https://api.github.com/users/binary1248/orgs","repos_url":"https://api.github.com/users/binary1248/repos","events_url":"https://api.github.com/users/binary1248/events{/privacy}","received_events_url":"https://api.github.com/users/binary1248/received_events","type":"User","site_admin":false},"assignees":[{"login":"binary1248","id":949359,"avatar_url":"https://avatars1.githubusercontent.com/u/949359?v=4","gravatar_id":"","url":"https://api.github.com/users/binary1248","html_url":"https://github.com/binary1248","followers_url":"https://api.github.com/users/binary1248/followers","following_url":"https://api.github.com/users/binary1248/following{/other_user}","gists_url":"https://api.github.com/users/binary1248/gists{/gist_id}","starred_url":"https://api.github.com/users/binary1248/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binary1248/subscriptions","organizations_url":"https://api.github.com/users/binary1248/orgs","repos_url":"https://api.github.com/users/binary1248/repos","events_url":"https://api.github.com/users/binary1248/events{/privacy}","received_events_url":"https://api.github.com/users/binary1248/received_events","type":"User","site_admin":false}],"milestone":null,"comments":15,"created_at":"2018-02-28T20:52:22Z","updated_at":"2018-03-10T11:39:17Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/SFML/SFML/pulls/1379","html_url":"https://github.com/SFML/SFML/pull/1379","diff_url":"https://github.com/SFML/SFML/pull/1379.diff","patch_url":"https://github.com/SFML/SFML/pull/1379.patch"},"body":"Optimized RenderTexture performance when using the FBO implementation by removing unnecessary context switches and flushing.\r\n\r\nIn this change, FBOs no longer live in their own context if they don't have to. This reduces or even eliminates context switching all together in single window applications, giving \"near native OpenGL performance\". Furthermore, the glFlush() in display() was also removed in favour of explicit rebinding in RenderTarget in order to reduce the time waiting for the driver queue to flush to the GPU queue. This also saves a large amount of time.\r\n\r\nIn applications that make heavy use of RenderTextures, this can mean a significant performance gain if they were previously CPU-bottlenecked. This change shouldn't have an effect on the actual GPU workload in any way.\r\n\r\nHere is a synthetic \"benchmark\" I used to test the difference with and without this change:\r\n```cpp\r\n#include <SFML/Graphics.hpp>\r\n#include <sstream>\r\n\r\nint main()\r\n{\r\n    sf::RenderWindow window(sf::VideoMode(800, 600), \"Test\", sf::Style::Titlebar | sf::Style::Close);\r\n    window.setVerticalSyncEnabled(false);\r\n\r\n    sf::Font font;\r\n    if (!font.loadFromFile(\"resources/sansation.ttf\"))\r\n        return EXIT_FAILURE;\r\n\r\n    sf::Text text(\"Test\", font, 20);\r\n\r\n    sf::RenderTexture renderTexture[10];\r\n\r\n    for (int i = 0; i < 10; ++i)\r\n        renderTexture[i].create(800, 600);\r\n\r\n    sf::Sprite sprite;\r\n\r\n    sf::Clock clock;\r\n    std::ostringstream sstr;\r\n\r\n    while (window.isOpen())\r\n    {\r\n        sf::Event event;\r\n        while (window.pollEvent(event))\r\n        {\r\n            if (event.type == sf::Event::Closed)\r\n                window.close();\r\n\r\n            if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))\r\n                window.close();\r\n        }\r\n\r\n        for (int i = 0; i < 20; ++i)\r\n        {\r\n            for (int j = 0; j < 10; ++j)\r\n            {\r\n                renderTexture[j].clear(sf::Color(0, 0, 0));\r\n\r\n                for (int j = 0; j < 10; ++j)\r\n                    renderTexture[j].draw(text);\r\n\r\n                renderTexture[j].display();\r\n            }\r\n\r\n            window.clear(sf::Color(0, 0, 0));\r\n\r\n            for (int j = 0; j < 10; ++j)\r\n            {\r\n                sprite.setTexture(renderTexture[j].getTexture());\r\n\r\n                for (int k = 0; k < 10; ++k)\r\n                    window.draw(sprite);\r\n            }\r\n        }\r\n\r\n        window.display();\r\n\r\n        sstr.str(\"\");\r\n        sstr << \"Test -- Frame: \" << clock.restart().asSeconds() << \" sec\";\r\n\r\n        window.setTitle(sstr.str());\r\n    }\r\n\r\n    return EXIT_SUCCESS;\r\n}\r\n```\r\nFrame times on my laptop dropped from 800ms down to 200ms with this change. This is a 4x speedup.\r\nEverybody is free to test this change for bugs and performance deltas using real-world applications. I'd like feedback regarding more realistic workloads as well."},"comment":{"url":"https://api.github.com/repos/SFML/SFML/issues/comments/372023424","html_url":"https://github.com/SFML/SFML/pull/1379#issuecomment-372023424","issue_url":"https://api.github.com/repos/SFML/SFML/issues/1379","id":372023424,"user":{"login":"binary1248","id":949359,"avatar_url":"https://avatars1.githubusercontent.com/u/949359?v=4","gravatar_id":"","url":"https://api.github.com/users/binary1248","html_url":"https://github.com/binary1248","followers_url":"https://api.github.com/users/binary1248/followers","following_url":"https://api.github.com/users/binary1248/following{/other_user}","gists_url":"https://api.github.com/users/binary1248/gists{/gist_id}","starred_url":"https://api.github.com/users/binary1248/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binary1248/subscriptions","organizations_url":"https://api.github.com/users/binary1248/orgs","repos_url":"https://api.github.com/users/binary1248/repos","events_url":"https://api.github.com/users/binary1248/events{/privacy}","received_events_url":"https://api.github.com/users/binary1248/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T11:39:17Z","updated_at":"2018-03-10T11:39:17Z","author_association":"OWNER","body":"@naezith The commit timestamp doesn't change if I amend it."}}
{"actor":{"display_login":"binary1248"}}