[Bf-blender-cvs] [3c2a2a6c965] master: Cleanup: Always store attribute name in attribute request

Hans Goudey noreply at git.blender.org
Sat Jun 18 11:49:13 CEST 2022


Commit: 3c2a2a6c9659dd66f1a1d3a5e4153d1d2f8243eb
Author: Hans Goudey
Date:   Sat Jun 18 11:48:51 2022 +0200
Branches: master
https://developer.blender.org/rB3c2a2a6c9659dd66f1a1d3a5e4153d1d2f8243eb

Cleanup: Always store attribute name in attribute request

Previously the attribute name was only stored in the request for curves.
Instead, pass it as part of the "add request" function, so that it is
always used. Since the whole attribute pipeline is name-based,
this can simplify code in a few places.

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

M	source/blender/draw/intern/draw_attributes.cc
M	source/blender/draw/intern/draw_attributes.h
M	source/blender/draw/intern/draw_cache_impl_curves.cc
M	source/blender/draw/intern/draw_cache_impl_mesh.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc

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

diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc
index 8fb4210901f..3f187aef8e6 100644
--- a/source/blender/draw/intern/draw_attributes.cc
+++ b/source/blender/draw/intern/draw_attributes.cc
@@ -65,9 +65,10 @@ bool drw_attributes_overlap(const DRW_Attributes *a, const DRW_Attributes *b)
 }
 
 DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs,
-                                                 eCustomDataType type,
-                                                 int layer,
-                                                 eAttrDomain domain)
+                                                 const char *name,
+                                                 const eCustomDataType type,
+                                                 const int layer_index,
+                                                 const eAttrDomain domain)
 {
   if (attrs->num_requests >= GPU_MAX_ATTR) {
     return nullptr;
@@ -75,7 +76,8 @@ DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs,
 
   DRW_AttributeRequest *req = &attrs->requests[attrs->num_requests];
   req->cd_type = type;
-  req->layer_index = layer;
+  BLI_strncpy(req->attribute_name, name, sizeof(req->attribute_name));
+  req->layer_index = layer_index;
   req->domain = domain;
   attrs->num_requests += 1;
   return req;
diff --git a/source/blender/draw/intern/draw_attributes.h b/source/blender/draw/intern/draw_attributes.h
index 4f82f3b94e9..b577c6c4162 100644
--- a/source/blender/draw/intern/draw_attributes.h
+++ b/source/blender/draw/intern/draw_attributes.h
@@ -46,8 +46,9 @@ void drw_attributes_merge(DRW_Attributes *dst,
 bool drw_attributes_overlap(const DRW_Attributes *a, const DRW_Attributes *b);
 
 DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs,
-                                                 eCustomDataType type,
-                                                 int layer,
+                                                 const char *name,
+                                                 eCustomDataType data_type,
+                                                 int layer_index,
                                                  eAttrDomain domain);
 
 bool drw_custom_data_match_attribute(const CustomData *custom_data,
diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc
index 6e2b7bc758c..ee81f74ca26 100644
--- a/source/blender/draw/intern/draw_cache_impl_curves.cc
+++ b/source/blender/draw/intern/draw_cache_impl_curves.cc
@@ -529,11 +529,7 @@ static bool curves_ensure_attributes(const Curves &curves,
       continue;
     }
 
-    DRW_AttributeRequest *request = drw_attributes_add_request(
-        &attrs_needed, type, layer_index, domain);
-    if (request) {
-      BLI_strncpy(request->attribute_name, name, sizeof(request->attribute_name));
-    }
+    drw_attributes_add_request(&attrs_needed, name, type, layer_index, domain);
   }
 
   CurvesEvalFinalCache &final_cache = cache.curves_cache.final[subdiv];
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc
index 7c02ee2c033..e93b1a66b66 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc
@@ -574,7 +574,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
             }
 
             if (layer != -1 && domain.has_value()) {
-              drw_attributes_add_request(attributes, type, layer, *domain);
+              drw_attributes_add_request(attributes, name, type, layer, *domain);
             }
             break;
           }
@@ -585,7 +585,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
           case CD_PROP_FLOAT:
           case CD_PROP_FLOAT2: {
             if (layer != -1 && domain.has_value()) {
-              drw_attributes_add_request(attributes, type, layer, *domain);
+              drw_attributes_add_request(attributes, name, type, layer, *domain);
             }
             break;
           }
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc
index fb6b5e1904b..c8fb677c5ac 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc
@@ -132,11 +132,8 @@ static void init_vbo_for_attribute(const MeshRenderData *mr,
   /* We should not be here if the attribute type is not supported. */
   BLI_assert(comp_size != 0);
 
-  const CustomData *custom_data = get_custom_data_for_domain(mr, request.domain);
   char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
-  const char *layer_name = CustomData_get_layer_name(
-      custom_data, request.cd_type, request.layer_index);
-  GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
+  GPU_vertformat_safe_attr_name(request.attribute_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
   /* Attributes use auto-name. */
   BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);



More information about the Bf-blender-cvs mailing list