@@ -65,10 +65,6 @@ struct device::impl : public std::enable_shared_from_this<impl>
65
65
std::array<std::array<tbb::concurrent_unordered_map<size_t , texture_queue_t >, 4 >, 2 > device_pools_;
66
66
std::array<tbb::concurrent_unordered_map<size_t , buffer_queue_t >, 2 > host_pools_;
67
67
68
- using sync_queue_t = tbb::concurrent_bounded_queue<std::shared_ptr<buffer>>;
69
-
70
- sync_queue_t sync_queue_;
71
-
72
68
GLuint fbo_;
73
69
74
70
std::wstring version_;
@@ -137,8 +133,6 @@ struct device::impl : public std::enable_shared_from_this<impl>
137
133
for (auto & pool : pools)
138
134
pool.clear ();
139
135
140
- sync_queue_.clear ();
141
-
142
136
GL (glDeleteFramebuffers (1 , &fbo_));
143
137
}
144
138
@@ -222,15 +216,16 @@ struct device::impl : public std::enable_shared_from_this<impl>
222
216
223
217
auto ptr = buf.get ();
224
218
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));
226
221
});
227
222
}
228
223
229
224
array<uint8_t > create_array (int size)
230
225
{
231
226
auto buf = create_buffer (size, true );
232
227
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) );
234
229
}
235
230
236
231
std::future<std::shared_ptr<texture>>
@@ -261,8 +256,6 @@ struct device::impl : public std::enable_shared_from_this<impl>
261
256
auto buf = create_buffer (source->size (), false );
262
257
source->copy_to (*buf);
263
258
264
- sync_queue_.push (nullptr );
265
-
266
259
auto fence = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0 );
267
260
268
261
GL (glFlush ());
@@ -281,53 +274,12 @@ struct device::impl : public std::enable_shared_from_this<impl>
281
274
282
275
glDeleteSync (fence);
283
276
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
-
292
277
auto ptr = reinterpret_cast <uint8_t *>(buf->data ());
293
278
auto size = buf->size ();
294
279
return array<const uint8_t >(ptr, size, std::move (buf));
295
280
});
296
281
}
297
282
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
-
331
283
boost::property_tree::wptree info () const
332
284
{
333
285
boost::property_tree::wptree info;
0 commit comments