OpenGL: Split OpenGLBackend in Forward.h and DeviceGL

This commit is contained in:
Corentin Wallez 2018-06-18 17:34:03 -04:00 committed by Corentin Wallez
parent 30f7ddbb6b
commit 77d1f10493
15 changed files with 101 additions and 109 deletions

View File

@ -66,10 +66,11 @@ if (NXT_ENABLE_OPENGL)
${OPENGL_DIR}/ComputePipelineGL.h
${OPENGL_DIR}/DepthStencilStateGL.cpp
${OPENGL_DIR}/DepthStencilStateGL.h
${OPENGL_DIR}/DeviceGL.cpp
${OPENGL_DIR}/DeviceGL.h
${OPENGL_DIR}/Forward.h
${OPENGL_DIR}/InputStateGL.cpp
${OPENGL_DIR}/InputStateGL.h
${OPENGL_DIR}/OpenGLBackend.cpp
${OPENGL_DIR}/OpenGLBackend.h
${OPENGL_DIR}/PersistentPipelineStateGL.cpp
${OPENGL_DIR}/PersistentPipelineStateGL.h
${OPENGL_DIR}/PipelineGL.cpp

View File

@ -14,7 +14,6 @@
#include "backend/opengl/BlendStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "common/Assert.h"
namespace backend { namespace opengl {

View File

@ -14,8 +14,6 @@
#include "backend/opengl/BufferGL.h"
#include "backend/opengl/OpenGLBackend.h"
namespace backend { namespace opengl {
// Buffer

View File

@ -14,11 +14,12 @@
#include "backend/opengl/CommandBufferGL.h"
#include "backend/BindGroup.h"
#include "backend/Commands.h"
#include "backend/opengl/BufferGL.h"
#include "backend/opengl/ComputePipelineGL.h"
#include "backend/opengl/Forward.h"
#include "backend/opengl/InputStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/opengl/PersistentPipelineStateGL.h"
#include "backend/opengl/PipelineLayoutGL.h"
#include "backend/opengl/RenderPipelineGL.h"

View File

@ -14,7 +14,6 @@
#include "backend/opengl/DepthStencilStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/opengl/PersistentPipelineStateGL.h"
#include "common/Assert.h"

View File

@ -12,8 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "backend/opengl/OpenGLBackend.h"
#include "backend/opengl/DeviceGL.h"
#include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h"
#include "backend/RenderPassDescriptor.h"
#include "backend/opengl/BlendStateGL.h"
#include "backend/opengl/BufferGL.h"
#include "backend/opengl/CommandBufferGL.h"
@ -106,17 +109,6 @@ namespace backend { namespace opengl {
void Device::TickImpl() {
}
// Bind Group
BindGroup::BindGroup(BindGroupBuilder* builder) : BindGroupBase(builder) {
}
// Bind Group Layout
BindGroupLayout::BindGroupLayout(BindGroupLayoutBuilder* builder)
: BindGroupLayoutBase(builder) {
}
// Queue
Queue::Queue(Device* device) : QueueBase(device) {
@ -128,10 +120,4 @@ namespace backend { namespace opengl {
}
}
// RenderPassDescriptor
RenderPassDescriptor::RenderPassDescriptor(RenderPassDescriptorBuilder* builder)
: RenderPassDescriptorBase(builder) {
}
}} // namespace backend::opengl

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,75 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef BACKEND_OPENGL_OPENGLBACKEND_H_
#define BACKEND_OPENGL_OPENGLBACKEND_H_
#ifndef BACKEND_OPENGL_DEVICEGL_H_
#define BACKEND_OPENGL_DEVICEGL_H_
#include "nxt/nxtcpp.h"
#include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h"
#include "backend/BlendState.h"
#include "backend/Buffer.h"
#include "backend/DepthStencilState.h"
#include "backend/Device.h"
#include "backend/InputState.h"
#include "backend/Queue.h"
#include "backend/RenderPassDescriptor.h"
#include "backend/ToBackend.h"
#include "backend/opengl/Forward.h"
#include "glad/glad.h"
namespace backend { namespace opengl {
class BindGroup;
class BindGroupLayout;
class BlendState;
class Buffer;
class BufferView;
class CommandBuffer;
class ComputePipeline;
class DepthStencilState;
class Device;
class InputState;
class PersistentPipelineState;
class PipelineLayout;
class Queue;
class RenderPassDescriptor;
class RenderPipeline;
class Sampler;
class ShaderModule;
class SwapChain;
class Texture;
class TextureView;
struct OpenGLBackendTraits {
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<OpenGLBackendTraits>(common)) {
return ToBackendBase<OpenGLBackendTraits>(common);
}
// Definition of backend types
class Device : public DeviceBase {
public:
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
@ -109,16 +53,6 @@ namespace backend { namespace opengl {
const nxt::SamplerDescriptor* descriptor) override;
};
class BindGroup : public BindGroupBase {
public:
BindGroup(BindGroupBuilder* builder);
};
class BindGroupLayout : public BindGroupLayoutBase {
public:
BindGroupLayout(BindGroupLayoutBuilder* builder);
};
class Queue : public QueueBase {
public:
Queue(Device* device);
@ -127,11 +61,6 @@ namespace backend { namespace opengl {
void Submit(uint32_t numCommands, CommandBuffer* const* commands);
};
class RenderPassDescriptor : public RenderPassDescriptorBase {
public:
RenderPassDescriptor(RenderPassDescriptorBuilder* builder);
};
}} // namespace backend::opengl
#endif // BACKEND_OPENGL_OPENGLBACKEND_H_
#endif // BACKEND_OPENGL_DEVICEGL_H_

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_OPENGL_FORWARD_H_
#define BACKEND_OPENGL_FORWARD_H_
#include "backend/ToBackend.h"
namespace {
class BindGroupBase;
class BindGroup;
class RenderPassDescriptor;
} // namespace
namespace backend { namespace opengl {
using BindGroup = BindGroupBase;
using BindGroupLayout = BindGroupLayoutBase;
class BlendState;
class Buffer;
class BufferView;
class CommandBuffer;
class ComputePipeline;
class DepthStencilState;
class Device;
class InputState;
class PersistentPipelineState;
class PipelineLayout;
class Queue;
using RenderPassDescriptor = RenderPassDescriptorBase;
class RenderPipeline;
class Sampler;
class ShaderModule;
class SwapChain;
class Texture;
class TextureView;
struct OpenGLBackendTraits {
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<OpenGLBackendTraits>(common)) {
return ToBackendBase<OpenGLBackendTraits>(common);
}
}} // namespace backend::opengl
#endif // BACKEND_OPENGL_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/opengl/BlendStateGL.h"
#include "backend/opengl/BufferGL.h"
#include "backend/opengl/CommandBufferGL.h"
#include "backend/opengl/ComputePipelineGL.h"
#include "backend/opengl/DepthStencilStateGL.h"
#include "backend/opengl/DeviceGL.h"
#include "backend/opengl/InputStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/opengl/PersistentPipelineStateGL.h"
#include "backend/opengl/PipelineLayoutGL.h"
#include "backend/opengl/RenderPipelineGL.h"

View File

@ -14,7 +14,6 @@
#include "backend/opengl/InputStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "common/Assert.h"
namespace backend { namespace opengl {

View File

@ -14,8 +14,6 @@
#include "backend/opengl/PersistentPipelineStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
namespace backend { namespace opengl {
void PersistentPipelineState::SetDefaultState() {

View File

@ -14,7 +14,8 @@
#include "backend/opengl/PipelineGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/BindGroupLayout.h"
#include "backend/opengl/Forward.h"
#include "backend/opengl/PersistentPipelineStateGL.h"
#include "backend/opengl/PipelineLayoutGL.h"
#include "backend/opengl/ShaderModuleGL.h"

View File

@ -14,7 +14,7 @@
#include "backend/opengl/PipelineLayoutGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/BindGroupLayout.h"
namespace backend { namespace opengl {

View File

@ -16,8 +16,8 @@
#include "backend/opengl/BlendStateGL.h"
#include "backend/opengl/DepthStencilStateGL.h"
#include "backend/opengl/Forward.h"
#include "backend/opengl/InputStateGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/opengl/PersistentPipelineStateGL.h"
namespace backend { namespace opengl {

View File

@ -14,7 +14,7 @@
#include "backend/opengl/SamplerGL.h"
#include "backend/opengl/OpenGLBackend.h"
#include "backend/opengl/DeviceGL.h"
#include "common/Assert.h"
namespace backend { namespace opengl {