VTK  9.7.1
vtkWebGPUBindGroupInternals.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkWebGPUBindGroupInternals_h
5 #define vtkWebGPUBindGroupInternals_h
6 
7 #include "vtkRenderingWebGPUModule.h"
8 #include "vtk_wgpu.h"
9 
10 #include <initializer_list>
11 
12 VTK_ABI_NAMESPACE_BEGIN
13 class VTKRENDERINGWEBGPU_NO_EXPORT vtkWebGPUBindGroupInternals
14 {
15 public:
16  // Helpers to make creating bind groups look nicer:
17  //
18  // vtkWebGPUBindGroupInternals::MakeBindGroup(
19  // device,
20  // layout,
21  // {
22  // {0, mySampler},
23  // {1, myBuffer, offset, size},
24  // {3, myTextureView}
25  // });
26 
27  // Structure with one constructor per-type of bindings, so that the initializer_list accepts
28  // bindings with the right type and no extra information.
30  {
31  BindingInitializationHelper(uint32_t binding, const wgpu::Sampler& sampler);
32  BindingInitializationHelper(uint32_t binding, const wgpu::TextureView& textureView);
33  BindingInitializationHelper(uint32_t binding, const wgpu::Buffer& buffer, uint64_t offset = 0,
34  uint64_t size = wgpu::kWholeSize);
37 
38  wgpu::BindGroupEntry GetAsBinding() const;
39 
40  uint32_t binding;
41  wgpu::Sampler sampler;
42  wgpu::TextureView textureView;
43  wgpu::Buffer buffer;
44  uint64_t offset = 0;
45  uint64_t size = 0;
46  };
47 
51  static wgpu::BindGroup MakeBindGroup(const wgpu::Device& device,
52  const wgpu::BindGroupLayout& layout,
53  std::initializer_list<BindingInitializationHelper> entriesInitializer, std::string label = "");
54 
58  static wgpu::BindGroup MakeBindGroup(const wgpu::Device& device,
59  const wgpu::BindGroupLayout& layout, const std::vector<wgpu::BindGroupEntry>& entries,
60  std::string label = "");
61 };
62 VTK_ABI_NAMESPACE_END
63 
64 #endif
65 // VTK-HeaderTest-Exclude: vtkWebGPUBindGroupInternals.h