[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53609] trunk/blender/source/blender/ editors/space_view3d/view3d_draw.c: Slight modification of viewport sky: Avoid clearing the colour buffer

Xavier Thomas xavier.thomas.1980 at gmail.com
Mon Jan 7 20:59:11 CET 2013


I recently red from
http://blogs.unity3d.com/2012/08/13/unity-talk-at-siggraph-mobile-2012/ that
not clearing is not an optimization. In fact, on many tilled based hardware
(mobile), not clearing a render target before drawing in it will cause the
GPU to fetch back data from RAM to the on chip memory (slow). When
clearing, the firmware knows that old values are not needed and can avoid
to read from RAM. After that, filling the buffer is quick for on chip
memory.



2013/1/6 Antony Riakiotakis <kalast at gmail.com>

> Revision: 53609
>
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53609
> Author:   psy-fi
> Date:     2013-01-06 17:06:13 +0000 (Sun, 06 Jan 2013)
> Log Message:
> -----------
> Slight modification of viewport sky: Avoid clearing the colour buffer
> since we fill it later anyway. Usually OpenGL does color + depth buffer
> concurrently so this probably won't have any noticable effect. Still
> better be pedantic about it in case we do earn some performance out of
> it. Added alpha component in sky color to make sure it is set to zero in
> the framebuffer too.
>
> Modified Paths:
> --------------
>     trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
>
> Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
> ===================================================================
> --- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
> 2013-01-06 16:45:10 UTC (rev 53608)
> +++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
> 2013-01-06 17:06:13 UTC (rev 53609)
> @@ -3000,7 +3000,7 @@
>  #define XTOT 16
>  #define YTOT 16
>
> -                       GLubyte grid_col[XTOT][YTOT][3];
> +                       GLubyte grid_col[XTOT][YTOT][4];
>                         float   grid_pos[XTOT][YTOT][2];
>
>
> IMB_colormanagement_pixel_to_display_space_v3(col_hor, &scene->world->horr,
> &scene->view_settings,
> @@ -3008,8 +3008,7 @@
>
> IMB_colormanagement_pixel_to_display_space_v3(col_zen, &scene->world->zenr,
> &scene->view_settings,
>
> &scene->display_settings);
>
> -                       glClearColor(col_hor[0], col_hor[1], col_hor[2],
> 0.0);
> -                       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
> +                       glClear(GL_DEPTH_BUFFER_BIT);
>
>                         glMatrixMode(GL_PROJECTION);
>                         glPushMatrix();
> @@ -3058,19 +3057,20 @@
>                                         interp_v3_v3v3(col_fl, col_hor,
> col_zen, col_fac);
>
>                                         rgb_float_to_uchar(col_ub, col_fl);
> +                                       col_ub[3] = 0;
>                                 }
>                         }
>
>                         glBegin(GL_QUADS);
>                         for (x = 0; x < XTOT - 1; x++) {
>                                 for (y = 0; y < YTOT - 1; y++) {
> -                                       glColor3ubv(grid_col[x][y]);
> +                                       glColor4ubv(grid_col[x][y]);
>                                         glVertex2fv(grid_pos[x][y]);
> -                                       glColor3ubv(grid_col[x][y + 1]);
> +                                       glColor4ubv(grid_col[x][y + 1]);
>                                         glVertex2fv(grid_pos[x][y + 1]);
> -                                       glColor3ubv(grid_col[x + 1][y +
> 1]);
> +                                       glColor4ubv(grid_col[x + 1][y +
> 1]);
>                                         glVertex2fv(grid_pos[x + 1][y +
> 1]);
> -                                       glColor3ubv(grid_col[x + 1][y]);
> +                                       glColor4ubv(grid_col[x + 1][y]);
>                                         glVertex2fv(grid_pos[x + 1][y]);
>                                 }
>                         }
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>


More information about the Bf-committers mailing list