0

I am drawing quad and attaching texture where my finger touches in screen. the texture i am using is same. but after some time of finger touch FPS goes down to 5 to 10. If I debug

enter image description here

We can see in the image the setFragmentTexture Command going every-time. The same thing repeating.

How can optimize so that I can use the texture optimize way. Only once I need to send the Texture to the GPU and use that Texture in future

Ruban4Axis
  • 821
  • 6
  • 27
  • A call to `setFragmentTexture` does not necessarily mean the fragment is downloaded to the GPU every time. It's just setting a reference in a table. The redundant calls do take a bit of CPU time, but it's far from clear that it's the cause of your low frame rate. If you don't want to make so many redundant calls to `setFragmentTexture`, well, just don't. It's your code which is doing that, so change your code to not do that. You only need to set textures when a) you want to work with different textures, or b) when you create a new command encoder. – Ken Thomases Aug 06 '18 at 14:53
  • How can i avoid that ? For an example if i draw 10 squares do I need to provide this every time commandEncoder.setRenderPipelineState(renderPipelineState!) commandEncoder.setVertexBuffer(vertexBuffer, offset: 0, index: 0) commandEncoder.setVertexBuffer(indexBuffer, offset: 0, index: 1) commandEncoder.setFragmentTexture(texture, index: 0) commandEncoder.setFragmentTexture(texture2, index: 1) commandEncoder.setFragmentTexture(texture3, index: 2) – Ruban4Axis Aug 07 '18 at 04:59
  • No, you don't need to do that unless the draws require different state or resources. I'm assuming you're using the same `commandEncoder` for all the draws, too. – Ken Thomases Aug 07 '18 at 15:01
  • yh I am using the same commandEncoder is It a cause for FPS drop ? – Ruban4Axis Aug 08 '18 at 01:21
  • It is good to use the same command encoder for as many draw operations as it's appropriate for. That won't cause poor frame rate. In general, you should try to avoid all redundant work. Creating multiple command encoders when one will suffice is redundant work. Of course, when you have a good reason to create another command encoder, don't hesitate to do that. For example, when you need to render to a different texture (color attachment). – Ken Thomases Aug 08 '18 at 03:40

0 Answers0