]> git.tdb.fi Git - libs/gl.git/commitdiff
Store query pool size separately, in the common part of the class
authorMikko Rasa <tdb@tdb.fi>
Fri, 1 Oct 2021 17:00:17 +0000 (20:00 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 1 Oct 2021 18:31:00 +0000 (21:31 +0300)
source/backends/opengl/query_backend.cpp
source/backends/opengl/query_backend.h
source/core/query.cpp
source/core/query.h

index b445be372696794753d7917ad9852faa80be7472..07360ba50da030fcc075a164d36b7ba20ce5d78b 100644 (file)
@@ -24,15 +24,16 @@ OpenGLQueryPool::~OpenGLQueryPool()
        glDeleteQueries(queries.size(), queries.data());
 }
 
-void OpenGLQueryPool::resize(unsigned s)
+void OpenGLQueryPool::resize()
 {
-       if(s<queries.size())
-               glDeleteQueries(queries.size()-s, queries.data()+s);
+       unsigned size = static_cast<const QueryPool *>(this)->size;
+       if(size<queries.size())
+               glDeleteQueries(queries.size()-size, queries.data()+size);
 
        unsigned old_size = queries.size();
-       queries.resize(s);
-       if(s>old_size)
-               glGenQueries(s-old_size, queries.data()+old_size);
+       queries.resize(size);
+       if(size>old_size)
+               glGenQueries(size-old_size, queries.data()+old_size);
 }
 
 unsigned OpenGLQueryPool::get_result(unsigned i) const
index 9365b24bc5ce4f5071d51061fb0425e7b84096b8..7bbbeb66a24037acf82894622c6d6882cba31407 100644 (file)
@@ -17,8 +17,7 @@ protected:
        OpenGLQueryPool(unsigned);
        ~OpenGLQueryPool();
 
-       void resize(unsigned);
-       unsigned get_size() const { return queries.size(); }
+       void resize();
 
        unsigned get_result(unsigned) const;
 };
index f075cada23c7f9d4ed577d37b1b51c2baabb651c..13b62801133f29636511b9fe1e55c74d628bfa11 100644 (file)
@@ -6,11 +6,18 @@ namespace GL {
 
 QueryPool::QueryPool(QueryType t, unsigned s):
        QueryPoolBackend(t),
-       type(t)
+       type(t),
+       size(0)
 {
        resize(s);
 }
 
+void QueryPool::resize(unsigned s)
+{
+       size = s;
+       QueryPoolBackend::resize();
+}
+
 
 QueryPool::Activate::Activate(Renderer &r, const QueryPool &p, unsigned i):
        renderer(r),
index f6b0a2e5ecfcb2269cf4027a0e54e7f0fd132d33..5bcae284e6cf28a067cd6d9555ca284251add92e 100644 (file)
@@ -33,12 +33,13 @@ public:
 
 private:
        QueryType type;
+       unsigned size;
 
 public:
        QueryPool(QueryType type, unsigned);
 
-       using QueryPoolBackend::resize;
-       using QueryPoolBackend::get_size;
+       void resize(unsigned);
+       unsigned get_size() const { return size; }
 
        using QueryPoolBackend::get_result;
 };