summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_query_cache.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2020-03-27 05:33:21 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-04-11 03:49:02 +0200
commit2905142f47163d0f409c31910cdc234e8797286c (patch)
tree7d5bf00d6b68f58b868e64a0683afd8c09e7f971 /src/video_core/renderer_vulkan/vk_query_cache.cpp
parentMerge pull request #3594 from ReinUsesLisp/vk-instance (diff)
downloadyuzu-2905142f47163d0f409c31910cdc234e8797286c.tar
yuzu-2905142f47163d0f409c31910cdc234e8797286c.tar.gz
yuzu-2905142f47163d0f409c31910cdc234e8797286c.tar.bz2
yuzu-2905142f47163d0f409c31910cdc234e8797286c.tar.lz
yuzu-2905142f47163d0f409c31910cdc234e8797286c.tar.xz
yuzu-2905142f47163d0f409c31910cdc234e8797286c.tar.zst
yuzu-2905142f47163d0f409c31910cdc234e8797286c.zip
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_query_cache.cpp')
-rw-r--r--src/video_core/renderer_vulkan/vk_query_cache.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp
index ffbf60dda..0966c7ff7 100644
--- a/src/video_core/renderer_vulkan/vk_query_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp
@@ -8,19 +8,19 @@
#include <utility>
#include <vector>
-#include "video_core/renderer_vulkan/declarations.h"
#include "video_core/renderer_vulkan/vk_device.h"
#include "video_core/renderer_vulkan/vk_query_cache.h"
#include "video_core/renderer_vulkan/vk_resource_manager.h"
#include "video_core/renderer_vulkan/vk_scheduler.h"
+#include "video_core/renderer_vulkan/wrapper.h"
namespace Vulkan {
namespace {
-constexpr std::array QUERY_TARGETS = {vk::QueryType::eOcclusion};
+constexpr std::array QUERY_TARGETS = {VK_QUERY_TYPE_OCCLUSION};
-constexpr vk::QueryType GetTarget(VideoCore::QueryType type) {
+constexpr VkQueryType GetTarget(VideoCore::QueryType type) {
return QUERY_TARGETS[static_cast<std::size_t>(type)];
}
@@ -35,29 +35,34 @@ void QueryPool::Initialize(const VKDevice& device_, VideoCore::QueryType type_)
type = type_;
}
-std::pair<vk::QueryPool, std::uint32_t> QueryPool::Commit(VKFence& fence) {
+std::pair<VkQueryPool, u32> QueryPool::Commit(VKFence& fence) {
std::size_t index;
do {
index = CommitResource(fence);
} while (usage[index]);
usage[index] = true;
- return {*pools[index / GROW_STEP], static_cast<std::uint32_t>(index % GROW_STEP)};
+ return {*pools[index / GROW_STEP], static_cast<u32>(index % GROW_STEP)};
}
void QueryPool::Allocate(std::size_t begin, std::size_t end) {
usage.resize(end);
- const auto dev = device->GetLogical();
- const u32 size = static_cast<u32>(end - begin);
- const vk::QueryPoolCreateInfo query_pool_ci({}, GetTarget(type), size, {});
- pools.push_back(dev.createQueryPoolUnique(query_pool_ci, nullptr, device->GetDispatchLoader()));
+ VkQueryPoolCreateInfo query_pool_ci;
+ query_pool_ci.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
+ query_pool_ci.pNext = nullptr;
+ query_pool_ci.flags = 0;
+ query_pool_ci.queryType = GetTarget(type);
+ query_pool_ci.queryCount = static_cast<u32>(end - begin);
+ query_pool_ci.pipelineStatistics = 0;
+ pools.push_back(device->GetLogical().CreateQueryPool(query_pool_ci));
}
-void QueryPool::Reserve(std::pair<vk::QueryPool, std::uint32_t> query) {
+void QueryPool::Reserve(std::pair<VkQueryPool, u32> query) {
const auto it =
- std::find_if(std::begin(pools), std::end(pools),
- [query_pool = query.first](auto& pool) { return query_pool == *pool; });
+ std::find_if(pools.begin(), pools.end(), [query_pool = query.first](vk::QueryPool& pool) {
+ return query_pool == *pool;
+ });
ASSERT(it != std::end(pools));
const std::ptrdiff_t pool_index = std::distance(std::begin(pools), it);
@@ -76,12 +81,11 @@ VKQueryCache::VKQueryCache(Core::System& system, VideoCore::RasterizerInterface&
VKQueryCache::~VKQueryCache() = default;
-std::pair<vk::QueryPool, std::uint32_t> VKQueryCache::AllocateQuery(VideoCore::QueryType type) {
+std::pair<VkQueryPool, u32> VKQueryCache::AllocateQuery(VideoCore::QueryType type) {
return query_pools[static_cast<std::size_t>(type)].Commit(scheduler.GetFence());
}
-void VKQueryCache::Reserve(VideoCore::QueryType type,
- std::pair<vk::QueryPool, std::uint32_t> query) {
+void VKQueryCache::Reserve(VideoCore::QueryType type, std::pair<VkQueryPool, u32> query) {
query_pools[static_cast<std::size_t>(type)].Reserve(query);
}
@@ -89,10 +93,10 @@ HostCounter::HostCounter(VKQueryCache& cache, std::shared_ptr<HostCounter> depen
VideoCore::QueryType type)
: VideoCommon::HostCounterBase<VKQueryCache, HostCounter>{std::move(dependency)}, cache{cache},
type{type}, query{cache.AllocateQuery(type)}, ticks{cache.Scheduler().Ticks()} {
- const auto dev = cache.Device().GetLogical();
- cache.Scheduler().Record([dev, query = query](vk::CommandBuffer cmdbuf, auto& dld) {
- dev.resetQueryPoolEXT(query.first, query.second, 1, dld);
- cmdbuf.beginQuery(query.first, query.second, vk::QueryControlFlagBits::ePrecise, dld);
+ const vk::Device* logical = &cache.Device().GetLogical();
+ cache.Scheduler().Record([logical, query = query](vk::CommandBuffer cmdbuf) {
+ logical->ResetQueryPoolEXT(query.first, query.second, 1);
+ cmdbuf.BeginQuery(query.first, query.second, VK_QUERY_CONTROL_PRECISE_BIT);
});
}
@@ -101,22 +105,16 @@ HostCounter::~HostCounter() {
}
void HostCounter::EndQuery() {
- cache.Scheduler().Record([query = query](auto cmdbuf, auto& dld) {
- cmdbuf.endQuery(query.first, query.second, dld);
- });
+ cache.Scheduler().Record(
+ [query = query](vk::CommandBuffer cmdbuf) { cmdbuf.EndQuery(query.first, query.second); });
}
u64 HostCounter::BlockingQuery() const {
if (ticks >= cache.Scheduler().Ticks()) {
cache.Scheduler().Flush();
}
-
- const auto dev = cache.Device().GetLogical();
- const auto& dld = cache.Device().GetDispatchLoader();
- u64 value;
- dev.getQueryPoolResults(query.first, query.second, 1, sizeof(value), &value, sizeof(value),
- vk::QueryResultFlagBits::e64 | vk::QueryResultFlagBits::eWait, dld);
- return value;
+ return cache.Device().GetLogical().GetQueryResult<u64>(
+ query.first, query.second, VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
}
} // namespace Vulkan