fixed issues with some opengl implementations
This commit is contained in:
@@ -254,6 +254,10 @@ void RendererProcessor::Start()
|
||||
|
||||
int background_thread_count = QThread::idealThreadCount();
|
||||
|
||||
// Some OpenGL implementations (notably wgl) require the context not to be current before sharing
|
||||
QSurface* old_surface = ctx->surface();
|
||||
ctx->doneCurrent();
|
||||
|
||||
threads_.resize(background_thread_count);
|
||||
|
||||
for (int i=0;i<threads_.size();i++) {
|
||||
@@ -297,6 +301,9 @@ void RendererProcessor::Start()
|
||||
|
||||
last_download_thread_ = 0;
|
||||
|
||||
// Restore context now that thread creation is complete
|
||||
ctx->makeCurrent(old_surface);
|
||||
|
||||
// Create master texture (the one sent to the viewer)
|
||||
master_texture_ = std::make_shared<RenderTexture>();
|
||||
master_texture_->Create(ctx, effective_width_, effective_height_, format_);
|
||||
|
||||
@@ -24,19 +24,14 @@
|
||||
|
||||
RendererThreadBase::RendererThreadBase(QOpenGLContext *share_ctx, const int &width, const int &height, const int ÷r, const olive::PixelFormat &format, const olive::RenderMode &mode) :
|
||||
share_ctx_(share_ctx),
|
||||
width_(width),
|
||||
height_(height),
|
||||
divider_(divider),
|
||||
format_(format),
|
||||
mode_(mode),
|
||||
render_instance_(nullptr)
|
||||
render_instance_(width, height, divider, format, mode)
|
||||
{
|
||||
connect(share_ctx_, SIGNAL(aboutToBeDestroyed()), this, SLOT(Cancel()));
|
||||
}
|
||||
|
||||
RenderInstance *RendererThreadBase::render_instance()
|
||||
{
|
||||
return render_instance_;
|
||||
return &render_instance_;
|
||||
}
|
||||
|
||||
void RendererThreadBase::run()
|
||||
@@ -44,18 +39,15 @@ void RendererThreadBase::run()
|
||||
// Lock mutex for main loop
|
||||
mutex_.lock();
|
||||
|
||||
// Signal that main thread can continue now
|
||||
caller_mutex_.lock();
|
||||
wait_cond_.wakeAll();
|
||||
caller_mutex_.unlock();
|
||||
|
||||
RenderInstance instance(width_, height_, divider_, format_, mode_);
|
||||
render_instance_ = &instance;
|
||||
|
||||
instance.SetShareContext(share_ctx_);
|
||||
render_instance_.SetShareContext(share_ctx_);
|
||||
|
||||
// Allocate and create resources
|
||||
if (instance.Start()) {
|
||||
bool started = render_instance_.Start();
|
||||
|
||||
// Signal that main thread can continue now
|
||||
WakeCaller();
|
||||
|
||||
if (started) {
|
||||
|
||||
// Main loop (use Cancel() to exit it)
|
||||
ProcessLoop();
|
||||
@@ -63,13 +55,20 @@ void RendererThreadBase::run()
|
||||
}
|
||||
|
||||
// Free all resources
|
||||
render_instance_ = nullptr;
|
||||
instance.Stop();
|
||||
render_instance_.Stop();
|
||||
|
||||
// Unlock mutex before exiting
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
||||
void RendererThreadBase::WakeCaller()
|
||||
{
|
||||
// Signal that main thread can continue now
|
||||
caller_mutex_.lock();
|
||||
wait_cond_.wakeAll();
|
||||
caller_mutex_.unlock();
|
||||
}
|
||||
|
||||
void RendererThreadBase::StartThread(QThread::Priority priority)
|
||||
{
|
||||
caller_mutex_.lock();
|
||||
|
||||
@@ -59,19 +59,11 @@ protected:
|
||||
QMutex caller_mutex_;
|
||||
|
||||
private:
|
||||
void WakeCaller();
|
||||
|
||||
QOpenGLContext* share_ctx_;
|
||||
|
||||
const int& width_;
|
||||
|
||||
const int& height_;
|
||||
|
||||
const int& divider_;
|
||||
|
||||
const olive::PixelFormat& format_;
|
||||
|
||||
const olive::RenderMode& mode_;
|
||||
|
||||
RenderInstance* render_instance_;
|
||||
RenderInstance render_instance_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user