UPDATE!!
Turned out I was using in built Intel graphics, changing it to dedicated graphics card kinda solved it... taking around 5ms, let me know if this is normal (for something like GeForce 840M low end graphics card) it now goes like 60 fps on 800*600 and 1920*1080, 25 fps on 1920*2160.
Now displaying takes 5 times the time it draws... more reasonable, but I'd like more if possible (It's just a few triangles (1000), and only one draw call... maybe my graphics card is just REALLY BAD)
Main profiler - new loop: 1
Main profiler - poll events: 13
Main profiler - graphene movement test: 6
Main profiler - graphene spawn element: 242
Spawn layout generator: 2
Generate layout: 303
Triangles: 1016
Draw: 1601
Display: 174618
5fps
This is the timings of each part of game loop using sf::Clock.
poll event took 13us
generating vertex array with my own function with 1016 triangles took 303us
drawing a single vertex array to the renderwindow took 1601us
However window->display() took up to 174ms, well over 20ms most of the cycles.
Here is a sample of time window->display() took for a few cycles:
10fps
Display: 8520
46fps
Display: 32877
24fps
Display: 28428
33fps
Display: 28748
32fps
Display: 33446
22fps
Display: 21339
41fps
Display: 29773
30fps
Display: 29936
30fps
Display: 29797
32fps
Display: 31445
30fps
Display: 34606
28fps
Display: 32469
28fps
Display: 31490
29fps
Display: 31927
29fps
Display: 33826
14fps
Display: 1545
429fps
Display: 35023
27fps
Display: 37010
26fps
Display: 35281
26fps
Display: 34500
13fps
Display: 1902
369fps
Display: 35636
27fps
Display: 35628
13fps
Display: 1368
451fps
Display: 37175
26fps
Display: 38083
12fps
Display: 2375
269fps
Display: 38247
25fps
Display: 38992
12fps
Display: 1510
410fps
Display: 40545
23fps
Display: 38150
11fps
Display: 1934
350fps
Display: 42024
20fps
Display: 82159
12fps
Display: 11240
62fps
Display: 28280
25fps
Display: 38575
25fps
Display: 44938
10fps
Display: 2280
293fps
Display: 44944
22fps
Display: 45327
19fps
Display: 39925
24fps
Display: 2717
265fps
Display: 43975
22fps
Display: 94987
10fps
Display: 10716
84fps
Display: 1818
277fps
Display: 47146
20fps
Display: 92366
10fps
Display: 7352
67fps
Display: 33882
27fps
Display: 48984
10fps
Display: 2449
198fps
Display: 48376
13fps
Display: 27405
11fps
Display: 1872
354fps
Display: 52004
19fps
Display: 50053
10fps
Display: 2184
300fps
Display: 53196
9fps
Display: 2035
130fps
Display: 57235
17fps
Display: 60270
9fps
Display: 2554
269fps
Display: 69510
11fps
Display: 36312
11fps
Display: 1661
388fps
Display: 57477
16fps
Display: 50891
9fps
Display: 8979
94fps
Display: 9000
14fps
Display: 3967
53fps
Display: 61478
16fps
Display: 57759
16fps
Display: 49832
18fps
Display: 55554
17fps
Display: 63664
As you can see, there is a few cycles that displayed very fast.
I tried vsync, framerate limit...
Here is the code for window displaying:
void renderUI() {
LayoutGenerator layoutGenerator(this);
layoutGenerator.generateLayout(_rootElement, Vector2f(0, 0), Vector2f((float)_window->getSize().x, (float)_window->getSize().y));
_window->draw(layoutGenerator.getVertexArray()->getBuffer(), layoutGenerator.getVertexArray()->getSize(), sf::Triangles);
_window->display();
}
Edit:
And the slowness is worse when maximized to 1920*1080, 90% of the cycles take over 100ms to do window display, while 5-10% is less than 2ms
Data above is on 800*600
And window.clear does not solve it, I don't think I need it anyways
Update:
The context settings was ContextSettings(0, 0, 4, 0, 4, 0, false); (anti-aliasing level 4)
And turn it down to 0(no aa)@800*600 made it go 30fps on average (30ms window.display time)
full screen 1920*1080 with no aa is still 100ms+
Although without aa 800*600 feels much smoother (mainly because of less stutter, not faster framerates), but still really bad. How can I fix it? I already turned off multi threading on my graphics driver.