VTK  9.3.20240919
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
28private:
32 friend class vtkWebGPURenderer;
33
36 void operator=(const vtkWebGPUComputeRenderBuffer&) = delete;
37
39
43 void SetWebGPUBuffer(wgpu::Buffer buffer) { this->wgpuBuffer = buffer; };
44 wgpu::Buffer GetWebGPUBuffer() { return this->wgpuBuffer; };
46
48
51 vtkGetMacro(PointBufferAttribute, vtkWebGPUPolyDataMapper::PointDataAttributes);
52 vtkSetMacro(PointBufferAttribute, vtkWebGPUPolyDataMapper::PointDataAttributes);
54
56
59 vtkGetMacro(CellBufferAttribute, vtkWebGPUPolyDataMapper::CellDataAttributes);
60 vtkSetMacro(CellBufferAttribute, vtkWebGPUPolyDataMapper::CellDataAttributes);
62
64
68 vtkGetMacro(RenderUniformsBinding, uint32_t);
69 vtkSetMacro(RenderUniformsBinding, uint32_t);
71
73
77 vtkGetMacro(RenderUniformsGroup, uint32_t);
78 vtkSetMacro(RenderUniformsGroup, uint32_t);
80
82
86 vtkGetMacro(RenderBufferOffset, uint32_t);
87 vtkSetMacro(RenderBufferOffset, uint32_t);
89
91
95 vtkGetMacro(RenderBufferElementCount, uint32_t);
96 vtkSetMacro(RenderBufferElementCount, uint32_t);
98
100
103 vtkGetMacro(AssociatedComputePass, vtkWebGPUComputePass*);
104 vtkSetMacro(AssociatedComputePass, vtkWebGPUComputePass*);
107
108 // We may want vtkWebGPUComputePipeline::AddBuffer() not to create a new device buffer for this
109 // vtkWebGPUComputeBuffer but rather use an exisiting one that has been created elsewhere (by a
110 // webGPUPolyDataMapper for example). This is the attribute that points to this 'already existing'
111 // buffer.
112 wgpu::Buffer wgpuBuffer = nullptr;
113
114 // Attribute used when we're reusing an existing buffer (from the vtkWebGPUPolyDataMapper for
115 // example). Can be either a cell attribute or a point attribute but not both at the same time
120
121 // Because ComputeRenderBuffers give access to the whole buffer of point / cell data, we need to
122 // give the user the information on where in the buffer are the colors / normals / uvs / whatever
123 // they requested. The RenderUniformsGroup and RenderUniformsBinding give the binding point of the
124 // uniforms buffer that will contain these pieces of information
125 uint32_t RenderUniformsGroup = -1;
126 uint32_t RenderUniformsBinding = -1;
127
128 // RenderBufferOffset in an offset in bytes for where the requested part of the buffer starts.
129 // RenderBufferElementCount is the number of elements of interest available in the buffer starting
130 // at RenderBufferOffset
131 uint32_t RenderBufferOffset = -1;
132 uint32_t RenderBufferElementCount = -1;
133
134 // Pipeline this render buffer belongs to.
135 // Weak pointer here because the render buffer will also store a pointer to its pipeline. If both
136 // are shared pointers, we have a cyclic dependency.
137 vtkWebGPUComputePass* AssociatedComputePass = nullptr;
138};
139
140VTK_ABI_NAMESPACE_END
141#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()
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.