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

Author Topic: sf::Texture Sizes  (Read 2870 times)

0 Members and 1 Guest are viewing this topic.

zTn

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
sf::Texture Sizes
« on: December 07, 2018, 11:46:31 pm »
I often find myself creating sf::RenderTextures that are optimized to only contain the minimally complete set of images that I need, and then compose/sort them to reduce the number of times I have to switch between them when drawing each frame.

Question:  What size should I make these optimized sf::RenderTextures?

Should I use the largest power-of-2 size supported by the hardware, or will that be slower since it will take longer to switch between them?  Would it be better to have 3 at 4096x4096 because that means fewer transitions, or is it faster to use 12 at 1024x1024 because now switching will take less time?  Or are they the same because the total amount of pixels transferred per frame is the same?

(I'm not getting a clear answer from tests on the machines I have access to.)

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: sf::Texture Sizes
« Reply #1 on: December 08, 2018, 04:25:50 pm »
Texture size is irrelevant for opengl state changes. Use the largest power-of-2 size that all the devices you are targeting can use.

zTn

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: sf::Texture Sizes
« Reply #2 on: December 08, 2018, 07:14:21 pm »
Thanks for getting back NGM88, but to clarify...

(1)  So changing which texture you are drawing with is a (relatively) expensive operation, but the size of the current and new texture has no effect on how long it takes?  (or if so, nothing significant?)

(2) Since I'm generating these textures at run-time with sf::RenderTextures, can't I just query the max supported size with sf::Texture::getMaximumSize() and use that?

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: sf::Texture Sizes
« Reply #3 on: December 09, 2018, 08:15:04 pm »
1 - True. The cost of a texture bind is fixed, it's not based on size.

2 - Should be fine as far as I know. Maybe ask a dev just in case.

 

anything