Metal-cpp iOS examples/frame capture

I'm at the point where I seem to be running a very simple render loop (inside of a very complex project) and having fun trying to figure out what isn't actually functioning. It seems like the documentation online might be slightly out of date as when I try to look for a way to do a frame capture I am only presented with "Capture GPU Workload" and a little "M" icon instead of the documented "Capture GPU Frame" and a "camera" icon. My assumption is it was just renamed as it could potentially include other GPU work not directly related to rendering.

I've changed my project settings to explicitly capture Metal rather than Automatic, but that didn't really seem to change anything.

I've verified the broad strokes of my rendering which roughly matches the Mac example of drawing a simple triangle. The only significant difference is that I immediately reclaim the MTL::CommandBuffer with an autoRelease after the commit. Does that seem fine?

When I capture I am told that: "No GPU commands have been captured. At least one command buffer must be created and committed within the boundaries of a GPU Capture." Not sure if there is some sort of implicit frame tracking that I am somehow violating.

In terms of the rough order of things being done for the rendering:

  • renderCommandEncoder()
  • setRenderPipelineState()
  • drawIndexedPrimitives()
  • endEncoding()
  • presentDrawable()
  • commit()

Oops, almost forgot to mention the reason for my title which is that metal-cpp only seems to come with Mac examples. Are there any iOS examples for metal-cpp?

I'm still digging into this. Conceptually the run loop doesn't seem to be failing on anything. The very first command buffer commit yields a purple screen (not sure yet where this is coming from). I also wanted to mention that I am currently ignoring the run loop callback and instead using our normal frame cadence to do the swap. The part I'm least familiar with is definitely the code to set up the view in the first place. It is mostly straight from our Vulkan version that is using MoltenVK.

Hi scarrow,

I'm sorry to hear you are experiencing these difficulties. There are a few points to address. Let me take them in order and hopefully help uncover a solution.

  • Typically, you only release objects that have been created by method that are prefixed by alloc, new, copy, mutableCopy, or Create. Resources created by methods that do not start with any of these prefixes, such as MTL::CommandQueue::commandBuffer() do not require (and indeed you should not) manually release (or autoreleasing) them, unless you've retained them previously. The following resources provide more details about the memory management model of our platform:
  1. Memory Management Programming Guide:  https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html
  2. Our metal-cpp talk from WWDC this year includes a detailed explanation of our memory management model.
  • The "No GPU commands have been captured" message usually denotes that the tools have not received a complete command buffer (i.e. a command buffer that has been created, encoded into, and committed). If you are uncertain of whether the full command buffer is being captured, you can also try using the MTL::CaptureManager object to manually start recording before creating the command buffer and end recording after it's been committed. If the problem persists, and you can file a Feedback Assistant ticket with a reproducer, we would be happy to look at the workload. Just make sure to post the Feedback Assistant ID here.

  • Magenta in your framebuffer usually signifies that you are seeing uninitialized memory. This could be caused by a render attachment that has not been cleared (for example if it has a load action of "dont care" and that content is then presented), or if you are using untracked resources and missing one or more resource dependencies. Because you are interoperating with a 3rd party library, it's also possible that the interface between that library and Metal needs to partake in the synchronization as well.

  • Please check out the Deferred Rendering C++ sample in our Sample Code Gallery. It provides an example of how to make an iOS application with a pure C++ renderer.

Metal-cpp iOS examples/frame capture
 
 
Q