glDrawArrays – Texture distortion

This topic contains 4 replies, has 2 voices, and was last updated by  IanES 8 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29881

    IanES
    Member

    I am loading Fonts and Images on demand as I need to display them. So while I draw the current frame I may bind a few textures and send some vertices to draw them and then have to create a texture, use glTexSubImage to update it and then use it in a draw.

    Sometimes while this is happening a few textures will become distorted (the one that was last loaded). I sometimes also see what I expect to be on the texture flash on the screen and then disappear. I have found that the only way to stop this is to remove the glDrawArrays calls that a4re used to show these dynamic textures. At that point I will still create the textures but never draw them.

    Is it possible its a timing issue and if so what should I do to make sure the new textures are not distorted?

    #33294

    Xmas
    Member

    First of all, on what platform are you seeing these problems?

    We strongly discourage using glTexSubImage to update textures mid-frame. It can be a very expensive operation if the texture has already been used in the current or previous frames. I’d recommend creating new texture objects for textures you need to load on demand, and loading them at the start of a frame, not in between draw calls.

    #33295

    IanES
    Member

    The problem is seen on Windows CE.

    The slowdown is acceptable for what I am working on but are you saying I should not do this regardless?

    #33296

    IanES
    Member

    So I moved font loading to application load and found that I no longer have any texture distortion. I cant do this with all images though because they may change on the server during application run time so I guess I just need to make sure they are loaded at frame start.

    Before making any changes, what do you consider to be ‘start of the frame’? Does that just mean before any calls to glDrawArrays or should I start the load before doing anything after the eglSwapBuffer call?

    Just wondering, my initial design should have worked, correct? Like I should be able to call texSubImage at any time and it should only be an issue that its slow and my textures should not be distorted?

    #33297

    IanES
    Member

    I believe I may have found the solution to my problem or at least a hint at where the problem lies. I load glyphs into font textures that start at 512×512. I decreased this size to 256×256 and I have stopped seeing the distortion. I’m not sure if this is just postponing the issue but so far so good.

    Would that make sense as the problem?

Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.