From bbe45e4a8abfbdc4e85e06c2f9b5302279265e73 Mon Sep 17 00:00:00 2001 From: Chip Davis Date: Fri, 25 Sep 2020 15:22:40 -0500 Subject: [PATCH] MVKQueryPool: Fix ending a query outside a render pass. I missed this when I fixed occlusion queries begun outside a render pass. --- MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h | 3 +++ MoltenVK/MoltenVK/GPUObjects/MVKQueryPool.mm | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h index 9002d59e..322b19c2 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h +++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h @@ -290,6 +290,9 @@ public: /** If a render encoder is active, encodes store actions for all attachments to it. */ void encodeStoreActions(bool storeOverride = false); + /** Returns whether or not we are presently in a render pass. */ + bool isInRenderPass() { return _renderPass != nullptr; } + /** Returns the render subpass that is currently active. */ MVKRenderSubpass* getSubpass(); diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKQueryPool.mm b/MoltenVK/MoltenVK/GPUObjects/MVKQueryPool.mm index 68db119a..41050262 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKQueryPool.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKQueryPool.mm @@ -31,7 +31,7 @@ using namespace std; #pragma mark MVKQueryPool void MVKQueryPool::endQuery(uint32_t query, MVKCommandEncoder* cmdEncoder) { - uint32_t queryCount = cmdEncoder->getSubpass()->getViewCountInMetalPass(cmdEncoder->getMultiviewPassIndex()); + uint32_t queryCount = cmdEncoder->isInRenderPass() ? cmdEncoder->getSubpass()->getViewCountInMetalPass(cmdEncoder->getMultiviewPassIndex()) : 1; lock_guard lock(_availabilityLock); for (uint32_t i = query; i < query + queryCount; ++i) { _availability[i] = DeviceAvailable;