Revision: 48427
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48427
Author:   jwilkins
Date:     2012-06-30 07:43:37 +0000 (Sat, 30 Jun 2012)
Log Message:
-----------
OpenGL Regression Fixes: Thanks to Jorge Bernal on Blender Artists.

Modified Paths:
--------------
    
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/cdderivedmesh.c
    
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/editderivedmesh.c
    branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h
    
branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_widgets.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/view2d.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_text/text_draw.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawanimviz.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawobject.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_draw.c
    
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_fly.c
    branches/soc-2012-swiss_cheese/source/blender/editors/uvedit/uvedit_draw.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/WM_api.h
    
branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c
    
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp

Modified: 
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/cdderivedmesh.c 
    2012-06-30 05:35:40 UTC (rev 48426)
+++ 
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/cdderivedmesh.c 
    2012-06-30 07:43:37 UTC (rev 48427)
@@ -941,7 +941,6 @@
                        
                        if (nors) nors += 3;
                }
-               gpuImmediateUnformat();
        }
        else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster 
rendering */
                int prevstart = 0;
@@ -1058,7 +1057,7 @@
                        texco = GL_TRUE;
                else {
                        attribMap_f[attrib_f] = attribs->tface[b].gl_index;
-                       attribSize_f[attrib_f] = 3;
+                       attribSize_f[attrib_f] = 2;
                        attrib_f++;
                }
        }
@@ -1175,7 +1174,7 @@
                DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n");
                memset(&attribs, 0, sizeof(attribs));
 
-               cddm_format_attrib_vertex(&attribs);
+               cddm_format_attrib_vertex(&attribs); /* XXX: jwilkins, just to 
make this simple to write for now */
                gpuBegin(GL_QUADS);
 
                for (a = 0; a < dm->numTessFaceData; a++, mface++) {

Modified: 
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/editderivedmesh.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/editderivedmesh.c
   2012-06-30 05:35:40 UTC (rev 48426)
+++ 
branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/editderivedmesh.c
   2012-06-30 07:43:37 UTC (rev 48427)
@@ -987,6 +987,64 @@
        emDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, 
userData);
 }
 
+static emdm_format_attrib_vertex(DMVertexAttribs *attribs)
+{
+       int b;
+       GLint attribMap_f[16];
+       GLint attribSize_f[16];
+       GLint attrib_f = 0;
+       GLint attribMap_ub[16];
+       GLint attribSize_ub[16];
+       GLint attrib_ub = 0;
+
+       /* orco texture coordinates */
+       if (attribs->totorco) {
+               attribMap_f[attrib_f] = attribs->orco.gl_index;
+               attribSize_f[attrib_f] = 3;
+               attrib_f++;
+       }
+
+       /* uv texture coordinates */
+       for (b = 0; b < attribs->tottface; b++) {
+               attribMap_f[attrib_f] = attribs->tface[b].gl_index;
+               attribSize_f[attrib_f] = 2;
+               attrib_f++;
+       }
+
+       /* vertex colors */
+       for (b = 0; b < attribs->totmcol; b++) {
+               attribMap_ub[attrib_ub] = attribs->mcol[b].gl_index;
+               attribSize_ub[attrib_ub] = 4;
+               attrib_ub++;
+       }
+
+       /* tangent for normal mapping */
+       if (attribs->tottang) {
+               attribMap_f[attrib_f] = attribs->tang.gl_index;
+               attribSize_f[attrib_f] = 3;
+               attrib_f++;
+       }
+
+       gpuImmediateFormatReset();
+
+       gpuImmediateElementSizes(3, 3, 0);
+
+       gpuImmediateFloatAttribCount(attrib_f);
+       gpuImmediateFloatAttribIndexMap(attribMap_f);
+       gpuImmediateFloatAttribSizes(attribSize_f);
+
+       gpuImmediateUbyteAttribCount(attrib_ub);
+       gpuImmediateUbyteAttribIndexMap(attribMap_ub);
+       gpuImmediateUbyteAttribSizes(attribMap_ub);
+
+       gpuImmediateLock();
+}
+
+static void emdm_unformat_attrib_vertex(void)
+{
+       gpuImmediateUnlock();
+}
+
 static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
                                      DMSetMaterial setMaterial,
                                      DMSetDrawOptions setDrawOptions,
@@ -1009,6 +1067,8 @@
 
        memset(&attribs, 0, sizeof(attribs));
 
+       emdm_format_attrib_vertex(&attribs); /* XXX: jwilkins, just to make 
this easy to write for now */
+
        /* always use smooth shading even for flat faces, else vertex colors 
wont interpolate */
        glShadeModel(GL_SMOOTH);
        BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
@@ -1049,8 +1109,13 @@
                new_matnr = efa->mat_nr + 1;
                if (new_matnr != matnr) {
                        do_draw = setMaterial(matnr = new_matnr, &gattribs);
-                       if (do_draw)
+                       if (do_draw) {
+                               emdm_unformat_attrib_vertex();
+
                                DM_vertex_attributes_from_gpu(dm, &gattribs, 
&attribs);
+
+                               emdm_format_attrib_vertex(&attribs);
+                       }
                }
 
                if (do_draw) {
@@ -1105,6 +1170,8 @@
                        gpuEnd();
                }
        }
+
+       emdm_unformat_attrib_vertex();
 #undef PASSATTRIB
 }
 

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h    
    2012-06-30 05:35:40 UTC (rev 48426)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/include/UI_resources.h    
    2012-06-30 07:43:37 UTC (rev 48427)
@@ -244,6 +244,7 @@
 void    UI_ThemeAppendColorBlend(int colorid1, int colorid2, float fac);
 // same, with shade offset
 void    UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int 
offset);
+void    UI_ThemeAppendColorBlendShade(int colorid1, int colorid2, float fac, 
int offset);
 void    UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, 
int offset, int alphaoffset);
 
 // returns one value, not scaled

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_widgets.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_widgets.c
 2012-06-30 05:35:40 UTC (rev 48426)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_widgets.c
 2012-06-30 07:43:37 UTC (rev 48427)
@@ -2169,8 +2169,6 @@
        float rgb[3], hsv[3], v, range;
        int color_profile = but->block->color_profile;
 
-       gpuImmediateFormat_C4_V3();
-
        if (but->rnaprop && RNA_property_subtype(but->rnaprop) == 
PROP_COLOR_GAMMA)
                color_profile = BLI_PR_NONE;
 
@@ -2204,8 +2202,8 @@
        y = rect->ymin + v * (rect->ymax - rect->ymin);
        CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
 
+       gpuImmediateFormat_C4_V3();
        ui_hsv_cursor(x, y);
-
        gpuImmediateUnformat();
 }
 

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c 
2012-06-30 05:35:40 UTC (rev 48426)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/interface/resources.c 
2012-06-30 07:43:37 UTC (rev 48427)
@@ -1068,7 +1068,7 @@
 {
        int r, g, b;
        const unsigned char *cp1, *cp2;
-       
+
        cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
        cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
 
@@ -1076,15 +1076,36 @@
        r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
        g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
        b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
-       
+
        CLAMP(r, 0, 255);
        CLAMP(g, 0, 255);
        CLAMP(b, 0, 255);
-       
+
        gpuCurrentColor3ub(r, g, b);
 }
 
 // blend between to theme colors, shade it, and set it
+void UI_ThemeAppendColorBlendShade(int colorid1, int colorid2, float fac, int 
offset)
+{
+       int r, g, b;
+       const unsigned char *cp1, *cp2;
+
+       cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+       cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+
+       CLAMP(fac, 0.0f, 1.0f);
+       r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+       g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+       b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+
+       CLAMP(r, 0, 255);
+       CLAMP(g, 0, 255);
+       CLAMP(b, 0, 255);
+
+       gpuColor3ub(r, g, b);
+}
+
+// blend between to theme colors, shade it, and set it
 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int 
offset, int alphaoffset)
 {
        int r, g, b, a;

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/interface/view2d.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/interface/view2d.c    
2012-06-30 05:35:40 UTC (rev 48426)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/interface/view2d.c    
2012-06-30 07:43:37 UTC (rev 48427)
@@ -1336,6 +1336,8 @@
        float lstep = step;
        int level;
 
+       gpuImmediateFormat_V2();
+
        for (level = 0; level < totlevels; ++level) {
                int i;
                float start;
@@ -1376,6 +1378,8 @@
                lstep *= level_size;
                offset -= 6;
        }
+
+       gpuImmediateUnformat();
 }
 
 /* the price we pay for not exposting structs :( */

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/space_text/text_draw.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/space_text/text_draw.c    
    2012-06-30 05:35:40 UTC (rev 48426)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/space_text/text_draw.c    
    2012-06-30 07:43:37 UTC (rev 48427)
@@ -1387,6 +1387,8 @@
                x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
                y = ar->winy - 3;
 
+               gpuImmediateFormat_V2();
+
                if (y1 == y2) {
                        y -= y1 * st->lheight;
                        gpuBegin(GL_LINE_LOOP);
@@ -1423,6 +1425,8 @@
                        gpuVertex2i(x, y - st->lheight);
                        gpuEnd();
                }
+
+               gpuImmediateUnformat();
        }
 }
 
@@ -1464,6 +1468,7 @@
        UI_ThemeColor(TH_BACK);
        gpuSingleFilledRecti(x, y, x + boxw, y - boxh);
        UI_ThemeColor(TH_SHADE1);
+       gpuImmediateFormat_V2();
        gpuBegin(GL_LINE_LOOP);
        gpuVertex2i(x, y);
        gpuVertex2i(x + boxw, y);
@@ -1480,6 +1485,7 @@
        gpuVertex2i(x + boxw - 4, y - boxh + 7);
        gpuVertex2i(x + boxw - 7, y - boxh + 2);
        gpuEnd();
+       gpuImmediateUnformat();
        UI_ThemeColor(TH_TEXT);
 
        BLF_draw_lock(mono);
@@ -1965,10 +1971,12 @@
        if (st->flags & ST_SHOW_MARGIN) {
                UI_ThemeColor(TH_HILITE);
 
+               gpuImmediateFormat_V2();
                gpuBegin(GL_LINES);
                gpuVertex2i(x + st->cwidth * st->margin_column, 0);
                gpuVertex2i(x + st->cwidth * st->margin_column, ar->winy - 2);
                gpuEnd();
+               gpuImmediateUnformat();
        }
 
        /* draw other stuff */

Modified: 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawanimviz.c
===================================================================
--- 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawanimviz.c
    2012-06-30 05:35:40 UTC (rev 48426)
+++ 
branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawanimviz.c
    2012-06-30 07:43:37 UTC (rev 48427)
@@ -91,7 +91,9 @@
        bMotionPathVert *mpv, *mpv_start;
        int i, stepsize = avs->path_step;
        int sfra, efra, sind, len;
-       
+
+       gpuImmediateFormat_V3();
+
        /* get frame ranges */
        if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
                /* With "Around Current", we only choose frames from around 
@@ -105,7 +107,7 @@
                sfra = avs->path_sf;
                efra = avs->path_ef;
        }
-       
+
        /* no matter what, we can only show what is in the cache and no more 
         * - abort if whole range is past ends of path
         * - otherwise clamp endpoints to extents of path

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to