4 #ifndef vtkWebGPUComputePassInternals_h
5 #define vtkWebGPUComputePassInternals_h
14 #include <unordered_map>
15 #include <unordered_set>
19 VTK_ABI_NAMESPACE_BEGIN
60 wgpu::BindGroupLayoutEntry CreateBindGroupLayoutEntry(
66 wgpu::BindGroupLayoutEntry CreateBindGroupLayoutEntry(uint32_t binding,
76 wgpu::BindGroupLayoutEntry CreateBindGroupLayoutEntry(uint32_t binding,
78 wgpu::TextureViewDimension textureViewDimension);
84 wgpu::BindGroupEntry CreateBindGroupEntry(wgpu::Buffer buffer, uint32_t binding,
91 wgpu::BindGroupEntry CreateBindGroupEntry(uint32_t binding, wgpu::TextureView textureView);
96 void CreateShaderModule();
102 void CreateBindGroupsAndLayouts();
108 static wgpu::BindGroupLayout CreateBindGroupLayout(
109 const wgpu::Device& device,
const std::vector<wgpu::BindGroupLayoutEntry>& layoutEntries);
114 std::vector<wgpu::BindGroupEntry> CreateBindGroupEntries(
115 const std::vector<vtkWebGPUComputeBuffer*>& buffers);
126 bool CheckBufferIndex(
int bufferIndex,
const std::string& callerFunctionName);
133 bool CheckTextureIndex(
int textureIndex,
const std::string& callerFunctionName);
140 bool CheckTextureViewIndex(
int textureViewIndex,
const std::string& callerFunctionName);
155 void RecreateBufferBindGroup(
int bufferIndex);
161 void RegisterBufferToPipeline(
172 bool GetRegisteredBufferFromPipeline(
175 bool GetRegisteredTextureFromPipeline(
183 wgpu::Buffer GetWGPUBuffer(std::size_t bufferIndex);
189 void RegisterTextureToPipeline(
196 void RecreateBuffer(
int bufferIndex,
vtkIdType newByteSize);
201 void RecreateTexture(
int textureIndex);
210 void RecreateTextureViews(
int textureIndex);
216 wgpu::TextureView CreateWebGPUTextureView(
236 void UpdateComputeTextureAndViews(
243 void RecreateTextureBindGroup(
int textureIndex);
264 void CreateWebGPUComputePipeline();
273 wgpu::PipelineLayout CreateWebGPUComputePipelineLayout();
278 wgpu::CommandEncoder CreateCommandEncoder();
283 wgpu::ComputePassEncoder CreateComputePassEncoder(
const wgpu::CommandEncoder& commandEncoder);
291 void WebGPUDispatch(
unsigned int groupsX,
unsigned int groupsY,
unsigned int groupsZ);
297 void SubmitCommandEncoderToQueue(
const wgpu::CommandEncoder& commandEncoder);
302 void ReleaseResources();
326 bool Initialized =
false;
330 bool BindGroupOrLayoutsInvalidated =
true;
338 wgpu::ShaderModule ShaderModule;
340 std::vector<wgpu::BindGroup> BindGroups;
343 std::unordered_map<int, std::vector<wgpu::BindGroupEntry>> BindGroupEntries;
344 std::vector<wgpu::BindGroupLayout> BindGroupLayouts;
347 std::unordered_map<int, std::vector<wgpu::BindGroupLayoutEntry>> BindGroupLayoutEntries;
349 wgpu::ComputePipeline ComputePipeline;
359 VTK_ABI_NAMESPACE_END
Internals of the vtkWebGPUComputePass.
abstract base class for most VTK objects
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Hold a reference to a vtkObjectBase instance.
Internal implementation details of vtkWebGPUPointCloudMapper.
a simple class to control print indentation
This class manages the creation/deletion/recreation/resizing/updating of compute buffers used by a co...
vtkWeakPointer< vtkWebGPUComputePass > ParentPass
Create a webgpu device for use in rendering and compute pipelines.
A compute pipeline is the orchestrator of a collection of compute passes.
This class manages the creation/deletion/recreation/ of compute textures used by a compute pass...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
A compute pass is an abstraction for offloading computation from the CPU onto the GPU using WebGPU co...