From 7d9608de2db640cb712996015a7c3e3edd24be0f Mon Sep 17 00:00:00 2001 From: Martin Piatka Date: Wed, 28 Feb 2024 12:02:06 +0100 Subject: [PATCH] gl_panorama: make Coverity happy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wasn't really incorrect, because the front & back textures were only accessed by the reader & writer thread respectively. --- src/video_display/opengl_panorama.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/video_display/opengl_panorama.cpp b/src/video_display/opengl_panorama.cpp index 60fa39dab4..f016fb7b54 100644 --- a/src/video_display/opengl_panorama.cpp +++ b/src/video_display/opengl_panorama.cpp @@ -105,26 +105,32 @@ void PanoramaScene::render(int width, int height, const glm::mat4& pvMat){ pvLoc = glGetUniformLocation(program.get(), "pv_mat"); glUniformMatrix4fv(pvLoc, 1, GL_FALSE, glm::value_ptr(pvMat)); + GLuint tex_id; {//lock std::lock_guard lock(tex_mut); if(tex.is_new_front_available()){ tex.swap_front(); } + tex_id = tex.get_front().get(); } - glBindTexture(GL_TEXTURE_2D, tex.get_front().get()); + glBindTexture(GL_TEXTURE_2D, tex_id); model.render(); } void PanoramaScene::put_frame(video_frame *f, bool pbo_frame){ PROFILE_FUNC; - Texture& back_texture = tex.get_back(); + Texture *back_texture; + { + std::lock_guard lock(tex_mut); + back_texture = &tex.get_back(); + } - uploader.attach_dst_texture(&back_texture); + uploader.attach_dst_texture(back_texture); uploader.put_frame(f, pbo_frame); - glBindTexture(GL_TEXTURE_2D, back_texture.get()); + glBindTexture(GL_TEXTURE_2D, back_texture->get()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glFinish();