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:
42  exint sumQueries(RV_Render* r, bool wait = false);
43 
45  int myCurIdx;
47 
50 
51  RV_OcclusionQuery(RV_OcclusionResult t, bool gpu_exclusive);
52  virtual ~RV_OcclusionQuery();
53 };
54 
55 // RV_OcclusionQueryCPU
56 // Intenally uses RV_VKQuery
57 //
58 
59 /// Query to get occlusion results on the CPU -- useful for Debugging
60 /// more performant code should use the GPU version (RV_OcclusionQueryGPU)
61 /// and use conditional rendering in the command buffer
63 {
64 public:
65 
67  ~RV_OcclusionQueryCPU() override;
68 
69  /// Return true if the query has finished and the result is available
70  bool isResultAvailable(RV_Render* r);
71  /// Return true if any samples were drawn
72  bool getAnySamplesDrawn(RV_Render* r);
73  /// Return the exact number of samples drawn
74  int64 getNumSamples(RV_Render* r);
75 };
76 
77 // RV_OcclusionQueryGPU
78 // Intenally uses RV_VKQuery
79 //
80 /// Query to get occlusion results on the CPU results are written
81 /// to a buffer owned by the class instead of CPU memory.
83 {
84 public:
86  ~RV_OcclusionQueryGPU() override;
87 
88  /// Read the query results into a buffer.
89  bool getResults(
90  RV_Render* r,
92  bool wait = true);
93 
94 };
95 #if 0
96 /// A query that returns the elapsed time between begin and end in nanoseconds
97 class RV_API RV_TimerQuery
98 {
99 public:
100  RV_TimerQuery();
101 
102  /// Create the query
103  void init(RV_Render* r);
104  /// Create the query
105  void init(RV_Render* inst);
106  /// Begin the timer query
107  bool begin(RV_VKCommandBuffer *cb);
108  /// Begin end timer query
109  void end(RV_VKCommandBuffer* cb);
110 
111  /// REturn the elapsed time in nanoseconds (10^-9 seconds)
112  int64 getTimeNS();
113 
114  void writeResult(RV_VKCommandBuffer* cb, RV_VKBuffer* buf);
115 private:
116  UT_UniquePtr<RV_VKQuery> myQuery;
117 };
118 
119 #endif
120 
121 #endif
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
int64 exint
Definition: SYS_Types.h:125
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:44
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:81
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:558