@@ -36,7 +36,6 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
36
36
37
37
const egl::CEGL* egl;
38
38
ISurface::E_PRESENT_MODE m_presentMode;
39
- const COpenGLFeatureMap* features;
40
39
uint32_t imageCount;
41
40
uint32_t imgWidth, imgHeight;
42
41
core::smart_refctd_ptr<COpenGLSync> syncs[ISwapchain::MaxImages];
@@ -46,7 +45,7 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
46
45
asset::E_FORMAT m_ourFormat;
47
46
GLenum m_glFormat;
48
47
49
- bool needToBlit = false ;
48
+ std::atomic_bool needToBlit = false ;
50
49
51
50
EGLBoolean m_makeCurrentRes = EGL_FALSE;
52
51
// std::condition_variable m_ctxCreatedCvar;
@@ -55,15 +54,13 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
55
54
IOpenGL_LogicalDevice* dev,
56
55
ISurface::E_PRESENT_MODE presentMode,
57
56
uint32_t _imgCount, uint32_t _imgWidth, uint32_t _imgHeight,
58
- const COpenGLFeatureMap* _features,
59
57
egl::CEGL::Context _glctx,
60
58
COpenGLDebugCallback* _dbgCb,
61
59
asset::E_FORMAT format
62
60
) : m_device(dev), m_masterContextCallsWaited(0 ),
63
61
egl (_egl),
64
62
m_presentMode(presentMode),
65
63
glctx(_glctx),
66
- features(_features),
67
64
imageCount(_imgCount),
68
65
imgWidth(_imgWidth),
69
66
imgHeight(_imgHeight),
@@ -75,7 +72,7 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
75
72
{
76
73
auto raii_handler = base_t::createRAIIDispatchHandler ();
77
74
78
- needToBlit = true ;
75
+ needToBlit. store ( true ) ;
79
76
request.imgIx = _imgIx;
80
77
request.semCount = semCount;
81
78
request.sems = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<core::smart_refctd_ptr<COpenGLSemaphore>>>(semCount);
@@ -141,9 +138,9 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
141
138
}
142
139
143
140
if (m_device->getAPIType () == video::EAT_OPENGL)
144
- new (state_ptr) COpenGLFunctionTable (egl, features , core::smart_refctd_ptr<system::ILogger>(m_dbgCb->getLogger ()));
141
+ new (state_ptr) COpenGLFunctionTable (egl, m_device-> getGlFeatures () , core::smart_refctd_ptr<system::ILogger>(m_dbgCb->getLogger ()));
145
142
else if (m_device->getAPIType () == video::EAT_OPENGL_ES)
146
- new (state_ptr) COpenGLESFunctionTable (egl, features , core::smart_refctd_ptr<system::ILogger>(m_dbgCb->getLogger ()));
143
+ new (state_ptr) COpenGLESFunctionTable (egl, m_device-> getGlFeatures () , core::smart_refctd_ptr<system::ILogger>(m_dbgCb->getLogger ()));
147
144
else assert (false );
148
145
auto gl = getFunctionTable (m_device->getAPIType (), state_ptr);
149
146
@@ -195,7 +192,7 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
195
192
void work (typename base_t ::lock_t & lock, typename base_t ::internal_state_t & state)
196
193
{
197
194
auto gl = getFunctionTable (m_device->getAPIType (), &state);
198
- needToBlit = false ;
195
+ needToBlit. store ( false ) ;
199
196
200
197
const uint32_t imgix = request.imgIx ;
201
198
const uint32_t w = imgWidth;
@@ -226,8 +223,8 @@ class COpenGL_SwapchainThreadHandler final : public system::IThreadHandler<COpen
226
223
egl->call .peglDestroySurface (egl->display , glctx.surface );
227
224
}
228
225
229
- bool wakeupPredicate () const { return needToBlit; }
230
- bool continuePredicate () const { return needToBlit; }
226
+ bool wakeupPredicate () const { return needToBlit. load () ; }
227
+ bool continuePredicate () const { return needToBlit. load () ; }
231
228
};
232
229
233
230
template <typename FunctionTableType>
@@ -236,7 +233,8 @@ const void* COpenGL_Swapchain<FunctionTableType>::getNativeHandle() const { retu
236
233
template <typename FunctionTableType>
237
234
core::smart_refctd_ptr<COpenGL_Swapchain<FunctionTableType>> COpenGL_Swapchain<FunctionTableType>::create(const core::smart_refctd_ptr<ILogicalDevice>&& logicalDevice, ISwapchain::SCreationParams&& params)
238
235
{
239
- if (params.surface ->getAPIType () != EAT_OPENGL || (params.presentMode == ISurface::EPM_MAILBOX) || (params.presentMode == ISurface::EPM_UNKNOWN))
236
+ // surfaces are only supported by queue family index 0 on opengl
237
+ if (!params.surface ->isSupportedForPhysicalDevice (logicalDevice->getPhysicalDevice (), 0u ) || params.surface ->getAPIType () != EAT_OPENGL || (params.presentMode == ISurface::EPM_MAILBOX) || (params.presentMode == ISurface::EPM_UNKNOWN))
240
238
return nullptr ;
241
239
242
240
auto device = core::smart_refctd_ptr_static_cast<IOpenGL_LogicalDevice>(logicalDevice);
@@ -281,7 +279,7 @@ core::smart_refctd_ptr<COpenGL_Swapchain<FunctionTableType>> COpenGL_Swapchain<F
281
279
device.get (),
282
280
params.presentMode ,
283
281
params.minImageCount , params.width , params.height ,
284
- device-> getGlFeatures (), { ctx, surface },
282
+ { ctx, surface },
285
283
static_cast <COpenGLDebugCallback*>(device->getPhysicalDevice ()->getDebugCallback ()),
286
284
params.surfaceFormat .format
287
285
));
@@ -378,7 +376,7 @@ core::smart_refctd_ptr<IGPUImage> COpenGL_Swapchain<FunctionTableType>::createIm
378
376
swapchainRef->m_imageIndex = imageIndex;
379
377
380
378
imgCreationParams.preDestroyCleanup = std::unique_ptr<ICleanup>(swapchainRef.release ());
381
- imgCreationParams.importedHandle = true ;
379
+ imgCreationParams.skipHandleDestroy = true ;
382
380
383
381
return m_threadHandler->createImageAsImported (imageIndex, std::move (imgCreationParams));
384
382
}
0 commit comments