31 lines
867 B
Markdown
31 lines
867 B
Markdown
|
|
# D3D12Device::CreateSampler
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
RHISampler* CreateSampler(const SamplerDesc& desc) override;
|
||
|
|
```
|
||
|
|
|
||
|
|
创建 D3D12 采样器。
|
||
|
|
|
||
|
|
**参数:**
|
||
|
|
- `desc` - 采样器描述符,包含过滤模式、地址模式等
|
||
|
|
|
||
|
|
**返回:** 新创建的采样器指针,失败返回 `nullptr`
|
||
|
|
|
||
|
|
**示例:**
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
SamplerDesc samplerDesc;
|
||
|
|
samplerDesc.filter = (uint32_t)D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||
|
|
samplerDesc.addressU = (uint32_t)D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||
|
|
samplerDesc.addressV = (uint32_t)D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||
|
|
samplerDesc.addressW = (uint32_t)D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||
|
|
|
||
|
|
RHISampler* sampler = device->CreateSampler(samplerDesc);
|
||
|
|
```
|
||
|
|
|
||
|
|
## 相关文档
|
||
|
|
|
||
|
|
- [D3D12Device 总览](device.md) - 返回类总览
|
||
|
|
- [RHIDevice::CreateSampler](../../device/create-sampler.md) - 基类方法
|
||
|
|
- [D3D12Sampler](../../sampler/sampler.md) - D3D12 采样器实现
|