VTK  9.4.20250203
vtkWebGPUComputeRenderBuffer.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 vtkWebGPUComputeRenderBuffer_h
5#define vtkWebGPUComputeRenderBuffer_h
6
7#include "vtkRenderingWebGPUModule.h" // For export macro
9#include "vtkWebGPUPolyDataMapper.h" // for the point/cell attributes
10
11VTK_ABI_NAMESPACE_BEGIN
12
14
21class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUComputeRenderBuffer : public vtkWebGPUComputeBuffer
22{
23public:
26 void PrintSelf(ostream& os, vtkIndent indent) override;
27
28protected:
31
32private:
36 friend class vtkWebGPURenderer;
37
39 void operator=(const vtkWebGPUComputeRenderBuffer&) = delete;
40
42
46 void SetWebGPUBuffer(wgpu::Buffer buffer) { this->wgpuBuffer = buffer; };
47 wgpu::Buffer GetWebGPUBuffer() { return this->wgpuBuffer; };
49
51
54 vtkGetMacro(PointBufferAttribute, vtkWebGPUPolyDataMapper::PointDataAttributes);
55 vtkSetMacro(PointBufferAttribute, vtkWebGPUPolyDataMapper::PointDataAttributes);
57
59
62 vtkGetMacro(CellBufferAttribute, vtkWebGPUPolyDataMapper::CellDataAttributes);
63 vtkSetMacro(CellBufferAttribute, vtkWebGPUPolyDataMapper::CellDataAttributes);
65
67
71 vtkGetMacro(RenderUniformsBinding, uint32_t);
72 vtkSetMacro(RenderUniformsBinding, uint32_t);
74
76
80 vtkGetMacro(RenderUniformsGroup, uint32_t);
81 vtkSetMacro(RenderUniformsGroup, uint32_t);
83
85
89 vtkGetMacro(RenderBufferOffset, uint32_t);
90 vtkSetMacro(RenderBufferOffset, uint32_t);
92
94
98 vtkGetMacro(RenderBufferElementCount, uint32_t);
99 vtkSetMacro(RenderBufferElementCount, uint32_t);
101
103
106 vtkGetMacro(AssociatedComputePass, vtkWebGPUComputePass*);
107 vtkSetMacro(AssociatedComputePass, vtkWebGPUComputePass*);
110
111 // We may want vtkWebGPUComputePipeline::AddBuffer() not to create a new device buffer for this
112 // vtkWebGPUComputeBuffer but rather use an exisiting one that has been created elsewhere (by a
113 // webGPUPolyDataMapper for example). This is the attribute that points to this 'already existing'
114 // buffer.
115 wgpu::Buffer wgpuBuffer = nullptr;
116
117 // Attribute used when we're reusing an existing buffer (from the vtkWebGPUPolyDataMapper for
118 // example). Can be either a cell attribute or a point attribute but not both at the same time
123
124 // Because ComputeRenderBuffers give access to the whole buffer of point / cell data, we need to
125 // give the user the information on where in the buffer are the colors / normals / uvs / whatever
126 // they requested. The RenderUniformsGroup and RenderUniformsBinding give the binding point of the
127 // uniforms buffer that will contain these pieces of information
128 uint32_t RenderUniformsGroup = -1;
129 uint32_t RenderUniformsBinding = -1;
130
131 // RenderBufferOffset in an offset in bytes for where the requested part of the buffer starts.
132 // RenderBufferElementCount is the number of elements of interest available in the buffer starting
133 // at RenderBufferOffset
134 uint32_t RenderBufferOffset = -1;
135 uint32_t RenderBufferElementCount = -1;
136
137 // Pipeline this render buffer belongs to.
138 // Weak pointer here because the render buffer will also store a pointer to its pipeline. If both
139 // are shared pointers, we have a cyclic dependency.
140 vtkWebGPUComputePass* AssociatedComputePass = nullptr;
141};
142
143VTK_ABI_NAMESPACE_END
144#endif
a simple class to control print indentation
Definition vtkIndent.h:108
Represents the set of parameters that will be used to create a compute shader buffer on the device wh...
This class manages the creation/deletion/recreation/resizing/updating of compute buffers used by a co...
A compute pass is an abstraction for offloading computation from the CPU onto the GPU using WebGPU co...
Render buffers are returned by calls to vtkWebGPUPolyDataMapper::AcquirePointAttributeComputeRenderBu...
static vtkWebGPUComputeRenderBuffer * New()
~vtkWebGPUComputeRenderBuffer() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
PointDataAttributes
All the attributes supported by the point data buffer.
CellDataAttributes
All the attributes supported by the cell data buffer.