general improvements to the renderer backend to help keep rendering consistent and performant

This commit is contained in:
itsmattkc
2019-12-22 03:04:34 +11:00
parent 46855adea7
commit a8beae64ae
4 changed files with 29 additions and 25 deletions
+3
View File
@@ -118,6 +118,9 @@ void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix)
m_vbo.destroy();
m_vao.release();
m_vao.destroy();
// Make sure drawing is actually complete before this function returns
func->glFinish();
}
void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline,
+1 -2
View File
@@ -32,8 +32,7 @@ bool OpenGLBackend::InitInternal()
// Initiate one thread per CPU core
for (int i=0;i<threads().size();i++) {
// Create one processor object for each thread
//OpenGLWorker* processor = new OpenGLWorker(share_ctx, &shader_cache_, &texture_cache_, frame_cache());
OpenGLWorker* processor = new OpenGLWorker(share_ctx, &shader_cache_, new OpenGLTextureCache(), frame_cache());
OpenGLWorker* processor = new OpenGLWorker(share_ctx, &shader_cache_, &texture_cache_, frame_cache());
processor->SetParameters(params());
processors_.append(processor);
}
+20 -20
View File
@@ -45,12 +45,12 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
frame->set_format(params_.format());
frame->allocate();
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
f->glViewport(0, 0, texture_->width(), texture_->height());
// Blit for transform if the width/height are different
OpenGLTexturePtr input_tex = texture.value<OpenGLTexturePtr>();
if (input_tex) {
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
f->glViewport(0, 0, texture_->width(), texture_->height());
buffer_.Attach(texture_);
buffer_.Bind();
input_tex->Bind();
@@ -60,24 +60,24 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
input_tex->Release();
buffer_.Release();
buffer_.Detach();
// Perform OpenGL read
buffer_.Attach(texture_);
buffer_.Bind();
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(params_.format());
f->glReadPixels(0,
0,
texture_->width(),
texture_->height(),
format_info.pixel_format,
format_info.gl_pixel_type,
frame->data());
buffer_.Release();
buffer_.Detach();
}
// Perform OpenGL read
buffer_.Attach(texture_);
buffer_.Bind();
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(params_.format());
f->glReadPixels(0,
0,
texture_->width(),
texture_->height(),
format_info.pixel_format,
format_info.gl_pixel_type,
frame->data());
buffer_.Release();
buffer_.Detach();
return frame;
}
@@ -29,9 +29,7 @@ OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext* ctx, co
// If we didn't find a texture, we'll need to create one
if (!texture) {
texture = std::make_shared<OpenGLTexture>();
texture->Create(ctx, params.effective_width(), params.effective_height(), params.format(), data);
} else if (data) {
texture->Upload(data);
texture->Create(ctx, params.effective_width(), params.effective_height(), params.format());
}
ReferencePtr ref = std::make_shared<Reference>(this, texture);
@@ -39,6 +37,10 @@ OpenGLTextureCache::ReferencePtr OpenGLTextureCache::Get(QOpenGLContext* ctx, co
lock_.unlock();
if (data) {
texture->Upload(data);
}
return ref;
}