[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53037] trunk/blender/source/blender/gpu/ intern/gpu_draw.c: Attempted fix #33546: GPU mipmap generation is not working on some ATI cards,
Brecht Van Lommel
brechtvanlommel at pandora.be
Sat Dec 15 18:15:44 CET 2012
Revision: 53037
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53037
Author: blendix
Date: 2012-12-15 17:15:42 +0000 (Sat, 15 Dec 2012)
Log Message:
-----------
Attempted fix #33546: GPU mipmap generation is not working on some ATI cards,
causing textures to be missing in textured draw mode. There is apparently a bug
in the ATI drivers, committed a workaround for that now.
http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation
Modified Paths:
--------------
trunk/blender/source/blender/gpu/intern/gpu_draw.c
Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_draw.c 2012-12-15 16:35:00 UTC (rev 53036)
+++ trunk/blender/source/blender/gpu/intern/gpu_draw.c 2012-12-15 17:15:42 UTC (rev 53037)
@@ -252,6 +252,25 @@
}
}
+static void gpu_generate_mipmap(GLenum target)
+{
+ int is_ati = GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY);
+ int target_enabled = 0;
+
+ /* work around bug in ATI driver, need to have GL_TEXTURE_2D enabled
+ * http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation */
+ if (is_ati) {
+ target_enabled = glIsEnabled(target);
+ if (!target_enabled)
+ glEnable(target);
+ }
+
+ glGenerateMipmapEXT(target);
+
+ if (is_ati && !target_enabled)
+ glDisable(target);
+}
+
void GPU_set_mipmap(int mipmap)
{
if (GTS.domipmap != (mipmap != 0)) {
@@ -691,7 +710,7 @@
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix);
- glGenerateMipmapEXT(GL_TEXTURE_2D);
+ gpu_generate_mipmap(GL_TEXTURE_2D);
}
else {
if (use_high_bit_depth)
@@ -934,7 +953,7 @@
/* we have already accounted for the case where GTS.gpu_mipmap is false
* so we will be using GPU mipmap generation here */
if (GPU_get_mipmap()) {
- glGenerateMipmapEXT(GL_TEXTURE_2D);
+ gpu_generate_mipmap(GL_TEXTURE_2D);
}
else {
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
@@ -959,7 +978,7 @@
/* see comment above as to why we are using gpu mipmap generation here */
if (GPU_get_mipmap()) {
- glGenerateMipmapEXT(GL_TEXTURE_2D);
+ gpu_generate_mipmap(GL_TEXTURE_2D);
}
else {
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
More information about the Bf-blender-cvs
mailing list