English 中文(简体)
Flickering while Making a CALayer ->MTLTexture, through CARenderer on background thread
原标题:Flickering while rendering a CALayer -> MTLTexture, via CARenderer on background thread

I m trying to render a layer tree, via CARenderer, ideally on a background thread. I m seeing flicking when I run the render method on a non-main thread (see renderLayerToMTLTexture). If I run on a main thread its better but there is still flicker, just much less.

enter image description here

For video, see: https://www.dropbox.com/s/7uhg7nyjde3h1rt/Purple%20flicker%20of%20doom.mov?dl=0

  • note: the background is being cleared to pink to make it more obvious.

The code producing the texture: https://gist.github.com/scornflake/0f42841e377e99440910c43f7424f0a5

The context is that events are being generated (throttled to 60fps), requesting render to texture for a given layer (that layer being a composition of other layers). These textures are either painted to the screen (in preview mode) or sent to a video writer (to create a movie).

Flicking occurs both on screen & in the movie. Thus I am so far presuming that the flickering is not a result of my texture preview MTKView, but rather a problem in my CALayerToMetalRenderer.

我迄今所尝试的是:

  • double/tripple buffering (helps a bit, but problem still there even with tripple buffers)
  • doing a blit to synchronize on the texture resource (seems to have no effect at all)
  • creating the texture with a storageMode of .private - since I never need the texture available to the CPU. In doing this I have to remove the synchronization blit, I m guessing because the texture is now no longer CPU accessible thus sync is invalid.
  • passing my own MTLCommandQueue queue to CARenderer (options, in constructor), to see if manually synchronizing on the texture resources works. No change.

我没有一位金属专家,但像最初的指挥(以明确案文)一样,它向我投了feels,但安放人有时不是/或有时是晚? (es, grasp at grraws here a bit)

任何想法?

问题回答

暂无回答




相关问题
How to distort a Sprite into a trapezoid?

I am trying to transform a Sprite into a trapezoid, I don t really care about the interpolation even though I know without it my image will lose detail. All I really want to do is Transform my ...

Heeelp! Debugger says "out of scope"!

I just cannot imagine what the hell the problem could be. I made a pretty app, and decided to use only CALayers to "render". When I saw that the changes in the position property gets animated, ...

Need help to make my iPhone animation work?

I m brand new in iPhone animation feature. I wrote a simple testing program to spin a red rectangle; however, the animation doesn t act at all. What s wrong with my code? Thanks a lot... //.h #import ...

NSViewController. Core Animation sublayer not drawing

I create NSViewController. It manage my view hierarchy and set other views in one NSBox. - (void)displayViewController:(ManagingViewController *)vc { NSWindow *w = [box window]; NSView *v = [vc view];...

Fast User Switching Hides CALayer

I have an GUI cocoa application that is automatically started when the computer is woken from sleep. The application runs in multiple users accounts at the same time and is sometime launched in a user ...

Using CALayer Delegate

I have a UIView whose layers will have sublayers. I d like to assign delegates for each of those sublayers, so the delegate method can tell the layer what to draw. My question is: What should I ...

Is CALayer insertSublayer: atindex: destructive?

The documentation is not clear on what happens the the layer currently atindex:xy when using insertSublayer:abc.layer atindex:xy. My experimentation has had mixed results. My understanding is index 0 ...

热门标签