feat(d3d12): 新增纹理资源类,修复 Surface 重复释放问题

核心变更:
- 新增 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、资源创建方式、纹理资源类章节
- 新增变更记录文档
This commit is contained in:
SpecialX
2026-04-01 16:15:12 +08:00
parent 95d8893182
commit 4d13d8df89
19 changed files with 1821 additions and 233 deletions

View File

@@ -2,7 +2,7 @@
* @file TestRenderer.cpp
* @brief 渲染功能综合测试实现。
*/
#include "Test.h"
#include "TestRenderer.h"
#include "Graphics/Renderer.h"
#include "Platform/Platform.h"
@@ -13,9 +13,9 @@
#ifdef TEST_RENDERER
using namespace XEngine;
time_it timer{};
graphics::render_surface _surfaces[4];
void destroy_render_surface(graphics::render_surface& surface);
LRESULT win_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
bool toggle_fullscreen{ false };
@@ -26,9 +26,15 @@ LRESULT win_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
bool all_closed{ true };
for (u32 i{ 0 }; i < _countof(_surfaces); ++i)
{
if(!_surfaces[i].window.is_closed())
{
all_closed = false;
if(_surfaces[i].window.is_valid()){
if(_surfaces[i].window.is_closed())
{
destroy_render_surface(_surfaces[i]);
}
else
{
all_closed = false;
}
}
}
if (all_closed)
@@ -49,6 +55,12 @@ LRESULT win_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
}
break;
}
case WM_KEYDOWN:
if(wparam == VK_ESCAPE)
{
PostMessage(hwnd,WM_CLOSE,0,0);
return 0;
}
}
@@ -59,12 +71,16 @@ void
create_render_surface(graphics::render_surface& surface, const platform::window_init_info info)
{
surface.window = platform::create_window(&info);
surface.surface = graphics::create_surface(surface.window);
}
void
_destroy_render_surface(graphics::render_surface& surface)
destroy_render_surface(graphics::render_surface& surface)
{
platform::remove_window(surface.window.get_id());
graphics::render_surface temp{surface};
surface = {};
if(temp.surface.is_valid())graphics::remove_surface(temp.surface.get_id());
if(temp.window.is_valid())platform::remove_window(temp.window.get_id());
}
bool
@@ -93,8 +109,16 @@ engine_test::initialize()
void
engine_test::run()
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
graphics::render();
timer.begin();
//std::this_thread::sleep_for(std::chrono::milliseconds(10));
for (u32 i{ 0 }; i < _countof(_surfaces); ++i)
{
if(_surfaces[i].surface.is_valid())
{
_surfaces[i].surface.render();
}
}
timer.end();
}
bool
@@ -102,7 +126,7 @@ engine_test::shutdown()
{
for (u32 i{ 0 }; i < _countof(_surfaces); ++i)
{
_destroy_render_surface(_surfaces[i]);
destroy_render_surface(_surfaces[i]);
}
graphics::shutdown();