Files
HelloVulkan/Engine/include/Engine/Vulkan/Device.h
T
atdunbg dd7c67a116 feat: ImGui docking Editor + 显示链/帧同步/输入语义重构
- App/editor: Hierarchy/Inspector/Viewport/Stats 四面板 + DockBuilder 默认布局,main.cpp 瘦身为场景搭建与生命周期
- 显示链: Tonemap→PresentTarget 经 ImGui::Image 呈现(零色偏),backbuffer 仅承载 ImGui;Direct/Viewport 双显示模式 + 面板分辨率上报
- 帧首同步 BeginFrameSync: resize/vsync/尺寸/模式意图统一帧首落定(修描述符悬垂);修复 vsync 意图未落 swapchain 导致的每帧重建交换链
- 输入: Editor 每帧判定键盘/鼠标归属(打字让位、Viewport hover/focus 放行、Fullscreen 全放行)
- 材质: roughness 独立槽位 + 非 glTF 金属/粗糙贴图映射;透明队列 depthWrite=FALSE + translucent 独立 shader + scratch 清帧
- FBX: 非蒙皮网格烘焙节点链全局变换(Z-up 旋转/单位换算落顶点)
- Hierarchy 行 ImGui ID 以 UUID 作用域(重名不冲突、改名不丢选中)
2026-09-30 00:24:53 +08:00

93 lines
2.9 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/20.
//
#ifndef HELLOVULKAN_DEVICE_H
#define HELLOVULKAN_DEVICE_H
#include <vulkan/vulkan.hpp>
#include <vector>
namespace Engine {
class Window;
class Device {
public:
Device(Window& window);
~Device();
Device(const Device&) = delete;
Device& operator=(const Device&) = delete;
vk::Instance GetInstance() const { return m_Instance; }
vk::PhysicalDevice GetPhysicalDevice() const { return m_PhysicalDevice; }
vk::Device GetDevice() const { return m_Device; }
vk::SurfaceKHR GetSurface() const { return m_Surface; }
vk::Queue GetGraphicsQueue() const { return m_GraphicsQueue; }
vk::Queue GetPresentQueue() const { return m_PresentQueue; }
uint32_t GetGraphicsFamily() const { return m_GraphicsFamily; }
uint32_t GetPresentFamily() const { return m_PresentFamily; }
uint32_t FindMemoryType(uint32_t typeFilter, vk::MemoryPropertyFlags props) const;
// 在候选列表中找到第一个满足 tiling+features 的格式,找不到则 FATAL
vk::Format FindSupportedFormat(const std::vector<vk::Format>& candidates,
vk::ImageTiling tiling,
vk::FormatFeatureFlags features) const;
// 1.4 特性查询
bool IsDynamicRenderingSupported() const { return m_DynamicRenderingSupported; }
bool IsShaderObjectSupported() const { return m_ShaderObjectSupported; }
bool IsSynchronization2Supported() const { return m_Synchronization2Supported; }
// MDI:drawCount>1 的 drawIndexedIndirect(Count) 必需(core 特性位)
bool IsMultiDrawIndirectSupported() const { return m_MultiDrawIndirectSupported; }
private:
void CreateInstance();
void SetupDebugMessenger();
void CreateSurface(Window& window);
void PickPhysicalDevice();
void CreateLogicalDevice();
bool IsDeviceSuitable(vk::PhysicalDevice device);
bool CheckValidationLayerSupport();
vk::Instance m_Instance;
vk::DebugUtilsMessengerEXT m_DebugMessenger;
vk::SurfaceKHR m_Surface;
vk::PhysicalDevice m_PhysicalDevice;
vk::Device m_Device;
vk::Queue m_GraphicsQueue;
vk::Queue m_PresentQueue;
uint32_t m_GraphicsFamily = 0;
uint32_t m_PresentFamily = 0;
vk::PhysicalDeviceMemoryProperties m_MemoryProperties;
// 1.4 特性标志
bool m_DynamicRenderingSupported = false;
bool m_ShaderObjectSupported = false;
bool m_Synchronization2Supported = false;
bool m_MultiDrawIndirectSupported = false;
bool m_DrawIndirectCountSupported = false;
std::vector<const char*> m_ValidationLayers = { "VK_LAYER_KHRONOS_validation" };
std::vector<const char*> m_DeviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
#ifdef NDEBUG
static constexpr bool kEnableValidation = false;
#else
static constexpr bool kEnableValidation = true;
#endif
};
} // namespace Engine
#endif //HELLOVULKAN_DEVICE_H