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  }
28 
29  return object;
30  }
31 
32  template <typename VKQueryType>
33  static uint32_t getId(VKBackend& backend, const QueryPointer& query) {
34  // VKTODO Vulkan handle is used instead
35  return 0;
36  if (!query) {
37  return 0;
38  }
39 
40  /*VKQuery* object = sync<VKQueryType>(backend, *query);
41  if (!object) {
42  return 0;
43  }
44 
45  return object->_endqo;*/
46  }
47 
48  // VKTODO Vulkan handle is used instead
49  /*const uint32_t& _endqo = { _id };
50  const uint32_t _beginqo = { 0 };
51  uint64_t _result { (uint64_t)-1 };*/
52 
53 protected:
54  // VKTODO: We need a check on backend.lock(), or to pass backend reference instead
55  VKQuery(const std::weak_ptr<VKBackend>& backend, const Query& query) : Parent(*backend.lock(), query) {}
56  ~VKQuery() {
57  auto backend = _backend.lock();
58  auto &recycler = backend->getContext().recycler;
59  recycler.queryDeleted(this);
60  // Vulkan handle is used instead
61  /*if (_id) {
62  // VKTODO
63  uint32_t ids[2] = { _endqo, _beginqo };
64  //glDeleteQueries(2, ids);
65  }*/
66  }
67 };
68 
69 } }
70 
71 #endif