docs: update RHI API docs

This commit is contained in:
2026-03-20 02:35:45 +08:00
parent ea756c0177
commit 070b444f8f
501 changed files with 13493 additions and 2022 deletions

View File

@@ -0,0 +1,37 @@
# D3D12Common::CheckFormatSupport
```cpp
inline bool CheckFormatSupport(
ID3D12Device* device,
DXGI_FORMAT format,
D3D12_FORMAT_SUPPORT1 support1,
D3D12_FORMAT_SUPPORT2 support2 = D3D12_FORMAT_SUPPORT2_NONE
)
```
检查设备是否支持指定格式的特定功能。
**参数:**
- `device` - D3D12 设备指针
- `format` - 要检查的 DXGI 格式
- `support1` - 主格式支持标志(`D3D12_FORMAT_SUPPORT1`
- `support2` - 扩展格式支持标志(`D3D12_FORMAT_SUPPORT2`),默认为 `D3D12_FORMAT_SUPPORT2_NONE`
**返回:** 如果格式支持指定功能返回 `true`,否则返回 `false`
**线程安全:** ✅(只读查询)
**示例:**
```cpp
ID3D12Device* device = ...;
if (CheckFormatSupport(device, DXGI_FORMAT_BC1_UNORM, D3D12_FORMAT_SUPPORT1_TEXTURE2D)) {
// 支持 BC1 压缩格式
}
```
## 相关文档
- [D3D12Common 总览](common.md)
- [IsRenderTargetFormatSupported](is-render-target-format-supported.md)
- [IsTextureFormatSupported](is-texture-format-supported.md)

View File

@@ -2,7 +2,21 @@
**命名空间**: `XCEngine::RHI`
**描述**: D3D12 通用辅助函数集合,提供描述符大小、屏障创建、格式支持检查等功能。**所有函数均为 inline 函数**。
**类型**: `inline 函数集合` (header-only)
**描述**: D3D12 通用辅助函数集合,提供描述符大小查询、资源屏障创建、格式支持检查、视图创建等功能。所有函数均为 `inline` 函数,封装自 DirectX 12 原生 API。
## 概述
D3D12Common 是 D3D12 后端的工具函数模块,封装了 DirectX 12 常用的辅助功能,包括:
- **描述符大小查询**: 封装 `ID3D12Device::GetDescriptorHandleIncrementSize`,提供各类描述符的增量大小
- **资源屏障创建**: 封装 `D3D12_RESOURCE_BARRIER` 的三种类型Transition、UAV、Aliasing
- **格式支持检查**: 封装 `ID3D12Device::CheckFeatureSupport`,检查格式是否支持特定用途
- **视图创建**: 封装 D3D12_VERTEX_BUFFER_VIEW、D3D12_INDEX_BUFFER_VIEW、D3D12_VIEWPORT 等创建
- **描述符句柄运算**: 提供描述符句柄的偏移计算
这些函数均为无状态的纯函数,设计用于简化 D3D12 常见操作的代码编写。
## 函数列表
@@ -10,58 +24,88 @@
| 函数 | 描述 |
|------|------|
| `GetDescriptorHandleIncrementSize` | 获取描述符增量大小 |
| `GetRTVDescriptorSize` | 获取 RTV 描述符大小 |
| `GetDSVDescriptorSize` | 获取 DSV 描述符大小 |
| `GetCBV_SRV_UAVDescriptorSize` | 获取 CBV/SRV/UAV 描述符大小 |
| `GetSamplerDescriptorSize` | 获取 Sampler 描述符大小 |
| [`GetDescriptorHandleIncrementSize`](get-descriptor-handle-increment-size.md) | 获取指定描述符堆类型的增量大小 |
| [`GetRTVDescriptorSize`](get-rtv-descriptor-size.md) | 获取 RTV 描述符大小 |
| [`GetDSVDescriptorSize`](get-dsv-descriptor-size.md) | 获取 DSV 描述符大小 |
| [`GetCBV_SRV_UAVDescriptorSize`](get-cbv-srv-uav-descriptor-size.md) | 获取 CBV/SRV/UAV 描述符大小 |
| [`GetSamplerDescriptorSize`](get-sampler-descriptor-size.md) | 获取 Sampler 描述符大小 |
### 屏障创建
| 函数 | 描述 |
|------|------|
| `CreateTransitionBarrier` | 创建资源状态转换屏障 |
| `CreateUAVBarrier` | 创建 UAV 屏障 |
| `CreateAliasingBarrier` | 创建别名化屏障 |
| [`CreateTransitionBarrier`](create-transition-barrier.md) | 创建资源状态转换屏障 |
| [`CreateUAVBarrier`](create-uav-barrier.md) | 创建 UAV 屏障 |
| [`CreateAliasingBarrier`](create-aliasing-barrier.md) | 创建别名化屏障 |
### 格式支持
| 函数 | 描述 |
|------|------|
| `CheckFormatSupport` | 检查格式支持 |
| `IsRenderTargetFormatSupported` | 检查是否支持作为渲染目标 |
| `IsDepthStencilFormatSupported` | 检查是否支持作为深度模板 |
| `IsShaderResourceFormatSupported` | 检查 shader 是否可读取 |
| `IsTextureFormatSupported` | 检查是否支持作为纹理 |
| [`CheckFormatSupport`](check-format-support.md) | 检查格式是否支持指定功能 |
| [`IsRenderTargetFormatSupported`](is-render-target-format-supported.md) | 检查是否支持作为渲染目标 |
| [`IsDepthStencilFormatSupported`](is-depth-stencil-format-supported.md) | 检查是否支持作为深度模板 |
| [`IsShaderResourceFormatSupported`](is-shader-resource-format-supported.md) | 检查是否支持作为着色器资源 |
| [`IsTextureFormatSupported`](is-texture-format-supported.md) | 检查是否支持作为纹理 |
### 清除值创建
| 函数 | 描述 |
|------|------|
| `CreateRenderTargetClearValue` | 创建渲染目标清除值 |
| `CreateDepthStencilClearValue` | 创建深度模板清除值 |
| [`CreateRenderTargetClearValue`](create-render-target-clear-value.md) | 创建渲染目标清除值 |
| [`CreateDepthStencilClearValue`](create-depth-stencil-clear-value.md) | 创建深度模板清除值 |
### 视口和裁剪矩形
| 函数 | 描述 |
|------|------|
| `CreateViewport` | 创建视口 |
| `CreateScissorRect` | 创建裁剪矩形 |
| [`CreateViewport`](create-viewport.md) | 创建视口结构 |
| [`CreateScissorRect`](create-scissor-rect.md) | 创建裁剪矩形 |
### 缓冲区视图
| 函数 | 描述 |
|------|------|
| `CreateVertexBufferView` | 创建顶点缓冲区视图 |
| `CreateIndexBufferView` | 创建索引缓冲区视图 |
| [`CreateVertexBufferView`](create-vertex-buffer-view.md) | 创建顶点缓冲区视图 |
| [`CreateIndexBufferView`](create-index-buffer-view.md) | 创建索引缓冲区视图 |
### 描述符句柄运算
| 函数 | 描述 |
|------|------|
| `GetCPUDescriptorHandle` | 计算偏移后的 CPU 描述符句柄 |
| `GetGPUDescriptorHandle` | 计算偏移后的 GPU 描述符句柄 |
| [`GetCPUDescriptorHandle`](get-cpu-descriptor-handle.md) | 计算偏移后的 CPU 描述符句柄 |
| [`GetGPUDescriptorHandle`](get-gpu-descriptor-handle.md) | 计算偏移后的 GPU 描述符句柄 |
## 使用示例
```cpp
#include <XCEngine/RHI/D3D12/D3D12Common.h>
using namespace XCEngine::RHI;
// 获取描述符大小
ID3D12Device* device = ...;
UINT rtvSize = GetRTVDescriptorSize(device);
// 创建资源屏障
D3D12_RESOURCE_BARRIER barrier = CreateTransitionBarrier(
resource,
D3D12_RESOURCE_STATE_RENDER_TARGET,
D3D12_RESOURCE_STATE_COMMON
);
// 检查格式支持
if (IsTextureFormatSupported(device, DXGI_FORMAT_BC1_UNORM)) {
// 使用压缩纹理
}
// 创建视口
D3D12_VIEWPORT viewport = CreateViewport(1280.0f, 720.0f);
```
## 相关文档
- [D3D12 后端](../../opengl/overview.md)
- [D3D12 后端](../d3d12.md) - D3D12 模块总览
- [RHI 模块总览](../../rhi.md) - RHI 抽象层
- [D3D12Device](../device/device.md) - D3D12 设备
- [D3D12DescriptorHeap](../descriptor-heap/descriptor-heap.md) - 描述符堆

View File

@@ -0,0 +1,32 @@
# D3D12Common::CreateAliasingBarrier
```cpp
inline D3D12_RESOURCE_BARRIER CreateAliasingBarrier(
ID3D12Resource* beforeResource = nullptr,
ID3D12Resource* afterResource = nullptr
)
```
创建资源别名化屏障,用于不同资源之间的切换。
**参数:**
- `beforeResource` - 别名前的资源,默认为 `nullptr`
- `afterResource` - 别名后的资源,默认为 `nullptr`
**返回:** 配置好的 `D3D12_RESOURCE_BARRIER` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
ID3D12Resource* resourceA = ...;
ID3D12Resource* resourceB = ...;
D3D12_RESOURCE_BARRIER barrier = CreateAliasingBarrier(resourceA, resourceB);
cmdList->ResourceBarrier(1, &barrier);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateTransitionBarrier](create-transition-barrier.md)

View File

@@ -0,0 +1,35 @@
# D3D12Common::CreateDepthStencilClearValue
```cpp
inline D3D12_CLEAR_VALUE CreateDepthStencilClearValue(
DXGI_FORMAT format,
float depth = 1.0f,
uint8_t stencil = 0
)
```
创建深度模板缓冲区的清除值。
**参数:**
- `format` - 深度模板格式
- `depth` - 深度值,默认为 1.0f
- `stencil` - 模板值,默认为 0
**返回:** 配置好的 `D3D12_CLEAR_VALUE` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
D3D12_CLEAR_VALUE clearValue = CreateDepthStencilClearValue(
DXGI_FORMAT_D24_UNORM_S8_UINT,
1.0f,
0
);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateRenderTargetClearValue](create-render-target-clear-value.md)

View File

@@ -0,0 +1,37 @@
# D3D12Common::CreateIndexBufferView
```cpp
inline D3D12_INDEX_BUFFER_VIEW CreateIndexBufferView(
D3D12_GPU_VIRTUAL_ADDRESS bufferLocation,
UINT sizeInBytes,
DXGI_FORMAT format
)
```
创建索引缓冲区视图。
**参数:**
- `bufferLocation` - 索引缓冲区 GPU 虚拟地址
- `sizeInBytes` - 缓冲区大小(字节)
- `format` - 索引格式DXGI_FORMAT_R16_UINT 或 DXGI_FORMAT_R32_UINT
**返回:** 配置好的 `D3D12_INDEX_BUFFER_VIEW` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
ID3D12Resource* indexBuffer = ...;
D3D12_INDEX_BUFFER_VIEW ibView = CreateIndexBufferView(
indexBuffer->GetGPUVirtualAddress(),
indexBufferSize,
DXGI_FORMAT_R16_UINT
);
cmdList->IASetIndexBuffer(&ibView);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateVertexBufferView](create-vertex-buffer-view.md)

View File

@@ -0,0 +1,38 @@
# D3D12Common::CreateRenderTargetClearValue
```cpp
inline D3D12_CLEAR_VALUE CreateRenderTargetClearValue(
DXGI_FORMAT format,
float r = 0.0f,
float g = 0.0f,
float b = 0.0f,
float a = 1.0f
)
```
创建渲染目标的清除值(清除颜色)。
**参数:**
- `format` - 渲染目标格式
- `r` - 红色分量,默认为 0.0f
- `g` - 绿色分量,默认为 0.0f
- `b` - 蓝色分量,默认为 0.0f
- `a` - Alpha 分量,默认为 1.0f
**返回:** 配置好的 `D3D12_CLEAR_VALUE` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
D3D12_CLEAR_VALUE clearValue = CreateRenderTargetClearValue(
DXGI_FORMAT_R8G8B8A8_UNORM,
0.0f, 0.0f, 0.0f, 1.0f
);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateDepthStencilClearValue](create-depth-stencil-clear-value.md)

View File

@@ -0,0 +1,29 @@
# D3D12Common::CreateScissorRect
```cpp
inline D3D12_RECT CreateScissorRect(int left, int top, int right, int bottom)
```
创建裁剪矩形(剪刀矩形)。
**参数:**
- `left` - 矩形左边界
- `top` - 矩形上边界
- `right` - 矩形右边界
- `bottom` - 矩形下边界
**返回:** 配置好的 `D3D12_RECT` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
D3D12_RECT scissorRect = CreateScissorRect(0, 0, 1280, 720);
cmdList->RSSetScissorRects(1, &scissorRect);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateViewport](create-viewport.md)

View File

@@ -0,0 +1,39 @@
# D3D12Common::CreateTransitionBarrier
```cpp
inline D3D12_RESOURCE_BARRIER CreateTransitionBarrier(
ID3D12Resource* resource,
D3D12_RESOURCE_STATES stateBefore,
D3D12_RESOURCE_STATES stateAfter,
UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES
)
```
创建资源状态转换屏障,用于同步资源状态转换。
**参数:**
- `resource` - 目标资源指针
- `stateBefore` - 转换前的资源状态
- `stateAfter` - 转换后的资源状态
- `subresource` - 子资源索引,默认为所有子资源
**返回:** 配置好的 `D3D12_RESOURCE_BARRIER` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
ID3D12Resource* texture = ...;
D3D12_RESOURCE_BARRIER barrier = CreateTransitionBarrier(
texture,
D3D12_RESOURCE_STATE_RENDER_TARGET,
D3D12_RESOURCE_STATE_COMMON
);
cmdList->ResourceBarrier(1, &barrier);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [D3D12CommandList](../command-list/command-list.md)

View File

@@ -0,0 +1,27 @@
# D3D12Common::CreateUAVBarrier
```cpp
inline D3D12_RESOURCE_BARRIER CreateUAVBarrier(ID3D12Resource* resource = nullptr)
```
创建无序访问视图UAV屏障用于同步 UAV 访问。
**参数:**
- `resource` - UAV 资源指针,默认为 `nullptr`(全局 UAV 屏障)
**返回:** 配置好的 `D3D12_RESOURCE_BARRIER` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
ID3D12Resource* uavResource = ...;
D3D12_RESOURCE_BARRIER barrier = CreateUAVBarrier(uavResource);
cmdList->ResourceBarrier(1, &barrier);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateTransitionBarrier](create-transition-barrier.md)

View File

@@ -0,0 +1,37 @@
# D3D12Common::CreateVertexBufferView
```cpp
inline D3D12_VERTEX_BUFFER_VIEW CreateVertexBufferView(
D3D12_GPU_VIRTUAL_ADDRESS bufferLocation,
UINT sizeInBytes,
UINT strideInBytes
)
```
创建顶点缓冲区视图。
**参数:**
- `bufferLocation` - 顶点缓冲区 GPU 虚拟地址
- `sizeInBytes` - 缓冲区大小(字节)
- `strideInBytes` - 单个顶点的大小(字节)
**返回:** 配置好的 `D3D12_VERTEX_BUFFER_VIEW` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
ID3D12Resource* vertexBuffer = ...;
D3D12_VERTEX_BUFFER_VIEW vbView = CreateVertexBufferView(
vertexBuffer->GetGPUVirtualAddress(),
vertexBufferSize,
sizeof(Vertex)
);
cmdList->IASetVertexBuffers(0, 1, &vbView);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateIndexBufferView](create-index-buffer-view.md)

View File

@@ -0,0 +1,38 @@
# D3D12Common::CreateViewport
```cpp
inline D3D12_VIEWPORT CreateViewport(
float width,
float height,
float topLeftX = 0.0f,
float topLeftY = 0.0f,
float minDepth = 0.0f,
float maxDepth = 1.0f
)
```
创建 D3D12 视口结构。
**参数:**
- `width` - 视口宽度(像素)
- `height` - 视口高度(像素)
- `topLeftX` - 视口左上角 X 坐标,默认为 0
- `topLeftY` - 视口左上角 Y 坐标,默认为 0
- `minDepth` - 最小深度值,默认为 0
- `maxDepth` - 最大深度值,默认为 1
**返回:** 配置好的 `D3D12_VIEWPORT` 结构
**线程安全:** ✅(纯函数)
**示例:**
```cpp
D3D12_VIEWPORT viewport = CreateViewport(1280.0f, 720.0f, 0.0f, 0.0f, 0.0f, 1.0f);
cmdList->RSSetViewports(1, &viewport);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CreateScissorRect](create-scissor-rect.md)

View File

@@ -0,0 +1,26 @@
# D3D12Common::GetCBV_SRV_UAVDescriptorSize
```cpp
inline UINT GetCBV_SRV_UAVDescriptorSize(ID3D12Device* device)
```
获取常量缓冲区视图CBV、着色器资源视图SRV和无序访问视图UAV的描述符大小。
**参数:**
- `device` - D3D12 设备指针
**返回:** CBV/SRV/UAV 描述符大小(字节)
**线程安全:** ✅(只读操作)
**示例:**
```cpp
ID3D12Device* device = ...;
UINT descriptorSize = GetCBV_SRV_UAVDescriptorSize(device);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [GetSamplerDescriptorSize](get-sampler-descriptor-size.md)

View File

@@ -0,0 +1,35 @@
# D3D12Common::GetCPUDescriptorHandle
```cpp
inline D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandle(
D3D12_CPU_DESCRIPTOR_HANDLE baseHandle,
UINT offsetInDescriptors,
UINT descriptorSize
)
```
计算偏移后的 CPU 描述符句柄。
**参数:**
- `baseHandle` - 基础描述符句柄
- `offsetInDescriptors` - 描述符偏移数量
- `descriptorSize` - 单个描述符大小(字节)
**返回:** 偏移后的 CPU 描述符句柄
**线程安全:** ✅(纯函数)
**示例:**
```cpp
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = GetCPUDescriptorHandle(
heapStartHandle,
2, // 第3个描述符
rtvDescriptorSize
);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [GetGPUDescriptorHandle](get-gpu-descriptor-handle.md)

View File

@@ -0,0 +1,28 @@
# D3D12Common::GetDescriptorHandleIncrementSize
```cpp
inline UINT GetDescriptorHandleIncrementSize(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE heapType)
```
获取指定描述符堆类型的描述符增量大小(增量偏移值)。
**参数:**
- `device` - D3D12 设备指针
- `heapType` - 描述符堆类型(`D3D12_DESCRIPTOR_HEAP_TYPE`
**返回:** 指定类型的描述符增量大小(字节)
**线程安全:** ✅(只读操作)
**示例:**
```cpp
ID3D12Device* device = ...;
UINT rtvIncSize = GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
UINT srvIncSize = GetDescriptorHandleIncrementSize(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [D3D12DescriptorHeap](../descriptor-heap/descriptor-heap.md)

View File

@@ -0,0 +1,26 @@
# D3D12Common::GetDSVDescriptorSize
```cpp
inline UINT GetDSVDescriptorSize(ID3D12Device* device)
```
获取深度模板视图DSV的描述符大小。
**参数:**
- `device` - D3D12 设备指针
**返回:** DSV 描述符大小(字节)
**线程安全:** ✅(只读操作)
**示例:**
```cpp
ID3D12Device* device = ...;
UINT dsvSize = GetDSVDescriptorSize(device);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [GetRTVDescriptorSize](get-rtv-descriptor-size.md)

View File

@@ -0,0 +1,35 @@
# D3D12Common::GetGPUDescriptorHandle
```cpp
inline D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandle(
D3D12_GPU_DESCRIPTOR_HANDLE baseHandle,
UINT offsetInDescriptors,
UINT descriptorSize
)
```
计算偏移后的 GPU 描述符句柄。
**参数:**
- `baseHandle` - 基础描述符句柄
- `offsetInDescriptors` - 描述符偏移数量
- `descriptorSize` - 单个描述符大小(字节)
**返回:** 偏移后的 GPU 描述符句柄
**线程安全:** ✅(纯函数)
**示例:**
```cpp
D3D12_GPU_DESCRIPTOR_HANDLE srvHandle = GetGPUDescriptorHandle(
heapStartHandle,
5, // 第6个描述符
srvDescriptorSize
);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [GetCPUDescriptorHandle](get-cpu-descriptor-handle.md)

View File

@@ -0,0 +1,27 @@
# D3D12Common::GetRTVDescriptorSize
```cpp
inline UINT GetRTVDescriptorSize(ID3D12Device* device)
```
获取渲染目标视图RTV的描述符大小。
**参数:**
- `device` - D3D12 设备指针
**返回:** RTV 描述符大小(字节)
**线程安全:** ✅(只读操作)
**示例:**
```cpp
ID3D12Device* device = ...;
UINT rtvSize = GetRTVDescriptorSize(device);
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = GetCPUDescriptorHandle(baseHandle, 0, rtvSize);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [D3D12RenderTargetView](../render-target-view/render-target-view.md)

View File

@@ -0,0 +1,26 @@
# D3D12Common::GetSamplerDescriptorSize
```cpp
inline UINT GetSamplerDescriptorSize(ID3D12Device* device)
```
获取采样器Sampler的描述符大小。
**参数:**
- `device` - D3D12 设备指针
**返回:** Sampler 描述符大小(字节)
**线程安全:** ✅(只读操作)
**示例:**
```cpp
ID3D12Device* device = ...;
UINT samplerSize = GetSamplerDescriptorSize(device);
```
## 相关文档
- [D3D12Common 总览](common.md)
- [GetCBV_SRV_UAVDescriptorSize](get-cbv-srv-uav-descriptor-size.md)

View File

@@ -0,0 +1,29 @@
# D3D12Common::IsDepthStencilFormatSupported
```cpp
inline bool IsDepthStencilFormatSupported(ID3D12Device* device, DXGI_FORMAT format)
```
检查指定格式是否支持作为深度模板缓冲区。
**参数:**
- `device` - D3D12 设备指针
- `format` - 要检查的 DXGI 格式
**返回:** 如果格式支持作为深度模板返回 `true`
**线程安全:** ✅(只读查询)
**示例:**
```cpp
ID3D12Device* device = ...;
if (IsDepthStencilFormatSupported(device, DXGI_FORMAT_D24_UNORM_S8_UINT)) {
// 可以使用该格式作为深度模板
}
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CheckFormatSupport](check-format-support.md)

View File

@@ -0,0 +1,29 @@
# D3D12Common::IsRenderTargetFormatSupported
```cpp
inline bool IsRenderTargetFormatSupported(ID3D12Device* device, DXGI_FORMAT format)
```
检查指定格式是否支持作为渲染目标。
**参数:**
- `device` - D3D12 设备指针
- `format` - 要检查的 DXGI 格式
**返回:** 如果格式支持作为渲染目标返回 `true`
**线程安全:** ✅(只读查询)
**示例:**
```cpp
ID3D12Device* device = ...;
if (IsRenderTargetFormatSupported(device, DXGI_FORMAT_R8G8B8A8_UNORM)) {
// 可以使用该格式作为渲染目标
}
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CheckFormatSupport](check-format-support.md)

View File

@@ -0,0 +1,29 @@
# D3D12Common::IsShaderResourceFormatSupported
```cpp
inline bool IsShaderResourceFormatSupported(ID3D12Device* device, DXGI_FORMAT format)
```
检查指定格式是否支持作为着色器资源。
**参数:**
- `device` - D3D12 设备指针
- `format` - 要检查的 DXGI 格式
**返回:** 如果格式支持作为着色器资源返回 `true`
**线程安全:** ✅(只读查询)
**示例:**
```cpp
ID3D12Device* device = ...;
if (IsShaderResourceFormatSupported(device, DXGI_FORMAT_R32G32B32_FLOAT)) {
// 可以在着色器中读取该格式
}
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CheckFormatSupport](check-format-support.md)

View File

@@ -0,0 +1,29 @@
# D3D12Common::IsTextureFormatSupported
```cpp
inline bool IsTextureFormatSupported(ID3D12Device* device, DXGI_FORMAT format)
```
检查指定格式是否支持作为纹理。
**参数:**
- `device` - D3D12 设备指针
- `format` - 要检查的 DXGI 格式
**返回:** 如果格式支持作为纹理返回 `true`
**线程安全:** ✅(只读查询)
**示例:**
```cpp
ID3D12Device* device = ...;
if (IsTextureFormatSupported(device, DXGI_FORMAT_BC1_UNORM)) {
// 可以创建该格式的纹理
}
```
## 相关文档
- [D3D12Common 总览](common.md)
- [CheckFormatSupport](check-format-support.md)