mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
add null D3D12 backend
This commit is contained in:
193
src/backend/d3d12/D3D12Backend.cpp
Normal file
193
src/backend/d3d12/D3D12Backend.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
// Copyright 2017 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.
|
||||
|
||||
#include "D3D12Backend.h"
|
||||
|
||||
namespace backend {
|
||||
namespace d3d12 {
|
||||
|
||||
nxtProcTable GetNonValidatingProcs();
|
||||
nxtProcTable GetValidatingProcs();
|
||||
|
||||
void Init(nxtProcTable* procs, nxtDevice* device) {
|
||||
*device = nullptr;
|
||||
*procs = GetValidatingProcs();
|
||||
}
|
||||
|
||||
Device::Device() {
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
}
|
||||
|
||||
BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
|
||||
return new BindGroup(this, builder);
|
||||
}
|
||||
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
||||
return new BindGroupLayout(this, builder);
|
||||
}
|
||||
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
||||
return new Buffer(this, builder);
|
||||
}
|
||||
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
|
||||
return new BufferView(this, builder);
|
||||
}
|
||||
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
||||
return new CommandBuffer(this, builder);
|
||||
}
|
||||
DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
|
||||
return new DepthStencilState(this, builder);
|
||||
}
|
||||
InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
|
||||
return new InputState(this, builder);
|
||||
}
|
||||
FramebufferBase* Device::CreateFramebuffer(FramebufferBuilder* builder) {
|
||||
return new Framebuffer(this, builder);
|
||||
}
|
||||
PipelineBase* Device::CreatePipeline(PipelineBuilder* builder) {
|
||||
return new Pipeline(this, builder);
|
||||
}
|
||||
PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) {
|
||||
return new PipelineLayout(this, builder);
|
||||
}
|
||||
QueueBase* Device::CreateQueue(QueueBuilder* builder) {
|
||||
return new Queue(this, builder);
|
||||
}
|
||||
RenderPassBase* Device::CreateRenderPass(RenderPassBuilder* builder) {
|
||||
return new RenderPass(this, builder);
|
||||
}
|
||||
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
|
||||
return new Sampler(this, builder);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
return new ShaderModule(this, builder);
|
||||
}
|
||||
TextureBase* Device::CreateTexture(TextureBuilder* builder) {
|
||||
return new Texture(this, builder);
|
||||
}
|
||||
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
|
||||
return new TextureView(this, builder);
|
||||
}
|
||||
|
||||
void Device::Reference() {
|
||||
}
|
||||
|
||||
void Device::Release() {
|
||||
}
|
||||
|
||||
// Bind Group
|
||||
|
||||
BindGroup::BindGroup(Device* device, BindGroupBuilder* builder)
|
||||
: BindGroupBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Bind Group Layout
|
||||
|
||||
BindGroupLayout::BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder)
|
||||
: BindGroupLayoutBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Buffer
|
||||
|
||||
Buffer::Buffer(Device* device, BufferBuilder* builder)
|
||||
: BufferBase(builder), device(device) {
|
||||
}
|
||||
|
||||
void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) {
|
||||
}
|
||||
|
||||
// BufferView
|
||||
|
||||
BufferView::BufferView(Device* device, BufferViewBuilder* builder)
|
||||
: BufferViewBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// CommandBuffer
|
||||
|
||||
CommandBuffer::CommandBuffer(Device* device, CommandBufferBuilder* builder)
|
||||
: CommandBufferBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// DepthStencilState
|
||||
|
||||
DepthStencilState::DepthStencilState(Device* device, DepthStencilStateBuilder* builder)
|
||||
: DepthStencilStateBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Framebuffer
|
||||
|
||||
Framebuffer::Framebuffer(Device* device, FramebufferBuilder* builder)
|
||||
: FramebufferBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// InputState
|
||||
|
||||
InputState::InputState(Device* device, InputStateBuilder * builder)
|
||||
: InputStateBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Pipeline
|
||||
|
||||
Pipeline::Pipeline(Device* device, PipelineBuilder* builder)
|
||||
: PipelineBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// PipelineLayout
|
||||
|
||||
PipelineLayout::PipelineLayout(Device* device, PipelineLayoutBuilder* builder)
|
||||
: PipelineLayoutBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Queue
|
||||
|
||||
Queue::Queue(Device* device, QueueBuilder* builder)
|
||||
: QueueBase(builder), device(device) {
|
||||
}
|
||||
|
||||
void Queue::Submit(uint32_t numCommands, CommandBuffer* const * commands) {
|
||||
|
||||
}
|
||||
|
||||
// RenderPass
|
||||
|
||||
RenderPass::RenderPass(Device* device, RenderPassBuilder* builder)
|
||||
: RenderPassBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Sampler
|
||||
|
||||
Sampler::Sampler(Device* device, SamplerBuilder* builder)
|
||||
: SamplerBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// ShaderModule
|
||||
|
||||
ShaderModule::ShaderModule(Device* device, ShaderModuleBuilder* builder)
|
||||
: ShaderModuleBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// Texture
|
||||
|
||||
Texture::Texture(Device* device, TextureBuilder* builder)
|
||||
: TextureBase(builder), device(device) {
|
||||
}
|
||||
|
||||
// TextureView
|
||||
|
||||
TextureView::TextureView(Device* device, TextureViewBuilder* builder)
|
||||
: TextureViewBase(builder), device(device) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
246
src/backend/d3d12/D3D12Backend.h
Normal file
246
src/backend/d3d12/D3D12Backend.h
Normal file
@@ -0,0 +1,246 @@
|
||||
// Copyright 2017 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_D3D12BACKEND_H_
|
||||
#define BACKEND_D3D12_D3D12BACKEND_H_
|
||||
|
||||
#include "nxt/nxtcpp.h"
|
||||
|
||||
#include "common/Buffer.h"
|
||||
#include "common/BindGroup.h"
|
||||
#include "common/BindGroupLayout.h"
|
||||
#include "common/CommandBuffer.h"
|
||||
#include "common/Device.h"
|
||||
#include "common/Framebuffer.h"
|
||||
#include "common/DepthStencilState.h"
|
||||
#include "common/InputState.h"
|
||||
#include "common/Pipeline.h"
|
||||
#include "common/PipelineLayout.h"
|
||||
#include "common/Queue.h"
|
||||
#include "common/RenderPass.h"
|
||||
#include "common/Sampler.h"
|
||||
#include "common/ShaderModule.h"
|
||||
#include "common/Texture.h"
|
||||
#include "common/ToBackend.h"
|
||||
|
||||
namespace backend {
|
||||
namespace d3d12 {
|
||||
|
||||
class BindGroup;
|
||||
class BindGroupLayout;
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
class CommandBuffer;
|
||||
class DepthStencilState;
|
||||
class InputState;
|
||||
class Pipeline;
|
||||
class PipelineLayout;
|
||||
class Queue;
|
||||
class Sampler;
|
||||
class ShaderModule;
|
||||
class Texture;
|
||||
class TextureView;
|
||||
class Framebuffer;
|
||||
class RenderPass;
|
||||
|
||||
struct D3D12BackendTraits {
|
||||
using BindGroupType = BindGroup;
|
||||
using BindGroupLayoutType = BindGroupLayout;
|
||||
using BufferType = Buffer;
|
||||
using BufferViewType = BufferView;
|
||||
using CommandBufferType = CommandBuffer;
|
||||
using DepthStencilStateType = DepthStencilState;
|
||||
using InputStateType = InputState;
|
||||
using PipelineType = Pipeline;
|
||||
using PipelineLayoutType = PipelineLayout;
|
||||
using QueueType = Queue;
|
||||
using SamplerType = Sampler;
|
||||
using ShaderModuleType = ShaderModule;
|
||||
using TextureType = Texture;
|
||||
using TextureViewType = TextureView;
|
||||
using FramebufferType = Framebuffer;
|
||||
using RenderPassType = RenderPass;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
auto ToBackend(T&& common) -> decltype(ToBackendBase<D3D12BackendTraits>(common)) {
|
||||
return ToBackendBase<D3D12BackendTraits>(common);
|
||||
}
|
||||
|
||||
// Definition of backend types
|
||||
class Device : public DeviceBase {
|
||||
public:
|
||||
Device();
|
||||
~Device();
|
||||
|
||||
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
||||
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
||||
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
||||
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
||||
FramebufferBase* CreateFramebuffer(FramebufferBuilder* builder) override;
|
||||
PipelineBase* CreatePipeline(PipelineBuilder* builder) override;
|
||||
PipelineLayoutBase* CreatePipelineLayout(PipelineLayoutBuilder* builder) override;
|
||||
QueueBase* CreateQueue(QueueBuilder* builder) override;
|
||||
RenderPassBase* CreateRenderPass(RenderPassBuilder* builder) override;
|
||||
SamplerBase* CreateSampler(SamplerBuilder* builder) override;
|
||||
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
||||
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
||||
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
|
||||
|
||||
// NXT API
|
||||
void Reference();
|
||||
void Release();
|
||||
};
|
||||
|
||||
|
||||
class BindGroup : public BindGroupBase {
|
||||
public:
|
||||
BindGroup(Device* device, BindGroupBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class BindGroupLayout : public BindGroupLayoutBase {
|
||||
public:
|
||||
BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class Buffer : public BufferBase {
|
||||
public:
|
||||
Buffer(Device* device, BufferBuilder* builder);
|
||||
|
||||
private:
|
||||
void SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) override;
|
||||
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class BufferView : public BufferViewBase {
|
||||
public:
|
||||
BufferView(Device* device, BufferViewBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(Device* device, CommandBufferBuilder* buidler);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class Framebuffer : public FramebufferBase {
|
||||
public:
|
||||
Framebuffer(Device* device, FramebufferBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class DepthStencilState : public DepthStencilStateBase {
|
||||
public:
|
||||
DepthStencilState(Device* device, DepthStencilStateBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class InputState : public InputStateBase {
|
||||
public:
|
||||
InputState(Device* device, InputStateBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class Pipeline : public PipelineBase {
|
||||
public:
|
||||
Pipeline(Device* device, PipelineBuilder* buidler);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class PipelineLayout : public PipelineLayoutBase {
|
||||
public:
|
||||
PipelineLayout(Device* device, PipelineLayoutBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class Queue : public QueueBase {
|
||||
public:
|
||||
Queue(Device* device, QueueBuilder* builder);
|
||||
|
||||
// NXT API
|
||||
void Submit(uint32_t numCommands, CommandBuffer* const * commands);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class RenderPass : public RenderPassBase {
|
||||
public:
|
||||
RenderPass(Device* device, RenderPassBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class Sampler : public SamplerBase {
|
||||
public:
|
||||
Sampler(Device* device, SamplerBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class ShaderModule : public ShaderModuleBase {
|
||||
public:
|
||||
ShaderModule(Device* device, ShaderModuleBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class Texture : public TextureBase {
|
||||
public:
|
||||
Texture(Device* device, TextureBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
class TextureView : public TextureViewBase {
|
||||
public:
|
||||
TextureView(Device* device, TextureViewBuilder* builder);
|
||||
|
||||
private:
|
||||
Device* device;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BACKEND_D3D12_D3D12BACKEND_H_
|
||||
15
src/backend/d3d12/GeneratedCodeIncludes.h
Normal file
15
src/backend/d3d12/GeneratedCodeIncludes.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017 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.
|
||||
|
||||
#include "D3D12Backend.h"
|
||||
Reference in New Issue
Block a user