39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
# D3D12Shader::Compile
|
|
|
|
```cpp
|
|
bool Compile(const void* sourceData, size_t sourceSize, const char* entryPoint, const char* target) override;
|
|
```
|
|
|
|
## 作用
|
|
|
|
从内存中的 HLSL 源码编译 shader。
|
|
|
|
## 当前实现行为
|
|
|
|
- 调用 `D3DCompile(...)`
|
|
- 编译标志同样固定为 `D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION`
|
|
- 不提供文件名、宏或 include handler
|
|
- 失败时如果 `m_error` 非空,只调用 `OutputDebugStringA(errorMsg)`,不会像 [CompileFromFile](CompileFromFile.md) 一样写到 `stderr`
|
|
- 成功后按 `target` 推断类型
|
|
- 把 `m_uniformsCached` 设为 `false`
|
|
|
|
## 使用场景
|
|
|
|
这个重载主要服务于:
|
|
|
|
- [D3D12Device](../D3D12Device/D3D12Device.md) 的内存源码编译路径
|
|
- 单元测试里的内嵌 HLSL 字符串
|
|
- 运行时生成 shader 文本的实验性场景
|
|
|
|
## 当前限制
|
|
|
|
- 仍然是 FXC 路径
|
|
- 没有源码来源名,编译报错定位体验弱于文件编译
|
|
- 类型推断依赖 `target` 字符串,而不是字节码内容
|
|
|
|
## 相关文档
|
|
|
|
- [CompileFromFile](CompileFromFile.md)
|
|
- [GetBytecode](GetBytecode.md)
|
|
- [GetType](GetType.md)
|