Files
HelloVulkan/Engine/src/Renderer/Cubemap.cpp
T
atdunbg 1d690067bd feat: IBL 预积分 GPU compute 化 + 环境资产入 Assets 层(动态切换)
CPU 逐像素卷积(venice 4k 阻塞 7.36s)→ 4 个 compute shader 一次性
提交:equirect→cube / irradiance / prefilter×5mip / BRDF LUT。
Cubemap 瘦身为纯资源持有类,生成职责移交 IblGenerator;
环境经 AssetManager 缓存(EnvRef),Renderer::SetEnvironment
动态换绑(RenderPass::OnEnvironmentChanged 广播)。
调试视图 +4:EnvCube / Irradiance / Prefilter / BRDF LUT。

性能前后对比(RTX 5060 Laptop,venice_dawn_1_4k.hdr):
- 改造前 CPU:7.36 s(主线程阻塞)
- 改造后 GPU:HDR decode 127-134ms + 资源 22-35ms + compute 17-19ms
  ≈ 165-190ms(约 40×);Neutral 兜底 ~6ms
- 运行中动态切换环境同量级(ms 级 GPU,decode 占大头)

冒烟:两构建目录 0 警告;运行期 0 validation(含两次环境切换 +
调试视图 9-12 轮播自动化验证)。
2026-09-24 13:23:59 +08:00

30 lines
869 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// Created by atdunbg on 2026/9/23.
//
// Cubemap 实现:纯资源持有(构造注入 + 成对析构)。
// 预积分生成见 IblGenerator(compute 链);CPU 积分路径已整体移除,
// 环境切换从秒级阻塞降到毫秒级 GPU 提交。
//
#include <Engine/Renderer/Cubemap.h>
#include <Engine/Vulkan/Device.h>
#include <Engine/Vulkan/MemoryAllocator.h>
namespace Engine
{
Cubemap::~Cubemap()
{
const auto& vkDevice = m_Device.GetDevice();
vkDevice.destroySampler(m_EnvSampler);
vkDevice.destroySampler(m_LutSampler);
// 三元组成对释放:view → (image + 显存) 经 VMA 成对销毁
for (EnvTexture* tex : {&m_Env, &m_Irr, &m_Pref, &m_Lut}) {
vkDevice.destroyImageView(tex->view);
m_Allocator.Destroy(tex->allocation);
}
}
} // namespace Engine