[Bf-blender-cvs] [ab758c30d2b] master: GLBackend: Fix gl error inside the mip rendering workaround detection

Clément noreply at git.blender.org
Tue Sep 8 16:14:56 CEST 2020


Commit: ab758c30d2ba46eabd9774951afaed52c8344855
Author: Clément
Date:   Tue Sep 8 16:05:36 2020 +0200
Branches: master
https://developer.blender.org/rBab758c30d2ba46eabd9774951afaed52c8344855

GLBackend: Fix gl error inside the mip rendering workaround detection

This was caused by an incorrect mipmap size.
Also add debug checks for good mesure.

===================================================================

M	source/blender/gpu/opengl/gl_backend.cc

===================================================================

diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc
index 3dfe0e1e412..e55e07d5a0b 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -28,6 +28,8 @@
 
 #include "glew-mx.h"
 
+#include "gl_debug.hh"
+
 #include "gl_backend.hh"
 
 namespace blender::gpu {
@@ -151,6 +153,8 @@ static bool detect_mip_render_workaround(void)
   float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
   float *source_pix = (float *)MEM_callocN(sizeof(float[4]) * cube_size * cube_size * 6, __func__);
 
+  /* NOTE: Debug layers are not yet enabled. Force use of glGetError. */
+  debug::check_gl_error("Cubemap Workaround Start");
   /* Not using GPU API since it is not yet fully initialized. */
   GLuint tex, fb;
   /* Create cubemap with 2 mip level. */
@@ -158,8 +162,9 @@ static bool detect_mip_render_workaround(void)
   glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
   for (int mip = 0; mip < 2; mip++) {
     for (int i = 0; i < 6; i++) {
+      const int width = cube_size / (1 << mip);
       GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
-      glTexImage2D(target, mip, GL_RGBA16F, 2, 2, 0, GL_RGBA, GL_FLOAT, source_pix);
+      glTexImage2D(target, mip, GL_RGBA16F, width, width, 0, GL_RGBA, GL_FLOAT, source_pix);
     }
   }
   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
@@ -182,6 +187,8 @@ static bool detect_mip_render_workaround(void)
   glDeleteFramebuffers(1, &fb);
   glDeleteTextures(1, &tex);
 
+  debug::check_gl_error("Cubemap Workaround End9");
+
   return enable_workaround;
 }



More information about the Bf-blender-cvs mailing list