Commit: 3e61478b1be7b11b11fbccc37d6d64c99f354717
Author: Antony Riakiotakis
Date:   Tue Dec 16 21:52:55 2014 +0100
Branches: master
https://developer.blender.org/rB3e61478b1be7b11b11fbccc37d6d64c99f354717

Fix T42917 shadow maps not working on ATIs.

This is yet another issue with framebuffers. There are two issues: We
need the framebuffer fully bound to check for completeness and when we
bind a depth texture as frame buffer we need to disable read/write.

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

M       source/blender/gpu/intern/gpu_extensions.c
M       source/blender/gpu/intern/gpu_material.c

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

diff --git a/source/blender/gpu/intern/gpu_extensions.c 
b/source/blender/gpu/intern/gpu_extensions.c
index e386869..05c40d6 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -969,10 +969,16 @@ void GPU_texture_bind_as_framebuffer(GPUTexture *tex)
        /* bind framebuffer */
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, tex->fb->object);
 
-       /* last bound prevails here, better allow explicit control here too */
-       glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + tex->fb_attachment);
-       glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + tex->fb_attachment);
-
+       if (tex->depth) {
+               glDrawBuffer(GL_NONE);
+               glReadBuffer(GL_NONE);
+       }
+       else {
+               /* last bound prevails here, better allow explicit control here 
too */
+               glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + tex->fb_attachment);
+               glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + tex->fb_attachment);
+       }
+       
        /* push matrices and set default viewport and matrix */
        glViewport(0, 0, tex->w, tex->h);
        GG.currentfb = tex->fb->object;
diff --git a/source/blender/gpu/intern/gpu_material.c 
b/source/blender/gpu/intern/gpu_material.c
index 31b499d..fcf3425 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1953,10 +1953,15 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object 
*ob, Object *par)
                                return lamp;
                        }
                        
+                       /* we need to properly bind to test for completeness */
+                       GPU_texture_bind_as_framebuffer(lamp->blurtex);
+                       
                        if (!GPU_framebuffer_check_valid(lamp->blurfb, NULL)) {
                                gpu_lamp_shadow_free(lamp);
-                               return lamp;                            
-                       }                       
+                               return lamp;
+                       }
+                       
+                       GPU_framebuffer_texture_unbind(lamp->blurfb, 
lamp->blurtex);
                }
                else {
                        lamp->tex = GPU_texture_create_depth(lamp->size, 
lamp->size, NULL);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to