Fix Metal validation error when occlusion query and
renderpass are in separate Vulkan command buffers.
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index 68d6acd..8bbc2a7 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -40,6 +40,8 @@
   within each descriptor set.
 - `vkCmdCopyImage` on macOS flush non-coherent image memory before copy operation.
 - Re-add support for bitcode generation on *iOS* and *tvOS*.
+- Fix Metal validation error when occlusion query and renderpass are in separate 
+  Vulkan command buffers.
 
 
 
diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdRenderPass.mm b/MoltenVK/MoltenVK/Commands/MVKCmdRenderPass.mm
index 9c76718..f89ae29 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCmdRenderPass.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCmdRenderPass.mm
@@ -118,6 +118,7 @@
 	for (uint32_t cbIdx = 0; cbIdx < commandBuffersCount; cbIdx++) {
 		_secondaryCommandBuffers.push_back(MVKCommandBuffer::getMVKCommandBuffer(pCommandBuffers[cbIdx]));
 	}
+	cmdBuff->recordExecuteCommands(_secondaryCommandBuffers.contents());
 
 	return VK_SUCCESS;
 }
diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
index 2e023e3..9002d59 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
@@ -97,6 +97,8 @@
      */
     id<MTLBuffer> _initialVisibilityResultMTLBuffer;
 
+	/** Called when a MVKCmdExecuteCommands is added to this command buffer. */
+	void recordExecuteCommands(const MVKArrayRef<MVKCommandBuffer*> secondaryCommandBuffers);
 
 #pragma mark Tessellation constituent command management
 
diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
index 8a5f516..24b65a4 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
@@ -195,6 +195,19 @@
 	reset(0);
 }
 
+// If the initial visibility result buffer has not been set, promote the first visibility result buffer
+// found among any of the secondary command buffers, to support the case where a render pass is started in
+// the primary command buffer but the visibility query is started inside one of the secondary command buffers.
+void MVKCommandBuffer::recordExecuteCommands(const MVKArrayRef<MVKCommandBuffer*> secondaryCommandBuffers) {
+	if (_initialVisibilityResultMTLBuffer == nil) {
+		for (MVKCommandBuffer* cmdBuff : secondaryCommandBuffers) {
+			if (cmdBuff->_initialVisibilityResultMTLBuffer) {
+				_initialVisibilityResultMTLBuffer = cmdBuff->_initialVisibilityResultMTLBuffer;
+				break;
+			}
+		}
+	}
+}
 
 #pragma mark -
 #pragma mark Tessellation constituent command management