renderer: moved alpha channel detection to where texture is actually made
This commit is contained in:
@@ -286,7 +286,6 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
|
||||
QString iterative_name;
|
||||
GLuint iterative_input = 0;
|
||||
QVector<TextureToBind> textures_to_bind;
|
||||
bool input_textures_have_alpha = false;
|
||||
|
||||
QOpenGLShaderProgram* shader = Node::ValueToPtr<QOpenGLShaderProgram>(s);
|
||||
|
||||
@@ -360,10 +359,6 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
|
||||
GLuint tex_id = texture ? texture->id().value<GLuint>() : 0;
|
||||
textures_to_bind.append({texture, job.GetInterpolation(it.key())});
|
||||
|
||||
if (texture && texture->channel_count() == VideoParams::kRGBAChannelCount) {
|
||||
input_textures_have_alpha = true;
|
||||
}
|
||||
|
||||
// Set enable flag if shader wants it
|
||||
int enable_param_location = shader->uniformLocation(QStringLiteral("%1_enabled").arg(it.key()));
|
||||
if (enable_param_location > -1) {
|
||||
@@ -440,13 +435,6 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
|
||||
destination_params.effective_width(),
|
||||
destination_params.effective_height());
|
||||
|
||||
// Set whether our destination texture needs an alpha channel
|
||||
if (input_textures_have_alpha || job.GetAlphaChannelRequired()) {
|
||||
destination_params.set_channel_count(VideoParams::kRGBAChannelCount);
|
||||
} else {
|
||||
destination_params.set_channel_count(VideoParams::kRGBChannelCount);
|
||||
}
|
||||
|
||||
// Bind vertex array object
|
||||
QOpenGLVertexArrayObject vao_;
|
||||
vao_.create();
|
||||
|
||||
@@ -391,9 +391,26 @@ QVariant RenderProcessor::ProcessShader(const Node *node, const TimeRange &range
|
||||
}
|
||||
}
|
||||
|
||||
const VideoParams& video_params = ticket_->property("vparam").value<VideoParams>();
|
||||
VideoParams tex_params = ticket_->property("vparam").value<VideoParams>();
|
||||
|
||||
TexturePtr destination = render_ctx_->CreateTexture(video_params);
|
||||
bool input_textures_have_alpha = false;
|
||||
for (auto it=job.GetValues().cbegin(); it!=job.GetValues().cend(); it++) {
|
||||
if (it.value().type == NodeParam::kTexture) {
|
||||
TexturePtr tex = it.value().data.value<TexturePtr>();
|
||||
if (tex && tex->channel_count() == VideoParams::kRGBAChannelCount) {
|
||||
input_textures_have_alpha = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (input_textures_have_alpha || job.GetAlphaChannelRequired()) {
|
||||
tex_params.set_channel_count(VideoParams::kRGBAChannelCount);
|
||||
} else {
|
||||
tex_params.set_channel_count(VideoParams::kRGBChannelCount);
|
||||
}
|
||||
|
||||
TexturePtr destination = render_ctx_->CreateTexture(tex_params);
|
||||
|
||||
// Run shader
|
||||
render_ctx_->BlitToTexture(shader, job, destination.get());
|
||||
@@ -487,8 +504,6 @@ QVariant RenderProcessor::GetCachedFrame(const Node *node, const rational &time)
|
||||
|
||||
f->set_video_params(p);
|
||||
|
||||
qDebug() << "Using cached frame!";
|
||||
|
||||
TexturePtr texture = render_ctx_->CreateTexture(f->video_params(), f->data(), f->linesize_pixels());
|
||||
return QVariant::fromValue(texture);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user