Skip to content

Commit 9a76980

Browse files
committed
fix: remove buffer sync_queue #1600
1 parent f5be849 commit 9a76980

File tree

1 file changed

+3
-51
lines changed

1 file changed

+3
-51
lines changed

src/accelerator/ogl/util/device.cpp

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ struct device::impl : public std::enable_shared_from_this<impl>
6565
std::array<std::array<tbb::concurrent_unordered_map<size_t, texture_queue_t>, 4>, 2> device_pools_;
6666
std::array<tbb::concurrent_unordered_map<size_t, buffer_queue_t>, 2> host_pools_;
6767

68-
using sync_queue_t = tbb::concurrent_bounded_queue<std::shared_ptr<buffer>>;
69-
70-
sync_queue_t sync_queue_;
71-
7268
GLuint fbo_;
7369

7470
std::wstring version_;
@@ -137,8 +133,6 @@ struct device::impl : public std::enable_shared_from_this<impl>
137133
for (auto& pool : pools)
138134
pool.clear();
139135

140-
sync_queue_.clear();
141-
142136
GL(glDeleteFramebuffers(1, &fbo_));
143137
}
144138

@@ -222,15 +216,16 @@ struct device::impl : public std::enable_shared_from_this<impl>
222216

223217
auto ptr = buf.get();
224218
return std::shared_ptr<buffer>(ptr, [buf = std::move(buf), self = shared_from_this()](buffer*) mutable {
225-
self->sync_queue_.emplace(std::move(buf));
219+
auto pool = &self->host_pools_[static_cast<int>(buf->write() ? 1 : 0)][buf->size()];
220+
pool->push(std::move(buf));
226221
});
227222
}
228223

229224
array<uint8_t> create_array(int size)
230225
{
231226
auto buf = create_buffer(size, true);
232227
auto ptr = reinterpret_cast<uint8_t*>(buf->data());
233-
return array<uint8_t>(ptr, buf->size(), buf);
228+
return array<uint8_t>(ptr, buf->size(), std::move(buf));
234229
}
235230

236231
std::future<std::shared_ptr<texture>>
@@ -261,8 +256,6 @@ struct device::impl : public std::enable_shared_from_this<impl>
261256
auto buf = create_buffer(source->size(), false);
262257
source->copy_to(*buf);
263258

264-
sync_queue_.push(nullptr);
265-
266259
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
267260

268261
GL(glFlush());
@@ -281,53 +274,12 @@ struct device::impl : public std::enable_shared_from_this<impl>
281274

282275
glDeleteSync(fence);
283276

284-
{
285-
std::shared_ptr<buffer> buf2;
286-
while (sync_queue_.try_pop(buf2) && buf2) {
287-
auto pool = &host_pools_[static_cast<int>(buf2->write() ? 1 : 0)][buf2->size()];
288-
pool->push(std::move(buf2));
289-
}
290-
}
291-
292277
auto ptr = reinterpret_cast<uint8_t*>(buf->data());
293278
auto size = buf->size();
294279
return array<const uint8_t>(ptr, size, std::move(buf));
295280
});
296281
}
297282

298-
#ifdef WIN32
299-
/* Unused? */
300-
std::future<std::shared_ptr<texture>>
301-
copy_async(GLuint source, int width, int height, int stride, common::bit_depth depth)
302-
{
303-
return spawn_async([=](yield_context yield) {
304-
auto tex = create_texture(width, height, stride, depth, false);
305-
306-
tex->copy_from(source);
307-
308-
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
309-
310-
GL(glFlush());
311-
312-
deadline_timer timer(service_);
313-
for (auto n = 0; true; ++n) {
314-
// TODO (perf) Smarter non-polling solution?
315-
timer.expires_from_now(boost::posix_time::milliseconds(2));
316-
timer.async_wait(yield);
317-
318-
auto wait = glClientWaitSync(fence, 0, 1);
319-
if (wait == GL_ALREADY_SIGNALED || wait == GL_CONDITION_SATISFIED) {
320-
break;
321-
}
322-
}
323-
324-
glDeleteSync(fence);
325-
326-
return tex;
327-
});
328-
}
329-
#endif
330-
331283
boost::property_tree::wptree info() const
332284
{
333285
boost::property_tree::wptree info;

0 commit comments

Comments
 (0)