feat: 实现D3D12 RHI抽象层,修复PSO创建问题

- 添加RHI接口定义(IRHIDevice, ICommandList, IResource等)
- 实现D3D12Device, D3D12CommandList, D3D12PipelineState等
- 修复RootSignature参数数量(3->4)与HelloEarth一致
- 修复DSV格式设置(Unknown->D24_UNorm_S8_UInt)
- 添加Geometry Shader编译
- 创建XCEngineDemo项目验证RHI功能
This commit is contained in:
2026-03-14 02:42:59 +08:00
parent 6a0dfb150d
commit 5f12393424
76 changed files with 3112 additions and 15048 deletions

View File

@@ -0,0 +1,40 @@
#include <Rendering\Shader.h>
#include <d3dcompiler.h>
#include <wrl/client.h>
#include <string>
namespace XCEngine {
namespace RHI {
bool CompileShader(const char* filePath, const char* entryPoint, const char* target, ShaderBytecode& outBytecode) {
UINT flags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
ID3DBlob* shaderBuffer = nullptr;
ID3DBlob* errorBuffer = nullptr;
HRESULT hr = D3DCompileFromFile(
std::wstring(filePath, filePath + strlen(filePath)).c_str(),
nullptr,
nullptr,
entryPoint,
target,
flags,
0,
&shaderBuffer,
&errorBuffer);
if (FAILED(hr)) {
if (errorBuffer) {
OutputDebugStringA((const char*)errorBuffer->GetBufferPointer());
errorBuffer->Release();
}
return false;
}
outBytecode.bytecode = shaderBuffer->GetBufferPointer();
outBytecode.size = shaderBuffer->GetBufferSize();
return true;
}
} // namespace RHI
} // namespace XCEngine