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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user