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

Author Topic: Do draw calls with same Texture affect performance?  (Read 428 times)

0 Members and 1 Guest are viewing this topic.

name9006

  • Newbie
  • *
  • Posts: 1
    • View Profile
Do draw calls with same Texture affect performance?
« on: May 30, 2022, 02:34:48 am »
I am trying to go about rendering in the fastest way possible because I want the highest FPS possible. I use a sf::RenderTexture to combine multiple textures into one so I can pass them to a draw call as such:

sf::VertexBuffer buffer;
sf::RenderTexture textureAtlas;

...

// if I do multiple draw calls but use the same texture, does it treat it the same as an entirely new texture?

sf::RenderStates states(&textureAtlas.getTexture());
window.draw(buffer, start1, count1, states);

std::size_t start2 = start1 + count1;
window.draw(buffer, start2, count2, states);


My question is the above comment; if I do multiple draw calls but use the same texture, does it treat it the same as an entirely new texture and texture switch? Or would it treat it the same as the statement below?


window.draw(buffer, start1, count1 + count2, states);

kojack

  • Full Member
  • ***
  • Posts: 203
    • View Profile
Re: Do draw calls with same Texture affect performance?
« Reply #1 on: May 30, 2022, 03:50:47 pm »
From what I can see in the source, draw uses a state cache. If the texture you tell it to draw with is the same as the last draw call, it doesn't rebind the texture.

Although one condition is that FBO textures will always be rebound, and I think render textures are made as FBOs (but I'm not 100% sure), so it might not help your situation.