Fix #19669 and other: triple buffer & icon texture drawing could cause
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 19 Oct 2009 10:10:05 +0000 (10:10 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 19 Oct 2009 10:10:05 +0000 (10:10 +0000)
a system crash and other issues on ATI/Apple, due to a buggy driver
(similar issues reported for other OpenGL applications). For now, work
around it by not using non-power-of-two textures on this combination.

source/blender/editors/interface/interface_icons.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/drawvolume.c
source/blender/gpu/GPU_extensions.h
source/blender/gpu/intern/gpu_extensions.c
source/blender/windowmanager/intern/wm_draw.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.cpp

index 1153c475339c020fdbfe492bc5fc754bc34ad9fa..7648c9412b771a78142b944606e436da44ed9ea4 100644 (file)
@@ -489,7 +489,7 @@ static void init_internal_icons()
                }
 
                /* we only use a texture for cards with non-power of two */
-               if(GLEW_ARB_texture_non_power_of_two) {
+               if(GPU_non_power_of_two_support()) {
                        glGenTextures(1, &icongltex.id);
 
                        if(icongltex.id) {
index d2988772abe8ad729c1ecfcae4377e0ac5b10127..0688f9b5e0e4087aea7cff527fcafb19c3b7e2d6 100644 (file)
@@ -212,7 +212,7 @@ static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr)
 
 int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
 {
-       if(!GPU_extensions_minimum_support())
+       if(!GPU_glsl_support())
                return 0;
        if(G.f & G_PICKSEL)
                return 0;
index ef3627e2b12de3cea2151eed1f2c628e6deebe4b..ea022d1b670faf4fde9feb0a3f1a7da6b3505698 100644 (file)
@@ -349,7 +349,7 @@ void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture
        else
                printf("No volume shadow\n");
 
-       if (!GLEW_ARB_texture_non_power_of_two) {
+       if (!GPU_non_power_of_two_support()) {
                cor[0] = (float)res[0]/(float)larger_pow2(res[0]);
                cor[1] = (float)res[1]/(float)larger_pow2(res[1]);
                cor[2] = (float)res[2]/(float)larger_pow2(res[2]);
index e00cab79ce06176e76b620425ceaa1961bf45abd..a910ff9c3e7f1fcd47d55154f21153f6754462b3 100644 (file)
@@ -54,7 +54,8 @@ typedef struct GPUShader GPUShader;
 void GPU_extensions_disable(void);
 void GPU_extensions_init(void); /* call this before running any of the functions below */
 void GPU_extensions_exit(void);
-int GPU_extensions_minimum_support(void);
+int GPU_glsl_support(void);
+int GPU_non_power_of_two_support(void);
 int GPU_print_error(char *str);
 
 /* GPU Texture
index 55e4b337a772f5b11b8a6a38137602a64c02b498..52a6b0dd1e8daca7c1ff668079620bb64dbe3d82 100644 (file)
@@ -69,7 +69,7 @@
 static struct GPUGlobal {
        GLint maxtextures;
        GLuint currentfb;
-       int minimumsupport;
+       int glslsupport;
        int extdisabled;
 } GG = {1, 0, 0, 0};
 
@@ -87,15 +87,27 @@ void GPU_extensions_init()
        if (GLEW_ARB_multitexture)
                glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &GG.maxtextures);
 
-       GG.minimumsupport = 1;
-       if (!GLEW_ARB_multitexture) GG.minimumsupport = 0;
-       if (!GLEW_ARB_vertex_shader) GG.minimumsupport = 0;
-       if (!GLEW_ARB_fragment_shader) GG.minimumsupport = 0;
+       GG.glslsupport = 1;
+       if (!GLEW_ARB_multitexture) GG.glslsupport = 0;
+       if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0;
+       if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0;
 }
 
-int GPU_extensions_minimum_support()
+int GPU_glsl_support()
 {
-       return !GG.extdisabled && GG.minimumsupport;
+       return !GG.extdisabled && GG.glslsupport;
+}
+
+int GPU_non_power_of_two_support()
+{
+       /* Exception for buggy ATI/Apple driver in Mac OS X 10.5/10.6,
+        * they claim to support this but can cause system freeze */
+#ifdef __APPLE__
+       if(strcmp(glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0)
+               return 0;
+#endif
+
+       return GLEW_ARB_texture_non_power_of_two;
 }
 
 int GPU_print_error(char *str)
@@ -231,7 +243,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
                return NULL;
        }
 
-       if (!GLEW_ARB_texture_non_power_of_two) {
+       if (!GPU_non_power_of_two_support()) {
                tex->w = larger_pow2(tex->w);
                tex->h = larger_pow2(tex->h);
        }
@@ -337,7 +349,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
                return NULL;
        }
 
-       if (!GLEW_ARB_texture_non_power_of_two) {
+       if (!GPU_non_power_of_two_support()) {
                tex->w = larger_pow2(tex->w);
                tex->h = larger_pow2(tex->h);
                tex->depth = larger_pow2(tex->depth);
index 1df567e3c923e39ad58a78fd2c0fafea3628ff38..93ecd4076a3eb013d69c131b97e9c85d7a6b9767 100644 (file)
@@ -376,7 +376,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
                triple->x[0]= win->sizex;
                triple->y[0]= win->sizey;
        }
-       else if(GLEW_ARB_texture_non_power_of_two) {
+       else if(GPU_non_power_of_two_support()) {
                triple->target= GL_TEXTURE_2D;
                triple->nx= 1;
                triple->ny= 1;
index df7f35d777317261cc9da66147c91da3ea669f7d..ca5faf00bb674b918d9af20bf0ecd0ef869aebcf 100644 (file)
@@ -356,7 +356,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
                        if(GLEW_ARB_multitexture && GLEW_VERSION_1_1)
                                usemat = true;
 
-                       if(GPU_extensions_minimum_support())
+                       if(GPU_glsl_support())
                                useglslmat = true;
                        else if(blscene->gm.matmode == GAME_MAT_GLSL)
                                usemat = false;
index 3c989293c948686473ffd1ca7cfd5b93ce42b249..e771d12988c2da5ee55792d6e900770b59bf7018 100644 (file)
@@ -539,7 +539,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
                if(GLEW_ARB_multitexture && GLEW_VERSION_1_1)
                        m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0);
 
-               if(GPU_extensions_minimum_support())
+               if(GPU_glsl_support())
                        m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0);
                else if(gm->matmode == GAME_MAT_GLSL)
                        m_blendermat = false;