From a2f9277dac29b5a6b2b3915493bd24f7cff28eb9 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 18 Jun 2018 19:26:12 -0400 Subject: [PATCH] D3D12: Split D3D12Backend in Forward.h and DeviceD3D12 --- src/backend/CMakeLists.txt | 5 +- src/backend/d3d12/BindGroupD3D12.cpp | 2 +- src/backend/d3d12/BindGroupLayoutD3D12.cpp | 2 +- src/backend/d3d12/BlendStateD3D12.cpp | 2 +- src/backend/d3d12/BufferD3D12.cpp | 2 +- src/backend/d3d12/CommandAllocatorManager.cpp | 2 +- src/backend/d3d12/CommandBufferD3D12.cpp | 2 +- src/backend/d3d12/ComputePipelineD3D12.cpp | 2 +- src/backend/d3d12/DescriptorHeapAllocator.cpp | 2 +- .../{D3D12Backend.cpp => DeviceD3D12.cpp} | 2 +- .../d3d12/{D3D12Backend.h => DeviceD3D12.h} | 56 ++------------- src/backend/d3d12/Forward.h | 71 +++++++++++++++++++ src/backend/d3d12/GeneratedCodeIncludes.h | 2 +- .../d3d12/NativeSwapChainImplD3D12.cpp | 2 +- src/backend/d3d12/PipelineLayoutD3D12.cpp | 2 +- src/backend/d3d12/QueueD3D12.cpp | 2 +- .../d3d12/RenderPassDescriptorD3D12.cpp | 2 +- src/backend/d3d12/RenderPipelineD3D12.cpp | 2 +- src/backend/d3d12/ResourceAllocator.cpp | 2 +- src/backend/d3d12/ResourceUploader.cpp | 2 +- src/backend/d3d12/SamplerD3D12.cpp | 2 +- src/backend/d3d12/SwapChainD3D12.cpp | 2 +- src/backend/d3d12/TextureD3D12.cpp | 2 +- 23 files changed, 98 insertions(+), 74 deletions(-) rename src/backend/d3d12/{D3D12Backend.cpp => DeviceD3D12.cpp} (99%) rename src/backend/d3d12/{D3D12Backend.h => DeviceD3D12.h} (71%) create mode 100644 src/backend/d3d12/Forward.h diff --git a/src/backend/CMakeLists.txt b/src/backend/CMakeLists.txt index 88b19d5ce2..17b0bf79e4 100644 --- a/src/backend/CMakeLists.txt +++ b/src/backend/CMakeLists.txt @@ -233,8 +233,9 @@ if (NXT_ENABLE_D3D12) ${D3D12_DIR}/DepthStencilStateD3D12.h ${D3D12_DIR}/DescriptorHeapAllocator.cpp ${D3D12_DIR}/DescriptorHeapAllocator.h - ${D3D12_DIR}/D3D12Backend.cpp - ${D3D12_DIR}/D3D12Backend.h + ${D3D12_DIR}/DeviceD3D12.cpp + ${D3D12_DIR}/DeviceD3D12.h + ${D3D12_DIR}/Forward.h ${D3D12_DIR}/InputStateD3D12.cpp ${D3D12_DIR}/InputStateD3D12.h ${D3D12_DIR}/NativeSwapChainImplD3D12.cpp diff --git a/src/backend/d3d12/BindGroupD3D12.cpp b/src/backend/d3d12/BindGroupD3D12.cpp index e5b4967328..3701524231 100644 --- a/src/backend/d3d12/BindGroupD3D12.cpp +++ b/src/backend/d3d12/BindGroupD3D12.cpp @@ -19,7 +19,7 @@ #include "backend/d3d12/TextureD3D12.h" #include "common/BitSetIterator.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/BindGroupLayoutD3D12.cpp b/src/backend/d3d12/BindGroupLayoutD3D12.cpp index ba29fcef6a..dba077b6de 100644 --- a/src/backend/d3d12/BindGroupLayoutD3D12.cpp +++ b/src/backend/d3d12/BindGroupLayoutD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/BindGroupLayoutD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "common/BitSetIterator.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/BlendStateD3D12.cpp b/src/backend/d3d12/BlendStateD3D12.cpp index d959507f1f..61d47f49f0 100644 --- a/src/backend/d3d12/BlendStateD3D12.cpp +++ b/src/backend/d3d12/BlendStateD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/BlendStateD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "common/Assert.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/BufferD3D12.cpp b/src/backend/d3d12/BufferD3D12.cpp index f602f22d6f..e51eec8a40 100644 --- a/src/backend/d3d12/BufferD3D12.cpp +++ b/src/backend/d3d12/BufferD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/BufferD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/ResourceAllocator.h" #include "backend/d3d12/ResourceUploader.h" #include "common/Assert.h" diff --git a/src/backend/d3d12/CommandAllocatorManager.cpp b/src/backend/d3d12/CommandAllocatorManager.cpp index 15343bb030..1262d7e70c 100644 --- a/src/backend/d3d12/CommandAllocatorManager.cpp +++ b/src/backend/d3d12/CommandAllocatorManager.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/CommandAllocatorManager.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "common/Assert.h" #include "common/BitSetIterator.h" diff --git a/src/backend/d3d12/CommandBufferD3D12.cpp b/src/backend/d3d12/CommandBufferD3D12.cpp index 5df4209e53..40009b6768 100644 --- a/src/backend/d3d12/CommandBufferD3D12.cpp +++ b/src/backend/d3d12/CommandBufferD3D12.cpp @@ -19,8 +19,8 @@ #include "backend/d3d12/BindGroupLayoutD3D12.h" #include "backend/d3d12/BufferD3D12.h" #include "backend/d3d12/ComputePipelineD3D12.h" -#include "backend/d3d12/D3D12Backend.h" #include "backend/d3d12/DescriptorHeapAllocator.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/InputStateD3D12.h" #include "backend/d3d12/PipelineLayoutD3D12.h" #include "backend/d3d12/RenderPassDescriptorD3D12.h" diff --git a/src/backend/d3d12/ComputePipelineD3D12.cpp b/src/backend/d3d12/ComputePipelineD3D12.cpp index 971da4cf47..3fc9c2dbbd 100644 --- a/src/backend/d3d12/ComputePipelineD3D12.cpp +++ b/src/backend/d3d12/ComputePipelineD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/ComputePipelineD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/PipelineLayoutD3D12.h" #include "backend/d3d12/ShaderModuleD3D12.h" #include "common/Assert.h" diff --git a/src/backend/d3d12/DescriptorHeapAllocator.cpp b/src/backend/d3d12/DescriptorHeapAllocator.cpp index 320a50887c..54ddce38bf 100644 --- a/src/backend/d3d12/DescriptorHeapAllocator.cpp +++ b/src/backend/d3d12/DescriptorHeapAllocator.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/DescriptorHeapAllocator.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "common/Assert.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/D3D12Backend.cpp b/src/backend/d3d12/DeviceD3D12.cpp similarity index 99% rename from src/backend/d3d12/D3D12Backend.cpp rename to src/backend/d3d12/DeviceD3D12.cpp index c5a85b1efe..83462134fb 100644 --- a/src/backend/d3d12/D3D12Backend.cpp +++ b/src/backend/d3d12/DeviceD3D12.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/BindGroupD3D12.h" #include "backend/d3d12/BindGroupLayoutD3D12.h" diff --git a/src/backend/d3d12/D3D12Backend.h b/src/backend/d3d12/DeviceD3D12.h similarity index 71% rename from src/backend/d3d12/D3D12Backend.h rename to src/backend/d3d12/DeviceD3D12.h index 03392957c8..6a2253668c 100644 --- a/src/backend/d3d12/D3D12Backend.h +++ b/src/backend/d3d12/DeviceD3D12.h @@ -12,72 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef BACKEND_D3D12_D3D12BACKEND_H_ -#define BACKEND_D3D12_D3D12BACKEND_H_ +#ifndef BACKEND_D3D12_DEVICED3D12_H_ +#define BACKEND_D3D12_DEVICED3D12_H_ #include "nxt/nxtcpp.h" -#include "backend/DepthStencilState.h" #include "backend/Device.h" -#include "backend/ToBackend.h" +#include "backend/d3d12/Forward.h" #include "backend/d3d12/d3d12_platform.h" #include "common/SerialQueue.h" namespace backend { namespace d3d12 { - class BindGroup; - class BindGroupLayout; - class BlendState; - class Buffer; - class BufferView; - class CommandBuffer; - class ComputePipeline; - class DepthStencilState; - class Device; - class InputState; - class PipelineLayout; - class Queue; - class RenderPassDescriptor; - class RenderPipeline; - class Sampler; - class ShaderModule; - class SwapChain; - class Texture; - class TextureView; - class CommandAllocatorManager; class DescriptorHeapAllocator; class MapRequestTracker; class ResourceAllocator; class ResourceUploader; - struct D3D12BackendTraits { - using BindGroupType = BindGroup; - using BindGroupLayoutType = BindGroupLayout; - using BlendStateType = BlendState; - using BufferType = Buffer; - using BufferViewType = BufferView; - using CommandBufferType = CommandBuffer; - using ComputePipelineType = ComputePipeline; - using DepthStencilStateType = DepthStencilState; - using DeviceType = Device; - using InputStateType = InputState; - using PipelineLayoutType = PipelineLayout; - using QueueType = Queue; - using RenderPassDescriptorType = RenderPassDescriptor; - using RenderPipelineType = RenderPipeline; - using SamplerType = Sampler; - using ShaderModuleType = ShaderModule; - using SwapChainType = SwapChain; - using TextureType = Texture; - using TextureViewType = TextureView; - }; - - template - auto ToBackend(T&& common) -> decltype(ToBackendBase(common)) { - return ToBackendBase(common); - } - void ASSERT_SUCCESS(HRESULT hr); // Definition of backend types @@ -156,4 +108,4 @@ namespace backend { namespace d3d12 { }} // namespace backend::d3d12 -#endif // BACKEND_D3D12_D3D12BACKEND_H_ +#endif // BACKEND_D3D12_DEVICED3D12_H_ diff --git a/src/backend/d3d12/Forward.h b/src/backend/d3d12/Forward.h new file mode 100644 index 0000000000..3d49fca9ac --- /dev/null +++ b/src/backend/d3d12/Forward.h @@ -0,0 +1,71 @@ +// Copyright 2018 The NXT Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef BACKEND_D3D12_FORWARD_H_ +#define BACKEND_D3D12_FORWARD_H_ + +#include "backend/ToBackend.h" + +namespace backend { namespace d3d12 { + + class BindGroup; + class BindGroupLayout; + class BlendState; + class Buffer; + class BufferView; + class CommandBuffer; + class ComputePipeline; + class DepthStencilState; + class Device; + class InputState; + class PipelineLayout; + class Queue; + class RenderPassDescriptor; + class RenderPipeline; + class Sampler; + class ShaderModule; + class SwapChain; + class Texture; + class TextureView; + + struct D3D12BackendTraits { + using BindGroupType = BindGroup; + using BindGroupLayoutType = BindGroupLayout; + using BlendStateType = BlendState; + using BufferType = Buffer; + using BufferViewType = BufferView; + using CommandBufferType = CommandBuffer; + using ComputePipelineType = ComputePipeline; + using DepthStencilStateType = DepthStencilState; + using DeviceType = Device; + using InputStateType = InputState; + using PipelineLayoutType = PipelineLayout; + using QueueType = Queue; + using RenderPassDescriptorType = RenderPassDescriptor; + using RenderPipelineType = RenderPipeline; + using SamplerType = Sampler; + using ShaderModuleType = ShaderModule; + using SwapChainType = SwapChain; + using TextureType = Texture; + using TextureViewType = TextureView; + }; + + template + auto ToBackend(T&& common) -> decltype(ToBackendBase(common)) { + return ToBackendBase(common); + } + +}} // namespace backend::d3d12 + +#endif // BACKEND_D3D12_FORWARD_H_ diff --git a/src/backend/d3d12/GeneratedCodeIncludes.h b/src/backend/d3d12/GeneratedCodeIncludes.h index c02e291299..60fe4249f5 100644 --- a/src/backend/d3d12/GeneratedCodeIncludes.h +++ b/src/backend/d3d12/GeneratedCodeIncludes.h @@ -18,8 +18,8 @@ #include "backend/d3d12/BufferD3D12.h" #include "backend/d3d12/CommandBufferD3D12.h" #include "backend/d3d12/ComputePipelineD3D12.h" -#include "backend/d3d12/D3D12Backend.h" #include "backend/d3d12/DepthStencilStateD3D12.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/InputStateD3D12.h" #include "backend/d3d12/PipelineLayoutD3D12.h" #include "backend/d3d12/QueueD3D12.h" diff --git a/src/backend/d3d12/NativeSwapChainImplD3D12.cpp b/src/backend/d3d12/NativeSwapChainImplD3D12.cpp index 60bbcda40d..e99fc13268 100644 --- a/src/backend/d3d12/NativeSwapChainImplD3D12.cpp +++ b/src/backend/d3d12/NativeSwapChainImplD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/NativeSwapChainImplD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/TextureD3D12.h" #include "common/Assert.h" diff --git a/src/backend/d3d12/PipelineLayoutD3D12.cpp b/src/backend/d3d12/PipelineLayoutD3D12.cpp index 6262eadaa3..c4e1d65512 100644 --- a/src/backend/d3d12/PipelineLayoutD3D12.cpp +++ b/src/backend/d3d12/PipelineLayoutD3D12.cpp @@ -15,7 +15,7 @@ #include "backend/d3d12/PipelineLayoutD3D12.h" #include "backend/d3d12/BindGroupLayoutD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "common/Assert.h" using Microsoft::WRL::ComPtr; diff --git a/src/backend/d3d12/QueueD3D12.cpp b/src/backend/d3d12/QueueD3D12.cpp index b67d6aaa1c..40dd9e6c29 100644 --- a/src/backend/d3d12/QueueD3D12.cpp +++ b/src/backend/d3d12/QueueD3D12.cpp @@ -15,7 +15,7 @@ #include "backend/d3d12/QueueD3D12.h" #include "backend/d3d12/CommandBufferD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/RenderPassDescriptorD3D12.cpp b/src/backend/d3d12/RenderPassDescriptorD3D12.cpp index ad53ab765d..e7fa85b769 100644 --- a/src/backend/d3d12/RenderPassDescriptorD3D12.cpp +++ b/src/backend/d3d12/RenderPassDescriptorD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/RenderPassDescriptorD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/TextureD3D12.h" #include "common/BitSetIterator.h" diff --git a/src/backend/d3d12/RenderPipelineD3D12.cpp b/src/backend/d3d12/RenderPipelineD3D12.cpp index 358df42c65..649b4ccc6b 100644 --- a/src/backend/d3d12/RenderPipelineD3D12.cpp +++ b/src/backend/d3d12/RenderPipelineD3D12.cpp @@ -15,8 +15,8 @@ #include "backend/d3d12/RenderPipelineD3D12.h" #include "backend/d3d12/BlendStateD3D12.h" -#include "backend/d3d12/D3D12Backend.h" #include "backend/d3d12/DepthStencilStateD3D12.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/InputStateD3D12.h" #include "backend/d3d12/PipelineLayoutD3D12.h" #include "backend/d3d12/ShaderModuleD3D12.h" diff --git a/src/backend/d3d12/ResourceAllocator.cpp b/src/backend/d3d12/ResourceAllocator.cpp index 251e604e5a..06cdcd1d5d 100644 --- a/src/backend/d3d12/ResourceAllocator.cpp +++ b/src/backend/d3d12/ResourceAllocator.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/ResourceAllocator.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/ResourceUploader.cpp b/src/backend/d3d12/ResourceUploader.cpp index bd1ac3f107..f4f752613e 100644 --- a/src/backend/d3d12/ResourceUploader.cpp +++ b/src/backend/d3d12/ResourceUploader.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/ResourceUploader.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/ResourceAllocator.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/SamplerD3D12.cpp b/src/backend/d3d12/SamplerD3D12.cpp index 7e7fdf151d..ca60727bc5 100644 --- a/src/backend/d3d12/SamplerD3D12.cpp +++ b/src/backend/d3d12/SamplerD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/SamplerD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/SwapChainD3D12.cpp b/src/backend/d3d12/SwapChainD3D12.cpp index 694dc1dd14..8658add26b 100644 --- a/src/backend/d3d12/SwapChainD3D12.cpp +++ b/src/backend/d3d12/SwapChainD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/SwapChainD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/TextureD3D12.h" #include diff --git a/src/backend/d3d12/TextureD3D12.cpp b/src/backend/d3d12/TextureD3D12.cpp index ee226822bf..de50558f65 100644 --- a/src/backend/d3d12/TextureD3D12.cpp +++ b/src/backend/d3d12/TextureD3D12.cpp @@ -14,7 +14,7 @@ #include "backend/d3d12/TextureD3D12.h" -#include "backend/d3d12/D3D12Backend.h" +#include "backend/d3d12/DeviceD3D12.h" #include "backend/d3d12/ResourceAllocator.h" namespace backend { namespace d3d12 {