Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / DerivedMesh.c
index bcc3b60b34e38c401ef64491acf72dc113f7c35c..d590a35bb578b2f33cea5f3d222329637eb66ecc 100644 (file)
@@ -2003,15 +2003,10 @@ static void mesh_calc_modifiers(
                                        DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
                                        DM_add_poly_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
 
-#pragma omp parallel sections if (dm->numVertData + dm->numEdgeData + dm->numPolyData >= BKE_MESH_OMP_LIMIT)
-                                       {
-#pragma omp section
-                                               { range_vn_i(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0); }
-#pragma omp section
-                                               { range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0); }
-#pragma omp section
-                                               { range_vn_i(DM_get_poly_data_layer(dm, CD_ORIGINDEX), dm->numPolyData, 0); }
-                                       }
+                                       /* Not worth parallelizing this, gives less than 0.1% overall speedup in best of best cases... */
+                                       range_vn_i(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0);
+                                       range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0);
+                                       range_vn_i(DM_get_poly_data_layer(dm, CD_ORIGINDEX), dm->numPolyData, 0);
                                }
                        }
 
@@ -3269,17 +3264,18 @@ void DM_calc_loop_tangents_step_0(
         bool *rcalc_act, bool *rcalc_ren, int *ract_uv_n, int *rren_uv_n,
         char *ract_uv_name, char *rren_uv_name, char *rtangent_mask) {
        /* Active uv in viewport */
+       int layer_index = CustomData_get_layer_index(loopData, CD_MLOOPUV);
        *ract_uv_n = CustomData_get_active_layer(loopData, CD_MLOOPUV);
        ract_uv_name[0] = 0;
        if (*ract_uv_n != -1) {
-               strcpy(ract_uv_name, loopData->layers[*ract_uv_n].name);
+               strcpy(ract_uv_name, loopData->layers[*ract_uv_n + layer_index].name);
        }
 
        /* Active tangent in render */
        *rren_uv_n = CustomData_get_render_layer(loopData, CD_MLOOPUV);
        rren_uv_name[0] = 0;
        if (*rren_uv_n != -1) {
-               strcpy(rren_uv_name, loopData->layers[*rren_uv_n].name);
+               strcpy(rren_uv_name, loopData->layers[*rren_uv_n + layer_index].name);
        }
 
        /* If active tangent not in tangent_names we take it into account */
@@ -3677,6 +3673,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                        }
 
                        attribs->tface[a].gl_index = gattribs->layer[b].glindex;
+                       attribs->tface[a].gl_info_index = gattribs->layer[b].glinfoindoex;
                        attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
                }
                else if (type == CD_MCOL) {
@@ -3700,6 +3697,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                        }
 
                        attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
+                       attribs->mcol[a].gl_info_index = gattribs->layer[b].glinfoindoex;
                }
                else if (type == CD_TANGENT) {
                        /* note, even with 'is_editmesh' this uses the derived-meshes loop data */
@@ -3722,6 +3720,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                        }
 
                        attribs->tang[a].gl_index = gattribs->layer[b].glindex;
+                       attribs->tang[a].gl_info_index = gattribs->layer[b].glinfoindoex;
                }
                else if (type == CD_ORCO) {
                        /* original coordinates */
@@ -3741,6 +3740,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
 
                        attribs->orco.gl_index = gattribs->layer[b].glindex;
                        attribs->orco.gl_texco = gattribs->layer[b].gltexco;
+                       attribs->orco.gl_info_index = gattribs->layer[b].glinfoindoex;
                }
        }
 }
@@ -3769,6 +3769,7 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert,
                        glTexCoord3fv(orco);
                else
                        glVertexAttrib3fv(attribs->orco.gl_index, orco);
+               glUniform1i(attribs->orco.gl_info_index, 0);
        }
 
        /* uv texture coordinates */
@@ -3787,6 +3788,7 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert,
                        glTexCoord2fv(uv);
                else
                        glVertexAttrib2fv(attribs->tface[b].gl_index, uv);
+               glUniform1i(attribs->tface[b].gl_info_index, 0);
        }
 
        /* vertex colors */
@@ -3802,6 +3804,7 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert,
                }
 
                glVertexAttrib4fv(attribs->mcol[b].gl_index, col);
+               glUniform1i(attribs->mcol[b].gl_info_index, GPU_ATTR_INFO_SRGB);
        }
 
        /* tangent for normal mapping */
@@ -3811,6 +3814,7 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert,
                        const float *tang = (array) ? array[a * 4 + vert] : zero;
                        glVertexAttrib4fv(attribs->tang[b].gl_index, tang);
                }
+               glUniform1i(attribs->tang[b].gl_info_index, 0);
        }
 }