Skip to content

Commit

Permalink
Bugfix: Vulkan query results are now properly retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
BearishSun committed Jul 10, 2018
1 parent 2e9448e commit df010eb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Source/Plugins/bsfVulkanRenderAPI/BsVulkanEventQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace bs { namespace ct
~VulkanEventQuery();

/** @copydoc EventQuery::begin */
void begin(const SPtr<CommandBuffer>& cb = nullptr) override;
void begin(const SPtr<CommandBuffer>& cb) override;

/** @copydoc EventQuery::isReady */
bool isReady() const override;
Expand Down
4 changes: 2 additions & 2 deletions Source/Plugins/bsfVulkanRenderAPI/BsVulkanOcclusionQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace bs { namespace ct
~VulkanOcclusionQuery();

/** @copydoc OcclusionQuery::begin */
void begin(const SPtr<CommandBuffer>& cb = nullptr) override;
void begin(const SPtr<CommandBuffer>& cb) override;

/** @copydoc OcclusionQuery::end */
void end(const SPtr<CommandBuffer>& cb = nullptr) override;
void end(const SPtr<CommandBuffer>& cb) override;

/** @copydoc OcclusionQuery::isReady */
bool isReady() const override;
Expand Down
4 changes: 2 additions & 2 deletions Source/Plugins/bsfVulkanRenderAPI/BsVulkanTimerQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace bs { namespace ct
~VulkanTimerQuery();

/** @copydoc TimerQuery::begin */
void begin(const SPtr<CommandBuffer>& cb = nullptr) override;
void begin(const SPtr<CommandBuffer>& cb) override;

/** @copydoc TimerQuery::end */
void end(const SPtr<CommandBuffer>& cb = nullptr) override;
void end(const SPtr<CommandBuffer>& cb) override;

/** @copydoc TimerQuery::isReady */
bool isReady() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,12 @@ namespace bs { namespace ct
Lock lock(mMutex);

query->mFree = true;
query->mNeedsReset = true;
}

VulkanQueryManager::VulkanQueryManager(VulkanRenderAPI& rapi)
:mRenderAPI(rapi)
{ }

VulkanQueryManager::~VulkanQueryManager()
{

}

SPtr<EventQuery> VulkanQueryManager::createEventQuery(UINT32 deviceIdx) const
{
SPtr<VulkanDevice> device = mRenderAPI._getDevice(deviceIdx);
Expand Down Expand Up @@ -193,7 +187,7 @@ namespace bs { namespace ct
}

VulkanQuery::VulkanQuery(VulkanResourceManager* owner, VkQueryPool pool, UINT32 queryIdx)
:VulkanResource(owner, false), mPool(pool), mQueryIdx(queryIdx), mFree(true)
:VulkanResource(owner, false), mPool(pool), mQueryIdx(queryIdx)
{
}

Expand All @@ -204,7 +198,7 @@ namespace bs { namespace ct
// in the pool at once.

VkDevice vkDevice = mOwner->getDevice().getLogical();
VkResult vkResult = vkGetQueryPoolResults(vkDevice, mPool, 0, 1, sizeof(result), &result, sizeof(result),
VkResult vkResult = vkGetQueryPoolResults(vkDevice, mPool, mQueryIdx, 1, sizeof(result), &result, sizeof(result),
VK_QUERY_RESULT_64_BIT);
assert(vkResult == VK_SUCCESS || vkResult == VK_NOT_READY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ namespace bs { namespace ct
{
public:
VulkanQueryManager(VulkanRenderAPI& rapi);
~VulkanQueryManager();

/** @copydoc QueryManager::createEventQuery */
SPtr<EventQuery> createEventQuery(UINT32 deviceIdx = 0) const override;
Expand Down Expand Up @@ -125,8 +124,7 @@ namespace bs { namespace ct

VkQueryPool mPool;
UINT32 mQueryIdx;
bool mFree;
bool mNeedsReset;
bool mFree = true;
};

/** @} */
Expand Down

0 comments on commit df010eb

Please sign in to comment.