核心变更: - 新增 d3d12_texture 和 d3d12_render_texture 类 - 新增 d3d12_texture_init_info 结构,支持三种资源创建方式 - 新增 D3D12Helpers.h,提供堆属性辅助结构 - 改用 utl::free_list 管理 surface,解决重复释放问题 - 为 d3d12_surface 添加移动语义,支持撕裂检测 文档完善: - 为 FreeList.h 和 Vector.h 添加完整 Doxygen 中文注释 - 更新 D3D12 学习 Wiki,添加 SRV、资源创建方式、纹理资源类章节 - 新增变更记录文档
107 lines
2.1 KiB
C++
107 lines
2.1 KiB
C++
#pragma once
|
|
#include "Platform/Window.h"
|
|
|
|
|
|
namespace XEngine::graphics {
|
|
|
|
DEFINE_TYPED_ID(surface_id);
|
|
|
|
/**
|
|
* @brief 表面类
|
|
* @details 定义了渲染表面的属性与操作
|
|
*/
|
|
class surface
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 由表面 ID 构造句柄。
|
|
* @param id 表面 ID。
|
|
*/
|
|
constexpr explicit surface(surface_id id) : _id{ id } {}
|
|
/**
|
|
* @brief 构造无效表面句柄。
|
|
*/
|
|
constexpr surface() = default;
|
|
/**
|
|
* @brief 获取表面 ID。
|
|
* @return 表面 ID。
|
|
*/
|
|
constexpr surface_id get_id() const { return _id; }
|
|
/**
|
|
* @brief 判断表面句柄是否有效。
|
|
* @return 有效返回 true。
|
|
*/
|
|
constexpr bool is_valid() const { return id::is_valid(_id); }
|
|
|
|
|
|
/**
|
|
* @brief 调整表面大小。
|
|
* @param width 目标宽度。
|
|
* @param height 目标高度。
|
|
*/
|
|
void resize(u32 width, u32 height) const;
|
|
/**
|
|
* @brief 获取表面宽度。
|
|
* @return 宽度像素值。
|
|
*/
|
|
u32 width() const;
|
|
/**
|
|
* @brief 获取表面高度。
|
|
* @return 高度像素值。
|
|
*/
|
|
u32 height() const;
|
|
|
|
void render() const;
|
|
|
|
private:
|
|
surface_id _id{ id::invalid_id };
|
|
};
|
|
|
|
/**
|
|
* @brief 渲染表面结构体
|
|
* @details 定义了渲染表面的窗口与表面对象
|
|
*/
|
|
struct render_surface
|
|
{
|
|
platform::window window{};
|
|
surface surface{};
|
|
};
|
|
|
|
/**
|
|
* @brief 图形渲染平台枚举
|
|
* @details 定义了支持的图形渲染平台类型
|
|
*/
|
|
enum class graphics_platform : u32
|
|
{
|
|
direct3d12 = 0,
|
|
vulkan = 1,
|
|
opengl = 2,
|
|
};
|
|
|
|
/**
|
|
* @brief 初始化图形渲染平台
|
|
* @details 调用设置平台接口函数,初始化指定的图形渲染平台
|
|
* @param platform 图形渲染平台类型
|
|
* @return true 如果初始化成功,否则返回 false
|
|
*/
|
|
bool initialize(graphics_platform platform);
|
|
/**
|
|
* @brief 关闭图形渲染平台
|
|
* @details 调用关闭函数指针,关闭指定的图形渲染平台
|
|
*/
|
|
void shutdown();
|
|
|
|
/**
|
|
* @brief 创建渲染表面
|
|
* @details window 渲染表面的窗口
|
|
* @return 渲染表面对象柄
|
|
*/
|
|
surface create_surface(platform::window window);
|
|
|
|
/**
|
|
* @brief 移除渲染表面
|
|
* @details id 渲染表面的 ID
|
|
*/
|
|
void remove_surface(surface_id id);
|
|
|
|
} |