fix: 阴影光源错误绑定 FillLight + 截图 usage 警告 + nodiscard

- LightComponent 增加 castShadow 标志;灯收集排序键改为
  castShadow 方向光 > 方向光 > 点光(此前稳定排序把收集序靠前的
  FillLight 排到 lights[0],KeyLight 方向滑条自然不影响阴影)
- TextureDesc 增加 extraUsage:HDRColor 声明 TRANSFER_SRC,
  消除截图 copy 的 3 条 usage 不匹配运行时警告
- waitForFences nodiscard 返回值显式丢弃,消除编译警告
This commit is contained in:
2026-09-24 11:59:18 +08:00
parent 4d3963e291
commit 42fd9d5f30
9 changed files with 40 additions and 13 deletions
+1 -1
View File
@@ -94,11 +94,11 @@ namespace Engine::ECS {
// Point——位置取实体 Transform(固有的),向四周发光 + 距离衰减
struct LightComponent {
enum class Type : u8 { Directional = 0, Point = 1 };
Type type = Type::Directional;
glm::vec3 direction{0.0f, -1.0f, 0.0f}; // 仅方向光
glm::vec4 color{1.0f, 1.0f, 1.0f, 1.0f}; // rgb = 颜色,a = 强度
f32 radius = 10.0f; // 仅点光:衰减半径
bool castShadow = false; // 方向光可投影(引擎取第一个 castShadow 方向光为 CSM 光源)
};
} // namespace Engine::ECS
@@ -72,6 +72,8 @@ namespace Engine::RG {
u32 width = 0; // 0 = 跟随目标(swapchain)尺寸 × sizeScale
u32 height = 0;
f32 sizeScale = 1.0f; // 相对尺寸(后处理降采样用,如 bloom 0.5)
// 附加 usage(在 pass 读写推导之外;如调试截图需要 TRANSFER_SRC)
vk::ImageUsageFlags extraUsage{};
};
// ---------- 物理镜像 ----------
@@ -33,7 +33,7 @@ namespace Engine {
// 后处理链参数(ImGui 可调;Renderer 持有,pass 按引用读取)
struct PostProcessParams {
f32 exposure = 1.0f;
f32 exposure = 0.6f;
bool useACES = true;
f32 bloomThreshold = 1.0f; // HDR 域亮度阈值
f32 bloomStrength = 0.8f; // 叠加强度
@@ -101,6 +101,7 @@ namespace Engine {
void BuildGraph(); // 声明 RG 资源 + 注册 pass 对象
void HandleResize();
void ReadGpuTimes(u32 frameSlot);
void CaptureFrame(); // 调试截图(一次性,写 capture.bmp)
Window& m_Window;
@@ -154,6 +155,11 @@ namespace Engine {
vk::Extent2D m_Extent{};
u32 m_CurrentFrame = 0;
// 调试截图(一次性):第 60 帧把 TAAColor(HDR)落成 capture.bmp
u32 m_FrameCounter = 0;
bool m_Captured = false;
MemoryAllocator::Allocation m_CaptureAlloc{};
};
} // namespace Engine