share contexts on all renderthreads

This commit is contained in:
itsmattkc
2019-08-27 23:49:05 +10:00
parent d76218924e
commit 797a4eae16
5 changed files with 26 additions and 3 deletions
+13
View File
@@ -26,6 +26,7 @@ RenderInstance::RenderInstance(const int& width,
const int& height,
const olive::PixelFormat& format,
const olive::RenderMode& mode) :
share_ctx_(nullptr),
width_(width),
height_(height),
format_(format),
@@ -33,8 +34,20 @@ RenderInstance::RenderInstance(const int& width,
{
}
void RenderInstance::SetShareContext(QOpenGLContext *share)
{
Q_ASSERT(!IsStarted());
share_ctx_ = share;
}
bool RenderInstance::Start()
{
// If we're sharing resources, set this up now
if (share_ctx_ != nullptr) {
ctx_.setShareContext(share_ctx_);
}
// Create OpenGL context (automatically destroys any existing if there is one)
if (!ctx_.create()) {
qWarning() << tr("Failed to create OpenGL context in thread %1").arg(reinterpret_cast<quintptr>(this));