VTK  9.7.20261125
vtkWebGPUDeepFramebuffer.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
29
30#ifndef vtkWebGPUDeepFramebuffer_h
31#define vtkWebGPUDeepFramebuffer_h
32
33#include "vtkObject.h"
34
35#include "vtkRenderingWebGPUModule.h" // for export macro
36#include "vtkSmartPointer.h" // for ivar
37#include "vtk_wgpu.h" // for the WebGPU C API
38
39#include <cstdint> // for fixed width types
40#include <memory> // for asynchronous readback state
41
42VTK_ABI_NAMESPACE_BEGIN
44
45class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUDeepFramebuffer : public vtkObject
46{
47public:
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
57 vtkGetMacro(AverageLayersPerPixel, vtkTypeUInt32);
58 vtkSetClampMacro(AverageLayersPerPixel, vtkTypeUInt32, 1, 64);
59
61
62 vtkSetMacro(MaximumMemoryInBytes, vtkTypeUInt64);
63 vtkGetMacro(MaximumMemoryInBytes, vtkTypeUInt64);
65
67
72 vtkSetMacro(AutoResize, bool);
73 vtkGetMacro(AutoResize, bool);
74 vtkBooleanMacro(AutoResize, bool);
76
78
82 vtkSetClampMacro(StatisticsInterval, int, 1, 64);
83 vtkGetMacro(StatisticsInterval, int);
85
88
99
106 VTK_MAYSUSPEND int ReadStatistics(bool wait = false);
107 vtkGetMacro(LastFrameStatus, int);
108 vtkGetMacro(LastFragmentCount, vtkTypeUInt32);
109 vtkGetMacro(MaximumFragmentNodeCapacity, vtkTypeUInt32);
110
115
122 VTK_MAYSUSPEND bool Resize(int width, int height);
123
128 void Clear();
129
134 WGPUBuffer GetHeadPointersBuffer() { return this->HeadPointersBuffer; }
135 WGPUBuffer GetFragmentNodesBuffer() { return this->FragmentNodesBuffer; }
136 WGPUBuffer GetFragmentCounterBuffer() { return this->FragmentCounterBuffer; }
137
141 vtkGetMacro(Width, int);
142 vtkGetMacro(Height, int);
143 vtkGetMacro(FragmentNodeCapacity, vtkTypeUInt32);
144 vtkGetMacro(AllocationGeneration, vtkTypeUInt64);
145
150
151protected:
154
155private:
160 static constexpr std::uint32_t FragmentNodeSize = 28;
161
165 static constexpr std::uint32_t InvalidIndex = 0xFFFFFFFFu;
166
168 void operator=(const vtkWebGPUDeepFramebuffer&) = delete;
169
171
172 WGPUBuffer HeadPointersBuffer = nullptr;
173 WGPUBuffer FragmentNodesBuffer = nullptr;
174 WGPUBuffer FragmentCounterBuffer = nullptr;
175 WGPUBuffer StatisticsReadbackBuffer = nullptr;
176
177 int Width = 0;
178 int Height = 0;
179 std::uint32_t AverageLayersPerPixel = 8;
180 std::uint32_t FragmentNodeCapacity = 0;
181 vtkTypeUInt64 MaximumMemoryInBytes = 0;
182 vtkTypeUInt64 AllocationGeneration = 0;
183 vtkTypeUInt32 MaximumFragmentNodeCapacity = 0;
184 vtkTypeUInt32 FailedGrowthCapacity = 0;
185 bool AutoResize = true;
186 int StatisticsInterval = 8;
187 vtkTypeUInt32 AllocatedAverageLayers = 0;
188 vtkTypeUInt64 AllocatedMemoryLimit = 0;
189 vtkTypeUInt64 FrameNumber = 0;
190 int LastFrameStatus = Pending;
191 vtkTypeUInt32 LastFragmentCount = 0;
192 int WarnedStatus = Complete;
193 struct Readback;
194 std::shared_ptr<Readback> Statistics;
195 void UpdateStatistics();
196};
197VTK_ABI_NAMESPACE_END
198
199#endif
a simple class to control print indentation
Definition vtkIndent.h:108
Hold a reference to a vtkObjectBase instance.
Create a webgpu device for use in rendering and compute pipelines.
~vtkWebGPUDeepFramebuffer() override
static vtkWebGPUDeepFramebuffer * New()
void SetWGPUConfiguration(vtkWebGPUConfiguration *config)
The configuration used to allocate the buffers.
VTK_MAYSUSPEND int ReadStatistics(bool wait=false)
Read statistics after the frame's commands have been submitted.
VTK_MAYSUSPEND void ReleaseGraphicsResources()
Release the buffers.
void Clear()
Reset the counter to zero and every head pointer to InvalidIndex.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
WGPUBuffer GetHeadPointersBuffer()
The buffers, for binding into render and compute passes.
VTK_MAYSUSPEND bool Resize(int width, int height)
Allocate the buffers for a width x height viewport, reallocating only when the dimensions or effectiv...
FrameStatus
Completeness flags for the most recent statistics readback.
VTK_MAYSUSPEND void RequestStatistics()
Request asynchronous feedback at the configured sampling interval.
#define VTK_MAYSUSPEND