Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-09-15 01:10:27 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-09-15 01:11:25 +0300
commitb3a90691703c85fdad9e205722ee061f9c9645e8 (patch)
tree6dc784494ef7e70e6f492952a6da6f6d3bb1b87a /source/blender/gpu/intern/gpu_texture.c
parent6b024c7e1aebe8b0a76316ceef3139827cd3cb9f (diff)
GPUTexture: Fix problem with glGenerateMipmap
Fix T56789: There was issue with certain driver with glGenerateMipmap and GPU_DEPTH_COMPONENT24. In this case we just create a complete texture with mipmaps manually without downsampling / initializing the data.
Diffstat (limited to 'source/blender/gpu/intern/gpu_texture.c')
-rw-r--r--source/blender/gpu/intern/gpu_texture.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 3e4a57c8f64..0ef1700b348 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -1226,7 +1226,21 @@ void GPU_texture_generate_mipmap(GPUTexture *tex)
WARN_NOT_BOUND(tex);
glActiveTexture(GL_TEXTURE0 + tex->number);
- glGenerateMipmap(tex->target_base);
+
+ if (GPU_texture_depth(tex)) {
+ /* Some drivers have bugs when using glGenerateMipmap with depth textures (see T56789).
+ * In this case we just create a complete texture with mipmaps manually without downsampling.
+ * You must initialize the texture levels using other methods like GPU_framebuffer_recursive_downsample(). */
+ int levels = 1 + floor(log2(max_ii(tex->w, tex->h)));
+ GPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex->format);
+ for (int i = 1; i < levels; ++i) {
+ GPU_texture_add_mipmap(tex, data_format, i, NULL);
+ }
+ glBindTexture(tex->target, tex->bindcode);
+ }
+ else {
+ glGenerateMipmap(tex->target_base);
+ }
}
void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare)