Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 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 | |
Corentin Wallez | 04863c4 | 2019-10-25 11:36:47 +0000 | [diff] [blame] | 18 | #include <dawn/webgpu_cpp.h> |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 19 | |
| 20 | #include "common/Constants.h" |
| 21 | |
| 22 | #include <array> |
| 23 | |
| 24 | namespace utils { |
| 25 | |
Brandon Jones | 7e59470 | 2021-05-21 18:25:48 +0000 | [diff] [blame] | 26 | // Primarily used by tests to easily set up the vertex buffer state portion of a RenderPipeline. |
Brandon Jones | 41c87d9 | 2021-05-21 05:01:38 +0000 | [diff] [blame] | 27 | class ComboVertexStateDescriptor { |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 28 | public: |
Kai Ninomiya | ae1f25f | 2019-11-07 22:23:29 +0000 | [diff] [blame] | 29 | ComboVertexStateDescriptor(); |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 30 | |
Corentin Wallez | 2c32fa6 | 2021-01-22 17:51:45 +0000 | [diff] [blame] | 31 | ComboVertexStateDescriptor(const ComboVertexStateDescriptor&) = delete; |
| 32 | ComboVertexStateDescriptor& operator=(const ComboVertexStateDescriptor&) = delete; |
| 33 | ComboVertexStateDescriptor(ComboVertexStateDescriptor&&) = delete; |
| 34 | ComboVertexStateDescriptor& operator=(ComboVertexStateDescriptor&&) = delete; |
| 35 | |
Brandon Jones | 41c87d9 | 2021-05-21 05:01:38 +0000 | [diff] [blame] | 36 | uint32_t vertexBufferCount; |
Kai Ninomiya | ae1f25f | 2019-11-07 22:23:29 +0000 | [diff] [blame] | 37 | std::array<wgpu::VertexBufferLayoutDescriptor, kMaxVertexBuffers> cVertexBuffers; |
Corentin Wallez | 04863c4 | 2019-10-25 11:36:47 +0000 | [diff] [blame] | 38 | std::array<wgpu::VertexAttributeDescriptor, kMaxVertexAttributes> cAttributes; |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
Corentin Wallez | 04863c4 | 2019-10-25 11:36:47 +0000 | [diff] [blame] | 41 | class ComboRenderPipelineDescriptor : public wgpu::RenderPipelineDescriptor { |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 42 | public: |
Brandon Jones | 41c87d9 | 2021-05-21 05:01:38 +0000 | [diff] [blame] | 43 | ComboRenderPipelineDescriptor(); |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 44 | |
Corentin Wallez | b8dbada | 2019-09-20 23:15:47 +0000 | [diff] [blame] | 45 | ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete; |
| 46 | ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete; |
| 47 | ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete; |
| 48 | ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete; |
| 49 | |
Brandon Jones | 6e5d47a | 2021-03-17 17:48:59 +0000 | [diff] [blame] | 50 | wgpu::DepthStencilState* EnableDepthStencil( |
| 51 | wgpu::TextureFormat format = wgpu::TextureFormat::Depth24PlusStencil8); |
| 52 | |
Brandon Jones | 0702b70 | 2021-03-11 21:19:00 +0000 | [diff] [blame] | 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 | |
Brandon Jones | 0702b70 | 2021-03-11 21:19:00 +0000 | [diff] [blame] | 58 | wgpu::FragmentState cFragment; |
Brandon Jones | 6e5d47a | 2021-03-17 17:48:59 +0000 | [diff] [blame] | 59 | wgpu::DepthStencilState cDepthStencil; |
Brandon Jones | 0702b70 | 2021-03-11 21:19:00 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
Corentin Wallez | dd15b11 | 2019-07-15 12:23:18 +0000 | [diff] [blame] | 62 | } // namespace utils |
| 63 | |
| 64 | #endif // UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_ |