VTK  9.3.20240919
vtkWebGPUComputeTexture.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 vtkWebGPUComputeTexture_h
5#define vtkWebGPUComputeTexture_h
6
7#include "vtkDataArray.h" // for vtkDataArray used in SetData
8#include "vtkLogger.h" // for the logger
9#include "vtkRenderingWebGPUModule.h" // For export macro
10#include "vtkWebGPUTexture.h"
11#include "vtk_wgpu.h" // for dawn classes
12
13VTK_ABI_NAMESPACE_BEGIN
14
16
28class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUComputeTexture : public vtkWebGPUTexture
29{
30public:
33
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35
37
40 vtkGetMacro(ByteSize, vtkIdType);
41 vtkSetMacro(ByteSize, vtkIdType);
43
51 template <typename T>
52 void SetData(const std::vector<T>& data)
53 {
54 this->DataPointer = data.data();
55 this->ByteSize = data.size() * sizeof(T);
56 }
57
65 void SetData(vtkDataArray* data);
66
68
71 vtkGetMacro(DataType, TextureDataType);
72 vtkSetMacro(DataType, TextureDataType);
74
81 const void* GetDataPointer() { return this->DataPointer; }
82
89 vtkDataArray* GetDataArray() { return this->DataArray; }
90
92
95 const std::string& GetLabel() const { return this->Label; }
96 vtkGetMacro(Label, std::string&);
97 vtkSetMacro(Label, std::string);
99
100protected:
104 void operator=(const vtkWebGPUComputeTexture&) = delete;
105
106private:
107 // Total size of the texture in bytes
108 vtkIdType ByteSize = -1;
109
110 // The type of data that will be uploaded to the GPU
112
113 // Pointer to the data that this buffer will contain. This variable DataPointer is only used when
114 // the user set the buffer data (with SetData()) using an std::vector.
115 const void* DataPointer = nullptr;
116 // Data array containing the data that will be uploaded to the buffer. Only relevant if the user
117 // called SetData(vtkDataArray).
118 vtkDataArray* DataArray = nullptr;
119
120 // Label used for debugging if something goes wrong.
121 std::string Label = "Compute texture";
122};
123
124VTK_ABI_NAMESPACE_END
125
126#endif
abstract superclass for arrays of numeric data
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Represents the set of parameters that will be used to create a compute shader texture on the device w...
const std::string & GetLabel() const
Get/set the label used for debugging in case of errors.
static vtkWebGPUComputeTexture * New()
void SetData(const std::vector< T > &data)
Sets the data that will be used by the texture.
vtkDataArray * GetDataArray()
The pointer to the vtkDataArray passed with SetData(vtkDataArray)
vtkWebGPUComputeTexture(const vtkWebGPUComputeTexture &)=delete
const void * GetDataPointer()
The pointer to the std::vector<> data passed with SetData(std::vector)
~vtkWebGPUComputeTexture() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void operator=(const vtkWebGPUComputeTexture &)=delete
void SetData(vtkDataArray *data)
Sets the data that will be used by the texture.
Abstraction class for WebGPU textures.
TextureDataType
Because the compute texture can accept multiple data types as input (std::vector, vtkDataArray) but w...
int vtkIdType
Definition vtkType.h:315