Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Yurkovich <jesse.y@gmail.com>2022-02-13 08:52:24 +0300
committerJesse Yurkovich <jesse.y@gmail.com>2022-02-13 08:52:24 +0300
commit7413c2feede68c45f13fa37ebdcbf325d8f32c10 (patch)
treee08267ea33026b5b0681fd9ca7bc29ba832a8e7b /source/blender/gpu/opengl
parent52be06301257a82a1b4a5746e91ff60daa637ded (diff)
Cleanup: Optimize gl query code path
Currently whenever gl queries are performed for the viewport, a large 1024 byte array is allocated to store the query results (256 of them). Unfortunately, if any gizmo using a `draw_select` callback is active (e.g. the transform gizmos), these queries (and allocations) will occur during every mouse move event. Change the vector to allow for up to 16 query results before making an allocation. This provides enough space for every built-in gizmo except Scale Cage (which needs 27 queries). It also removes unnecessary allocations from two other related vectors used during query processing. Differential Revision: https://developer.blender.org/D13784
Diffstat (limited to 'source/blender/gpu/opengl')
-rw-r--r--source/blender/gpu/opengl/gl_query.cc5
-rw-r--r--source/blender/gpu/opengl/gl_query.hh2
2 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/gpu/opengl/gl_query.cc b/source/blender/gpu/opengl/gl_query.cc
index 3195ec95ed2..0081efbf1e7 100644
--- a/source/blender/gpu/opengl/gl_query.cc
+++ b/source/blender/gpu/opengl/gl_query.cc
@@ -37,8 +37,9 @@ void GLQueryPool::begin_query()
/* TODO: add assert about expected usage. */
while (query_issued_ >= query_ids_.size()) {
int64_t prev_size = query_ids_.size();
- query_ids_.resize(prev_size + QUERY_CHUNCK_LEN);
- glGenQueries(QUERY_CHUNCK_LEN, &query_ids_[prev_size]);
+ int64_t chunk_size = prev_size == 0 ? query_ids_.capacity() : QUERY_CHUNCK_LEN;
+ query_ids_.resize(prev_size + chunk_size);
+ glGenQueries(chunk_size, &query_ids_[prev_size]);
}
glBeginQuery(gl_type_, query_ids_[query_issued_++]);
}
diff --git a/source/blender/gpu/opengl/gl_query.hh b/source/blender/gpu/opengl/gl_query.hh
index 0dc4a6b8d51..e15a2584e07 100644
--- a/source/blender/gpu/opengl/gl_query.hh
+++ b/source/blender/gpu/opengl/gl_query.hh
@@ -18,7 +18,7 @@ namespace blender::gpu {
class GLQueryPool : public QueryPool {
private:
/** Contains queries object handles. */
- Vector<GLuint> query_ids_;
+ Vector<GLuint, QUERY_MIN_LEN> query_ids_;
/** Type of this query pool. */
GPUQueryType type_;
/** Associated GL type. */