// // Created by atdunbg on 2026/9/22. // #include #include #include #include #include namespace Engine::Assets { AssetManager::AssetManager(Device& device, MemoryAllocator& allocator, DescriptorManager& descriptors, vk::DescriptorSetLayout textureLayout) : m_Device(device), m_Allocator(allocator), m_Descriptors(descriptors), m_TextureLayout(textureLayout) { ENGINE_INFO("AssetManager created"); } ModelHandle AssetManager::LoadModel(const std::string& path) { return m_Models.Load(path, [this](const std::string& p) -> Scope { // GPU 上传在此发生:资产层调用渲染层接口完成 buffer/image 创建 return CreateScope( m_Device, m_Allocator, m_Descriptors, m_TextureLayout, p); }); } ModelHandle AssetManager::CreatePlane(f32 halfSize, u8 r, u8 g, u8 b) { // 程序化资产复用同一缓存:键 = 伪路径 + 参数 std::string key = "procedural://plane/" + std::to_string(halfSize) + "/" + std::to_string(r) + "," + std::to_string(g) + "," + std::to_string(b); return m_Models.Load(key, [&](const std::string&) -> Scope { return Model::CreatePlane(m_Device, m_Allocator, m_Descriptors, m_TextureLayout, halfSize, r, g, b); }); } } // namespace Engine::Assets