From f99600ed40789665547e6b3485a24f4da09d27cf Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Sat, 27 Mar 2021 01:50:17 +0000 Subject: [PATCH] openglrender: Add attributeLocation check Sometimes when the default fragment shader is used a_texcoord is optimised out which can cause GL errors. Also adds the same check for a_position preemptively --- app/render/opengl/openglrenderer.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/render/opengl/openglrenderer.cpp b/app/render/opengl/openglrenderer.cpp index 9e3aab53f..2e28bb4c3 100644 --- a/app/render/opengl/openglrenderer.cpp +++ b/app/render/opengl/openglrenderer.cpp @@ -491,16 +491,20 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video frag_vbo_.release(); int vertex_location = shader->attributeLocation("a_position"); - vert_vbo_.bind(); - functions_->glEnableVertexAttribArray(vertex_location); - functions_->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, nullptr); - vert_vbo_.release(); + if (vertex_location != -1) { + vert_vbo_.bind(); + functions_->glEnableVertexAttribArray(vertex_location); + functions_->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, nullptr); + vert_vbo_.release(); + } int tex_location = shader->attributeLocation("a_texcoord"); - frag_vbo_.bind(); - functions_->glEnableVertexAttribArray(tex_location); - functions_->glVertexAttribPointer(tex_location, 2, GL_FLOAT, GL_FALSE, 0, nullptr); - frag_vbo_.release(); + if (tex_location != -1) { + frag_vbo_.bind(); + functions_->glEnableVertexAttribArray(tex_location); + functions_->glVertexAttribPointer(tex_location, 2, GL_FLOAT, GL_FALSE, 0, nullptr); + frag_vbo_.release(); + } // Some shaders optimize through multiple iterations which requires ping-ponging textures // - If there are only two iterations, we can just create one backend texture and then the