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

Author Topic: Drawing large triangles/sprites is slow | Possible bug?  (Read 3828 times)

0 Members and 1 Guest are viewing this topic.

Paschka

  • Newbie
  • *
  • Posts: 4
    • View Profile
Drawing large triangles/sprites is slow | Possible bug?
« on: December 19, 2016, 04:44:22 am »
Hello,

drawing large triangles or sprites seems to be unreasonably slow for me. My minimum test case draws 10 triangles with a size of 800x800 at 200 FPS. However, I can draw about 500 triangles with a size of 100x100 before I get down to roughly the same frame rate.

My specs:
Intel Core i5-5200U 2.2 GHz
Intel HD Graphics 5500
4 GB RAM
Ubuntu 16.10

Testcase below. I omitted "displayFPS()" for readability.
(click to show/hide)

Edit: Renamed "circlecount" to "count"
« Last Edit: December 19, 2016, 05:10:14 pm by Paschka »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Drawing large triangles/sprites is slow | Possible bug?
« Reply #1 on: December 19, 2016, 09:15:59 am »
Intel GPUs are known to not be very performant compared to dedicated GPUs.
Wgat driver are you using?

As for the code, you're totally missing the point of a vertex array. They exist to batch draw primitives and not to draw single triangles.

And finally 200 FPS is still quite high. Remember that FPS is non-linear, this means that the FPS will not go down proportionally to the number of drawn triangles.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Paschka

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Drawing large triangles/sprites is slow | Possible bug?
« Reply #2 on: December 19, 2016, 05:01:04 pm »
Intel GPUs are known to not be very performant compared to dedicated GPUs.
Wgat driver are you using?

I used the Intel Graphics Installer to get (presumably) the right one.

Quote from: eXpl0it3r
As for the code, you're totally missing the point of a vertex array. They exist to batch draw primitives and not to draw single triangles.

Yes, but isn't the point of vertex arrays to reduce the number of draw calls? I merely used 10 for the large triangles. Drawing these 10 triangles at once wouldn't really make a difference, would it?

Quote from: eXpl0it3r
And finally 200 FPS is still quite high. Remember that FPS is non-linear, this means that the FPS will not go down proportionally to the number of drawn triangles.

I didn't know about the non-linearity, thank you. But still, I'm not complaining about the overall loss of FPS.
Running the same test with 100 large triangles and then with 5000 small triangles both results in about 30 FPS.
Grouped together in a large vertex array, I can use 200 large triangles or 10000 small triangles to get the same result.

I'm rather complaining about the relative loss since I could draw 50 times more triangles when they were smaller.
Is this normal behaviour? Does that mean that I have to split large triangles into smaller ones?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Drawing large triangles/sprites is slow | Possible bug?
« Reply #3 on: December 19, 2016, 05:21:29 pm »
Yes, but isn't the point of vertex arrays to reduce the number of draw calls? I merely used 10 for the large triangles. Drawing these 10 triangles at once wouldn't really make a difference, would it?
The point of vertex arrays is to reduce draw calls and since draw calls are relatively slow/expensive batching vertices together can perform better. However there shouldn't be that big of a difference for 10 draw calls.

I'm rather complaining about the relative loss since I could draw 50 times more triangles when they were smaller.
Is this normal behaviour? Does that mean that I have to split large triangles into smaller ones?
There are different computations to be done, so it can very well yield different results, but generally even a Intel GPU should be able to handle a good amount of draw calls.

So if you run some other simple OpenGL games, do they run fine? What driver version did that installer install exactly? If you get some OpenGL testing tool, what OpenGL version does it say is supported and what else does it report?

Do you see a lot of difference if you run it in release mode? Might want to get a profiler and figure out where the bottleneck is.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Paschka

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Drawing large triangles/sprites is slow | Possible bug?
« Reply #4 on: December 19, 2016, 09:17:45 pm »
So if you run some other simple OpenGL games, do they run fine?
Well, my  Intel GPU is indeed a little slow but Trine runs in windowed mode with 1280x800 at around 20 FPS.

What driver version did that installer install exactly?
i915 4.4.0-53-generic

If you get some OpenGL testing tool, what OpenGL version does it say is supported and what else does it report?
glmark2 runs in "OpenGL 3.0 Mesa 13.1.0-devel". A quick look in glxinfo confirms this (there is no version 4.*).
Besides, my glmark2 score is 526 and most glmark2 tests run at 200-500 FPS.

Do you see a lot of difference if you run it in release mode?
Nope. No difference with fullscreen and deactivated V-Sync either.

Might want to get a profiler and figure out where the bottleneck is.
Any suggestions what to use or how to do that?

Chaia*

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Drawing large triangles/sprites is slow | Possible bug?
« Reply #5 on: December 29, 2016, 12:33:59 am »
Maybe you are just Fillrate-limited.

Number of pixels your graphics card has to draw:
With 10 large triangles: 10x800x800/2 = 3.2 Megapixel
With 500 small triangles: 500x100x100/2 = 2.5 Megapixel

So actually in terms of fillrate, 500 of your small triangles are even faster than 10 of your large ones. But with 500 triangles you get more overhead (draw calls) and more load on the rasterizer etc. In the end you get about the same performance.

I don't know if this is the reason for your observed behaviour but for me it seems plausible.

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Drawing large triangles/sprites is slow | Possible bug?
« Reply #6 on: December 29, 2016, 08:32:22 pm »
Maybe you are just Fillrate-limited.

Number of pixels your graphics card has to draw:
With 10 large triangles: 10x800x800/2 = 3.2 Megapixel
With 500 small triangles: 500x100x100/2 = 2.5 Megapixel

So actually in terms of fillrate, 500 of your small triangles are even faster than 10 of your large ones. But with 500 triangles you get more overhead (draw calls) and more load on the rasterizer etc. In the end you get about the same performance.

I don't know if this is the reason for your observed behaviour but for me it seems plausible.

I couldn't have said it better. :D
I would like a spanish/latin community...
Problems building for Android? Look here

Paschka

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Drawing large triangles/sprites is slow | Possible bug?
« Reply #7 on: January 04, 2017, 11:42:45 pm »
Maybe you are just Fillrate-limited.

Number of pixels your graphics card has to draw:
With 10 large triangles: 10x800x800/2 = 3.2 Megapixel
With 500 small triangles: 500x100x100/2 = 2.5 Megapixel

So actually in terms of fillrate, 500 of your small triangles are even faster than 10 of your large ones. But with 500 triangles you get more overhead (draw calls) and more load on the rasterizer etc. In the end you get about the same performance.

I don't know if this is the reason for your observed behaviour but for me it seems plausible.

Then there wouldn't be much I could do, I guess. Thanks, anyway.