Files
XCSDD/docs/api/rhi/device/compile-shader.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

36 lines
822 B
Markdown

# RHIDevice::CompileShader
```cpp
virtual RHIShader* CompileShader(const ShaderCompileDesc& desc) = 0;
```
编译着色器程序。
**参数:**
- `desc` - 着色器编译描述符,包含入口点、配置文件、源文件等
**返回:** 新创建的着色器指针,失败返回 `nullptr`
**复杂度:** O(n) - 取决于着色器代码复杂度
**示例:**
```cpp
ShaderCompileDesc shaderDesc;
shaderDesc.entryPoint = L"main";
shaderDesc.profile = L"vs_6_0";
shaderDesc.fileName = L"shaders/vertex.hlsl";
shaderDesc.macros = {};
RHIShader* vertexShader = device->CompileShader(shaderDesc);
if (!vertexShader->IsValid()) {
// 处理编译错误
vertexShader->Shutdown();
}
```
## 相关文档
- [RHIDevice 总览](device.md) - 返回类总览
- [RHIShader](../shader/shader.md) - 着色器类