blob: 036ce1c7115f8a708f3d6319bba92e7b5c66dc4b [file] [log] [blame]
Corentin Wallezdd15b112019-07-15 12:23:18 +00001// 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 Wallez04863c42019-10-25 11:36:47 +000018#include <dawn/webgpu_cpp.h>
Corentin Wallezdd15b112019-07-15 12:23:18 +000019
20#include "common/Constants.h"
21
22#include <array>
23
24namespace utils {
25
Brandon Jones7e594702021-05-21 18:25:48 +000026 // Primarily used by tests to easily set up the vertex buffer state portion of a RenderPipeline.
Brandon Jones41c87d92021-05-21 05:01:38 +000027 class ComboVertexStateDescriptor {
Corentin Wallezdd15b112019-07-15 12:23:18 +000028 public:
Kai Ninomiyaae1f25f2019-11-07 22:23:29 +000029 ComboVertexStateDescriptor();
Corentin Wallezdd15b112019-07-15 12:23:18 +000030
Corentin Wallez2c32fa62021-01-22 17:51:45 +000031 ComboVertexStateDescriptor(const ComboVertexStateDescriptor&) = delete;
32 ComboVertexStateDescriptor& operator=(const ComboVertexStateDescriptor&) = delete;
33 ComboVertexStateDescriptor(ComboVertexStateDescriptor&&) = delete;
34 ComboVertexStateDescriptor& operator=(ComboVertexStateDescriptor&&) = delete;
35
Brandon Jones41c87d92021-05-21 05:01:38 +000036 uint32_t vertexBufferCount;
Kai Ninomiyaae1f25f2019-11-07 22:23:29 +000037 std::array<wgpu::VertexBufferLayoutDescriptor, kMaxVertexBuffers> cVertexBuffers;
Corentin Wallez04863c42019-10-25 11:36:47 +000038 std::array<wgpu::VertexAttributeDescriptor, kMaxVertexAttributes> cAttributes;
Corentin Wallezdd15b112019-07-15 12:23:18 +000039 };
40
Corentin Wallez04863c42019-10-25 11:36:47 +000041 class ComboRenderPipelineDescriptor : public wgpu::RenderPipelineDescriptor {
Corentin Wallezdd15b112019-07-15 12:23:18 +000042 public:
Brandon Jones41c87d92021-05-21 05:01:38 +000043 ComboRenderPipelineDescriptor();
Corentin Wallezdd15b112019-07-15 12:23:18 +000044
Corentin Wallezb8dbada2019-09-20 23:15:47 +000045 ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete;
46 ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete;
47 ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete;
48 ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete;
49
Brandon Jones6e5d47a2021-03-17 17:48:59 +000050 wgpu::DepthStencilState* EnableDepthStencil(
51 wgpu::TextureFormat format = wgpu::TextureFormat::Depth24PlusStencil8);
52
Brandon Jones0702b702021-03-11 21:19:00 +000053 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 Jones0702b702021-03-11 21:19:00 +000058 wgpu::FragmentState cFragment;
Brandon Jones6e5d47a2021-03-17 17:48:59 +000059 wgpu::DepthStencilState cDepthStencil;
Brandon Jones0702b702021-03-11 21:19:00 +000060 };
61
Corentin Wallezdd15b112019-07-15 12:23:18 +000062} // namespace utils
63
64#endif // UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_