Remove helper functions: GetCommandAllocator, GetCommandList, GetD3DDevice, SwapD3D12Buffers
This commit is contained in:
@@ -633,14 +633,6 @@ bool InitD3D12(HWND inHWND, int inWidth, int inHeight) {
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
// 命令相关辅助函数
|
// 命令相关辅助函数
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
ID3D12CommandAllocator* GetCommandAllocator() {
|
|
||||||
return gCommandAllocator.GetCommandAllocator();
|
|
||||||
}
|
|
||||||
|
|
||||||
ID3D12GraphicsCommandList* GetCommandList() {
|
|
||||||
return gCommandList.GetCommandList();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaitForCompletionOfCommandList() {
|
void WaitForCompletionOfCommandList() {
|
||||||
UINT64 completed = gFence.GetCompletedValue();
|
UINT64 completed = gFence.GetCompletedValue();
|
||||||
UINT64 current = gFenceValue;
|
UINT64 current = gFenceValue;
|
||||||
@@ -698,13 +690,6 @@ void EndRenderToSwapChain(ID3D12GraphicsCommandList* inCommandList) {
|
|||||||
inCommandList->ResourceBarrier(1, &barrier);
|
inCommandList->ResourceBarrier(1, &barrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
|
||||||
// 交换缓冲区 (显示渲染结果)
|
|
||||||
//=================================================================================
|
|
||||||
void SwapD3D12Buffers() {
|
|
||||||
gSwapChain.Present(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// 截图保存 Debug 工具
|
// 截图保存 Debug 工具
|
||||||
// 使用 RHI 模块的 D3D12Screenshot 类
|
// 使用 RHI 模块的 D3D12Screenshot 类
|
||||||
@@ -724,13 +709,6 @@ bool SaveScreenshot(const char* filename, int width, int height) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
|
||||||
// 获取D3D12设备
|
|
||||||
//=================================================================================
|
|
||||||
ID3D12Device* GetD3DDevice() {
|
|
||||||
return gDevice.GetDevice();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// Win32 窗口相关
|
// Win32 窗口相关
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@@ -804,7 +782,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
InitD3D12(hwnd, 1280, 720);
|
InitD3D12(hwnd, 1280, 720);
|
||||||
ID3D12CommandAllocator* commandAllocator = GetCommandAllocator();
|
ID3D12CommandAllocator* commandAllocator = gCommandAllocator.GetCommandAllocator();
|
||||||
StaticMeshComponent staticMeshComponent;
|
StaticMeshComponent staticMeshComponent;
|
||||||
staticMeshComponent.InitFromFile(gCommandList.GetCommandList(), "Res/Model/Sphere.lhsm");
|
staticMeshComponent.InitFromFile(gCommandList.GetCommandList(), "Res/Model/Sphere.lhsm");
|
||||||
|
|
||||||
@@ -853,7 +831,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
ID3D12Resource* texture = CreateTexture2D(gCommandList.GetCommandList(), pixels,
|
ID3D12Resource* texture = CreateTexture2D(gCommandList.GetCommandList(), pixels,
|
||||||
imageWidth * imageHeight * imageChannel, imageWidth, imageHeight, DXGI_FORMAT_R8G8B8A8_UNORM);
|
imageWidth * imageHeight * imageChannel, imageWidth, imageHeight, DXGI_FORMAT_R8G8B8A8_UNORM);
|
||||||
delete[] pixels;
|
delete[] pixels;
|
||||||
ID3D12Device* d3dDevice = GetD3DDevice();
|
ID3D12Device* d3dDevice = gDevice.GetDevice();
|
||||||
|
|
||||||
XCEngine::RHI::D3D12DescriptorHeap srvHeap;
|
XCEngine::RHI::D3D12DescriptorHeap srvHeap;
|
||||||
srvHeap.Initialize(d3dDevice, XCEngine::RHI::DescriptorHeapType::CBV_SRV_UAV, 3, true);
|
srvHeap.Initialize(d3dDevice, XCEngine::RHI::DescriptorHeapType::CBV_SRV_UAV, 3, true);
|
||||||
@@ -919,7 +897,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
|
|
||||||
// On screenshot frame, don't Present - we'll screenshot before next frame
|
// On screenshot frame, don't Present - we'll screenshot before next frame
|
||||||
if (frameCount != 30) {
|
if (frameCount != 30) {
|
||||||
SwapD3D12Buffers();
|
gSwapChain.Present(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screenshot after rendering is done
|
// Screenshot after rendering is done
|
||||||
|
|||||||
Reference in New Issue
Block a user