Open billhollings opened 3 years ago
I performed some further analysis and experimentation. Additional requirements:
_needsVisibilityResultMTLBuffer
is set in any of the secondary command buffers.MVKCommandEncoder:: _needsVisibilityResultMTLBuffer
status set by encoding of MVKBeginRenderpassand
MVKNextSubpass`.MVKCommandEncoder:: _needsVisibilityResultMTLBuffer
status used in beginMetalRenderPass()
to determine whether visibility buffer should be used.MVKCommandEncoder:: _needsVisibilityResultMTLBuffer
.Since a full solution appears to be necessarily complex, and the benefits of the improvement are unclear (assumed to be some type of undefined performance improvement), at this point, further work on this is being left until a definite need arises.
The current logic around deciding whether a visibility buffer is needed is relatively crude. Currently, it is applied to all render passes in a Vulkan command buffer based on at least one occlusion query being present. A Metal renderpass needs a visibility buffer if a query is started either before it or inside it. For a command buffer with multiple Metal render passes, not all of them may need it.
Recommended logic:
MVKCmdBeginRenderPass
andMVKCmdNextSubpass
.MVKCommandBuffer
track whenMVKCmdBeginRenderPass
orMVKCmdNextSubpass
added and set it's_needsVisibilityResultMTLBuffer
fromMVKCommandBuffer:: _isOcclusionQueryOpen
.MVKCmdBeginQuery
setsMVKCommandBuffer::_isOcclusionQueryOpen
and if aMVKCmdBeginRenderPass
orMVKCmdNextSubpass
is open, set its_needsVisibilityResultMTLBuffer
too.MVKCmdEndQuery
setsMVKCommandBuffer:: _isOcclusionQueryOpen
to false.MVKCmdEndRenderPass
clears open render/sub pass inMVKCommandBuffer
.