Remove RHI interface inheritance from all D3D12 backend classes
- D3D12Device, D3D12CommandQueue, D3D12CommandAllocator, D3D12Fence - D3D12DescriptorHeap, D3D12QueryHeap, D3D12RootSignature - D3D12PipelineState, D3D12Sampler, D3D12Shader - D3D12Buffer, D3D12Texture, D3D12SwapChain All D3D12 backend classes now directly use D3D12 APIs without going through RHI interface abstraction. This decouples the D3D12 backend from the RHI abstraction layer. Test: D3D12 rendering test passed (screenshot comparison 100% match)
This commit is contained in:
424
docs/Unity_SRP_API_Reference.md
Normal file
424
docs/Unity_SRP_API_Reference.md
Normal file
@@ -0,0 +1,424 @@
|
||||
# Unity SRP (Scriptable Render Pipeline) API 参考文档
|
||||
|
||||
## 1. 概述
|
||||
|
||||
Unity 的可编写脚本渲染管线 (Scriptable Render Pipeline, SRP) 是一项允许通过 C# 脚本控制渲染的功能。SRP 是通用渲染管线 (URP) 和高清渲染管线 (HDRP) 的底层技术基础。
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
---
|
||||
|
||||
## 2. 核心类 API
|
||||
|
||||
### 2.1 RenderPipeline 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 提供实现可编写脚本渲染管线的渲染逻辑的方式。继承自此类以重写 `Render` 方法来实现自定义 SRP。
|
||||
|
||||
**示例代码**:
|
||||
```csharp
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class CustomRenderPipeline : RenderPipeline
|
||||
{
|
||||
protected override void Render(ScriptableRenderContext context, List<Camera> cameras)
|
||||
{
|
||||
// 实现自定义 SRP 渲染逻辑
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**属性**:
|
||||
| 属性 | 描述 |
|
||||
|------|------|
|
||||
| `disposed` | 返回 true 表示 RenderPipeline 无效或已销毁 |
|
||||
|
||||
**受保护的方法**:
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `IsPreviewSupported()` | 指定相机是否可以预览 |
|
||||
| `IsRenderRequestSupported()` | 实现此方法以指定特定的相机和渲染请求组合是否受支持 |
|
||||
| `ProcessRenderRequests()` | 执行使用 RenderPipeline.SubmitRenderRequest 提交的渲染请求 |
|
||||
| `Render()` | 定义此 RenderPipeline 自定义渲染的入口点方法 |
|
||||
|
||||
**静态方法**:
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `BeginCameraRendering` | 调用 RenderPipelineManager.beginCameraRendering 委托 |
|
||||
| `BeginContextRendering` | 调用 RenderPipelineManager.beginContextRendering 和 RenderPipelineManager.beginFrameRendering 委托 |
|
||||
| `EndCameraRendering` | 调用 RenderPipelineManager.endCameraRendering 委托 |
|
||||
| `EndContextRendering` | 调用 RenderPipelineManager.endContextRendering 和 RenderPipelineManager.endFrameRendering 委托 |
|
||||
| `SubmitRenderRequest` | 使用渲染管线向相机提交渲染请求(在 Unity 渲染循环之外) |
|
||||
| `SupportsRenderRequest` | 检查渲染管线是否支持使用相机的 RequestData 类型 |
|
||||
|
||||
---
|
||||
|
||||
### 2.2 RenderPipelineAsset 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**继承**: `ScriptableObject`
|
||||
|
||||
**描述**: 生成特定 IRenderPipeline 的资源。IRenderPipelineAsset 的默认实现。管理继承类型的生命周期,并确保创建的 IRenderPipeline 在资源更改时失效。
|
||||
|
||||
**属性**:
|
||||
| 属性 | 描述 |
|
||||
|------|------|
|
||||
| `autodeskInteractiveMaskedShader` | 获取此管线的默认 Autodesk Interactive 遮罩 Shader |
|
||||
| `autodeskInteractiveShader` | 获取此管线的默认 Autodesk Interactive Shader |
|
||||
| `autodeskInteractiveTransparentShader` | 获取此管线的默认 Autodesk Interactive 透明 Shader |
|
||||
| `default2DMaskMaterial` | 获取 Sprite Masks 使用的默认 2D 遮罩材质 |
|
||||
| `default2DMaterial` | 返回此管线的默认 2D 材质 |
|
||||
| `defaultLineMaterial` | 返回此管线的默认线条材质 |
|
||||
| `defaultMaterial` | 返回此管线的默认材质 |
|
||||
| `defaultParticleMaterial` | 返回此管线的默认粒子材质 |
|
||||
| `defaultShader` | 返回此管线的默认 Shader |
|
||||
| `defaultSpeedTree7Shader` | 返回 SpeedTree v7 Shader |
|
||||
| `defaultSpeedTree8Shader` | 返回 SpeedTree v8 Shader |
|
||||
| `defaultSpeedTree9Shader` | 返回 SpeedTree v9 Shader |
|
||||
| `defaultTerrainMaterial` | 返回此管线的默认地形材质 |
|
||||
| `defaultUIETC1SupportedMaterial` | 返回默认 UI ETC1 材质 |
|
||||
| `defaultUIMaterial` | 返回默认 UI 材质 |
|
||||
| `defaultUIOverdrawMaterial` | 返回默认 UI overdraw 材质 |
|
||||
| `pipelineType` | 返回与此 RenderPipelineAsset 实例关联的 RenderPipeline 类型 |
|
||||
| `renderPipelineShaderTag` | 返回此资源描述的渲染管线的 Shader Tag 值 |
|
||||
| `terrainBrushPassIndex` | 编辑器中地形笔刷的渲染索引 |
|
||||
| `terrainDetailGrassBillboardShader` | 返回此管线的细节草 Billboard Shader |
|
||||
| `terrainDetailGrassShader` | 返回此管线的细节草 Shader |
|
||||
| `terrainDetailLitShader` | 返回此管线的细节光照 Shader |
|
||||
|
||||
**受保护的方法**:
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `CreatePipeline()` | 创建此资源特有的 IRenderPipeline |
|
||||
| `EnsureGlobalSettings()` | 确保全局设置已准备好并注册到 GraphicsSettings |
|
||||
| `OnDisable()` | RenderPipelineAsset 的 OnDisable 默认实现 |
|
||||
| `OnValidate()` | RenderPipelineAsset 的 OnValidate 默认实现 |
|
||||
|
||||
---
|
||||
|
||||
### 2.3 ScriptableRenderContext 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 渲染上下文的可编写脚本表示。用于调度和执行渲染命令。
|
||||
|
||||
**主要方法**:
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `BeginRenderPass()` | 开始渲染 pass |
|
||||
| `EndRenderPass()` | 结束渲染 pass |
|
||||
| `ExecuteCommandBuffer()` | 执行命令缓冲区 |
|
||||
| `Submit()` | 提交所有待处理的渲染命令 |
|
||||
| `SetupCameraProperties()` | 设置相机属性 |
|
||||
|
||||
---
|
||||
|
||||
### 2.4 ScriptableRenderPass 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 可编写脚本的渲染 Pass 基类。用于实现自定义渲染 passes。
|
||||
|
||||
**主要成员**:
|
||||
| 成员 | 描述 |
|
||||
|------|------|
|
||||
| `renderPassEvent` | 指定 Pass 在渲染管线中的执行时机 |
|
||||
| `ConfigureInput()` | 配置渲染器输入 |
|
||||
| `ConfigureTarget()` | 配置渲染目标 |
|
||||
| `Execute()` | 执行 Pass 的渲染逻辑 |
|
||||
| `FrameCleanup()` | 帧清理回调 |
|
||||
| `OnCameraSetup()` | 相机设置回调 |
|
||||
| `OnCameraCleanup()` | 相机清理回调 |
|
||||
|
||||
---
|
||||
|
||||
### 2.5 ScriptableRenderer 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 可编写脚本的渲染器实现基类。
|
||||
|
||||
**主要方法**:
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `EnqueuePass()` | 将渲染 Pass 加入队列 |
|
||||
| `Execute()` | 执行渲染 |
|
||||
| `Initialize()` | 初始化渲染器 |
|
||||
| `Submit()` | 提交渲染 |
|
||||
|
||||
---
|
||||
|
||||
### 2.6 RenderPassEvent 枚举
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 指定渲染 Pass 在渲染管线中的执行时机。
|
||||
|
||||
**枚举值**:
|
||||
| 值 | 描述 |
|
||||
|------|------|
|
||||
| `BeforeRendering` | 渲染开始前 |
|
||||
| `BeforeRenderingShadows` | 阴影渲染前 |
|
||||
| `BeforeRenderingPrePasses` | 预 Pass 前 |
|
||||
| `BeforeRenderingOpaques` | 不透明物体前 |
|
||||
| `BeforeRenderingGbuffer` | G-Buffer 前 |
|
||||
| `BeforeRenderingLit` | 光照物体前 |
|
||||
| `BeforeRenderingTransparents` | 透明物体前 |
|
||||
| `BeforeRenderingOverlays` | 覆盖层前 |
|
||||
| `AfterRendering` | 渲染结束后 |
|
||||
| `AfterRenderingShadows` | 阴影渲染后 |
|
||||
| `AfterRenderingPrePasses` | 预 Pass 后 |
|
||||
| `AfterRenderingOpaques` | 不透明物体后 |
|
||||
| `AfterRenderingGbuffer` | G-Buffer 后 |
|
||||
| `AfterRenderingLit` | 光照物体后 |
|
||||
| `AfterRenderingTransparents` | 透明物体后 |
|
||||
| `AfterRenderingOverlays` | 覆盖层后 |
|
||||
|
||||
---
|
||||
|
||||
## 3. CommandBuffer 相关 API
|
||||
|
||||
### 3.1 CommandBuffer 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 用于存储渲染命令的缓冲区。
|
||||
|
||||
**常用方法**:
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `Blit()` | 执行纹理拷贝 (blit) 操作 |
|
||||
| `DrawRenderer()` | 绘制渲染器 |
|
||||
| `DrawMesh()` | 绘制网格 |
|
||||
| `DrawMeshInstanced()` | 绘制实例化网格 |
|
||||
| `SetRenderTarget()` | 设置渲染目标 |
|
||||
| `SetGlobalTexture()` | 设置全局纹理 |
|
||||
| `SetGlobalFloat()` | 设置全局浮点数 |
|
||||
| `SetGlobalVector()` | 设置全局向量 |
|
||||
| `SetGlobalMatrix()` | 设置全局矩阵 |
|
||||
| `SetViewProjectionMatrices()` | 设置视图投影矩阵 |
|
||||
| `ClearRenderTarget()` | 清除渲染目标 |
|
||||
| `CopyTexture()` | 复制纹理 |
|
||||
| `ComputeDispatch()` | 计算着色器调度 |
|
||||
|
||||
### 3.2 CommandBufferPool 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: CommandBuffer 池化管理器,用于优化内存分配。
|
||||
|
||||
---
|
||||
|
||||
## 4. 渲染相关类
|
||||
|
||||
### 4.1 ShaderTagId
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: Shader 标签标识符,用于标识 Shader 的渲染通道。
|
||||
|
||||
### 4.2 LightProbe
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 光照探针管理类,用于处理光照探针数据。
|
||||
|
||||
### 4.3 DrawRendererSettings
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
**描述**: 渲染器绘制设置结构体,用于配置渲染器绘制参数。
|
||||
|
||||
**主要成员**:
|
||||
| 成员 | 描述 |
|
||||
|------|------|
|
||||
| `sorting` | 排序设置 |
|
||||
| `flags` | 渲染标志 |
|
||||
| `rendererConfiguration` | 渲染器配置 |
|
||||
| `passIndex` | Pass 索引 |
|
||||
|
||||
---
|
||||
|
||||
## 5. URP (Universal Render Pipeline) 核心 API
|
||||
|
||||
**包**: `com.unity.render-pipelines.universal`
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering`
|
||||
|
||||
URP 是建立在 SRP Core 之上的渲染管线,提供了更简化的 API。
|
||||
|
||||
### 5.1 UniversalRenderPipeline 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.Universal`
|
||||
|
||||
**描述**: URP 的主渲染管线类。
|
||||
|
||||
### 5.2 UniversalRenderPipelineAsset 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.Universal`
|
||||
|
||||
**描述**: URP 的渲染管线资源资产。
|
||||
|
||||
### 5.3 ForwardRenderer 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.Universal`
|
||||
|
||||
**描述**: URP 的前向渲染器实现。
|
||||
|
||||
### 5.4 RenderPassEvent (URP扩展)
|
||||
|
||||
URP 扩展了标准的 RenderPassEvent,添加了 URP 特有的渲染事件。
|
||||
|
||||
---
|
||||
|
||||
## 6. HDRP (High Definition Render Pipeline) 核心 API
|
||||
|
||||
**包**: `com.unity.render-pipelines.high-definition`
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.HighDefinition`
|
||||
|
||||
HDRP 是建立在 SRP Core 之上的高端渲染管线,提供了高质量的渲染效果。
|
||||
|
||||
### 6.1 HDRenderPipeline 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.HighDefinition`
|
||||
|
||||
**描述**: HDRP 的主渲染管线类。
|
||||
|
||||
### 6.2 HDRenderPipelineAsset 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.HighDefinition`
|
||||
|
||||
**描述**: HDRP 的渲染管线资源资产。
|
||||
|
||||
### 6.3 HDRenderer 类
|
||||
|
||||
**命名空间**: `UnityEngine.Rendering.HighDefinition`
|
||||
|
||||
**描述**: HDRP 的渲染器实现。
|
||||
|
||||
---
|
||||
|
||||
## 7. SRP Core 核心类 (com.unity.render-pipelines.core)
|
||||
|
||||
### 7.1 核心工具类
|
||||
|
||||
| 类名 | 描述 |
|
||||
|------|------|
|
||||
| `CoreUtils` | SRP 核心工具函数集合 |
|
||||
| `CoreMatrixUtils` | 矩阵操作工具函数 |
|
||||
| `Blitter` | Blit (纹理拷贝) 工具 |
|
||||
| `RTHandle` | 可自动缩放的渲染纹理 |
|
||||
| `RTHandleSystem` | RTHandle 纹理管理系统 |
|
||||
| `Volume` | 通用 Volume 组件 |
|
||||
| `VolumeManager` | Volume 全局管理器 |
|
||||
| `VolumeProfile` | Volume 设置资源 |
|
||||
| `VolumeComponent` | Volume 组件基类 |
|
||||
|
||||
### 7.2 调试相关类
|
||||
|
||||
| 类名 | 描述 |
|
||||
|------|------|
|
||||
| `DebugManager` | 调试窗口管理器 |
|
||||
| `DebugUI` | 调试 UI 类 |
|
||||
| `ProfilingSampler` | CPU/GPU 性能分析采样器 |
|
||||
| `ProfilingScope` | 性能分析作用域 |
|
||||
|
||||
### 7.3 资源管理类
|
||||
|
||||
| 类名 | 描述 |
|
||||
|------|------|
|
||||
| `RenderPipelineGlobalSettings` | 渲染管线全局设置 |
|
||||
| `RenderPipelineResources` | 渲染管线资源资产基类 |
|
||||
| `ConstantBuffer` | 常量缓冲区管理 |
|
||||
|
||||
---
|
||||
|
||||
## 8. 使用示例
|
||||
|
||||
### 8.1 创建自定义渲染管线
|
||||
|
||||
```csharp
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class CustomRenderPipeline : RenderPipeline
|
||||
{
|
||||
protected override void Render(ScriptableRenderContext context, List<Camera> cameras)
|
||||
{
|
||||
foreach (var camera in cameras)
|
||||
{
|
||||
// 渲染每个相机
|
||||
Render(context, camera);
|
||||
}
|
||||
|
||||
// 提交渲染命令
|
||||
context.Submit();
|
||||
}
|
||||
|
||||
private void Render(ScriptableRenderContext context, Camera camera)
|
||||
{
|
||||
// 设置相机属性
|
||||
context.SetupCameraProperties(camera);
|
||||
|
||||
// 创建命令缓冲区
|
||||
CommandBuffer cmd = CommandBufferPool.Get("Clear");
|
||||
cmd.ClearRenderTarget(true, true, Color.black);
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
CommandBufferPool.Release(cmd);
|
||||
|
||||
// 提交
|
||||
context.Submit();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 8.2 创建自定义渲染 Pass
|
||||
|
||||
```csharp
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class CustomRenderPass : ScriptableRenderPass
|
||||
{
|
||||
public CustomRenderPass()
|
||||
{
|
||||
// 设置 Pass 执行时机
|
||||
renderPassEvent = RenderPassEvent.BeforeRenderingOpaques;
|
||||
}
|
||||
|
||||
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
|
||||
{
|
||||
// 相机设置
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
// 执行渲染逻辑
|
||||
}
|
||||
|
||||
public override void FrameCleanup(CommandBuffer cmd)
|
||||
{
|
||||
// 帧清理
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. 官方文档资源
|
||||
|
||||
- [SRP 官方文档](https://docs.unity3d.com/Manual/ScriptableRenderPipeline.html)
|
||||
- [URP Scripting API](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest/api/)
|
||||
- [HDRP Scripting API](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/api/)
|
||||
- [SRP Core Scripting API](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest/api/)
|
||||
|
||||
---
|
||||
|
||||
*文档生成时间: 2026-03-16*
|
||||
*Unity 版本: 2023.1+*
|
||||
@@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12Buffer : public IBuffer {
|
||||
class D3D12Buffer {
|
||||
public:
|
||||
D3D12Buffer();
|
||||
~D3D12Buffer();
|
||||
@@ -29,18 +29,18 @@ public:
|
||||
|
||||
void UpdateData(const void* data, uint64_t size);
|
||||
|
||||
void* GetNativeHandle() const override { return m_resource.Get(); }
|
||||
ResourceStates GetState() const override { return m_state; }
|
||||
void SetState(ResourceStates state) override { m_state = state; }
|
||||
void* GetNativeHandle() const { return m_resource.Get(); }
|
||||
ResourceStates GetState() const { return m_state; }
|
||||
void SetState(ResourceStates state) { m_state = state; }
|
||||
|
||||
uint64_t GetGPUAddress() const override { return m_resource->GetGPUVirtualAddress(); }
|
||||
size_t GetSize() const override { return GetDesc().Width; }
|
||||
uint64_t GetGPUAddress() const { return m_resource->GetGPUVirtualAddress(); }
|
||||
size_t GetSize() const { return GetDesc().Width; }
|
||||
|
||||
const std::string& GetName() const override { return m_name; }
|
||||
void SetName(const std::string& name) override { m_name = name; }
|
||||
const std::string& GetName() const { return m_name; }
|
||||
void SetName(const std::string& name) { m_name = name; }
|
||||
|
||||
uint32_t GetStride() const override { return m_stride; }
|
||||
BufferType GetBufferType() const override { return m_bufferType; }
|
||||
uint32_t GetStride() const { return m_stride; }
|
||||
BufferType GetBufferType() const { return m_bufferType; }
|
||||
|
||||
void SetStride(uint32_t stride) { m_stride = stride; }
|
||||
void SetBufferType(BufferType type) { m_bufferType = type; }
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12CommandAllocator : public ICommandAllocator {
|
||||
class D3D12CommandAllocator {
|
||||
public:
|
||||
D3D12CommandAllocator();
|
||||
~D3D12CommandAllocator();
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
|
||||
void Shutdown();
|
||||
|
||||
void Reset() override;
|
||||
bool IsReady() const override;
|
||||
void Reset();
|
||||
bool IsReady() const;
|
||||
|
||||
ID3D12CommandAllocator* GetCommandAllocator() const { return m_commandAllocator.Get(); }
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace RHI {
|
||||
|
||||
class D3D12Fence;
|
||||
|
||||
class D3D12CommandQueue : public ICommandQueue {
|
||||
class D3D12CommandQueue {
|
||||
public:
|
||||
D3D12CommandQueue();
|
||||
~D3D12CommandQueue();
|
||||
@@ -22,17 +22,17 @@ public:
|
||||
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
|
||||
void Shutdown();
|
||||
|
||||
void ExecuteCommandLists(uint32_t count, ICommandList** lists) override;
|
||||
void ExecuteCommandLists(uint32_t count, ICommandList** lists);
|
||||
void ExecuteCommandLists(uint32_t count, ID3D12CommandList** lists);
|
||||
void Signal(IFence* fence, uint64_t value) override;
|
||||
void Signal(IFence* fence, uint64_t value);
|
||||
void Signal(ID3D12Fence* fence, uint64_t value);
|
||||
void Wait(IFence* fence, uint64_t value) override;
|
||||
void Wait(IFence* fence, uint64_t value);
|
||||
void Wait(ID3D12Fence* fence, uint64_t value);
|
||||
uint64_t GetCompletedValue() override;
|
||||
void WaitForIdle() override;
|
||||
uint64_t GetCompletedValue();
|
||||
void WaitForIdle();
|
||||
|
||||
CommandQueueType GetType() const override { return m_type; }
|
||||
uint64_t GetTimestampFrequency() const override { return m_timestampFrequency; }
|
||||
CommandQueueType GetType() const { return m_type; }
|
||||
uint64_t GetTimestampFrequency() const { return m_timestampFrequency; }
|
||||
|
||||
ID3D12CommandQueue* GetCommandQueue() const { return m_commandQueue.Get(); }
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12DescriptorHeap : public IDescriptorHeap {
|
||||
class D3D12DescriptorHeap {
|
||||
public:
|
||||
D3D12DescriptorHeap();
|
||||
~D3D12DescriptorHeap();
|
||||
@@ -23,10 +23,10 @@ public:
|
||||
|
||||
ID3D12DescriptorHeap* GetDescriptorHeap() const { return m_descriptorHeap.Get(); }
|
||||
|
||||
CPUDescriptorHandle GetCPUDescriptorHandle(uint32_t index) override;
|
||||
GPUDescriptorHandle GetGPUDescriptorHandle(uint32_t index) override;
|
||||
uint32_t GetDescriptorCount() const override;
|
||||
DescriptorType GetType() const override;
|
||||
CPUDescriptorHandle GetCPUDescriptorHandle(uint32_t index);
|
||||
GPUDescriptorHandle GetGPUDescriptorHandle(uint32_t index);
|
||||
uint32_t GetDescriptorCount() const;
|
||||
DescriptorType GetType() const;
|
||||
|
||||
uint32_t GetDescriptorSize() const { return m_descriptorSize; }
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart() const;
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12Fence : public IFence {
|
||||
class D3D12Fence {
|
||||
public:
|
||||
D3D12Fence();
|
||||
~D3D12Fence();
|
||||
@@ -19,10 +19,10 @@ public:
|
||||
bool Initialize(ID3D12Device* device, uint64_t initialValue = 0);
|
||||
void Shutdown();
|
||||
|
||||
void Signal(uint64_t value) override;
|
||||
void Wait(uint64_t value) override;
|
||||
uint64_t GetCompletedValue() override;
|
||||
void* GetEventHandle() override { return m_eventHandle; }
|
||||
void Signal(uint64_t value);
|
||||
void Wait(uint64_t value);
|
||||
uint64_t GetCompletedValue();
|
||||
void* GetEventHandle() { return m_eventHandle; }
|
||||
|
||||
ID3D12Fence* GetFence() const { return m_fence.Get(); }
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12PipelineState : public IPipelineState {
|
||||
class D3D12PipelineState {
|
||||
public:
|
||||
D3D12PipelineState();
|
||||
~D3D12PipelineState();
|
||||
@@ -21,8 +21,8 @@ public:
|
||||
|
||||
ID3D12PipelineState* GetPipelineState() const { return m_pipelineState.Get(); }
|
||||
|
||||
void* GetNativeHandle() const override { return m_pipelineState.Get(); }
|
||||
PipelineType GetType() const override { return PipelineType::Graphics; }
|
||||
void* GetNativeHandle() const { return m_pipelineState.Get(); }
|
||||
PipelineType GetType() const { return PipelineType::Graphics; }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12PipelineState> m_pipelineState;
|
||||
|
||||
@@ -12,7 +12,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12QueryHeap : public IQueryHeap {
|
||||
class D3D12QueryHeap {
|
||||
public:
|
||||
D3D12QueryHeap();
|
||||
~D3D12QueryHeap();
|
||||
@@ -22,9 +22,9 @@ public:
|
||||
|
||||
ID3D12QueryHeap* GetQueryHeap() const { return m_queryHeap.Get(); }
|
||||
|
||||
void* GetNativeHandle() const override { return m_queryHeap.Get(); }
|
||||
QueryType GetType() const override { return m_type; }
|
||||
uint32_t GetCount() const override { return m_count; }
|
||||
void* GetNativeHandle() const { return m_queryHeap.Get(); }
|
||||
QueryType GetType() const { return m_type; }
|
||||
uint32_t GetCount() const { return m_count; }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12QueryHeap> m_queryHeap;
|
||||
|
||||
@@ -12,7 +12,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12RootSignature : public IRootSignature {
|
||||
class D3D12RootSignature {
|
||||
public:
|
||||
D3D12RootSignature();
|
||||
~D3D12RootSignature();
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
|
||||
ID3D12RootSignature* GetRootSignature() const { return m_rootSignature.Get(); }
|
||||
|
||||
void* GetNativeHandle() const override { return m_rootSignature.Get(); }
|
||||
uint32_t GetParameterCount() const override { return m_parameterCount; }
|
||||
void* GetNativeHandle() const { return m_rootSignature.Get(); }
|
||||
uint32_t GetParameterCount() const { return m_parameterCount; }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12RootSignature> m_rootSignature;
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12Sampler : public ISampler {
|
||||
class D3D12Sampler {
|
||||
public:
|
||||
D3D12Sampler();
|
||||
~D3D12Sampler();
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
D3D12_SAMPLER_DESC GetDesc() const { return m_desc; }
|
||||
|
||||
void* GetNativeHandle() const override { return nullptr; }
|
||||
void* GetNativeHandle() const { return nullptr; }
|
||||
|
||||
private:
|
||||
D3D12_SAMPLER_DESC m_desc;
|
||||
|
||||
@@ -13,7 +13,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12Shader : public IShader {
|
||||
class D3D12Shader {
|
||||
public:
|
||||
D3D12Shader();
|
||||
~D3D12Shader();
|
||||
@@ -23,10 +23,10 @@ public:
|
||||
void Shutdown();
|
||||
|
||||
const D3D12_SHADER_BYTECODE GetD3D12Bytecode() const;
|
||||
virtual const void* GetBytecode() const override;
|
||||
virtual size_t GetBytecodeSize() const override;
|
||||
virtual ShaderType GetType() const override;
|
||||
virtual const InputLayoutDesc& GetInputLayout() const override;
|
||||
const void* GetBytecode() const;
|
||||
size_t GetBytecodeSize() const;
|
||||
ShaderType GetType() const;
|
||||
const InputLayoutDesc& GetInputLayout() const;
|
||||
|
||||
private:
|
||||
ComPtr<ID3DBlob> m_bytecode;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <dxgi1_4.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "../SwapChain.h"
|
||||
#include "D3D12Enum.h"
|
||||
#include "D3D12Texture.h"
|
||||
|
||||
@@ -13,7 +12,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12SwapChain : public ISwapChain {
|
||||
class D3D12SwapChain {
|
||||
public:
|
||||
D3D12SwapChain();
|
||||
~D3D12SwapChain();
|
||||
@@ -22,13 +21,13 @@ public:
|
||||
bool Initialize(IDXGISwapChain* swapChain, uint32_t width, uint32_t height);
|
||||
void Shutdown();
|
||||
|
||||
uint32_t GetCurrentBackBufferIndex() const override;
|
||||
IResource* GetBackBuffer(uint32_t index) const override;
|
||||
void Present(uint32_t syncInterval, uint32_t flags) override;
|
||||
void Resize(uint32_t width, uint32_t height) override;
|
||||
void SetFullscreen(bool fullscreen) override;
|
||||
bool IsFullscreen() const override;
|
||||
void* GetNativeHandle() const override;
|
||||
uint32_t GetCurrentBackBufferIndex() const;
|
||||
D3D12Texture* GetBackBuffer(uint32_t index) const;
|
||||
void Present(uint32_t syncInterval, uint32_t flags);
|
||||
void Resize(uint32_t width, uint32_t height);
|
||||
void SetFullscreen(bool fullscreen);
|
||||
bool IsFullscreen() const;
|
||||
void* GetNativeHandle() const;
|
||||
|
||||
IDXGISwapChain3* GetSwapChain() const { return m_swapChain.Get(); }
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12Texture : public ITexture {
|
||||
class D3D12Texture {
|
||||
public:
|
||||
D3D12Texture();
|
||||
~D3D12Texture();
|
||||
@@ -31,19 +31,19 @@ public:
|
||||
uint32_t GetDepth() const { return GetDesc().DepthOrArraySize; }
|
||||
uint32_t GetMipLevels() const { return GetDesc().MipLevels; }
|
||||
|
||||
void* GetNativeHandle() const override { return m_resource.Get(); }
|
||||
ResourceStates GetState() const override { return m_state; }
|
||||
void SetState(ResourceStates state) override { m_state = state; }
|
||||
void* GetNativeHandle() const { return m_resource.Get(); }
|
||||
ResourceStates GetState() const { return m_state; }
|
||||
void SetState(ResourceStates state) { m_state = state; }
|
||||
|
||||
uint64_t GetGPUAddress() const override { return m_resource->GetGPUVirtualAddress(); }
|
||||
size_t GetSize() const override { return GetDesc().Width * GetDesc().Height * GetDesc().DepthOrArraySize; }
|
||||
uint64_t GetGPUAddress() const { return m_resource->GetGPUVirtualAddress(); }
|
||||
size_t GetSize() const { return GetDesc().Width * GetDesc().Height * GetDesc().DepthOrArraySize; }
|
||||
|
||||
const std::string& GetName() const override { return m_name; }
|
||||
void SetName(const std::string& name) override { m_name = name; }
|
||||
const std::string& GetName() const { return m_name; }
|
||||
void SetName(const std::string& name) { m_name = name; }
|
||||
|
||||
uint32_t GetArraySize() const override { return GetDesc().DepthOrArraySize; }
|
||||
Format GetFormat() const override { return static_cast<Format>(GetDesc().Format); }
|
||||
TextureType GetTextureType() const override { return TextureType::Texture2D; }
|
||||
uint32_t GetArraySize() const { return GetDesc().DepthOrArraySize; }
|
||||
Format GetFormat() const { return static_cast<Format>(GetDesc().Format); }
|
||||
TextureType GetTextureType() const { return TextureType::Texture2D; }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12Resource> m_resource;
|
||||
|
||||
@@ -74,7 +74,7 @@ uint32_t D3D12SwapChain::GetCurrentBackBufferIndex() const {
|
||||
return m_swapChain->GetCurrentBackBufferIndex();
|
||||
}
|
||||
|
||||
IResource* D3D12SwapChain::GetBackBuffer(uint32_t index) const {
|
||||
D3D12Texture* D3D12SwapChain::GetBackBuffer(uint32_t index) const {
|
||||
if (index < m_backBuffers.size()) {
|
||||
return const_cast<D3D12Texture*>(&m_backBuffers[index]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user