| // Copyright 2018 The Dawn 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 "dawn_native/opengl/DeviceGL.h" |
| |
| #include "dawn_native/BindGroup.h" |
| #include "dawn_native/BindGroupLayout.h" |
| #include "dawn_native/OpenGLBackend.h" |
| #include "dawn_native/RenderPassDescriptor.h" |
| #include "dawn_native/opengl/BlendStateGL.h" |
| #include "dawn_native/opengl/BufferGL.h" |
| #include "dawn_native/opengl/CommandBufferGL.h" |
| #include "dawn_native/opengl/ComputePipelineGL.h" |
| #include "dawn_native/opengl/DepthStencilStateGL.h" |
| #include "dawn_native/opengl/InputStateGL.h" |
| #include "dawn_native/opengl/PipelineLayoutGL.h" |
| #include "dawn_native/opengl/QueueGL.h" |
| #include "dawn_native/opengl/RenderPipelineGL.h" |
| #include "dawn_native/opengl/SamplerGL.h" |
| #include "dawn_native/opengl/ShaderModuleGL.h" |
| #include "dawn_native/opengl/SwapChainGL.h" |
| #include "dawn_native/opengl/TextureGL.h" |
| |
| namespace dawn_native { namespace opengl { |
| dawnProcTable GetNonValidatingProcs(); |
| dawnProcTable GetValidatingProcs(); |
| |
| void Init(void* (*getProc)(const char*), dawnProcTable* procs, dawnDevice* device) { |
| *device = nullptr; |
| |
| gladLoadGLLoader(reinterpret_cast<GLADloadproc>(getProc)); |
| |
| *procs = GetValidatingProcs(); |
| *device = reinterpret_cast<dawnDevice>(new Device); |
| |
| glEnable(GL_DEPTH_TEST); |
| glEnable(GL_SCISSOR_TEST); |
| glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); |
| } |
| |
| // Device |
| |
| BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) { |
| return new BindGroup(builder); |
| } |
| ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl( |
| const BindGroupLayoutDescriptor* descriptor) { |
| return new BindGroupLayout(this, descriptor); |
| } |
| BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) { |
| return new BlendState(builder); |
| } |
| BufferBase* Device::CreateBuffer(BufferBuilder* builder) { |
| return new Buffer(builder); |
| } |
| BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) { |
| return new BufferView(builder); |
| } |
| CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) { |
| return new CommandBuffer(builder); |
| } |
| ComputePipelineBase* Device::CreateComputePipeline(ComputePipelineBuilder* builder) { |
| return new ComputePipeline(builder); |
| } |
| DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) { |
| return new DepthStencilState(builder); |
| } |
| InputStateBase* Device::CreateInputState(InputStateBuilder* builder) { |
| return new InputState(builder); |
| } |
| ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl( |
| const PipelineLayoutDescriptor* descriptor) { |
| return new PipelineLayout(this, descriptor); |
| } |
| ResultOrError<QueueBase*> Device::CreateQueueImpl() { |
| return new Queue(this); |
| } |
| RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( |
| RenderPassDescriptorBuilder* builder) { |
| return new RenderPassDescriptor(builder); |
| } |
| RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) { |
| return new RenderPipeline(builder); |
| } |
| ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) { |
| return new Sampler(this, descriptor); |
| } |
| ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { |
| return new ShaderModule(builder); |
| } |
| SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) { |
| return new SwapChain(builder); |
| } |
| TextureBase* Device::CreateTexture(TextureBuilder* builder) { |
| return new Texture(builder); |
| } |
| TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) { |
| return new TextureView(builder); |
| } |
| |
| void Device::TickImpl() { |
| } |
| |
| }} // namespace dawn_native::opengl |