• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
16 #define UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
17 
18 #include <dawn/webgpu_cpp.h>
19 
20 #include "common/Constants.h"
21 
22 #include <array>
23 
24 namespace utils {
25 
26     // Primarily used by tests to easily set up the vertex buffer state portion of a RenderPipeline.
27     class ComboVertexState {
28       public:
29         ComboVertexState();
30 
31         ComboVertexState(const ComboVertexState&) = delete;
32         ComboVertexState& operator=(const ComboVertexState&) = delete;
33         ComboVertexState(ComboVertexState&&) = delete;
34         ComboVertexState& operator=(ComboVertexState&&) = delete;
35 
36         uint32_t vertexBufferCount;
37         std::array<wgpu::VertexBufferLayout, kMaxVertexBuffers> cVertexBuffers;
38         std::array<wgpu::VertexAttribute, kMaxVertexAttributes> cAttributes;
39     };
40 
41     class ComboRenderPipelineDescriptor : public wgpu::RenderPipelineDescriptor {
42       public:
43         ComboRenderPipelineDescriptor();
44 
45         ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete;
46         ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete;
47         ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete;
48         ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete;
49 
50         wgpu::DepthStencilState* EnableDepthStencil(
51             wgpu::TextureFormat format = wgpu::TextureFormat::Depth24PlusStencil8);
52 
53         std::array<wgpu::VertexBufferLayout, kMaxVertexBuffers> cBuffers;
54         std::array<wgpu::VertexAttribute, kMaxVertexAttributes> cAttributes;
55         std::array<wgpu::ColorTargetState, kMaxColorAttachments> cTargets;
56         std::array<wgpu::BlendState, kMaxColorAttachments> cBlends;
57 
58         wgpu::FragmentState cFragment;
59         wgpu::DepthStencilState cDepthStencil;
60     };
61 
62 }  // namespace utils
63 
64 #endif  // UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
65