Currently UV maps and tangents are referenced by custom data layer index by the mesh extraction system that decides what attributes are needed on the GPU for rendering. This system is closely tied to CustomData, and adds a limit on 8 total UV maps on the mesh (crucially different than a limit on the supported UV map count for rendering). The process of detecting which attributes to upload is also directly tied to CustomData. In particular, `mesh_cd_calc_used_gpu_layers` is quite complicated. This commit reimplements that function, and references used UV maps and UV tangents by name rather than by index. The process is now mostly separated from `CustomData`, which is important as Mesh moves to `AttributeStorage` instead. Overall I noticed this introduces some overhead (a few percent cost to playback in some extreme cases). `DRW_MeshCDMask` is bigger than before (it was just an integer), and the attribute API currently has some overhead that can be removed when it's backed by `AttributeStorage`. The change still feels worth it to me, given other opportunities for optimization in this area. Ref #122398 Pull Request: https://projects.blender.org/blender/blender/pulls/141467
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup draw
|
|
*
|
|
* \brief Utilities for rendering attributes.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "BLI_string_ref.hh"
|
|
#include "BLI_struct_equality_utils.hh"
|
|
#include "BLI_sys_types.h"
|
|
|
|
#include "BLI_vector_set.hh"
|
|
|
|
namespace blender::bke {
|
|
enum class AttrDomain : int8_t;
|
|
}
|
|
|
|
namespace blender::draw {
|
|
|
|
struct DRW_MeshCDMask {
|
|
VectorSet<std::string> uv;
|
|
VectorSet<std::string> tan;
|
|
bool orco = false;
|
|
bool tan_orco = false;
|
|
bool sculpt_overlays = false;
|
|
bool edit_uv = false;
|
|
BLI_STRUCT_EQUALITY_OPERATORS_6(
|
|
DRW_MeshCDMask, uv.as_span(), uv.as_span(), orco, tan_orco, sculpt_overlays, edit_uv);
|
|
void clear()
|
|
{
|
|
uv.clear_and_keep_capacity();
|
|
tan.clear_and_keep_capacity();
|
|
orco = false;
|
|
tan_orco = false;
|
|
sculpt_overlays = false;
|
|
edit_uv = false;
|
|
}
|
|
};
|
|
|
|
void drw_attributes_merge(VectorSet<std::string> *dst, const VectorSet<std::string> *src);
|
|
|
|
/* Return true if all requests in b are in a. */
|
|
bool drw_attributes_overlap(const VectorSet<std::string> *a, const VectorSet<std::string> *b);
|
|
|
|
void drw_attributes_add_request(VectorSet<std::string> *attrs, StringRef name);
|
|
|
|
} // namespace blender::draw
|