minor adjustments to render threads
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "rendererdownloadthread.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFloat16>
|
||||
#include <OpenImageIO/imageio.h>
|
||||
|
||||
#include "common/define.h"
|
||||
@@ -13,7 +14,6 @@ RendererDownloadThread::RendererDownloadThread(QOpenGLContext *share_ctx,
|
||||
const olive::RenderMode &mode) :
|
||||
RendererThreadBase(share_ctx, width, height, format, mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RendererDownloadThread::Queue(RenderTexturePtr texture, const QString& fn)
|
||||
@@ -42,68 +42,62 @@ void RendererDownloadThread::ProcessLoop()
|
||||
render_instance()->width(),
|
||||
render_instance()->height());
|
||||
|
||||
uchar* data_buffer = new uchar[buffer_size];
|
||||
QVector<uchar> data_buffer;
|
||||
data_buffer.resize(buffer_size);
|
||||
|
||||
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(render_instance()->format());
|
||||
|
||||
// Set up OIIO::ImageSpec for compressing cached images on disk
|
||||
OIIO::ImageSpec spec(render_instance()->width(), render_instance()->height(), kRGBAChannels, format_info.oiio_desc);
|
||||
spec.attribute("compression", "dwaa:200");
|
||||
|
||||
while (!Cancelled()) {
|
||||
// Check queue for textures to download (use mutex to prevent collisions)
|
||||
texture_queue_lock_.lock();
|
||||
|
||||
do {
|
||||
if (texture_queue_.isEmpty()) {
|
||||
working_texture = nullptr;
|
||||
} else {
|
||||
working_texture = texture_queue_.takeFirst();
|
||||
working_filename = download_filenames_.takeFirst();
|
||||
}
|
||||
while (texture_queue_.isEmpty()) {
|
||||
// Main waiting condition
|
||||
wait_cond_.wait(&texture_queue_lock_);
|
||||
}
|
||||
|
||||
if (working_texture == nullptr) {
|
||||
// Main waiting condition
|
||||
wait_cond_.wait(&texture_queue_lock_);
|
||||
}
|
||||
} while (working_texture == nullptr);
|
||||
working_texture = texture_queue_.takeFirst();
|
||||
working_filename = download_filenames_.takeFirst();
|
||||
|
||||
texture_queue_lock_.unlock();
|
||||
|
||||
// Download the texture
|
||||
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, read_buffer_);
|
||||
|
||||
xf->glFramebufferTexture2D(GL_READ_FRAMEBUFFER,
|
||||
f->glBindFramebuffer(GL_FRAMEBUFFER, read_buffer_);
|
||||
|
||||
xf->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D,
|
||||
working_texture->texture(),
|
||||
0);
|
||||
|
||||
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(working_texture->format());
|
||||
|
||||
f->glReadPixels(0,
|
||||
0,
|
||||
working_texture->width(),
|
||||
working_texture->height(),
|
||||
format_info.pixel_format,
|
||||
format_info.pixel_type,
|
||||
data_buffer);
|
||||
data_buffer.data());
|
||||
|
||||
xf->glFramebufferTexture2D(GL_READ_FRAMEBUFFER,
|
||||
xf->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
0);
|
||||
|
||||
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
f->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
std::string working_fn_std = working_filename.toStdString();
|
||||
|
||||
std::unique_ptr<OIIO::ImageOutput> out = OIIO::ImageOutput::create(working_fn_std);
|
||||
|
||||
if (out) {
|
||||
OIIO::ImageSpec spec(working_texture->width(), working_texture->height(), kRGBAChannels, format_info.oiio_desc);
|
||||
|
||||
spec.attribute("compression", "dwaa:200");
|
||||
|
||||
out->open(working_fn_std, spec);
|
||||
|
||||
out->write_image(format_info.oiio_desc, data_buffer);
|
||||
|
||||
out->write_image(format_info.oiio_desc, data_buffer.data());
|
||||
out->close();
|
||||
}
|
||||
|
||||
@@ -111,7 +105,5 @@ void RendererDownloadThread::ProcessLoop()
|
||||
|
||||
}
|
||||
|
||||
delete [] data_buffer;
|
||||
|
||||
f->glDeleteFramebuffers(1, &read_buffer_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user