VTK  9.7.20261123
vtkWebGPUVolumeRayCastCoordinatorInternals.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
11
12#ifndef vtkWebGPUVolumeRayCastCoordinatorInternals_h
13#define vtkWebGPUVolumeRayCastCoordinatorInternals_h
14
16
17#include "Private/vtkWebGPUHandle.h" // for the reference counted handle wrappers
20
21#include "vtk_wgpu.h"
22
23#include <array>
24#include <cstdint>
25#include <map>
26#include <vector>
27
28VTK_ABI_NAMESPACE_BEGIN
29
30class vtkRenderer;
32
34{
35public:
37
39 : Self(self)
40 {
41 }
42
47 bool Offer(const vtkWebGPUVolumeRayCastContribution& contribution);
48
50 void Render(vtkWebGPURenderWindow* window, vtkRenderer* renderer);
51
55
56 std::size_t GetNumberOfContributions() const { return this->Contributions.size(); }
57
59 bool WasComplete() const { return this->Complete; }
60
62 bool Rendered = true;
63
67 bool RenderToImage = false;
71 vtkWebGPU::Texture ImageColor;
72 vtkWebGPU::TextureView ImageColorView;
73 vtkWebGPU::Texture ImageDepth;
74 vtkWebGPU::TextureView ImageDepthView;
75 int ImageSize[2] = { 0, 0 };
79 bool ReadImage(vtkWebGPURenderWindow* window, bool depth, int scalarType, vtkImageData* output);
80
81private:
82 void BeginFrame();
84 void ReleaseDeviceResources();
85
86 void UpdateTransferFunctions(vtkWebGPURenderWindow* window);
87 void UpdateCells(vtkWebGPURenderWindow* window);
88 void UpdateResidency(vtkWebGPURenderWindow* window, vtkRenderer* renderer);
89 void UpdateDepthView(vtkWebGPURenderWindow* window);
90 void UpdateUniforms(vtkWebGPURenderWindow* window, vtkRenderer* renderer);
93 void UpdatePropIds(vtkRenderer* renderer);
94 void UpdateTableLayout();
95 void UpdateBindGroup(vtkWebGPURenderWindow* window);
96 void EnsurePipeline(vtkWebGPURenderWindow* window);
97 void EnsurePlaceholders(vtkWebGPURenderWindow* window);
98 void RecordRenderPass(vtkWebGPURenderWindow* window);
99
101 bool VolumesCanOverlap() const;
103 bool AllBlendModesMatch(int& outMode) const;
104
105 vtkWebGPUVolumeRayCastCoordinator* Self = nullptr;
106
107 std::vector<vtkWebGPUVolumeRayCastContribution> Contributions;
108
111 struct LayerState
112 {
113 vtkWebGPUVolumeRayCastMapper* Mapper = nullptr;
114 int Port = -1;
115 vtkMTimeType ContentTime = 0;
116 };
117 std::vector<LayerState> Layers;
118 std::vector<LayerState> CellLayers;
121 std::map<const void*, vtkMTimeType> BrickContent;
123 std::vector<std::uint32_t> PageOffsets;
124 std::vector<std::uint32_t> CellOffsets;
126 std::vector<std::array<int, 3>> PageDimensions;
129 std::vector<std::array<double, 16>> VolumeMatrices;
130
133 bool Complete = true;
136 bool SkipEmptyBricks = false;
137 float EmptyThreshold = 0.0f;
138
139 vtkWebGPU::Buffer GlobalUniformBuffer;
140 vtkWebGPU::Buffer VolumeParamsBuffer;
141 vtkWebGPU::Buffer PageBuffer;
142 std::size_t PageBufferElements = 0;
144 std::vector<unsigned char> PageTable;
145
148 vtkWebGPU::Buffer CellBuffer;
149 std::size_t CellBufferElements = 0;
150
151 vtkWebGPU::Texture ColorTransferFunctions;
152 vtkWebGPU::TextureView ColorTransferFunctionsView;
153 vtkWebGPU::Texture OpacityTransferFunctions;
154 vtkWebGPU::TextureView OpacityTransferFunctionsView;
155 vtkWebGPU::Texture GradientTransferFunctions;
156 vtkWebGPU::TextureView GradientTransferFunctionsView;
158 vtkWebGPU::Texture Transfer2DFunctions;
159 vtkWebGPU::TextureView Transfer2DFunctionsView;
160 std::vector<LayerState> Transfer2DLayers;
161
164 vtkWebGPU::Texture LabelTransferFunctions;
165 vtkWebGPU::TextureView LabelTransferFunctionsView;
166 std::vector<LayerState> LabelLayers;
167 int LabelRows = 0;
168 vtkWebGPU::Sampler TransferFunctionSampler;
169
172 vtkWebGPU::TextureView OpaqueDepthView;
173
177 WGPUDevice DeviceIdentity = nullptr;
178
179 vtkWebGPU::BindGroupLayout BindGroupLayout;
180 vtkWebGPU::BindGroup BindGroup;
181 vtkWebGPU::RenderPipeline Pipeline;
182 WGPUTextureFormat PipelineColorFormat = WGPUTextureFormat_Undefined;
183 bool PipelineRenderToImage = false;
184
185 bool DepthAvailable = false;
187 float ViewportRectangle[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
188 bool DrawFullScreen = false;
189};
190
191VTK_ABI_NAMESPACE_END
192#endif
193// VTK-HeaderTest-Exclude: vtkWebGPUVolumeRayCastCoordinatorInternals.h
topologically and geometrically regular array of data
abstract specification for renderers
WebGPU rendering window.
Fixed size 3D texture that holds the resident bricks of every volume in a pass.
void Forget(vtkWebGPUVolumeRayCastMapper *mapper)
Forget what a mapper contributed, because it is letting go of its resources.
bool Rendered
Whether the pass for this frame has already been recorded.
void EnsureImageTargets(vtkWebGPURenderWindow *window)
bool ReadImage(vtkWebGPURenderWindow *window, bool depth, int scalarType, vtkImageData *output)
Copy one of the two image targets back into output.
void Render(vtkWebGPURenderWindow *window, vtkRenderer *renderer)
March every gathered input and composite the result over the frame, once.
bool WasComplete() const
Whether every brick the last frame wanted was there.
bool Offer(const vtkWebGPUVolumeRayCastContribution &contribution)
Take one input.
bool RenderToImage
Render to image draws the volume alone into textures of this object's own, with the depth of the firs...
vtkWebGPURenderWindow * LastWindow
The window the last pass was drawn with, so the image can be read back afterwards.
GPU ray cast volume mapper for the WebGPU backend.
One input offered up to be ray cast alongside the others.
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:321
Reference-counted ownership for WebGPU C API handles.
constexpr int vtkWebGPUVolumeTransferFunctionSize
Size of every tabulated transfer function, in texels.