- No parent.
- Manually marked as frame referenced in
StartFrameCapture.
- No parent.
- Not marked as frame referenced.
- Parent is set as
MTLLibary. - Not marked as frame referenced.
- No parent.
- Marked as frame referenced during active capture when a child
MTLCommandBuffercallscommitAPI.
- No parent (logical parent is
MTLCommandQueue, this is not set asMTLCommandQueueis manually marked as frame referenced by its childMTLCommandBuffer). - Manually added to capture, stored in a list when
commitis called during active capture.
- Any
MTLFunction(s) referenced by its descriptor are set as parents in creation APIs ie.MTLDevice::newRenderPipelineStateWithDescriptor. - Marked as frame referenced during active capture by APIs which use it ie.
MTLRenderCommandEncoder::setRenderPipelineState.
- No parent.
- Not marked as frame referenced.
- Its creation and API chunks are added to its parent
MTLCommandBufferrecord.
- No parent.
- Marked as frame referenced during capture by APIs which use it ie.
MTLCommandBuffer::renderCommandEncoderWithDescriptor,MTLRenderCommandEncoder::setFragmentTexture.
- INCOMPLETE: describe marking dirty.
- No parent.
- Marked as frame referenced during capture by APIs which use it ie.
MTLCommandBuffer::renderCommandEncoderWithDescriptor,MTLRenderCommandEncoder::setVertexBuffer,MTLRenderCommandEncoder::setFragmentBuffer. - INCOMPLETE: describe marking dirty.
- Is it worth tracking precise global resource usage tied to the active capture frame ie.
MTLCommandQueue,MTLLibrary,MTLFunction,MTLRenderPipelineState.- For basic usage, this is possible, however, expect it is not viable to achieve this for all scenarios and possible usage.
- NOT ANSWERED
- The primary rationale for the Permanent resource type is that it is invalid to call the resource creation of these types multiple times.
- Perhaps the correct approach is to handle it on the replay side and filter these chunks out of the per-frame replayed chunks?
- NOT ANSWERED
- The ultimate goal is for a Permanent Resource created during the active capture frame then its creation chunk(s) appear before the
Frame Section. Is this goal realistic and achievable?- NOT ANSWERED
- Should
AddParentonly be used when resource A creates resource B? Is it valid to useAddParentif resource A only contains references to resource B (and resource B might be referenced by other resources)?- Note: using
AddParentto describe resource A references resource B is working. - NOT ANSWERED
- Note: using
- NONE
- Do not add
MTLCommandQueueas a parent ofMTLCommandBuffer(it is added as a parent and marked as frame referenced).- Capture output is correct and the
MTLCommandQueuecreation chunk is in theInitialisation Section.
- Capture output is correct and the
- Check a capture when the application creates the Permanent Resources in the same frame as using them, then the resource creation chunks are output before the
Frame Section.- Works for
MTLCommandQueue,MTLRenderPipelineState,MTLLibrary,MTLFunction.
- Works for
- Solve the problem without using custom code for Permanent Resources and instead use the existing resource manager and record APIs
- In
MTLDevice::newRenderPipelineStateadd the vertex and fragment functions as parents of theMTLRenderPipelineStateresource. - In
MTLCommandBuffer::commitin an active capture frame mark the parentMTLCommandQueueas frame referenced. - In
MTLRenderCommandEncoder::setRenderPipelineStatein an active capture frame mark theMTLRenderPipelineStateas frame referenced. - Doing these changes results in the Permanent Resource chunks being output in the desired place in the capture file ie. before
Frame Section.
- In
- Add PermanentResource array to the wrapped device and then in
EndFrameCapturemark these resources as FrameReferenced- In
MTLDevice::newRenderPipelineStateadd the referencedMTLFunctionas a permananent resource - In
MTLRenderCommandEncoder::setRenderPipelineStateadd theMTLRenderPipelineStateas a permanent resource - Note: this is not precise tracking, the
MTLRenderPipelineStateis not marked as referenced when its command buffer is committed. The resource might not be required. - This should not be required as the resource manager has the systems in place to solve this.
- In
- Debug why marking resources as frame referenced during
EndFrameCapturemakes the chunks get output before theFrame Section- They get added to
m_FrameReferencedResourceswhich are output byInsertReferencedChunkswhich is before theFrame Sectionoutput.
- They get added to
- Comment out all marking of resources as referenced. Mark
MTLFunctionas referenced whenMTLRenderPipelineStateis created: see if this marking also brings theMTLLibrarycreation chunk via the parent relationship.- Created does not work, no connection to the command buffer record, no
MTLFunctionorMTLLibrarychunks output. - Marking
MTLRenderPipelineStateas frame referenced duringsetandMTLFunctionas frame referenced during creation does not work forMTLFunctiononly theMTLRenderPipelineStatecreation chunks are output. - For
MTLCommandBuffermarkingMTLCommandQueueas the parent, then when theMTLCommandBufferchunks are output theMTLCommandQueuecreation records are also output.
- Created does not work, no connection to the command buffer record, no
- INVALID Mark resources referenced by
MTLRenderPipelineStateduringsetRenderPipelineStatebut only during active capture.- Can't extract from
MTLRenderPipelineState, only the descriptor has the resource references ie.MTLFunction. - The tracking would need to be done when
MTLRenderPipelineStateis created.
- Can't extract from
- INVALID In
EndFrameCapturefollow resource references from the trackedMTLCommandBuffer's toMTLRenderCommandEncoderand thenMTLFunctionand possiblyMTLLibrary- Can't extract from
MTLRenderPipelineState, only the descriptor has the resource references ie.MTLFunction. - The tracking would need to be done when
setRenderPipelineStateis created.
- Can't extract from
- Is Metal-specific capture code required to achieve the goals of Permanent Resources (should never be recreated) ie.
MTLCommandQueue,MTLLibrary,MTLFunction,MTLRenderPipelineStateetc.- Need to complete the active frame to identify any resources used or created during the capture.
- Adding code in
EndFrameCaptureto manually mark these resources appears to be working. It needs to be done before the capture state transitions back toBackgroundCapturing.
MTLLibrarycreates and is set as parent ofMTLFunctionMTLFunctionis referenced byMTLRenderPipelineStateresourceMTLRenderPipelineStateis referenced byMTLRenderCommandEncoderAPIMTLCommandQueuecreatesMTLRenderCommandEncoder(parent is not set).- Resources can have multiple parents.
MTLDeviceMTLLibraryMTLFunctionMTLCommandQueueMTLCommandBufferMTLRenderPipelineStateMTLTextureMTLBufferMTLRenderCommandEncoder
- Parent/child relationships.
- For all captures (including first frame captures), irrespective of when the resource is created, which section of the capture file the resource creation chunk is expected to be in:
Initialisation Section(before chunkInternal::List of Initial Contents Resources).Frame Section(after chunkInternal::Beginning of Capture)
- If it should be listed in the initial contents resources chunk
Internal::List of Initial Contents Resources. - When and how it should be marked as frame referenced.
- Immutable or Mutable after it is created.
- Type of Resource: Permanent (should never be recreated), Transitory.
- Notes.
- Has no parents, in theory, is the ultimate parent of all resources.
- Present in
Initialisation Section. - Not listed in the initial contents chunk.
- Manually marked as frame referenced in
StartFrameCapture. - Immutable, serialized content doesn't change after creation.
- Permanent Resource.
- ID is serialized in chunk
MTLCreateSystemDefaultDevice.
- Logical parent is
MTLDevice, not set in practice. - Present in
Initialisation Section. - Not listed in the initial contents chunk.
- Not marked as frame referenced.
- Immutable, serialized content doesn't change after creation.
- Permanent Resource.
- Parent is set as
MTLLibary. - Present in
Initialisation Section. - Not listed in the initial contents chunk.
- Not marked as frame referenced.
- Immutable, serialized content doesn't change after creation.
- Permanent Resource.
- Set as a parent of
MTLRenderPipelineStateinMTLDevice::newRenderPipelineState.
- Logical parent is
MTLDevice, not set in practice. - Present in
Initialisation Section. - Not listed in the initial contents chunk.
- Marked as frame referenced during active capture when a child
MTLCommandBuffercallscommitAPI. - Immutable, serialized content doesn't change after creation.
- Permanent Resource.
- Parent is set as
MTLCommandQueue. - Present in
Frame Section. - Not listed in the initial contents chunk.
- Manually added to capture, stored in a list when
commitis called during active capture. - Mutable.
- Transitory Resource
- Logical parent is
MTLDevice, not set in practice. TheMTLFunction(s) referenced by its descriptor are set as parents. - Present in
Initialisation Section. - Not listed in the initial contents chunk.
- Marked as frame referenced during active capture by APIs which use it ie.
MTLRenderCommandEncoder::setRenderPipelineState. - Immutable, serialized content doesn't change after creation.
- Permanent Resource.
- Logical parent is
MTLDevice, not set in practice. - Present in
Initialisation Section. - Listed in the initial contents chunk.
- Marked as frame referenced during capture by APIs which use it ie.
MTLCommandBuffer::renderCommandEncoderWithDescriptor,MTLRenderCommandEncoder::setFragmentTexture. - Mutable.
- Permanent Resource.
- Logical parent is
MTLDevice, not set in practice. - Present in
Initialisation Section. - Listed in the initial contents chunk.
- Marked as frame referenced during capture by APIs which use it ie.
MTLCommandBuffer::renderCommandEncoderWithDescriptor,MTLRenderCommandEncoder::setVertexBuffer,MTLRenderCommandEncoder::setFragmentBuffer. - Mutable.
- Permanent Resource.
- Logical parent is
MTLCommandBuffer, not set in practice. - Present in
Frame Section. - Not listed in the initial contents chunk.
- Not marked as frame referenced.
- Mutable.
- Transitory Resource.
- Its creation and API chunks are added to its parent
MTLCommandBufferrecord.