VTK  9.7.20260913
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 <string>
11#include <vector>
12
13#include <initializer_list>
14
15VTK_ABI_NAMESPACE_BEGIN
16class VTKRENDERINGWEBGPU_NO_EXPORT vtkWebGPUBindGroupInternals
17{
18public:
19 // Helpers to make creating bind groups look nicer:
20 //
21 // vtkWebGPUBindGroupInternals::MakeBindGroup(
22 // device,
23 // layout,
24 // {
25 // {0, mySampler},
26 // {1, myBuffer, offset, size},
27 // {3, myTextureView}
28 // });
29
30 // Structure with one constructor per-type of bindings, so that the initializer_list accepts
31 // bindings with the right type and no extra information.
33 {
37 uint32_t binding, WGPUBuffer buffer, uint64_t offset = 0, uint64_t size = WGPU_WHOLE_SIZE);
40
41 WGPUBindGroupEntry GetAsBinding() const;
42
43 uint32_t binding;
44 WGPUSampler sampler = nullptr;
45 WGPUTextureView textureView = nullptr;
46 WGPUBuffer buffer = nullptr;
47 uint64_t offset = 0;
48 uint64_t size = 0;
49 };
50
54 static WGPUBindGroup MakeBindGroup(const WGPUDevice& device, const WGPUBindGroupLayout& layout,
55 std::initializer_list<BindingInitializationHelper> entriesInitializer, std::string label = "");
56
60 static WGPUBindGroup MakeBindGroup(const WGPUDevice& device, const WGPUBindGroupLayout& layout,
61 const std::vector<WGPUBindGroupEntry>& entries, std::string label = "");
62};
63VTK_ABI_NAMESPACE_END
64
65#endif
66// VTK-HeaderTest-Exclude: vtkWebGPUBindGroupInternals.h
static WGPUBindGroup MakeBindGroup(const WGPUDevice &device, const WGPUBindGroupLayout &layout, std::initializer_list< BindingInitializationHelper > entriesInitializer, std::string label="")
Creates a bind group given the bind group layout and a list of BindGroupEntry.
static WGPUBindGroup MakeBindGroup(const WGPUDevice &device, const WGPUBindGroupLayout &layout, const std::vector< WGPUBindGroupEntry > &entries, std::string label="")
Creates a bind group given the bind group layout and a list of BindGroupEntry.
BindingInitializationHelper(uint32_t binding, WGPUSampler sampler)
BindingInitializationHelper(const BindingInitializationHelper &)
BindingInitializationHelper(uint32_t binding, WGPUBuffer buffer, uint64_t offset=0, uint64_t size=WGPU_WHOLE_SIZE)
BindingInitializationHelper(uint32_t binding, WGPUTextureView textureView)