Files
XCEngine/docs/api/rhi/d3d12/device/compile-shader.md

32 lines
777 B
Markdown
Raw Normal View History

2026-03-20 02:35:45 +08:00
# D3D12Device::CompileShader
```cpp
RHIShader* CompileShader(const ShaderCompileDesc& desc) override;
```
编译 D3D12 着色器。
**参数:**
- `desc` - 着色器编译描述符包含文件名、入口点、Profile 等
**返回:** 新创建的着色器指针,失败返回 `nullptr`
**复杂度:** 取决于着色器复杂度
**示例:**
```cpp
ShaderCompileDesc shaderDesc;
shaderDesc.fileName = L"shaders/vertex.hlsl";
shaderDesc.entryPoint = "VSMain";
shaderDesc.profile = "vs_5_0";
RHIShader* shader = device->CompileShader(shaderDesc);
```
## 相关文档
- [D3D12Device 总览](device.md) - 返回类总览
- [RHIDevice::CompileShader](../../device/compile-shader.md) - 基类方法
- [D3D12Shader](../../shader/shader.md) - D3D12 着色器实现