|
@@ -395,6 +395,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
|
|
|
|
|
if (new_surface.attribute_data.size()) {
|
|
|
s->attribute_buffer = RD::get_singleton()->vertex_buffer_create(new_surface.attribute_data.size(), new_surface.attribute_data);
|
|
|
+ s->attribute_buffer_size = new_surface.attribute_data.size();
|
|
|
}
|
|
|
if (new_surface.skin_data.size()) {
|
|
|
s->skin_buffer = RD::get_singleton()->vertex_buffer_create(new_surface.skin_data.size(), new_surface.skin_data, as_storage_flag);
|
|
@@ -411,6 +412,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
|
|
bool is_index_16 = new_surface.vertex_count <= 65536 && new_surface.vertex_count > 0;
|
|
|
|
|
|
s->index_buffer = RD::get_singleton()->index_buffer_create(new_surface.index_count, is_index_16 ? RD::INDEX_BUFFER_FORMAT_UINT16 : RD::INDEX_BUFFER_FORMAT_UINT32, new_surface.index_data, false);
|
|
|
+ s->index_buffer_size = new_surface.index_data.size();
|
|
|
s->index_count = new_surface.index_count;
|
|
|
s->index_array = RD::get_singleton()->index_array_create(s->index_buffer, 0, s->index_count);
|
|
|
if (new_surface.lods.size()) {
|
|
@@ -420,6 +422,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
|
|
for (int i = 0; i < new_surface.lods.size(); i++) {
|
|
|
uint32_t indices = new_surface.lods[i].index_data.size() / (is_index_16 ? 2 : 4);
|
|
|
s->lods[i].index_buffer = RD::get_singleton()->index_buffer_create(indices, is_index_16 ? RD::INDEX_BUFFER_FORMAT_UINT16 : RD::INDEX_BUFFER_FORMAT_UINT32, new_surface.lods[i].index_data);
|
|
|
+ s->lods[i].index_buffer_size = new_surface.lods[i].index_data.size();
|
|
|
s->lods[i].index_array = RD::get_singleton()->index_array_create(s->lods[i].index_buffer, 0, indices);
|
|
|
s->lods[i].edge_length = new_surface.lods[i].edge_length;
|
|
|
s->lods[i].index_count = indices;
|
|
@@ -437,6 +440,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
|
|
|
|
|
if (mesh->blend_shape_count > 0) {
|
|
|
s->blend_shape_buffer = RD::get_singleton()->storage_buffer_create(new_surface.blend_shape_data.size(), new_surface.blend_shape_data);
|
|
|
+ s->blend_shape_buffer_size = new_surface.blend_shape_data.size();
|
|
|
}
|
|
|
|
|
|
if (use_as_storage) {
|
|
@@ -917,6 +921,35 @@ void MeshStorage::mesh_surface_remove(RID p_mesh, int p_surface) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void MeshStorage::mesh_debug_usage(List<RS::MeshInfo> *r_info) {
|
|
|
+ for (const RID &mesh_rid : mesh_owner.get_owned_list()) {
|
|
|
+ Mesh *mesh = mesh_owner.get_or_null(mesh_rid);
|
|
|
+ if (!mesh) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ RS::MeshInfo mesh_info;
|
|
|
+ mesh_info.mesh = mesh_rid;
|
|
|
+ mesh_info.path = mesh->path;
|
|
|
+
|
|
|
+ for (uint32_t surface_index = 0; surface_index < mesh->surface_count; surface_index++) {
|
|
|
+ MeshStorage::Mesh::Surface *surface = mesh->surfaces[surface_index];
|
|
|
+
|
|
|
+ mesh_info.vertex_buffer_size += surface->vertex_buffer_size;
|
|
|
+ mesh_info.attribute_buffer_size += surface->attribute_buffer_size;
|
|
|
+ mesh_info.skin_buffer_size += surface->skin_buffer_size;
|
|
|
+ mesh_info.index_buffer_size += surface->index_buffer_size;
|
|
|
+ mesh_info.blend_shape_buffer_size += surface->blend_shape_buffer_size;
|
|
|
+ mesh_info.vertex_count += surface->vertex_count;
|
|
|
+
|
|
|
+ for (uint32_t lod_index = 0; lod_index < surface->lod_count; lod_index++) {
|
|
|
+ mesh_info.lod_index_buffers_size += surface->lods[lod_index].index_buffer_size;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ r_info->push_back(mesh_info);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
bool MeshStorage::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
|
|
|
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
|
|
ERR_FAIL_NULL_V(mesh, false);
|