@@ -28,12 +28,12 @@ class COpenGLQueryPool final : public IQueryPool
28
28
{
29
29
if (_params.queryType == EQT_OCCLUSION)
30
30
{
31
- queries.resize (params .queryCount );
31
+ queries.resize (_params .queryCount );
32
32
gl->extGlCreateQueries (GL_SAMPLES_PASSED, _params.queryCount , queries.data ());
33
33
}
34
34
else if (_params.queryType == EQT_TIMESTAMP)
35
35
{
36
- queries.resize (params .queryCount );
36
+ queries.resize (_params .queryCount );
37
37
gl->extGlCreateQueries (GL_TIMESTAMP, _params.queryCount , queries.data ());
38
38
}
39
39
else if (_params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
@@ -42,9 +42,9 @@ class COpenGLQueryPool final : public IQueryPool
42
42
// The first integer is the number of primitives successfully written to the corresponding transform feedback buffer
43
43
// and the second is the number of primitives output to the vertex stream.
44
44
// But in OpenGL there you need twice the queries to get both values.
45
- queries.resize (params .queryCount * 2 );
45
+ queries.resize (_params .queryCount * 2 );
46
46
gl->extGlCreateQueries (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, _params.queryCount , queries.data ());
47
- gl->extGlCreateQueries (GL_PRIMITIVES_GENERATED, _params.queryCount , queries.data () + params .queryCount );
47
+ gl->extGlCreateQueries (GL_PRIMITIVES_GENERATED, _params.queryCount , queries.data () + _params .queryCount );
48
48
}
49
49
else
50
50
{
@@ -57,18 +57,6 @@ class COpenGLQueryPool final : public IQueryPool
57
57
return core::SRange<const GLuint>(queries.data (), queries.data () + queries.size ());
58
58
}
59
59
60
- inline GLuint getQueryAt (uint32_t index) const
61
- {
62
- if (index < queries.size ())
63
- {
64
- return queries[index];
65
- }
66
- else
67
- {
68
- return 0 ; // is 0 an invalid GLuint?
69
- }
70
- }
71
-
72
60
inline void beginQuery (IOpenGL_FunctionTable* gl, uint32_t queryIndex, E_QUERY_CONTROL_FLAGS flags) const
73
61
{
74
62
if (gl != nullptr )
@@ -174,6 +162,59 @@ class COpenGLQueryPool final : public IQueryPool
174
162
}
175
163
}
176
164
}
165
+
166
+ inline bool resetQueries (IOpenGL_FunctionTable* gl, uint32_t query, uint32_t queryCount)
167
+ {
168
+ // NOTE: There is no Reset Queries on OpenGL but to make the queries invalid/unavailable and not return the previous ones we just delete the queries and recreate them.
169
+ // TODO: Needs test
170
+ size_t logicalQuerySize = 0ull ;
171
+ if (params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
172
+ logicalQuerySize = queries.size () / 2ull ;
173
+ else
174
+ logicalQuerySize = queries.size ();
175
+
176
+ if (query + queryCount > logicalQuerySize)
177
+ {
178
+ assert (false );
179
+ return false ;
180
+ }
181
+
182
+ if (params.queryType == EQT_OCCLUSION)
183
+ {
184
+ gl->glQuery .pglDeleteQueries (queryCount, queries.data () + query);
185
+ gl->extGlCreateQueries (GL_SAMPLES_PASSED, queryCount, queries.data () + query);
186
+ }
187
+ else if (params.queryType == EQT_TIMESTAMP)
188
+ {
189
+ gl->glQuery .pglDeleteQueries (queryCount, queries.data () + query);
190
+ gl->extGlCreateQueries (GL_TIMESTAMP, queryCount, queries.data () + query);
191
+ }
192
+ else if (params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
193
+ {
194
+ gl->glQuery .pglDeleteQueries (queryCount, queries.data () + query);
195
+ gl->glQuery .pglDeleteQueries (queryCount, (queries.data () + logicalQuerySize) + query);
196
+ gl->extGlCreateQueries (GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queryCount, queries.data () + query);
197
+ gl->extGlCreateQueries (GL_PRIMITIVES_GENERATED, queryCount, (queries.data () + logicalQuerySize) + query );
198
+ }
199
+
200
+ return true ;
201
+ }
202
+
203
+ protected:
204
+
205
+ inline GLuint getQueryAt (uint32_t index) const
206
+ {
207
+ if (index < queries.size ())
208
+ {
209
+ return queries[index];
210
+ }
211
+ else
212
+ {
213
+ assert (false );
214
+ return 0u ; // is 0 an invalid GLuint?
215
+ }
216
+ }
217
+
177
218
};
178
219
179
220
} // end namespace nbl::video
0 commit comments