Commit: d64b1221c67846bb954855a19c8dd093b83adc8e
Author: Joe Eagar
Date:   Sun Sep 13 14:51:36 2015 -0700
Branches: master
https://developer.blender.org/rBd64b1221c67846bb954855a19c8dd093b83adc8e

Fix crash in opengl render caused by gfx being blacklisted for
non-power-of-2 texture support.  Note that all I did was pass
the correct width/height into glReadPixels; the result may not
be the same as if non2 textures were enabled.

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

M       source/blender/editors/render/render_opengl.c
M       source/blender/gpu/GPU_extensions.h
M       source/blender/gpu/intern/gpu_extensions.c

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

diff --git a/source/blender/editors/render/render_opengl.c 
b/source/blender/editors/render/render_opengl.c
index c718dfa..1654382 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -324,7 +324,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, 
RenderResult *rr)
                        G.f &= ~G_RENDER_OGL;
 
                        gp_rect = MEM_mallocN(sizex * sizey * sizeof(unsigned 
char) * 4, "offscreen rect");
-                       GPU_offscreen_read_pixels(oglrender->ofs, 
GL_UNSIGNED_BYTE, gp_rect);
+                       GPU_offscreen_read_pixels_wh(oglrender->ofs, sizex, 
sizey, GL_UNSIGNED_BYTE, gp_rect);
 
                        BLI_assert(rectf != NULL);
 
@@ -380,7 +380,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, 
RenderResult *rr)
                                scene, v3d, ar, sizex, sizey, NULL, winmat,
                                draw_bgpic, draw_sky, is_persp,
                                oglrender->ofs, oglrender->fx, &fx_settings, 
viewname);
-                       GPU_offscreen_read_pixels(oglrender->ofs, 
GL_UNSIGNED_BYTE, rect);
+                       GPU_offscreen_read_pixels_wh(oglrender->ofs, sizex, 
sizey, GL_UNSIGNED_BYTE, rect);
                }
                else {
                        /* simple accumulation, less hassle then FSAA FBO's */
@@ -396,7 +396,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, 
RenderResult *rr)
                                scene, v3d, ar, sizex, sizey, NULL, winmat,
                                draw_bgpic, draw_sky, is_persp,
                                oglrender->ofs, oglrender->fx, &fx_settings, 
viewname);
-                       GPU_offscreen_read_pixels(oglrender->ofs, 
GL_UNSIGNED_BYTE, rect);
+                       GPU_offscreen_read_pixels_wh(oglrender->ofs, sizex, 
sizey, GL_UNSIGNED_BYTE, rect);
 
                        for (i = 0; i < sizex * sizey * 4; i++)
                                accum_buffer[i] = rect[i];
@@ -412,7 +412,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, 
RenderResult *rr)
                                        scene, v3d, ar, sizex, sizey, NULL, 
winmat_jitter,
                                        draw_bgpic, draw_sky, is_persp,
                                        oglrender->ofs, oglrender->fx, 
&fx_settings, viewname);
-                               GPU_offscreen_read_pixels(oglrender->ofs, 
GL_UNSIGNED_BYTE, rect);
+                               GPU_offscreen_read_pixels_wh(oglrender->ofs, 
sizex, sizey, GL_UNSIGNED_BYTE, rect);
 
                                for (i = 0; i < sizex * sizey * 4; i++)
                                        accum_buffer[i] += rect[i];
diff --git a/source/blender/gpu/GPU_extensions.h 
b/source/blender/gpu/GPU_extensions.h
index f3927ba..3a668c3 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -184,6 +184,8 @@ void GPU_offscreen_free(GPUOffScreen *ofs);
 void GPU_offscreen_bind(GPUOffScreen *ofs, bool save);
 void GPU_offscreen_unbind(GPUOffScreen *ofs, bool restore);
 void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels);
+void GPU_offscreen_read_pixels_wh(GPUOffScreen *ofs, int width, int height, 
int type, void *pixels);
+
 int GPU_offscreen_width(const GPUOffScreen *ofs);
 int GPU_offscreen_height(const GPUOffScreen *ofs);
 
diff --git a/source/blender/gpu/intern/gpu_extensions.c 
b/source/blender/gpu/intern/gpu_extensions.c
index a6a3429..e69c74b 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -1473,6 +1473,12 @@ void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int 
type, void *pixels)
        glReadPixels(0, 0, ofs->color->w, ofs->color->h, GL_RGBA, type, pixels);
 }
 
+//if non power of two textures are not supported, than ofs->w/h may not be 
same size as allocated *pixels
+void GPU_offscreen_read_pixels_wh(GPUOffScreen *ofs, int width, int height, 
int type, void *pixels)
+{
+       glReadPixels(0, 0, width, height, GL_RGBA, type, pixels);
+}
+
 int GPU_offscreen_width(const GPUOffScreen *ofs)
 {
        return ofs->color->w;

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

Reply via email to