Metal: Split MetalBackend in Forward.h and DeviceMTL

This commit is contained in:
Corentin Wallez 2018-06-18 18:19:31 -04:00 committed by Corentin Wallez
parent a714f5b459
commit 0f2e7b67c1
18 changed files with 107 additions and 110 deletions

View File

@ -124,10 +124,11 @@ if (NXT_ENABLE_METAL)
${METAL_DIR}/ComputePipelineMTL.h
${METAL_DIR}/DepthStencilStateMTL.mm
${METAL_DIR}/DepthStencilStateMTL.h
${METAL_DIR}/DeviceMTL.mm
${METAL_DIR}/DeviceMTL.h
${METAL_DIR}/Forward.h
${METAL_DIR}/InputStateMTL.mm
${METAL_DIR}/InputStateMTL.h
${METAL_DIR}/MetalBackend.mm
${METAL_DIR}/MetalBackend.h
${METAL_DIR}/PipelineLayoutMTL.mm
${METAL_DIR}/PipelineLayoutMTL.h
${METAL_DIR}/RenderPipelineMTL.mm

View File

@ -14,8 +14,6 @@
#include "backend/metal/BlendStateMTL.h"
#include "backend/metal/MetalBackend.h"
namespace backend { namespace metal {
namespace {

View File

@ -14,7 +14,7 @@
#include "backend/metal/BufferMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/ResourceUploader.h"
namespace backend { namespace metal {

View File

@ -14,12 +14,13 @@
#include "backend/metal/CommandBufferMTL.h"
#include "backend/BindGroup.h"
#include "backend/Commands.h"
#include "backend/metal/BufferMTL.h"
#include "backend/metal/ComputePipelineMTL.h"
#include "backend/metal/DepthStencilStateMTL.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/InputStateMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/PipelineLayoutMTL.h"
#include "backend/metal/RenderPipelineMTL.h"
#include "backend/metal/SamplerMTL.h"

View File

@ -14,7 +14,7 @@
#include "backend/metal/ComputePipelineMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/ShaderModuleMTL.h"
namespace backend { namespace metal {

View File

@ -14,7 +14,7 @@
#include "backend/metal/DepthStencilStateMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
namespace backend { namespace metal {

View File

@ -1,4 +1,4 @@
// Copyright 2017 The NXT Authors
// 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.
@ -12,17 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef BACKEND_METAL_METALBACKEND_H_
#define BACKEND_METAL_METALBACKEND_H_
#ifndef BACKEND_METAL_DEVICEMTL_H_
#define BACKEND_METAL_DEVICEMTL_H_
#include "nxt/nxtcpp.h"
#include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h"
#include "backend/Device.h"
#include "backend/Queue.h"
#include "backend/RenderPassDescriptor.h"
#include "backend/ToBackend.h"
#include "backend/metal/Forward.h"
#include "common/Serial.h"
#import <Metal/Metal.h>
@ -31,54 +28,6 @@
namespace backend { namespace metal {
class BindGroup;
class BindGroupLayout;
class BlendState;
class Buffer;
class BufferView;
class CommandBuffer;
class ComputePipeline;
class DepthStencilState;
class Device;
class Framebuffer;
class InputState;
class PipelineLayout;
class Queue;
class RenderPassDescriptor;
class RenderPipeline;
class Sampler;
class ShaderModule;
class SwapChain;
class Texture;
class TextureView;
struct MetalBackendTraits {
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 <typename T>
auto ToBackend(T&& common) -> decltype(ToBackendBase<MetalBackendTraits>(common)) {
return ToBackendBase<MetalBackendTraits>(common);
}
class MapRequestTracker;
class ResourceUploader;
@ -133,16 +82,6 @@ namespace backend { namespace metal {
id<MTLCommandBuffer> mPendingCommands = nil;
};
class BindGroup : public BindGroupBase {
public:
BindGroup(BindGroupBuilder* builder);
};
class BindGroupLayout : public BindGroupLayoutBase {
public:
BindGroupLayout(BindGroupLayoutBuilder* builder);
};
class Queue : public QueueBase {
public:
Queue(Device* device);
@ -151,12 +90,6 @@ namespace backend { namespace metal {
void Submit(uint32_t numCommands, CommandBuffer* const* commands);
};
class RenderPassDescriptor : public RenderPassDescriptorBase {
public:
RenderPassDescriptor(RenderPassDescriptorBuilder* builder);
~RenderPassDescriptor();
};
}} // namespace backend::metal
#endif // BACKEND_METAL_METALBACKEND_H_
#endif // BACKEND_METAL_DEVICEMTL_H_

View File

@ -12,8 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h"
#include "backend/RenderPassDescriptor.h"
#include "backend/metal/BlendStateMTL.h"
#include "backend/metal/BufferMTL.h"
#include "backend/metal/CommandBufferMTL.h"
@ -190,17 +193,6 @@ namespace backend { namespace metal {
return mResourceUploader;
}
// Bind Group
BindGroup::BindGroup(BindGroupBuilder* builder) : BindGroupBase(builder) {
}
// Bind Group Layout
BindGroupLayout::BindGroupLayout(BindGroupLayoutBuilder* builder)
: BindGroupLayoutBase(builder) {
}
// Queue
Queue::Queue(Device* device) : QueueBase(device) {
@ -218,13 +210,4 @@ namespace backend { namespace metal {
device->SubmitPendingCommandBuffer();
}
// RenderPass
RenderPassDescriptor::RenderPassDescriptor(RenderPassDescriptorBuilder* builder)
: RenderPassDescriptorBase(builder) {
}
RenderPassDescriptor::~RenderPassDescriptor() {
}
}} // namespace backend::metal

View File

@ -0,0 +1,78 @@
// 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_METAL_FORWARD_H_
#define BACKEND_METAL_FORWARD_H_
#include "backend/ToBackend.h"
namespace {
class BindGroupBase;
class BindGroup;
class RenderPassDescriptor;
} // namespace
namespace backend { namespace metal {
using BindGroup = BindGroupBase;
using BindGroupLayout = BindGroupLayoutBase;
class BlendState;
class Buffer;
class BufferView;
class CommandBuffer;
class ComputePipeline;
class DepthStencilState;
class Device;
class Framebuffer;
class InputState;
class PipelineLayout;
class Queue;
using RenderPassDescriptor = RenderPassDescriptorBase;
class RenderPipeline;
class Sampler;
class ShaderModule;
class SwapChain;
class Texture;
class TextureView;
struct MetalBackendTraits {
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 <typename T>
auto ToBackend(T&& common) -> decltype(ToBackendBase<MetalBackendTraits>(common)) {
return ToBackendBase<MetalBackendTraits>(common);
}
}} // namespace backend::metal
#endif // BACKEND_METAL_FORWARD_H_

View File

@ -12,13 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h"
#include "backend/RenderPassDescriptor.h"
#include "backend/metal/BlendStateMTL.h"
#include "backend/metal/BufferMTL.h"
#include "backend/metal/CommandBufferMTL.h"
#include "backend/metal/ComputePipelineMTL.h"
#include "backend/metal/DepthStencilStateMTL.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/InputStateMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/PipelineLayoutMTL.h"
#include "backend/metal/RenderPipelineMTL.h"
#include "backend/metal/SamplerMTL.h"

View File

@ -14,7 +14,6 @@
#include "backend/metal/InputStateMTL.h"
#include "backend/metal/MetalBackend.h"
#include "common/BitSetIterator.h"
namespace backend { namespace metal {

View File

@ -14,7 +14,7 @@
#include "backend/metal/PipelineLayoutMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/BindGroupLayout.h"
namespace backend { namespace metal {

View File

@ -16,8 +16,8 @@
#include "backend/metal/BlendStateMTL.h"
#include "backend/metal/DepthStencilStateMTL.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/InputStateMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/PipelineLayoutMTL.h"
#include "backend/metal/ShaderModuleMTL.h"
#include "backend/metal/TextureMTL.h"

View File

@ -14,7 +14,7 @@
#include "backend/metal/ResourceUploader.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
namespace backend { namespace metal {

View File

@ -14,7 +14,7 @@
#include "backend/metal/SamplerMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
namespace backend { namespace metal {

View File

@ -14,7 +14,8 @@
#include "backend/metal/ShaderModuleMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/BindGroupLayout.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/PipelineLayoutMTL.h"
#include <spirv-cross/spirv_msl.hpp>

View File

@ -14,7 +14,7 @@
#include "backend/metal/SwapChainMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
#include "backend/metal/TextureMTL.h"
#include <nxt/nxt_wsi.h>

View File

@ -14,7 +14,7 @@
#include "backend/metal/TextureMTL.h"
#include "backend/metal/MetalBackend.h"
#include "backend/metal/DeviceMTL.h"
namespace backend { namespace metal {