Files
HelloVulkan/Engine/src/Renderer/Passes/ImGuiPass.cpp
T
atdunbg cc837bc605 Add animation controller system, material assets and skeleton visualization
- .animctrl state machine asset (params/transitions/blend trees, 1D+2D
  directional blending) with Unity Animator-style editor panel: state
  list, transitions, params, directional pad preview driving live
  CrossFade on the selected entity
- Split animation evaluation out of SceneRenderer into
  AnimationSystem/AnimationEvaluator; skin palettes with rest-pose
  fallback and blend-weight epsilon filtering
- MaterialAsset (.material) with reload-safe preview tile pool
  (DropMaterial clears dirty refs before instance destruction)
- EditorGizmoPass skeleton wires + viewport joint overlay; camera
  projection rework (baked Vulkan Y-flip, ortho support)
- Editor/game build split via HELLOVULKAN_EDITOR option
2026-10-07 01:50:04 +08:00

62 lines
2.6 KiB
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.
//
#include <Engine/Renderer/Passes/ImGuiPass.h>
#include <Engine/ImGui/ImGuiLayer.h>
namespace Engine::Passes
{
void ImGuiPass::Register(RG::RenderGraph& rg)
{
rg.AddPass("ImGui", [this](RG::RenderGraphContext& ctx) {
const vk::CommandBuffer cmd = ctx.cmd;
// loadOp 按显示模式分支:Direct = blit 已铺满场景(Load 叠加);
// Viewport = 本 pass 是唯一写入者(Clear 为"桌面底色")
const bool direct = (m_Frame.displayMode == kDisplayDirect);
vk::ClearValue clearValue;
clearValue.color = vk::ClearColorValue(
std::array<float, 4>{0.04f, 0.045f, 0.06f, 1.0f});
vk::RenderingAttachmentInfo colorAttachment;
colorAttachment.setImageView(ctx.View(m_Backbuffer))
.setImageLayout(vk::ImageLayout::eColorAttachmentOptimal)
.setLoadOp(direct ? vk::AttachmentLoadOp::eLoad
: vk::AttachmentLoadOp::eClear)
.setStoreOp(vk::AttachmentStoreOp::eStore)
.setClearValue(clearValue);
vk::RenderingInfo renderingInfo;
// 渲染区域 = backbuffer 物理尺寸(窗口大小),不是 ctx.extent
//(= RG 目标尺寸 = 场景渲染分辨率)。Editor 视口模式下场景链
// 按面板尺寸渲染,而 backbuffer 是全窗口——若跟随目标尺寸,
// 整个 ImGui 会被裁剪到面板大小
renderingInfo.setRenderArea({{0, 0}, ctx.Extent(m_Backbuffer)})
.setLayerCount(1)
.setColorAttachments(colorAttachment);
cmd.beginRendering(renderingInfo);
if (*m_Layer) {
(*m_Layer)->RenderDrawData(cmd);
}
cmd.endRendering();
}).Write(m_Backbuffer, RG::ResourceUse::ColorAttachment)
// 场景纹理在本 pass 内被 ImGui::Image 的描述符采样:声明读让 RG
// 补 ColorAttachment→ShaderRead barrier,并推导 eSampled usage
.Read(m_PresentTarget, RG::ResourceUse::ShaderRead,
vk::ShaderStageFlagBits::eFragment)
#ifdef HELLO_EDITOR
// 材质球预览 atlas 同理(材质槽行的 ImGui::Image 采样);
// game 构建不声明(atlas 不存在)
.Read(m_PreviewAtlas, RG::ResourceUse::ShaderRead,
vk::ShaderStageFlagBits::eFragment)
#endif
;
}
} // namespace Engine::Passes