Overte C++ Documentation
VKQuery.h
1 //
2 // Created by Bradley Austin Davis on 2016/08/07
3 // Copyright 2013-2018 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 #ifndef hifi_gpu_vk_VKQuery_h
9 #define hifi_gpu_vk_VKQuery_h
10 
11 #include "VKShared.h"
12 #include "VKBackend.h"
13 
14 namespace gpu { namespace vk {
15 
16 class VKQuery : public VKObject<Query> {
17  using Parent = gpu::vk::VKObject<Query>;
18 public:
19  static VKQuery* sync(VKBackend& backend, const Query& query) {
20  VKQuery* object = Backend::getGPUObject<VKQuery>(query);
21 
22  // need to have a gpu object?
23  if (!object) {
24  // All is green, assign the gpuobject to the Query
25  object = new VKQuery(backend.shared_from_this(), query);
26  Backend::setGPUObject(query, object);
27  backend._queries.insert(object);
28  }
29 
30  return object;
31  }
32 
33  template <typename VKQueryType>
34  static uint32_t getId(VKBackend& backend, const QueryPointer& query) {
35  // VKTODO Vulkan handle is used instead
36  return 0;
37  if (!query) {
38  return 0;
39  }
40 
41  /*VKQuery* object = sync<VKQueryType>(backend, *query);
42  if (!object) {
43  return 0;
44  }
45 
46  return object->_endqo;*/
47  }
48 
49  // VKTODO Vulkan handle is used instead
50  /*const uint32_t& _endqo = { _id };
51  const uint32_t _beginqo = { 0 };
52  uint64_t _result { (uint64_t)-1 };*/
53 
54 protected:
55  // VKTODO: We need a check on backend.lock(), or to pass backend reference instead
56  VKQuery(const std::weak_ptr<VKBackend>& backend, const Query& query) : Parent(*backend.lock(), query) {}
57  ~VKQuery() {
58  auto backend = _backend.lock();
59  auto &recycler = backend->getContext().recycler;
60  recycler.queryDeleted(this);
61  // Vulkan handle is used instead
62  /*if (_id) {
63  // VKTODO
64  uint32_t ids[2] = { _endqo, _beginqo };
65  //glDeleteQueries(2, ids);
66  }*/
67  }
68 };
69 
70 } }
71 
72 #endif