From 0ce312e6483b33a665a9586d9075792f3e02d9ee Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Mon, 16 Mar 2026 15:48:14 +0800 Subject: [PATCH] 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) --- docs/Unity_SRP_API_Reference.md | 424 ++++++++++++++++++ .../include/XCEngine/RHI/D3D12/D3D12Buffer.h | 20 +- .../RHI/D3D12/D3D12CommandAllocator.h | 6 +- .../XCEngine/RHI/D3D12/D3D12CommandQueue.h | 16 +- .../XCEngine/RHI/D3D12/D3D12DescriptorHeap.h | 10 +- .../include/XCEngine/RHI/D3D12/D3D12Fence.h | 10 +- .../XCEngine/RHI/D3D12/D3D12PipelineState.h | 6 +- .../XCEngine/RHI/D3D12/D3D12QueryHeap.h | 8 +- .../XCEngine/RHI/D3D12/D3D12RootSignature.h | 6 +- .../include/XCEngine/RHI/D3D12/D3D12Sampler.h | 4 +- .../include/XCEngine/RHI/D3D12/D3D12Shader.h | 10 +- .../XCEngine/RHI/D3D12/D3D12SwapChain.h | 17 +- .../include/XCEngine/RHI/D3D12/D3D12Texture.h | 22 +- engine/src/RHI/D3D12/D3D12SwapChain.cpp | 2 +- 14 files changed, 492 insertions(+), 69 deletions(-) create mode 100644 docs/Unity_SRP_API_Reference.md diff --git a/docs/Unity_SRP_API_Reference.md b/docs/Unity_SRP_API_Reference.md new file mode 100644 index 00000000..c6fa7a44 --- /dev/null +++ b/docs/Unity_SRP_API_Reference.md @@ -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 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 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+* diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h b/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h index 4477af27..e3ed31d6 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h @@ -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; } diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12CommandAllocator.h b/engine/include/XCEngine/RHI/D3D12/D3D12CommandAllocator.h index eebc6bbd..eb803811 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12CommandAllocator.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12CommandAllocator.h @@ -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(); } diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12CommandQueue.h b/engine/include/XCEngine/RHI/D3D12/D3D12CommandQueue.h index 3a070eb5..f02b282f 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12CommandQueue.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12CommandQueue.h @@ -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(); } diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12DescriptorHeap.h b/engine/include/XCEngine/RHI/D3D12/D3D12DescriptorHeap.h index 9d6c9f77..3cb48f37 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12DescriptorHeap.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12DescriptorHeap.h @@ -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; diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Fence.h b/engine/include/XCEngine/RHI/D3D12/D3D12Fence.h index bce8c298..1de39540 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Fence.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Fence.h @@ -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(); } diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12PipelineState.h b/engine/include/XCEngine/RHI/D3D12/D3D12PipelineState.h index ffba4486..29a0c04d 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12PipelineState.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12PipelineState.h @@ -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 m_pipelineState; diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12QueryHeap.h b/engine/include/XCEngine/RHI/D3D12/D3D12QueryHeap.h index 572a593c..c8991c95 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12QueryHeap.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12QueryHeap.h @@ -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 m_queryHeap; diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12RootSignature.h b/engine/include/XCEngine/RHI/D3D12/D3D12RootSignature.h index 8fb0968f..fa6b83de 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12RootSignature.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12RootSignature.h @@ -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 m_rootSignature; diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Sampler.h b/engine/include/XCEngine/RHI/D3D12/D3D12Sampler.h index cc328424..58d430a8 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Sampler.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Sampler.h @@ -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; diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Shader.h b/engine/include/XCEngine/RHI/D3D12/D3D12Shader.h index 549479af..fe379816 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Shader.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Shader.h @@ -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 m_bytecode; diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h b/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h index 24bb6c09..f855e0fe 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h @@ -4,7 +4,6 @@ #include #include -#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(); } diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h b/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h index 54173835..ff8b77cf 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h @@ -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(GetDesc().Format); } - TextureType GetTextureType() const override { return TextureType::Texture2D; } + uint32_t GetArraySize() const { return GetDesc().DepthOrArraySize; } + Format GetFormat() const { return static_cast(GetDesc().Format); } + TextureType GetTextureType() const { return TextureType::Texture2D; } private: ComPtr m_resource; diff --git a/engine/src/RHI/D3D12/D3D12SwapChain.cpp b/engine/src/RHI/D3D12/D3D12SwapChain.cpp index 6e502906..cc63399f 100644 --- a/engine/src/RHI/D3D12/D3D12SwapChain.cpp +++ b/engine/src/RHI/D3D12/D3D12SwapChain.cpp @@ -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(&m_backBuffers[index]); }