VTK  9.4.20241112
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:
103
104private:
106 void operator=(const vtkWebGPUComputeTexture&) = delete;
107
108 // Total size of the texture in bytes
109 vtkIdType ByteSize = -1;
110
111 // The type of data that will be uploaded to the GPU
113
114 // Pointer to the data that this buffer will contain. This variable DataPointer is only used when
115 // the user set the buffer data (with SetData()) using an std::vector.
116 const void* DataPointer = nullptr;
117 // Data array containing the data that will be uploaded to the buffer. Only relevant if the user
118 // called SetData(vtkDataArray).
119 vtkDataArray* DataArray = nullptr;
120
121 // Label used for debugging if something goes wrong.
122 std::string Label = "Compute texture";
123};
124
125VTK_ABI_NAMESPACE_END
126
127#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)
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 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