From ab758c30d2ba46eabd9774951afaed52c8344855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 8 Sep 2020 16:05:36 +0200 Subject: 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. --- source/blender/gpu/opengl/gl_backend.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to '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; } -- cgit v1.2.3