VTK  9.7.20261205
vtkWebGPUAMRMapperInternals.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 vtkWebGPUAMRMapperInternals_h
5#define vtkWebGPUAMRMapperInternals_h
6
7#include "vtkAMRToBricksHelper.h" // ExaBricks cache + NewForInput factory
8#include "vtkObject.h"
9#include "vtkRenderingWebGPUModule.h"
10#include "vtkSmartPointer.h"
11#include "vtkTimeStamp.h"
15#include "vtk_wgpu.h"
16
17class vtkDataObject;
18class vtkRenderer;
19class vtkVolume;
24
25VTK_ABI_NAMESPACE_BEGIN
26
38class VTKRENDERINGWEBGPU_NO_EXPORT vtkWebGPUAMRMapperInternals : public vtkObject
39{
40public:
43
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47 void SetInput(vtkDataObject* input);
48
50 void SetInterfaceRenderEnabled(bool enabled) { this->InterfaceRenderEnabled = enabled; }
51
53 void SetSamplingRate(double scale) { this->SamplingRate = scale; }
54
56 void SetMaxTraversalDepth(unsigned int depth) { this->MaxTraversalDepth = depth; }
57
58 // Per-frame: rebuild bricks if the input changed, upload, dispatch.
59 void Render(vtkRenderer* renderer, vtkVolume* vol);
60
61protected:
64
65 // Rebuild CachedBricks when Input's MTime is newer than BuildTime.
67 // Upload CachedBricks to the compute buffers when BuildTime > UploadTime.
69
70private:
72 void operator=(const vtkWebGPUAMRMapperInternals&) = delete;
73
74 friend class vtkWebGPUAMRMapper;
75
76 vtkDataObject* Input = nullptr;
77
78 bool InterfaceRenderEnabled = true;
79 double SamplingRate = 1.0;
80 unsigned int MaxTraversalDepth = 0;
81
82 // Caching: ExaBricks result + helper + timestamps guarding rebuild/upload
85 vtkTimeStamp BuildTime;
86 vtkTimeStamp UploadTime;
87
88 // Compute pipeline + pass ("HTG main compute pass")
91
92 // Storage buffers, created on first upload, updated on rebuild.
93 // Index = position in the pass's buffer list (-1 = not yet added).
94 vtkSmartPointer<vtkWebGPUComputeBuffer> ScalarsBuffer; // binding 0
95 int ScalarsBufferIndex = -1;
96 vtkSmartPointer<vtkWebGPUComputeBuffer> BricksBuffer; // binding 1
97 int BricksBufferIndex = -1;
98 vtkSmartPointer<vtkWebGPUComputeBuffer> ABRBuffer; // binding 2
99 int ABRBufferIndex = -1;
100 vtkSmartPointer<vtkWebGPUComputeBuffer> ABRBrickListsBuffer; // binding 7
101 int ABRBrickListsBufferIndex = -1;
102 vtkSmartPointer<vtkWebGPUComputeBuffer> InterfaceBuffer; // binding 8
103 int InterfaceBufferIndex = -1;
104 vtkSmartPointer<vtkWebGPUComputeBuffer> BVHBuffer; // binding 6
105 int BVHBufferIndex = -1;
106
107 // Camera uniform (binding 4)
109 int CameraBufferIndex = -1;
110
112 int ParamsBufferIndex = -1;
113
114 // Transfer function as a 256-entry RGBA8 lookup texture (binding 5)
117 int ColorTableTextureIndex = -1;
118 const int ColorTableSize = 256;
119
120 // Track TF MTimes so the LUT texture and ABR max-opacity values are only
121 // rebuilt/re-uploaded when the transfer functions actually changed.
122 unsigned long ColorTransferFunctionMTime = 0;
123 unsigned long TransferFunctionMTime = 0;
124
125 // Domain normalization cached at upload time (needed to re-upload ABRs
126 // when only the transfer function changed).
127 double GlobalMin[3] = { 0.0, 0.0, 0.0 };
128 double GlobalExtent[3] = { 1.0, 1.0, 1.0 };
129
130 // Compute output written straight into the framebuffer (binding 3)
131 vtkSmartPointer<vtkWebGPUComputeRenderTexture> FramebufferRenderTexture;
132
133 int LastWindowSize[2] = { 0, 0 };
134};
135VTK_ABI_NAMESPACE_END
136
137#endif
general representation of visualization data
a simple class to control print indentation
Definition vtkIndent.h:108
abstract specification for renderers
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
represents a volume (data & properties) in a rendered scene
Definition vtkVolume.h:130
void Render(vtkRenderer *renderer, vtkVolume *vol)
~vtkWebGPUAMRMapperInternals() override
void SetInput(vtkDataObject *input)
Single input path for HTG and OverlappingAMR: picks the helper via the factory.
void SetMaxTraversalDepth(unsigned int depth)
Max AMR level traversed during brick building (0 = unlimited).
static vtkWebGPUAMRMapperInternals * New()
void SetInterfaceRenderEnabled(bool enabled)
Clip mixed cells against their interface planes (off = treat all as pure).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetSamplingRate(double scale)
Scale factor on the base sampling rate (1.0 = two samples per finest cell).
Represents the set of parameters that will be used to create a compute shader buffer on the device wh...
A compute pass is an abstraction for offloading computation from the CPU onto the GPU using WebGPU co...
A compute pipeline is the orchestrator of a collection of compute passes.
WebGPU rendering window.
Result of BuildBricks: the three structures, ready for GPU upload.