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

Author Topic: Performance implications of global scale  (Read 2112 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Performance implications of global scale
« on: October 20, 2013, 02:25:38 am »
What I basically want is scale entire world by 1.f/32.f(so a 64x64 rect is now 2x2, position 32,32 is now 1,1 etc.) and use same view zoom to compensate so everything looks same, are there any negative performance implications coming from OpenGL from this?
I imagine not because it's doing same operations as it would with normal sizes and scales but I want to make sure. :P
« Last Edit: October 20, 2013, 02:32:20 am by FRex »
Back to C++ gamedev with SFML in May 2023

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Performance implications of global scale
« Reply #1 on: October 20, 2013, 03:02:37 am »
Just a guess, but a quick look at the source code implies that setting the view does little more than set the projection matrix, which is such a core component of the 3D rendering pipeline (assuming this tutorial isn't misleading me) that it's probably a non-issue.

Hopefully I'm at least close.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
AW: Performance implications of global scale
« Reply #2 on: October 20, 2013, 08:02:08 am »
Keep in mind though, that you can get visual "artefacts", due to OpenGL's rasterization.
So a 64*64 square might not always turn into a 2*2 square. ;)

Regarding performance it shouldn't have a big impact.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Performance implications of global scale
« Reply #3 on: October 20, 2013, 11:48:55 am »
Wouldn't that depend on if SFML internally sets the textures to use mipmaps? Btw., does it?
« Last Edit: October 20, 2013, 11:50:51 am by wintertime »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Performance implications of global scale
« Reply #4 on: October 20, 2013, 11:59:47 am »
Hmm, I don't see any of the mipmap-related OpenGL functions/constants in the SFML source, plus I see this comment in the opengl example:
Quote
    // Load an OpenGL texture.
    // We could directly use a sf::Texture as an OpenGL texture (with its Bind() member function),
    // but here we want more control on it (generate mipmaps, ...) so we create a new one from an image

So I think it's safe to assume SFML doesn't auto-mipmap stuff for you.  Of course, SFML is intended for 2D graphics, so I don't think auto-mipmapping would benefit anyone anyway.

Regarding your main question: tl;dr no it's more complicated than that.

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Performance implications of global scale
« Reply #5 on: October 20, 2013, 04:32:38 pm »
If the window gets resized or the texture may be scaled down to less than 50% there should be some gain from having mipmaps even in 2D. Of course thats not very often and ideally the image files should be generated at compile time from the source images at the most appropriate size, which means people can live without mipmaps.
I also fear that activating GL_GENERATE_MIPMAP or using glGenerateMipmap would result in gamma-incorrect mipmaps.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Performance implications of global scale
« Reply #6 on: October 20, 2013, 11:53:39 pm »
Feel free to experiment with it yourself.  If you manage to get any significant performance/fidelity gains with a non-contrived example maybe we can consider adding sf::Texture::generateMipmaps().

Personally I'm still busy with X11 icons.