HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_Query.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RV_Query.h ( RV Library, C++)
7  *
8  * COMMENTS:
9  * Higher level Class to handle Vulkan Queries
10  */
11 
12 #ifndef RV_Query_h
13 #define RV_Query_h
14 
15 #include "RV_API.h"
16 
17 #include <SYS/SYS_Types.h>
18 #include <UT/UT_UniquePtr.h>
19 
20 class RV_Render;
21 class RV_VKBuffer;
22 class RV_VKQuery;
23 
25 {
28 };
29 
30 /// Occlusion query object
32 {
33 public:
34  /// Initialize the query (create it)
35  void init(RV_Render* r);
36  /// Start the query
37  bool begin(RV_Render* r);
38  /// End the query
39  void end(RV_Render* r);
40 
41 protected:
45 
46  RV_OcclusionQuery(RV_OcclusionResult t, bool gpu_exclusive);
47  virtual ~RV_OcclusionQuery();
48 };
49 
50 // RV_OcclusionQueryCPU
51 // Intenally uses RV_VKQuery
52 //
53 
54 /// Query to get occlusion results on the CPU -- useful for Debugging
55 /// more performant code should use the GPU version (RV_OcclusionQueryGPU)
56 /// and use conditional rendering in the command buffer
58 {
59 public:
60 
62  ~RV_OcclusionQueryCPU() override;
63 
64  /// Return true if the query has finished and the result is available
65  bool isResultAvailable(RV_Render* r);
66  /// Return true if any samples were drawn
67  bool getAnySamplesDrawn(RV_Render* r);
68  /// Return the exact number of samples drawn
69  int64 getNumSamples(RV_Render* r);
70 };
71 
72 // RV_OcclusionQueryGPU
73 // Intenally uses RV_VKQuery
74 //
75 /// Query to get occlusion results on the CPU results are written
76 /// to a buffer owned by the class instead of CPU memory.
78 {
79 public:
81  ~RV_OcclusionQueryGPU() override;
82 
83  /// Read the query results into a buffer.
84  bool getResults(
85  RV_Render* r,
87  bool wait = true);
88 
89 };
90 #if 0
91 /// A query that returns the elapsed time between begin and end in nanoseconds
92 class RV_API RV_TimerQuery
93 {
94 public:
95  RV_TimerQuery();
96 
97  /// Create the query
98  void init(RV_Render* r);
99  /// Create the query
100  void init(RV_Render* inst);
101  /// Begin the timer query
102  bool begin(RV_VKCommandBuffer *cb);
103  /// Begin end timer query
104  void end(RV_VKCommandBuffer* cb);
105 
106  /// REturn the elapsed time in nanoseconds (10^-9 seconds)
107  int64 getTimeNS();
108 
109  void writeResult(RV_VKCommandBuffer* cb, RV_VKBuffer* buf);
110 private:
111  UT_UniquePtr<RV_VKQuery> myQuery;
112 };
113 
114 #endif
115 
116 #endif
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
UT_UniquePtr< RV_VKQuery > myQuery
Definition: RV_Query.h:42
Definition: core.h:760
Occlusion query object.
Definition: RV_Query.h:31
GLuint GLuint end
Definition: glcorearb.h:475
#define RV_API
Definition: RV_API.h:10
long long int64
Definition: SYS_Types.h:116
GLdouble t
Definition: glad.h:2397
*tasks wait()
GLboolean r
Definition: glcorearb.h:1222
A vulkan buffer object.
Definition: RV_VKBuffer.h:80
RV_OcclusionResult
Definition: RV_Query.h:24
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:483