renderer: ensure offscreen surface is created in main thread
Fixes render crash on some platforms.
This commit is contained in:
@@ -25,10 +25,17 @@
|
|||||||
OLIVE_NAMESPACE_ENTER
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
OpenGLBackend::OpenGLBackend(QObject* parent) :
|
OpenGLBackend::OpenGLBackend(QObject* parent) :
|
||||||
RenderBackend(parent),
|
RenderBackend(parent)
|
||||||
proxy_(nullptr)
|
|
||||||
{
|
{
|
||||||
|
proxy_ = new OpenGLProxy();
|
||||||
|
|
||||||
|
QThread* proxy_thread = new QThread();
|
||||||
|
proxy_thread->start(QThread::IdlePriority);
|
||||||
|
proxy_->moveToThread(proxy_thread);
|
||||||
|
|
||||||
|
if (!proxy_->Init()) {
|
||||||
|
ClearProxy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGLBackend::~OpenGLBackend()
|
OpenGLBackend::~OpenGLBackend()
|
||||||
@@ -40,19 +47,6 @@ OpenGLBackend::~OpenGLBackend()
|
|||||||
|
|
||||||
RenderWorker *OpenGLBackend::CreateNewWorker()
|
RenderWorker *OpenGLBackend::CreateNewWorker()
|
||||||
{
|
{
|
||||||
if (!proxy_) {
|
|
||||||
proxy_ = new OpenGLProxy();
|
|
||||||
|
|
||||||
QThread* proxy_thread = new QThread();
|
|
||||||
proxy_thread->start(QThread::IdlePriority);
|
|
||||||
proxy_->moveToThread(proxy_thread);
|
|
||||||
|
|
||||||
if (!proxy_->Init()) {
|
|
||||||
ClearProxy();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OpenGLWorker(this, proxy_);
|
return new OpenGLWorker(this, proxy_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
|
|
||||||
virtual ~RenderBackend() override;
|
virtual ~RenderBackend() override;
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
|
||||||
void SetViewerNode(ViewerOutput* viewer_node);
|
void SetViewerNode(ViewerOutput* viewer_node);
|
||||||
|
|
||||||
void SetUpdateWithGraph(bool e);
|
void SetUpdateWithGraph(bool e);
|
||||||
@@ -76,8 +78,6 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
virtual RenderWorker* CreateNewWorker() = 0;
|
virtual RenderWorker* CreateNewWorker() = 0;
|
||||||
|
|
||||||
void Close();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CopyNodeInputValue(NodeInput* input);
|
void CopyNodeInputValue(NodeInput* input);
|
||||||
Node *CopyNodeConnections(Node *src_node);
|
Node *CopyNodeConnections(Node *src_node);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
#include "common/timecodefunctions.h"
|
#include "common/timecodefunctions.h"
|
||||||
#include "render/backend/opengl/openglbackend.h"
|
|
||||||
|
|
||||||
OLIVE_NAMESPACE_ENTER
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
@@ -62,16 +61,12 @@ void RenderTask::Render(const TimeRangeList& video_range,
|
|||||||
const QMatrix4x4& mat,
|
const QMatrix4x4& mat,
|
||||||
bool use_disk_cache)
|
bool use_disk_cache)
|
||||||
{
|
{
|
||||||
OpenGLBackend backend;
|
|
||||||
|
|
||||||
backend.moveToThread(qApp->thread());
|
|
||||||
|
|
||||||
// FIXME: This makes a full copy of the node graph every time it starts, there must be a better
|
// FIXME: This makes a full copy of the node graph every time it starts, there must be a better
|
||||||
// way.
|
// way.
|
||||||
backend.SetViewerNode(viewer_);
|
backend_.SetViewerNode(viewer_);
|
||||||
backend.SetVideoParams(video_params_);
|
backend_.SetVideoParams(video_params_);
|
||||||
backend.SetAudioParams(audio_params_);
|
backend_.SetAudioParams(audio_params_);
|
||||||
backend.SetVideoDownloadMatrix(mat);
|
backend_.SetVideoDownloadMatrix(mat);
|
||||||
|
|
||||||
std::list<RangeSampleFuturePair> audio_lookup_table;
|
std::list<RangeSampleFuturePair> audio_lookup_table;
|
||||||
if (!audio_range.isEmpty()) {
|
if (!audio_range.isEmpty()) {
|
||||||
@@ -79,7 +74,7 @@ void RenderTask::Render(const TimeRangeList& video_range,
|
|||||||
QList<TimeRange> ranges = RenderBackend::SplitRangeIntoChunks(r);
|
QList<TimeRange> ranges = RenderBackend::SplitRangeIntoChunks(r);
|
||||||
|
|
||||||
foreach (const TimeRange& split, ranges) {
|
foreach (const TimeRange& split, ranges) {
|
||||||
audio_lookup_table.push_back({split, backend.RenderAudio(split)});
|
audio_lookup_table.push_back({split, backend_.RenderAudio(split)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +87,7 @@ void RenderTask::Render(const TimeRangeList& video_range,
|
|||||||
{
|
{
|
||||||
QList<rational> times = viewer_->video_frame_cache()->GetFrameListFromTimeRange(video_range);
|
QList<rational> times = viewer_->video_frame_cache()->GetFrameListFromTimeRange(video_range);
|
||||||
|
|
||||||
QFuture<QList<QByteArray> > hash_future = backend.Hash(times);
|
QFuture<QList<QByteArray> > hash_future = backend_.Hash(times);
|
||||||
QList<QByteArray> hashes = hash_future.result();
|
QList<QByteArray> hashes = hash_future.result();
|
||||||
|
|
||||||
// Determine any duplicates
|
// Determine any duplicates
|
||||||
@@ -139,7 +134,7 @@ void RenderTask::Render(const TimeRangeList& video_range,
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (const HashTimePair& p, sorted_times) {
|
foreach (const HashTimePair& p, sorted_times) {
|
||||||
render_lookup_table.push_back({p.hash, backend.RenderFrame(p.time)});
|
render_lookup_table.push_back({p.hash, backend_.RenderFrame(p.time)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,6 +200,8 @@ void RenderTask::Render(const TimeRangeList& video_range,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backend_.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTask::SetAnchorPoint(const rational &r)
|
void RenderTask::SetAnchorPoint(const rational &r)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
#include "node/output/viewer/viewer.h"
|
#include "node/output/viewer/viewer.h"
|
||||||
|
#include "render/backend/opengl/openglbackend.h"
|
||||||
#include "task/task.h"
|
#include "task/task.h"
|
||||||
|
|
||||||
OLIVE_NAMESPACE_ENTER
|
OLIVE_NAMESPACE_ENTER
|
||||||
@@ -71,6 +72,8 @@ private:
|
|||||||
|
|
||||||
rational anchor_point_;
|
rational anchor_point_;
|
||||||
|
|
||||||
|
OpenGLBackend backend_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OLIVE_NAMESPACE_EXIT
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|||||||
Reference in New Issue
Block a user