Metal: Fix for not submitting command buffers in order First I added a check that CommandBuffers are committed in order as the design requires that they are. This showed several tests asserting including the angle end2end test, OcclusionQueriesNoSurfaceTestES3.SwitchingContextsWithQuery/ES3_Metal and also several others. The check is cheap and helps catch bugs so it seems prudent to have it. Unfortunately, AFAICT, there is no trival fix. The issue is ContextMtl::flushCommandBuffer commits the outstanding commandbuffers but then, if there is/was a query in progress, more work needs to be done. That work calls ContextMtl::getBlitCommandEncoder which calls ContextMtl::ensureCommandBufferReady which calls ProvokingVertexHelper::ensureCommandBufferReady which ends up making a new command buffer. That command buffer should be committed before switching to a new context but the code that would commit it has already executed. It's not at all clear to me how to refactor the code to do this correctly. The simplest solution is to call ContextMlt::flushCommandBuffer twice which I know is gross but at least it fixes the bug and optimizing and/or refactoring can be done separately. Bug: angleproject:7131 Change-Id: Idb11efb35f6ad2fd890a5db15d3791c07586bf34 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3553939 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>