Blender V5.3
gl_work_in_flight.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11namespace blender::gpu {
12
14{
15 async_fences_.resize(max_in_flight);
16 async_fences_.fill(0);
17}
18
20{
21 delete_fences();
22}
23
24void GLWorkInFlight::delete_fences()
25{
26 for (GLsync fence : async_fences_) {
27 if (fence != 0) {
28 glDeleteSync(fence);
29 }
30 }
31}
32
34{
35 delete_fences();
36 async_fences_.fill(0);
37 work_index_ = 0;
38}
39
41{
42 GLsync async_fence_prev = async_fences_[work_index_];
43 if (async_fence_prev != 0) {
44 while (glClientWaitSync(async_fence_prev, GL_SYNC_FLUSH_COMMANDS_BIT, 1000) ==
45 GL_TIMEOUT_EXPIRED)
46 {
47 /* Repeat until the work has finished. */
48 }
49 }
50}
51
53{
54 async_fences_[work_index_] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
55 work_index_ = (work_index_ + 1) % async_fences_.size();
56}
57
58} // namespace blender::gpu
GLWorkInFlight(unsigned int max_in_flight)
unsigned int uint
Definition BKE_text.h:55