Posts

Post not yet marked as solved
5 Replies
910 Views
Hi,I've ran into a weird situation, on macOS, where a texture I uploaded seems to not be available for usage immediately after the calls are done to upload it are done.At first I was using what I assume is the typical way (- [id<MTLTexture> replaceRegion:mipmapLevel:withBytes:bytesPerRow:), in a secondary thread, and whenever that call was returning, I was assuming the texture would then be available for the next frame. This seemed not to be the case, quite often.After looking around a bit, I found another way to upload the texture data, which is by creating an MTLBuffer first, then blitting it onto the texture. This improves things quite a bit, as some textures are now available as I expect them to, but still others can't seem to make the cut. Being a blit operation, I would expect some dependency to be enforced, to make sure that the operation is finished before the next command encoder would try and use that texture.So, either I'm missing some synchronization - but after searching for such information, I was left under the impression that it shouldn't be necessary. Or, I'm doing something really wrong that I can't pinpoint.The trick here is that this is not a game, but an application displaying some UI overlay in Metal. Thus, I'm doing redraws only when needed, and not rendering continuously (which means the problems would be solved at some point, after rendering a few frames). I am already detecting when a texture is not yet fully created and uploaded (as far as I know, from either the replaceRegion: call returning, or the blit command having been committed), and redrawing if a frame was missing some, but even that seems to not be enough.Any help appreciated here!
Posted
by ltkettch.
Last updated
.