From cd15da52eac6471f860f4232161c451530dc9bd4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 1 Oct 2021 20:00:17 +0300 Subject: [PATCH] Store query pool size separately, in the common part of the class --- source/backends/opengl/query_backend.cpp | 13 +++++++------ source/backends/opengl/query_backend.h | 3 +-- source/core/query.cpp | 9 ++++++++- source/core/query.h | 5 +++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/source/backends/opengl/query_backend.cpp b/source/backends/opengl/query_backend.cpp index b445be37..07360ba5 100644 --- a/source/backends/opengl/query_backend.cpp +++ b/source/backends/opengl/query_backend.cpp @@ -24,15 +24,16 @@ OpenGLQueryPool::~OpenGLQueryPool() glDeleteQueries(queries.size(), queries.data()); } -void OpenGLQueryPool::resize(unsigned s) +void OpenGLQueryPool::resize() { - if(s(this)->size; + if(sizeold_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 diff --git a/source/backends/opengl/query_backend.h b/source/backends/opengl/query_backend.h index 9365b24b..7bbbeb66 100644 --- a/source/backends/opengl/query_backend.h +++ b/source/backends/opengl/query_backend.h @@ -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; }; diff --git a/source/core/query.cpp b/source/core/query.cpp index f075cada..13b62801 100644 --- a/source/core/query.cpp +++ b/source/core/query.cpp @@ -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), diff --git a/source/core/query.h b/source/core/query.h index f6b0a2e5..5bcae284 100644 --- a/source/core/query.h +++ b/source/core/query.h @@ -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; }; -- 2.45.2