资产改为保存场景或者关闭软件时候更新guid文件,vulkan/DescriptorManager 创建DescriptorPool时候注释eFreeDescriptorSet,PhysicsWorld初始化时候改为推荐的inNumBodyMutexes
This commit is contained in:
@@ -232,6 +232,11 @@ namespace Engine
|
||||
// 后续扩展点:TextureHandle / MaterialHandle / ShaderHandle
|
||||
// 各自一个 AssetCache<T> + 便捷方法,模式与 Model 完全一致。
|
||||
|
||||
// 把 dirty 的 GUID 注册表落盘(Application 退出 / 场景保存时调)。
|
||||
// 内部幂等:非 dirty 直接 return。GetOrCreateGUID 只标 dirty 不落盘,
|
||||
// 避免每次新增 GUID 都全量重写 yaml(开发期编辑器卡顿主因之一)
|
||||
void FlushGUIDRegistry();
|
||||
|
||||
private:
|
||||
void LoadGUIDRegistry();
|
||||
void SaveGUIDRegistry() const;
|
||||
@@ -241,9 +246,13 @@ namespace Engine
|
||||
AssetCache<Model> m_Models;
|
||||
AssetCache<Cubemap> m_Environments;
|
||||
|
||||
// GUID 注册表(双向);dirty 即时保存,无析构落盘依赖
|
||||
// GUID 注册表(双向);GetOrCreateGUID 标 dirty,FlushGUIDRegistry 落盘
|
||||
// (Application 退出 / 场景保存时统一 flush,避免每次新增都全量重写 yaml)
|
||||
std::unordered_map<u64, std::string> m_GuidToPath;
|
||||
std::unordered_map<std::string, u64> m_PathToGuid;
|
||||
|
||||
bool m_GuidRegistryDirty = false;
|
||||
|
||||
};
|
||||
} // namespace Assets
|
||||
} // namespace Engine
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Engine::Assets {
|
||||
m_PathToGuid.emplace(path, guid);
|
||||
m_GuidToPath.emplace(guid, path);
|
||||
SaveGUIDRegistry();
|
||||
m_GuidRegistryDirty = true;
|
||||
return guid;
|
||||
}
|
||||
|
||||
@@ -61,6 +62,12 @@ namespace Engine::Assets {
|
||||
return {};
|
||||
}
|
||||
|
||||
void AssetManager::FlushGUIDRegistry() {
|
||||
if (!m_GuidRegistryDirty) return;
|
||||
SaveGUIDRegistry();
|
||||
m_GuidRegistryDirty = false;
|
||||
}
|
||||
|
||||
void AssetManager::LoadGUIDRegistry()
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -55,6 +55,13 @@ namespace Engine {
|
||||
m_Renderer->GetDevice().GetDevice().waitIdle();
|
||||
}
|
||||
|
||||
// ✅ 进程退出前持久化 GUID 注册表(GetOrCreateGUID 只标 dirty,
|
||||
// 此处统一落盘,避免开发期每次新增都触发全量 yaml 重写)
|
||||
if (m_Assets) {
|
||||
m_Assets->FlushGUIDRegistry();
|
||||
}
|
||||
|
||||
|
||||
if (m_ImGuiLayer) m_ImGuiLayer.reset();
|
||||
|
||||
// 注意:这里不能 Logger::Shutdown()——成员析构(Device 销毁等)
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Engine {
|
||||
m_ObjectVsObjectLayerFilter = CreateScope<ObjectLayerPairFilterImpl>();
|
||||
|
||||
m_System = CreateScope<JPH::PhysicsSystem>();
|
||||
m_System->Init(4096, 0, 16384, 4096,
|
||||
m_System->Init(4096, 65536, 16384, 4096,
|
||||
*m_BPLayerInterface, *m_ObjectVsBPLayerFilter,
|
||||
*m_ObjectVsObjectLayerFilter);
|
||||
m_System->SetGravity(JPH::Vec3(0.0f, -9.81f, 0.0f));
|
||||
|
||||
@@ -461,6 +461,7 @@ namespace Engine::Serialization {
|
||||
return false;
|
||||
}
|
||||
file << doc;
|
||||
assets.FlushGUIDRegistry();
|
||||
return true;
|
||||
}
|
||||
catch (const YAML::Exception& e) {
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Engine
|
||||
|
||||
vk::DescriptorPoolCreateInfo poolInfo;
|
||||
poolInfo.setMaxSets(kChunkSets)
|
||||
.setPoolSizes(poolSizes)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
.setPoolSizes(poolSizes);
|
||||
// .setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
|
||||
return m_Device.GetDevice().createDescriptorPool(poolInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user