资产浏览器可视化改造 + 材质缩略图 GPU 烘焙 + 纹理上传批式化
- 资产浏览器可视化与配色:面板重构(网格/列表/缩略图)、AssetKind 分类、 EditorColors 统一配色、AssetItemView 抽出条目绘制;HierarchyPanel/ MaterialEditorPanel 同步调整 - 材质缩略图改走 GPU 回读烘焙:MaterialPreviewPass 新增 bake pass (SDR atlas → host staging copyImageToBuffer)、Renderer 提供 Request/PollMaterialPreviewBake(无 waitIdle,依赖 per-slot fence), Editor 每帧排空后注入 ThumbnailCache——脱离预览 tile 池,消除"滚出视野 即失效/池耗尽"两问题 - 缩略图失效:BakedIdentity(serial, editVersion) 与当前材质身份比对, 换贴图槽(重载新 serial)/调参数(editVersion++)不符即 Invalidate 重烘, 修"修改材质后资产浏览器缩略图不更新" - 材质加载闸门:每帧至多 1 个 + 按实测耗时冷却,替代固定 2/帧 - 纹理上传批式化:VulkanAssetUploader 新增路径纹理缓存(跨材质去重, 同一贴图只解码/上传一次)+ 同批新纹理合并为单 cmd/单 submit/单 fence; Texture 抽出 RecordPixelsUpload/CreateDeferred/ReleasePendingStaging, 析构兜底释放 staging;MaterialAsset 纹理所有权移交 uploader 缓存—— 修大材质目录首次打开卡顿
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// AssetKind.h:资产分类的单一事实来源(Content Browser / 编辑器共用)。
|
||||
//
|
||||
// 原先分类逻辑散在 AssetBrowserPanel.cpp 匿名 ns(Kind/KindOf/KindTag),
|
||||
// 现在上提为头文件:面板、拖拽源、缩略图缓存按同一份扩展名表分派。
|
||||
//
|
||||
|
||||
#ifndef HELLOVULKAN_ASSETKIND_H
|
||||
#define HELLOVULKAN_ASSETKIND_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace EditorAsset {
|
||||
|
||||
// 资产类别(按扩展名分派;同时是类型过滤的身份)
|
||||
enum class AssetKind {
|
||||
Model, Texture, Scene, Material, AnimClip, Prefab, Other
|
||||
};
|
||||
|
||||
// 统一小写扩展名(含点,如 ".png";无扩展名 = 空串)
|
||||
inline std::string LowerExt(const std::filesystem::path& p)
|
||||
{
|
||||
std::string ext = p.extension().string();
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
return ext;
|
||||
}
|
||||
|
||||
// 纹理扩展名表(单一事实来源:分类 / 缩略图 / 材质纹理槽选择器共用)。
|
||||
// 口径 = 引擎 Texture 可直接加载者:
|
||||
// stb_image 8-bit 系 png/jpg/tga/bmp/psd/gif/pnm
|
||||
// + .hdr(环境贴图,stbi_loadf / stbi_load 走内置 hdr→ldr)
|
||||
// + .dds(引擎 DdsLoader,BC 压缩直传)
|
||||
inline bool IsTexturePath(const std::filesystem::path& p)
|
||||
{
|
||||
static const char* kExts[] = {
|
||||
".png", ".jpg", ".jpeg", ".tga", ".bmp", ".psd",
|
||||
".gif", ".ppm", ".pgm", ".pnm", ".hdr", ".dds"};
|
||||
const std::string ext = LowerExt(p);
|
||||
for (const char* e : kExts)
|
||||
{
|
||||
if (ext == e) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 扩展名 → 类别
|
||||
inline AssetKind KindOfPath(const std::filesystem::path& p)
|
||||
{
|
||||
const std::string ext = LowerExt(p);
|
||||
if (ext == ".gltf" || ext == ".glb" || ext == ".fbx" ||
|
||||
ext == ".obj")
|
||||
{
|
||||
return AssetKind::Model;
|
||||
}
|
||||
if (IsTexturePath(p))
|
||||
{
|
||||
return AssetKind::Texture;
|
||||
}
|
||||
if (ext == ".scene")
|
||||
{
|
||||
return AssetKind::Scene;
|
||||
}
|
||||
if (ext == ".material")
|
||||
{
|
||||
return AssetKind::Material;
|
||||
}
|
||||
if (ext == ".animctrl")
|
||||
{
|
||||
return AssetKind::AnimClip;
|
||||
}
|
||||
if (ext == ".prefab")
|
||||
{
|
||||
return AssetKind::Prefab;
|
||||
}
|
||||
return AssetKind::Other;
|
||||
}
|
||||
|
||||
// 全称标签(tooltip / 网格标题;替代原下标对齐数组)
|
||||
inline const char* KindLabel(AssetKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AssetKind::Model: return "Model";
|
||||
case AssetKind::Texture: return "Texture/Environment";
|
||||
case AssetKind::Scene: return "Scene";
|
||||
case AssetKind::Material: return "Material";
|
||||
case AssetKind::AnimClip: return "Controller";
|
||||
case AssetKind::Prefab: return "Prefab";
|
||||
default: return "File";
|
||||
}
|
||||
}
|
||||
|
||||
// 列表类型列的短标签(替代原 "[M]"/"[T]" 前缀)
|
||||
inline const char* KindShortLabel(AssetKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AssetKind::Model: return "MDL";
|
||||
case AssetKind::Texture: return "TEX";
|
||||
case AssetKind::Scene: return "SCN";
|
||||
case AssetKind::Material: return "MAT";
|
||||
case AssetKind::AnimClip: return "CTRL";
|
||||
case AssetKind::Prefab: return "PFB";
|
||||
default: return "FILE";
|
||||
}
|
||||
}
|
||||
|
||||
// 可解码为 8-bit 缩略图的扩展名:stbi_load 原生支持者(含 .hdr ——
|
||||
// stbi_load 内部走 hdr→ldr 色调映射)。仅 .dds 例外(BC 压缩块,需
|
||||
// 专用解码器)→ 占位块
|
||||
inline bool IsThumbnailable(const std::filesystem::path& p)
|
||||
{
|
||||
return IsTexturePath(p) && LowerExt(p) != ".dds";
|
||||
}
|
||||
|
||||
} // namespace EditorAsset
|
||||
|
||||
#endif //HELLOVULKAN_ASSETKIND_H
|
||||
Reference in New Issue
Block a user